Some extra stuff for recycle bin, general usability enhancements.

This commit is contained in:
Martin Rotter 2014-09-19 14:30:48 +02:00
parent 0e6f807d85
commit 63abccc7a5
7 changed files with 37 additions and 18 deletions

View File

@ -477,6 +477,17 @@ FeedsModelCategory *FeedsModel::categoryForIndex(const QModelIndex &index) const
}
}
FeedsModelRecycleBin *FeedsModel::recycleBinForIndex(const QModelIndex &index) const {
FeedsModelRootItem *item = itemForIndex(index);
if (item->kind() == FeedsModelRootItem::RecycleBin) {
return static_cast<FeedsModelRecycleBin*>(item);
}
else {
return NULL;
}
}
QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const {
if (item == NULL || item->kind() == FeedsModelRootItem::RootItem) {
// Root item lies on invalid index.

View File

@ -122,6 +122,8 @@ class FeedsModel : public QAbstractItemModel {
// or NULL if no category lies in given index.
FeedsModelCategory *categoryForIndex(const QModelIndex &index) const;
FeedsModelRecycleBin *recycleBinForIndex(const QModelIndex &index) const;
// Returns feed/category which lies at the specified index or
// root item if index is invalid.
FeedsModelRootItem *itemForIndex(const QModelIndex &index) const;

View File

@ -119,6 +119,11 @@ FeedsModelFeed *FeedsView::selectedFeed() const {
return m_sourceModel->feedForIndex(current_mapped);
}
FeedsModelRecycleBin *FeedsView::selectedRecycleBin() const{
QModelIndex current_mapped = m_proxyModel->mapToSource(currentIndex());
return m_sourceModel->recycleBinForIndex(current_mapped);
}
void FeedsView::saveExpandedStates() {
Settings *settings = qApp->settings();
@ -305,20 +310,7 @@ void FeedsView::editSelectedItem() {
editCategory(static_cast<FeedsModelCategory*>(category));
}
else if ((feed = selectedFeed()) != NULL) {
// Feed is selected.
switch (feed->type()) {
case FeedsModelFeed::Atom10:
case FeedsModelFeed::Rdf:
case FeedsModelFeed::Rss0X:
case FeedsModelFeed::Rss2X: {
// User wants to edit standard feed.
editFeed(static_cast<FeedsModelFeed*>(feed));
break;
}
default:
break;
}
editFeed(static_cast<FeedsModelFeed*>(feed));
}
// Changes are done, unlock the update master lock.
@ -412,6 +404,13 @@ void FeedsView::openSelectedFeedsInNewspaperMode() {
}
void FeedsView::emptyRecycleBin() {
if (MessageBox::show(qApp->mainForm(), QMessageBox::Question, tr("Permanently delete messages"),
tr("You are about to permanenty delete all messages from your recycle bin."), tr("Do you really want to empty your recycle bin?"),
QString(), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::No) {
// User changed his mind.
return;
}
m_sourceModel->recycleBin()->empty();
updateCountsOfSelectedFeeds();

View File

@ -63,6 +63,7 @@ class FeedsView : public QTreeView {
// selected.
FeedsModelCategory *selectedCategory() const;
FeedsModelFeed *selectedFeed() const;
FeedsModelRecycleBin *selectedRecycleBin() const;
// Saves/loads expand states of all nodes (feeds/categories) of the list to/from settings.
void saveExpandedStates();

View File

@ -126,6 +126,10 @@ QList<QAction*> FormMain::allActions() {
actions << m_ui->m_actionSelectPreviousMessage;
actions << m_ui->m_actionDefragmentDatabase;
// Add recycle bin actions.
actions << m_ui->m_actionRestoreAllMessages;
actions << m_ui->m_actionEmptyRecycleBin;
return actions;
}

View File

@ -278,10 +278,12 @@ void MessagesView::openSelectedMessagesInternally() {
messages << m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row());
}
emit openMessagesInNewspaperView(messages);
if (!messages.isEmpty()) {
emit openMessagesInNewspaperView(messages);
// Finally, mark opened messages as read.
markSelectedMessagesRead();
// Finally, mark opened messages as read.
markSelectedMessagesRead();
}
}
void MessagesView::markSelectedMessagesRead() {

View File

@ -96,7 +96,7 @@ int main(int argc, char *argv[]) {
main_window.setWindowTitle(APP_LONG_NAME);
// Now is a good time to initialize dynamic keyboard shortcuts.
DynamicShortcuts::load(main_window.allActions());
DynamicShortcuts::load(qApp->userActions());
// Display main window.
if (qApp->settings()->value(APP_CFG_GUI, "start_hidden", false).toBool() && SystemTrayIcon::isSystemTrayActivated()) {