Massive code upkeep.
This commit is contained in:
parent
300b1b46f5
commit
acf5e63f7c
@ -132,13 +132,13 @@ void FeedMessageViewer::onFeedUpdatesFinished() {
|
|||||||
|
|
||||||
void FeedMessageViewer::createConnections() {
|
void FeedMessageViewer::createConnections() {
|
||||||
// General connections.
|
// General connections.
|
||||||
connect(m_messagesView, SIGNAL(currentMessageRemoved()),
|
connect(m_messagesView, SIGNAL(currentMessagesRemoved()),
|
||||||
m_messagesBrowser, SLOT(clear()));
|
m_messagesBrowser, SLOT(clear()));
|
||||||
connect(m_messagesView, SIGNAL(currentMessageChanged(Message)),
|
connect(m_messagesView, SIGNAL(currentMessagesChanged(QList<Message>)),
|
||||||
m_messagesBrowser, SLOT(navigateToMessage(Message)));
|
m_messagesBrowser, SLOT(navigateToMessages(QList<Message>)));
|
||||||
connect(m_messagesView, SIGNAL(openMessageNewTabRequested(Message)),
|
connect(m_messagesView, SIGNAL(openMessagesInNewspaperView(QList<Message>)),
|
||||||
FormMain::getInstance()->m_ui->m_tabWidget,
|
FormMain::getInstance()->m_ui->m_tabWidget,
|
||||||
SLOT(addBrowserWithMessage(Message)));
|
SLOT(addBrowserWithMessages(QList<Message>)));
|
||||||
connect(m_messagesView, SIGNAL(openLinkMessageNewTabRequested(QString)),
|
connect(m_messagesView, SIGNAL(openLinkMessageNewTabRequested(QString)),
|
||||||
FormMain::getInstance()->m_ui->m_tabWidget,
|
FormMain::getInstance()->m_ui->m_tabWidget,
|
||||||
SLOT(addLinkedBrowser(QString)));
|
SLOT(addLinkedBrowser(QString)));
|
||||||
|
@ -84,7 +84,7 @@ void MessagesView::reloadSelections(int mark_current_index_read) {
|
|||||||
// be selected and no message can be displayed.
|
// be selected and no message can be displayed.
|
||||||
// TOTO: Check if this is OKAY. If not, then emit this signal
|
// TOTO: Check if this is OKAY. If not, then emit this signal
|
||||||
// from FeedsView itself.
|
// from FeedsView itself.
|
||||||
emit currentMessageRemoved();
|
emit currentMessagesRemoved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,10 +205,11 @@ void MessagesView::currentChanged(const QModelIndex ¤t,
|
|||||||
m_sourceModel->setMessageRead(mapped_current_index.row(), 1);
|
m_sourceModel->setMessageRead(mapped_current_index.row(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit currentMessageChanged(m_sourceModel->messageAt(mapped_current_index.row()));
|
emit currentMessagesChanged(QList<Message>() <<
|
||||||
|
m_sourceModel->messageAt(mapped_current_index.row()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit currentMessageRemoved();
|
emit currentMessagesRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeView::currentChanged(current, previous);
|
QTreeView::currentChanged(current, previous);
|
||||||
@ -222,7 +223,7 @@ void MessagesView::loadFeeds(const QList<int> &feed_ids) {
|
|||||||
|
|
||||||
// Messages are loaded, make sure that previously
|
// Messages are loaded, make sure that previously
|
||||||
// active message is not shown in browser.
|
// active message is not shown in browser.
|
||||||
emit currentMessageRemoved();
|
emit currentMessagesRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesView::openSelectedSourceArticlesExternally() {
|
void MessagesView::openSelectedSourceArticlesExternally() {
|
||||||
@ -256,15 +257,19 @@ void MessagesView::openSelectedSourceMessagesInternally() {
|
|||||||
tr("Message '%s' does not contain URL.").arg(message.m_title));
|
tr("Message '%s' does not contain URL.").arg(message.m_title));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit openLinkMessageNewTabRequested(message.m_url);
|
emit openLinkNewTab(message.m_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesView::openSelectedMessagesInternally() {
|
void MessagesView::openSelectedMessagesInternally() {
|
||||||
|
QList<Message> messages;
|
||||||
|
|
||||||
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
|
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
|
||||||
emit openMessageNewTabRequested(m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()));
|
messages << m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit openMessagesInNewspaperView(messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesView::markSelectedMessagesRead() {
|
void MessagesView::markSelectedMessagesRead() {
|
||||||
@ -324,7 +329,7 @@ void MessagesView::deleteSelectedMessages() {
|
|||||||
reselectIndexes(QModelIndexList() << last_item);
|
reselectIndexes(QModelIndexList() << last_item);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit currentMessageRemoved();
|
emit currentMessagesRemoved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,12 +64,12 @@ class MessagesView : public QTreeView {
|
|||||||
const QModelIndex &previous);
|
const QModelIndex &previous);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void openLinkMessageNewTabRequested(const QString &link);
|
void openLinkNewTab(const QString &link);
|
||||||
void openMessageNewTabRequested(const Message &message);
|
void openMessagesInNewspaperView(const QList<Message> &messages);
|
||||||
void openMessagesInNewspaperViewRequested(const QList<Message> &messages);
|
|
||||||
|
|
||||||
void currentMessageChanged(const Message &message);
|
// Notify others about message selections.
|
||||||
void currentMessageRemoved();
|
void currentMessagesChanged(const QList<Message> &messages);
|
||||||
|
void currentMessagesRemoved();
|
||||||
|
|
||||||
// Emitted if counts of unread/total messages has changed
|
// Emitted if counts of unread/total messages has changed
|
||||||
// because of user interaction with list of messages.
|
// because of user interaction with list of messages.
|
||||||
|
@ -175,15 +175,13 @@ int TabWidget::insertTab(int index, QWidget *widget, const QString &label,
|
|||||||
return tab_index;
|
return tab_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TabWidget::addBrowserWithMessage(const Message &message) {
|
|
||||||
int new_index = addBrowser(false, false);
|
|
||||||
static_cast<WebBrowser*>(widget(new_index))->navigateToMessage(message);
|
|
||||||
return new_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
int TabWidget::addBrowserWithMessages(const QList<Message> &messages) {
|
int TabWidget::addBrowserWithMessages(const QList<Message> &messages) {
|
||||||
int new_index = addBrowser(false, true);
|
int new_index = addBrowser(false, true);
|
||||||
static_cast<WebBrowser*>(widget(new_index))->navigateToMessages(messages);
|
WebBrowser *browser = static_cast<WebBrowser*>(widget(new_index));
|
||||||
|
|
||||||
|
browser->setNavigationBarVisible(false);
|
||||||
|
browser->navigateToMessages(messages);
|
||||||
|
|
||||||
return new_index;
|
return new_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,6 @@ class TabWidget : public QTabWidget {
|
|||||||
void closeAllTabsExceptCurrent();
|
void closeAllTabsExceptCurrent();
|
||||||
|
|
||||||
// Open single or multiple (newspaper mode) messages in new tab.
|
// Open single or multiple (newspaper mode) messages in new tab.
|
||||||
int addBrowserWithMessage(const Message &message);
|
|
||||||
int addBrowserWithMessages(const QList<Message> &messages);
|
int addBrowserWithMessages(const QList<Message> &messages);
|
||||||
|
|
||||||
// Adds new WebBrowser tab to global TabWidget.
|
// Adds new WebBrowser tab to global TabWidget.
|
||||||
|
@ -35,7 +35,8 @@ WebBrowser::WebBrowser(QWidget *parent)
|
|||||||
m_actionBack(m_webView->pageAction(QWebPage::Back)),
|
m_actionBack(m_webView->pageAction(QWebPage::Back)),
|
||||||
m_actionForward(m_webView->pageAction(QWebPage::Forward)),
|
m_actionForward(m_webView->pageAction(QWebPage::Forward)),
|
||||||
m_actionReload(m_webView->pageAction(QWebPage::Reload)),
|
m_actionReload(m_webView->pageAction(QWebPage::Reload)),
|
||||||
m_actionStop(m_webView->pageAction(QWebPage::Stop)) {
|
m_actionStop(m_webView->pageAction(QWebPage::Stop)),
|
||||||
|
m_activeNewspaperMode(false) {
|
||||||
|
|
||||||
m_index = -1;
|
m_index = -1;
|
||||||
|
|
||||||
@ -165,10 +166,6 @@ void WebBrowser::clear() {
|
|||||||
m_webView->load(QUrl());
|
m_webView->load(QUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebBrowser::navigateToMessage(const Message &message) {
|
|
||||||
navigateToMessages(QList<Message>() << message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebBrowser::navigateToMessages(const QList<Message> &messages) {
|
void WebBrowser::navigateToMessages(const QList<Message> &messages) {
|
||||||
SkinFactory *factory = SkinFactory::getInstance();
|
SkinFactory *factory = SkinFactory::getInstance();
|
||||||
QString messages_layout;
|
QString messages_layout;
|
||||||
|
@ -60,10 +60,7 @@ class WebBrowser : public TabContent {
|
|||||||
void navigateToUrl(const QString &url);
|
void navigateToUrl(const QString &url);
|
||||||
void navigateToUrl(const QUrl &url);
|
void navigateToUrl(const QUrl &url);
|
||||||
|
|
||||||
// Navigates to single message.
|
// Navigates to messages, used also as "newspaper" view.
|
||||||
void navigateToMessage(const Message &message);
|
|
||||||
|
|
||||||
// Navigates to messages via "newspaper" view.
|
|
||||||
void navigateToMessages(const QList<Message> &messages);
|
void navigateToMessages(const QList<Message> &messages);
|
||||||
|
|
||||||
// Clears contents.
|
// Clears contents.
|
||||||
@ -112,6 +109,8 @@ class WebBrowser : public TabContent {
|
|||||||
QAction *m_actionReload;
|
QAction *m_actionReload;
|
||||||
QAction *m_actionStop;
|
QAction *m_actionStop;
|
||||||
|
|
||||||
|
bool m_activeNewspaperMode;
|
||||||
|
|
||||||
static QPointer<WebBrowserNetworkAccessManager> m_networkManager;
|
static QPointer<WebBrowserNetworkAccessManager> m_networkManager;
|
||||||
static QList<WebBrowser*> m_runningWebBrowsers;
|
static QList<WebBrowser*> m_runningWebBrowsers;
|
||||||
};
|
};
|
||||||
|
@ -16,6 +16,7 @@ class WebView : public QWebView {
|
|||||||
explicit WebView(QWidget *parent = 0);
|
explicit WebView(QWidget *parent = 0);
|
||||||
virtual ~WebView();
|
virtual ~WebView();
|
||||||
|
|
||||||
|
// Page accessor.
|
||||||
WebPage *page() const;
|
WebPage *page() const;
|
||||||
|
|
||||||
void setupIcons();
|
void setupIcons();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user