diff --git a/CMakeLists.txt b/CMakeLists.txt index aa9a5aaa5..48f8b026b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -399,13 +399,13 @@ set(APP_SOURCES src/core/messagesproxymodel.cpp src/core/feedsmodel.cpp src/core/feedsproxymodel.cpp - src/core/feedsmodelcategory.cpp - src/core/feedsmodelrootitem.cpp - src/core/feedsmodelfeed.cpp + src/core/category.cpp + src/core/rootitem.cpp + src/core/feed.cpp src/core/parsingfactory.cpp src/core/feeddownloader.cpp src/core/feedsimportexportmodel.cpp - src/core/feedsmodelrecyclebin.cpp + src/core/recyclebin.cpp src/core/feedsselection.cpp # NETWORK-WEB sources. diff --git a/localization/rssguard-cs_CZ.ts b/localization/rssguard-cs_CZ.ts index e79852dd8..1ced65091 100644 --- a/localization/rssguard-cs_CZ.ts +++ b/localization/rssguard-cs_CZ.ts @@ -198,6 +198,29 @@ Berte také na paměti, že některé prostředky webových stránek jsou intern Obnovení nastavení nebylo spuštěno. Ujistěte se, že cílový adresář je zapisovatelný. + + Category + + %1 (category)%2%3 + Tooltip for standard feed. + %1 (kategorie)%2%3 + + + +This category does not contain any nested items. + +Tato kategorie neobsahuje žádné položky. + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + %n nepřečtená zpráva. + %n nepřečtené zprávy. + %n nepřečtených zpráv. + + + DatabaseCleaner @@ -425,6 +448,50 @@ Klikněte sem pro otevření nadřazeného adresáře. + + Feed + + does not use auto-update + Describes feed auto-update status. + nepoužívá auto-aktualizace + + + uses global settings + Describes feed auto-update status. + používá globální nastavení + + + uses specific settings (%n minute(s) to next auto-update) + Describes feed auto-update status. + + používá specifické nastavení (%n minuta do další aktualizace) + používá specifické nastavení (%n minuty do další aktualizace) + používá specifické nastavení (%n minut do další aktualizace) + + + + %1 (%2)%3 + +Network status: %6 +Encoding: %4 +Auto-update status: %5 + Tooltip for feed. + %1 (%2)%3 + +Síťový status: %6 +Kódování: %4 +Automatický update: %5 + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + %n nepřečtená zpráva. + %n nepřečtené zprávy. + %n nepřečtených zpráv. + + + FeedMessageViewer @@ -518,98 +585,6 @@ Klikněte sem pro otevření nadřazeného adresáře. Import byl zcela úspěšný. - - FeedsModelCategory - - %n unread message(s). - Tooltip for "unread" column of feed list. - - %n nepřečtená zpráva. - %n nepřečtené zprávy. - %n nepřečtených zpráv. - - - - %1 (category)%2%3 - Tooltip for standard feed. - %1 (kategorie)%2%3 - - - -This category does not contain any nested items. - -Tato kategorie neobsahuje žádné položky. - - - - FeedsModelFeed - - does not use auto-update - Describes feed auto-update status. - nepoužívá auto-aktualizace - - - uses global settings - Describes feed auto-update status. - používá globální nastavení - - - uses specific settings (%n minute(s) to next auto-update) - Describes feed auto-update status. - - používá specifické nastavení (%n minuta do další aktualizace) - používá specifické nastavení (%n minuty do další aktualizace) - používá specifické nastavení (%n minut do další aktualizace) - - - - %n unread message(s). - Tooltip for "unread" column of feed list. - - %n nepřečtená zpráva. - %n nepřečtené zprávy. - %n nepřečtených zpráv. - - - - %1 (%2)%3 - -Network status: %6 -Encoding: %4 -Auto-update status: %5 - Tooltip for feed. - %1 (%2)%3 - -Síťový status: %6 -Kódování: %4 -Automatický update: %5 - - - - FeedsModelRecycleBin - - Recycle bin - Koš - - - Recycle bin contains all deleted messages from all feeds. - Koš obsahuje všechny smazané zprávy ze všech kanálů. - - - Recycle bin -%1 - Koš -%1 - - - %n deleted message(s). - - %n smazaná zpráva. - %n smazané zprávy. - %n smazaných zpráv. - - - FeedsToolBar @@ -2981,6 +2956,31 @@ Přejít na web aplikace a stáhnout jej ručně. Vítá vás %1 %2. + + RecycleBin + + Recycle bin + Koš + + + Recycle bin contains all deleted messages from all feeds. + Koš obsahuje všechny smazané zprávy ze všech kanálů. + + + Recycle bin +%1 + Koš +%1 + + + %n deleted message(s). + + %n smazaná zpráva. + %n smazané zprávy. + %n smazaných zpráv. + + + ShortcutCatcher diff --git a/localization/rssguard-de_DE.ts b/localization/rssguard-de_DE.ts index f2e2bb71c..a3fe81b5c 100644 --- a/localization/rssguard-de_DE.ts +++ b/localization/rssguard-de_DE.ts @@ -196,6 +196,27 @@ Also note that some resources are cached by internal web browser. Thus, after ch + + Category + + %1 (category)%2%3 + Tooltip for standard feed. + + + + +This category does not contain any nested items. + + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + + + + + DatabaseCleaner @@ -415,6 +436,44 @@ Click here to open parent directory. + + Feed + + does not use auto-update + Describes feed auto-update status. + + + + uses global settings + Describes feed auto-update status. + + + + uses specific settings (%n minute(s) to next auto-update) + Describes feed auto-update status. + + + + + + + %1 (%2)%3 + +Network status: %6 +Encoding: %4 +Auto-update status: %5 + Tooltip for feed. + + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + + + + + FeedMessageViewer @@ -508,88 +567,6 @@ Click here to open parent directory. - - FeedsModelCategory - - %n unread message(s). - Tooltip for "unread" column of feed list. - - - - - - - %1 (category)%2%3 - Tooltip for standard feed. - - - - -This category does not contain any nested items. - - - - - FeedsModelFeed - - does not use auto-update - Describes feed auto-update status. - - - - uses global settings - Describes feed auto-update status. - - - - uses specific settings (%n minute(s) to next auto-update) - Describes feed auto-update status. - - - - - - - %n unread message(s). - Tooltip for "unread" column of feed list. - - - - - - - %1 (%2)%3 - -Network status: %6 -Encoding: %4 -Auto-update status: %5 - Tooltip for feed. - - - - - FeedsModelRecycleBin - - Recycle bin - Mülleimer - - - Recycle bin contains all deleted messages from all feeds. - Der Mülleimer enthält die gelöschten Nachrichten aus allen Feeds. - - - Recycle bin -%1 - - - - %n deleted message(s). - - - - - - FeedsToolBar @@ -2944,6 +2921,29 @@ Go to application website to obtain it manually. + + RecycleBin + + Recycle bin + Mülleimer + + + Recycle bin contains all deleted messages from all feeds. + Der Mülleimer enthält die gelöschten Nachrichten aus allen Feeds. + + + Recycle bin +%1 + + + + %n deleted message(s). + + + + + + ShortcutCatcher diff --git a/localization/rssguard-en_GB.ts b/localization/rssguard-en_GB.ts index f9d0b2e04..749de4d8b 100644 --- a/localization/rssguard-en_GB.ts +++ b/localization/rssguard-en_GB.ts @@ -196,6 +196,27 @@ Also note that some resources are cached by internal web browser. Thus, after ch + + Category + + %1 (category)%2%3 + Tooltip for standard feed. + + + + +This category does not contain any nested items. + + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + + + + + DatabaseCleaner @@ -415,6 +436,44 @@ Click here to open parent directory. + + Feed + + does not use auto-update + Describes feed auto-update status. + + + + uses global settings + Describes feed auto-update status. + + + + uses specific settings (%n minute(s) to next auto-update) + Describes feed auto-update status. + + + + + + + %1 (%2)%3 + +Network status: %6 +Encoding: %4 +Auto-update status: %5 + Tooltip for feed. + + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + + + + + FeedMessageViewer @@ -508,88 +567,6 @@ Click here to open parent directory. - - FeedsModelCategory - - %n unread message(s). - Tooltip for "unread" column of feed list. - - - - - - - %1 (category)%2%3 - Tooltip for standard feed. - - - - -This category does not contain any nested items. - - - - - FeedsModelFeed - - does not use auto-update - Describes feed auto-update status. - - - - uses global settings - Describes feed auto-update status. - - - - uses specific settings (%n minute(s) to next auto-update) - Describes feed auto-update status. - - - - - - - %n unread message(s). - Tooltip for "unread" column of feed list. - - - - - - - %1 (%2)%3 - -Network status: %6 -Encoding: %4 -Auto-update status: %5 - Tooltip for feed. - - - - - FeedsModelRecycleBin - - Recycle bin - - - - Recycle bin contains all deleted messages from all feeds. - - - - Recycle bin -%1 - - - - %n deleted message(s). - - - - - - FeedsToolBar @@ -2939,6 +2916,29 @@ Go to application website to obtain it manually. + + RecycleBin + + Recycle bin + + + + Recycle bin contains all deleted messages from all feeds. + + + + Recycle bin +%1 + + + + %n deleted message(s). + + + + + + ShortcutCatcher diff --git a/localization/rssguard-en_US.ts b/localization/rssguard-en_US.ts index e895434f3..c501ba651 100644 --- a/localization/rssguard-en_US.ts +++ b/localization/rssguard-en_US.ts @@ -242,6 +242,30 @@ Also note that some resources are cached by internal web browser. Thus, after ch + + Category + + + %1 (category)%2%3 + Tooltip for standard feed. + + + + + +This category does not contain any nested items. + + + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + + + + + DatabaseCleaner @@ -510,6 +534,49 @@ Click here to open parent directory. + + Feed + + + does not use auto-update + Describes feed auto-update status. + + + + + uses global settings + Describes feed auto-update status. + + + + + uses specific settings (%n minute(s) to next auto-update) + Describes feed auto-update status. + + + + + + + + %1 (%2)%3 + +Network status: %6 +Encoding: %4 +Auto-update status: %5 + Tooltip for feed. + + + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + + + + + FeedMessageViewer @@ -623,100 +690,6 @@ Click here to open parent directory. - - FeedsModelCategory - - - %1 (category)%2%3 - Tooltip for standard feed. - - - - - -This category does not contain any nested items. - - - - - %n unread message(s). - Tooltip for "unread" column of feed list. - - - - - - - - FeedsModelFeed - - - does not use auto-update - Describes feed auto-update status. - - - - - uses global settings - Describes feed auto-update status. - - - - - uses specific settings (%n minute(s) to next auto-update) - Describes feed auto-update status. - - - - - - - - %1 (%2)%3 - -Network status: %6 -Encoding: %4 -Auto-update status: %5 - Tooltip for feed. - - - - - %n unread message(s). - Tooltip for "unread" column of feed list. - - - - - - - - FeedsModelRecycleBin - - - Recycle bin - - - - - Recycle bin contains all deleted messages from all feeds. - - - - - Recycle bin -%1 - - - - - %n deleted message(s). - - - - - - FeedsToolBar @@ -3662,6 +3635,33 @@ currently installed one. rotter.martinos@gmail.com + + RecycleBin + + + Recycle bin + + + + + Recycle bin contains all deleted messages from all feeds. + + + + + Recycle bin +%1 + + + + + %n deleted message(s). + + + + + + ShortcutCatcher diff --git a/localization/rssguard-fr_FR.ts b/localization/rssguard-fr_FR.ts index cfb88365c..53d7fd784 100644 --- a/localization/rssguard-fr_FR.ts +++ b/localization/rssguard-fr_FR.ts @@ -196,6 +196,27 @@ Also note that some resources are cached by internal web browser. Thus, after ch + + Category + + %1 (category)%2%3 + Tooltip for standard feed. + %1 (catégorie)%2%3 + + + +This category does not contain any nested items. + + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + + + + + DatabaseCleaner @@ -415,6 +436,44 @@ Click here to open parent directory. + + Feed + + does not use auto-update + Describes feed auto-update status. + Ne pas utiliser la mise à jour automatique + + + uses global settings + Describes feed auto-update status. + Utiliser les paramètres globaux + + + uses specific settings (%n minute(s) to next auto-update) + Describes feed auto-update status. + + + + + + + %1 (%2)%3 + +Network status: %6 +Encoding: %4 +Auto-update status: %5 + Tooltip for feed. + + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + + + + + FeedMessageViewer @@ -508,89 +567,6 @@ Click here to open parent directory. - - FeedsModelCategory - - %n unread message(s). - Tooltip for "unread" column of feed list. - - %n message(s) non lu(s). - %n message(s) non lu(s). - - - - %1 (category)%2%3 - Tooltip for standard feed. - %1 (catégorie)%2%3 - - - -This category does not contain any nested items. - - - - - FeedsModelFeed - - does not use auto-update - Describes feed auto-update status. - Ne pas utiliser la mise à jour automatique - - - uses global settings - Describes feed auto-update status. - Utiliser les paramètres globaux - - - uses specific settings (%n minute(s) to next auto-update) - Describes feed auto-update status. - - - - - - - %n unread message(s). - Tooltip for "unread" column of feed list. - - - %n message(s) non lu(s). - - - - %1 (%2)%3 - -Network status: %6 -Encoding: %4 -Auto-update status: %5 - Tooltip for feed. - - - - - FeedsModelRecycleBin - - Recycle bin - Poubelle - - - Recycle bin contains all deleted messages from all feeds. - - - - Recycle bin -%1 - Corbeille -%1 - - - %n deleted message(s). - - - - - - FeedsToolBar @@ -2956,6 +2932,30 @@ Aller sur le site de l'application pour les obtenir manuellement. + + RecycleBin + + Recycle bin + Poubelle + + + Recycle bin contains all deleted messages from all feeds. + + + + Recycle bin +%1 + Corbeille +%1 + + + %n deleted message(s). + + + + + + ShortcutCatcher diff --git a/localization/rssguard-it_IT.ts b/localization/rssguard-it_IT.ts index 7dd1ad9e4..d7796f007 100644 --- a/localization/rssguard-it_IT.ts +++ b/localization/rssguard-it_IT.ts @@ -196,6 +196,27 @@ Also note that some resources are cached by internal web browser. Thus, after ch + + Category + + %1 (category)%2%3 + Tooltip for standard feed. + + + + +This category does not contain any nested items. + + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + + + + + DatabaseCleaner @@ -415,6 +436,44 @@ Click here to open parent directory. + + Feed + + does not use auto-update + Describes feed auto-update status. + non utilizza l'auto-aggiornamento + + + uses global settings + Describes feed auto-update status. + utilizza impostazioni globali + + + uses specific settings (%n minute(s) to next auto-update) + Describes feed auto-update status. + + + + + + + %1 (%2)%3 + +Network status: %6 +Encoding: %4 +Auto-update status: %5 + Tooltip for feed. + + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + + + + + FeedMessageViewer @@ -508,88 +567,6 @@ Click here to open parent directory. - - FeedsModelCategory - - %n unread message(s). - Tooltip for "unread" column of feed list. - - %n messaggio(i) non letto. - %n messaggio(i) non letti. - - - - %1 (category)%2%3 - Tooltip for standard feed. - - - - -This category does not contain any nested items. - - - - - FeedsModelFeed - - does not use auto-update - Describes feed auto-update status. - non utilizza l'auto-aggiornamento - - - uses global settings - Describes feed auto-update status. - utilizza impostazioni globali - - - uses specific settings (%n minute(s) to next auto-update) - Describes feed auto-update status. - - - - - - - %n unread message(s). - Tooltip for "unread" column of feed list. - - - %n messaggio(i) non letti. - - - - %1 (%2)%3 - -Network status: %6 -Encoding: %4 -Auto-update status: %5 - Tooltip for feed. - - - - - FeedsModelRecycleBin - - Recycle bin - - - - Recycle bin contains all deleted messages from all feeds. - - - - Recycle bin -%1 - - - - %n deleted message(s). - - - - - - FeedsToolBar @@ -2944,6 +2921,29 @@ Go to application website to obtain it manually. + + RecycleBin + + Recycle bin + + + + Recycle bin contains all deleted messages from all feeds. + + + + Recycle bin +%1 + + + + %n deleted message(s). + + + + + + ShortcutCatcher diff --git a/localization/rssguard-nl_NL.ts b/localization/rssguard-nl_NL.ts index 7351a68ab..a1619f969 100644 --- a/localization/rssguard-nl_NL.ts +++ b/localization/rssguard-nl_NL.ts @@ -196,6 +196,29 @@ Also note that some resources are cached by internal web browser. Thus, after ch Herstel van de instellingen werd niet gestart. Zorg ervoor dat de uitvoermap beschrijfbaar is. + + Category + + %1 (category)%2%3 + Tooltip for standard feed. + %1 (categorie)%2%3 + + + +This category does not contain any nested items. + + +Deze categorie bevat geen nested items. + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + %n ongelezen bericht. + %n ongelezen berichten. + + + DatabaseCleaner @@ -417,6 +440,48 @@ Click here to open parent directory. + + Feed + + does not use auto-update + Describes feed auto-update status. + automatisch bijwerken niet gebruiken + + + uses global settings + Describes feed auto-update status. + gebruik algemene instellingen + + + uses specific settings (%n minute(s) to next auto-update) + Describes feed auto-update status. + + gebruik specifieke instellingen (%n minuut voor volgende automatische update) + gebruik specifieke instellingen (%n minuten voor volgende automatische update) + + + + %1 (%2)%3 + +Network status: %6 +Encoding: %4 +Auto-update status: %5 + Tooltip for feed. + %1 (%2)%3 + +Netwerk status: %6 +Coderen: %4 +Auto-update status: %5 + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + %n ongelezen bericht. + %n ongelezen berichten. + + + FeedMessageViewer @@ -510,95 +575,6 @@ Click here to open parent directory. Importeren is helemaal geslaagd. - - FeedsModelCategory - - %n unread message(s). - Tooltip for "unread" column of feed list. - - %n ongelezen bericht. - %n ongelezen berichten. - - - - %1 (category)%2%3 - Tooltip for standard feed. - %1 (categorie)%2%3 - - - -This category does not contain any nested items. - - -Deze categorie bevat geen nested items. - - - - FeedsModelFeed - - does not use auto-update - Describes feed auto-update status. - automatisch bijwerken niet gebruiken - - - uses global settings - Describes feed auto-update status. - gebruik algemene instellingen - - - uses specific settings (%n minute(s) to next auto-update) - Describes feed auto-update status. - - gebruik specifieke instellingen (%n minuut voor volgende automatische update) - gebruik specifieke instellingen (%n minuten voor volgende automatische update) - - - - %n unread message(s). - Tooltip for "unread" column of feed list. - - %n ongelezen bericht. - %n ongelezen berichten. - - - - %1 (%2)%3 - -Network status: %6 -Encoding: %4 -Auto-update status: %5 - Tooltip for feed. - %1 (%2)%3 - -Netwerk status: %6 -Coderen: %4 -Auto-update status: %5 - - - - FeedsModelRecycleBin - - Recycle bin - Prullenbak - - - Recycle bin contains all deleted messages from all feeds. - De prullenbak bevat alle verwijderde berichten van alle feeds. - - - Recycle bin -%1 - Prullenbak -%1 - - - %n deleted message(s). - - %n verwijderde bericht(en). - %n verwijderde bericht(en). - - - FeedsToolBar @@ -2981,6 +2957,30 @@ Ga naar RRSguard website en download het handmatig. + + RecycleBin + + Recycle bin + Prullenbak + + + Recycle bin contains all deleted messages from all feeds. + De prullenbak bevat alle verwijderde berichten van alle feeds. + + + Recycle bin +%1 + Prullenbak +%1 + + + %n deleted message(s). + + %n verwijderde bericht(en). + %n verwijderde bericht(en). + + + ShortcutCatcher diff --git a/localization/rssguard-sv_SE.ts b/localization/rssguard-sv_SE.ts index 7c086f058..731d8ee10 100644 --- a/localization/rssguard-sv_SE.ts +++ b/localization/rssguard-sv_SE.ts @@ -196,6 +196,28 @@ Also note that some resources are cached by internal web browser. Thus, after ch Inställningsåterställning startades inte. Tillse att utdatamappen är skrivbar. + + Category + + %1 (category)%2%3 + Tooltip for standard feed. + %1 (kategori)%2%3 + + + +This category does not contain any nested items. + +Denna kategori innehåller inga objekt. + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + %n oläst meddelande. + %n olästa meddelanden. + + + DatabaseCleaner @@ -417,6 +439,48 @@ Click here to open parent directory. + + Feed + + does not use auto-update + Describes feed auto-update status. + Uppdateras inte automatiskt + + + uses global settings + Describes feed auto-update status. + Globala inställningar + + + uses specific settings (%n minute(s) to next auto-update) + Describes feed auto-update status. + + Anpassade inställningar. (%n minut till nästa auto-uppdatering) + Anpassade inställningar. (%n minuter till nästa auto-uppdatering) + + + + %1 (%2)%3 + +Network status: %6 +Encoding: %4 +Auto-update status: %5 + Tooltip for feed. + %1 (%2)%3 + +Nätverksstatus: %6 +Kodning: %4 +Uppdateringsstatus: %5 + + + %n unread message(s). + Tooltip for "unread" column of feed list. + + %n oläst meddelande. + %n olästa meddelanden. + + + FeedMessageViewer @@ -510,94 +574,6 @@ Click here to open parent directory. Importen slutfördes korrekt. - - FeedsModelCategory - - %n unread message(s). - Tooltip for "unread" column of feed list. - - %n oläst meddelande. - %n olästa meddelanden. - - - - %1 (category)%2%3 - Tooltip for standard feed. - %1 (kategori)%2%3 - - - -This category does not contain any nested items. - -Denna kategori innehåller inga objekt. - - - - FeedsModelFeed - - does not use auto-update - Describes feed auto-update status. - Uppdateras inte automatiskt - - - uses global settings - Describes feed auto-update status. - Globala inställningar - - - uses specific settings (%n minute(s) to next auto-update) - Describes feed auto-update status. - - Anpassade inställningar. (%n minut till nästa auto-uppdatering) - Anpassade inställningar. (%n minuter till nästa auto-uppdatering) - - - - %n unread message(s). - Tooltip for "unread" column of feed list. - - %n oläst meddelande. - %n olästa meddelanden. - - - - %1 (%2)%3 - -Network status: %6 -Encoding: %4 -Auto-update status: %5 - Tooltip for feed. - %1 (%2)%3 - -Nätverksstatus: %6 -Kodning: %4 -Uppdateringsstatus: %5 - - - - FeedsModelRecycleBin - - Recycle bin - Papperskorgen - - - Recycle bin contains all deleted messages from all feeds. - Papperskorgen innehåller borttagna meddelanden från samtliga flöden. - - - Recycle bin -%1 - Papperskorgen -%1 - - - %n deleted message(s). - - %n borttaget meddelande. - %n borttagna meddelanden. - - - FeedsToolBar @@ -2971,6 +2947,30 @@ Gå till programmets hemsida för att hämta den manuellt. + + RecycleBin + + Recycle bin + Papperskorgen + + + Recycle bin contains all deleted messages from all feeds. + Papperskorgen innehåller borttagna meddelanden från samtliga flöden. + + + Recycle bin +%1 + Papperskorgen +%1 + + + %n deleted message(s). + + %n borttaget meddelande. + %n borttagna meddelanden. + + + ShortcutCatcher diff --git a/src/core/feedsmodelcategory.cpp b/src/core/category.cpp old mode 100755 new mode 100644 similarity index 80% rename from src/core/feedsmodelcategory.cpp rename to src/core/category.cpp index f70fe8cfb..cf2fb0bdd --- a/src/core/feedsmodelcategory.cpp +++ b/src/core/category.cpp @@ -15,14 +15,13 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#include "core/feedsmodelcategory.h" +#include "core/category.h" #include "definitions/definitions.h" #include "miscellaneous/databasefactory.h" #include "miscellaneous/textfactory.h" #include "miscellaneous/settings.h" #include "miscellaneous/iconfactory.h" -#include "gui/dialogs/formcategorydetails.h" #include "core/feedsmodel.h" #include @@ -30,12 +29,12 @@ #include -FeedsModelCategory::FeedsModelCategory(FeedsModelRootItem *parent_item) : FeedsModelRootItem(parent_item) { +Category::Category(RootItem *parent_item) : RootItem(parent_item) { init(); } -FeedsModelCategory::FeedsModelCategory(const FeedsModelCategory &other) - : FeedsModelRootItem(NULL) { +Category::Category(const Category &other) + : RootItem(NULL) { m_kind = other.kind(); m_id = other.id(); m_title = other.title(); @@ -46,15 +45,15 @@ FeedsModelCategory::FeedsModelCategory(const FeedsModelCategory &other) m_parentItem = other.parent(); } -FeedsModelCategory::~FeedsModelCategory() { - qDebug("Destroying FeedsModelCategory instance."); +Category::~Category() { + qDebug("Destroying Category instance."); } -void FeedsModelCategory::init() { - m_kind = FeedsModelRootItem::Category; +void Category::init() { + m_kind = RootItem::Cattegory; } -QVariant FeedsModelCategory::data(int column, int role) const { +QVariant Category::data(int column, int role) const { switch (role) { case Qt::ToolTipRole: if (column == FDS_MODEL_TITLE_INDEX) { @@ -122,17 +121,17 @@ QVariant FeedsModelCategory::data(int column, int role) const { } } -bool FeedsModelCategory::removeItself() { +bool Category::removeItself() { bool children_removed = true; // Remove all child items (feeds, categories.) - foreach (FeedsModelRootItem *child, m_childItems) { + foreach (RootItem *child, m_childItems) { children_removed &= child->removeItself(); } if (children_removed) { // Children are removed, remove this standard category too. - QSqlDatabase database = qApp->database()->connection(QSL("FeedsModelCategory"), DatabaseFactory::FromSettings); + QSqlDatabase database = qApp->database()->connection(QSL("Category"), DatabaseFactory::FromSettings); QSqlQuery query_remove(database); // Remove this category from database. @@ -147,10 +146,10 @@ bool FeedsModelCategory::removeItself() { } } -bool FeedsModelCategory::addItself(FeedsModelRootItem *parent) { +bool Category::addItself(RootItem *parent) { // Now, add category to persistent storage. // Children are removed, remove this standard category too. - QSqlDatabase database = qApp->database()->connection(QSL("FeedsModelCategory"), DatabaseFactory::FromSettings); + QSqlDatabase database = qApp->database()->connection(QSL("Category"), DatabaseFactory::FromSettings); QSqlQuery query_add(database); query_add.setForwardOnly(true); @@ -186,11 +185,11 @@ bool FeedsModelCategory::addItself(FeedsModelRootItem *parent) { return true; } -bool FeedsModelCategory::editItself(FeedsModelCategory *new_category_data) { - QSqlDatabase database = qApp->database()->connection(QSL("FeedsModelCategory"), DatabaseFactory::FromSettings); +bool Category::editItself(Category *new_category_data) { + QSqlDatabase database = qApp->database()->connection(QSL("Category"), DatabaseFactory::FromSettings); QSqlQuery query_update_category(database); - FeedsModelCategory *original_category = this; - FeedsModelRootItem *new_parent = new_category_data->parent(); + Category *original_category = this; + RootItem *new_parent = new_category_data->parent(); query_update_category.setForwardOnly(true); query_update_category.prepare("UPDATE Categories " @@ -216,7 +215,7 @@ bool FeedsModelCategory::editItself(FeedsModelCategory *new_category_data) { return true; } -FeedsModelCategory::FeedsModelCategory(const QSqlRecord &record) : FeedsModelRootItem(NULL) { +Category::Category(const QSqlRecord &record) : RootItem(NULL) { init(); setId(record.value(CAT_DB_ID_INDEX).toInt()); diff --git a/src/core/feedsmodelcategory.h b/src/core/category.h old mode 100755 new mode 100644 similarity index 72% rename from src/core/feedsmodelcategory.h rename to src/core/category.h index 8af039937..3cf04adb1 --- a/src/core/feedsmodelcategory.h +++ b/src/core/category.h @@ -18,7 +18,7 @@ #ifndef FEEDSMODELCATEGORY_H #define FEEDSMODELCATEGORY_H -#include "core/feedsmodelrootitem.h" +#include "core/rootitem.h" #include #include @@ -29,15 +29,15 @@ class FeedsModel; // Base class for all categories contained in FeedsModel. // NOTE: This class should be derived to create PARTICULAR category types. // NOTE: This class should not be instantiated directly. -class FeedsModelCategory : public FeedsModelRootItem { - Q_DECLARE_TR_FUNCTIONS(FeedsModelCategory) +class Category : public RootItem { + Q_DECLARE_TR_FUNCTIONS(Category) public: // Constructors and destructors - explicit FeedsModelCategory(FeedsModelRootItem *parent_item = NULL); - explicit FeedsModelCategory(const FeedsModelCategory &other); - explicit FeedsModelCategory(const QSqlRecord &record); - virtual ~FeedsModelCategory(); + explicit Category(RootItem *parent_item = NULL); + explicit Category(const Category &other); + explicit Category(const QSqlRecord &record); + virtual ~Category(); // Returns the actual data representation of standard category. QVariant data(int column, int role) const; @@ -46,8 +46,8 @@ class FeedsModelCategory : public FeedsModelRootItem { // database. bool removeItself(); - bool addItself(FeedsModelRootItem *parent); - bool editItself(FeedsModelCategory *new_category_data); + bool addItself(RootItem *parent); + bool editItself(Category *new_category_data); private: void init(); diff --git a/src/core/feedsmodelfeed.cpp b/src/core/feed.cpp old mode 100755 new mode 100644 similarity index 89% rename from src/core/feedsmodelfeed.cpp rename to src/core/feed.cpp index c392058ec..565649ceb --- a/src/core/feedsmodelfeed.cpp +++ b/src/core/feed.cpp @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#include "core/feedsmodelfeed.h" +#include "core/feed.h" #include "definitions/definitions.h" #include "core/parsingfactory.h" @@ -38,7 +38,7 @@ #include -void FeedsModelFeed::init() { +void Feed::init() { m_passwordProtected = false; m_username = QString(); m_password = QString(); @@ -52,16 +52,16 @@ void FeedsModelFeed::init() { m_autoUpdateRemainingInterval = DEFAULT_AUTO_UPDATE_INTERVAL; m_encoding = QString(); m_url = QString(); - m_kind = FeedsModelRootItem::Feed; + m_kind = RootItem::Feeed; } -FeedsModelFeed::FeedsModelFeed(FeedsModelRootItem *parent_item) - : FeedsModelRootItem(parent_item) { +Feed::Feed(RootItem *parent_item) + : RootItem(parent_item) { init(); } -FeedsModelFeed::FeedsModelFeed(const FeedsModelFeed &other) - : FeedsModelRootItem(NULL) { +Feed::Feed(const Feed &other) + : RootItem(NULL) { m_passwordProtected = other.passwordProtected(); m_username = other.username(); m_password = other.password(); @@ -75,7 +75,7 @@ FeedsModelFeed::FeedsModelFeed(const FeedsModelFeed &other) m_autoUpdateRemainingInterval = other.autoUpdateRemainingInterval(); m_encoding = other.encoding(); m_url = other.url(); - m_kind = FeedsModelRootItem::Feed; + m_kind = RootItem::Feeed; m_title = other.title(); m_id = other.id(); m_icon = other.icon(); @@ -85,24 +85,24 @@ FeedsModelFeed::FeedsModelFeed(const FeedsModelFeed &other) m_description = other.description(); } -FeedsModelFeed::~FeedsModelFeed() { - qDebug("Destroying FeedsModelFeed instance."); +Feed::~Feed() { + qDebug("Destroying Feed instance."); } -int FeedsModelFeed::childCount() const { +int Feed::childCount() const { // Because feed has no children. return 0; } -int FeedsModelFeed::countOfAllMessages() const { +int Feed::countOfAllMessages() const { return m_totalCount; } -int FeedsModelFeed::countOfUnreadMessages() const { +int Feed::countOfUnreadMessages() const { return m_unreadCount; } -QString FeedsModelFeed::typeToString(FeedsModelFeed::Type type) { +QString Feed::typeToString(Feed::Type type) { switch (type) { case Atom10: return QSL("ATOM 1.0"); @@ -119,8 +119,8 @@ QString FeedsModelFeed::typeToString(FeedsModelFeed::Type type) { } } -void FeedsModelFeed::updateCounts(bool including_total_count, bool update_feed_statuses) { - QSqlDatabase database = qApp->database()->connection(QSL("FeedsModelFeed"), DatabaseFactory::FromSettings); +void Feed::updateCounts(bool including_total_count, bool update_feed_statuses) { + QSqlDatabase database = qApp->database()->connection(QSL("Feed"), DatabaseFactory::FromSettings); QSqlQuery query_all(database); query_all.setForwardOnly(true); @@ -143,10 +143,10 @@ void FeedsModelFeed::updateCounts(bool including_total_count, bool update_feed_s } } -QPair FeedsModelFeed::guessFeed(const QString &url, +QPair Feed::guessFeed(const QString &url, const QString &username, const QString &password) { - QPair result; result.first = NULL; + QPair result; result.first = NULL; QByteArray feed_contents; NetworkResult network_result = NetworkFactory::downloadFeedFile(url, @@ -175,7 +175,7 @@ QPair FeedsModelFeed::guessFeed(co } if (result.first == NULL) { - result.first = new FeedsModelFeed(); + result.first = new Feed(); } QTextCodec *custom_codec = QTextCodec::codecForName(xml_schema_encoding.toLocal8Bit()); @@ -287,7 +287,7 @@ QPair FeedsModelFeed::guessFeed(co return result; } -QVariant FeedsModelFeed::data(int column, int role) const { +QVariant Feed::data(int column, int role) const { switch (role) { case Qt::DisplayRole: if (column == FDS_MODEL_TITLE_INDEX) { @@ -352,7 +352,7 @@ QVariant FeedsModelFeed::data(int column, int role) const { "Network status: %6\n" "Encoding: %4\n" "Auto-update status: %5").arg(m_title, - FeedsModelFeed::typeToString(m_type), + Feed::typeToString(m_type), m_description.isEmpty() ? QString() : QString('\n') + m_description, m_encoding, auto_update_string, @@ -394,7 +394,7 @@ QVariant FeedsModelFeed::data(int column, int role) const { } } -int FeedsModelFeed::update() { +int Feed::update() { QByteArray feed_contents; int download_timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt(); m_networkError = NetworkFactory::downloadFeedFile(url(), download_timeout, feed_contents, @@ -427,16 +427,16 @@ int FeedsModelFeed::update() { QList messages; switch (type()) { - case FeedsModelFeed::Rss0X: - case FeedsModelFeed::Rss2X: + case Feed::Rss0X: + case Feed::Rss2X: messages = ParsingFactory::parseAsRSS20(formatted_feed_contents); break; - case FeedsModelFeed::Rdf: + case Feed::Rdf: messages = ParsingFactory::parseAsRDF(formatted_feed_contents); break; - case FeedsModelFeed::Atom10: + case Feed::Atom10: messages = ParsingFactory::parseAsATOM10(formatted_feed_contents); default: @@ -446,8 +446,8 @@ int FeedsModelFeed::update() { return updateMessages(messages); } -bool FeedsModelFeed::removeItself() { - QSqlDatabase database = qApp->database()->connection(QSL("FeedsModelFeed"), DatabaseFactory::FromSettings); +bool Feed::removeItself() { + QSqlDatabase database = qApp->database()->connection(QSL("Feed"), DatabaseFactory::FromSettings); QSqlQuery query_remove(database); query_remove.setForwardOnly(true); @@ -467,9 +467,9 @@ bool FeedsModelFeed::removeItself() { return query_remove.exec(); } -bool FeedsModelFeed::addItself(FeedsModelRootItem *parent) { +bool Feed::addItself(RootItem *parent) { // Now, add feed to persistent storage. - QSqlDatabase database = qApp->database()->connection(QSL("FeedsModelFeed"), DatabaseFactory::FromSettings); + QSqlDatabase database = qApp->database()->connection(QSL("Feed"), DatabaseFactory::FromSettings); QSqlQuery query_add_feed(database); query_add_feed.setForwardOnly(true); @@ -511,11 +511,11 @@ bool FeedsModelFeed::addItself(FeedsModelRootItem *parent) { return true; } -bool FeedsModelFeed::editItself(FeedsModelFeed *new_feed_data) { - QSqlDatabase database = qApp->database()->connection(QSL("FeedsModelFeed"), DatabaseFactory::FromSettings); +bool Feed::editItself(Feed *new_feed_data) { + QSqlDatabase database = qApp->database()->connection(QSL("Feed"), DatabaseFactory::FromSettings); QSqlQuery query_update_feed(database); - FeedsModelFeed *original_feed = this; - FeedsModelRootItem *new_parent = new_feed_data->parent(); + Feed *original_feed = this; + RootItem *new_parent = new_feed_data->parent(); query_update_feed.setForwardOnly(true); query_update_feed.prepare("UPDATE Feeds " @@ -558,10 +558,10 @@ bool FeedsModelFeed::editItself(FeedsModelFeed *new_feed_data) { return true; } -int FeedsModelFeed::updateMessages(const QList &messages) { +int Feed::updateMessages(const QList &messages) { int feed_id = id(); int updated_messages = 0; - QSqlDatabase database = qApp->database()->connection(QSL("FeedsModelFeed"), DatabaseFactory::FromSettings); + QSqlDatabase database = qApp->database()->connection(QSL("Feed"), DatabaseFactory::FromSettings); bool remove_duplicates = qApp->settings()->value(GROUP(Messages), SETTING(Messages::RemoveDuplicates)).toBool(); // Prepare queries. @@ -685,12 +685,12 @@ int FeedsModelFeed::updateMessages(const QList &messages) { return updated_messages; } -QNetworkReply::NetworkError FeedsModelFeed::networkError() const { +QNetworkReply::NetworkError Feed::networkError() const { return m_networkError; } -FeedsModelFeed::FeedsModelFeed(const QSqlRecord &record) : FeedsModelRootItem(NULL) { - m_kind = FeedsModelRootItem::Feed; +Feed::Feed(const QSqlRecord &record) : RootItem(NULL) { + m_kind = RootItem::Feeed; setTitle(record.value(FDS_DB_TITLE_INDEX).toString()); setId(record.value(FDS_DB_ID_INDEX).toInt()); @@ -702,7 +702,7 @@ FeedsModelFeed::FeedsModelFeed(const QSqlRecord &record) : FeedsModelRootItem(NU setPasswordProtected(record.value(FDS_DB_PROTECTED_INDEX).toBool()); setUsername(record.value(FDS_DB_USERNAME_INDEX).toString()); setPassword(TextFactory::decrypt(record.value(FDS_DB_PASSWORD_INDEX).toString())); - setAutoUpdateType(static_cast(record.value(FDS_DB_UPDATE_TYPE_INDEX).toInt())); + setAutoUpdateType(static_cast(record.value(FDS_DB_UPDATE_TYPE_INDEX).toInt())); setAutoUpdateInitialInterval(record.value(FDS_DB_UPDATE_INTERVAL_INDEX).toInt()); updateCounts(); } diff --git a/src/core/feedsmodelfeed.h b/src/core/feed.h old mode 100755 new mode 100644 similarity index 87% rename from src/core/feedsmodelfeed.h rename to src/core/feed.h index 5ef16bfc1..06f421124 --- a/src/core/feedsmodelfeed.h +++ b/src/core/feed.h @@ -18,7 +18,7 @@ #ifndef FEEDSMODELFEED_H #define FEEDSMODELFEED_H -#include "core/feedsmodelrootitem.h" +#include "core/rootitem.h" #include #include @@ -33,8 +33,8 @@ class FeedsModel; // Represents BASE class for feeds contained in FeedsModel. // NOTE: This class should be derived to create PARTICULAR feed types. -class FeedsModelFeed : public FeedsModelRootItem { - Q_DECLARE_TR_FUNCTIONS(FeedsModelFeed) +class Feed : public RootItem { + Q_DECLARE_TR_FUNCTIONS(Feed) public: // Describes possible types of feeds. @@ -63,10 +63,10 @@ class FeedsModelFeed : public FeedsModelRootItem { }; // Constructors and destructors. - explicit FeedsModelFeed(FeedsModelRootItem *parent_item = NULL); - explicit FeedsModelFeed(const FeedsModelFeed &other); - explicit FeedsModelFeed(const QSqlRecord &record); - virtual ~FeedsModelFeed(); + explicit Feed(RootItem *parent_item = NULL); + explicit Feed(const Feed &other); + explicit Feed(const QSqlRecord &record); + virtual ~Feed(); // Returns 0, feeds have no children. int childCount() const; @@ -86,8 +86,8 @@ class FeedsModelFeed : public FeedsModelRootItem { // Removes this standard feed from persistent // storage. bool removeItself(); - bool addItself(FeedsModelRootItem *parent); - bool editItself(FeedsModelFeed *new_feed_data); + bool addItself(RootItem *parent); + bool editItself(Feed *new_feed_data); // Other getters/setters. inline Type type() const { @@ -180,7 +180,7 @@ class FeedsModelFeed : public FeedsModelRootItem { // Returns pointer to guessed feed (if at least partially // guessed) and retrieved error/status code from network layer // or NULL feed. - static QPair guessFeed(const QString &url, + static QPair guessFeed(const QString &url, const QString &username, const QString &password); @@ -219,6 +219,6 @@ class FeedsModelFeed : public FeedsModelRootItem { QString m_url; }; -Q_DECLARE_METATYPE(FeedsModelFeed::Type) +Q_DECLARE_METATYPE(Feed::Type) #endif // FEEDSMODELFEED_H diff --git a/src/core/feeddownloader.cpp b/src/core/feeddownloader.cpp index 47ef1ac91..8482e11a6 100644 --- a/src/core/feeddownloader.cpp +++ b/src/core/feeddownloader.cpp @@ -17,7 +17,7 @@ #include "core/feeddownloader.h" -#include "core/feedsmodelfeed.h" +#include "core/feed.h" #include "definitions/definitions.h" #include @@ -32,7 +32,7 @@ FeedDownloader::~FeedDownloader() { qDebug("Destroying FeedDownloader instance."); } -void FeedDownloader::updateFeeds(const QList &feeds) { +void FeedDownloader::updateFeeds(const QList &feeds) { qDebug().nospace() << "Performing feed updates in thread: \'" << QThread::currentThreadId() << "\'."; // Job starts now. diff --git a/src/core/feeddownloader.h b/src/core/feeddownloader.h index f2233c515..88f8992b7 100644 --- a/src/core/feeddownloader.h +++ b/src/core/feeddownloader.h @@ -23,7 +23,7 @@ #include -class FeedsModelFeed; +class Feed; // Represents results of batch feed updates. struct FeedDownloadResults { @@ -55,7 +55,7 @@ class FeedDownloader : public QObject { // New messages are downloaded for each feed and they // are stored persistently in the database. // Appropriate signals are emitted. - void updateFeeds(const QList &feeds); + void updateFeeds(const QList &feeds); signals: // Emitted if feed updates started. @@ -69,7 +69,7 @@ class FeedDownloader : public QObject { // "Current" number indicates count of processed feeds // and "total" number indicates total number of feeds // which were in the initial queue. - void progress(FeedsModelFeed *feed, int current, int total); + void progress(Feed *feed, int current, int total); }; #endif // FEEDDOWNLOADER_H diff --git a/src/core/feedsimportexportmodel.cpp b/src/core/feedsimportexportmodel.cpp index afc56bb0c..b73d9a1c9 100644 --- a/src/core/feedsimportexportmodel.cpp +++ b/src/core/feedsimportexportmodel.cpp @@ -17,8 +17,8 @@ #include "core/feedsimportexportmodel.h" -#include "core/feedsmodelfeed.h" -#include "core/feedsmodelcategory.h" +#include "core/feed.h" +#include "core/category.h" #include "definitions/definitions.h" #include "miscellaneous/application.h" #include "miscellaneous/iconfactory.h" @@ -31,7 +31,7 @@ FeedsImportExportModel::FeedsImportExportModel(QObject *parent) - : QAbstractItemModel(parent), m_checkStates(QHash()), + : QAbstractItemModel(parent), m_checkStates(QHash()), m_rootItem(NULL), m_recursiveChange(false), m_mode(Import) { } @@ -43,20 +43,20 @@ FeedsImportExportModel::~FeedsImportExportModel() { } } -FeedsModelRootItem *FeedsImportExportModel::itemForIndex(const QModelIndex &index) const { +RootItem *FeedsImportExportModel::itemForIndex(const QModelIndex &index) const { if (index.isValid() && index.model() == this) { - return static_cast(index.internalPointer()); + return static_cast(index.internalPointer()); } else { return m_rootItem; } } -FeedsModelRootItem *FeedsImportExportModel::rootItem() const { +RootItem *FeedsImportExportModel::rootItem() const { return m_rootItem; } -void FeedsImportExportModel::setRootItem(FeedsModelRootItem *rootItem) { +void FeedsImportExportModel::setRootItem(RootItem *rootItem) { m_rootItem = rootItem; } @@ -85,21 +85,21 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray &result) { opml_document.documentElement().appendChild(elem_opml_head); QDomElement elem_opml_body = opml_document.createElement(QSL("body")); - QStack items_to_process; items_to_process.push(m_rootItem); + QStack items_to_process; items_to_process.push(m_rootItem); QStack elements_to_use; elements_to_use.push(elem_opml_body); // Process all unprocessed nodes. while (!items_to_process.isEmpty()) { QDomElement active_element = elements_to_use.pop(); - FeedsModelRootItem *active_item = items_to_process.pop(); + RootItem *active_item = items_to_process.pop(); - foreach (FeedsModelRootItem *child_item, active_item->childItems()) { + foreach (RootItem *child_item, active_item->childItems()) { if (!m_checkStates.contains(child_item) || m_checkStates[child_item] != Qt::Checked) { continue; } switch (child_item->kind()) { - case FeedsModelRootItem::Category: { + case RootItem::Cattegory: { QDomElement outline_category = opml_document.createElement(QSL("outline")); outline_category.setAttribute(QSL("text"), child_item->title()); outline_category.setAttribute(QSL("description"), child_item->description()); @@ -110,8 +110,8 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray &result) { break; } - case FeedsModelRootItem::Feed: { - FeedsModelFeed *child_feed = child_item->toFeed(); + case RootItem::Feeed: { + Feed *child_feed = child_item->toFeed(); QDomElement outline_feed = opml_document.createElement("outline"); outline_feed.setAttribute(QSL("text"), child_feed->title()); outline_feed.setAttribute(QSL("xmlUrl"), child_feed->url()); @@ -121,16 +121,16 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray &result) { outline_feed.setAttribute(QSL("rssguard:icon"), QString(qApp->icons()->toByteArray(child_feed->icon()))); switch (child_feed->type()) { - case FeedsModelFeed::Rss0X: - case FeedsModelFeed::Rss2X: + case Feed::Rss0X: + case Feed::Rss2X: outline_feed.setAttribute(QSL("version"), QSL("RSS")); break; - case FeedsModelFeed::Rdf: + case Feed::Rdf: outline_feed.setAttribute(QSL("version"), QSL("RSS1")); break; - case FeedsModelFeed::Atom10: + case Feed::Atom10: outline_feed.setAttribute(QSL("version"), QSL("ATOM")); break; @@ -166,12 +166,12 @@ bool FeedsImportExportModel::importAsOPML20(const QByteArray &data) { return false; } - FeedsModelRootItem *root_item = new FeedsModelRootItem(); - QStack model_items; model_items.push(root_item); + RootItem *root_item = new RootItem(); + 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()); while (!elements_to_process.isEmpty()) { - FeedsModelRootItem *active_model_item = model_items.pop(); + RootItem *active_model_item = model_items.pop(); QDomElement active_element = elements_to_process.pop(); for (int i = 0; i < active_element.childNodes().size(); i++) { @@ -192,23 +192,23 @@ bool FeedsImportExportModel::importAsOPML20(const QByteArray &data) { QString feed_description = child_element.attribute(QSL("description")); QIcon feed_icon = qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit()); - FeedsModelFeed *new_feed = new FeedsModelFeed(active_model_item); + Feed *new_feed = new Feed(active_model_item); new_feed->setTitle(feed_title); new_feed->setDescription(feed_description); new_feed->setEncoding(feed_encoding); new_feed->setUrl(feed_url); new_feed->setCreationDate(QDateTime::currentDateTime()); new_feed->setIcon(feed_icon.isNull() ? qApp->icons()->fromTheme(QSL("folder-feed")) : feed_icon); - new_feed->setAutoUpdateType(FeedsModelFeed::DefaultAutoUpdate); + new_feed->setAutoUpdateType(Feed::DefaultAutoUpdate); if (feed_type == QL1S("RSS1")) { - new_feed->setType(FeedsModelFeed::Rdf); + new_feed->setType(Feed::Rdf); } else if (feed_type == QL1S("ATOM")) { - new_feed->setType(FeedsModelFeed::Atom10); + new_feed->setType(Feed::Atom10); } else { - new_feed->setType(FeedsModelFeed::Rss2X); + new_feed->setType(Feed::Rss2X); } active_model_item->appendChild(new_feed); @@ -230,7 +230,7 @@ bool FeedsImportExportModel::importAsOPML20(const QByteArray &data) { } } - FeedsModelCategory *new_category = new FeedsModelCategory(active_model_item); + Category *new_category = new Category(active_model_item); new_category->setTitle(category_title); new_category->setIcon(category_icon.isNull() ? qApp->icons()->fromTheme(QSL("folder-category")) : category_icon); new_category->setCreationDate(QDateTime::currentDateTime()); @@ -263,16 +263,16 @@ void FeedsImportExportModel::setMode(const FeedsImportExportModel::Mode &mode) { } void FeedsImportExportModel::checkAllItems() { - foreach (FeedsModelRootItem *root_child, m_rootItem->childItems()) { - if (root_child->kind() != FeedsModelRootItem::RecycleBin) { + foreach (RootItem *root_child, m_rootItem->childItems()) { + if (root_child->kind() != RootItem::Bin) { setData(indexForItem(root_child), Qt::Checked, Qt::CheckStateRole); } } } void FeedsImportExportModel::uncheckAllItems() { - foreach (FeedsModelRootItem *root_child, m_rootItem->childItems()) { - if (root_child->kind() != FeedsModelRootItem::RecycleBin) { + foreach (RootItem *root_child, m_rootItem->childItems()) { + if (root_child->kind() != RootItem::Bin) { setData(indexForItem(root_child), Qt::Unchecked, Qt::CheckStateRole); } } @@ -283,8 +283,8 @@ QModelIndex FeedsImportExportModel::index(int row, int column, const QModelIndex return QModelIndex(); } - FeedsModelRootItem *parent_item = itemForIndex(parent); - FeedsModelRootItem *child_item = parent_item->child(row); + RootItem *parent_item = itemForIndex(parent); + RootItem *child_item = parent_item->child(row); if (child_item) { return createIndex(row, column, child_item); @@ -294,8 +294,8 @@ QModelIndex FeedsImportExportModel::index(int row, int column, const QModelIndex } } -QModelIndex FeedsImportExportModel::indexForItem(FeedsModelRootItem *item) const { - if (item == NULL || item->kind() == FeedsModelRootItem::RootItem) { +QModelIndex FeedsImportExportModel::indexForItem(RootItem *item) const { + if (item == NULL || item->kind() == RootItem::Root) { // Root item lies on invalid index. return QModelIndex(); } @@ -312,7 +312,7 @@ QModelIndex FeedsImportExportModel::indexForItem(FeedsModelRootItem *item) const if (row_count > 0) { // This index has children. // Lets take a look if our target item is among them. - FeedsModelRootItem *active_item = itemForIndex(active_index); + RootItem *active_item = itemForIndex(active_index); int candidate_index = active_item->childItems().indexOf(item); if (candidate_index >= 0) { @@ -322,9 +322,9 @@ QModelIndex FeedsImportExportModel::indexForItem(FeedsModelRootItem *item) const else { // Item is not found, add all "categories" from active_item. for (int i = 0; i < row_count; i++) { - FeedsModelRootItem *possible_category = active_item->child(i); + RootItem *possible_category = active_item->child(i); - if (possible_category->kind() == FeedsModelRootItem::Category) { + if (possible_category->kind() == RootItem::Cattegory) { parents << index(i, 0, active_index); } } @@ -340,8 +340,8 @@ QModelIndex FeedsImportExportModel::parent(const QModelIndex &child) const { return QModelIndex(); } - FeedsModelRootItem *child_item = itemForIndex(child); - FeedsModelRootItem *parent_item = child_item->parent(); + RootItem *child_item = itemForIndex(child); + RootItem *parent_item = child_item->parent(); if (parent_item == m_rootItem) { return QModelIndex(); @@ -371,7 +371,7 @@ QVariant FeedsImportExportModel::data(const QModelIndex &index, int role) const return QVariant(); } - FeedsModelRootItem *item = itemForIndex(index); + RootItem *item = itemForIndex(index); if (role == Qt::CheckStateRole) { if (m_checkStates.contains(item)) { @@ -383,9 +383,9 @@ QVariant FeedsImportExportModel::data(const QModelIndex &index, int role) const } else if (role == Qt::DecorationRole) { switch (item->kind()) { - case FeedsModelRootItem::Category: - case FeedsModelRootItem::RecycleBin: - case FeedsModelRootItem::Feed: + case RootItem::Cattegory: + case RootItem::Bin: + case RootItem::Feeed: return item->icon(); default: @@ -394,10 +394,10 @@ QVariant FeedsImportExportModel::data(const QModelIndex &index, int role) const } else if (role == Qt::DisplayRole) { switch (item->kind()) { - case FeedsModelRootItem::Category: + case RootItem::Cattegory: return QVariant(item->data(index.column(), role).toString() + tr(" (category)")); - case FeedsModelRootItem::Feed: + case RootItem::Feeed: return QVariant(item->data(index.column(), role).toString() + tr(" (feed)")); default: @@ -411,7 +411,7 @@ QVariant FeedsImportExportModel::data(const QModelIndex &index, int role) const bool FeedsImportExportModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (index.isValid() && index.column() == 0 && role == Qt::CheckStateRole) { - FeedsModelRootItem *item = itemForIndex(index); + RootItem *item = itemForIndex(index); if (item == m_rootItem) { // Cannot set data on root item. @@ -427,7 +427,7 @@ bool FeedsImportExportModel::setData(const QModelIndex &index, const QVariant &v } // Set new data for all descendants of this actual item. - foreach(FeedsModelRootItem *child, item->childItems()) { + foreach(RootItem *child, item->childItems()) { setData(indexForItem(child), value, Qt::CheckStateRole); } @@ -442,7 +442,7 @@ bool FeedsImportExportModel::setData(const QModelIndex &index, const QVariant &v // Check children of this new parent item. Qt::CheckState parent_state = Qt::Unchecked; - foreach (FeedsModelRootItem *child_of_parent, item->childItems()) { + foreach (RootItem *child_of_parent, item->childItems()) { if (m_checkStates.contains(child_of_parent) && m_checkStates[child_of_parent] == Qt::Checked) { // We found out, that some child of this item is checked, // therefore this item must be checked too. @@ -462,7 +462,7 @@ bool FeedsImportExportModel::setData(const QModelIndex &index, const QVariant &v } Qt::ItemFlags FeedsImportExportModel::flags(const QModelIndex &index) const { - if (!index.isValid() || itemForIndex(index)->kind() == FeedsModelRootItem::RecycleBin) { + if (!index.isValid() || itemForIndex(index)->kind() == RootItem::Bin) { return Qt::NoItemFlags; } @@ -475,6 +475,6 @@ Qt::ItemFlags FeedsImportExportModel::flags(const QModelIndex &index) const { return flags; } -bool FeedsImportExportModel::isItemChecked(FeedsModelRootItem *item) { +bool FeedsImportExportModel::isItemChecked(RootItem *item) { return m_checkStates.contains(item) && m_checkStates.value(item, Qt::Unchecked); } diff --git a/src/core/feedsimportexportmodel.h b/src/core/feedsimportexportmodel.h index 41a8cdda0..972ed5e3c 100644 --- a/src/core/feedsimportexportmodel.h +++ b/src/core/feedsimportexportmodel.h @@ -20,7 +20,7 @@ #include -#include "core/feedsmodelrootitem.h" +#include "core/rootitem.h" class FeedsImportExportModel : public QAbstractItemModel { @@ -44,18 +44,18 @@ class FeedsImportExportModel : public QAbstractItemModel { bool setData(const QModelIndex &index, const QVariant &value, int role); Qt::ItemFlags flags(const QModelIndex &index) const; - bool isItemChecked(FeedsModelRootItem *item); + bool isItemChecked(RootItem *item); // Returns feed/category which lies at the specified index or // root item if index is invalid. - FeedsModelRootItem *itemForIndex(const QModelIndex &index) const; + RootItem *itemForIndex(const QModelIndex &index) const; // Returns source QModelIndex on which lies given item. - QModelIndex indexForItem(FeedsModelRootItem *item) const; + QModelIndex indexForItem(RootItem *item) const; // Root item manipulators. - FeedsModelRootItem *rootItem() const; - void setRootItem(FeedsModelRootItem *rootItem); + RootItem *rootItem() const; + void setRootItem(RootItem *rootItem); // Exports to OPML 2.0 // NOTE: http://dev.opml.org/spec2.html @@ -70,8 +70,8 @@ class FeedsImportExportModel : public QAbstractItemModel { void uncheckAllItems(); private: - QHash m_checkStates; - FeedsModelRootItem *m_rootItem; + QHash m_checkStates; + RootItem *m_rootItem; // When it's true, then bool m_recursiveChange; diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index e6e46b7d6..f30bde7ab 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -18,9 +18,9 @@ #include "core/feedsmodel.h" #include "definitions/definitions.h" -#include "core/feedsmodelcategory.h" -#include "core/feedsmodelfeed.h" -#include "core/feedsmodelrecyclebin.h" +#include "core/category.h" +#include "core/feed.h" +#include "core/recyclebin.h" #include "core/feedsimportexportmodel.h" #include "miscellaneous/textfactory.h" #include "miscellaneous/databasefactory.h" @@ -38,11 +38,11 @@ FeedsModel::FeedsModel(QObject *parent) - : QAbstractItemModel(parent), m_recycleBin(new FeedsModelRecycleBin()) { + : QAbstractItemModel(parent), m_recycleBin(new RecycleBin()) { setObjectName(QSL("FeedsModel")); // Create root item. - m_rootItem = new FeedsModelRootItem(); + m_rootItem = new RootItem(); m_rootItem->setId(NO_PARENT_CATEGORY); //: Name of root item of feed list which can be seen in feed add/edit dialog. @@ -78,9 +78,9 @@ QMimeData *FeedsModel::mimeData(const QModelIndexList &indexes) const { continue; } - FeedsModelRootItem *item_for_index = itemForIndex(index); + RootItem *item_for_index = itemForIndex(index); - if (item_for_index->kind() != FeedsModelRootItem::RootItem) { + if (item_for_index->kind() != RootItem::Root) { stream << (quintptr) item_for_index; } } @@ -117,30 +117,30 @@ bool FeedsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int stream >> pointer_to_item; // We have item we want to drag, we also determine the target item. - FeedsModelRootItem *dragged_item = (FeedsModelRootItem*) pointer_to_item; - FeedsModelRootItem *target_item = itemForIndex(parent); + RootItem *dragged_item = (RootItem*) pointer_to_item; + RootItem *target_item = itemForIndex(parent); if (dragged_item == target_item || dragged_item->parent() == target_item) { qDebug("Dragged item is equal to target item or its parent is equal to target item. Cancelling drag-drop action."); return false; } - if (dragged_item->kind() == FeedsModelRootItem::Feed) { + if (dragged_item->kind() == RootItem::Feeed) { qDebug("Drag-drop action for feed '%s' detected, editing the feed.", qPrintable(dragged_item->title())); - FeedsModelFeed *actual_feed = dragged_item->toFeed(); - FeedsModelFeed *feed_new = new FeedsModelFeed(*actual_feed); + Feed *actual_feed = dragged_item->toFeed(); + Feed *feed_new = new Feed(*actual_feed); feed_new->setParent(target_item); editFeed(actual_feed, feed_new); emit requireItemValidationAfterDragDrop(indexForItem(actual_feed)); } - else if (dragged_item->kind() == FeedsModelRootItem::Category) { + else if (dragged_item->kind() == RootItem::Cattegory) { qDebug("Drag-drop action for category '%s' detected, editing the feed.", qPrintable(dragged_item->title())); - FeedsModelCategory *actual_category = dragged_item->toCategory(); - FeedsModelCategory *category_new = new FeedsModelCategory(*actual_category); + Category *actual_category = dragged_item->toCategory(); + Category *category_new = new Category(*actual_category); category_new->clearChildren(); category_new->setParent(target_item); @@ -160,19 +160,19 @@ Qt::DropActions FeedsModel::supportedDropActions() const { Qt::ItemFlags FeedsModel::flags(const QModelIndex &index) const { Qt::ItemFlags base_flags = QAbstractItemModel::flags(index); - FeedsModelRootItem *item_for_index = itemForIndex(index); + RootItem *item_for_index = itemForIndex(index); switch (item_for_index->kind()) { - case FeedsModelRootItem::RecycleBin: + case RootItem::Bin: return base_flags; - case FeedsModelRootItem::Category: + case RootItem::Cattegory: return base_flags | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; - case FeedsModelRootItem::Feed: + case RootItem::Feeed: return base_flags | Qt::ItemIsDragEnabled; - case FeedsModelRootItem::RootItem: + case RootItem::Root: default: return base_flags | Qt::ItemIsDropEnabled; } @@ -213,8 +213,8 @@ QModelIndex FeedsModel::index(int row, int column, const QModelIndex &parent) co return QModelIndex(); } - FeedsModelRootItem *parent_item = itemForIndex(parent); - FeedsModelRootItem *child_item = parent_item->child(row); + RootItem *parent_item = itemForIndex(parent); + RootItem *child_item = parent_item->child(row); if (child_item) { return createIndex(row, column, child_item); @@ -229,8 +229,8 @@ QModelIndex FeedsModel::parent(const QModelIndex &child) const { return QModelIndex(); } - FeedsModelRootItem *child_item = itemForIndex(child); - FeedsModelRootItem *parent_item = child_item->parent(); + RootItem *child_item = itemForIndex(child); + RootItem *parent_item = child_item->parent(); if (parent_item == m_rootItem) { return QModelIndex(); @@ -252,8 +252,8 @@ int FeedsModel::rowCount(const QModelIndex &parent) const { bool FeedsModel::removeItem(const QModelIndex &index) { if (index.isValid()) { QModelIndex parent_index = index.parent(); - FeedsModelRootItem *deleting_item = itemForIndex(index); - FeedsModelRootItem *parent_item = deleting_item->parent(); + RootItem *deleting_item = itemForIndex(index); + RootItem *parent_item = deleting_item->parent(); // Try to persistently remove the item. if (deleting_item->removeItself()) { @@ -272,7 +272,7 @@ bool FeedsModel::removeItem(const QModelIndex &index) { return false; } -bool FeedsModel::addCategory(FeedsModelCategory *category, FeedsModelRootItem *parent) { +bool FeedsModel::addCategory(Category *category, RootItem *parent) { // Get index of parent item (parent standard category). QModelIndex parent_index = indexForItem(parent); bool result = category->addItself(parent); @@ -292,9 +292,9 @@ bool FeedsModel::addCategory(FeedsModelCategory *category, FeedsModelRootItem *p return result; } -bool FeedsModel::editCategory(FeedsModelCategory *original_category, FeedsModelCategory *new_category_data) { - FeedsModelRootItem *original_parent = original_category->parent(); - FeedsModelRootItem *new_parent = new_category_data->parent(); +bool FeedsModel::editCategory(Category *original_category, Category *new_category_data) { + RootItem *original_parent = original_category->parent(); + RootItem *new_parent = new_category_data->parent(); bool result = original_category->editItself(new_category_data); if (result && original_parent != new_parent) { @@ -319,7 +319,7 @@ bool FeedsModel::editCategory(FeedsModelCategory *original_category, FeedsModelC return result; } -bool FeedsModel::addFeed(FeedsModelFeed *feed, FeedsModelRootItem *parent) { +bool FeedsModel::addFeed(Feed *feed, RootItem *parent) { // Get index of parent item (parent standard category or root item). QModelIndex parent_index = indexForItem(parent); bool result = feed->addItself(parent); @@ -337,9 +337,9 @@ bool FeedsModel::addFeed(FeedsModelFeed *feed, FeedsModelRootItem *parent) { return result; } -bool FeedsModel::editFeed(FeedsModelFeed *original_feed, FeedsModelFeed *new_feed_data) { - FeedsModelRootItem *original_parent = original_feed->parent(); - FeedsModelRootItem *new_parent = new_feed_data->parent(); +bool FeedsModel::editFeed(Feed *original_feed, Feed *new_feed_data) { + RootItem *original_parent = original_feed->parent(); + RootItem *new_parent = new_feed_data->parent(); bool result = original_feed->editItself(new_feed_data); if (result && original_parent != new_parent) { @@ -363,23 +363,23 @@ bool FeedsModel::editFeed(FeedsModelFeed *original_feed, FeedsModelFeed *new_fee return result; } -QList FeedsModel::feedsForScheduledUpdate(bool auto_update_now) { - QList feeds_for_update; +QList FeedsModel::feedsForScheduledUpdate(bool auto_update_now) { + QList feeds_for_update; - foreach (FeedsModelFeed *feed, allFeeds()) { + foreach (Feed *feed, allFeeds()) { switch (feed->autoUpdateType()) { - case FeedsModelFeed::DontAutoUpdate: + case Feed::DontAutoUpdate: // Do not auto-update this feed ever. continue; - case FeedsModelFeed::DefaultAutoUpdate: + case Feed::DefaultAutoUpdate: if (auto_update_now) { feeds_for_update.append(feed); } break; - case FeedsModelFeed::SpecificAutoUpdate: + case Feed::SpecificAutoUpdate: default: int remaining_interval = feed->autoUpdateRemainingInterval(); @@ -402,7 +402,7 @@ QList FeedsModel::feedsForScheduledUpdate(bool auto_update_now) return feeds_for_update; } -QList FeedsModel::messagesForFeeds(const QList &feeds) { +QList FeedsModel::messagesForFeeds(const QList &feeds) { QList messages; QSqlDatabase database = qApp->database()->connection(objectName(), @@ -413,7 +413,7 @@ QList FeedsModel::messagesForFeeds(const QList &feeds) "FROM Messages " "WHERE is_deleted = 0 AND feed = :feed;"); - foreach (FeedsModelFeed *feed, feeds) { + foreach (Feed *feed, feeds) { query_read_msg.bindValue(QSL(":feed"), feed->id()); if (query_read_msg.exec()) { @@ -441,19 +441,19 @@ int FeedsModel::columnCount(const QModelIndex &parent) const { return FEEDS_VIEW_COLUMN_COUNT; } -FeedsModelRootItem *FeedsModel::itemForIndex(const QModelIndex &index) const { +RootItem *FeedsModel::itemForIndex(const QModelIndex &index) const { if (index.isValid() && index.model() == this) { - return static_cast(index.internalPointer()); + return static_cast(index.internalPointer()); } else { return m_rootItem; } } -FeedsModelCategory *FeedsModel::categoryForIndex(const QModelIndex &index) const { - FeedsModelRootItem *item = itemForIndex(index); +Category *FeedsModel::categoryForIndex(const QModelIndex &index) const { + RootItem *item = itemForIndex(index); - if (item->kind() == FeedsModelRootItem::Category) { + if (item->kind() == RootItem::Cattegory) { return item->toCategory(); } else { @@ -461,10 +461,10 @@ FeedsModelCategory *FeedsModel::categoryForIndex(const QModelIndex &index) const } } -FeedsModelRecycleBin *FeedsModel::recycleBinForIndex(const QModelIndex &index) const { - FeedsModelRootItem *item = itemForIndex(index); +RecycleBin *FeedsModel::recycleBinForIndex(const QModelIndex &index) const { + RootItem *item = itemForIndex(index); - if (item->kind() == FeedsModelRootItem::RecycleBin) { + if (item->kind() == RootItem::Bin) { return item->toRecycleBin(); } else { @@ -472,15 +472,15 @@ FeedsModelRecycleBin *FeedsModel::recycleBinForIndex(const QModelIndex &index) c } } -QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const { - if (item == NULL || item->kind() == FeedsModelRootItem::RootItem) { +QModelIndex FeedsModel::indexForItem(RootItem *item) const { + if (item == NULL || item->kind() == RootItem::Root) { // Root item lies on invalid index. return QModelIndex(); } - QStack chain; + QStack chain; - while (item->kind() != FeedsModelRootItem::RootItem) { + while (item->kind() != RootItem::Root) { chain.push(item); item = item->parent(); } @@ -490,7 +490,7 @@ QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const { // We go through the stack and create our target index. while (!chain.isEmpty()) { - FeedsModelRootItem *parent_item = chain.pop(); + RootItem *parent_item = chain.pop(); target_index = index(parent_item->parent()->childItems().indexOf(parent_item), 0, target_index); } @@ -498,8 +498,8 @@ QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const { } bool FeedsModel::hasAnyFeedNewMessages() { - foreach (const FeedsModelFeed *feed, allFeeds()) { - if (feed->status() == FeedsModelFeed::NewMessages) { + foreach (const Feed *feed, allFeeds()) { + if (feed->status() == Feed::NewMessages) { return true; } } @@ -514,8 +514,8 @@ bool FeedsModel::mergeModel(FeedsImportExportModel *model, QString &output_messa return false; } - QStack original_parents; original_parents.push(m_rootItem); - QStack new_parents; new_parents.push(model->rootItem()); + QStack original_parents; original_parents.push(m_rootItem); + QStack new_parents; new_parents.push(model->rootItem()); bool some_feed_category_error = false; // We are definitely about to add some new items into the model. @@ -523,19 +523,19 @@ bool FeedsModel::mergeModel(FeedsImportExportModel *model, QString &output_messa // Iterate all new items we would like to merge into current model. while (!new_parents.isEmpty()) { - FeedsModelRootItem *target_parent = original_parents.pop(); - FeedsModelRootItem *source_parent = new_parents.pop(); + RootItem *target_parent = original_parents.pop(); + RootItem *source_parent = new_parents.pop(); - foreach (FeedsModelRootItem *source_item, source_parent->childItems()) { + foreach (RootItem *source_item, source_parent->childItems()) { if (!model->isItemChecked(source_item)) { // We can skip this item, because it is not checked and should not be imported. // NOTE: All descendants are thus skipped too. continue; } - if (source_item->kind() == FeedsModelRootItem::Category) { - FeedsModelCategory *source_category = source_item->toCategory(); - FeedsModelCategory *new_category = new FeedsModelCategory(*source_category); + if (source_item->kind() == RootItem::Cattegory) { + Category *source_category = source_item->toCategory(); + Category *new_category = new Category(*source_category); // Add category to model. new_category->clearChildren(); @@ -549,7 +549,7 @@ bool FeedsModel::mergeModel(FeedsImportExportModel *model, QString &output_messa // Add category failed, but this can mean that the same category (with same title) // already exists. If such a category exists in current parent, then find it and // add descendants to it. - FeedsModelRootItem *existing_category = target_parent->child(FeedsModelRootItem::Category, new_category->title()); + RootItem *existing_category = target_parent->child(RootItem::Cattegory, new_category->title()); if (existing_category != NULL) { original_parents.push(existing_category); @@ -560,9 +560,9 @@ bool FeedsModel::mergeModel(FeedsImportExportModel *model, QString &output_messa } } } - else if (source_item->kind() == FeedsModelRootItem::Feed) { - FeedsModelFeed *source_feed = source_item->toFeed(); - FeedsModelFeed *new_feed = new FeedsModelFeed(*source_feed); + else if (source_item->kind() == RootItem::Feeed) { + Feed *source_feed = source_item->toFeed(); + Feed *new_feed = new Feed(*source_feed); // Append this feed and end this iteration. if (!addFeed(new_feed, target_parent)) { @@ -595,11 +595,11 @@ void FeedsModel::reloadChangedLayout(QModelIndexList list) { } } -QStringList FeedsModel::textualFeedIds(const QList &feeds) { +QStringList FeedsModel::textualFeedIds(const QList &feeds) { QStringList stringy_ids; stringy_ids.reserve(feeds.size()); - foreach (FeedsModelFeed *feed, feeds) { + foreach (Feed *feed, feeds) { stringy_ids.append(QString::number(feed->id())); } @@ -632,7 +632,7 @@ void FeedsModel::loadFromDatabase() { while (query_categories.next()) { CategoryAssignmentItem pair; pair.first = query_categories.value(CAT_DB_PARENT_ID_INDEX).toInt(); - pair.second = new FeedsModelCategory(query_categories.record()); + pair.second = new Category(query_categories.record()); categories << pair; } @@ -648,16 +648,16 @@ void FeedsModel::loadFromDatabase() { while (query_feeds.next()) { // Process this feed. - FeedsModelFeed::Type type = static_cast(query_feeds.value(FDS_DB_TYPE_INDEX).toInt()); + Feed::Type type = static_cast(query_feeds.value(FDS_DB_TYPE_INDEX).toInt()); switch (type) { - case FeedsModelFeed::Atom10: - case FeedsModelFeed::Rdf: - case FeedsModelFeed::Rss0X: - case FeedsModelFeed::Rss2X: { + case Feed::Atom10: + case Feed::Rdf: + case Feed::Rss0X: + case Feed::Rss2X: { FeedAssignmentItem pair; pair.first = query_feeds.value(FDS_DB_CATEGORY_INDEX).toInt(); - pair.second = new FeedsModelFeed(query_feeds.record()); + pair.second = new Feed(query_feeds.record()); pair.second->setType(type); feeds << pair; @@ -677,15 +677,15 @@ void FeedsModel::loadFromDatabase() { m_rootItem->appendChild(m_recycleBin); } -QList FeedsModel::feedsForIndex(const QModelIndex &index) { - FeedsModelRootItem *item = itemForIndex(index); +QList FeedsModel::feedsForIndex(const QModelIndex &index) { + RootItem *item = itemForIndex(index); return feedsForItem(item); } -FeedsModelFeed *FeedsModel::feedForIndex(const QModelIndex &index) { - FeedsModelRootItem *item = itemForIndex(index); +Feed *FeedsModel::feedForIndex(const QModelIndex &index) { + RootItem *item = itemForIndex(index); - if (item->kind() == FeedsModelRootItem::Feed) { + if (item->kind() == RootItem::Feeed) { return item->toFeed(); } else { @@ -693,8 +693,8 @@ FeedsModelFeed *FeedsModel::feedForIndex(const QModelIndex &index) { } } -QList FeedsModel::feedsForIndexes(const QModelIndexList &indexes) { - QList feeds; +QList FeedsModel::feedsForIndexes(const QModelIndexList &indexes) { + QList feeds; // Get selected feeds for each index. foreach (const QModelIndex &index, indexes) { @@ -706,14 +706,14 @@ QList FeedsModel::feedsForIndexes(const QModelIndexList &indexe // Selection contains duplicate feeds (for // example situation where feed and its parent category are both // selected). So, remove duplicates from the list. - qSort(feeds.begin(), feeds.end(), FeedsModelRootItem::lessThan); - feeds.erase(std::unique(feeds.begin(), feeds.end(), FeedsModelRootItem::isEqual), feeds.end()); + qSort(feeds.begin(), feeds.end(), RootItem::lessThan); + feeds.erase(std::unique(feeds.begin(), feeds.end(), RootItem::isEqual), feeds.end()); } return feeds; } -bool FeedsModel::markFeedsRead(const QList &feeds, int read) { +bool FeedsModel::markFeedsRead(const QList &feeds, int read) { QSqlDatabase db_handle = qApp->database()->connection(objectName(), DatabaseFactory::FromSettings); if (!db_handle.transaction()) { @@ -748,7 +748,7 @@ bool FeedsModel::markFeedsRead(const QList &feeds, int read) { } } -bool FeedsModel::markFeedsDeleted(const QList &feeds, int deleted, bool read_only) { +bool FeedsModel::markFeedsDeleted(const QList &feeds, int deleted, bool read_only) { QSqlDatabase db_handle = qApp->database()->connection(objectName(), DatabaseFactory::FromSettings); if (!db_handle.transaction()) { @@ -794,24 +794,24 @@ bool FeedsModel::markFeedsDeleted(const QList &feeds, int delet } } -QHash FeedsModel::allCategories() { +QHash FeedsModel::allCategories() { return categoriesForItem(m_rootItem); } -QHash FeedsModel::categoriesForItem(FeedsModelRootItem *root) { - QHash categories; - QList parents; +QHash FeedsModel::categoriesForItem(RootItem *root) { + QHash categories; + QList parents; parents.append(root->childItems()); while (!parents.isEmpty()) { - FeedsModelRootItem *item = parents.takeFirst(); + RootItem *item = parents.takeFirst(); - if (item->kind() == FeedsModelRootItem::Category) { + if (item->kind() == RootItem::Cattegory) { // This item is category, add it to the output list and // scan its children. int category_id = item->id(); - FeedsModelCategory *category = item->toCategory(); + Category *category = item->toCategory(); if (!categories.contains(category_id)) { categories.insert(category_id, category); @@ -824,16 +824,16 @@ QHash FeedsModel::categoriesForItem(FeedsModelRootItem return categories; } -QList FeedsModel::allFeeds() { +QList FeedsModel::allFeeds() { return feedsForItem(m_rootItem); } -QList FeedsModel::feedsForItem(FeedsModelRootItem *root) { - QList children = root->getRecursiveChildren(); - QList feeds; +QList FeedsModel::feedsForItem(RootItem *root) { + QList children = root->getRecursiveChildren(); + QList feeds; - foreach (FeedsModelRootItem *child, children) { - if (child->kind() == FeedsModelRootItem::Feed) { + foreach (RootItem *child, children) { + if (child->kind() == RootItem::Feeed) { feeds.append(child->toFeed()); } } @@ -842,7 +842,7 @@ QList FeedsModel::feedsForItem(FeedsModelRootItem *root) { } void FeedsModel::assembleFeeds(FeedAssignment feeds) { - QHash categories = allCategories(); + QHash categories = allCategories(); foreach (const FeedAssignmentItem &feed, feeds) { if (feed.first == NO_PARENT_CATEGORY) { @@ -859,12 +859,12 @@ void FeedsModel::assembleFeeds(FeedAssignment feeds) { } } -FeedsModelRecycleBin *FeedsModel::recycleBin() const { +RecycleBin *FeedsModel::recycleBin() const { return m_recycleBin; } void FeedsModel::assembleCategories(CategoryAssignment categories) { - QHash assignments; + QHash assignments; assignments.insert(NO_PARENT_CATEGORY, m_rootItem); // Add top-level categories. diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index 811ea779b..e0f1bed13 100644 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -21,27 +21,27 @@ #include #include "core/messagesmodel.h" -#include "core/feedsmodelrootitem.h" +#include "core/rootitem.h" #include -class FeedsModelCategory; -class FeedsModelFeed; -class FeedsModelRecycleBin; +class Category; +class Feed; +class RecycleBin; class FeedsImportExportModel; -typedef QList > CategoryAssignment; -typedef QPair CategoryAssignmentItem; +typedef QList > CategoryAssignment; +typedef QPair CategoryAssignmentItem; -typedef QList > FeedAssignment; -typedef QPair FeedAssignmentItem; +typedef QList > FeedAssignment; +typedef QPair FeedAssignmentItem; class FeedsModel : public QAbstractItemModel { Q_OBJECT - friend class FeedsModelFeed; - friend class FeedsModelCategory; + friend class Feed; + friend class Category; public: // Constructors and destructors. @@ -78,73 +78,73 @@ class FeedsModel : public QAbstractItemModel { bool removeItem(const QModelIndex &index); // Standard category manipulators. - bool addCategory(FeedsModelCategory *category, FeedsModelRootItem *parent); - bool editCategory(FeedsModelCategory *original_category, FeedsModelCategory *new_category_data); + bool addCategory(Category *category, RootItem *parent); + bool editCategory(Category *original_category, Category *new_category_data); // Standard feed manipulators. - bool addFeed(FeedsModelFeed *feed, FeedsModelRootItem *parent); + bool addFeed(Feed *feed, RootItem *parent); // New feed is just temporary feed, it is not added to the model. // It is used to fetch its data to the original feed // and the original feed is moved if needed. - bool editFeed(FeedsModelFeed *original_feed, FeedsModelFeed *new_feed_data); + bool editFeed(Feed *original_feed, Feed *new_feed_data); // Returns the list of updates which should be updated // according to auto-update schedule. // Variable "auto_update_now" is true, when global timeout // for scheduled auto-update was met so feeds with "default" // auto-update strategy should be updated. - QList feedsForScheduledUpdate(bool auto_update_now); + QList feedsForScheduledUpdate(bool auto_update_now); // Returns (undeleted) messages for given feeds. // This is usually used for displaying whole feeds // in "newspaper" mode. - QList messagesForFeeds(const QList &feeds); + QList messagesForFeeds(const QList &feeds); // Returns all categories, each pair // consists of ID of parent item and pointer to category. - QHash allCategories(); + QHash allCategories(); // Returns categories from the subtree with given root node, each pair // consists of ID of parent item and pointer to category. - QHash categoriesForItem(FeedsModelRootItem *root); + QHash categoriesForItem(RootItem *root); // Returns list of all feeds contained in the model. - QList allFeeds(); + QList allFeeds(); // Get list of feeds from tree with particular item // as root. If root itself is a feed, then it is returned. - QList feedsForItem(FeedsModelRootItem *root); + QList feedsForItem(RootItem *root); // Returns list of ALL CHILD feeds which belong to given parent indexes. - QList feedsForIndexes(const QModelIndexList &indexes); + QList feedsForIndexes(const QModelIndexList &indexes); // Returns ALL CHILD feeds contained within single index. - QList feedsForIndex(const QModelIndex &index); + QList feedsForIndex(const QModelIndex &index); // Returns pointer to feed if it lies on given index // or NULL if no feed lies on given index. - FeedsModelFeed *feedForIndex(const QModelIndex &index); + Feed *feedForIndex(const QModelIndex &index); // Returns pointer to category if it lies on given index // or NULL if no category lies on given index. - FeedsModelCategory *categoryForIndex(const QModelIndex &index) const; + Category *categoryForIndex(const QModelIndex &index) const; // Returns pointer to recycle bin if lies on given index // or NULL if no recycle bin lies on given index. - FeedsModelRecycleBin *recycleBinForIndex(const QModelIndex &index) const; + RecycleBin *recycleBinForIndex(const QModelIndex &index) const; // Returns feed/category which lies at the specified index or // root item if index is invalid. - FeedsModelRootItem *itemForIndex(const QModelIndex &index) const; + RootItem *itemForIndex(const QModelIndex &index) const; // Returns source QModelIndex on which lies given item. - QModelIndex indexForItem(FeedsModelRootItem *item) const; + QModelIndex indexForItem(RootItem *item) const; bool hasAnyFeedNewMessages(); // Access to root item. - inline FeedsModelRootItem *rootItem() const { + inline RootItem *rootItem() const { return m_rootItem; } @@ -153,12 +153,12 @@ class FeedsModel : public QAbstractItemModel { bool mergeModel(FeedsImportExportModel *model, QString &output_message); // Access to recycle bin. - FeedsModelRecycleBin *recycleBin() const; + RecycleBin *recycleBin() const; public slots: // Feeds operations. - bool markFeedsRead(const QList &feeds, int read); - bool markFeedsDeleted(const QList &feeds, int deleted, bool read_only); + bool markFeedsRead(const QList &feeds, int read); + bool markFeedsDeleted(const QList &feeds, int deleted, bool read_only); // Signals that properties (probably counts) // of ALL items have changed. @@ -172,7 +172,7 @@ class FeedsModel : public QAbstractItemModel { protected: // Returns converted ids of given feeds // which are suitable as IN clause for SQL queries. - QStringList textualFeedIds(const QList &feeds); + QStringList textualFeedIds(const QList &feeds); // Loads feed/categories from the database. void loadFromDatabase(); @@ -186,8 +186,8 @@ class FeedsModel : public QAbstractItemModel { void requireItemValidationAfterDragDrop(const QModelIndex &source_index); private: - FeedsModelRootItem *m_rootItem; - FeedsModelRecycleBin *m_recycleBin; + RootItem *m_rootItem; + RecycleBin *m_recycleBin; QList m_headerData; QList m_tooltipData; QIcon m_countsIcon; diff --git a/src/core/feedsproxymodel.cpp b/src/core/feedsproxymodel.cpp index 2c2ce14e0..3e8d9f5cc 100755 --- a/src/core/feedsproxymodel.cpp +++ b/src/core/feedsproxymodel.cpp @@ -19,9 +19,9 @@ #include "definitions/definitions.h" #include "core/feedsmodel.h" -#include "core/feedsmodelcategory.h" -#include "core/feedsmodelfeed.h" -#include "core/feedsmodelrootitem.h" +#include "core/category.h" +#include "core/feed.h" +#include "core/rootitem.h" FeedsProxyModel::FeedsProxyModel(QObject *parent) @@ -134,8 +134,8 @@ QModelIndexList FeedsProxyModel::match(const QModelIndex &start, int role, const bool FeedsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { if (left.isValid() && right.isValid()) { // Make necessary castings. - FeedsModelRootItem *left_item = m_sourceModel->itemForIndex(left); - FeedsModelRootItem *right_item = m_sourceModel->itemForIndex(right); + RootItem *left_item = m_sourceModel->itemForIndex(left); + RootItem *right_item = m_sourceModel->itemForIndex(right); // NOTE: Here we want to accomplish that ALL // categories are queued one after another and all @@ -154,15 +154,15 @@ bool FeedsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right return QString::localeAwareCompare(left_item->title(), right_item->title()) < 0; } } - else if (left_item->kind() == FeedsModelRootItem::RecycleBin) { + else if (left_item->kind() == RootItem::Bin) { // Left item is recycle bin. Make sure it is "biggest" item if we have selected ascending order. return sortOrder() == Qt::DescendingOrder; } - else if (right_item->kind() == FeedsModelRootItem::RecycleBin) { + else if (right_item->kind() == RootItem::Bin) { // Right item is recycle bin. Make sure it is "smallest" item if we have selected descending order. return sortOrder() == Qt::AscendingOrder; } - else if (left_item->kind() == FeedsModelRootItem::Feed) { + else if (left_item->kind() == RootItem::Feeed) { // Left item is feed, right item is category. return false; } @@ -190,9 +190,9 @@ bool FeedsProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source return false; } - FeedsModelRootItem *item = m_sourceModel->itemForIndex(idx); + RootItem *item = m_sourceModel->itemForIndex(idx); - if (item->kind() == FeedsModelRootItem::RecycleBin) { + if (item->kind() == RootItem::Bin) { // Recycle bin is always displayed. return true; } @@ -205,11 +205,11 @@ bool FeedsProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source } } -FeedsModelRootItem *FeedsProxyModel::selectedItem() const { +RootItem *FeedsProxyModel::selectedItem() const { return m_selectedItem; } -void FeedsProxyModel::setSelectedItem(FeedsModelRootItem *selected_item) { +void FeedsProxyModel::setSelectedItem(RootItem *selected_item) { m_selectedItem = selected_item; } diff --git a/src/core/feedsproxymodel.h b/src/core/feedsproxymodel.h index d43fc74fb..aa000b94b 100755 --- a/src/core/feedsproxymodel.h +++ b/src/core/feedsproxymodel.h @@ -18,7 +18,7 @@ #ifndef FEEDSPROXYMODEL_H #define FEEDSPROXYMODEL_H -#include "feedsmodelrootitem.h" +#include "rootitem.h" #include @@ -46,8 +46,8 @@ class FeedsProxyModel : public QSortFilterProxyModel { bool showUnreadOnly() const; void setShowUnreadOnly(bool show_unread_only); - FeedsModelRootItem *selectedItem() const; - void setSelectedItem(FeedsModelRootItem *selected_item); + RootItem *selectedItem() const; + void setSelectedItem(RootItem *selected_item); public slots: void invalidateFilter(); @@ -61,7 +61,7 @@ class FeedsProxyModel : public QSortFilterProxyModel { // Source model pointer. FeedsModel *m_sourceModel; - FeedsModelRootItem *m_selectedItem; + RootItem *m_selectedItem; bool m_showUnreadOnly; }; diff --git a/src/core/feedsselection.cpp b/src/core/feedsselection.cpp index 435831864..4b7328c1b 100755 --- a/src/core/feedsselection.cpp +++ b/src/core/feedsselection.cpp @@ -17,13 +17,13 @@ #include "core/feedsselection.h" -#include "core/feedsmodelrootitem.h" -#include "core/feedsmodelcategory.h" -#include "core/feedsmodelfeed.h" +#include "core/rootitem.h" +#include "core/category.h" +#include "core/feed.h" #include "definitions/definitions.h" -FeedsSelection::FeedsSelection(FeedsModelRootItem *root_of_selection) : m_selectedItem(root_of_selection) { +FeedsSelection::FeedsSelection(RootItem *root_of_selection) : m_selectedItem(root_of_selection) { } FeedsSelection::FeedsSelection(const FeedsSelection &other) { @@ -39,11 +39,11 @@ FeedsSelection::SelectionMode FeedsSelection::mode() { } switch (m_selectedItem->kind()) { - case FeedsModelRootItem::RecycleBin: + case RootItem::Bin: return FeedsSelection::MessagesFromRecycleBin; - case FeedsModelRootItem::Category: - case FeedsModelRootItem::Feed: + case RootItem::Cattegory: + case RootItem::Feeed: return FeedsSelection::MessagesFromFeeds; default: @@ -51,18 +51,18 @@ FeedsSelection::SelectionMode FeedsSelection::mode() { } } -FeedsModelRootItem *FeedsSelection::selectedItem() const { +RootItem *FeedsSelection::selectedItem() const { return m_selectedItem; } QString FeedsSelection::generateListOfIds() { if (m_selectedItem != NULL && - (m_selectedItem->kind() == FeedsModelRootItem::Feed || m_selectedItem->kind() == FeedsModelRootItem::Category)) { - QList children = m_selectedItem->getRecursiveChildren(); + (m_selectedItem->kind() == RootItem::Feeed || m_selectedItem->kind() == RootItem::Cattegory)) { + QList children = m_selectedItem->getRecursiveChildren(); QStringList stringy_ids; - foreach (FeedsModelRootItem *child, children) { - if (child->kind() == FeedsModelRootItem::Feed) { + foreach (RootItem *child, children) { + if (child->kind() == RootItem::Feeed) { stringy_ids.append(QString::number(child->id())); } } diff --git a/src/core/feedsselection.h b/src/core/feedsselection.h index 4e6e1d5dc..2eb1d27cb 100644 --- a/src/core/feedsselection.h +++ b/src/core/feedsselection.h @@ -22,8 +22,8 @@ #include -class FeedsModelRootItem; -class FeedsModelFeed; +class RootItem; +class Feed; class FeedsSelection { public: @@ -33,16 +33,16 @@ class FeedsSelection { MessagesFromRecycleBin }; - explicit FeedsSelection(FeedsModelRootItem *root_of_selection = NULL); + explicit FeedsSelection(RootItem *root_of_selection = NULL); FeedsSelection(const FeedsSelection &other); virtual ~FeedsSelection(); SelectionMode mode(); - FeedsModelRootItem *selectedItem() const; + RootItem *selectedItem() const; QString generateListOfIds(); private: - FeedsModelRootItem *m_selectedItem; + RootItem *m_selectedItem; }; Q_DECLARE_METATYPE(FeedsSelection::SelectionMode) diff --git a/src/core/feedsmodelrecyclebin.cpp b/src/core/recyclebin.cpp old mode 100755 new mode 100644 similarity index 76% rename from src/core/feedsmodelrecyclebin.cpp rename to src/core/recyclebin.cpp index f6248df5a..df086ff39 --- a/src/core/feedsmodelrecyclebin.cpp +++ b/src/core/recyclebin.cpp @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#include "core/feedsmodelrecyclebin.h" +#include "core/recyclebin.h" #include "miscellaneous/application.h" #include "miscellaneous/iconfactory.h" @@ -23,9 +23,9 @@ #include -FeedsModelRecycleBin::FeedsModelRecycleBin(FeedsModelRootItem *parent) - : FeedsModelRootItem(parent) { - m_kind = FeedsModelRootItem::RecycleBin; +RecycleBin::RecycleBin(RootItem *parent) + : RootItem(parent) { + m_kind = RootItem::Bin; m_icon = qApp->icons()->fromTheme(QSL("folder-recycle-bin")); m_id = ID_RECYCLE_BIN; m_title = tr("Recycle bin"); @@ -35,27 +35,27 @@ FeedsModelRecycleBin::FeedsModelRecycleBin(FeedsModelRootItem *parent) updateCounts(true); } -FeedsModelRecycleBin::~FeedsModelRecycleBin() { - qDebug("Destroying FeedsModelRecycleBin instance."); +RecycleBin::~RecycleBin() { + qDebug("Destroying RecycleBin instance."); } -int FeedsModelRecycleBin::childCount() const { +int RecycleBin::childCount() const { return 0; } -void FeedsModelRecycleBin::appendChild(FeedsModelRootItem *child) { +void RecycleBin::appendChild(RootItem *child) { Q_UNUSED(child) } -int FeedsModelRecycleBin::countOfUnreadMessages() const { +int RecycleBin::countOfUnreadMessages() const { return m_unreadCount; } -int FeedsModelRecycleBin::countOfAllMessages() const { +int RecycleBin::countOfAllMessages() const { return m_totalCount; } -QVariant FeedsModelRecycleBin::data(int column, int role) const { +QVariant RecycleBin::data(int column, int role) const { switch (role) { case Qt::DisplayRole: if (column == FDS_MODEL_TITLE_INDEX) { @@ -108,8 +108,8 @@ QVariant FeedsModelRecycleBin::data(int column, int role) const { } } -bool FeedsModelRecycleBin::empty() { - QSqlDatabase db_handle = qApp->database()->connection(QSL("FeedsModelRecycleBin"), DatabaseFactory::FromSettings); +bool RecycleBin::empty() { + QSqlDatabase db_handle = qApp->database()->connection(QSL("RecycleBin"), DatabaseFactory::FromSettings); if (!db_handle.transaction()) { qWarning("Starting transaction for recycle bin emptying."); @@ -135,8 +135,8 @@ bool FeedsModelRecycleBin::empty() { } } -bool FeedsModelRecycleBin::restore() { - QSqlDatabase db_handle = qApp->database()->connection(QSL("FeedsModelRecycleBin"), DatabaseFactory::FromSettings); +bool RecycleBin::restore() { + QSqlDatabase db_handle = qApp->database()->connection(QSL("RecycleBin"), DatabaseFactory::FromSettings); if (!db_handle.transaction()) { qWarning("Starting transaction for recycle bin restoring."); @@ -162,8 +162,8 @@ bool FeedsModelRecycleBin::restore() { } } -void FeedsModelRecycleBin::updateCounts(bool update_total_count) { - QSqlDatabase database = qApp->database()->connection(QSL("FeedsModelRecycleBin"), DatabaseFactory::FromSettings); +void RecycleBin::updateCounts(bool update_total_count) { + QSqlDatabase database = qApp->database()->connection(QSL("RecycleBin"), DatabaseFactory::FromSettings); QSqlQuery query_all(database); query_all.setForwardOnly(true); diff --git a/src/core/feedsmodelrecyclebin.h b/src/core/recyclebin.h old mode 100755 new mode 100644 similarity index 71% rename from src/core/feedsmodelrecyclebin.h rename to src/core/recyclebin.h index 490dd2149..0ffcebda5 --- a/src/core/feedsmodelrecyclebin.h +++ b/src/core/recyclebin.h @@ -15,23 +15,23 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#ifndef FEEDSMODELRECYCLEBIN_H -#define FEEDSMODELRECYCLEBIN_H +#ifndef RECYCLEBIN_H +#define RECYCLEBIN_H -#include "core/feedsmodelrootitem.h" +#include "core/rootitem.h" #include -class FeedsModelRecycleBin : public FeedsModelRootItem { - Q_DECLARE_TR_FUNCTIONS(FeedsModelRecycleBin) +class RecycleBin : public RootItem { + Q_DECLARE_TR_FUNCTIONS(RecycleBin) public: - explicit FeedsModelRecycleBin(FeedsModelRootItem *parent = NULL); - virtual ~FeedsModelRecycleBin(); + explicit RecycleBin(RootItem *parent = NULL); + virtual ~RecycleBin(); int childCount() const; - void appendChild(FeedsModelRootItem *child); + void appendChild(RootItem *child); int countOfUnreadMessages() const; int countOfAllMessages() const; QVariant data(int column, int role) const; @@ -47,4 +47,4 @@ class FeedsModelRecycleBin : public FeedsModelRootItem { int m_unreadCount; }; -#endif // FEEDSMODELRECYCLEBIN_H +#endif // RECYCLEBIN_H diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/rootitem.cpp old mode 100755 new mode 100644 similarity index 50% rename from src/core/feedsmodelrootitem.cpp rename to src/core/rootitem.cpp index 53276394f..a262b8d96 --- a/src/core/feedsmodelrootitem.cpp +++ b/src/core/rootitem.cpp @@ -15,41 +15,41 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#include "core/feedsmodelrootitem.h" +#include "core/rootitem.h" -#include "core/feedsmodelcategory.h" -#include "core/feedsmodelfeed.h" -#include "core/feedsmodelrecyclebin.h" +#include "core/category.h" +#include "core/feed.h" +#include "core/recyclebin.h" #include "miscellaneous/application.h" #include -FeedsModelRootItem::FeedsModelRootItem(FeedsModelRootItem *parent_item) - : m_kind(FeedsModelRootItem::RootItem), +RootItem::RootItem(RootItem *parent_item) + : m_kind(RootItem::Root), m_id(NO_PARENT_CATEGORY), m_title(QString()), m_description(QString()), m_icon(QIcon()), m_creationDate(QDateTime()), - m_childItems(QList()), + m_childItems(QList()), m_parentItem(parent_item) { setupFonts(); } -FeedsModelRootItem::~FeedsModelRootItem() { +RootItem::~RootItem() { qDeleteAll(m_childItems); } -void FeedsModelRootItem::setupFonts() { +void RootItem::setupFonts() { m_normalFont = Application::font("FeedsView"); m_boldFont = m_normalFont; m_boldFont.setBold(true); } -int FeedsModelRootItem::row() const { +int RootItem::row() const { if (m_parentItem) { - return m_parentItem->m_childItems.indexOf(const_cast(this)); + return m_parentItem->m_childItems.indexOf(const_cast(this)); } else { // This item has no parent. Therefore, its row index is 0. @@ -57,7 +57,7 @@ int FeedsModelRootItem::row() const { } } -QVariant FeedsModelRootItem::data(int column, int role) const { +QVariant RootItem::data(int column, int role) const { Q_UNUSED(column) Q_UNUSED(role) @@ -65,11 +65,11 @@ QVariant FeedsModelRootItem::data(int column, int role) const { return QVariant(); } -int FeedsModelRootItem::countOfAllMessages() const { +int RootItem::countOfAllMessages() const { int total_count = 0; - foreach (FeedsModelRootItem *child_item, m_childItems) { - if (child_item->kind() != FeedsModelRootItem::RecycleBin) { + foreach (RootItem *child_item, m_childItems) { + if (child_item->kind() != RootItem::Bin) { total_count += child_item->countOfAllMessages(); } } @@ -77,29 +77,29 @@ int FeedsModelRootItem::countOfAllMessages() const { return total_count; } -QList FeedsModelRootItem::getRecursiveChildren() { - QList children; +QList RootItem::getRecursiveChildren() { + QList children; - if (kind() == FeedsModelRootItem::Feed) { + if (kind() == RootItem::Feeed) { // Root itself is a FEED. children.append(this); } else { // Root itself is a CATEGORY or ROOT item. - QList traversable_items; + QList traversable_items; traversable_items.append(this); // Iterate all nested categories. while (!traversable_items.isEmpty()) { - FeedsModelRootItem *active_category = traversable_items.takeFirst(); + RootItem *active_category = traversable_items.takeFirst(); - foreach (FeedsModelRootItem *child, active_category->childItems()) { - if (child->kind() == FeedsModelRootItem::Feed) { + foreach (RootItem *child, active_category->childItems()) { + if (child->kind() == RootItem::Feeed) { // This child is feed. children.append(child); } - else if (child->kind() == FeedsModelRootItem::Category) { + else if (child->kind() == RootItem::Cattegory) { // This child is category, add its child feeds too. traversable_items.append(child); } @@ -110,27 +110,27 @@ QList FeedsModelRootItem::getRecursiveChildren() { return children; } -bool FeedsModelRootItem::removeChild(FeedsModelRootItem *child) { +bool RootItem::removeChild(RootItem *child) { return m_childItems.removeOne(child); } -FeedsModelRecycleBin *FeedsModelRootItem::toRecycleBin() { - return static_cast(this); +RecycleBin *RootItem::toRecycleBin() { + return static_cast(this); } -FeedsModelCategory *FeedsModelRootItem::toCategory() { - return static_cast(this); +Category *RootItem::toCategory() { + return static_cast(this); } -FeedsModelFeed *FeedsModelRootItem::toFeed() { - return static_cast(this); +Feed *RootItem::toFeed() { + return static_cast(this); } -FeedsModelRootItem *FeedsModelRootItem::child(FeedsModelRootItem::Kind kind_of_child, const QString &identifier) { - foreach (FeedsModelRootItem *child, childItems()) { +RootItem *RootItem::child(RootItem::Kind kind_of_child, const QString &identifier) { + foreach (RootItem *child, childItems()) { if (child->kind() == kind_of_child) { - if ((kind_of_child == Category && child->title() == identifier) || - (kind_of_child == Feed && child->toFeed()->url() == identifier)) { + if ((kind_of_child == Cattegory && child->title() == identifier) || + (kind_of_child == Feeed && child->toFeed()->url() == identifier)) { return child; } } @@ -139,11 +139,11 @@ FeedsModelRootItem *FeedsModelRootItem::child(FeedsModelRootItem::Kind kind_of_c return NULL; } -int FeedsModelRootItem::countOfUnreadMessages() const { +int RootItem::countOfUnreadMessages() const { int total_count = 0; - foreach (FeedsModelRootItem *child_item, m_childItems) { - if (child_item->kind() != FeedsModelRootItem::RecycleBin) { + foreach (RootItem *child_item, m_childItems) { + if (child_item->kind() != RootItem::Bin) { total_count += child_item->countOfUnreadMessages(); } } @@ -151,7 +151,7 @@ int FeedsModelRootItem::countOfUnreadMessages() const { return total_count; } -bool FeedsModelRootItem::removeChild(int index) { +bool RootItem::removeChild(int index) { if (index >= 0 && index < m_childItems.size()) { m_childItems.removeAt(index); return true; @@ -161,11 +161,11 @@ bool FeedsModelRootItem::removeChild(int index) { } } -bool FeedsModelRootItem::isEqual(FeedsModelRootItem *lhs, FeedsModelRootItem *rhs) { +bool RootItem::isEqual(RootItem *lhs, RootItem *rhs) { return (lhs->kind() == rhs->kind()) && (lhs->id() == rhs->id()); } -bool FeedsModelRootItem::lessThan(FeedsModelRootItem *lhs, FeedsModelRootItem *rhs) { +bool RootItem::lessThan(RootItem *lhs, RootItem *rhs) { if (lhs->kind() == rhs->kind()) { return lhs->id() < rhs->id(); } diff --git a/src/core/feedsmodelrootitem.h b/src/core/rootitem.h old mode 100755 new mode 100644 similarity index 70% rename from src/core/feedsmodelrootitem.h rename to src/core/rootitem.h index 9a5e1e01d..7ee0e49ef --- a/src/core/feedsmodelrootitem.h +++ b/src/core/rootitem.h @@ -15,55 +15,55 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#ifndef FEEDSMODELROOTITEM_H -#define FEEDSMODELROOTITEM_H +#ifndef ROOTITEM_H +#define ROOTITEM_H #include #include #include -class FeedsModelRecycleBin; -class FeedsModelCategory; -class FeedsModelFeed; +class RecycleBin; +class Category; +class Feed; // Represents ROOT item of FeedsModel. // NOTE: This class is derived to add functionality for // all other non-root items of FeedsModel. -class FeedsModelRootItem { +class RootItem { public: // Describes the kind of the item. enum Kind { - RootItem = 1001, - RecycleBin = 1002, - Feed = 1003, - Category = 1004 + Root = 1001, + Bin = 1002, + Feeed = 1003, + Cattegory = 1004 }; // Constructors and destructors. - explicit FeedsModelRootItem(FeedsModelRootItem *parent_item = NULL); - virtual ~FeedsModelRootItem(); + explicit RootItem(RootItem *parent_item = NULL); + virtual ~RootItem(); // Basic operations. - inline virtual FeedsModelRootItem *parent() const { + inline virtual RootItem *parent() const { return m_parentItem; } - inline virtual void setParent(FeedsModelRootItem *parent_item) { + inline virtual void setParent(RootItem *parent_item) { m_parentItem = parent_item; } - inline virtual FeedsModelRootItem *child(int row) { + inline virtual RootItem *child(int row) { return m_childItems.value(row); } - virtual FeedsModelRootItem *child(FeedsModelRootItem::Kind kind_of_child, const QString &identifier); + virtual RootItem *child(RootItem::Kind kind_of_child, const QString &identifier); inline virtual int childCount() const { return m_childItems.size(); } - inline virtual void appendChild(FeedsModelRootItem *child) { + inline virtual void appendChild(RootItem *child) { m_childItems.append(child); child->setParent(this); } @@ -87,20 +87,20 @@ class FeedsModelRootItem { } // Access to children. - inline QList childItems() const { + inline QList childItems() const { return m_childItems; } // Checks whether THIS object is child (direct or indirect) // of the given root. - bool isChildOf(FeedsModelRootItem *root) { + bool isChildOf(RootItem *root) { if (root == NULL) { return false; } - FeedsModelRootItem *this_item = this; + RootItem *this_item = this; - while (this_item->kind() != FeedsModelRootItem::RootItem) { + while (this_item->kind() != RootItem::Root) { if (root->childItems().contains(this_item)) { return true; } @@ -112,7 +112,7 @@ class FeedsModelRootItem { return false; } - bool isParentOf(FeedsModelRootItem *child) { + bool isParentOf(RootItem *child) { if (child == NULL) { return false; } @@ -127,12 +127,12 @@ class FeedsModelRootItem { m_childItems.clear(); } - QList getRecursiveChildren(); + QList getRecursiveChildren(); // Removes particular child at given index. // NOTE: Child is NOT freed from the memory. bool removeChild(int index); - bool removeChild(FeedsModelRootItem *child); + bool removeChild(RootItem *child); inline Kind kind() const { return m_kind; @@ -182,13 +182,13 @@ class FeedsModelRootItem { } // Converters - FeedsModelRecycleBin *toRecycleBin(); - FeedsModelCategory *toCategory(); - FeedsModelFeed *toFeed(); + RecycleBin *toRecycleBin(); + Category *toCategory(); + Feed *toFeed(); // Compares two model items. - static bool isEqual(FeedsModelRootItem *lhs, FeedsModelRootItem *rhs); - static bool lessThan(FeedsModelRootItem *lhs, FeedsModelRootItem *rhs); + static bool isEqual(RootItem *lhs, RootItem *rhs); + static bool lessThan(RootItem *lhs, RootItem *rhs); protected: void setupFonts(); @@ -203,8 +203,8 @@ class FeedsModelRootItem { QFont m_normalFont; QFont m_boldFont; - QList m_childItems; - FeedsModelRootItem *m_parentItem; + QList m_childItems; + RootItem *m_parentItem; }; -#endif // FEEDMODELROOTITEM_H +#endif // ROOTITEM_H diff --git a/src/gui/dialogs/formcategorydetails.cpp b/src/gui/dialogs/formcategorydetails.cpp index 5d2e2c6a9..bac6ad7ec 100755 --- a/src/gui/dialogs/formcategorydetails.cpp +++ b/src/gui/dialogs/formcategorydetails.cpp @@ -18,8 +18,8 @@ #include "gui/dialogs/formcategorydetails.h" #include "definitions/definitions.h" -#include "core/feedsmodelrootitem.h" -#include "core/feedsmodelcategory.h" +#include "core/rootitem.h" +#include "core/category.h" #include "core/feedsmodel.h" #include "miscellaneous/iconfactory.h" #include "gui/feedsview.h" @@ -67,7 +67,7 @@ void FormCategoryDetails::createConnections() { connect(m_actionUseDefaultIcon, SIGNAL(triggered()), this, SLOT(onUseDefaultIcon())); } -void FormCategoryDetails::setEditableCategory(FeedsModelCategory *editable_category) { +void FormCategoryDetails::setEditableCategory(Category *editable_category) { m_editableCategory = editable_category; m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) editable_category->parent()))); @@ -76,7 +76,7 @@ void FormCategoryDetails::setEditableCategory(FeedsModelCategory *editable_categ m_ui->m_btnIcon->setIcon(editable_category->icon()); } -int FormCategoryDetails::exec(FeedsModelCategory *input_category, FeedsModelRootItem *parent_to_select) { +int FormCategoryDetails::exec(Category *input_category, RootItem *parent_to_select) { // Load categories. loadCategories(m_feedsModel->allCategories().values(), m_feedsModel->rootItem(), input_category); @@ -90,10 +90,10 @@ int FormCategoryDetails::exec(FeedsModelCategory *input_category, FeedsModelRoot // Load parent from suggested item. if (parent_to_select != NULL) { - if (parent_to_select->kind() == FeedsModelRootItem::Category) { + if (parent_to_select->kind() == RootItem::Cattegory) { m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select))); } - else if (parent_to_select->kind() == FeedsModelRootItem::Feed) { + else if (parent_to_select->kind() == RootItem::Feeed) { int target_item = m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select->parent())); if (target_item >= 0) { @@ -113,8 +113,8 @@ int FormCategoryDetails::exec(FeedsModelCategory *input_category, FeedsModelRoot } void FormCategoryDetails::apply() { - FeedsModelRootItem *parent = static_cast(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value()); - FeedsModelCategory *new_category = new FeedsModelCategory(); + RootItem *parent = static_cast(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value()); + Category *new_category = new Category(); new_category->setTitle(m_ui->m_txtTitle->lineEdit()->text()); new_category->setCreationDate(QDateTime::currentDateTime()); @@ -241,14 +241,14 @@ void FormCategoryDetails::initialize() { m_ui->m_txtTitle->lineEdit()->setFocus(Qt::TabFocusReason); } -void FormCategoryDetails::loadCategories(const QList categories, - FeedsModelRootItem *root_item, - FeedsModelCategory *input_category) { +void FormCategoryDetails::loadCategories(const QList categories, + RootItem *root_item, + Category *input_category) { m_ui->m_cmbParentCategory->addItem(root_item->icon(), root_item->title(), QVariant::fromValue((void*) root_item)); - foreach (FeedsModelCategory *category, categories) { + foreach (Category *category, categories) { if (input_category != NULL && (category == input_category || category->isChildOf(input_category))) { // This category cannot be selected as the new // parent for currently edited category, so diff --git a/src/gui/dialogs/formcategorydetails.h b/src/gui/dialogs/formcategorydetails.h index 371ec785d..67abd4196 100644 --- a/src/gui/dialogs/formcategorydetails.h +++ b/src/gui/dialogs/formcategorydetails.h @@ -27,10 +27,10 @@ namespace Ui { class FormCategoryDetails; } -class FeedsModelCategory; -class FeedsModelCategory; +class Category; +class Category; class FeedsModel; -class FeedsModelRootItem; +class RootItem; class QMenu; class QAction; @@ -44,7 +44,7 @@ class FormCategoryDetails : public QDialog { public slots: // Executes add/edit standard category dialog. - int exec(FeedsModelCategory *input_category, FeedsModelRootItem *parent_to_select); + int exec(Category *input_category, RootItem *parent_to_select); protected slots: // Applies changes. @@ -64,7 +64,7 @@ class FormCategoryDetails : public QDialog { void createConnections(); // Sets the category which will be edited. - void setEditableCategory(FeedsModelCategory *editable_category); + void setEditableCategory(Category *editable_category); // Initializes the dialog. void initialize(); @@ -72,11 +72,11 @@ class FormCategoryDetails : public QDialog { // Loads categories into the dialog + give root "category" // and make sure that no childs of input category (including) // input category are loaded. - void loadCategories(const QList categories, FeedsModelRootItem *root_item, FeedsModelCategory *input_category); + void loadCategories(const QList categories, RootItem *root_item, Category *input_category); private: Ui::FormCategoryDetails *m_ui; - FeedsModelCategory *m_editableCategory; + Category *m_editableCategory; FeedsModel *m_feedsModel; QMenu *m_iconMenu; diff --git a/src/gui/dialogs/formfeeddetails.cpp b/src/gui/dialogs/formfeeddetails.cpp index 41a3054c7..f872fbab4 100755 --- a/src/gui/dialogs/formfeeddetails.cpp +++ b/src/gui/dialogs/formfeeddetails.cpp @@ -19,9 +19,9 @@ #include "definitions/definitions.h" #include "core/feedsmodel.h" -#include "core/feedsmodelrootitem.h" -#include "core/feedsmodelcategory.h" -#include "core/feedsmodelfeed.h" +#include "core/rootitem.h" +#include "core/category.h" +#include "core/feed.h" #include "miscellaneous/textfactory.h" #include "miscellaneous/iconfactory.h" #include "network-web/networkfactory.h" @@ -58,7 +58,7 @@ FormFeedDetails::~FormFeedDetails() { delete m_ui; } -int FormFeedDetails::exec(FeedsModelFeed *input_feed, FeedsModelRootItem *parent_to_select) { +int FormFeedDetails::exec(Feed *input_feed, RootItem *parent_to_select) { // Load categories. loadCategories(m_feedsModel->allCategories().values(), m_feedsModel->rootItem()); @@ -77,10 +77,10 @@ int FormFeedDetails::exec(FeedsModelFeed *input_feed, FeedsModelRootItem *parent } if (parent_to_select != NULL) { - if (parent_to_select->kind() == FeedsModelRootItem::Category) { + if (parent_to_select->kind() == RootItem::Cattegory) { m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select))); } - else if (parent_to_select->kind() == FeedsModelRootItem::Feed) { + else if (parent_to_select->kind() == RootItem::Feeed) { int target_item = m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select->parent())); if (target_item >= 0) { @@ -168,15 +168,15 @@ void FormFeedDetails::onAuthenticationSwitched() { } void FormFeedDetails::onAutoUpdateTypeChanged(int new_index) { - FeedsModelFeed::AutoUpdateType auto_update_type = static_cast(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt()); + Feed::AutoUpdateType auto_update_type = static_cast(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt()); switch (auto_update_type) { - case FeedsModelFeed::DontAutoUpdate: - case FeedsModelFeed::DefaultAutoUpdate: + case Feed::DontAutoUpdate: + case Feed::DefaultAutoUpdate: m_ui->m_spinAutoUpdateInterval->setEnabled(false); break; - case FeedsModelFeed::SpecificAutoUpdate: + case Feed::SpecificAutoUpdate: default: m_ui->m_spinAutoUpdateInterval->setEnabled(true); } @@ -219,9 +219,9 @@ void FormFeedDetails::onUseDefaultIcon() { } void FormFeedDetails::apply() { - FeedsModelRootItem *parent = static_cast(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value()); - FeedsModelFeed::Type type = static_cast(m_ui->m_cmbType->itemData(m_ui->m_cmbType->currentIndex()).value()); - FeedsModelFeed *new_feed = new FeedsModelFeed(); + RootItem *parent = static_cast(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value()); + Feed::Type type = static_cast(m_ui->m_cmbType->itemData(m_ui->m_cmbType->currentIndex()).value()); + Feed *new_feed = new Feed(); // Setup data for new_feed. new_feed->setTitle(m_ui->m_txtTitle->lineEdit()->text()); @@ -234,7 +234,7 @@ void FormFeedDetails::apply() { new_feed->setPasswordProtected(m_ui->m_gbAuthentication->isChecked()); new_feed->setUsername(m_ui->m_txtUsername->lineEdit()->text()); new_feed->setPassword(m_ui->m_txtPassword->lineEdit()->text()); - new_feed->setAutoUpdateType(static_cast(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt())); + new_feed->setAutoUpdateType(static_cast(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt())); new_feed->setAutoUpdateInitialInterval(m_ui->m_spinAutoUpdateInterval->value()); new_feed->setParent(parent); @@ -263,7 +263,7 @@ void FormFeedDetails::apply() { } void FormFeedDetails::guessFeed() { - QPair result = FeedsModelFeed::guessFeed(m_ui->m_txtUrl->lineEdit()->text(), + QPair result = Feed::guessFeed(m_ui->m_txtUrl->lineEdit()->text(), m_ui->m_txtUsername->lineEdit()->text(), m_ui->m_txtPassword->lineEdit()->text()); @@ -307,7 +307,7 @@ void FormFeedDetails::guessFeed() { } void FormFeedDetails::guessIconOnly() { - QPair result = FeedsModelFeed::guessFeed(m_ui->m_txtUrl->lineEdit()->text(), + QPair result = Feed::guessFeed(m_ui->m_txtUrl->lineEdit()->text(), m_ui->m_txtUsername->lineEdit()->text(), m_ui->m_txtPassword->lineEdit()->text()); @@ -356,7 +356,7 @@ void FormFeedDetails::createConnections() { connect(m_actionUseDefaultIcon, SIGNAL(triggered()), this, SLOT(onUseDefaultIcon())); } -void FormFeedDetails::setEditableFeed(FeedsModelFeed *editable_feed) { +void FormFeedDetails::setEditableFeed(Feed *editable_feed) { m_editableFeed = editable_feed; m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) editable_feed->parent()))); @@ -405,10 +405,10 @@ void FormFeedDetails::initialize() { #endif // Add standard feed types. - m_ui->m_cmbType->addItem(FeedsModelFeed::typeToString(FeedsModelFeed::Atom10), QVariant::fromValue((int) FeedsModelFeed::Atom10)); - m_ui->m_cmbType->addItem(FeedsModelFeed::typeToString(FeedsModelFeed::Rdf), QVariant::fromValue((int) FeedsModelFeed::Rdf)); - m_ui->m_cmbType->addItem(FeedsModelFeed::typeToString(FeedsModelFeed::Rss0X), QVariant::fromValue((int) FeedsModelFeed::Rss0X)); - m_ui->m_cmbType->addItem(FeedsModelFeed::typeToString(FeedsModelFeed::Rss2X), QVariant::fromValue((int) FeedsModelFeed::Rss2X)); + m_ui->m_cmbType->addItem(Feed::typeToString(Feed::Atom10), QVariant::fromValue((int) Feed::Atom10)); + m_ui->m_cmbType->addItem(Feed::typeToString(Feed::Rdf), QVariant::fromValue((int) Feed::Rdf)); + m_ui->m_cmbType->addItem(Feed::typeToString(Feed::Rss0X), QVariant::fromValue((int) Feed::Rss0X)); + m_ui->m_cmbType->addItem(Feed::typeToString(Feed::Rss2X), QVariant::fromValue((int) Feed::Rss2X)); // Load available encodings. QList encodings = QTextCodec::availableCodecs(); @@ -449,9 +449,9 @@ void FormFeedDetails::initialize() { // Setup auto-update options. m_ui->m_spinAutoUpdateInterval->setValue(DEFAULT_AUTO_UPDATE_INTERVAL); - m_ui->m_cmbAutoUpdateType->addItem(tr("Auto-update using global interval"), QVariant::fromValue((int) FeedsModelFeed::DefaultAutoUpdate)); - m_ui->m_cmbAutoUpdateType->addItem(tr("Auto-update every"), QVariant::fromValue((int) FeedsModelFeed::SpecificAutoUpdate)); - m_ui->m_cmbAutoUpdateType->addItem(tr("Do not auto-update at all"), QVariant::fromValue((int) FeedsModelFeed::DontAutoUpdate)); + m_ui->m_cmbAutoUpdateType->addItem(tr("Auto-update using global interval"), QVariant::fromValue((int) Feed::DefaultAutoUpdate)); + m_ui->m_cmbAutoUpdateType->addItem(tr("Auto-update every"), QVariant::fromValue((int) Feed::SpecificAutoUpdate)); + m_ui->m_cmbAutoUpdateType->addItem(tr("Do not auto-update at all"), QVariant::fromValue((int) Feed::DontAutoUpdate)); // Set tab order. setTabOrder(m_ui->m_cmbParentCategory, m_ui->m_cmbType); @@ -475,13 +475,13 @@ void FormFeedDetails::initialize() { m_ui->m_txtUrl->lineEdit()->setFocus(Qt::TabFocusReason); } -void FormFeedDetails::loadCategories(const QList categories, - FeedsModelRootItem *root_item) { +void FormFeedDetails::loadCategories(const QList categories, + RootItem *root_item) { m_ui->m_cmbParentCategory->addItem(root_item->icon(), root_item->title(), QVariant::fromValue((void*) root_item)); - foreach (FeedsModelCategory *category, categories) { + foreach (Category *category, categories) { m_ui->m_cmbParentCategory->addItem(category->data(FDS_MODEL_TITLE_INDEX, Qt::DecorationRole).value(), category->title(), diff --git a/src/gui/dialogs/formfeeddetails.h b/src/gui/dialogs/formfeeddetails.h index b0ff5434a..550b0bcb9 100644 --- a/src/gui/dialogs/formfeeddetails.h +++ b/src/gui/dialogs/formfeeddetails.h @@ -28,9 +28,9 @@ namespace Ui { } class FeedsModel; -class FeedsModelFeed; -class FeedsModelCategory; -class FeedsModelRootItem; +class Feed; +class Category; +class RootItem; class FormFeedDetails : public QDialog { Q_OBJECT @@ -42,7 +42,7 @@ class FormFeedDetails : public QDialog { public slots: // Executes add/edit standard feed dialog. - int exec(FeedsModelFeed *input_feed, FeedsModelRootItem *parent_to_select); + int exec(Feed *input_feed, RootItem *parent_to_select); protected slots: // Applies changes. @@ -72,18 +72,18 @@ class FormFeedDetails : public QDialog { void createConnections(); // Sets the feed which will be edited. - void setEditableFeed(FeedsModelFeed *editable_feed); + void setEditableFeed(Feed *editable_feed); // Initializes the dialog. void initialize(); // Loads categories into the dialog from the model. - void loadCategories(const QList categories, - FeedsModelRootItem *root_item); + void loadCategories(const QList categories, + RootItem *root_item); private: Ui::FormFeedDetails *m_ui; - FeedsModelFeed *m_editableFeed; + Feed *m_editableFeed; FeedsModel *m_feedsModel; QMenu *m_iconMenu; diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 2da799db3..8f0e739ba 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -25,7 +25,7 @@ #include "miscellaneous/databasecleaner.h" #include "core/messagesproxymodel.h" #include "core/feeddownloader.h" -#include "core/feedsmodelfeed.h" +#include "core/feed.h" #include "core/feedsselection.h" #include "core/feedsimportexportmodel.h" #include "network-web/webbrowser.h" @@ -252,7 +252,7 @@ void FeedMessageViewer::onFeedUpdatesStarted() { qApp->mainForm()->statusBar()->showProgressFeeds(0, tr("Feed update started")); } -void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, int current, int total) { +void FeedMessageViewer::onFeedUpdatesProgress(Feed *feed, int current, int total) { // Some feed got updated. m_feedsView->updateCountsOfParticularFeed(feed, true); qApp->mainForm()->statusBar()->showProgressFeeds((current * 100.0) / total, @@ -360,7 +360,7 @@ void FeedMessageViewer::createConnections() { form_main->m_ui->m_tabWidget, SLOT(addBrowserWithMessages(QList))); // Downloader connections. - connect(m_feedsView, SIGNAL(feedsUpdateRequested(QList)), this, SLOT(updateFeeds(QList))); + connect(m_feedsView, SIGNAL(feedsUpdateRequested(QList)), this, SLOT(updateFeeds(QList))); // Toolbar forwardings. connect(form_main->m_ui->m_actionCleanupDatabase, @@ -535,7 +535,7 @@ void FeedMessageViewer::refreshVisualProperties() { m_toolBarMessages->setToolButtonStyle(button_style); } -void FeedMessageViewer::updateFeeds(QList feeds) { +void FeedMessageViewer::updateFeeds(QList feeds) { if (!qApp->feedUpdateLock()->tryLock()) { qApp->showGuiMessage(tr("Cannot update all items"), tr("You cannot update all items because another another critical operation is ongoing."), @@ -548,14 +548,14 @@ void FeedMessageViewer::updateFeeds(QList feeds) { m_feedDownloaderThread = new QThread(); // Downloader setup. - qRegisterMetaType >("QList"); + qRegisterMetaType >("QList"); m_feedDownloader->moveToThread(m_feedDownloaderThread); - connect(this, SIGNAL(feedsUpdateRequested(QList)), m_feedDownloader, SLOT(updateFeeds(QList))); + connect(this, SIGNAL(feedsUpdateRequested(QList)), m_feedDownloader, SLOT(updateFeeds(QList))); connect(m_feedDownloaderThread, SIGNAL(finished()), m_feedDownloaderThread, SLOT(deleteLater())); connect(m_feedDownloader, SIGNAL(finished(FeedDownloadResults)), this, SLOT(onFeedUpdatesFinished(FeedDownloadResults))); connect(m_feedDownloader, SIGNAL(started()), this, SLOT(onFeedUpdatesStarted())); - connect(m_feedDownloader, SIGNAL(progress(FeedsModelFeed*,int,int)), this, SLOT(onFeedUpdatesProgress(FeedsModelFeed*,int,int))); + connect(m_feedDownloader, SIGNAL(progress(Feed*,int,int)), this, SLOT(onFeedUpdatesProgress(Feed*,int,int))); // Connections are made, start the feed downloader thread. m_feedDownloaderThread->start(); diff --git a/src/gui/feedmessageviewer.h b/src/gui/feedmessageviewer.h index 8f6067eaf..539f4cb35 100644 --- a/src/gui/feedmessageviewer.h +++ b/src/gui/feedmessageviewer.h @@ -30,7 +30,7 @@ class MessagesToolBar; class FeedsToolBar; class FeedsView; class DatabaseCleaner; -class FeedsModelFeed; +class Feed; class QToolBar; class QSplitter; class QProgressBar; @@ -103,7 +103,7 @@ class FeedMessageViewer : public TabContent { // Reloads some changeable visual settings. void refreshVisualProperties(); - void updateFeeds(QList feeds); + void updateFeeds(QList feeds); private slots: // Updates counts of messages for example in tray icon. @@ -111,7 +111,7 @@ class FeedMessageViewer : public TabContent { // Reacts on feed updates. void onFeedUpdatesStarted(); - void onFeedUpdatesProgress(FeedsModelFeed *feed, int current, int total); + void onFeedUpdatesProgress(Feed *feed, int current, int total); void onFeedUpdatesFinished(FeedDownloadResults results); // Switches visibility of feed list and related @@ -135,7 +135,7 @@ class FeedMessageViewer : public TabContent { signals: // Emitted if user/application requested updating of some feeds. - void feedsUpdateRequested(const QList feeds); + void feedsUpdateRequested(const QList feeds); private: bool m_toolBarsEnabled; diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index b909ec681..a9f24d2e0 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -18,13 +18,13 @@ #include "gui/feedsview.h" #include "definitions/definitions.h" -#include "core/feedsmodelfeed.h" +#include "core/feed.h" #include "core/feedsmodel.h" #include "core/feedsproxymodel.h" -#include "core/feedsmodelrootitem.h" -#include "core/feedsmodelcategory.h" -#include "core/feedsmodelrecyclebin.h" -#include "core/feedsmodelfeed.h" +#include "core/rootitem.h" +#include "core/category.h" +#include "core/recyclebin.h" +#include "core/feed.h" #include "miscellaneous/systemfactory.h" #include "miscellaneous/mutex.h" #include "gui/systemtrayicon.h" @@ -103,43 +103,43 @@ void FeedsView::updateAutoUpdateStatus() { } } -QList FeedsView::selectedFeeds() const { +QList FeedsView::selectedFeeds() const { QModelIndex current_index = currentIndex(); if (current_index.isValid()) { return m_sourceModel->feedsForIndex(m_proxyModel->mapToSource(current_index)); } else { - return QList(); + return QList(); } } -QList FeedsView::allFeeds() const { +QList FeedsView::allFeeds() const { return m_sourceModel->allFeeds(); } -FeedsModelRootItem *FeedsView::selectedItem() const { +RootItem *FeedsView::selectedItem() const { QModelIndexList selected_rows = selectionModel()->selectedRows(); if (selected_rows.isEmpty()) { return NULL; } - FeedsModelRootItem *selected_item = m_sourceModel->itemForIndex(m_proxyModel->mapToSource(selected_rows.at(0))); + RootItem *selected_item = m_sourceModel->itemForIndex(m_proxyModel->mapToSource(selected_rows.at(0))); return selected_item == m_sourceModel->rootItem() ? NULL : selected_item; } -FeedsModelCategory *FeedsView::selectedCategory() const { +Category *FeedsView::selectedCategory() const { QModelIndex current_mapped = m_proxyModel->mapToSource(currentIndex()); return m_sourceModel->categoryForIndex(current_mapped); } -FeedsModelFeed *FeedsView::selectedFeed() const { +Feed *FeedsView::selectedFeed() const { QModelIndex current_mapped = m_proxyModel->mapToSource(currentIndex()); return m_sourceModel->feedForIndex(current_mapped); } -FeedsModelRecycleBin *FeedsView::selectedRecycleBin() const{ +RecycleBin *FeedsView::selectedRecycleBin() const{ QModelIndex current_mapped = m_proxyModel->mapToSource(currentIndex()); return m_sourceModel->recycleBinForIndex(current_mapped); } @@ -148,7 +148,7 @@ void FeedsView::saveExpandedStates() { Settings *settings = qApp->settings(); // Iterate all categories and save their expand statuses. - foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) { + foreach (Category *category, sourceModel()->allCategories().values()) { settings->setValue(GROUP(Categories), QString::number(category->id()), isExpanded(model()->mapFromSource(sourceModel()->indexForItem(category)))); @@ -159,7 +159,7 @@ void FeedsView::loadExpandedStates() { Settings *settings = qApp->settings(); // Iterate all categories and save their expand statuses. - foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) { + foreach (Category *category, sourceModel()->allCategories().values()) { setExpanded(model()->mapFromSource(sourceModel()->indexForItem(category)), settings->value(GROUP(Categories), QString::number(category->id()), true).toBool()); } @@ -207,7 +207,7 @@ void FeedsView::executeNextAutoUpdate() { // Pass needed interval data and lets the model decide which feeds // should be updated in this pass. - QList feeds_for_update = m_sourceModel->feedsForScheduledUpdate(m_globalAutoUpdateEnabled && + QList feeds_for_update = m_sourceModel->feedsForScheduledUpdate(m_globalAutoUpdateEnabled && m_globalAutoUpdateRemainingInterval == 0); if (feeds_for_update.isEmpty()) { @@ -266,7 +266,7 @@ void FeedsView::addNewCategory() { qApp->feedUpdateLock()->unlock(); } -void FeedsView::editCategory(FeedsModelCategory *category) { +void FeedsView::editCategory(Category *category) { QPointer form_pointer = new FormCategoryDetails(m_sourceModel, this); form_pointer.data()->exec(category, NULL); @@ -295,7 +295,7 @@ void FeedsView::addNewFeed() { qApp->feedUpdateLock()->unlock(); } -void FeedsView::editFeed(FeedsModelFeed *feed) { +void FeedsView::editFeed(Feed *feed) { QPointer form_pointer = new FormFeedDetails(m_sourceModel, this); form_pointer.data()->exec(feed, NULL); @@ -354,8 +354,8 @@ void FeedsView::editSelectedItem() { return; } - FeedsModelCategory *category; - FeedsModelFeed *feed; + Category *category; + Feed *feed; if ((category = selectedCategory()) != NULL) { editCategory(category); @@ -472,7 +472,7 @@ void FeedsView::restoreRecycleBin() { } void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) { - foreach (FeedsModelFeed *feed, selectedFeeds()) { + foreach (Feed *feed, selectedFeeds()) { feed->updateCounts(update_total_too); } @@ -498,7 +498,7 @@ void FeedsView::updateCountsOfRecycleBin(bool update_total_too) { } void FeedsView::updateCountsOfAllFeeds(bool update_total_too) { - foreach (FeedsModelFeed *feed, allFeeds()) { + foreach (Feed *feed, allFeeds()) { feed->updateCounts(update_total_too); } @@ -512,7 +512,7 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) { notifyWithCounts(); } -void FeedsView::updateCountsOfParticularFeed(FeedsModelFeed *feed, bool update_total_too) { +void FeedsView::updateCountsOfParticularFeed(Feed *feed, bool update_total_too) { QModelIndex index = m_sourceModel->indexForItem(feed); if (index.isValid()) { @@ -620,7 +620,7 @@ void FeedsView::setupAppearance() { } void FeedsView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) { - FeedsModelRootItem *selected_item = selectedItem(); + RootItem *selected_item = selectedItem(); m_proxyModel->setSelectedItem(selected_item); QTreeView::selectionChanged(selected, deselected); @@ -641,9 +641,9 @@ void FeedsView::contextMenuEvent(QContextMenuEvent *event) { if (clicked_index.isValid()) { QModelIndex mapped_index = model()->mapToSource(clicked_index); - FeedsModelRootItem *clicked_item = sourceModel()->itemForIndex(mapped_index); + RootItem *clicked_item = sourceModel()->itemForIndex(mapped_index); - if (clicked_item->kind() == FeedsModelRootItem::Category || clicked_item->kind() == FeedsModelRootItem::Feed) { + if (clicked_item->kind() == RootItem::Cattegory || clicked_item->kind() == RootItem::Feeed) { // Display context menu for categories. if (m_contextMenuCategoriesFeeds == NULL) { // Context menu is not initialized, initialize. @@ -652,7 +652,7 @@ void FeedsView::contextMenuEvent(QContextMenuEvent *event) { m_contextMenuCategoriesFeeds->exec(event->globalPos()); } - else if (clicked_item->kind() == FeedsModelRootItem::RecycleBin) { + else if (clicked_item->kind() == RootItem::Bin) { // Display context menu for recycle bin. if (m_contextMenuRecycleBin == NULL) { initializeContextMenuRecycleBin(); diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index dcb2f579c..edbfca314 100755 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -28,8 +28,8 @@ class FeedsProxyModel; -class FeedsModelFeed; -class FeedsModelCategory; +class Feed; +class Category; class QTimer; class FeedsView : public QTreeView { @@ -60,15 +60,15 @@ class FeedsView : public QTreeView { // Returns list of selected/all feeds. // NOTE: This is recursive method which returns all descendants. - QList selectedFeeds() const; - QList allFeeds() const; + QList selectedFeeds() const; + QList allFeeds() const; // Returns pointers to selected feed/category if they are really // selected. - FeedsModelRootItem *selectedItem() const; - FeedsModelCategory *selectedCategory() const; - FeedsModelFeed *selectedFeed() const; - FeedsModelRecycleBin *selectedRecycleBin() const; + RootItem *selectedItem() const; + Category *selectedCategory() const; + Feed *selectedFeed() const; + RecycleBin *selectedRecycleBin() const; // Saves/loads expand states of all nodes (feeds/categories) of the list to/from settings. void saveExpandedStates(); @@ -112,11 +112,11 @@ class FeedsView : public QTreeView { // Standard category manipulators. void addNewCategory(); - void editCategory(FeedsModelCategory *category); + void editCategory(Category *category); // Standard feed manipulators. void addNewFeed(); - void editFeed(FeedsModelFeed *feed); + void editFeed(Feed *feed); // Is called when counts of messages are changed externally, // typically from message view. @@ -132,7 +132,7 @@ class FeedsView : public QTreeView { void updateCountsOfAllFeeds(bool update_total_too); // Reloads counts for particular feed. - void updateCountsOfParticularFeed(FeedsModelFeed *feed, bool update_total_too); + void updateCountsOfParticularFeed(Feed *feed, bool update_total_too); // Notifies other components about messages // counts. @@ -175,7 +175,7 @@ class FeedsView : public QTreeView { signals: // Emitted if user/application requested updating of some feeds. - void feedsUpdateRequested(const QList feeds); + void feedsUpdateRequested(const QList feeds); // Emitted if counts of messages are changed. void messageCountsChanged(int unread_messages, int total_messages, bool any_feed_has_unread_messages);