diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 4e74e5f97..9c7f30610 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include #include "gui/feedmessageviewer.h" #include "gui/webbrowser.h" @@ -34,10 +37,25 @@ void FeedMessageViewer::initialize() { m_toolBar->setAllowedAreas(Qt::TopToolBarArea); // TODO: testovaci + QMenu *update_menu = new QMenu(m_toolBar); + QAction *testAction = new QAction("test menu item", this); + update_menu->addAction(testAction); + + QToolButton* toolButton = new QToolButton(); + toolButton->setMenu(update_menu); + toolButton->setIcon(QIcon::fromTheme("application-exit")); + toolButton->setText("aaa"); + toolButton->setPopupMode(QToolButton::MenuButtonPopup); + + QWidgetAction* toolButtonAction = new QWidgetAction(this); + toolButtonAction->setDefaultWidget(toolButton); + + m_toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + m_toolBar->addAction(toolButtonAction); m_toolBar->addAction(QIcon::fromTheme("application-exit"), "aaa"); QAction *ac = m_toolBar->actions().at(0); connect(ac, SIGNAL(triggered()), - m_messagesView->model()->sourceModel(), SLOT(submitAll())); + m_messagesView, SLOT(setAllMessagesRead())); // Finish web/message browser setup. m_messagesBrowser->setNavigationBarVisible(false); diff --git a/src/gui/feedmessageviewer.h b/src/gui/feedmessageviewer.h index 4151e9f61..85e4f04c5 100644 --- a/src/gui/feedmessageviewer.h +++ b/src/gui/feedmessageviewer.h @@ -29,6 +29,7 @@ class FeedMessageViewer : public TabContent { private: QToolBar *m_toolBar; + MessagesView *m_messagesView; FeedsView *m_feedsView; WebBrowser *m_messagesBrowser; diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index 5a45fd7b5..42541e505 100644 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -148,6 +148,8 @@ void FormMain::setupIcons() { m_ui->m_actionImport->setIcon(IconThemeFactory::getInstance()->fromTheme("document-import")); m_ui->m_actionExport->setIcon(IconThemeFactory::getInstance()->fromTheme("document-export")); m_ui->m_actionFullscreen->setIcon(IconThemeFactory::getInstance()->fromTheme("view-fullscreen")); + m_ui->m_actionUpdateAll->setIcon(IconThemeFactory::getInstance()->fromTheme("view-refresh")); + m_ui->m_actionUpdateSelected->setIcon(IconThemeFactory::getInstance()->fromTheme("view-refresh")); // Setup icons for underlying components: opened web browsers... foreach (WebBrowser *browser, WebBrowser::runningWebBrowsers()) { diff --git a/src/gui/formmain.ui b/src/gui/formmain.ui index 0dbf0a05a..ac03dcd51 100644 --- a/src/gui/formmain.ui +++ b/src/gui/formmain.ui @@ -48,7 +48,7 @@ 0 0 800 - 19 + 21 @@ -93,8 +93,28 @@ + + + Fee&ds + + + + + + + + + + &Messages + + + + + + + @@ -195,6 +215,62 @@ + + + Update &all + + + Update all feeds. + + + + + Update &selected + + + Update selected feeds/categories. + + + + + &Edit selected + + + Edit selected feed/category. + + + + + &Delete selected + + + Delete selected feeds/categories. + + + + + Mark as &read + + + Mark selected messages as read. + + + + + Mark as &unread + + + Mark selected messages as unread. + + + + + Switch importance + + + Switch importance of selected messages. + + diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index da9b56dc8..9526bb08d 100644 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -82,16 +82,30 @@ void MessagesView::keyPressEvent(QKeyEvent *event) { void MessagesView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { - QModelIndex ind = m_proxyModel->mapToSource(current); + QModelIndex mapped_current = m_proxyModel->mapToSource(current); - qDebug("CurrentChanged %d %d source %d %d", + qDebug("Current row changed, row [%d,%d] source %d %d", current.row(), current.column(), - ind.row(), ind.column()); + mapped_current.row(), mapped_current.column()); - m_sourceModel->setMessageRead(ind.row(), 1); - - emit currentMessageChanged(m_sourceModel->messageAt(ind.row())); + m_sourceModel->setMessageRead(mapped_current.row(), 1); + emit currentMessageChanged(m_sourceModel->messageAt(mapped_current.row())); QTreeView::currentChanged(current, previous); } + +void MessagesView::setSelectedMessagesReadStatus(int read) { +} + +void MessagesView::setAllMessagesRead() { + selectAll(); + QModelIndexList selected_indexes = selectedIndexes(); + QModelIndexList mapp; + + foreach (const QModelIndex &index, selected_indexes) { + mapp << m_proxyModel->mapToSource(index); + } + + m_sourceModel->switchBatchMessageImportance(mapp); +} diff --git a/src/gui/messagesview.h b/src/gui/messagesview.h index 3ae0afca3..e93cf976c 100644 --- a/src/gui/messagesview.h +++ b/src/gui/messagesview.h @@ -24,11 +24,10 @@ class MessagesView : public QTreeView { public slots: // Message manipulators. - // TODO: sem pridat metody jako - // setSelectedMessagesRead.... - // setSelectedMessagesUnread..... - // deleteSelectedMessages.... - // ...... + void setSelectedMessagesReadStatus(int read); + + void setAllMessagesRead(); + protected: void setupAppearance();