Commit 56c8bfc3 authored by Anna Udovichenko's avatar Anna Udovichenko

changed mPath type in UBFeature class to QUrl

parent dcf9d3be
This diff is collapsed.
This diff is collapsed.
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <QVector> #include <QVector>
#include <QString> #include <QString>
#include <QPixmap> #include <QPixmap>
#include <QMap>
#include <QUrl>
//#include "UBDockPaletteWidget.h" //#include "UBDockPaletteWidget.h"
...@@ -29,25 +31,30 @@ class UBFeature ...@@ -29,25 +31,30 @@ class UBFeature
public: public:
UBFeature() {;} UBFeature() {;}
//UBFeature(const UBFeature &f); //UBFeature(const UBFeature &f);
UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QString &realPath, UBFeatureElementType type = FEATURE_CATEGORY); UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type = FEATURE_CATEGORY);
virtual ~UBFeature() {;} virtual ~UBFeature() {;}
QString getName() const { return mName; } QString getName() const { return mName; }
QPixmap getThumbnail() const {return mThumbnail;} QPixmap getThumbnail() const {return mThumbnail;}
QString getUrl() const { return virtualPath; } QString getVirtualPath() const { return virtualPath; }
//QString getPath() const { return mPath; }; //QString getPath() const { return mPath; };
QString getFullPath() const { return mPath; } QUrl getFullPath() const { return mPath; }
QString getVirtualPath() const { return virtualPath + "/" + mName; } QString getFullVirtualPath() const { return virtualPath + "/" + mName; }
QString getUrl() const;
UBFeatureElementType getType() const { return elementType; } UBFeatureElementType getType() const { return elementType; }
bool isFolder() const; bool isFolder() const;
bool isDeletable() const; bool isDeletable() const;
bool operator ==( const UBFeature &f )const; bool operator ==( const UBFeature &f )const;
bool operator !=( const UBFeature &f )const; bool operator !=( const UBFeature &f )const;
const QMap<QString,QString> & getMetadata() const { return metadata; }
void setMetadata( const QMap<QString,QString> &data ) { metadata = data; }
private: private:
QString virtualPath; QString virtualPath;
QPixmap mThumbnail; QPixmap mThumbnail;
QString mName; QString mName;
QString mPath; QUrl mPath;
UBFeatureElementType elementType; UBFeatureElementType elementType;
QMap<QString,QString> metadata;
}; };
Q_DECLARE_METATYPE( UBFeature ) Q_DECLARE_METATYPE( UBFeature )
...@@ -80,7 +87,7 @@ public: ...@@ -80,7 +87,7 @@ public:
static bool isDeletable( const QUrl &url ); static bool isDeletable( const QUrl &url );
private: private:
void initDirectoryTree(); void initDirectoryTree();
void fileSystemScan(const QString &currPath, const QString & currVirtualPath); void fileSystemScan(const QUrl &currPath, const QString & currVirtualPath);
static QPixmap createThumbnail(const QString &path); static QPixmap createThumbnail(const QString &path);
//void addImageToCurrentPage( const QString &path ); //void addImageToCurrentPage( const QString &path );
void loadFavoriteList(); void loadFavoriteList();
...@@ -92,22 +99,22 @@ private: ...@@ -92,22 +99,22 @@ private:
QList <UBFeature> *featuresList; QList <UBFeature> *featuresList;
UBFeature *rootElement; UBFeature *rootElement;
QString mUserAudioDirectoryPath; QUrl mUserAudioDirectoryPath;
QString mUserVideoDirectoryPath; QUrl mUserVideoDirectoryPath;
QString mUserPicturesDirectoryPath; QUrl mUserPicturesDirectoryPath;
QString mUserInteractiveDirectoryPath; QUrl mUserInteractiveDirectoryPath;
QString mUserAnimationDirectoryPath; QUrl mUserAnimationDirectoryPath;
QString libraryPath; QString libraryPath;
QString mLibAudioDirectoryPath; QUrl mLibAudioDirectoryPath;
QString mLibVideoDirectoryPath; QUrl mLibVideoDirectoryPath;
QString mLibPicturesDirectoryPath; QUrl mLibPicturesDirectoryPath;
QString mLibInteractiveDirectoryPath; QUrl mLibInteractiveDirectoryPath;
QString mLibAnimationDirectoryPath; QUrl mLibAnimationDirectoryPath;
QString mLibApplicationsDirectoryPath; QUrl mLibApplicationsDirectoryPath;
QString mLibShapesDirectoryPath; QUrl mLibShapesDirectoryPath;
QString trashDirectoryPath; QUrl trashDirectoryPath;
QString mLibSearchDirectoryPath; QUrl mLibSearchDirectoryPath;
QString rootPath; QString rootPath;
QString audiosPath; QString audiosPath;
...@@ -132,7 +139,7 @@ private: ...@@ -132,7 +139,7 @@ private:
UBFeature shapesElement; UBFeature shapesElement;
UBFeature webSearchElement; UBFeature webSearchElement;
QSet <QString> *favoriteSet; QSet <QUrl> *favoriteSet;
}; };
......
...@@ -124,6 +124,8 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale ...@@ -124,6 +124,8 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ), connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ),
this, SLOT( currentPathChanged( const QModelIndex & ) ) ); this, SLOT( currentPathChanged( const QModelIndex & ) ) );
connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) ); connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) );
connect( UBApplication::boardController, SIGNAL( displayMetadata( QMap<QString,QString> ) ),
this, SLOT( onDisplayMetadata( QMap<QString,QString> ) ) );
} }
bool UBFeaturesWidget::eventFilter( QObject *target, QEvent *event ) bool UBFeaturesWidget::eventFilter( QObject *target, QEvent *event )
...@@ -165,7 +167,7 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current) ...@@ -165,7 +167,7 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
if ( feature.isFolder() ) if ( feature.isFolder() )
{ {
QString newPath = feature.getUrl() + "/" + feature.getName(); QString newPath = feature.getFullVirtualPath();
//pathViewer->addPathElement( feature.getThumbnail(), newPath ); //pathViewer->addPathElement( feature.getThumbnail(), newPath );
controller->setCurrentElement( feature ); controller->setCurrentElement( feature );
...@@ -208,7 +210,7 @@ void UBFeaturesWidget::currentPathChanged(const QModelIndex &index) ...@@ -208,7 +210,7 @@ void UBFeaturesWidget::currentPathChanged(const QModelIndex &index)
if ( index.isValid() ) if ( index.isValid() )
{ {
UBFeature feature = featuresPathModel->data(index, Qt::UserRole + 1).value<UBFeature>(); UBFeature feature = featuresPathModel->data(index, Qt::UserRole + 1).value<UBFeature>();
QString newPath = feature.getUrl() + "/" + feature.getName(); QString newPath = feature.getFullVirtualPath();
featuresPathModel->setPath( newPath ); featuresPathModel->setPath( newPath );
featuresPathModel->invalidate(); featuresPathModel->invalidate();
...@@ -281,7 +283,7 @@ void UBFeaturesWidget::addToFavorite( const QMimeData & mimeData ) ...@@ -281,7 +283,7 @@ void UBFeaturesWidget::addToFavorite( const QMimeData & mimeData )
foreach ( QUrl url, urls ) foreach ( QUrl url, urls )
{ {
UBFeature elem = controller->addToFavorite( url ); UBFeature elem = controller->addToFavorite( url );
if ( !elem.getUrl().isEmpty() && !elem.getUrl().isNull() ) if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() )
featuresModel->addItem( elem ); featuresModel->addItem( elem );
} }
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() ); QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
...@@ -305,6 +307,16 @@ void UBFeaturesWidget::thumbnailSizeChanged( int value ) ...@@ -305,6 +307,16 @@ void UBFeaturesWidget::thumbnailSizeChanged( int value )
featuresListView->setGridSize( QSize( value * 1.75, value * 1.75 ) ); featuresListView->setGridSize( QSize( value * 1.75, value * 1.75 ) );
} }
void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
{
UBFeature feature( QString(), QPixmap(":images/libpalette/notFound.png"), QString(), metadata["Url"], FEATURE_ITEM );
feature.setMetadata( metadata );
featureProperties->showElement( feature );
switchToProperties();
mActionBar->setCurrentState( IN_PROPERTIES );
}
void UBFeaturesWidget::switchToListView() void UBFeaturesWidget::switchToListView()
{ {
stackedWidget->setCurrentIndex(ID_LISTVIEW); stackedWidget->setCurrentIndex(ID_LISTVIEW);
...@@ -441,7 +453,7 @@ UBFeaturesWebView::~UBFeaturesWebView() ...@@ -441,7 +453,7 @@ UBFeaturesWebView::~UBFeaturesWebView()
void UBFeaturesWebView::showElement(const UBFeature &elem) void UBFeaturesWebView::showElement(const UBFeature &elem)
{ {
QString qsWidgetName; QString qsWidgetName;
QString path = elem.getFullPath(); QString path = elem.getFullPath().toLocalFile();
QString qsConfigPath = QString("%0/config.xml").arg(path); QString qsConfigPath = QString("%0/config.xml").arg(path);
...@@ -490,6 +502,7 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) : ...@@ -490,6 +502,7 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
, mpThumbnail(NULL) , mpThumbnail(NULL)
, mpOrigPixmap(NULL) , mpOrigPixmap(NULL)
, mpElement(NULL) , mpElement(NULL)
, mpObjInfos(NULL)
{ {
setObjectName(name); setObjectName(name);
...@@ -529,10 +542,19 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) : ...@@ -529,10 +542,19 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
mpButtonLayout->addStretch(1); mpButtonLayout->addStretch(1);
mpObjInfoLabel = new QLabel(tr("Object informations")); mpObjInfoLabel = new QLabel(tr("Object informations"));
mpObjInfoLabel->setStyleSheet(QString("color: #888888; font-size : 18px; font-weight:bold;")); mpObjInfoLabel->setStyleSheet(QString("color: #888888; font-size : 18px; font-weight:bold;"));
mpLayout->addWidget(mpObjInfoLabel, 0); mpLayout->addWidget(mpObjInfoLabel, 0);
mpObjInfos = new QTreeWidget(this);
mpObjInfos->setColumnCount(2);
mpObjInfos->header()->hide();
mpObjInfos->setAlternatingRowColors(true);
mpObjInfos->setRootIsDecorated(false);
mpObjInfos->setObjectName("DockPaletteWidgetBox");
mpObjInfos->setStyleSheet("background:white;");
mpLayout->addWidget(mpObjInfos, 1);
connect(mpAddPageButton, SIGNAL(clicked()), this, SLOT(onAddToPage())); connect(mpAddPageButton, SIGNAL(clicked()), this, SLOT(onAddToPage()));
} }
...@@ -552,46 +574,65 @@ void UBFeatureProperties::showElement( const UBFeature &elem ) ...@@ -552,46 +574,65 @@ void UBFeatureProperties::showElement( const UBFeature &elem )
mpElement = new UBFeature( elem ); mpElement = new UBFeature( elem );
mpOrigPixmap = new QPixmap( elem.getThumbnail() ); mpOrigPixmap = new QPixmap( elem.getThumbnail() );
mpThumbnail->setPixmap(elem.getThumbnail().scaledToWidth(THUMBNAIL_WIDTH)); mpThumbnail->setPixmap(elem.getThumbnail().scaledToWidth(THUMBNAIL_WIDTH));
//populateMetadata(); populateMetadata();
if ( UBApplication::isFromWeb( elem.getUrl() ) ) if ( UBApplication::isFromWeb( elem.getFullPath().toString() ) )
{ {
mpAddToLibButton->show(); mpAddToLibButton->show();
/*if(elem->metadatas()["Type"].toLower().contains("image")) if( elem.getMetadata()["Type"].toLower().contains("image") )
{ {
mpSetAsBackgroundButton->show(); mpSetAsBackgroundButton->show();
} }
else else
{ {
mpSetAsBackgroundButton->hide(); mpSetAsBackgroundButton->hide();
}*/ }
} }
else else
{ {
mpAddToLibButton->hide(); mpAddToLibButton->hide();
if (UBFileSystemUtils::mimeTypeFromFileName( elem.getUrl() ).contains("image")) if (UBFileSystemUtils::mimeTypeFromFileName( elem.getFullPath().toLocalFile() ).contains("image"))
{ {
mpSetAsBackgroundButton->show(); mpSetAsBackgroundButton->show();
} }
else else
{ {
mpSetAsBackgroundButton->hide(); mpSetAsBackgroundButton->hide();
} }
} }
} }
void UBFeatureProperties::populateMetadata()
{
if(NULL != mpObjInfos){
mpObjInfos->clear();
QMap<QString, QString> metas = mpElement->getMetadata();
QList<QString> lKeys = metas.keys();
QList<QString> lValues = metas.values();
for(int i=0; i< metas.size(); i++){
QStringList values;
values << lKeys.at(i);
values << lValues.at(i);
mpItem = new QTreeWidgetItem(values);
mpObjInfos->addTopLevelItem(mpItem);
}
mpObjInfos->resizeColumnToContents(0);
}
}
void UBFeatureProperties::onAddToPage() void UBFeatureProperties::onAddToPage()
{ {
QWidget *w = parentWidget()->parentWidget(); QWidget *w = parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = dynamic_cast<UBFeaturesWidget*>( w ); UBFeaturesWidget* featuresWidget = dynamic_cast<UBFeaturesWidget*>( w );
featuresWidget->getFeaturesController()->addItemToPage( *mpElement ); featuresWidget->getFeaturesController()->addItemToPage( *mpElement );
/*if ( UBApplication::isFromWeb( mpElement->getUrl() ) ) /*if ( UBApplication::isFromWeb( mpElement->getVirtualPath() ) )
{ {
sDownloadFileDesc desc; sDownloadFileDesc desc;
desc.isBackground = false; desc.isBackground = false;
desc.modal = true; desc.modal = true;
desc.name = QFileInfo( mpElement->getName() ).fileName(); desc.name = QFileInfo( mpElement->getName() ).fileName();
desc.url = mpElement->getUrl(); desc.url = mpElement->getVirtualPath();
UBDownloadManager::downloadManager()->addFileToDownload(desc); UBDownloadManager::downloadManager()->addFileToDownload(desc);
} }
...@@ -641,7 +682,7 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const ...@@ -641,7 +682,7 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
} }
else if (role == Qt::UserRole) else if (role == Qt::UserRole)
{ {
return featuresList->at(index.row()).getUrl(); return featuresList->at(index.row()).getVirtualPath();
} }
else if (role == Qt::UserRole + 1) else if (role == Qt::UserRole + 1)
{ {
...@@ -669,7 +710,7 @@ QMimeData* UBFeaturesModel::mimeData(const QModelIndexList &indexes) const ...@@ -669,7 +710,7 @@ QMimeData* UBFeaturesModel::mimeData(const QModelIndexList &indexes) const
} }
else if ( element.getType() == FEATURE_INTERACTIVE || element.getType() == FEATURE_ITEM ) else if ( element.getType() == FEATURE_INTERACTIVE || element.getType() == FEATURE_ITEM )
{ {
urlList.push_back( QUrl::fromLocalFile(element.getFullPath()) ); urlList.push_back( element.getFullPath() );
} }
} }
} }
...@@ -731,8 +772,8 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path ) ...@@ -731,8 +772,8 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path )
{ {
for ( int i = 0; i < featuresList->size(); ++i ) for ( int i = 0; i < featuresList->size(); ++i )
{ {
if ( !QString::compare( featuresList->at(i).getFullPath(), path, Qt::CaseInsensitive ) && if ( !QString::compare( featuresList->at(i).getUrl(), path, Qt::CaseInsensitive ) &&
!QString::compare( featuresList->at(i).getUrl(), "/root/favorites", Qt::CaseInsensitive ) ) !QString::compare( featuresList->at(i).getVirtualPath(), "/root/favorites", Qt::CaseInsensitive ) )
{ {
removeRow( i, QModelIndex() ); removeRow( i, QModelIndex() );
return; return;
...@@ -776,7 +817,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const ...@@ -776,7 +817,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
item.getType() == FEATURE_ITEM || item.getType() == FEATURE_ITEM ||
item.getType() == FEATURE_INTERNAL ) item.getType() == FEATURE_INTERNAL )
return Qt::ItemIsDragEnabled | defaultFlags; return Qt::ItemIsDragEnabled | defaultFlags;
if ( item.isFolder() && !item.getFullPath().isNull() ) if ( item.isFolder() && !item.getVirtualPath().isNull() )
return defaultFlags | Qt::ItemIsDropEnabled; return defaultFlags | Qt::ItemIsDropEnabled;
else return defaultFlags | Qt::ItemIsDropEnabled; else return defaultFlags | Qt::ItemIsDropEnabled;
} }
...@@ -846,9 +887,8 @@ bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelInde ...@@ -846,9 +887,8 @@ bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelInde
eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/ eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>(); UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>();
QString virtualFullPath = feature.getUrl() + "/" + feature.getName();
return feature.isFolder() && path.startsWith( virtualFullPath ); return feature.isFolder() && path.startsWith( feature.getFullVirtualPath() );
} }
QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLocale & locale ) const QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLocale & locale ) const
......
...@@ -99,6 +99,7 @@ private slots: ...@@ -99,6 +99,7 @@ private slots:
void addToFavorite( const QMimeData & ); void addToFavorite( const QMimeData & );
void removeFromFavorite( const QMimeData & ); void removeFromFavorite( const QMimeData & );
void thumbnailSizeChanged( int ); void thumbnailSizeChanged( int );
void onDisplayMetadata( QMap<QString,QString> );
protected: protected:
bool eventFilter(QObject *target, QEvent *event); bool eventFilter(QObject *target, QEvent *event);
}; };
...@@ -160,18 +161,20 @@ private slots: ...@@ -160,18 +161,20 @@ private slots:
//void onBack(); //void onBack();
private: private:
void populateMetadata();
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
QHBoxLayout* mpButtonLayout; QHBoxLayout* mpButtonLayout;
UBFeatureItemButton* mpAddPageButton; UBFeatureItemButton* mpAddPageButton;
UBFeatureItemButton* mpAddToLibButton; UBFeatureItemButton* mpAddToLibButton;
UBFeatureItemButton* mpSetAsBackgroundButton; UBFeatureItemButton* mpSetAsBackgroundButton;
QLabel* mpObjInfoLabel; QLabel* mpObjInfoLabel;
//QTreeWidget* mpObjInfos; QTreeWidget* mpObjInfos;
QLabel* mpThumbnail; QLabel* mpThumbnail;
QPixmap* mpOrigPixmap; QPixmap* mpOrigPixmap;
int maxThumbHeight; int maxThumbHeight;
UBFeature *mpElement; UBFeature *mpElement;
//QTreeWidgetItem* mpItem; QTreeWidgetItem* mpItem;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment