This commit is contained in:
Martin Rotter 2014-10-27 18:11:30 +01:00
parent 9233393956
commit bc2aa7f777
10 changed files with 40 additions and 29 deletions

View File

@ -4,11 +4,12 @@
Fixed:
<ul>
<li>Database is now correctly restored when using SQLite memory databases.</li>
<li>When items are deleted from recycle bin then they are kept in DB and marked as "permanently deleted" (bug # 95).'
<li>When items are deleted from recycle bin then they are kept in DB and marked as "permanently deleted" (bug #95).'
</ul>
Added:
<ul>
<li>Tray icon now displays blue number of unread messages if any of those messages is newly downloaded from online feed (enhancement #87).</li>
<li>Fixed issue request #95: items are now permanently hidden (not deleted from database) when "deleted" from recycle bin.</li>
<li>Issue request #95: moreover custom incremental ability to update database schema was added to keep RSS Guard 2.0.0.4+ fully compatible with previous releases. Incremental algorithm supports both database backends.</li>
</ul>

View File

@ -549,6 +549,16 @@ QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const {
*/
}
bool FeedsModel::hasAnyFeedNewMessages() {
foreach (const FeedsModelFeed *feed, allFeeds()) {
if (feed->status() == FeedsModelFeed::NewMessages) {
return true;
}
}
return false;
}
bool FeedsModel::mergeModel(FeedsImportExportModel *model, QString &output_message) {
if (model == NULL || model->rootItem() == NULL) {
output_message = tr("Invalid tree data.");

View File

@ -114,14 +114,16 @@ class FeedsModel : public QAbstractItemModel {
// Returns ALL CHILD feeds contained within single index.
QList<FeedsModelFeed*> feedsForIndex(const QModelIndex &index);
// Returns pointer to feed if it lies in given index
// or NULL if no feed lies in given index.
// Returns pointer to feed if it lies on given index
// or NULL if no feed lies on given index.
FeedsModelFeed *feedForIndex(const QModelIndex &index);
// Returns pointer to category if it lies in given index
// or NULL if no category lies in given index.
// Returns pointer to category if it lies on given index
// or NULL if no category lies on given index.
FeedsModelCategory *categoryForIndex(const QModelIndex &index) const;
// Returns pointer to recycle bin if lies on given index
// or NULL if no recycle bin lies on given index.
FeedsModelRecycleBin *recycleBinForIndex(const QModelIndex &index) const;
// Returns feed/category which lies at the specified index or
@ -131,6 +133,8 @@ class FeedsModel : public QAbstractItemModel {
// Returns source QModelIndex on which lies given item.
QModelIndex indexForItem(FeedsModelRootItem *item) const;
bool hasAnyFeedNewMessages();
// Access to root item.
inline FeedsModelRootItem *rootItem() const {
return m_rootItem;

View File

@ -120,17 +120,13 @@ void FeedsModelFeed::updateCounts(bool including_total_count, bool update_feed_s
query_all.setForwardOnly(true);
if (including_total_count) {
if (query_all.exec(QString("SELECT count(*) FROM Messages "
"WHERE feed = %1 AND is_deleted = 0;").arg(id())) &&
query_all.next()) {
if (query_all.exec(QString("SELECT count(*) FROM Messages WHERE feed = %1 AND is_deleted = 0;").arg(id())) && query_all.next()) {
m_totalCount = query_all.value(0).toInt();
}
}
// Obtain count of unread messages.
if (query_all.exec(QString("SELECT count(*) FROM Messages "
"WHERE feed = %1 AND is_deleted = 0 AND is_read = 0;").arg(id())) &&
query_all.next()) {
if (query_all.exec(QString("SELECT count(*) FROM Messages WHERE feed = %1 AND is_deleted = 0 AND is_read = 0;").arg(id())) && query_all.next()) {
int new_unread_count = query_all.value(0).toInt();
if (update_feed_statuses && m_status == NewMessages && new_unread_count < m_unreadCount) {

View File

@ -145,11 +145,11 @@ void FeedMessageViewer::setListHeadersEnabled(bool enable) {
m_messagesView->header()->setVisible(enable);
}
void FeedMessageViewer::updateTrayIconStatus(int unread_messages, int total_messages) {
void FeedMessageViewer::updateTrayIconStatus(int unread_messages, int total_messages, bool any_unread_messages) {
Q_UNUSED(total_messages)
if (SystemTrayIcon::isSystemTrayActivated()) {
qApp->trayIcon()->setNumber(unread_messages);
qApp->trayIcon()->setNumber(unread_messages, any_unread_messages);
}
}
@ -199,7 +199,7 @@ void FeedMessageViewer::createConnections() {
connect(m_feedsView, SIGNAL(feedsNeedToBeReloaded(int)), m_messagesView, SLOT(reloadSelections(int)));
// If counts of unread/all messages change, update the tray icon.
connect(m_feedsView, SIGNAL(messageCountsChanged(int, int)), this, SLOT(updateTrayIconStatus(int, int)));
connect(m_feedsView, SIGNAL(messageCountsChanged(int,int,bool)), this, SLOT(updateTrayIconStatus(int,int,bool)));
// Message openers.
connect(m_messagesView, SIGNAL(openMessagesInNewspaperView(QList<Message>)),

View File

@ -95,7 +95,7 @@ class FeedMessageViewer : public TabContent {
protected slots:
// Updates counts of messages for example in tray icon.
void updateTrayIconStatus(int unread_messages, int total_messages);
void updateTrayIconStatus(int unread_messages, int total_messages, bool any_unread_messages);
// Reacts on feed updates.
void onFeedUpdatesStarted();

View File

@ -452,7 +452,8 @@ 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?"),
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;

View File

@ -131,7 +131,9 @@ class FeedsView : public QTreeView {
// Notifies other components about messages
// counts.
inline void notifyWithCounts() {
emit messageCountsChanged(m_sourceModel->countOfUnreadMessages(), m_sourceModel->countOfAllMessages());
emit messageCountsChanged(m_sourceModel->countOfUnreadMessages(),
m_sourceModel->countOfAllMessages(),
m_sourceModel->hasAnyFeedNewMessages());
}
// Selects next/previous item (feed/category) in the list.
@ -165,7 +167,7 @@ class FeedsView : public QTreeView {
void feedsUpdateRequested(const QList<FeedsModelFeed*> feeds);
// Emitted if counts of messages are changed.
void messageCountsChanged(int unread_messages, int total_messages);
void messageCountsChanged(int unread_messages, int total_messages, bool any_feed_has_unread_messages);
// Emitted if currently selected feeds needs to be reloaded.
void feedsNeedToBeReloaded(int mark_current_index_read);

View File

@ -115,10 +115,9 @@ void SystemTrayIcon::show() {
#endif
}
void SystemTrayIcon::setNumber(int number) {
void SystemTrayIcon::setNumber(int number, bool any_unread_message) {
if (number <= 0) {
setToolTip(APP_LONG_NAME);
QSystemTrayIcon::setIcon(QIcon(m_normalIcon));
}
else {
@ -127,10 +126,12 @@ void SystemTrayIcon::setNumber(int number) {
QPixmap background(m_plainPixmap);
QPainter tray_painter;
// TODO: Here draw different background instead of different color of number.
tray_painter.begin(&background);
tray_painter.setBrush(Qt::black);
tray_painter.setPen(any_unread_message ? Qt::blue : Qt::black);
tray_painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
tray_painter.setRenderHint(QPainter::TextAntialiasing, false);
tray_painter.setRenderHint(QPainter::TextAntialiasing, true);
// Numbers with more than 2 digits won't be readable, display
// infinity symbol in that case.
@ -138,9 +139,7 @@ void SystemTrayIcon::setNumber(int number) {
m_font.setPixelSize(100);
tray_painter.setFont(m_font);
tray_painter.drawText(QRect(0, 0, 128, 128),
Qt::AlignVCenter | Qt::AlignCenter ,
QChar(8734));
tray_painter.drawText(QRect(0, 0, 128, 128), Qt::AlignVCenter | Qt::AlignCenter, QChar(8734));
}
else {
// Smaller number if it has 3 digits.
@ -156,9 +155,7 @@ void SystemTrayIcon::setNumber(int number) {
}
tray_painter.setFont(m_font);
tray_painter.drawText(QRect(0, 0, 128, 128),
Qt::AlignVCenter | Qt::AlignCenter ,
QString::number(number));
tray_painter.drawText(QRect(0, 0, 128, 128), Qt::AlignVCenter | Qt::AlignCenter, QString::number(number));
}
tray_painter.end();

View File

@ -55,7 +55,7 @@ class SystemTrayIcon : public QSystemTrayIcon {
virtual ~SystemTrayIcon();
// Sets the number to be visible in the tray icon, number <= 0 removes it.
void setNumber(int number = -1);
void setNumber(int number = -1, bool any_unread_message = false);
void showMessage(const QString &title, const QString &message, MessageIcon icon = Information,
int milliseconds_timeout_hint = TRAY_ICON_BUBBLE_TIMEOUT, QObject *click_target = NULL,