diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index b5916b72d..502e5fb17 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -339,17 +339,31 @@ void FeedsModel::reloadCountsOfWholeModel() { void FeedsModel::removeItem(const QModelIndex &index) { if (index.isValid()) { - QModelIndex parent_index = index.parent(); RootItem *deleting_item = itemForIndex(index); + QModelIndex parent_index = index.parent(); RootItem *parent_item = deleting_item->parent(); - // Item was persistently removed. - // Remove it from the model. beginRemoveRows(parent_index, index.row(), index.row()); parent_item->removeChild(deleting_item); endRemoveRows(); - delete deleting_item; + deleting_item->deleteLater(); + notifyWithCounts(); + } +} + +void FeedsModel::removeItem(RootItem *deleting_item) { + if (deleting_item != NULL) { + QModelIndex index = indexForItem(deleting_item); + QModelIndex parent_index = index.parent(); + RootItem *parent_item = deleting_item->parent(); + + beginRemoveRows(parent_index, index.row(), index.row()); + parent_item->removeChild(deleting_item); + endRemoveRows(); + + deleting_item->deleteLater(); + notifyWithCounts(); } } diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index c1cfff0ca..08b205d96 100755 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -67,6 +67,7 @@ class FeedsModel : public QAbstractItemModel { // Removes item with given index. // NOTE: Also deletes item from memory. void removeItem(const QModelIndex &index); + void removeItem(RootItem *deleting_item); // Checks if new parent node is different from one used by original node. // If it is, then it reassigns original_node to new parent. diff --git a/src/dynamic-shortcuts/dynamicshortcutswidget.cpp b/src/dynamic-shortcuts/dynamicshortcutswidget.cpp index 12ad5fac8..73356fa42 100755 --- a/src/dynamic-shortcuts/dynamicshortcutswidget.cpp +++ b/src/dynamic-shortcuts/dynamicshortcutswidget.cpp @@ -71,7 +71,7 @@ void DynamicShortcutsWidget::populate(QList actions) { int row_id = 0; - // TODO: Maybe separate actions into "categories". Each category will start with label. + // FIXME: Maybe separate actions into "categories". Each category will start with label. // I will assign each QAaction a property called "category" with some enum value. // Like: // File, FeedsCategories, Messages, Tools, WebBrowser, Help diff --git a/src/gui/dialogs/formmain.cpp b/src/gui/dialogs/formmain.cpp index 765bcaaf2..349794e44 100755 --- a/src/gui/dialogs/formmain.cpp +++ b/src/gui/dialogs/formmain.cpp @@ -129,6 +129,7 @@ QList FormMain::allActions() { actions << m_ui->m_actionUpdateSelectedItems; actions << m_ui->m_actionEditSelectedItem; actions << m_ui->m_actionDeleteSelectedItem; + actions << m_ui->m_actionServiceAdd; actions << m_ui->m_actionViewSelectedItemsNewspaperMode; actions << m_ui->m_actionSelectNextItem; actions << m_ui->m_actionSelectPreviousItem; @@ -197,12 +198,15 @@ void FormMain::updateAddItemMenu() { m_ui->m_menuAddItem->addMenu(root_menu); } -} -void FormMain::updateServicesMenu() { - m_ui->m_menuServices->clear(); + if (m_ui->m_menuAddItem->actions().size() > 0) { + m_ui->m_menuAddItem->addSeparator(); + } - foreach (ServiceRoot *activated_root, tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->serviceRoots()) { + m_ui->m_menuAddItem->addAction(m_ui->m_actionServiceAdd); + + /* + * foreach (ServiceRoot *activated_root, tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->serviceRoots()) { QMenu *root_menu = new QMenu(activated_root->title(), m_ui->m_menuServices); root_menu->setIcon(activated_root->icon()); root_menu->setToolTip(activated_root->description()); @@ -221,22 +225,14 @@ void FormMain::updateServicesMenu() { } m_ui->m_menuServices->addMenu(root_menu); - } - - if (!m_ui->m_menuServices->isEmpty()) { - m_ui->m_menuServices->addSeparator(); - } - - m_ui->m_menuServices->addAction(m_ui->m_actionServiceAdd); - m_ui->m_menuServices->addAction(m_ui->m_actionServiceEdit); - m_ui->m_menuServices->addAction(m_ui->m_actionServiceDelete); + }*/ } void FormMain::updateRecycleBinMenu() { m_ui->m_menuRecycleBin->clear(); foreach (ServiceRoot *activated_root, tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->serviceRoots()) { - QMenu *root_menu = new QMenu(activated_root->title(), m_ui->m_menuServices); + QMenu *root_menu = new QMenu(activated_root->title(), m_ui->m_menuRecycleBin); root_menu->setIcon(activated_root->icon()); root_menu->setToolTip(activated_root->description()); @@ -442,7 +438,6 @@ void FormMain::createConnections() { connect(m_ui->m_actionFullscreen, SIGNAL(toggled(bool)), m_statusBar->fullscreenSwitcher(), SLOT(setChecked(bool))); connect(m_ui->m_menuAddItem, SIGNAL(aboutToShow()), this, SLOT(updateAddItemMenu())); - connect(m_ui->m_menuServices, SIGNAL(aboutToShow()), this, SLOT(updateServicesMenu())); connect(m_ui->m_menuRecycleBin, SIGNAL(aboutToShow()), this, SLOT(updateRecycleBinMenu())); // Menu "File" connections. diff --git a/src/gui/dialogs/formmain.h b/src/gui/dialogs/formmain.h index 8060e136e..bf17615d3 100755 --- a/src/gui/dialogs/formmain.h +++ b/src/gui/dialogs/formmain.h @@ -78,7 +78,6 @@ class FormMain : public QMainWindow { private slots: void updateAddItemMenu(); - void updateServicesMenu(); void updateRecycleBinMenu(); // Loads web browser menu if user selects to change tabs. diff --git a/src/gui/dialogs/formmain.ui b/src/gui/dialogs/formmain.ui index 085eb8677..8a15ea446 100755 --- a/src/gui/dialogs/formmain.ui +++ b/src/gui/dialogs/formmain.ui @@ -131,6 +131,7 @@ Add &new item + @@ -171,14 +172,6 @@ - - - &Services - - - - - &Recycle bin @@ -188,7 +181,6 @@ - @@ -717,28 +709,6 @@ - - - false - - - &Delete selected service account - - - - - - - - false - - - &Edit selected service account - - - - - &Restore selected messages diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 270cfb782..cbe2d9fac 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -202,8 +202,6 @@ void FeedMessageViewer::updateFeedButtonsAvailability() { bool service_selected = anything_selected && selected_item->kind() == RootItemKind::ServiceRoot; FormMain *form_main = qApp->mainForm(); - form_main->m_ui->m_actionServiceEdit->setEnabled(!critical_action_running && service_selected); - form_main->m_ui->m_actionServiceDelete->setEnabled(!critical_action_running && service_selected); form_main->m_ui->m_actionBackupDatabaseSettings->setEnabled(!critical_action_running); form_main->m_ui->m_actionCleanupDatabase->setEnabled(!critical_action_running); form_main->m_ui->m_actionClearSelectedItems->setEnabled(feed_selected || category_selected || service_selected); diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 2ff36f599..e2fc28122 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -239,15 +239,6 @@ void FeedsView::deleteSelectedItem() { qApp->mainForm(), true); } - else { - // Item is gone, cleared from database. We can clear it from model now. - // NOTE: Cleared from memory here too. - // TODO: možná toto přesunout taky to metody deleteViaGui - // a delete selected_item jen volat tady, editViaGui taky obstará všechno, - // ale tam je to zas komplexnější. - m_sourceModel->removeItem(m_proxyModel->mapToSource(current_index)); - m_sourceModel->notifyWithCounts(); - } } else { qApp->showGuiMessage(tr("Cannot delete \"%1\"").arg(selected_item->title()), diff --git a/src/gui/systemtrayicon.cpp b/src/gui/systemtrayicon.cpp index 63bfc9ea9..514f061c4 100755 --- a/src/gui/systemtrayicon.cpp +++ b/src/gui/systemtrayicon.cpp @@ -124,7 +124,7 @@ void SystemTrayIcon::setNumber(int number, bool any_new_message) { QPixmap background(m_plainPixmap); QPainter tray_painter; - // TODO: Here draw different background instead of different color of number. + // FIXME: Here draw different background instead of different color of number. tray_painter.begin(&background); tray_painter.setPen(any_new_message ? Qt::blue : Qt::black); tray_painter.setRenderHint(QPainter::SmoothPixmapTransform, true); diff --git a/src/gui/tabwidget.cpp b/src/gui/tabwidget.cpp index 0c82fd4b0..2c0831e54 100755 --- a/src/gui/tabwidget.cpp +++ b/src/gui/tabwidget.cpp @@ -69,7 +69,6 @@ void TabWidget::openMainMenu() { m_menuMain = new QMenu(tr("Main menu"), this); m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuFile); m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuView); - m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuServices); m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuFeeds); m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuMessages); m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuWebBrowser); diff --git a/src/network-web/webbrowsernetworkaccessmanager.cpp b/src/network-web/webbrowsernetworkaccessmanager.cpp index 0adf4ff1a..b8e433c24 100755 --- a/src/network-web/webbrowsernetworkaccessmanager.cpp +++ b/src/network-web/webbrowsernetworkaccessmanager.cpp @@ -39,7 +39,7 @@ WebBrowserNetworkAccessManager::~WebBrowserNetworkAccessManager() { void WebBrowserNetworkAccessManager::onAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator) { Q_UNUSED(authenticator); - // TODO: Support authentication for web pages. + // FIXME: Support authentication for web pages. qDebug("URL '%s' requested authentication but username/password is not available.", qPrintable(reply->url().toString())); } diff --git a/src/services/abstract/serviceroot.h b/src/services/abstract/serviceroot.h index 1e05f29d8..34d30bd61 100755 --- a/src/services/abstract/serviceroot.h +++ b/src/services/abstract/serviceroot.h @@ -53,6 +53,7 @@ class ServiceRoot : public RootItem { // NOTE: Caller does NOT take ownership of created menu! virtual QList serviceMenu() = 0; + // Access to recycle bin of this account if there is any. virtual RecycleBin *recycleBin() = 0; // Start/stop services. diff --git a/src/services/standard/standardcategory.cpp b/src/services/standard/standardcategory.cpp index 83075bc30..2ef830d2a 100755 --- a/src/services/standard/standardcategory.cpp +++ b/src/services/standard/standardcategory.cpp @@ -99,7 +99,13 @@ bool StandardCategory::editViaGui() { } bool StandardCategory::deleteViaGui() { - return removeItself(); + if (removeItself()) { + serviceRoot()->feedsModel()->removeItem(this); + return true; + } + else { + return false; + } } bool StandardCategory::markAsReadUnread(ReadStatus status) { @@ -113,7 +119,8 @@ bool StandardCategory::cleanMessages(bool clean_read_only) { bool StandardCategory::removeItself() { bool children_removed = true; - // Remove all child items (feeds, categories.) + // Remove all child items (feeds and categories) + // from the database. foreach (RootItem *child, childItems()) { if (child->kind() == RootItemKind::Category) { children_removed &= static_cast(child)->removeItself(); diff --git a/src/services/standard/standardfeed.cpp b/src/services/standard/standardfeed.cpp index bafdfecee..066562f3d 100755 --- a/src/services/standard/standardfeed.cpp +++ b/src/services/standard/standardfeed.cpp @@ -115,7 +115,13 @@ bool StandardFeed::editViaGui() { } bool StandardFeed::deleteViaGui() { - return removeItself(); + if (removeItself()) { + serviceRoot()->feedsModel()->removeItem(this); + return true; + } + else { + return false; + } } bool StandardFeed::markAsReadUnread(ReadStatus status) { diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index 18b065af5..236a4b0ab 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -88,8 +88,6 @@ void StandardServiceRoot::start() { try { model.importAsOPML20(IOFactory::readTextFile(file_to_load)); model.checkAllItems(); - - // TODO: Expand all items here? mergeImportExportModel(&model, output_msg); } catch (ApplicationException &ex) { @@ -593,6 +591,10 @@ QList StandardServiceRoot::serviceMenu() { return m_serviceMenu; } +QList StandardServiceRoot::contextMenuActions() { + return serviceMenu(); +} + bool StandardServiceRoot::loadMessagesForItem(RootItem *item, QSqlTableModel *model) { if (item->kind() == RootItemKind::Bin) { model->setFilter(QSL("is_deleted = 1 AND is_pdeleted = 0")); diff --git a/src/services/standard/standardserviceroot.h b/src/services/standard/standardserviceroot.h index bede330c3..aa65fc15c 100755 --- a/src/services/standard/standardserviceroot.h +++ b/src/services/standard/standardserviceroot.h @@ -59,6 +59,8 @@ class StandardServiceRoot : public ServiceRoot { // Return menu to be shown in "Services -> service" menu. QList serviceMenu(); + QList contextMenuActions(); + // Message stuff. bool loadMessagesForItem(RootItem *item, QSqlTableModel *model);