diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 25789c41d..d53e41406 100644 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -3,16 +3,20 @@ Fixed: Added: Changed: +
diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 175aafc34..359bb4c8e 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -66,13 +66,7 @@ FeedsModel::~FeedsModel() { delete m_rootItem; } -QModelIndexList FeedsModel::persistentIndexList() const { - return QAbstractItemModel::persistentIndexList(); -} - -QVariant FeedsModel::headerData(int section, - Qt::Orientation orientation, - int role) const { +QVariant FeedsModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation != Qt::Horizontal) { return QVariant(); } @@ -900,6 +894,10 @@ void FeedsModel::assembleFeeds(FeedAssignment feeds) { } } +FeedsModelRecycleBin *FeedsModel::recycleBin() const { + return m_recycleBin; +} + void FeedsModel::assembleCategories(CategoryAssignment categories) { QHash assignments; assignments.insert(NO_PARENT_CATEGORY, m_rootItem); diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index e76a69abc..8ae4e365d 100644 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -45,10 +45,6 @@ class FeedsModel : public QAbstractItemModel { explicit FeedsModel(QObject *parent = 0); virtual ~FeedsModel(); - // Returns list of all indexes available in the model. - // NOTE: Overriden because original method is protected. - QModelIndexList persistentIndexList() const; - // Model implementation. inline QVariant data(const QModelIndex &index, int role) const { // Return data according to item. @@ -142,6 +138,9 @@ class FeedsModel : public QAbstractItemModel { // it to active structure. bool mergeModel(FeedsImportExportModel *model, QString &output_message); + // Access to recycle bin. + FeedsModelRecycleBin *recycleBin() const; + public slots: // Feeds operations. bool markFeedsRead(const QList &feeds, int read); diff --git a/src/core/feedsmodelrecyclebin.cpp b/src/core/feedsmodelrecyclebin.cpp index 10254926c..5879a34b8 100644 --- a/src/core/feedsmodelrecyclebin.cpp +++ b/src/core/feedsmodelrecyclebin.cpp @@ -94,6 +94,9 @@ QVariant FeedsModelRecycleBin::data(int column, int role) const { return QVariant(); } + case Qt::ToolTipRole: + return tr("Recycle bin\n%1").arg(tr("%n deleted message(s).", 0, countOfUnreadMessages())); + case Qt::TextAlignmentRole: if (column == FDS_MODEL_COUNTS_INDEX) { return Qt::AlignCenter; diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp index d4940353b..b83742ed0 100755 --- a/src/core/feedsmodelrootitem.cpp +++ b/src/core/feedsmodelrootitem.cpp @@ -68,7 +68,9 @@ int FeedsModelRootItem::countOfAllMessages() const { int total_count = 0; foreach (FeedsModelRootItem *child_item, m_childItems) { - total_count += child_item->countOfAllMessages(); + if (child_item->kind() != FeedsModelRootItem::RecycleBin) { + total_count += child_item->countOfAllMessages(); + } } return total_count; @@ -95,7 +97,9 @@ int FeedsModelRootItem::countOfUnreadMessages() const { int total_count = 0; foreach (FeedsModelRootItem *child_item, m_childItems) { - total_count += child_item->countOfUnreadMessages(); + if (child_item->kind() != FeedsModelRootItem::RecycleBin) { + total_count += child_item->countOfUnreadMessages(); + } } return total_count; diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp index 6882517f0..ca6cf4f11 100755 --- a/src/core/messagesmodel.cpp +++ b/src/core/messagesmodel.cpp @@ -274,7 +274,7 @@ bool MessagesModel::setMessageRead(int row_index, int read) { // can reflect. emit dataChanged(index(row_index, 0), index(row_index, columnCount() - 1)); - emit feedCountsChanged(); + emit feedCountsChanged(false); return true; } else { @@ -354,7 +354,7 @@ bool MessagesModel::switchBatchMessageImportance(const QModelIndexList &messages select(); fetchAll(); - emit feedCountsChanged(); + //emit feedCountsChanged(false); return true; } else { @@ -381,7 +381,7 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList &messages, select(); fetchAll(); - emit feedCountsChanged(); + emit feedCountsChanged(true); return true; } else { @@ -407,7 +407,7 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList &messages, int re select(); fetchAll(); - emit feedCountsChanged(); + emit feedCountsChanged(true); return true; } else { diff --git a/src/core/messagesmodel.h b/src/core/messagesmodel.h index e4d11add9..eac0651a3 100644 --- a/src/core/messagesmodel.h +++ b/src/core/messagesmodel.h @@ -109,7 +109,7 @@ class MessagesModel : public QSqlTableModel { signals: // Emitted if some persistent change is made which affects // count of "unread/all" messages. - void feedCountsChanged(); + void feedCountsChanged(bool total_message_number_changed = true); protected: // Returns selected feed ids in concatenated textual form, diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 8ba8f5f3f..347c1ce55 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -206,7 +206,7 @@ void FeedMessageViewer::createConnections() { connect(m_feedsView, SIGNAL(feedsSelected(QList)), m_messagesView, SLOT(loadFeeds(QList))); // If user changes status of some messages, recalculate message counts. - connect(m_messagesView, SIGNAL(feedCountsChanged()), m_feedsView, SLOT(updateCountsOfSelectedFeeds())); + connect(m_messagesView, SIGNAL(feedCountsChanged(bool)), m_feedsView, SLOT(updateCountsOfSelectedFeeds())); // State of many messages is changed, then we need // to reload selections. diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 47bbb9a03..29adcc0c8 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -23,6 +23,7 @@ #include "core/feedsproxymodel.h" #include "core/feedsmodelrootitem.h" #include "core/feedsmodelcategory.h" +#include "core/feedsmodelrecyclebin.h" #include "core/feedsmodelfeed.h" #include "miscellaneous/systemfactory.h" #include "gui/formmain.h" @@ -407,18 +408,24 @@ void FeedsView::openSelectedFeedsInNewspaperMode() { } } -void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) { - QList selected_feeds = selectedFeeds(); - - if (!selected_feeds.isEmpty()) { - foreach (FeedsModelFeed *feed, selected_feeds) { - feed->updateCounts(update_total_too); - } - - // Make sure that selected view reloads changed indexes. - m_sourceModel->reloadChangedLayout(m_proxyModel->mapListToSource(selectionModel()->selectedRows())); - notifyWithCounts(); +void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) { + foreach (FeedsModelFeed *feed, selectedFeeds()) { + feed->updateCounts(update_total_too); } + + QModelIndexList selected_indexes = m_proxyModel->mapListToSource(selectionModel()->selectedRows()); + + if (update_total_too) { + // Number of items in recycle bin has changed. + m_sourceModel->recycleBin()->updateCounts(); + + // We need to refresh data for recycle bin too. + selected_indexes.append(m_sourceModel->indexForItem(m_sourceModel->recycleBin())); + } + + // Make sure that selected view reloads changed indexes. + m_sourceModel->reloadChangedLayout(selected_indexes); + notifyWithCounts(); } void FeedsView::updateCountsOfAllFeeds(bool update_total_too) { @@ -426,9 +433,13 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) { feed->updateCounts(update_total_too); } + if (update_total_too) { + // Number of items in recycle bin has changed. + m_sourceModel->recycleBin()->updateCounts(); + } + // Make sure that all views reloads its data. m_sourceModel->reloadWholeLayout(); - notifyWithCounts(); } diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index 4db1b986b..36ed11828 100755 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -50,17 +50,14 @@ MessagesView::~MessagesView() { void MessagesView::createConnections() { // Forward feed counts changes. - connect(m_sourceModel, SIGNAL(feedCountsChanged()), - this, SIGNAL(feedCountsChanged())); + connect(m_sourceModel, SIGNAL(feedCountsChanged(bool)), this, SIGNAL(feedCountsChanged(bool))); // Make sure that source message is opened // in new tab on double click. - connect(this, SIGNAL(doubleClicked(QModelIndex)), - this, SLOT(openSelectedSourceMessagesInternally())); + connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openSelectedSourceMessagesInternally())); // Adjust columns when layout gets changed. - connect(header(), SIGNAL(geometriesChanged()), - this, SLOT(adjustColumns())); + connect(header(), SIGNAL(geometriesChanged()), this, SLOT(adjustColumns())); } void MessagesView::keyboardSearch(const QString &search) { @@ -137,8 +134,7 @@ void MessagesView::contextMenuEvent(QContextMenuEvent *event) { QModelIndex clicked_index = indexAt(event->pos()); if (!clicked_index.isValid()) { - qDebug("Context menu for MessagesView will not be shown because " - "user clicked on invalid item."); + qDebug("Context menu for MessagesView will not be shown because user clicked on invalid item."); return; } diff --git a/src/gui/messagesview.h b/src/gui/messagesview.h index c281a7c6c..77249afb8 100755 --- a/src/gui/messagesview.h +++ b/src/gui/messagesview.h @@ -52,11 +52,7 @@ class MessagesView : public QTreeView { void createConnections(); public slots: - void keyboardSearch(const QString &search) { - setSelectionMode(QAbstractItemView::SingleSelection); - QTreeView::keyboardSearch(search); - setSelectionMode(QAbstractItemView::ExtendedSelection); - } + void keyboardSearch(const QString &search); // Called after data got changed externally // and it needs to be reloaded to the view. @@ -118,7 +114,7 @@ class MessagesView : public QTreeView { // Emitted if counts of unread/total messages has changed // because of user interaction with list of messages. - void feedCountsChanged(); + void feedCountsChanged(bool total_message_number_changed = true); private: QMenu *m_contextMenu;