mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-03 10:47:47 +01:00
Cleaned service menu, now service menus use context menus only.
This commit is contained in:
parent
85a7f104cf
commit
8ae9c97248
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -71,7 +71,7 @@ void DynamicShortcutsWidget::populate(QList<QAction*> 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
|
||||
|
@ -129,6 +129,7 @@ QList<QAction*> 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.
|
||||
|
@ -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.
|
||||
|
@ -131,6 +131,7 @@
|
||||
<property name="title">
|
||||
<string>Add &new item</string>
|
||||
</property>
|
||||
<addaction name="m_actionServiceAdd"/>
|
||||
</widget>
|
||||
<addaction name="m_actionUpdateAllItems"/>
|
||||
<addaction name="m_actionUpdateSelectedItems"/>
|
||||
@ -171,14 +172,6 @@
|
||||
<addaction name="m_actionDeleteSelectedMessages"/>
|
||||
<addaction name="m_actionRestoreSelectedMessages"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="m_menuServices">
|
||||
<property name="title">
|
||||
<string>&Services</string>
|
||||
</property>
|
||||
<addaction name="m_actionServiceAdd"/>
|
||||
<addaction name="m_actionServiceEdit"/>
|
||||
<addaction name="m_actionServiceDelete"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="m_menuRecycleBin">
|
||||
<property name="title">
|
||||
<string>&Recycle bin</string>
|
||||
@ -188,7 +181,6 @@
|
||||
</widget>
|
||||
<addaction name="m_menuFile"/>
|
||||
<addaction name="m_menuView"/>
|
||||
<addaction name="m_menuServices"/>
|
||||
<addaction name="m_menuFeeds"/>
|
||||
<addaction name="m_menuMessages"/>
|
||||
<addaction name="m_menuRecycleBin"/>
|
||||
@ -717,28 +709,6 @@
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionServiceDelete">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Delete selected service account</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionServiceEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Edit selected service account</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionRestoreSelectedMessages">
|
||||
<property name="text">
|
||||
<string>&Restore selected messages</string>
|
||||
|
@ -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);
|
||||
|
@ -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()),
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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()));
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ class ServiceRoot : public RootItem {
|
||||
// NOTE: Caller does NOT take ownership of created menu!
|
||||
virtual QList<QAction*> serviceMenu() = 0;
|
||||
|
||||
// Access to recycle bin of this account if there is any.
|
||||
virtual RecycleBin *recycleBin() = 0;
|
||||
|
||||
// Start/stop services.
|
||||
|
@ -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<StandardCategory*>(child)->removeItself();
|
||||
|
@ -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) {
|
||||
|
@ -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<QAction*> StandardServiceRoot::serviceMenu() {
|
||||
return m_serviceMenu;
|
||||
}
|
||||
|
||||
QList<QAction*> 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"));
|
||||
|
@ -59,6 +59,8 @@ class StandardServiceRoot : public ServiceRoot {
|
||||
// Return menu to be shown in "Services -> service" menu.
|
||||
QList<QAction*> serviceMenu();
|
||||
|
||||
QList<QAction*> contextMenuActions();
|
||||
|
||||
// Message stuff.
|
||||
bool loadMessagesForItem(RootItem *item, QSqlTableModel *model);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user