From 4150279b9fb146089106ef4a36e8db2cea914951 Mon Sep 17 00:00:00 2001 From: Anna Udovichenko Date: Tue, 8 May 2012 14:41:04 +0300 Subject: [PATCH 1/5] Implemented removing selected items from favorite --- src/gui/UBFeaturesActionBar.cpp | 6 ++++++ src/gui/UBFeaturesActionBar.h | 2 ++ src/gui/UBFeaturesWidget.cpp | 27 ++++++++++++++++++++++++--- src/gui/UBFeaturesWidget.h | 3 +++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/gui/UBFeaturesActionBar.cpp b/src/gui/UBFeaturesActionBar.cpp index 8311bfc9..7d1f092d 100644 --- a/src/gui/UBFeaturesActionBar.cpp +++ b/src/gui/UBFeaturesActionBar.cpp @@ -77,6 +77,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString))); connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder())); + connect(mpRemoveFavorite, SIGNAL(triggered()), this, SLOT(onActionRemoveFavorite())); // Build the default toolbar mLayout->addWidget(mpFavoriteBtn); @@ -175,6 +176,11 @@ void UBFeaturesActionBar::onActionFavorite() emit addElementsToFavorite(); } +void UBFeaturesActionBar::onActionRemoveFavorite() +{ + emit removeElementsFromFavorite(); +} + /* void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event) { diff --git a/src/gui/UBFeaturesActionBar.h b/src/gui/UBFeaturesActionBar.h index 7aec99a9..deea070f 100644 --- a/src/gui/UBFeaturesActionBar.h +++ b/src/gui/UBFeaturesActionBar.h @@ -31,10 +31,12 @@ signals: void addToFavorite( const QMimeData &data ); void removeFromFavorite( const QMimeData &data ); void addElementsToFavorite(); + void removeElementsFromFavorite(); private slots: void onSearchTextChanged(QString txt); void onActionNewFolder(); void onActionFavorite(); + void onActionRemoveFavorite(); protected: //void dragMoveEvent(QDragMoveEvent *event); void dragEnterEvent( QDragEnterEvent *event ); diff --git a/src/gui/UBFeaturesWidget.cpp b/src/gui/UBFeaturesWidget.cpp index 7a71b555..a8380a69 100644 --- a/src/gui/UBFeaturesWidget.cpp +++ b/src/gui/UBFeaturesWidget.cpp @@ -121,7 +121,8 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale connect( mActionBar, SIGNAL( deleteElements(const QMimeData &) ), this, SLOT( deleteElements(const QMimeData &) ) ); connect( mActionBar, SIGNAL( addToFavorite(const QMimeData &) ), this, SLOT( addToFavorite(const QMimeData &) ) ); connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) ); - connect ( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) ); + connect( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) ); + connect( mActionBar, SIGNAL( removeElementsFromFavorite() ), this, SLOT ( removeElementsFromFavorite() ) ); connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ), this, SLOT( currentPathChanged( const QModelIndex & ) ) ); connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) ); @@ -348,6 +349,25 @@ void UBFeaturesWidget::addElementsToFavorite() model->invalidate(); } +void UBFeaturesWidget::removeElementsFromFavorite() +{ + QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes(); + //qSort( selected.begin(), selected.end(), qGreater() ); + QList items; + for ( int i = 0; i < selected.size(); ++i ) + { + UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value(); + items.append( feature.getFullPath() ); + } + foreach ( QUrl url, items ) + { + controller->removeFromFavorite( url ); + featuresModel->deleteFavoriteItem( url.toString() ); + } + QSortFilterProxyModel *model = dynamic_cast( featuresListView->model() ); + model->invalidate(); +} + void UBFeaturesWidget::switchToListView() { stackedWidget->setCurrentIndex(ID_LISTVIEW); @@ -435,7 +455,7 @@ void UBFeaturesListView::dropEvent( QDropEvent *event ) { event->setDropAction( Qt::MoveAction ); } - QListView::dropEvent( event ); + QListView::dropEvent( event ); } @@ -854,7 +874,7 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path ) { for ( int i = 0; i < featuresList->size(); ++i ) { - if ( !QString::compare( featuresList->at(i).getUrl(), path, Qt::CaseInsensitive ) && + if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) && !QString::compare( featuresList->at(i).getVirtualPath(), "/root/favorites", Qt::CaseInsensitive ) ) { removeRow( i, QModelIndex() ); @@ -889,6 +909,7 @@ bool UBFeaturesModel::removeRow( int row, const QModelIndex & parent ) return true; } + Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const { Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); diff --git a/src/gui/UBFeaturesWidget.h b/src/gui/UBFeaturesWidget.h index 85aaebbd..6050fc33 100644 --- a/src/gui/UBFeaturesWidget.h +++ b/src/gui/UBFeaturesWidget.h @@ -102,6 +102,7 @@ private slots: void onDisplayMetadata( QMap ); void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray); void addElementsToFavorite(); + void removeElementsFromFavorite(); protected: bool eventFilter(QObject *target, QEvent *event); }; @@ -209,6 +210,8 @@ public: bool dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent); bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); bool removeRow(int row, const QModelIndex &parent = QModelIndex()); + //bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()); + //bool insertRow(int row, const QModelIndex &parent = QModelIndex()); Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } From cfa100d2d8f7d2470ac7dab7e3a71c87b9ef21d6 Mon Sep 17 00:00:00 2001 From: Anna Udovichenko Date: Tue, 8 May 2012 17:15:23 +0300 Subject: [PATCH 2/5] Implemented adding to favorite from properties page --- src/gui/UBFeaturesWidget.cpp | 31 +++++++++++++++++++++++++------ src/gui/UBFeaturesWidget.h | 3 +-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/gui/UBFeaturesWidget.cpp b/src/gui/UBFeaturesWidget.cpp index a8380a69..bc675a9f 100644 --- a/src/gui/UBFeaturesWidget.cpp +++ b/src/gui/UBFeaturesWidget.cpp @@ -337,13 +337,25 @@ void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUr void UBFeaturesWidget::addElementsToFavorite() { - QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes(); - for ( int i = 0; i < selected.size(); ++i ) + if ( currentStackedWidget == ID_PROPERTIES ) { - UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value(); - UBFeature elem = controller->addToFavorite( feature.getFullPath() ); - if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() ) - featuresModel->addItem( elem ); + UBFeature feature = featureProperties->getCurrentElement(); + if ( feature != UBFeature() && !UBApplication::isFromWeb( feature.getFullPath().toString() ) ) + { + UBFeature elem = controller->addToFavorite( feature.getFullPath() ); + featuresModel->addItem( elem ); + } + } + else if ( currentStackedWidget == ID_LISTVIEW ) + { + QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes(); + for ( int i = 0; i < selected.size(); ++i ) + { + UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value(); + UBFeature elem = controller->addToFavorite( feature.getFullPath() ); + if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() ) + featuresModel->addItem( elem ); + } } QSortFilterProxyModel *model = dynamic_cast( featuresListView->model() ); model->invalidate(); @@ -629,6 +641,13 @@ void UBFeatureProperties::showEvent (QShowEvent *event ) adaptSize(); } +UBFeature UBFeatureProperties::getCurrentElement() const +{ + if ( mpElement ) + return *mpElement; + return UBFeature(); +} + void UBFeatureProperties::adaptSize() { if( NULL != mpOrigPixmap ) diff --git a/src/gui/UBFeaturesWidget.h b/src/gui/UBFeaturesWidget.h index 6050fc33..0fafc7d9 100644 --- a/src/gui/UBFeaturesWidget.h +++ b/src/gui/UBFeaturesWidget.h @@ -152,8 +152,7 @@ public: ~UBFeatureProperties(); void showElement(const UBFeature &elem); - - + UBFeature getCurrentElement() const; protected: void resizeEvent(QResizeEvent *event); void showEvent(QShowEvent *event); From ccd8e5442c8d5e412ca022a24e0a4b2e35e8313d Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Thu, 10 May 2012 12:19:06 +0300 Subject: [PATCH 3/5] Fixed installation script for windows. Added CFFExportAdaptor; --- Sankore 3.1.iss | 6 +++++- release.win7.vc9.64.bat | 2 +- release.win7.vc9.bat | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Sankore 3.1.iss b/Sankore 3.1.iss index 553f777f..eaeacb68 100644 --- a/Sankore 3.1.iss +++ b/Sankore 3.1.iss @@ -45,7 +45,10 @@ Type: files ; Name: "{app}\*.dll" [Files] Source: "..\Sankore-ThirdParty\microsoft\vcredist_x86.exe"; DestDir:"{tmp}" -Source: ".\build\win32\release\product\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "build\win32\release\product\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs + +;Sankore plugins +Source: "plugins\cffadaptor\build\win32\release\lib\CFF_Adaptor.dll"; DestDir: "{app}"; Flags: ignoreversion ;OpenSSL Source: "..\Sankore-ThirdParty\openssl\win32\libeay32.dll"; DestDir:"{app}"; Flags: ignoreversion @@ -60,6 +63,7 @@ Source: "..\Qt-sankore3.1\lib\QtWebKit4.dll"; DestDir: "{app}"; Flags: ignorever Source: "..\Qt-sankore3.1\lib\phonon4.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\Qt-sankore3.1\lib\QtNetwork4.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\Qt-sankore3.1\lib\QtSvg4.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\Qt-sankore3.1\lib\QtOpenGL4.dll"; DestDir: "{app}"; Flags: ignoreversion ;Qt plugins Source: "..\Qt-sankore3.1\plugins\accessible\qtaccessiblecompatwidgets4.dll"; DestDir: "{app}\accessible"; Flags: ignoreversion diff --git a/release.win7.vc9.64.bat b/release.win7.vc9.64.bat index 810f9b0d..b344d2f8 100644 --- a/release.win7.vc9.64.bat +++ b/release.win7.vc9.64.bat @@ -62,7 +62,7 @@ nmake release-install copy %BASE_QT_TRANSLATIONS_DIRECTORY%\qt_*.qm build\win32\release\product\i18n\ del build\win32\release\product\i18n\qt_help* -del ".\build\win32\release\product\Sankore.pdb" +del "build\win32\release\product\Sankore.pdb" set INSTALLER_NAME=Open-Sankore diff --git a/release.win7.vc9.bat b/release.win7.vc9.bat index 51885958..dbf91aa2 100644 --- a/release.win7.vc9.bat +++ b/release.win7.vc9.bat @@ -66,7 +66,7 @@ copy resources\customizations build\win32\release\product\ del build\win32\release\product\i18n\qt_help* -del ".\build\win32\release\product\Sankore.pdb" +del "build\win32\release\product\Sankore.pdb" set INSTALLER_NAME=Open-Sankore From b484dae47f8b239aa428f1f69cba6ccc59589dd9 Mon Sep 17 00:00:00 2001 From: Anna Udovichenko Date: Thu, 10 May 2012 17:23:50 +0300 Subject: [PATCH 4/5] Implemented removing selected items --- src/gui/UBFeaturesActionBar.cpp | 12 +++++++-- src/gui/UBFeaturesActionBar.h | 2 ++ src/gui/UBFeaturesWidget.cpp | 43 +++++++++++++++++++++++++++++++++ src/gui/UBFeaturesWidget.h | 2 ++ 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/gui/UBFeaturesActionBar.cpp b/src/gui/UBFeaturesActionBar.cpp index 7d1f092d..60900c84 100644 --- a/src/gui/UBFeaturesActionBar.cpp +++ b/src/gui/UBFeaturesActionBar.cpp @@ -66,8 +66,8 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid mButtonGroup->addButton(mpRemoveFavoriteBtn); mButtonGroup->addButton(mpNewFolderBtn); // Connect signals & slots - connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite())); - /*connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial())); + /*connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite())); + connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial())); connect(mpSearchAction,SIGNAL(triggered()), this, SLOT(onActionSearch())); connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash())); connect(mpCloseAction, SIGNAL(triggered()), this, SLOT(onActionClose())); @@ -78,6 +78,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString))); connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder())); connect(mpRemoveFavorite, SIGNAL(triggered()), this, SLOT(onActionRemoveFavorite())); + connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash())); // Build the default toolbar mLayout->addWidget(mpFavoriteBtn); @@ -149,6 +150,8 @@ void UBFeaturesActionBar::setButtons() mpFavoriteBtn->hide(); mpSocialBtn->hide(); mSearchBar->show(); + mpDeleteBtn->show(); + mpDeleteBtn->setEnabled(true); //mpSearchBtn->show(); //mpDeleteBtn->hide(); mpCloseBtn->hide(); @@ -181,6 +184,11 @@ void UBFeaturesActionBar::onActionRemoveFavorite() emit removeElementsFromFavorite(); } +void UBFeaturesActionBar::onActionTrash() +{ + emit deleteSelectedElements(); +} + /* void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event) { diff --git a/src/gui/UBFeaturesActionBar.h b/src/gui/UBFeaturesActionBar.h index deea070f..99664a6d 100644 --- a/src/gui/UBFeaturesActionBar.h +++ b/src/gui/UBFeaturesActionBar.h @@ -32,11 +32,13 @@ signals: void removeFromFavorite( const QMimeData &data ); void addElementsToFavorite(); void removeElementsFromFavorite(); + void deleteSelectedElements(); private slots: void onSearchTextChanged(QString txt); void onActionNewFolder(); void onActionFavorite(); void onActionRemoveFavorite(); + void onActionTrash(); protected: //void dragMoveEvent(QDragMoveEvent *event); void dragEnterEvent( QDragEnterEvent *event ); diff --git a/src/gui/UBFeaturesWidget.cpp b/src/gui/UBFeaturesWidget.cpp index bc675a9f..8ee5e904 100644 --- a/src/gui/UBFeaturesWidget.cpp +++ b/src/gui/UBFeaturesWidget.cpp @@ -123,6 +123,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) ); connect( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) ); connect( mActionBar, SIGNAL( removeElementsFromFavorite() ), this, SLOT ( removeElementsFromFavorite() ) ); + connect( mActionBar, SIGNAL( deleteSelectedElements() ), this, SLOT( deleteSelectedElements() ) ); connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ), this, SLOT( currentPathChanged( const QModelIndex & ) ) ); connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) ); @@ -278,6 +279,36 @@ void UBFeaturesWidget::deleteElements( const QMimeData & mimeData ) model->invalidate(); } +void UBFeaturesWidget::deleteSelectedElements() +{ + QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes(); + QList urls; + foreach ( QModelIndex sel, selected ) + { + UBFeature feature = sel.data( Qt::UserRole + 1 ).value(); + urls.append( feature.getFullPath() ); + } + + foreach (QUrl url, urls) + { + if ( controller->isTrash( url ) ) + { + controller->deleteItem( url ); + } + else + { + UBFeature elem = controller->moveItemToFolder( url, controller->getTrashElement() ); + controller->removeFromFavorite( url ); + featuresModel->addItem( elem ); + featuresModel->deleteFavoriteItem( url.toString() ); + } + featuresModel->deleteItem( url.toString() ); + } + + QSortFilterProxyModel *model = dynamic_cast( featuresListView->model() ); + model->invalidate(); +} + void UBFeaturesWidget::addToFavorite( const QMimeData & mimeData ) { if ( !mimeData.hasUrls() ) @@ -902,6 +933,18 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path ) } } +void UBFeaturesModel::deleteItem( const QString &path ) +{ + for ( int i = 0; i < featuresList->size(); ++i ) + { + if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) ) + { + removeRow( i, QModelIndex() ); + return; + } + } +} + bool UBFeaturesModel::removeRows( int row, int count, const QModelIndex & parent ) { if ( row < 0 ) diff --git a/src/gui/UBFeaturesWidget.h b/src/gui/UBFeaturesWidget.h index 0fafc7d9..8ad8e8a3 100644 --- a/src/gui/UBFeaturesWidget.h +++ b/src/gui/UBFeaturesWidget.h @@ -103,6 +103,7 @@ private slots: void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray); void addElementsToFavorite(); void removeElementsFromFavorite(); + void deleteSelectedElements(); protected: bool eventFilter(QObject *target, QEvent *event); }; @@ -200,6 +201,7 @@ public: void addItem( const UBFeature &item ); void deleteFavoriteItem( const QString &path ); + void deleteItem( const QString &path ); QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; QMimeData *mimeData( const QModelIndexList &indexes ) const; From 88ad16b413990279cc1c64f0940cdb2d5f5d93be Mon Sep 17 00:00:00 2001 From: Anna Udovichenko Date: Thu, 10 May 2012 18:25:47 +0300 Subject: [PATCH 5/5] Fixed signal-slot connecting bug --- src/gui/UBFeaturesActionBar.cpp | 1 + src/gui/UBFeaturesWidget.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/UBFeaturesActionBar.cpp b/src/gui/UBFeaturesActionBar.cpp index 60900c84..a151406d 100644 --- a/src/gui/UBFeaturesActionBar.cpp +++ b/src/gui/UBFeaturesActionBar.cpp @@ -75,6 +75,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString))); connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder()));*/ + connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite())); connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString))); connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder())); connect(mpRemoveFavorite, SIGNAL(triggered()), this, SLOT(onActionRemoveFavorite())); diff --git a/src/gui/UBFeaturesWidget.cpp b/src/gui/UBFeaturesWidget.cpp index 8ee5e904..526fc23d 100644 --- a/src/gui/UBFeaturesWidget.cpp +++ b/src/gui/UBFeaturesWidget.cpp @@ -286,7 +286,8 @@ void UBFeaturesWidget::deleteSelectedElements() foreach ( QModelIndex sel, selected ) { UBFeature feature = sel.data( Qt::UserRole + 1 ).value(); - urls.append( feature.getFullPath() ); + if ( feature.isDeletable() ) + urls.append( feature.getFullPath() ); } foreach (QUrl url, urls)