Worked on more things.

This commit is contained in:
Martin Rotter 2013-12-30 21:23:42 +01:00
parent 17d757f1ae
commit 008d0b3fc1
6 changed files with 73 additions and 57 deletions

View File

@ -74,6 +74,7 @@ class FeedsModel : public QAbstractItemModel {
FeedsModelRootItem *rootItem() const;
public slots:
// Feeds operations.
bool markFeedsRead(const QList<FeedsModelFeed*> &feeds, int read);
bool markFeedsDeleted(const QList<FeedsModelFeed*> &feeds, int deleted);
@ -86,6 +87,8 @@ class FeedsModel : public QAbstractItemModel {
void reloadChangedLayout(QModelIndexList list);
protected:
// Returns converted ids of given feeds
// which are suitable as IN clause for SQL queries.
QStringList textualFeedIds(const QList<FeedsModelFeed*> &feeds);
// Loads feed/categories from the database.

View File

@ -181,13 +181,13 @@ void FeedMessageViewer::createConnections() {
SIGNAL(triggered()), m_feedsView, SLOT(markSelectedFeedsUnread()));
connect(FormMain::getInstance()->m_ui->m_actionClearFeeds,
SIGNAL(triggered()), m_feedsView, SLOT(clearSelectedFeeds()));
connect(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeeds,
connect(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeedsCategories,
SIGNAL(triggered()), this, SLOT(updateSelectedFeeds()));
connect(FormMain::getInstance()->m_ui->m_actionUpdateAllFeeds,
SIGNAL(triggered()), this, SLOT(updateAllFeeds()));
connect(FormMain::getInstance()->m_ui->m_actionAddNewCategory,
SIGNAL(triggered()), m_feedsView, SLOT(addNewCategory()));
connect(FormMain::getInstance()->m_ui->m_actionEditSelectedFeed,
connect(FormMain::getInstance()->m_ui->m_actionEditSelectedFeedCategory,
SIGNAL(triggered()), m_feedsView, SLOT(editSelectedItem()));
}
@ -200,10 +200,10 @@ void FeedMessageViewer::initialize() {
// Add everything to toolbar.
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionUpdateAllFeeds);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeeds);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeedsCategories);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionAddNewFeed);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionEditSelectedFeed);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionDeleteSelectedFeeds);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionEditSelectedFeedCategory);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionDeleteSelectedFeedsCategories);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkFeedsAsRead);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkFeedsAsUnread);
m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionClearFeeds);

View File

@ -17,7 +17,10 @@
#include <QPainter>
FeedsView::FeedsView(QWidget *parent) : QTreeView(parent), m_contextMenu(NULL) {
FeedsView::FeedsView(QWidget *parent)
: QTreeView(parent),
m_contextMenuCategoriesFeeds(NULL),
m_contextMenuEmptySpace(NULL) {
m_proxyModel = new FeedsProxyModel(this);
m_sourceModel = m_proxyModel->sourceModel();
@ -141,12 +144,19 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
m_sourceModel->reloadWholeLayout();
}
void FeedsView::initializeContextMenu() {
m_contextMenu = new QMenu(tr("Context menu for feeds"), this);
m_contextMenu->addActions(QList<QAction*>() <<
FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeeds <<
FormMain::getInstance()->m_ui->m_actionMarkFeedsAsRead <<
FormMain::getInstance()->m_ui->m_actionMarkFeedsAsUnread);
void FeedsView::initializeContextMenuCategoriesFeeds() {
m_contextMenuCategoriesFeeds = new QMenu(tr("Context menu for feeds"), this);
m_contextMenuCategoriesFeeds->addActions(QList<QAction*>() <<
FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeedsCategories <<
FormMain::getInstance()->m_ui->m_actionMarkFeedsAsRead <<
FormMain::getInstance()->m_ui->m_actionMarkFeedsAsUnread);
}
void FeedsView::initializeContextMenuEmptySpace() {
m_contextMenuEmptySpace = new QMenu(tr("Context menu for feeds"), this);
m_contextMenuEmptySpace->addActions(QList<QAction*>() <<
FormMain::getInstance()->m_ui->m_actionAddNewFeed);
}
void FeedsView::setupAppearance() {
@ -194,20 +204,24 @@ void FeedsView::selectionChanged(const QItemSelection &selected,
}
void FeedsView::contextMenuEvent(QContextMenuEvent *event) {
QModelIndex clicked_index = indexAt(event->pos());
if (indexAt(event->pos()).isValid()) {
// Display context menu for categories.
if (m_contextMenuCategoriesFeeds == NULL) {
// Context menu is not initialized, initialize.
initializeContextMenuCategoriesFeeds();
}
if (!clicked_index.isValid()) {
qDebug("Context menu for FeedsView will not be shown because "
"user clicked on invalid item.");
return;
m_contextMenuCategoriesFeeds->exec(event->globalPos());
}
else {
// Display menu for empty space.
if (m_contextMenuEmptySpace == NULL) {
// Context menu is not initialized, initialize.
initializeContextMenuEmptySpace();
}
if (m_contextMenu == NULL) {
// Context menu is not initialized, initialize.
initializeContextMenu();
m_contextMenuEmptySpace->exec(event->globalPos());
}
m_contextMenu->exec(event->globalPos());
}
void FeedsView::drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const {

View File

@ -54,7 +54,8 @@ class FeedsView : public QTreeView {
void updateCountsOfAllFeeds(bool update_total_too = true);
protected:
void initializeContextMenu();
void initializeContextMenuCategoriesFeeds();
void initializeContextMenuEmptySpace();
// Sets up appearance of this widget.
void setupAppearance();
@ -79,7 +80,8 @@ class FeedsView : public QTreeView {
void feedsSelected(const QList<int> &feed_ids);
private:
QMenu *m_contextMenu;
QMenu *m_contextMenuCategoriesFeeds;
QMenu *m_contextMenuEmptySpace;
QList<int> m_selectedFeeds;
FeedsModel *m_sourceModel;

View File

@ -89,9 +89,9 @@ QList<QAction*> FormMain::getActions() {
m_ui->m_actionSwitchImportanceOfSelectedMessages <<
m_ui->m_actionDeleteSelectedMessages <<
m_ui->m_actionUpdateAllFeeds <<
m_ui->m_actionUpdateSelectedFeeds <<
m_ui->m_actionEditSelectedFeed <<
m_ui->m_actionDeleteSelectedFeeds;
m_ui->m_actionUpdateSelectedFeedsCategories <<
m_ui->m_actionEditSelectedFeedCategory <<
m_ui->m_actionDeleteSelectedFeedsCategories;
return actions;
}
@ -216,13 +216,13 @@ void FormMain::setupIcons() {
// Feeds/messages.
m_ui->m_actionUpdateAllFeeds->setIcon(IconThemeFactory::getInstance()->fromTheme("document-save-as"));
m_ui->m_actionUpdateSelectedFeeds->setIcon(IconThemeFactory::getInstance()->fromTheme("document-save"));
m_ui->m_actionUpdateSelectedFeedsCategories->setIcon(IconThemeFactory::getInstance()->fromTheme("document-save"));
m_ui->m_actionClearFeeds->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-junk"));
m_ui->m_actionDeleteSelectedFeeds->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-delete"));
m_ui->m_actionDeleteSelectedFeedsCategories->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-delete"));
m_ui->m_actionDeleteSelectedMessages->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-junk"));
m_ui->m_actionAddNewCategory->setIcon(IconThemeFactory::getInstance()->fromTheme("document-new"));
m_ui->m_actionAddNewFeed->setIcon(IconThemeFactory::getInstance()->fromTheme("document-new"));
m_ui->m_actionEditSelectedFeed->setIcon(IconThemeFactory::getInstance()->fromTheme("gnome-other"));
m_ui->m_actionEditSelectedFeedCategory->setIcon(IconThemeFactory::getInstance()->fromTheme("gnome-other"));
m_ui->m_actionMarkFeedsAsRead->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-not-junk"));
m_ui->m_actionMarkFeedsAsUnread->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-important"));
m_ui->m_actionMarkFeedsAsRead->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-not-junk"));

View File

@ -15,7 +15,16 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -39,7 +48,7 @@
<x>0</x>
<y>0</y>
<width>979</width>
<height>20</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="m_menuFile">
@ -83,15 +92,15 @@
</widget>
<widget class="QMenu" name="m_menuFeeds">
<property name="title">
<string>Fee&amp;ds</string>
<string>Fee&amp;ds &amp;&amp; categories</string>
</property>
<addaction name="m_actionUpdateAllFeeds"/>
<addaction name="m_actionUpdateSelectedFeeds"/>
<addaction name="m_actionUpdateSelectedFeedsCategories"/>
<addaction name="separator"/>
<addaction name="m_actionAddNewFeed"/>
<addaction name="m_actionAddNewCategory"/>
<addaction name="m_actionEditSelectedFeed"/>
<addaction name="m_actionDeleteSelectedFeeds"/>
<addaction name="m_actionEditSelectedFeedCategory"/>
<addaction name="m_actionDeleteSelectedFeedsCategories"/>
<addaction name="separator"/>
<addaction name="m_actionMarkFeedsAsRead"/>
<addaction name="m_actionMarkFeedsAsUnread"/>
@ -219,47 +228,35 @@
</action>
<action name="m_actionUpdateAllFeeds">
<property name="text">
<string>Update &amp;all feeds</string>
<string>Update &amp;all items</string>
</property>
<property name="toolTip">
<string>Update all feeds.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionUpdateSelectedFeeds">
<action name="m_actionUpdateSelectedFeedsCategories">
<property name="text">
<string>Update &amp;selected feeds</string>
<string>Update &amp;selected items</string>
</property>
<property name="toolTip">
<string>Update selected feeds/categories.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionEditSelectedFeed">
<action name="m_actionEditSelectedFeedCategory">
<property name="text">
<string>&amp;Edit selected feed/category</string>
</property>
<property name="toolTip">
<string>Edit selected feed/category.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionDeleteSelectedFeeds">
<action name="m_actionDeleteSelectedFeedsCategories">
<property name="text">
<string>&amp;Delete selected feed(s)/category(ies)</string>
<string>&amp;Delete selected feeds/categories</string>
</property>
<property name="toolTip">
<string>Delete selected feeds/categories.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionMarkSelectedMessagesAsRead">
<property name="text">
@ -296,7 +293,7 @@
</action>
<action name="m_actionMarkFeedsAsRead">
<property name="text">
<string>Mark &amp;selected feeds read</string>
<string>Mark &amp;selected items read</string>
</property>
<property name="toolTip">
<string>Marks all messages (without message filters) from selected feeds as read.</string>
@ -304,7 +301,7 @@
</action>
<action name="m_actionMarkFeedsAsUnread">
<property name="text">
<string>Mark selected feeds unread</string>
<string>Mark selected items unread</string>
</property>
<property name="toolTip">
<string>Marks all messages (without message filters) from selected feeds as unread.</string>
@ -320,7 +317,7 @@
</action>
<action name="m_actionClearFeeds">
<property name="text">
<string>Clear selected feeds</string>
<string>Clear selected items</string>
</property>
<property name="toolTip">
<string>Removes all messages from selected feeds.</string>