Added some information to service roots implementations.
This commit is contained in:
parent
fa373df15c
commit
52b41e19f4
@ -69,10 +69,8 @@ int RootItem::countOfAllMessages() const {
|
|||||||
int total_count = 0;
|
int total_count = 0;
|
||||||
|
|
||||||
foreach (RootItem *child_item, m_childItems) {
|
foreach (RootItem *child_item, m_childItems) {
|
||||||
if (child_item->kind() != RootItem::Bin) {
|
|
||||||
total_count += child_item->countOfAllMessages();
|
total_count += child_item->countOfAllMessages();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return total_count;
|
return total_count;
|
||||||
}
|
}
|
||||||
@ -143,10 +141,8 @@ int RootItem::countOfUnreadMessages() const {
|
|||||||
int total_count = 0;
|
int total_count = 0;
|
||||||
|
|
||||||
foreach (RootItem *child_item, m_childItems) {
|
foreach (RootItem *child_item, m_childItems) {
|
||||||
if (child_item->kind() != RootItem::Bin) {
|
|
||||||
total_count += child_item->countOfUnreadMessages();
|
total_count += child_item->countOfUnreadMessages();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return total_count;
|
return total_count;
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,20 @@ bool SystemFactory::removeTrolltechJunkRegistryKeys() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QString SystemFactory::getUsername() const {
|
||||||
|
QString name = qgetenv("USER");
|
||||||
|
|
||||||
|
if (name.isEmpty()) {
|
||||||
|
name = qgetenv("USERNAME");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.isEmpty()) {
|
||||||
|
name = tr("anonymous");
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
QPair<UpdateInfo, QNetworkReply::NetworkError> SystemFactory::checkForUpdates() {
|
QPair<UpdateInfo, QNetworkReply::NetworkError> SystemFactory::checkForUpdates() {
|
||||||
QPair<UpdateInfo, QNetworkReply::NetworkError> result;
|
QPair<UpdateInfo, QNetworkReply::NetworkError> result;
|
||||||
QByteArray releases_xml;
|
QByteArray releases_xml;
|
||||||
|
@ -80,6 +80,9 @@ class SystemFactory : public QObject {
|
|||||||
QString getAutostartDesktopFileLocation();
|
QString getAutostartDesktopFileLocation();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Retrieves username of currently logged-in user.
|
||||||
|
QString getUsername() const;
|
||||||
|
|
||||||
// Tries to download list with new updates.
|
// Tries to download list with new updates.
|
||||||
QPair<UpdateInfo, QNetworkReply::NetworkError> checkForUpdates();
|
QPair<UpdateInfo, QNetworkReply::NetworkError> checkForUpdates();
|
||||||
|
|
||||||
|
@ -17,10 +17,88 @@
|
|||||||
|
|
||||||
#include "services/standard/standardserviceroot.h"
|
#include "services/standard/standardserviceroot.h"
|
||||||
|
|
||||||
|
#include "definitions/definitions.h"
|
||||||
|
#include "miscellaneous/application.h"
|
||||||
|
#include "miscellaneous/settings.h"
|
||||||
|
#include "services/standard/standardserviceentrypoint.h"
|
||||||
|
|
||||||
|
|
||||||
StandardServiceRoot::StandardServiceRoot(RootItem *parent) : ServiceRoot(parent) {
|
StandardServiceRoot::StandardServiceRoot(RootItem *parent) : ServiceRoot(parent) {
|
||||||
|
m_title = qApp->system()->getUsername() + "@" + APP_LOW_NAME;
|
||||||
|
m_icon = StandardServiceEntryPoint().icon();
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardServiceRoot::~StandardServiceRoot() {
|
StandardServiceRoot::~StandardServiceRoot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StandardServiceRoot::canBeEdited() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StandardServiceRoot::canBeDeleted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant StandardServiceRoot::data(int column, int role) const {
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
|
return m_title;
|
||||||
|
}
|
||||||
|
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
|
return qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString()
|
||||||
|
.replace(PLACEHOLDER_UNREAD_COUNTS, QString::number(countOfUnreadMessages()))
|
||||||
|
.replace(PLACEHOLDER_ALL_COUNTS, QString::number(countOfAllMessages()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::EditRole:
|
||||||
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
|
return m_title;
|
||||||
|
}
|
||||||
|
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
|
return countOfUnreadMessages();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::DecorationRole:
|
||||||
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
|
return m_icon;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::ToolTipRole:
|
||||||
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
|
return
|
||||||
|
m_title + "\n" +
|
||||||
|
tr("This is service account for standard RSS/RDF/ATOM feeds.");
|
||||||
|
}
|
||||||
|
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
|
//: Tooltip for "unread" column of feed list.
|
||||||
|
return tr("%n unread message(s).", 0, countOfUnreadMessages());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::TextAlignmentRole:
|
||||||
|
if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
|
return Qt::AlignCenter;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::FontRole:
|
||||||
|
return countOfUnreadMessages() > 0 ? m_boldFont : m_normalFont;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -20,11 +20,19 @@
|
|||||||
|
|
||||||
#include "services/abstract/serviceroot.h"
|
#include "services/abstract/serviceroot.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
|
||||||
class StandardServiceRoot : public ServiceRoot {
|
class StandardServiceRoot : public ServiceRoot {
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(StandardServiceRoot)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StandardServiceRoot(RootItem *parent = NULL);
|
explicit StandardServiceRoot(RootItem *parent = NULL);
|
||||||
virtual ~StandardServiceRoot();
|
virtual ~StandardServiceRoot();
|
||||||
|
|
||||||
|
bool canBeEdited();
|
||||||
|
bool canBeDeleted();
|
||||||
|
QVariant data(int column, int role) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STANDARDSERVICEROOT_H
|
#endif // STANDARDSERVICEROOT_H
|
||||||
|
@ -17,10 +17,95 @@
|
|||||||
|
|
||||||
#include "services/tt-rss/ttrssserviceroot.h"
|
#include "services/tt-rss/ttrssserviceroot.h"
|
||||||
|
|
||||||
|
#include "miscellaneous/application.h"
|
||||||
|
#include "miscellaneous/settings.h"
|
||||||
|
#include "services/tt-rss/ttrssserviceentrypoint.h"
|
||||||
|
|
||||||
|
|
||||||
TtRssServiceRoot::TtRssServiceRoot(RootItem *parent) : ServiceRoot(parent) {
|
TtRssServiceRoot::TtRssServiceRoot(RootItem *parent) : ServiceRoot(parent) {
|
||||||
|
// TODO: nadpis se bude měnit podle nastavení uživatelského
|
||||||
|
// jména a serveru tohoto ttrss učtu
|
||||||
|
m_title = qApp->system()->getUsername() + "@ttrss";
|
||||||
|
m_icon = TtRssServiceEntryPoint().icon();
|
||||||
}
|
}
|
||||||
|
|
||||||
TtRssServiceRoot::~TtRssServiceRoot() {
|
TtRssServiceRoot::~TtRssServiceRoot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TtRssServiceRoot::editViaDialog() {
|
||||||
|
// TODO: zobrazit custom edit dialog pro ttrss
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TtRssServiceRoot::canBeEdited() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TtRssServiceRoot::canBeDeleted() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant TtRssServiceRoot::data(int column, int role) const {
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
|
return m_title;
|
||||||
|
}
|
||||||
|
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
|
return qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString()
|
||||||
|
.replace(PLACEHOLDER_UNREAD_COUNTS, QString::number(countOfUnreadMessages()))
|
||||||
|
.replace(PLACEHOLDER_ALL_COUNTS, QString::number(countOfAllMessages()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::EditRole:
|
||||||
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
|
return m_title;
|
||||||
|
}
|
||||||
|
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
|
return countOfUnreadMessages();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::DecorationRole:
|
||||||
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
|
return m_icon;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::ToolTipRole:
|
||||||
|
// TODO: zobrazovat pokročile informace a statistiky.
|
||||||
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
|
return
|
||||||
|
m_title + "\n" +
|
||||||
|
tr("This is service account TT-RSS (TinyTiny RSS) server.");
|
||||||
|
}
|
||||||
|
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
|
//: Tooltip for "unread" column of feed list.
|
||||||
|
return tr("%n unread message(s).", 0, countOfUnreadMessages());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::TextAlignmentRole:
|
||||||
|
if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
|
return Qt::AlignCenter;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::FontRole:
|
||||||
|
return countOfUnreadMessages() > 0 ? m_boldFont : m_normalFont;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -20,11 +20,20 @@
|
|||||||
|
|
||||||
#include "services/abstract/serviceroot.h"
|
#include "services/abstract/serviceroot.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
|
||||||
class TtRssServiceRoot : public ServiceRoot {
|
class TtRssServiceRoot : public ServiceRoot {
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(StandardServiceRoot)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TtRssServiceRoot(RootItem *parent = NULL);
|
explicit TtRssServiceRoot(RootItem *parent = NULL);
|
||||||
virtual ~TtRssServiceRoot();
|
virtual ~TtRssServiceRoot();
|
||||||
|
|
||||||
|
bool canBeEdited();
|
||||||
|
bool canBeDeleted();
|
||||||
|
void editViaDialog();
|
||||||
|
QVariant data(int column, int role) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TTRSSSERVICEROOT_H
|
#endif // TTRSSSERVICEROOT_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user