From 169ecd485cf92834cfb26e56466c70c720f54484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 11 Jun 2014 19:38:13 +0200 Subject: [PATCH] foldersView context menu is now dynamic --- YACReaderLibrary/library_window.cpp | 19 ++++++++++++++++++- YACReaderLibrary/library_window.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 928d7ebd..cf721f47 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -723,6 +723,7 @@ void LibraryWindow::createConnections() connect(renameLibraryDialog,SIGNAL(renameLibrary(QString)),this,SLOT(rename(QString))); //navigations between view modes (tree,list and flow) + connect(foldersView, SIGNAL(pressed(QModelIndex)), this, SLOT(updateFoldersViewConextMenu(QModelIndex))); connect(foldersView, SIGNAL(clicked(QModelIndex)), this, SLOT(loadCovers(QModelIndex))); connect(foldersView, SIGNAL(clicked(QModelIndex)), this, SLOT(updateHistory(QModelIndex))); @@ -1805,7 +1806,23 @@ void LibraryWindow::updateHistory(const QModelIndex &mi) currentFolderNavigation++; } - forwardAction->setEnabled(false); + forwardAction->setEnabled(false); +} + +void LibraryWindow::updateFoldersViewConextMenu(const QModelIndex &mi) +{ + if(!mi.isValid()) + return; + + TreeItem * item = static_cast(mi.internalPointer()); + bool isFinished = item->data(TreeModel::Finished).toBool(); + bool isCompleted = item->data(TreeModel::Completed).toBool(); + + setFolderAsFinishedAction->setVisible(!isFinished); + setFolderAsNotFinishedAction->setVisible(isFinished); + + setFolderAsCompletedAction->setVisible(!isCompleted); + setFolderAsNotCompletedAction->setVisible(isCompleted); } void LibraryWindow::libraryAlreadyExists(const QString & name) diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 061b5f23..5925d897 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -279,6 +279,7 @@ public: void backward(); void forward(); void updateHistory(const QModelIndex & mi); + void updateFoldersViewConextMenu(const QModelIndex & mi); void libraryAlreadyExists(const QString & name); void importLibraryPackage(); void updateComicsView(quint64 libraryId, const ComicDB & comic);