diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 6aaff881d..ae20b66b6 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -477,6 +477,17 @@ FeedsModelCategory *FeedsModel::categoryForIndex(const QModelIndex &index) const } } +FeedsModelRecycleBin *FeedsModel::recycleBinForIndex(const QModelIndex &index) const { + FeedsModelRootItem *item = itemForIndex(index); + + if (item->kind() == FeedsModelRootItem::RecycleBin) { + return static_cast(item); + } + else { + return NULL; + } +} + QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const { if (item == NULL || item->kind() == FeedsModelRootItem::RootItem) { // Root item lies on invalid index. diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index 8ae4e365d..9187ac912 100644 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -122,6 +122,8 @@ class FeedsModel : public QAbstractItemModel { // or NULL if no category lies in given index. FeedsModelCategory *categoryForIndex(const QModelIndex &index) const; + FeedsModelRecycleBin *recycleBinForIndex(const QModelIndex &index) const; + // Returns feed/category which lies at the specified index or // root item if index is invalid. FeedsModelRootItem *itemForIndex(const QModelIndex &index) const; diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 342c9cf6b..72d581e01 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -119,6 +119,11 @@ FeedsModelFeed *FeedsView::selectedFeed() const { return m_sourceModel->feedForIndex(current_mapped); } +FeedsModelRecycleBin *FeedsView::selectedRecycleBin() const{ + QModelIndex current_mapped = m_proxyModel->mapToSource(currentIndex()); + return m_sourceModel->recycleBinForIndex(current_mapped); +} + void FeedsView::saveExpandedStates() { Settings *settings = qApp->settings(); @@ -305,20 +310,7 @@ void FeedsView::editSelectedItem() { editCategory(static_cast(category)); } else if ((feed = selectedFeed()) != NULL) { - // Feed is selected. - switch (feed->type()) { - case FeedsModelFeed::Atom10: - case FeedsModelFeed::Rdf: - case FeedsModelFeed::Rss0X: - case FeedsModelFeed::Rss2X: { - // User wants to edit standard feed. - editFeed(static_cast(feed)); - break; - } - - default: - break; - } + editFeed(static_cast(feed)); } // Changes are done, unlock the update master lock. @@ -412,6 +404,13 @@ void FeedsView::openSelectedFeedsInNewspaperMode() { } void FeedsView::emptyRecycleBin() { + if (MessageBox::show(qApp->mainForm(), QMessageBox::Question, tr("Permanently delete messages"), + tr("You are about to permanenty delete all messages from your recycle bin."), tr("Do you really want to empty your recycle bin?"), + QString(), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::No) { + // User changed his mind. + return; + } + m_sourceModel->recycleBin()->empty(); updateCountsOfSelectedFeeds(); diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index fbc8b6ac6..116448161 100644 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -63,6 +63,7 @@ class FeedsView : public QTreeView { // selected. FeedsModelCategory *selectedCategory() const; FeedsModelFeed *selectedFeed() const; + FeedsModelRecycleBin *selectedRecycleBin() const; // Saves/loads expand states of all nodes (feeds/categories) of the list to/from settings. void saveExpandedStates(); diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index 09baa5925..40278b747 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -126,6 +126,10 @@ QList FormMain::allActions() { actions << m_ui->m_actionSelectPreviousMessage; actions << m_ui->m_actionDefragmentDatabase; + // Add recycle bin actions. + actions << m_ui->m_actionRestoreAllMessages; + actions << m_ui->m_actionEmptyRecycleBin; + return actions; } diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index dcc51b7ab..d4837e874 100755 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -278,10 +278,12 @@ void MessagesView::openSelectedMessagesInternally() { messages << m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()); } - emit openMessagesInNewspaperView(messages); + if (!messages.isEmpty()) { + emit openMessagesInNewspaperView(messages); - // Finally, mark opened messages as read. - markSelectedMessagesRead(); + // Finally, mark opened messages as read. + markSelectedMessagesRead(); + } } void MessagesView::markSelectedMessagesRead() { diff --git a/src/main.cpp b/src/main.cpp index f7c5e6ed6..7bdd6d062 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -96,7 +96,7 @@ int main(int argc, char *argv[]) { main_window.setWindowTitle(APP_LONG_NAME); // Now is a good time to initialize dynamic keyboard shortcuts. - DynamicShortcuts::load(main_window.allActions()); + DynamicShortcuts::load(qApp->userActions()); // Display main window. if (qApp->settings()->value(APP_CFG_GUI, "start_hidden", false).toBool() && SystemTrayIcon::isSystemTrayActivated()) {