diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG
index 45589578b..929ca1918 100644
--- a/resources/text/CHANGELOG
+++ b/resources/text/CHANGELOG
@@ -3,18 +3,18 @@
Fixed:
-- List of actions in toolbar editor now do not allow copying of items.
+- List of actions in toolbar editor now does not allow copying of items.
- Keyboard search for message list should now work with Qt 4.
- Overall code cleanups and refactoring primarily in area of feed/message models and recycle bin functionality.
-- Fixed bug #66, #67, #69, #64.
+- Fixed bugs #66, #67, #69, #64.
- Blau skin now has colored webkit scrollbars, fixed some button widths and enhanced menu popup tool buttons.
Added:
-- Top-level recycle bin which displays count of deleted items properly.
-- MySQL backend now alows to defragment/optimize RSS Guard database.
-- New blau-based yellow skin.
+- Recycle bin with ability to trash or restore the whole bin or individual messages.
+- MySQL backend now allows to defragment/optimize RSS Guard database.
+- Three new skins, including solarized skin.
Changed:
diff --git a/src/core/feedsmodelrecyclebin.cpp b/src/core/feedsmodelrecyclebin.cpp
index a136bf220..c6e101b98 100644
--- a/src/core/feedsmodelrecyclebin.cpp
+++ b/src/core/feedsmodelrecyclebin.cpp
@@ -32,7 +32,7 @@ FeedsModelRecycleBin::FeedsModelRecycleBin(FeedsModelRootItem *parent)
m_description = tr("Recycle bin contains all deleted messages from all feeds.");
m_creationDate = QDateTime::currentDateTime();
- updateCounts();
+ updateCounts(true);
}
FeedsModelRecycleBin::~FeedsModelRecycleBin() {
@@ -48,7 +48,7 @@ void FeedsModelRecycleBin::appendChild(FeedsModelRootItem *child) {
}
int FeedsModelRecycleBin::countOfUnreadMessages() const {
- return m_totalCount;
+ return m_unreadCount;
}
int FeedsModelRecycleBin::countOfAllMessages() const {
@@ -166,16 +166,25 @@ bool FeedsModelRecycleBin::restore() {
}
}
-void FeedsModelRecycleBin::updateCounts() {
+void FeedsModelRecycleBin::updateCounts(bool update_total_count) {
QSqlDatabase database = qApp->database()->connection("FeedsModelRecycleBin",
DatabaseFactory::FromSettings);
QSqlQuery query_all(database);
query_all.setForwardOnly(true);
- if (query_all.exec("SELECT count(*) FROM Messages WHERE is_deleted = 1;") && query_all.next()) {
- m_totalCount = query_all.value(0).toInt();
+ if (query_all.exec("SELECT count(*) FROM Messages WHERE is_read = 0 AND is_deleted = 1;") && query_all.next()) {
+ m_unreadCount = query_all.value(0).toInt();
}
else {
- m_totalCount = 0;
+ m_unreadCount = 0;
+ }
+
+ if (update_total_count) {
+ if (query_all.exec("SELECT count(*) FROM Messages WHERE is_deleted = 1;") && query_all.next()) {
+ m_totalCount = query_all.value(0).toInt();
+ }
+ else {
+ m_totalCount = 0;
+ }
}
}
diff --git a/src/core/feedsmodelrecyclebin.h b/src/core/feedsmodelrecyclebin.h
index 44e9c43ee..f29614719 100644
--- a/src/core/feedsmodelrecyclebin.h
+++ b/src/core/feedsmodelrecyclebin.h
@@ -40,10 +40,11 @@ class FeedsModelRecycleBin : public FeedsModelRootItem {
bool restore();
public slots:
- void updateCounts();
+ void updateCounts(bool update_total_count);
private:
int m_totalCount;
+ int m_unreadCount;
};
#endif // FEEDSMODELRECYCLEBIN_H
diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp
index 016a4aaf6..44476a636 100755
--- a/src/core/messagesmodel.cpp
+++ b/src/core/messagesmodel.cpp
@@ -262,9 +262,8 @@ bool MessagesModel::setMessageRead(int row_index, int read) {
if (db_handle.commit()) {
// If commit succeeded, then emit changes, so that view
// can reflect.
- emit dataChanged(index(row_index, 0),
- index(row_index, columnCount() - 1));
- emit messageCountsChanged(false);
+ emit dataChanged(index(row_index, 0), index(row_index, columnCount() - 1));
+ emit messageCountsChanged(m_messageMode, false, false);
return true;
}
else {
@@ -375,7 +374,7 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList &messages, int
select();
fetchAll();
- emit messageCountsChanged(true);
+ emit messageCountsChanged(m_messageMode, true, false);
return true;
}
else {
@@ -400,7 +399,7 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList &messages, int re
select();
fetchAll();
- emit messageCountsChanged(true);
+ emit messageCountsChanged(m_messageMode, false, false);
return true;
}
else {
@@ -436,7 +435,7 @@ bool MessagesModel::setBatchMessagesRestored(const QModelIndexList &messages) {
select();
fetchAll();
- emit messageCountsChanged(true);
+ emit messageCountsChanged(m_messageMode, true, true);
return true;
}
else {
diff --git a/src/core/messagesmodel.h b/src/core/messagesmodel.h
index 3dfcad06e..1ab5b3578 100644
--- a/src/core/messagesmodel.h
+++ b/src/core/messagesmodel.h
@@ -114,7 +114,9 @@ class MessagesModel : public QSqlTableModel {
signals:
// Emitted if some persistent change is made which affects count of "unread/all" messages.
- void messageCountsChanged(bool total_message_number_changed);
+ void messageCountsChanged(MessagesModel::MessageMode mode,
+ bool total_msg_count_changed,
+ bool any_msg_restored);
protected:
// Returns selected feed ids in concatenated textual form,
@@ -146,6 +148,7 @@ class MessagesModel : public QSqlTableModel {
QIcon m_unreadIcon;
};
+Q_DECLARE_METATYPE(MessagesModel::MessageMode)
Q_DECLARE_METATYPE(MessagesModel::MessageFilter)
#endif // MESSAGESMODEL_H
diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp
index e550cc41f..3e6355589 100755
--- a/src/gui/feedmessageviewer.cpp
+++ b/src/gui/feedmessageviewer.cpp
@@ -191,7 +191,8 @@ 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(messageCountsChanged(bool)), m_feedsView, SLOT(updateCountsOfSelectedFeeds(bool)));
+ connect(m_messagesView->sourceModel(), SIGNAL(messageCountsChanged(MessagesModel::MessageMode,bool,bool)),
+ m_feedsView, SLOT(receiveMessageCountsChange(MessagesModel::MessageMode,bool,bool)));
// 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 bff300526..7ee88cbd4 100755
--- a/src/gui/feedsview.cpp
+++ b/src/gui/feedsview.cpp
@@ -291,6 +291,43 @@ void FeedsView::editFeed(FeedsModelFeed *feed) {
delete form_pointer.data();
}
+void FeedsView::receiveMessageCountsChange(MessagesModel::MessageMode mode,
+ bool total_msg_count_changed,
+ bool any_msg_restored) {
+ // If the change came from recycle bin mode, then:
+ // a) total count of message was changed AND no message was restored - some messages
+ // were permanently deleted from recycle bin --> we need to update counts of
+ // just recycle bin, including total counts.
+ // b) total count of message was changed AND some message was restored - some messages
+ // were restored --> we need to update counts from all items and bin, including total counts.
+ // c) total count of message was not changed - state of some messages was switched, no
+ // deletings or restorings were made --> update counts of just recycle bin, excluding total counts.
+ //
+ // If the change came from feed mode, then:
+ // a) total count of message was changed - some messages were deleted --> we need to update
+ // counts of recycle bin, including total counts and update counts of selected feeds, including
+ // total counts.
+ // b) total count of message was not changed - some messages switched state --> we need to update
+ // counts of just selected feeds.
+
+ if (mode == MessagesModel::MessagesFromRecycleBin) {
+ if (total_msg_count_changed) {
+ if (any_msg_restored) {
+ updateCountsOfAllFeeds(true);
+ }
+ else {
+ updateCountsOfRecycleBin(true);
+ }
+ }
+ else {
+ updateCountsOfRecycleBin(false);
+ }
+ }
+ else {
+ updateCountsOfSelectedFeeds(total_msg_count_changed);
+ }
+}
+
void FeedsView::editSelectedItem() {
if (!qApp->closeLock()->tryLock()) {
// Lock was not obtained because
@@ -434,7 +471,7 @@ void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) {
if (update_total_too) {
// Number of items in recycle bin has changed.
- m_sourceModel->recycleBin()->updateCounts();
+ m_sourceModel->recycleBin()->updateCounts(true);
// We need to refresh data for recycle bin too.
selected_indexes.append(m_sourceModel->indexForItem(m_sourceModel->recycleBin()));
@@ -445,6 +482,12 @@ void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) {
notifyWithCounts();
}
+void FeedsView::updateCountsOfRecycleBin(bool update_total_too) {
+ m_sourceModel->recycleBin()->updateCounts(update_total_too);
+ m_sourceModel->reloadChangedLayout(QModelIndexList() << m_sourceModel->indexForItem(m_sourceModel->recycleBin()));
+ notifyWithCounts();
+}
+
void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
foreach (FeedsModelFeed *feed, allFeeds()) {
feed->updateCounts(update_total_too);
@@ -452,7 +495,7 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
if (update_total_too) {
// Number of items in recycle bin has changed.
- m_sourceModel->recycleBin()->updateCounts();
+ m_sourceModel->recycleBin()->updateCounts(true);
}
// Make sure that all views reloads its data.
diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h
index 44a21dc5a..9ee013c6b 100644
--- a/src/gui/feedsview.h
+++ b/src/gui/feedsview.h
@@ -111,9 +111,17 @@ class FeedsView : public QTreeView {
void addNewFeed();
void editFeed(FeedsModelFeed *feed);
+ // Is called when counts of messages are changed externally,
+ // typically from message view.
+ void receiveMessageCountsChange(MessagesModel::MessageMode mode,
+ bool total_msg_count_changed,
+ bool any_msg_restored);
+
// Reloads counts for selected feeds.
void updateCountsOfSelectedFeeds(bool update_total_too);
+ void updateCountsOfRecycleBin(bool update_total_too);
+
// Reloads counts for all feeds.
void updateCountsOfAllFeeds(bool update_total_too);
diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp
index a84badb7d..59df34338 100755
--- a/src/gui/messagesview.cpp
+++ b/src/gui/messagesview.cpp
@@ -51,9 +51,6 @@ MessagesView::~MessagesView() {
}
void MessagesView::createConnections() {
- // Forward feed counts changes.
- connect(m_sourceModel, SIGNAL(messageCountsChanged(bool)), this, SIGNAL(messageCountsChanged(bool)));
-
// Make sure that source message is opened
// in new tab on double click.
connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openSelectedSourceMessagesInternally()));
diff --git a/src/gui/messagesview.h b/src/gui/messagesview.h
index 15a7cd49a..8f31e1b74 100755
--- a/src/gui/messagesview.h
+++ b/src/gui/messagesview.h
@@ -113,10 +113,6 @@ class MessagesView : public QTreeView {
void currentMessagesChanged(const QList &messages);
void currentMessagesRemoved();
- // Emitted if counts of unread/total messages has changed
- // because of user interaction with list of messages.
- void messageCountsChanged(bool total_message_number_changed);
-
private:
QMenu *m_contextMenu;