Display remaining time and better update status in tooltips.

This commit is contained in:
martinrotter 2017-03-15 06:45:18 +01:00
parent b8f90c8365
commit bb6ab9ee2f
3 changed files with 42 additions and 25 deletions

View File

@ -46,6 +46,19 @@ QList<Message> Feed::undeletedMessages() const {
QVariant Feed::data(int column, int role) const {
switch (role) {
case Qt::ToolTipRole:
if (column == FDS_MODEL_TITLE_INDEX) {
//: Tooltip for feed.
return tr("%1"
"%2\n\n"
"Auto-update status: %3").arg(title(),
description().isEmpty() ? QString() : QString('\n') + description(),
getAutoUpdateStatusDescription());
}
else {
return RootItem::data(column, role);
}
case Qt::ForegroundRole:
switch (status()) {
case NewMessages:
@ -201,3 +214,27 @@ int Feed::updateMessages(const QList<Message> &messages, bool error_during_obtai
return updated_messages;
}
QString Feed::getAutoUpdateStatusDescription() const {
QString auto_update_string;
switch (autoUpdateType()) {
case DontAutoUpdate:
//: Describes feed auto-update status.
auto_update_string = tr("does not use auto-update");
break;
case DefaultAutoUpdate:
//: Describes feed auto-update status.
auto_update_string = tr("uses global settings (%n minute(s) to next auto-update)", 0, qApp->feedReader()->autoUpdateRemainingInterval());
break;
case SpecificAutoUpdate:
default:
//: Describes feed auto-update status.
auto_update_string = tr("uses specific settings (%n minute(s) to next auto-update)", 0, autoUpdateRemainingInterval());
break;
}
return auto_update_string;
}

View File

@ -85,6 +85,9 @@ class Feed : public RootItem, public QRunnable {
void updateCounts(bool including_total_count);
int updateMessages(const QList<Message> &messages, bool error_during_obtaining);
protected:
QString getAutoUpdateStatusDescription() const;
signals:
void messagesObtained(QList<Message> messages, bool error_during_obtaining);

View File

@ -119,29 +119,6 @@ QVariant StandardFeed::data(int column, int role) const {
switch (role) {
case Qt::ToolTipRole:
if (column == FDS_MODEL_TITLE_INDEX) {
QString auto_update_string;
switch (autoUpdateType()) {
case DontAutoUpdate:
//: Describes feed auto-update status.
auto_update_string = tr("does not use auto-update");
break;
case DefaultAutoUpdate:
//: Describes feed auto-update status.
auto_update_string = tr("uses global settings");
break;
case SpecificAutoUpdate:
default:
//: Describes feed auto-update status.
auto_update_string = tr("uses specific settings "
"(%n minute(s) to next auto-update)",
0,
autoUpdateRemainingInterval());
break;
}
//: Tooltip for feed.
return tr("%1 (%2)"
"%3\n\n"
@ -151,11 +128,11 @@ QVariant StandardFeed::data(int column, int role) const {
StandardFeed::typeToString(type()),
description().isEmpty() ? QString() : QString('\n') + description(),
encoding(),
auto_update_string,
getAutoUpdateStatusDescription(),
NetworkFactory::networkErrorText(m_networkError));
}
else {
return Feed::data(column, role);
return QVariant();
}
default: