Refactoring, now almost everything probably works.

This commit is contained in:
Martin Rotter 2016-08-15 13:53:38 +02:00
parent 9df9a51df0
commit efd4ab8014
9 changed files with 168 additions and 157 deletions

View File

@ -31,7 +31,7 @@ FormDatabaseCleanup::FormDatabaseCleanup(QWidget *parent) : QDialog(parent), m_u
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
setWindowIcon(qApp->icons()->fromTheme(QSL("edit-clear")));
connect(m_ui->m_spinDays, SIGNAL(valueChanged(int)), this, SLOT(updateDaysSuffix(int)));
connect(m_ui->m_spinDays, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &FormDatabaseCleanup::updateDaysSuffix);
m_ui->m_spinDays->setValue(DEFAULT_DAYS_TO_DELETE_MSG);
m_ui->m_lblResult->setStatus(WidgetWithStatus::Information, tr("I am ready."), tr("I am ready."));
loadDatabaseInfo();

View File

@ -34,6 +34,8 @@
#include "gui/messagesview.h"
#include "gui/feedmessageviewer.h"
#include "gui/plaintoolbutton.h"
#include "gui/feedstoolbar.h"
#include "gui/messagestoolbar.h"
#include "gui/dialogs/formabout.h"
#include "gui/dialogs/formsettings.h"
#include "gui/dialogs/formupdate.h"
@ -63,22 +65,27 @@ FormMain::FormMain(QWidget *parent, Qt::WindowFlags f)
m_ui->setupUi(this);
qApp->setMainForm(this);
// Add these actions to the list of actions of the main window.
// This allows to use actions via shortcuts
// even if main menu is not visible.
addActions(allActions());
m_statusBar = new StatusBar(this);
setStatusBar(m_statusBar);
// Prepare main window and tabs.
prepareMenus();
// Prepare tabs.
//m_ui->m_tabWidget->initializeTabs();
tabWidget()->feedMessageViewer()->feedsToolBar()->loadChangeableActions();
tabWidget()->feedMessageViewer()->messagesToolBar()->loadChangeableActions();
// Establish connections.
createConnections();
// Add these actions to the list of actions of the main window.
// This allows to use actions via shortcuts
// even if main menu is not visible.
addActions(allActions());
// Prepare tabs.
m_ui->m_tabWidget->initializeTabs();
updateMessageButtonsAvailability();
updateFeedButtonsAvailability();
// Setup some appearance of the window.
setupIcons();
@ -323,8 +330,12 @@ void FormMain::updateAccountsMenu() {
m_ui->m_menuAccounts->addAction(m_ui->m_actionServiceDelete);
}
void FormMain::onFeedUpdatesFinished(FeedDownloadResults results) {
statusBar()->clearProgressFeeds();
}
void FormMain::onFeedUpdatesStarted() {
m_ui->m_actionStopRunningItemsUpdate->setEnabled(false);
m_ui->m_actionStopRunningItemsUpdate->setEnabled(true);
statusBar()->showProgressFeeds(0, tr("Feed update started"));
}
@ -334,8 +345,51 @@ void FormMain::onFeedUpdatesProgress(const Feed *feed, int current, int total) {
tr("Updated feed '%1'").arg(feed->title()));
}
void FormMain::onFeedUpdatesFinished(FeedDownloadResults results) {
statusBar()->clearProgressFeeds();
void FormMain::updateMessageButtonsAvailability() {
const bool one_message_selected = tabWidget()->feedMessageViewer()->messagesView()->selectionModel()->selectedRows().size() == 1;
const bool atleast_one_message_selected = !tabWidget()->feedMessageViewer()->messagesView()->selectionModel()->selectedRows().isEmpty();
const bool bin_loaded = tabWidget()->feedMessageViewer()->messagesView()->sourceModel()->loadedItem() != nullptr && tabWidget()->feedMessageViewer()->messagesView()->sourceModel()->loadedItem()->kind() == RootItemKind::Bin;
m_ui->m_actionDeleteSelectedMessages->setEnabled(atleast_one_message_selected);
m_ui->m_actionRestoreSelectedMessages->setEnabled(atleast_one_message_selected && bin_loaded);
m_ui->m_actionMarkSelectedMessagesAsRead->setEnabled(atleast_one_message_selected);
m_ui->m_actionMarkSelectedMessagesAsUnread->setEnabled(atleast_one_message_selected);
m_ui->m_actionOpenSelectedMessagesInternally->setEnabled(atleast_one_message_selected);
m_ui->m_actionOpenSelectedSourceArticlesExternally->setEnabled(atleast_one_message_selected);
m_ui->m_actionSendMessageViaEmail->setEnabled(one_message_selected);
m_ui->m_actionSwitchImportanceOfSelectedMessages->setEnabled(atleast_one_message_selected);
}
void FormMain::updateFeedButtonsAvailability() {
const bool is_update_running = qApp->feedReader()->isFeedUpdateRunning();
const bool critical_action_running = qApp->feedUpdateLock()->isLocked();
const RootItem *selected_item = tabWidget()->feedMessageViewer()->feedsView()->selectedItem();
const bool anything_selected = selected_item != nullptr;
const bool feed_selected = anything_selected && selected_item->kind() == RootItemKind::Feed;
const bool category_selected = anything_selected && selected_item->kind() == RootItemKind::Category;
const bool service_selected = anything_selected && selected_item->kind() == RootItemKind::ServiceRoot;
m_ui->m_actionStopRunningItemsUpdate->setEnabled(is_update_running);
m_ui->m_actionBackupDatabaseSettings->setEnabled(!critical_action_running);
m_ui->m_actionCleanupDatabase->setEnabled(!critical_action_running);
m_ui->m_actionClearSelectedItems->setEnabled(anything_selected);
m_ui->m_actionDeleteSelectedItem->setEnabled(!critical_action_running && anything_selected);
m_ui->m_actionEditSelectedItem->setEnabled(!critical_action_running && anything_selected);
m_ui->m_actionMarkSelectedItemsAsRead->setEnabled(anything_selected);
m_ui->m_actionMarkSelectedItemsAsUnread->setEnabled(anything_selected);
m_ui->m_actionUpdateAllItems->setEnabled(!critical_action_running);
m_ui->m_actionUpdateSelectedItems->setEnabled(!critical_action_running && (feed_selected || category_selected || service_selected));
m_ui->m_actionViewSelectedItemsNewspaperMode->setEnabled(anything_selected);
m_ui->m_actionExpandCollapseItem->setEnabled(anything_selected);
m_ui->m_actionServiceDelete->setEnabled(service_selected);
m_ui->m_actionServiceEdit->setEnabled(service_selected);
m_ui->m_actionAddFeedIntoSelectedAccount->setEnabled(anything_selected);
m_ui->m_actionAddCategoryIntoSelectedAccount->setEnabled(anything_selected);
m_ui->m_menuAddItem->setEnabled(!critical_action_running);
m_ui->m_menuAccounts->setEnabled(!critical_action_running);
m_ui->m_menuRecycleBin->setEnabled(!critical_action_running);
}
void FormMain::switchVisibility(bool force_hide) {
@ -543,6 +597,84 @@ void FormMain::createConnections() {
connect(m_ui->m_actionTabsCloseAllExceptCurrent, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::closeAllTabsExceptCurrent);
connect(m_ui->m_actionTabsCloseAll, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::closeAllTabs);
connect(m_ui->m_actionTabNewWebBrowser, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::addEmptyBrowser);
connect(tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::itemSelected, this, &FormMain::updateFeedButtonsAvailability);
connect(qApp->feedUpdateLock(), &Mutex::locked, this, &FormMain::updateFeedButtonsAvailability);
connect(qApp->feedUpdateLock(), &Mutex::unlocked, this, &FormMain::updateFeedButtonsAvailability);
connect(qApp->feedReader(), &FeedReader::feedUpdatesStarted, this, &FormMain::onFeedUpdatesStarted);
connect(qApp->feedReader(), &FeedReader::feedUpdatesProgress, this, &FormMain::onFeedUpdatesProgress);
connect(qApp->feedReader(), &FeedReader::feedUpdatesFinished, this, &FormMain::onFeedUpdatesFinished);
// Toolbar forwardings.
connect(m_ui->m_actionAddFeedIntoSelectedAccount, SIGNAL(triggered()),
tabWidget()->feedMessageViewer()->feedsView(), SLOT(addFeedIntoSelectedAccount()));
connect(m_ui->m_actionAddCategoryIntoSelectedAccount, SIGNAL(triggered()),
tabWidget()->feedMessageViewer()->feedsView(), SLOT(addCategoryIntoSelectedAccount()));
connect(m_ui->m_actionSwitchImportanceOfSelectedMessages,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->messagesView(), SLOT(switchSelectedMessagesImportance()));
connect(m_ui->m_actionDeleteSelectedMessages,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->messagesView(), SLOT(deleteSelectedMessages()));
connect(m_ui->m_actionMarkSelectedMessagesAsRead,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->messagesView(), SLOT(markSelectedMessagesRead()));
connect(m_ui->m_actionMarkSelectedMessagesAsUnread,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->messagesView(), SLOT(markSelectedMessagesUnread()));
connect(m_ui->m_actionOpenSelectedSourceArticlesExternally,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->messagesView(), SLOT(openSelectedSourceMessagesExternally()));
connect(m_ui->m_actionOpenSelectedMessagesInternally,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->messagesView(), SLOT(openSelectedMessagesInternally()));
connect(m_ui->m_actionSendMessageViaEmail,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->messagesView(), SLOT(sendSelectedMessageViaEmail()));
connect(m_ui->m_actionMarkAllItemsRead,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(markAllItemsRead()));
connect(m_ui->m_actionMarkSelectedItemsAsRead,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(markSelectedItemRead()));
connect(m_ui->m_actionExpandCollapseItem,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(expandCollapseCurrentItem()));
connect(m_ui->m_actionMarkSelectedItemsAsUnread,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(markSelectedItemUnread()));
connect(m_ui->m_actionClearSelectedItems,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(clearSelectedFeeds()));
connect(m_ui->m_actionClearAllItems,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(clearAllFeeds()));
connect(m_ui->m_actionUpdateSelectedItems,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(updateSelectedItems()));
connect(m_ui->m_actionUpdateAllItems,
SIGNAL(triggered()), qApp->feedReader(), SLOT(updateAllFeeds()));
connect(m_ui->m_actionStopRunningItemsUpdate,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView()->sourceModel(), SLOT(stopRunningFeedUpdate()));
connect(m_ui->m_actionEditSelectedItem,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(editSelectedItem()));
connect(m_ui->m_actionViewSelectedItemsNewspaperMode,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(openSelectedItemsInNewspaperMode()));
connect(m_ui->m_actionDeleteSelectedItem,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(deleteSelectedItem()));
connect(m_ui->m_actionSwitchFeedsList,
SIGNAL(triggered()), this, SLOT(switchFeedComponentVisibility()));
connect(m_ui->m_actionSelectNextItem,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(selectNextItem()));
connect(m_ui->m_actionSwitchToolBars,
SIGNAL(toggled(bool)), this, SLOT(setToolBarsEnabled(bool)));
connect(m_ui->m_actionSwitchListHeaders,
SIGNAL(toggled(bool)), this, SLOT(setListHeadersEnabled(bool)));
connect(m_ui->m_actionSelectPreviousItem,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->feedsView(), SLOT(selectPreviousItem()));
connect(m_ui->m_actionSelectNextMessage,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->messagesView(), SLOT(selectNextItem()));
connect(m_ui->m_actionSelectNextUnreadMessage,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->messagesView(), SLOT(selectNextUnreadItem()));
connect(m_ui->m_actionSelectPreviousMessage,
SIGNAL(triggered()), tabWidget()->feedMessageViewer()->messagesView(), SLOT(selectPreviousItem()));
connect(m_ui->m_actionSwitchMessageListOrientation, SIGNAL(triggered()),
this, SLOT(switchMessageSplitterOrientation()));
connect(m_ui->m_actionShowOnlyUnreadItems, SIGNAL(toggled(bool)),
this, SLOT(toggleShowOnlyUnreadFeeds()));
connect(m_ui->m_actionRestoreSelectedMessages, SIGNAL(triggered()),
tabWidget()->feedMessageViewer()->messagesView(), SLOT(restoreSelectedMessages()));
connect(m_ui->m_actionRestoreAllRecycleBins, SIGNAL(triggered()),
tabWidget()->feedMessageViewer()->feedsView()->sourceModel(), SLOT(restoreAllBins()));
connect(m_ui->m_actionEmptyAllRecycleBins, SIGNAL(triggered()),
tabWidget()->feedMessageViewer()->feedsView()->sourceModel(), SLOT(emptyAllBins()));
}
void FormMain::backupDatabaseSettings() {

View File

@ -78,6 +78,9 @@ class FormMain : public QMainWindow {
void updateRecycleBinMenu();
void updateAccountsMenu();
void updateMessageButtonsAvailability();
void updateFeedButtonsAvailability();
void onFeedUpdatesStarted();
void onFeedUpdatesProgress(const Feed *feed, int current, int total);
void onFeedUpdatesFinished(FeedDownloadResults results);

View File

@ -192,60 +192,7 @@ void FeedMessageViewer::toggleShowOnlyUnreadFeeds() {
}
}
void FeedMessageViewer::updateMessageButtonsAvailability() {
const bool one_message_selected = m_messagesView->selectionModel()->selectedRows().size() == 1;
const bool atleast_one_message_selected = !m_messagesView->selectionModel()->selectedRows().isEmpty();
const bool bin_loaded = m_messagesView->sourceModel()->loadedItem() != nullptr && m_messagesView->sourceModel()->loadedItem()->kind() == RootItemKind::Bin;
const FormMain *form_main = qApp->mainForm();
form_main->m_ui->m_actionDeleteSelectedMessages->setEnabled(atleast_one_message_selected);
form_main->m_ui->m_actionRestoreSelectedMessages->setEnabled(atleast_one_message_selected && bin_loaded);
form_main->m_ui->m_actionMarkSelectedMessagesAsRead->setEnabled(atleast_one_message_selected);
form_main->m_ui->m_actionMarkSelectedMessagesAsUnread->setEnabled(atleast_one_message_selected);
form_main->m_ui->m_actionOpenSelectedMessagesInternally->setEnabled(atleast_one_message_selected);
form_main->m_ui->m_actionOpenSelectedSourceArticlesExternally->setEnabled(atleast_one_message_selected);
form_main->m_ui->m_actionSendMessageViaEmail->setEnabled(one_message_selected);
form_main->m_ui->m_actionSwitchImportanceOfSelectedMessages->setEnabled(atleast_one_message_selected);
}
void FeedMessageViewer::updateFeedButtonsAvailability() {
const bool is_update_running = qApp->feedReader()->isFeedUpdateRunning();
const bool critical_action_running = qApp->feedUpdateLock()->isLocked();
const RootItem *selected_item = feedsView()->selectedItem();
const bool anything_selected = selected_item != nullptr;
const bool feed_selected = anything_selected && selected_item->kind() == RootItemKind::Feed;
const bool category_selected = anything_selected && selected_item->kind() == RootItemKind::Category;
const bool service_selected = anything_selected && selected_item->kind() == RootItemKind::ServiceRoot;
const FormMain *form_main = qApp->mainForm();
// TODO: přesunou do form main.
form_main->m_ui->m_actionStopRunningItemsUpdate->setEnabled(is_update_running);
form_main->m_ui->m_actionBackupDatabaseSettings->setEnabled(!critical_action_running);
form_main->m_ui->m_actionCleanupDatabase->setEnabled(!critical_action_running);
form_main->m_ui->m_actionClearSelectedItems->setEnabled(anything_selected);
form_main->m_ui->m_actionDeleteSelectedItem->setEnabled(!critical_action_running && anything_selected);
form_main->m_ui->m_actionEditSelectedItem->setEnabled(!critical_action_running && anything_selected);
form_main->m_ui->m_actionMarkSelectedItemsAsRead->setEnabled(anything_selected);
form_main->m_ui->m_actionMarkSelectedItemsAsUnread->setEnabled(anything_selected);
form_main->m_ui->m_actionUpdateAllItems->setEnabled(!critical_action_running);
form_main->m_ui->m_actionUpdateSelectedItems->setEnabled(!critical_action_running && (feed_selected || category_selected || service_selected));
form_main->m_ui->m_actionViewSelectedItemsNewspaperMode->setEnabled(anything_selected);
form_main->m_ui->m_actionExpandCollapseItem->setEnabled(anything_selected);
form_main->m_ui->m_actionServiceDelete->setEnabled(service_selected);
form_main->m_ui->m_actionServiceEdit->setEnabled(service_selected);
form_main->m_ui->m_actionAddFeedIntoSelectedAccount->setEnabled(anything_selected);
form_main->m_ui->m_actionAddCategoryIntoSelectedAccount->setEnabled(anything_selected);
form_main->m_ui->m_menuAddItem->setEnabled(!critical_action_running);
form_main->m_ui->m_menuAccounts->setEnabled(!critical_action_running);
form_main->m_ui->m_menuRecycleBin->setEnabled(!critical_action_running);
}
void FeedMessageViewer::createConnections() {
const FormMain *form_main = qApp->mainForm();
// Filtering & searching.
connect(m_toolBarMessages, SIGNAL(messageSearchPatternChanged(QString)), m_messagesView, SLOT(searchMessages(QString)));
connect(m_toolBarMessages, SIGNAL(messageFilterChanged(MessagesModel::MessageHighlighter)), m_messagesView, SLOT(filterMessages(MessagesModel::MessageHighlighter)));
@ -259,10 +206,6 @@ void FeedMessageViewer::createConnections() {
m_messagesView->sourceModel(), SLOT(setMessageReadById(int,RootItem::ReadStatus)));
connect(m_messagesBrowser, SIGNAL(markMessageImportant(int,RootItem::Importance)),
m_messagesView->sourceModel(), SLOT(setMessageImportantById(int,RootItem::Importance)));
connect(m_feedsView, SIGNAL(itemSelected(RootItem*)), this, SLOT(updateFeedButtonsAvailability()));
connect(qApp->feedUpdateLock(), SIGNAL(locked()), this, SLOT(updateFeedButtonsAvailability()));
connect(qApp->feedUpdateLock(), SIGNAL(unlocked()), this, SLOT(updateFeedButtonsAvailability()));
// If user selects feeds, load their messages.
connect(m_feedsView, SIGNAL(itemSelected(RootItem*)), m_messagesView, SLOT(loadItem(RootItem*)));
@ -272,83 +215,6 @@ void FeedMessageViewer::createConnections() {
connect(m_feedsView->sourceModel(), SIGNAL(reloadMessageListRequested(bool)),
m_messagesView, SLOT(reloadSelections(bool)));
connect(m_feedsView->sourceModel(), SIGNAL(feedsUpdateFinished()), this, SLOT(onFeedsUpdateFinished()));
connect(m_feedsView->sourceModel(), SIGNAL(feedsUpdateStarted()), this, SLOT(onFeedsUpdateStarted()));
// Message openers.
connect(m_messagesView, SIGNAL(openMessagesInNewspaperView(RootItem*,QList<Message>)),
qApp->mainForm()->tabWidget(), SLOT(addNewspaperView(RootItem*,QList<Message>)));
connect(m_feedsView, SIGNAL(openMessagesInNewspaperView(RootItem*,QList<Message>)),
qApp->mainForm()->tabWidget(), SLOT(addNewspaperView(RootItem*,QList<Message>)));
// Toolbar forwardings.
connect(form_main->m_ui->m_actionAddFeedIntoSelectedAccount, SIGNAL(triggered()),
m_feedsView, SLOT(addFeedIntoSelectedAccount()));
connect(form_main->m_ui->m_actionAddCategoryIntoSelectedAccount, SIGNAL(triggered()),
m_feedsView, SLOT(addCategoryIntoSelectedAccount()));
connect(form_main->m_ui->m_actionSwitchImportanceOfSelectedMessages,
SIGNAL(triggered()), m_messagesView, SLOT(switchSelectedMessagesImportance()));
connect(form_main->m_ui->m_actionDeleteSelectedMessages,
SIGNAL(triggered()), m_messagesView, SLOT(deleteSelectedMessages()));
connect(form_main->m_ui->m_actionMarkSelectedMessagesAsRead,
SIGNAL(triggered()), m_messagesView, SLOT(markSelectedMessagesRead()));
connect(form_main->m_ui->m_actionMarkSelectedMessagesAsUnread,
SIGNAL(triggered()), m_messagesView, SLOT(markSelectedMessagesUnread()));
connect(form_main->m_ui->m_actionOpenSelectedSourceArticlesExternally,
SIGNAL(triggered()), m_messagesView, SLOT(openSelectedSourceMessagesExternally()));
connect(form_main->m_ui->m_actionOpenSelectedMessagesInternally,
SIGNAL(triggered()), m_messagesView, SLOT(openSelectedMessagesInternally()));
connect(form_main->m_ui->m_actionSendMessageViaEmail,
SIGNAL(triggered()), m_messagesView, SLOT(sendSelectedMessageViaEmail()));
connect(form_main->m_ui->m_actionMarkAllItemsRead,
SIGNAL(triggered()), m_feedsView, SLOT(markAllItemsRead()));
connect(form_main->m_ui->m_actionMarkSelectedItemsAsRead,
SIGNAL(triggered()), m_feedsView, SLOT(markSelectedItemRead()));
connect(form_main->m_ui->m_actionExpandCollapseItem,
SIGNAL(triggered()), m_feedsView, SLOT(expandCollapseCurrentItem()));
connect(form_main->m_ui->m_actionMarkSelectedItemsAsUnread,
SIGNAL(triggered()), m_feedsView, SLOT(markSelectedItemUnread()));
connect(form_main->m_ui->m_actionClearSelectedItems,
SIGNAL(triggered()), m_feedsView, SLOT(clearSelectedFeeds()));
connect(form_main->m_ui->m_actionClearAllItems,
SIGNAL(triggered()), m_feedsView, SLOT(clearAllFeeds()));
connect(form_main->m_ui->m_actionUpdateSelectedItems,
SIGNAL(triggered()), m_feedsView, SLOT(updateSelectedItems()));
connect(form_main->m_ui->m_actionUpdateAllItems,
SIGNAL(triggered()), qApp->feedReader(), SLOT(updateAllFeeds()));
connect(form_main->m_ui->m_actionStopRunningItemsUpdate,
SIGNAL(triggered()), m_feedsView->sourceModel(), SLOT(stopRunningFeedUpdate()));
connect(form_main->m_ui->m_actionEditSelectedItem,
SIGNAL(triggered()), m_feedsView, SLOT(editSelectedItem()));
connect(form_main->m_ui->m_actionViewSelectedItemsNewspaperMode,
SIGNAL(triggered()), m_feedsView, SLOT(openSelectedItemsInNewspaperMode()));
connect(form_main->m_ui->m_actionDeleteSelectedItem,
SIGNAL(triggered()), m_feedsView, SLOT(deleteSelectedItem()));
connect(form_main->m_ui->m_actionSwitchFeedsList,
SIGNAL(triggered()), this, SLOT(switchFeedComponentVisibility()));
connect(form_main->m_ui->m_actionSelectNextItem,
SIGNAL(triggered()), m_feedsView, SLOT(selectNextItem()));
connect(form_main->m_ui->m_actionSwitchToolBars,
SIGNAL(toggled(bool)), this, SLOT(setToolBarsEnabled(bool)));
connect(form_main->m_ui->m_actionSwitchListHeaders,
SIGNAL(toggled(bool)), this, SLOT(setListHeadersEnabled(bool)));
connect(form_main->m_ui->m_actionSelectPreviousItem,
SIGNAL(triggered()), m_feedsView, SLOT(selectPreviousItem()));
connect(form_main->m_ui->m_actionSelectNextMessage,
SIGNAL(triggered()), m_messagesView, SLOT(selectNextItem()));
connect(form_main->m_ui->m_actionSelectNextUnreadMessage,
SIGNAL(triggered()), m_messagesView, SLOT(selectNextUnreadItem()));
connect(form_main->m_ui->m_actionSelectPreviousMessage,
SIGNAL(triggered()), m_messagesView, SLOT(selectPreviousItem()));
connect(form_main->m_ui->m_actionSwitchMessageListOrientation, SIGNAL(triggered()),
this, SLOT(switchMessageSplitterOrientation()));
connect(form_main->m_ui->m_actionShowOnlyUnreadItems, SIGNAL(toggled(bool)),
this, SLOT(toggleShowOnlyUnreadFeeds()));
connect(form_main->m_ui->m_actionRestoreSelectedMessages, SIGNAL(triggered()),
m_messagesView, SLOT(restoreSelectedMessages()));
connect(form_main->m_ui->m_actionRestoreAllRecycleBins, SIGNAL(triggered()),
m_feedsView->sourceModel(), SLOT(restoreAllBins()));
connect(form_main->m_ui->m_actionEmptyAllRecycleBins, SIGNAL(triggered()),
m_feedsView->sourceModel(), SLOT(emptyAllBins()));
}
void FeedMessageViewer::initialize() {
@ -356,11 +222,12 @@ void FeedMessageViewer::initialize() {
m_toolBarFeeds->setFloatable(false);
m_toolBarFeeds->setMovable(false);
m_toolBarFeeds->setAllowedAreas(Qt::TopToolBarArea);
m_toolBarFeeds->loadChangeableActions();
m_toolBarMessages->setFloatable(false);
m_toolBarMessages->setMovable(false);
m_toolBarMessages->setAllowedAreas(Qt::TopToolBarArea);
m_toolBarFeeds->loadChangeableActions();
m_toolBarMessages->loadChangeableActions();
m_messagesBrowser->clear();
@ -422,9 +289,6 @@ void FeedMessageViewer::initializeViews() {
setTabOrder(m_messagesView, m_toolBarFeeds);
setTabOrder(m_toolBarFeeds, m_toolBarMessages);
setTabOrder(m_toolBarMessages, m_messagesBrowser);
updateMessageButtonsAvailability();
updateFeedButtonsAvailability();
}
void FeedMessageViewer::refreshVisualProperties() {

View File

@ -83,9 +83,6 @@ class FeedMessageViewer : public TabContent {
// Toggles displayed feeds.
void toggleShowOnlyUnreadFeeds();
void updateMessageButtonsAvailability();
void updateFeedButtonsAvailability();
protected:
// Initializes some properties of the widget.
void initialize();

View File

@ -23,6 +23,8 @@
#include "miscellaneous/textfactory.h"
#include "miscellaneous/iconfactory.h"
#include "gui/tabbar.h"
#include "gui/messagesview.h"
#include "gui/feedsview.h"
#include "gui/feedmessageviewer.h"
#include "gui/webbrowser.h"
#include "gui/plaintoolbutton.h"
@ -35,6 +37,7 @@
TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent), m_menuMain(nullptr) {
setTabBar(new TabBar(this));
setupMainMenuButton();
initializeTabs();
createConnections();
}
@ -133,6 +136,11 @@ void TabWidget::createConnections() {
connect(tabBar(), SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
connect(tabBar(), SIGNAL(emptySpaceDoubleClicked()), this, SLOT(addEmptyBrowser()));
connect(tabBar(), SIGNAL(tabMoved(int,int)), this, SLOT(fixContentsAfterMove(int,int)));
connect(feedMessageViewer()->messagesView(), SIGNAL(openMessagesInNewspaperView(RootItem*,QList<Message>)),
this, SLOT(addNewspaperView(RootItem*,QList<Message>)));
connect(feedMessageViewer()->feedsView(), SIGNAL(openMessagesInNewspaperView(RootItem*,QList<Message>)),
this, SLOT(addNewspaperView(RootItem*,QList<Message>)));
}
void TabWidget::initializeTabs() {

View File

@ -127,9 +127,9 @@ void Application::eliminateFirstRun(const QString &version) {
void Application::setFeedReader(FeedReader *feed_reader) {
m_feedReader = feed_reader;
connect(m_feedReader->feedDownloader(), &FeedDownloader::updateStarted, this, &Application::onFeedUpdatesStarted);
connect(m_feedReader->feedDownloader(), &FeedDownloader::updateProgress, this, &Application::onFeedUpdatesProgress);
connect(m_feedReader->feedDownloader(), &FeedDownloader::updateFinished, this, &Application::onFeedUpdatesFinished);
connect(m_feedReader, &FeedReader::feedUpdatesStarted, this, &Application::onFeedUpdatesStarted);
connect(m_feedReader, &FeedReader::feedUpdatesProgress, this, &Application::onFeedUpdatesProgress);
connect(m_feedReader, &FeedReader::feedUpdatesFinished, this, &Application::onFeedUpdatesFinished);
}
IconFactory *Application::icons() {

View File

@ -38,7 +38,6 @@ FeedReader::FeedReader(QObject *parent)
: QObject(parent), m_feedServices(QList<ServiceEntryPoint*>()), m_autoUpdateTimer(new QTimer(this)),
m_feedDownloaderThread(nullptr), m_feedDownloader(nullptr),
m_dbCleanerThread(nullptr), m_dbCleaner(nullptr) {
m_feedDownloader = new FeedDownloader(this);
m_feedsModel = new FeedsModel(this);
m_feedsProxyModel = new FeedsProxyModel(m_feedsModel, this);
m_messagesModel = new MessagesModel(this);
@ -83,6 +82,10 @@ void FeedReader::updateFeeds(const QList<Feed*> &feeds) {
connect(this, &FeedReader::feedsUpdateRequested, m_feedDownloader, &FeedDownloader::updateFeeds);
connect(m_feedDownloaderThread, &QThread::finished, m_feedDownloaderThread, &QThread::deleteLater);
connect(m_feedDownloader, &FeedDownloader::updateFinished, this, &FeedReader::feedUpdatesFinished);
connect(m_feedDownloader, &FeedDownloader::updateProgress, this, &FeedReader::feedUpdatesProgress);
connect(m_feedDownloader, &FeedDownloader::updateStarted, this, &FeedReader::feedUpdatesStarted);
// Connections are made, start the feed downloader thread.
m_feedDownloaderThread->start();
}

View File

@ -21,9 +21,9 @@
#include <QObject>
#include "services/abstract/feed.h"
#include "core/feeddownloader.h"
class FeedDownloader;
class FeedsModel;
class MessagesModel;
class MessagesProxyModel;
@ -78,6 +78,10 @@ class FeedReader : public QObject {
// Emitted when model requests update of some feeds.
void feedsUpdateRequested(QList<Feed*> feeds);
void feedUpdatesStarted();
void feedUpdatesFinished(FeedDownloadResults updated_feeds);
void feedUpdatesProgress(const Feed *feed, int current, int total);
private:
QList<ServiceEntryPoint*> m_feedServices;