General work, will refactore some methods probably now.
This commit is contained in:
parent
85ca65bc39
commit
43b1aaa1a4
7 changed files with 24 additions and 17 deletions
|
@ -32,7 +32,7 @@ namespace RootItemKind {
|
||||||
// Describes the kind of the item.
|
// Describes the kind of the item.
|
||||||
enum Kind {
|
enum Kind {
|
||||||
Root = 1,
|
Root = 1,
|
||||||
Bin = 2,
|
Bin = 2,
|
||||||
Feed = 4,
|
Feed = 4,
|
||||||
Category = 8,
|
Category = 8,
|
||||||
ServiceRoot = 16
|
ServiceRoot = 16
|
||||||
|
@ -50,21 +50,20 @@ class RootItem : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Holds statuses for feeds/messages
|
||||||
|
// to be marked read/unread.
|
||||||
enum ReadStatus {
|
enum ReadStatus {
|
||||||
Unread = 0,
|
Unread = 0,
|
||||||
Read = 1
|
Read = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Holds statuses for messages
|
||||||
|
// to be switched importance (starred).
|
||||||
enum Importance {
|
enum Importance {
|
||||||
NotImportant = 0,
|
NotImportant = 0,
|
||||||
Important = 1
|
Important = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CleanStatus {
|
|
||||||
Clean,
|
|
||||||
Unclean
|
|
||||||
};
|
|
||||||
|
|
||||||
// Constructors and destructors.
|
// Constructors and destructors.
|
||||||
explicit RootItem(RootItem *parent_item = NULL);
|
explicit RootItem(RootItem *parent_item = NULL);
|
||||||
virtual ~RootItem();
|
virtual ~RootItem();
|
||||||
|
@ -104,7 +103,7 @@ class RootItem : public QObject {
|
||||||
// What "clean" means? It means delete messages -> move them to recycle bin
|
// What "clean" means? It means delete messages -> move them to recycle bin
|
||||||
// or eventually remove them completely if there is no recycle bin functionality.
|
// or eventually remove them completely if there is no recycle bin functionality.
|
||||||
// If this method is called on "recycle bin" instance of your
|
// If this method is called on "recycle bin" instance of your
|
||||||
// service account, it should NOT do anything.
|
// service account, it should "empty" the recycle bin.
|
||||||
virtual bool cleanMessages(bool clear_only_read);
|
virtual bool cleanMessages(bool clear_only_read);
|
||||||
|
|
||||||
// Updates counts of all/unread messages for this feed.
|
// Updates counts of all/unread messages for this feed.
|
||||||
|
|
|
@ -202,7 +202,7 @@ void FeedMessageViewer::updateFeedButtonsAvailability() {
|
||||||
|
|
||||||
form_main->m_ui->m_actionBackupDatabaseSettings->setEnabled(!critical_action_running);
|
form_main->m_ui->m_actionBackupDatabaseSettings->setEnabled(!critical_action_running);
|
||||||
form_main->m_ui->m_actionCleanupDatabase->setEnabled(!critical_action_running);
|
form_main->m_ui->m_actionCleanupDatabase->setEnabled(!critical_action_running);
|
||||||
form_main->m_ui->m_actionClearSelectedItems->setEnabled(feed_selected || category_selected || service_selected);
|
form_main->m_ui->m_actionClearSelectedItems->setEnabled(anything_selected);
|
||||||
form_main->m_ui->m_actionDeleteSelectedItem->setEnabled(!critical_action_running && anything_selected);
|
form_main->m_ui->m_actionDeleteSelectedItem->setEnabled(!critical_action_running && anything_selected);
|
||||||
form_main->m_ui->m_actionEditSelectedItem->setEnabled(!critical_action_running && anything_selected);
|
form_main->m_ui->m_actionEditSelectedItem->setEnabled(!critical_action_running && anything_selected);
|
||||||
form_main->m_ui->m_actionMarkSelectedItemsAsRead->setEnabled(anything_selected);
|
form_main->m_ui->m_actionMarkSelectedItemsAsRead->setEnabled(anything_selected);
|
||||||
|
@ -210,7 +210,7 @@ void FeedMessageViewer::updateFeedButtonsAvailability() {
|
||||||
form_main->m_ui->m_actionUpdateAllItems->setEnabled(!critical_action_running);
|
form_main->m_ui->m_actionUpdateAllItems->setEnabled(!critical_action_running);
|
||||||
form_main->m_ui->m_actionUpdateSelectedItems->setEnabled(!critical_action_running && (feed_selected || category_selected || service_selected));
|
form_main->m_ui->m_actionUpdateSelectedItems->setEnabled(!critical_action_running && (feed_selected || category_selected || service_selected));
|
||||||
form_main->m_ui->m_actionViewSelectedItemsNewspaperMode->setEnabled(feed_selected || category_selected || service_selected);
|
form_main->m_ui->m_actionViewSelectedItemsNewspaperMode->setEnabled(feed_selected || category_selected || service_selected);
|
||||||
form_main->m_ui->m_actionExpandCollapseItem->setEnabled(feed_selected || category_selected || service_selected);
|
form_main->m_ui->m_actionExpandCollapseItem->setEnabled(anything_selected);
|
||||||
form_main->m_ui->m_menuAddItem->setEnabled(!critical_action_running);
|
form_main->m_ui->m_menuAddItem->setEnabled(!critical_action_running);
|
||||||
form_main->m_ui->m_menuRecycleBin->setEnabled(!critical_action_running);
|
form_main->m_ui->m_menuRecycleBin->setEnabled(!critical_action_running);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ bool RecycleBin::markAsReadUnread(RootItem::ReadStatus status) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RecycleBin::empty() {
|
bool RecycleBin::cleanMessages(bool clear_only_read) {
|
||||||
QSqlDatabase db_handle = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
QSqlDatabase db_handle = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||||
|
|
||||||
if (!db_handle.transaction()) {
|
if (!db_handle.transaction()) {
|
||||||
|
@ -139,7 +139,15 @@ bool RecycleBin::empty() {
|
||||||
QSqlQuery query_empty_bin(db_handle);
|
QSqlQuery query_empty_bin(db_handle);
|
||||||
|
|
||||||
query_empty_bin.setForwardOnly(true);
|
query_empty_bin.setForwardOnly(true);
|
||||||
query_empty_bin.prepare(QSL("UPDATE Messages SET is_pdeleted = 1 WHERE is_deleted = 1 AND account_id = :account_id;"));
|
|
||||||
|
if (clear_only_read) {
|
||||||
|
query_empty_bin.prepare("UPDATE Messages SET is_pdeleted = 1 "
|
||||||
|
"WHERE is_read = 1 AND is_deleted = 1 AND account_id = :account_id;");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
query_empty_bin.prepare(QSL("UPDATE Messages SET is_pdeleted = 1 WHERE is_deleted = 1 AND account_id = :account_id;"));
|
||||||
|
}
|
||||||
|
|
||||||
query_empty_bin.bindValue(QSL(":account_id"), parent_root->accountId());
|
query_empty_bin.bindValue(QSL(":account_id"), parent_root->accountId());
|
||||||
|
|
||||||
if (!query_empty_bin.exec()) {
|
if (!query_empty_bin.exec()) {
|
||||||
|
@ -161,6 +169,10 @@ bool RecycleBin::empty() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RecycleBin::empty() {
|
||||||
|
return cleanMessages(false);
|
||||||
|
}
|
||||||
|
|
||||||
bool RecycleBin::restore() {
|
bool RecycleBin::restore() {
|
||||||
QSqlDatabase db_handle = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
QSqlDatabase db_handle = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ class RecycleBin : public RootItem {
|
||||||
QVariant data(int column, int role) const;
|
QVariant data(int column, int role) const;
|
||||||
|
|
||||||
bool markAsReadUnread(ReadStatus status);
|
bool markAsReadUnread(ReadStatus status);
|
||||||
|
bool cleanMessages(bool clear_only_read);
|
||||||
|
|
||||||
|
|
||||||
int countOfUnreadMessages() const;
|
int countOfUnreadMessages() const;
|
||||||
int countOfAllMessages() const;
|
int countOfAllMessages() const;
|
||||||
|
|
|
@ -133,4 +133,3 @@ void ServiceRoot::assembleCategories(Assignment categories) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,6 @@ RootItem *TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: stahnout a nastavit ikonu
|
|
||||||
feed->setTitle(item["name"].toString());
|
feed->setTitle(item["name"].toString());
|
||||||
feed->setCustomId(item_id);
|
feed->setCustomId(item_id);
|
||||||
act_parent->appendChild(feed);
|
act_parent->appendChild(feed);
|
||||||
|
|
|
@ -268,8 +268,6 @@ void TtRssServiceRoot::saveAccountDataToDatabase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TtRssServiceRoot::loadFromDatabase() {
|
void TtRssServiceRoot::loadFromDatabase() {
|
||||||
// TODO: Load feeds/categories from DB.
|
|
||||||
|
|
||||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||||
Assignment categories;
|
Assignment categories;
|
||||||
Assignment feeds;
|
Assignment feeds;
|
||||||
|
@ -444,7 +442,6 @@ void TtRssServiceRoot::storeNewFeedTree(RootItem *root) {
|
||||||
child->setId(query_category.lastInsertId().toInt());
|
child->setId(query_category.lastInsertId().toInt());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO: logovat
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (child->kind() == RootItemKind::Feed) {
|
else if (child->kind() == RootItemKind::Feed) {
|
||||||
|
@ -463,7 +460,6 @@ void TtRssServiceRoot::storeNewFeedTree(RootItem *root) {
|
||||||
feed->setId(query_feed.lastInsertId().toInt());
|
feed->setId(query_feed.lastInsertId().toInt());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO: logovat.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue