Implemented adding selected group of elements to favorite

preferencesAboutTextFull
Anna Udovichenko 13 years ago
parent 604ea2faea
commit de0ea916ad
  1. 9
      src/gui/UBFeaturesActionBar.cpp
  2. 2
      src/gui/UBFeaturesActionBar.h
  3. 35
      src/gui/UBFeaturesWidget.cpp
  4. 1
      src/gui/UBFeaturesWidget.h

@ -66,8 +66,8 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
mButtonGroup->addButton(mpRemoveFavoriteBtn); mButtonGroup->addButton(mpRemoveFavoriteBtn);
mButtonGroup->addButton(mpNewFolderBtn); mButtonGroup->addButton(mpNewFolderBtn);
// Connect signals & slots // Connect signals & slots
/*connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite())); connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite()));
connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial())); /*connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial()));
connect(mpSearchAction,SIGNAL(triggered()), this, SLOT(onActionSearch())); connect(mpSearchAction,SIGNAL(triggered()), this, SLOT(onActionSearch()));
connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash())); connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash()));
connect(mpCloseAction, SIGNAL(triggered()), this, SLOT(onActionClose())); connect(mpCloseAction, SIGNAL(triggered()), this, SLOT(onActionClose()));
@ -170,6 +170,11 @@ void UBFeaturesActionBar::onActionNewFolder()
emit newFolderToCreate(); emit newFolderToCreate();
} }
void UBFeaturesActionBar::onActionFavorite()
{
emit addElementsToFavorite();
}
/* /*
void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event) void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event)
{ {

@ -30,9 +30,11 @@ signals:
void deleteElements( const QMimeData &data ); void deleteElements( const QMimeData &data );
void addToFavorite( const QMimeData &data ); void addToFavorite( const QMimeData &data );
void removeFromFavorite( const QMimeData &data ); void removeFromFavorite( const QMimeData &data );
void addElementsToFavorite();
private slots: private slots:
void onSearchTextChanged(QString txt); void onSearchTextChanged(QString txt);
void onActionNewFolder(); void onActionNewFolder();
void onActionFavorite();
protected: protected:
//void dragMoveEvent(QDragMoveEvent *event); //void dragMoveEvent(QDragMoveEvent *event);
void dragEnterEvent( QDragEnterEvent *event ); void dragEnterEvent( QDragEnterEvent *event );

@ -121,6 +121,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
connect( mActionBar, SIGNAL( deleteElements(const QMimeData &) ), this, SLOT( deleteElements(const QMimeData &) ) ); 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( addToFavorite(const QMimeData &) ), this, SLOT( addToFavorite(const QMimeData &) ) );
connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) ); connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) );
connect ( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) );
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 ) ) );
@ -333,6 +334,20 @@ void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUr
} }
} }
void UBFeaturesWidget::addElementsToFavorite()
{
QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes();
for ( int i = 0; i < selected.size(); ++i )
{
UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>();
UBFeature elem = controller->addToFavorite( feature.getFullPath() );
if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() )
featuresModel->addItem( elem );
}
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
}
void UBFeaturesWidget::switchToListView() void UBFeaturesWidget::switchToListView()
{ {
stackedWidget->setCurrentIndex(ID_LISTVIEW); stackedWidget->setCurrentIndex(ID_LISTVIEW);
@ -806,17 +821,17 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
foreach ( QUrl url, urls ) foreach ( QUrl url, urls )
{ {
UBFeature element; UBFeature element;
if ( action == Qt::MoveAction ) if ( action == Qt::MoveAction )
{ {
element = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->moveItemToFolder( url, parentFeature ); element = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->moveItemToFolder( url, parentFeature );
} }
else else
{ {
element = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->copyItemToFolder( url, parentFeature ); element = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->copyItemToFolder( url, parentFeature );
} }
addItem( element ); addItem( element );
} }
} }
else if ( mimeData->hasImage() ) else if ( mimeData->hasImage() )

@ -101,6 +101,7 @@ private slots:
void thumbnailSizeChanged( int ); void thumbnailSizeChanged( int );
void onDisplayMetadata( QMap<QString,QString> ); void onDisplayMetadata( QMap<QString,QString> );
void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray); void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray);
void addElementsToFavorite();
protected: protected:
bool eventFilter(QObject *target, QEvent *event); bool eventFilter(QObject *target, QEvent *event);
}; };

Loading…
Cancel
Save