Optimize sync-in && show some tooltips.
This commit is contained in:
parent
5812c2e5d2
commit
f9fc5b1dfe
8 changed files with 91 additions and 102 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 572da127bb14842bba6f84e6315a5ecefb44ed07
|
||||
Subproject commit 2392b936c08eac92a6a34361a916a739f53836d0
|
|
@ -26,6 +26,7 @@
|
|||
#include <QScrollBar>
|
||||
#include <QToolBar>
|
||||
#include <QSqlQuery>
|
||||
#include <QToolTip>
|
||||
|
||||
|
||||
MessagePreviewer::MessagePreviewer(QWidget *parent) : QWidget(parent),
|
||||
|
@ -74,6 +75,13 @@ MessagePreviewer::MessagePreviewer(QWidget *parent) : QWidget(parent),
|
|||
&QAction::triggered,
|
||||
this,
|
||||
&MessagePreviewer::switchMessageImportance);
|
||||
connect(m_ui->m_txtMessage,
|
||||
static_cast<void (QTextBrowser::*)(const QString&)>(&QTextBrowser::highlighted),
|
||||
[=](const QString &text) {
|
||||
Q_UNUSED(text)
|
||||
|
||||
QToolTip::showText(QCursor::pos(), tr("Click this link to download it or open it with external browser."), this);
|
||||
});
|
||||
|
||||
m_actionSwitchImportance->setCheckable(true);
|
||||
|
||||
|
@ -92,6 +100,10 @@ void MessagePreviewer::reloadFontSettings() {
|
|||
SETTING(Messages::PreviewerFontStandard)).toString());
|
||||
|
||||
m_ui->m_txtMessage->setFont(fon);
|
||||
|
||||
fon.setPointSize(fon.pointSize() + 5);
|
||||
|
||||
m_ui->m_lblTitle->setFont(fon);
|
||||
}
|
||||
|
||||
void MessagePreviewer::clear() {
|
||||
|
|
|
@ -297,6 +297,65 @@ void ServiceRoot::requestItemRemoval(RootItem *item) {
|
|||
emit itemRemovalRequested(item);
|
||||
}
|
||||
|
||||
void ServiceRoot::syncIn() {
|
||||
QIcon original_icon = icon();
|
||||
|
||||
setIcon(qApp->icons()->fromTheme(QSL("item-sync")));
|
||||
itemChanged(QList<RootItem*>() << this);
|
||||
|
||||
RootItem *new_tree = obtainNewTreeForSyncIn();
|
||||
|
||||
if (new_tree != NULL) {
|
||||
// Purge old data from SQL and clean all model items.
|
||||
requestItemExpandStateSave(this);
|
||||
removeOldFeedTree(false);
|
||||
cleanAllItems();
|
||||
|
||||
// Model is clean, now store new tree into DB and
|
||||
// set primary IDs of the items.
|
||||
storeNewFeedTree(new_tree);
|
||||
|
||||
// We have new feed, some feeds were maybe removed,
|
||||
// so remove left over messages.
|
||||
removeLeftOverMessages();
|
||||
|
||||
foreach (RootItem *top_level_item, new_tree->childItems()) {
|
||||
top_level_item->setParent(NULL);
|
||||
requestItemReassignment(top_level_item, this);
|
||||
}
|
||||
|
||||
updateCounts(true);
|
||||
|
||||
new_tree->clearChildren();
|
||||
new_tree->deleteLater();
|
||||
|
||||
QList<RootItem*> all_items = getSubTree();
|
||||
|
||||
itemChanged(all_items);
|
||||
requestReloadMessageList(true);
|
||||
|
||||
// Now we must refresh expand states.
|
||||
QList<RootItem*> items_to_expand;
|
||||
|
||||
foreach (RootItem *item, all_items) {
|
||||
if (qApp->settings()->value(GROUP(CategoriesExpandStates), item->hashCode(), item->childCount() > 0).toBool()) {
|
||||
items_to_expand.append(item);
|
||||
}
|
||||
}
|
||||
|
||||
items_to_expand.append(this);
|
||||
|
||||
requestItemExpand(items_to_expand, true);
|
||||
}
|
||||
|
||||
setIcon(original_icon);
|
||||
itemChanged(QList<RootItem*>() << this);
|
||||
}
|
||||
|
||||
RootItem *ServiceRoot::obtainNewTreeForSyncIn() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QStringList ServiceRoot::customIDSOfMessagesForItem(RootItem *item) {
|
||||
if (item->getParentServiceRoot() != this) {
|
||||
// Not item from this account.
|
||||
|
|
|
@ -164,8 +164,13 @@ class ServiceRoot : public RootItem {
|
|||
public slots:
|
||||
virtual void addNewFeed(const QString &url = QString()) = 0;
|
||||
virtual void addNewCategory() = 0;
|
||||
virtual void syncIn();
|
||||
|
||||
protected:
|
||||
// This method should obtain new tree of feed/messages/etc to perform
|
||||
// sync in.
|
||||
virtual RootItem *obtainNewTreeForSyncIn() const;
|
||||
|
||||
// Removes all messages/categories/feeds which are
|
||||
// associated with this account.
|
||||
void removeOldFeedTree(bool including_messages);
|
||||
|
|
|
@ -245,59 +245,15 @@ void OwnCloudServiceRoot::addNewFeed(const QString &url) {
|
|||
void OwnCloudServiceRoot::addNewCategory() {
|
||||
}
|
||||
|
||||
void OwnCloudServiceRoot::syncIn() {
|
||||
QIcon original_icon = icon();
|
||||
|
||||
setIcon(qApp->icons()->fromTheme(QSL("item-sync")));
|
||||
itemChanged(QList<RootItem*>() << this);
|
||||
|
||||
RootItem *OwnCloudServiceRoot::obtainNewTreeForSyncIn() const {
|
||||
OwnCloudGetFeedsCategoriesResponse feed_cats_response = m_network->feedsCategories();
|
||||
|
||||
if (m_network->lastError() == QNetworkReply::NoError) {
|
||||
RootItem *new_tree = feed_cats_response.feedsCategories(true);
|
||||
|
||||
// Purge old data from SQL and clean all model items.
|
||||
requestItemExpandStateSave(this);
|
||||
removeOldFeedTree(false);
|
||||
cleanAllItems();
|
||||
|
||||
// Model is clean, now store new tree into DB and
|
||||
// set primary IDs of the items.
|
||||
storeNewFeedTree(new_tree);
|
||||
|
||||
// We have new feed, some feeds were maybe removed,
|
||||
// so remove left over messages.
|
||||
removeLeftOverMessages();
|
||||
|
||||
foreach (RootItem *top_level_item, new_tree->childItems()) {
|
||||
top_level_item->setParent(NULL);
|
||||
requestItemReassignment(top_level_item, this);
|
||||
}
|
||||
|
||||
updateCounts(true);
|
||||
|
||||
new_tree->clearChildren();
|
||||
new_tree->deleteLater();
|
||||
|
||||
QList<RootItem*> all_items = getSubTree();
|
||||
|
||||
itemChanged(all_items);
|
||||
requestReloadMessageList(true);
|
||||
|
||||
// Now we must refresh expand states.
|
||||
QList<RootItem*> items_to_expand;
|
||||
|
||||
foreach (RootItem *item, all_items) {
|
||||
if (qApp->settings()->value(GROUP(CategoriesExpandStates), item->hashCode(), item->childCount() > 0).toBool()) {
|
||||
items_to_expand.append(item);
|
||||
}
|
||||
}
|
||||
|
||||
requestItemExpand(items_to_expand, true);
|
||||
return feed_cats_response.feedsCategories(true);
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
setIcon(original_icon);
|
||||
itemChanged(QList<RootItem*>() << this);
|
||||
}
|
||||
|
||||
void OwnCloudServiceRoot::loadFromDatabase() {
|
||||
|
|
|
@ -55,9 +55,9 @@ class OwnCloudServiceRoot : public ServiceRoot {
|
|||
void addNewFeed(const QString &url);
|
||||
void addNewCategory();
|
||||
|
||||
void syncIn();
|
||||
|
||||
private:
|
||||
RootItem *obtainNewTreeForSyncIn() const;
|
||||
|
||||
void loadFromDatabase();
|
||||
|
||||
OwnCloudRecycleBin *m_recycleBin;
|
||||
|
|
|
@ -353,57 +353,13 @@ void TtRssServiceRoot::updateTitle() {
|
|||
setTitle(m_network->username() + QL1S("@") + host);
|
||||
}
|
||||
|
||||
void TtRssServiceRoot::syncIn() {
|
||||
QIcon original_icon = icon();
|
||||
|
||||
setIcon(qApp->icons()->fromTheme(QSL("item-sync")));
|
||||
itemChanged(QList<RootItem*>() << this);
|
||||
|
||||
RootItem *TtRssServiceRoot::obtainNewTreeForSyncIn() const {
|
||||
TtRssGetFeedsCategoriesResponse feed_cats_response = m_network->getFeedsCategories();
|
||||
|
||||
if (m_network->lastError() == QNetworkReply::NoError) {
|
||||
RootItem *new_tree = feed_cats_response.feedsCategories(true, m_network->url());
|
||||
|
||||
// Purge old data from SQL and clean all model items.
|
||||
requestItemExpandStateSave(this);
|
||||
removeOldFeedTree(false);
|
||||
cleanAllItems();
|
||||
|
||||
// Model is clean, now store new tree into DB and
|
||||
// set primary IDs of the items.
|
||||
storeNewFeedTree(new_tree);
|
||||
|
||||
// We have new feed, some feeds were maybe removed,
|
||||
// so remove left over messages.
|
||||
removeLeftOverMessages();
|
||||
|
||||
foreach (RootItem *top_level_item, new_tree->childItems()) {
|
||||
top_level_item->setParent(NULL);
|
||||
requestItemReassignment(top_level_item, this);
|
||||
}
|
||||
|
||||
updateCounts(true);
|
||||
|
||||
new_tree->clearChildren();
|
||||
new_tree->deleteLater();
|
||||
|
||||
QList<RootItem*> all_items = getSubTree();
|
||||
|
||||
itemChanged(all_items);
|
||||
requestReloadMessageList(true);
|
||||
|
||||
// Now we must refresh expand states.
|
||||
QList<RootItem*> items_to_expand;
|
||||
|
||||
foreach (RootItem *item, all_items) {
|
||||
if (qApp->settings()->value(GROUP(CategoriesExpandStates), item->hashCode(), item->childCount() > 0).toBool()) {
|
||||
items_to_expand.append(item);
|
||||
}
|
||||
}
|
||||
|
||||
requestItemExpand(items_to_expand, true);
|
||||
return feed_cats_response.feedsCategories(true, m_network->url());
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
setIcon(original_icon);
|
||||
itemChanged(QList<RootItem*>() << this);
|
||||
}
|
||||
|
|
|
@ -61,9 +61,10 @@ class TtRssServiceRoot : public ServiceRoot {
|
|||
public slots:
|
||||
void addNewFeed(const QString &url = QString());
|
||||
void addNewCategory();
|
||||
void syncIn();
|
||||
|
||||
private:
|
||||
RootItem *obtainNewTreeForSyncIn() const;
|
||||
|
||||
void loadFromDatabase();
|
||||
|
||||
TtRssRecycleBin *m_recycleBin;
|
||||
|
|
Loading…
Add table
Reference in a new issue