From bf3d97dd2c3232ceb283a824ccfc4db3be980712 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 30 Nov 2015 12:53:04 +0100 Subject: [PATCH] Reloaded langs + removed direct access to model from items - better encapsulation. --- localization/rssguard-cs_CZ.ts | 131 +++++++++++------ localization/rssguard-de_DE.ts | 133 ++++++++++++------ localization/rssguard-en_GB.ts | 131 +++++++++++------ localization/rssguard-en_US.ts | 131 +++++++++++------ localization/rssguard-fr_FR.ts | 131 +++++++++++------ localization/rssguard-it_IT.ts | 131 +++++++++++------ localization/rssguard-nl_NL.ts | 131 +++++++++++------ localization/rssguard-sv_SE.ts | 131 +++++++++++------ src/core/feedsmodel.cpp | 11 +- src/core/feedsmodel.h | 11 +- src/gui/dialogs/formaddaccount.cpp | 2 +- src/services/abstract/serviceentrypoint.h | 4 +- src/services/abstract/serviceroot.cpp | 14 +- src/services/abstract/serviceroot.h | 12 +- .../gui/formstandardcategorydetails.cpp | 4 +- .../standard/gui/formstandardfeeddetails.cpp | 4 +- src/services/standard/standardcategory.cpp | 4 +- src/services/standard/standardfeed.cpp | 4 +- .../standardfeedsimportexportmodel.cpp | 2 +- .../standard/standardserviceentrypoint.cpp | 8 +- .../standard/standardserviceentrypoint.h | 4 +- src/services/standard/standardserviceroot.cpp | 13 +- src/services/standard/standardserviceroot.h | 2 +- .../tt-rss/ttrssserviceentrypoint.cpp | 4 +- src/services/tt-rss/ttrssserviceentrypoint.h | 4 +- src/services/tt-rss/ttrssserviceroot.cpp | 2 +- src/services/tt-rss/ttrssserviceroot.h | 2 +- 27 files changed, 787 insertions(+), 374 deletions(-) diff --git a/localization/rssguard-cs_CZ.ts b/localization/rssguard-cs_CZ.ts index 01e69ac57..c599b7864 100644 --- a/localization/rssguard-cs_CZ.ts +++ b/localization/rssguard-cs_CZ.ts @@ -513,6 +513,14 @@ Klikněte sem pro otevření nadřazeného adresáře. New messages downloaded Staženy nové zprávy + + Cannot perform drag & drop operation. + + + + You can't transfer dragged item into different account, this is not supported. + + FeedsToolBar @@ -661,6 +669,45 @@ or this functionality is not implemented yet. <body>%5 je (velmi) lehkotonážní prohlížeč kanálů.<br><br>Tento software je distribuován pod licencí GNU General Public License, verze 3.<br><br>Kontakty:<ul><li><a href="mailto://%1">%1</a> ~e-mail</li><li><a href="%2">%2</a> ~web</li></ul>Zdrojový kór pro %5 lze získat na jeho webu.<br><br><br>Copyright (C) 2011-%3 %4</body> + + FormAddAccount + + Add new account + + + + Details + + + + Name + Název + + + Version + Verze + + + Author + Autor + + + Description + Popis + + + Cannot add account + + + + Some critical error occurred, report this to developers. + + + + This account can be added only once. + + + FormBackupDatabaseSettings @@ -881,10 +928,6 @@ or this functionality is not implemented yet. No actions are available right now. Žádná akce není právě dostupná. - - Fee&ds && categories - Kanály && ka&tegorie - Hides main window if it is visible and shows it if it is hidden. Skryje hlavní ikno, je-li aktuálně viditelné. Jinak jej zobrazí. @@ -1061,26 +1104,14 @@ or this functionality is not implemented yet. Add &new item - - &Services - - Update &all items - - Ctrl+Shift+U - - Update &selected items - - Ctrl+U - - &Edit selected item @@ -1137,26 +1168,14 @@ or this functionality is not implemented yet. Deletes all messages from all items. - - Ctrl+Shift+C - - Select &next item - - S - - Select &previous item - - A - - Show only unread items @@ -1165,22 +1184,10 @@ or this functionality is not implemented yet. &Expand/collapse selected item - - E - - &Add new service account - - &Delete selected service account - - - - &Edit selected service account - - &Restore selected messages @@ -1189,6 +1196,38 @@ or this functionality is not implemented yet. No possible actions + + Feeds && categories && accounts + + + + &Recycle bin(s) + + + + &Restore all recycle bins + + + + &Empty all recycle bins + + + + Select next &unread message + + + + No recycle bin + + + + Restore recycle bin + + + + Empty recycle bin + + FormRestoreDatabaseSettings @@ -1918,6 +1957,10 @@ File filter for external e-mail selection dialog. E-mail + + Enable notifications + + FormStandardCategoryDetails @@ -3281,6 +3324,14 @@ Nepřečtené zprávy: %2 Stop web page loading. Zastavit načítání aktuální webové stránky. + + Cannot add feed + Nelze přidat kanál + + + You cannot add this feed to %1 because standard RSS/ATOM account is not enabled. Enable it first. + + WebView diff --git a/localization/rssguard-de_DE.ts b/localization/rssguard-de_DE.ts index 7bb8c54f1..b6048b99d 100644 --- a/localization/rssguard-de_DE.ts +++ b/localization/rssguard-de_DE.ts @@ -502,6 +502,14 @@ Click here to open parent directory. New messages downloaded + + Cannot perform drag & drop operation. + + + + You can't transfer dragged item into different account, this is not supported. + + FeedsToolBar @@ -650,6 +658,45 @@ or this functionality is not implemented yet. + + FormAddAccount + + Add new account + + + + Details + + + + Name + Name + + + Version + Version + + + Author + Author + + + Description + Beschreibung + + + Cannot add account + + + + Some critical error occurred, report this to developers. + + + + This account can be added only once. + + + FormBackupDatabaseSettings @@ -869,10 +916,6 @@ or this functionality is not implemented yet. No actions are available right now. Keine Funktionen verfügbar. - - Fee&ds && categories - Fee&ds && Kategorien - Hides main window if it is visible and shows it if it is hidden. Hauptfenster verstecken falls es sichtbar was oder sichtbar falls es versteckt war. @@ -1049,26 +1092,14 @@ or this functionality is not implemented yet. Add &new item - - &Services - - Update &all items - - Ctrl+Shift+U - - Update &selected items - - Ctrl+U - - &Edit selected item @@ -1125,26 +1156,14 @@ or this functionality is not implemented yet. Deletes all messages from all items. - - Ctrl+Shift+C - - Select &next item - - S - - Select &previous item - - A - - Show only unread items @@ -1153,22 +1172,10 @@ or this functionality is not implemented yet. &Expand/collapse selected item - - E - - &Add new service account - - &Delete selected service account - - - - &Edit selected service account - - &Restore selected messages @@ -1177,6 +1184,38 @@ or this functionality is not implemented yet. No possible actions + + Feeds && categories && accounts + + + + &Recycle bin(s) + + + + &Restore all recycle bins + + + + &Empty all recycle bins + + + + Select next &unread message + + + + No recycle bin + + + + Restore recycle bin + + + + Empty recycle bin + + FormRestoreDatabaseSettings @@ -1888,6 +1927,10 @@ File filter for external e-mail selection dialog. E-mail + + Enable notifications + + FormStandardCategoryDetails @@ -2053,7 +2096,7 @@ File filter for external e-mail selection dialog. minutes - + Minuten Title @@ -3239,6 +3282,14 @@ Unread news: %2 Stop web page loading. Stoppe das laden der Webseite. + + Cannot add feed + Kann Feed nicht hinzufügen + + + You cannot add this feed to %1 because standard RSS/ATOM account is not enabled. Enable it first. + + WebView diff --git a/localization/rssguard-en_GB.ts b/localization/rssguard-en_GB.ts index 0bfaa0d1b..ec621f51b 100644 --- a/localization/rssguard-en_GB.ts +++ b/localization/rssguard-en_GB.ts @@ -502,6 +502,14 @@ Click here to open parent directory. New messages downloaded + + Cannot perform drag & drop operation. + + + + You can't transfer dragged item into different account, this is not supported. + + FeedsToolBar @@ -650,6 +658,45 @@ or this functionality is not implemented yet. + + FormAddAccount + + Add new account + + + + Details + + + + Name + + + + Version + + + + Author + + + + Description + + + + Cannot add account + + + + Some critical error occurred, report this to developers. + + + + This account can be added only once. + + + FormBackupDatabaseSettings @@ -869,10 +916,6 @@ or this functionality is not implemented yet. No actions are available right now. - - Fee&ds && categories - - Hides main window if it is visible and shows it if it is hidden. @@ -1049,26 +1092,14 @@ or this functionality is not implemented yet. Add &new item - - &Services - - Update &all items - - Ctrl+Shift+U - - Update &selected items - - Ctrl+U - - &Edit selected item @@ -1125,26 +1156,14 @@ or this functionality is not implemented yet. Deletes all messages from all items. - - Ctrl+Shift+C - - Select &next item - - S - - Select &previous item - - A - - Show only unread items @@ -1153,22 +1172,10 @@ or this functionality is not implemented yet. &Expand/collapse selected item - - E - - &Add new service account - - &Delete selected service account - - - - &Edit selected service account - - &Restore selected messages @@ -1177,6 +1184,38 @@ or this functionality is not implemented yet. No possible actions + + Feeds && categories && accounts + + + + &Recycle bin(s) + + + + &Restore all recycle bins + + + + &Empty all recycle bins + + + + Select next &unread message + + + + No recycle bin + + + + Restore recycle bin + + + + Empty recycle bin + + FormRestoreDatabaseSettings @@ -1886,6 +1925,10 @@ File filter for external e-mail selection dialog. E-mail + + Enable notifications + + FormStandardCategoryDetails @@ -3234,6 +3277,14 @@ Unread news: %2 Stop web page loading. + + Cannot add feed + + + + You cannot add this feed to %1 because standard RSS/ATOM account is not enabled. Enable it first. + + WebView diff --git a/localization/rssguard-en_US.ts b/localization/rssguard-en_US.ts index 4e3226e75..c5bec6629 100644 --- a/localization/rssguard-en_US.ts +++ b/localization/rssguard-en_US.ts @@ -502,6 +502,14 @@ Click here to open parent directory. New messages downloaded + + Cannot perform drag & drop operation. + + + + You can't transfer dragged item into different account, this is not supported. + + FeedsToolBar @@ -650,6 +658,45 @@ or this functionality is not implemented yet. + + FormAddAccount + + Add new account + + + + Details + + + + Name + + + + Version + + + + Author + + + + Description + + + + Cannot add account + + + + Some critical error occurred, report this to developers. + + + + This account can be added only once. + + + FormBackupDatabaseSettings @@ -869,10 +916,6 @@ or this functionality is not implemented yet. No actions are available right now. - - Fee&ds && categories - - Hides main window if it is visible and shows it if it is hidden. @@ -1049,26 +1092,14 @@ or this functionality is not implemented yet. Add &new item - - &Services - - Update &all items - - Ctrl+Shift+U - - Update &selected items - - Ctrl+U - - &Edit selected item @@ -1125,26 +1156,14 @@ or this functionality is not implemented yet. Deletes all messages from all items. - - Ctrl+Shift+C - - Select &next item - - S - - Select &previous item - - A - - Show only unread items @@ -1153,22 +1172,10 @@ or this functionality is not implemented yet. &Expand/collapse selected item - - E - - &Add new service account - - &Delete selected service account - - - - &Edit selected service account - - &Restore selected messages @@ -1177,6 +1184,38 @@ or this functionality is not implemented yet. No possible actions + + Feeds && categories && accounts + + + + &Recycle bin(s) + + + + &Restore all recycle bins + + + + &Empty all recycle bins + + + + Select next &unread message + + + + No recycle bin + + + + Restore recycle bin + + + + Empty recycle bin + + FormRestoreDatabaseSettings @@ -1886,6 +1925,10 @@ File filter for external e-mail selection dialog. E-mail + + Enable notifications + + FormStandardCategoryDetails @@ -3234,6 +3277,14 @@ Unread news: %2 Stop web page loading. + + Cannot add feed + + + + You cannot add this feed to %1 because standard RSS/ATOM account is not enabled. Enable it first. + + WebView diff --git a/localization/rssguard-fr_FR.ts b/localization/rssguard-fr_FR.ts index ea5667b98..bf084b1aa 100644 --- a/localization/rssguard-fr_FR.ts +++ b/localization/rssguard-fr_FR.ts @@ -502,6 +502,14 @@ Click here to open parent directory. New messages downloaded + + Cannot perform drag & drop operation. + + + + You can't transfer dragged item into different account, this is not supported. + + FeedsToolBar @@ -650,6 +658,45 @@ or this functionality is not implemented yet. + + FormAddAccount + + Add new account + + + + Details + + + + Name + Nom + + + Version + Version + + + Author + Auteur + + + Description + Description + + + Cannot add account + + + + Some critical error occurred, report this to developers. + + + + This account can be added only once. + + + FormBackupDatabaseSettings @@ -869,10 +916,6 @@ or this functionality is not implemented yet. No actions are available right now. Aucune actions disponibles pour le moment. - - Fee&ds && categories - Flux && catégories - Hides main window if it is visible and shows it if it is hidden. Cacher la fenêtre principale si il est visible et la montrer si il est cacher. @@ -1049,26 +1092,14 @@ or this functionality is not implemented yet. Add &new item - - &Services - - Update &all items - - Ctrl+Shift+U - - Update &selected items - - Ctrl+U - - &Edit selected item @@ -1125,26 +1156,14 @@ or this functionality is not implemented yet. Deletes all messages from all items. - - Ctrl+Shift+C - - Select &next item - - S - - Select &previous item - - A - - Show only unread items @@ -1153,22 +1172,10 @@ or this functionality is not implemented yet. &Expand/collapse selected item - - E - - &Add new service account - - &Delete selected service account - - - - &Edit selected service account - - &Restore selected messages @@ -1177,6 +1184,38 @@ or this functionality is not implemented yet. No possible actions + + Feeds && categories && accounts + + + + &Recycle bin(s) + + + + &Restore all recycle bins + + + + &Empty all recycle bins + + + + Select next &unread message + + + + No recycle bin + + + + Restore recycle bin + + + + Empty recycle bin + + FormRestoreDatabaseSettings @@ -1898,6 +1937,10 @@ File filter for external e-mail selection dialog. E-mail + + Enable notifications + + FormStandardCategoryDetails @@ -3250,6 +3293,14 @@ Unread news: %2 Stop web page loading. Arrêter le chargement de la page + + Cannot add feed + Impossible d'ajouter le flux + + + You cannot add this feed to %1 because standard RSS/ATOM account is not enabled. Enable it first. + + WebView diff --git a/localization/rssguard-it_IT.ts b/localization/rssguard-it_IT.ts index e6470cfc7..6e51a123f 100644 --- a/localization/rssguard-it_IT.ts +++ b/localization/rssguard-it_IT.ts @@ -502,6 +502,14 @@ Click here to open parent directory. New messages downloaded + + Cannot perform drag & drop operation. + + + + You can't transfer dragged item into different account, this is not supported. + + FeedsToolBar @@ -650,6 +658,45 @@ or this functionality is not implemented yet. + + FormAddAccount + + Add new account + + + + Details + + + + Name + Nome + + + Version + Versione + + + Author + Autore + + + Description + Descrizione + + + Cannot add account + + + + Some critical error occurred, report this to developers. + + + + This account can be added only once. + + + FormBackupDatabaseSettings @@ -869,10 +916,6 @@ or this functionality is not implemented yet. No actions are available right now. Non è disponibile nessuna azione adesso. - - Fee&ds && categories - - Hides main window if it is visible and shows it if it is hidden. Nasconde la finestra principale se è visibile e la mostra se è nascosta. @@ -1049,26 +1092,14 @@ or this functionality is not implemented yet. Add &new item - - &Services - - Update &all items - - Ctrl+Shift+U - - Update &selected items - - Ctrl+U - - &Edit selected item @@ -1125,26 +1156,14 @@ or this functionality is not implemented yet. Deletes all messages from all items. - - Ctrl+Shift+C - - Select &next item - - S - - Select &previous item - - A - - Show only unread items @@ -1153,22 +1172,10 @@ or this functionality is not implemented yet. &Expand/collapse selected item - - E - - &Add new service account - - &Delete selected service account - - - - &Edit selected service account - - &Restore selected messages @@ -1177,6 +1184,38 @@ or this functionality is not implemented yet. No possible actions + + Feeds && categories && accounts + + + + &Recycle bin(s) + + + + &Restore all recycle bins + + + + &Empty all recycle bins + + + + Select next &unread message + + + + No recycle bin + + + + Restore recycle bin + + + + Empty recycle bin + + FormRestoreDatabaseSettings @@ -1888,6 +1927,10 @@ File filter for external e-mail selection dialog. E-mail + + Enable notifications + + FormStandardCategoryDetails @@ -3239,6 +3282,14 @@ Unread news: %2 Stop web page loading. Ferma caricamento pagina web. + + Cannot add feed + Impossibile aggiungere feed + + + You cannot add this feed to %1 because standard RSS/ATOM account is not enabled. Enable it first. + + WebView diff --git a/localization/rssguard-nl_NL.ts b/localization/rssguard-nl_NL.ts index 3eb26b7e7..668f3e1e0 100644 --- a/localization/rssguard-nl_NL.ts +++ b/localization/rssguard-nl_NL.ts @@ -508,6 +508,14 @@ Klik hier om map te openen. New messages downloaded Nieuw bericht gedownload + + Cannot perform drag & drop operation. + + + + You can't transfer dragged item into different account, this is not supported. + + FeedsToolBar @@ -656,6 +664,45 @@ or this functionality is not implemented yet. + + FormAddAccount + + Add new account + + + + Details + + + + Name + Naam + + + Version + Versie + + + Author + Auteur + + + Description + Omschrijving + + + Cannot add account + + + + Some critical error occurred, report this to developers. + + + + This account can be added only once. + + + FormBackupDatabaseSettings @@ -875,10 +922,6 @@ or this functionality is not implemented yet. No actions are available right now. Er zijn geen acties beschikbaar op dit moment. - - Fee&ds && categories - Fee&ds && categorieën - Hides main window if it is visible and shows it if it is hidden. Verberg hoofdvenster als het zichtbaar is en toon het als het verborgen is. @@ -1055,26 +1098,14 @@ or this functionality is not implemented yet. Add &new item - - &Services - - Update &all items - - Ctrl+Shift+U - - Update &selected items - - Ctrl+U - - &Edit selected item @@ -1131,26 +1162,14 @@ or this functionality is not implemented yet. Deletes all messages from all items. - - Ctrl+Shift+C - - Select &next item - - S - - Select &previous item - - A - - Show only unread items @@ -1159,22 +1178,10 @@ or this functionality is not implemented yet. &Expand/collapse selected item - - E - - &Add new service account - - &Delete selected service account - - - - &Edit selected service account - - &Restore selected messages @@ -1183,6 +1190,38 @@ or this functionality is not implemented yet. No possible actions + + Feeds && categories && accounts + + + + &Recycle bin(s) + + + + &Restore all recycle bins + + + + &Empty all recycle bins + + + + Select next &unread message + + + + No recycle bin + + + + Restore recycle bin + + + + Empty recycle bin + + FormRestoreDatabaseSettings @@ -1920,6 +1959,10 @@ Open nieuw webbrowser pagina(sleep muis omlaag). E-mail + + Enable notifications + + FormStandardCategoryDetails @@ -3280,6 +3323,14 @@ Ongelezen nieuws: %2 Stop web page loading. Stop het laden van pagina. + + Cannot add feed + Kan geen feed toevoegen + + + You cannot add this feed to %1 because standard RSS/ATOM account is not enabled. Enable it first. + + WebView diff --git a/localization/rssguard-sv_SE.ts b/localization/rssguard-sv_SE.ts index d8a9d5c06..340d6b031 100644 --- a/localization/rssguard-sv_SE.ts +++ b/localization/rssguard-sv_SE.ts @@ -507,6 +507,14 @@ Klicka här för att öppna målmappen. New messages downloaded Nya meddelanden nedladdade + + Cannot perform drag & drop operation. + + + + You can't transfer dragged item into different account, this is not supported. + + FeedsToolBar @@ -655,6 +663,45 @@ or this functionality is not implemented yet. + + FormAddAccount + + Add new account + + + + Details + + + + Name + Namn + + + Version + Version + + + Author + + + + Description + Beskrivning + + + Cannot add account + + + + Some critical error occurred, report this to developers. + + + + This account can be added only once. + + + FormBackupDatabaseSettings @@ -874,10 +921,6 @@ or this functionality is not implemented yet. No actions are available right now. Inga åtgärder tillgängliga just nu. - - Fee&ds && categories - &Flöden && kategorier - Hides main window if it is visible and shows it if it is hidden. Dölj programfönstret om det är synligt, och visa det om det är dolt. @@ -1054,26 +1097,14 @@ or this functionality is not implemented yet. Add &new item - - &Services - - Update &all items - - Ctrl+Shift+U - - Update &selected items - - Ctrl+U - - &Edit selected item @@ -1130,26 +1161,14 @@ or this functionality is not implemented yet. Deletes all messages from all items. - - Ctrl+Shift+C - - Select &next item - - S - - Select &previous item - - A - - Show only unread items @@ -1158,22 +1177,10 @@ or this functionality is not implemented yet. &Expand/collapse selected item - - E - - &Add new service account - - &Delete selected service account - - - - &Edit selected service account - - &Restore selected messages @@ -1182,6 +1189,38 @@ or this functionality is not implemented yet. No possible actions + + Feeds && categories && accounts + + + + &Recycle bin(s) + + + + &Restore all recycle bins + + + + &Empty all recycle bins + + + + Select next &unread message + + + + No recycle bin + + + + Restore recycle bin + + + + Empty recycle bin + + FormRestoreDatabaseSettings @@ -1912,6 +1951,10 @@ File filter for external e-mail selection dialog. E-mail + + Enable notifications + + FormStandardCategoryDetails @@ -3270,6 +3313,14 @@ Olästa nyheter: %2 Stop web page loading. Stoppa inläsning av webbsidan. + + Cannot add feed + Kan inte lägga till flöde + + + You cannot add this feed to %1 because standard RSS/ATOM account is not enabled. Enable it first. + + WebView diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 66652ed54..c92dd72ae 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -685,12 +685,15 @@ void FeedsModel::reloadWholeLayout() { } bool FeedsModel::addServiceAccount(ServiceRoot *root) { - m_rootItem->appendChild(root); + int new_row_index = m_rootItem->childCount(); - // Item add, reload da shit. - reloadWholeLayout(); + beginInsertRows(indexForItem(m_rootItem), new_row_index, new_row_index); + m_rootItem->appendChild(root); + endInsertRows(); // Connect. + connect(root, SIGNAL(itemRemovalRequested(RootItem*)), this, SLOT(removeItem(RootItem*))); + connect(root, SIGNAL(itemReassignmentRequested(RootItem*,RootItem*)), this, SLOT(reassignNodeToNewParent(RootItem*,RootItem*))); connect(root, SIGNAL(readFeedsFilterInvalidationRequested()), this, SIGNAL(readFeedsFilterInvalidationRequested())); connect(root, SIGNAL(dataChanged(QList)), this, SLOT(onItemDataChanged(QList))); connect(root, SIGNAL(reloadMessageListRequested(bool)), this, SIGNAL(reloadMessageListRequested(bool))); @@ -731,7 +734,7 @@ void FeedsModel::loadActivatedServiceAccounts() { // Iterate all globally available feed "service plugins". foreach (ServiceEntryPoint *entry_point, qApp->feedServices()) { // Load all stored root nodes from the entry point and add those to the model. - QList roots = entry_point->initializeSubtree(this); + QList roots = entry_point->initializeSubtree(); foreach (ServiceRoot *root, roots) { addServiceAccount(root); diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index d99ce010f..83df548e5 100755 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -75,11 +75,6 @@ class FeedsModel : public QAbstractItemModel { // Removes item with given index. // NOTE: Also deletes item from memory. void removeItem(const QModelIndex &index); - void removeItem(RootItem *deleting_item); - - // Checks if new parent node is different from one used by original node. - // If it is, then it reassigns original_node to new parent. - void reassignNodeToNewParent(RootItem *original_node, RootItem *new_parent); // Returns all activated service roots. // NOTE: Service root nodes are lying directly UNDER @@ -157,6 +152,12 @@ class FeedsModel : public QAbstractItemModel { bool addServiceAccount(ServiceRoot *root); public slots: + // Checks if new parent node is different from one used by original node. + // If it is, then it reassigns original_node to new parent. + void reassignNodeToNewParent(RootItem *original_node, RootItem *new_parent); + + void removeItem(RootItem *deleting_item); + bool restoreAllBins(); bool emptyAllBins(); diff --git a/src/gui/dialogs/formaddaccount.cpp b/src/gui/dialogs/formaddaccount.cpp index 4d86eaf14..38d7d2e68 100755 --- a/src/gui/dialogs/formaddaccount.cpp +++ b/src/gui/dialogs/formaddaccount.cpp @@ -52,7 +52,7 @@ void FormAddAccount::addSelectedAccount() { accept(); ServiceEntryPoint *point = selectedEntryPoint(); - ServiceRoot *new_root = point->createNewRoot(m_model); + ServiceRoot *new_root = point->createNewRoot(); if (new_root != NULL) { m_model->addServiceAccount(new_root); diff --git a/src/services/abstract/serviceentrypoint.h b/src/services/abstract/serviceentrypoint.h index 4602666a8..1cefafa83 100755 --- a/src/services/abstract/serviceentrypoint.h +++ b/src/services/abstract/serviceentrypoint.h @@ -38,13 +38,13 @@ class ServiceEntryPoint { // some kind of first-time configuration dialog inside itself // before returning the root item. // Returns NULL if initialization of new root cannot be done. - virtual ServiceRoot *createNewRoot(FeedsModel *main_model) = 0; + virtual ServiceRoot *createNewRoot() = 0; // Performs initialization of all service accounts created using this entry // point from persistent DB. // Returns list of root nodes which will be afterwards added // to the global feed model. - virtual QList initializeSubtree(FeedsModel *main_model) = 0; + virtual QList initializeSubtree() = 0; // Can this service account be added just once? // NOTE: This is true particularly for "standard" service diff --git a/src/services/abstract/serviceroot.cpp b/src/services/abstract/serviceroot.cpp index 9a68e01d7..61c002824 100755 --- a/src/services/abstract/serviceroot.cpp +++ b/src/services/abstract/serviceroot.cpp @@ -20,17 +20,13 @@ #include "core/feedsmodel.h" -ServiceRoot::ServiceRoot(FeedsModel *feeds_model, RootItem *parent) : RootItem(parent), m_feedsModel(feeds_model) { +ServiceRoot::ServiceRoot(RootItem *parent) : RootItem(parent) { setKind(RootItemKind::ServiceRoot); } ServiceRoot::~ServiceRoot() { } -FeedsModel *ServiceRoot::feedsModel() const { - return m_feedsModel; -} - void ServiceRoot::itemChanged(QList items) { emit dataChanged(items); } @@ -42,3 +38,11 @@ void ServiceRoot::requestReloadMessageList(bool mark_selected_messages_read) { void ServiceRoot::requestFeedReadFilterReload() { emit readFeedsFilterInvalidationRequested(); } + +void ServiceRoot::requestItemReassignment(RootItem *item, RootItem *new_parent) { + emit itemReassignmentRequested(item, new_parent); +} + +void ServiceRoot::requestItemRemoval(RootItem *item) { + emit itemRemovalRequested(item); +} diff --git a/src/services/abstract/serviceroot.h b/src/services/abstract/serviceroot.h index d335020de..954df1a19 100755 --- a/src/services/abstract/serviceroot.h +++ b/src/services/abstract/serviceroot.h @@ -37,7 +37,7 @@ class ServiceRoot : public RootItem { Q_OBJECT public: - explicit ServiceRoot(FeedsModel *feeds_model, RootItem *parent = NULL); + explicit ServiceRoot(RootItem *parent = NULL); virtual ~ServiceRoot(); // Returns list of specific actions for "Add new item" main window menu. @@ -125,22 +125,22 @@ class ServiceRoot : public RootItem { // Selected item is naturally recycle bin. virtual bool onAfterMessagesRestoredFromBin(RootItem *selected_item, QList message_db_ids) = 0; - // Access to feed model. - FeedsModel *feedsModel() const; - // Obvious methods to wrap signals. void itemChanged(QList items); void requestReloadMessageList(bool mark_selected_messages_read); void requestFeedReadFilterReload(); + void requestItemReassignment(RootItem *item, RootItem *new_parent); + void requestItemRemoval(RootItem *item); + signals: // Emitted if data in any item belonging to this root are changed. void dataChanged(QList items); void readFeedsFilterInvalidationRequested(); void reloadMessageListRequested(bool mark_selected_messages_read); - private: - FeedsModel *m_feedsModel; + void itemReassignmentRequested(RootItem *item, RootItem *new_parent); + void itemRemovalRequested(RootItem *item); }; #endif // SERVICEROOT_H diff --git a/src/services/standard/gui/formstandardcategorydetails.cpp b/src/services/standard/gui/formstandardcategorydetails.cpp index 5c78d9958..86c6521a3 100755 --- a/src/services/standard/gui/formstandardcategorydetails.cpp +++ b/src/services/standard/gui/formstandardcategorydetails.cpp @@ -122,7 +122,7 @@ void FormStandardCategoryDetails::apply() { if (m_editableCategory == NULL) { // Add the category. if (new_category->addItself(parent)) { - m_serviceRoot->feedsModel()->reassignNodeToNewParent(new_category, parent); + m_serviceRoot->requestItemReassignment(new_category, parent); accept(); } else { @@ -139,7 +139,7 @@ void FormStandardCategoryDetails::apply() { bool edited = m_editableCategory->editItself(new_category); if (edited) { - m_serviceRoot->feedsModel()->reassignNodeToNewParent(m_editableCategory, new_category->parent()); + m_serviceRoot->requestItemReassignment(m_editableCategory, new_category->parent()); accept(); } else { diff --git a/src/services/standard/gui/formstandardfeeddetails.cpp b/src/services/standard/gui/formstandardfeeddetails.cpp index c6ccde65b..fa7dd493a 100755 --- a/src/services/standard/gui/formstandardfeeddetails.cpp +++ b/src/services/standard/gui/formstandardfeeddetails.cpp @@ -241,7 +241,7 @@ void FormStandardFeedDetails::apply() { if (m_editableFeed == NULL) { // Add the feed. if (new_feed->addItself(parent)) { - m_serviceRoot->feedsModel()->reassignNodeToNewParent(new_feed, parent); + m_serviceRoot->requestItemReassignment(new_feed, parent); accept(); } else { @@ -258,7 +258,7 @@ void FormStandardFeedDetails::apply() { bool edited = m_editableFeed->editItself(new_feed); if (edited) { - m_serviceRoot->feedsModel()->reassignNodeToNewParent(m_editableFeed, new_feed->parent()); + m_serviceRoot->requestItemReassignment(m_editableFeed, new_feed->parent()); accept(); } else { diff --git a/src/services/standard/standardcategory.cpp b/src/services/standard/standardcategory.cpp index ceca4f418..dc7a940b3 100755 --- a/src/services/standard/standardcategory.cpp +++ b/src/services/standard/standardcategory.cpp @@ -100,7 +100,7 @@ bool StandardCategory::performDragDropChange(RootItem *target_item) { category_new->setParent(target_item); if (editItself(category_new)) { - serviceRoot()->feedsModel()->reassignNodeToNewParent(this, target_item); + serviceRoot()->requestItemReassignment(this, target_item); delete category_new; return true; } @@ -120,7 +120,7 @@ bool StandardCategory::editViaGui() { bool StandardCategory::deleteViaGui() { if (removeItself()) { - serviceRoot()->feedsModel()->removeItem(this); + serviceRoot()->requestItemRemoval(this); return true; } else { diff --git a/src/services/standard/standardfeed.cpp b/src/services/standard/standardfeed.cpp index 36e2ad098..91125f8c3 100755 --- a/src/services/standard/standardfeed.cpp +++ b/src/services/standard/standardfeed.cpp @@ -116,7 +116,7 @@ bool StandardFeed::editViaGui() { bool StandardFeed::deleteViaGui() { if (removeItself()) { - serviceRoot()->feedsModel()->removeItem(this); + serviceRoot()->requestItemRemoval(this); return true; } else { @@ -445,7 +445,7 @@ bool StandardFeed::performDragDropChange(RootItem *target_item) { feed_new->setParent(target_item); if (editItself(feed_new)) { - serviceRoot()->feedsModel()->reassignNodeToNewParent(this, target_item); + serviceRoot()->requestItemReassignment(this, target_item); delete feed_new; return true; } diff --git a/src/services/standard/standardfeedsimportexportmodel.cpp b/src/services/standard/standardfeedsimportexportmodel.cpp index 837ebc3f6..fd74f1ed8 100755 --- a/src/services/standard/standardfeedsimportexportmodel.cpp +++ b/src/services/standard/standardfeedsimportexportmodel.cpp @@ -167,7 +167,7 @@ bool FeedsImportExportModel::importAsOPML20(const QByteArray &data) { return false; } - StandardServiceRoot *root_item = new StandardServiceRoot(false, NULL, NULL); + StandardServiceRoot *root_item = new StandardServiceRoot(false); QStack model_items; model_items.push(root_item); QStack elements_to_process; elements_to_process.push(opml_document.documentElement().elementsByTagName(QSL("body")).at(0).toElement()); diff --git a/src/services/standard/standardserviceentrypoint.cpp b/src/services/standard/standardserviceentrypoint.cpp index 1f9f11e82..97fa542d1 100755 --- a/src/services/standard/standardserviceentrypoint.cpp +++ b/src/services/standard/standardserviceentrypoint.cpp @@ -59,20 +59,20 @@ QString StandardServiceEntryPoint::code() { return SERVICE_CODE_STD_RSS; } -ServiceRoot *StandardServiceEntryPoint::createNewRoot(FeedsModel *main_model) { +ServiceRoot *StandardServiceEntryPoint::createNewRoot() { // Switch DB. QSqlDatabase database = qApp->database()->connection(QSL("StandardServiceEntryPoint"), DatabaseFactory::FromSettings); QSqlQuery query(database); if (query.exec(QSL("UPDATE Information SET inf_value = 1 WHERE inf_key = 'standard_account_enabled';"))) { - return new StandardServiceRoot(true, main_model); + return new StandardServiceRoot(true); } else { return NULL; } } -QList StandardServiceEntryPoint::initializeSubtree(FeedsModel *main_model) { +QList StandardServiceEntryPoint::initializeSubtree() { // Check DB if standard account is enabled. QSqlDatabase database = qApp->database()->connection(QSL("StandardServiceEntryPoint"), DatabaseFactory::FromSettings); QSqlQuery query(database); @@ -80,7 +80,7 @@ QList StandardServiceEntryPoint::initializeSubtree(FeedsModel *mai if (query.exec(QSL("SELECT inf_value FROM Information WHERE inf_key = 'standard_account_enabled';"))) { if (query.next() && query.value(0).toInt() == 1) { - StandardServiceRoot *root = new StandardServiceRoot(true, main_model); + StandardServiceRoot *root = new StandardServiceRoot(true); roots.append(root); } } diff --git a/src/services/standard/standardserviceentrypoint.h b/src/services/standard/standardserviceentrypoint.h index 8e4904cb4..b99de25a8 100755 --- a/src/services/standard/standardserviceentrypoint.h +++ b/src/services/standard/standardserviceentrypoint.h @@ -34,8 +34,8 @@ class StandardServiceEntryPoint : public ServiceEntryPoint { QIcon icon(); QString code(); - ServiceRoot *createNewRoot(FeedsModel *main_model); - QList initializeSubtree(FeedsModel *main_model); + ServiceRoot *createNewRoot(); + QList initializeSubtree(); }; #endif // STANDARDSERVICEENTRYPOINT_H diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index 3c6d63bb5..58ebfc167 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -43,8 +43,8 @@ #include -StandardServiceRoot::StandardServiceRoot(bool load_from_db, FeedsModel *feeds_model, RootItem *parent) - : ServiceRoot(feeds_model, parent), m_recycleBin(new StandardRecycleBin(this)), +StandardServiceRoot::StandardServiceRoot(bool load_from_db, RootItem *parent) + : ServiceRoot(parent), m_recycleBin(new StandardRecycleBin(this)), m_actionExportFeeds(NULL), m_actionImportFeeds(NULL), m_serviceMenu(QList()), m_addItemMenu(QList()), m_feedContextMenu(QList()), m_actionFeedFetchMetadata(NULL) { @@ -54,7 +54,6 @@ StandardServiceRoot::StandardServiceRoot(bool load_from_db, FeedsModel *feeds_mo setCreationDate(QDateTime::currentDateTime()); if (load_from_db) { - loadFromDatabase(); } } @@ -134,10 +133,8 @@ bool StandardServiceRoot::deleteViaGui() { // Switch "existence" flag. bool data_removed = QSqlQuery(connection).exec(QSL("UPDATE Information SET inf_value = 0 WHERE inf_key = 'standard_account_enabled';")); - // TODO: pokračovat - if (data_removed) { - feedsModel()->removeItem(this); + requestItemRemoval(this); } return data_removed; @@ -508,7 +505,7 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel *model, new_category->clearChildren(); if (new_category->addItself(target_parent)) { - feedsModel()->reassignNodeToNewParent(new_category, target_parent); + requestItemReassignment(new_category, target_parent); // Process all children of this category. original_parents.push(new_category); @@ -542,7 +539,7 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel *model, // Append this feed and end this iteration. if (new_feed->addItself(target_parent)) { - feedsModel()->reassignNodeToNewParent(new_feed, target_parent); + requestItemReassignment(new_feed, target_parent); } else { delete new_feed; diff --git a/src/services/standard/standardserviceroot.h b/src/services/standard/standardserviceroot.h index 18945401b..0d0903118 100755 --- a/src/services/standard/standardserviceroot.h +++ b/src/services/standard/standardserviceroot.h @@ -40,7 +40,7 @@ class StandardServiceRoot : public ServiceRoot { Q_OBJECT public: - explicit StandardServiceRoot(bool load_from_db, FeedsModel *feeds_model, RootItem *parent = NULL); + explicit StandardServiceRoot(bool load_from_db, RootItem *parent = NULL); virtual ~StandardServiceRoot(); // Start/stop root. diff --git a/src/services/tt-rss/ttrssserviceentrypoint.cpp b/src/services/tt-rss/ttrssserviceentrypoint.cpp index 6d5a24c03..e497d30d3 100755 --- a/src/services/tt-rss/ttrssserviceentrypoint.cpp +++ b/src/services/tt-rss/ttrssserviceentrypoint.cpp @@ -58,10 +58,10 @@ QString TtRssServiceEntryPoint::code() { return SERVICE_CODE_TT_RSS; } -ServiceRoot *TtRssServiceEntryPoint::createNewRoot(FeedsModel *main_model) { +ServiceRoot *TtRssServiceEntryPoint::createNewRoot() { return NULL; } -QList TtRssServiceEntryPoint::initializeSubtree(FeedsModel *main_model) { +QList TtRssServiceEntryPoint::initializeSubtree() { return QList(); } diff --git a/src/services/tt-rss/ttrssserviceentrypoint.h b/src/services/tt-rss/ttrssserviceentrypoint.h index 17e9a7635..dcd99616b 100755 --- a/src/services/tt-rss/ttrssserviceentrypoint.h +++ b/src/services/tt-rss/ttrssserviceentrypoint.h @@ -35,8 +35,8 @@ class TtRssServiceEntryPoint : public ServiceEntryPoint { QIcon icon(); QString code(); - ServiceRoot *createNewRoot(FeedsModel *main_model); - QList initializeSubtree(FeedsModel *main_model); + ServiceRoot *createNewRoot(); + QList initializeSubtree(); }; #endif // TTRSSSERVICEENTRYPOINT_H diff --git a/src/services/tt-rss/ttrssserviceroot.cpp b/src/services/tt-rss/ttrssserviceroot.cpp index 2654f6524..0c231832f 100755 --- a/src/services/tt-rss/ttrssserviceroot.cpp +++ b/src/services/tt-rss/ttrssserviceroot.cpp @@ -23,7 +23,7 @@ #include "core/feedsmodel.h" -TtRssServiceRoot::TtRssServiceRoot(FeedsModel *feeds_model, RootItem *parent) : ServiceRoot(feeds_model, 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 setTitle(qApp->system()->getUsername() + "@ttrss"); diff --git a/src/services/tt-rss/ttrssserviceroot.h b/src/services/tt-rss/ttrssserviceroot.h index 68d0e4f3a..f4f805292 100755 --- a/src/services/tt-rss/ttrssserviceroot.h +++ b/src/services/tt-rss/ttrssserviceroot.h @@ -29,7 +29,7 @@ class TtRssServiceRoot : public ServiceRoot { Q_OBJECT public: - explicit TtRssServiceRoot(FeedsModel *feeds_model, RootItem *parent = NULL); + explicit TtRssServiceRoot(RootItem *parent = NULL); virtual ~TtRssServiceRoot(); QString code();