mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-30 17:15:01 +01:00
Restoring of individual messages added.
This commit is contained in:
parent
7ea94ef42f
commit
6abe99ed54
@ -71,6 +71,8 @@ void MessagesModel::setupFonts() {
|
||||
m_boldFont.setBold(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MessagesModel::loadMessages(RootItem *item) {
|
||||
m_selectedItem = item;
|
||||
|
||||
@ -110,6 +112,10 @@ RootItem::Importance MessagesModel::messageImportance(int row_index) const {
|
||||
return (RootItem::Importance) data(row_index, MSG_DB_IMPORTANT_INDEX, Qt::EditRole).toInt();
|
||||
}
|
||||
|
||||
RootItem *MessagesModel::loadedItem() const {
|
||||
return m_selectedItem;
|
||||
}
|
||||
|
||||
void MessagesModel::updateDateFormat() {
|
||||
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool()) {
|
||||
m_customDateFormat = qApp->settings()->value(GROUP(Messages), SETTING(Messages::CustomDateFormat)).toString();
|
||||
@ -360,7 +366,7 @@ bool MessagesModel::switchBatchMessageImportance(const QModelIndexList &messages
|
||||
}
|
||||
}
|
||||
|
||||
bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList &messages, int deleted) {
|
||||
bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList &messages) {
|
||||
QStringList message_ids;
|
||||
QList<int> message_ids_num;
|
||||
|
||||
@ -382,12 +388,10 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList &messages, int
|
||||
query_read_msg.setForwardOnly(true);
|
||||
|
||||
if (m_selectedItem->kind() != RootItemKind::Bin) {
|
||||
sql_delete_query = QString(QSL("UPDATE Messages SET is_deleted = %2 WHERE id IN (%1);")).arg(message_ids.join(QSL(", ")),
|
||||
QString::number(deleted));
|
||||
sql_delete_query = QString(QSL("UPDATE Messages SET is_deleted = 1 WHERE id IN (%1);")).arg(message_ids.join(QSL(", ")));
|
||||
}
|
||||
else {
|
||||
sql_delete_query = QString(QSL("UPDATE Messages SET is_pdeleted = %2 WHERE id IN (%1);")).arg(message_ids.join(QSL(", ")),
|
||||
QString::number(deleted));
|
||||
sql_delete_query = QString(QSL("UPDATE Messages SET is_pdeleted = 1 WHERE id IN (%1);")).arg(message_ids.join(QSL(", ")));
|
||||
}
|
||||
|
||||
if (query_read_msg.exec(sql_delete_query)) {
|
||||
|
@ -55,6 +55,8 @@ class MessagesModel : public QSqlTableModel {
|
||||
int messageId(int row_index) const;
|
||||
RootItem::Importance messageImportance(int row_index) const;
|
||||
|
||||
RootItem *loadedItem() const;
|
||||
|
||||
void updateDateFormat();
|
||||
void reloadWholeLayout();
|
||||
|
||||
@ -71,7 +73,7 @@ class MessagesModel : public QSqlTableModel {
|
||||
// NOTE: Model is reset after one of these methods is applied and
|
||||
// changes ARE written to the database.
|
||||
bool switchBatchMessageImportance(const QModelIndexList &messages);
|
||||
bool setBatchMessagesDeleted(const QModelIndexList &messages, int deleted);
|
||||
bool setBatchMessagesDeleted(const QModelIndexList &messages);
|
||||
bool setBatchMessagesRead(const QModelIndexList &messages, RootItem::ReadStatus read);
|
||||
bool setBatchMessagesRestored(const QModelIndexList &messages);
|
||||
|
||||
|
@ -323,6 +323,7 @@ void FormMain::setupIcons() {
|
||||
m_ui->m_actionSelectPreviousMessage->setIcon(icon_theme_factory->fromTheme(QSL("go-up")));
|
||||
m_ui->m_actionShowOnlyUnreadItems->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-unread")));
|
||||
m_ui->m_actionExpandCollapseItem->setIcon(icon_theme_factory->fromTheme(QSL("expand-collapse")));
|
||||
m_ui->m_actionRestoreSelectedMessages->setIcon(icon_theme_factory->fromTheme(QSL("recycle-bin-restore-one")));
|
||||
|
||||
// Setup icons for underlying components: opened web browsers...
|
||||
foreach (WebBrowser *browser, WebBrowser::runningWebBrowsers()) {
|
||||
|
@ -643,6 +643,11 @@
|
||||
<string>&Edit selected service account</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionRestoreSelectedMessages">
|
||||
<property name="text">
|
||||
<string>&Restore selected messages</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -313,6 +313,8 @@ void FeedMessageViewer::createConnections() {
|
||||
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()));
|
||||
}
|
||||
|
||||
void FeedMessageViewer::initialize() {
|
||||
|
@ -140,16 +140,18 @@ void MessagesView::contextMenuEvent(QContextMenuEvent *event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_contextMenu == NULL) {
|
||||
// Context menu is not initialized, initialize.
|
||||
initializeContextMenu();
|
||||
}
|
||||
// Context menu is not initialized, initialize.
|
||||
initializeContextMenu();
|
||||
|
||||
m_contextMenu->exec(event->globalPos());
|
||||
}
|
||||
|
||||
void MessagesView::initializeContextMenu() {
|
||||
m_contextMenu = new QMenu(tr("Context menu for messages"), this);
|
||||
if (m_contextMenu == NULL) {
|
||||
m_contextMenu = new QMenu(tr("Context menu for messages"), this);
|
||||
}
|
||||
|
||||
m_contextMenu->clear();
|
||||
m_contextMenu->addActions(QList<QAction*>() <<
|
||||
qApp->mainForm()->m_ui->m_actionSendMessageViaEmail <<
|
||||
qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesExternally <<
|
||||
@ -159,6 +161,10 @@ void MessagesView::initializeContextMenu() {
|
||||
qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsUnread <<
|
||||
qApp->mainForm()->m_ui->m_actionSwitchImportanceOfSelectedMessages <<
|
||||
qApp->mainForm()->m_ui->m_actionDeleteSelectedMessages);
|
||||
|
||||
if (m_sourceModel->loadedItem() != NULL && m_sourceModel->loadedItem()->kind() == RootItemKind::Bin) {
|
||||
m_contextMenu->addAction(qApp->mainForm()->m_ui->m_actionRestoreSelectedMessages);
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesView::mousePressEvent(QMouseEvent *event) {
|
||||
@ -359,7 +365,35 @@ void MessagesView::deleteSelectedMessages() {
|
||||
QModelIndexList selected_indexes = selectionModel()->selectedRows();
|
||||
QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
|
||||
|
||||
m_sourceModel->setBatchMessagesDeleted(mapped_indexes, 1);
|
||||
m_sourceModel->setBatchMessagesDeleted(mapped_indexes);
|
||||
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
|
||||
|
||||
int row_count = m_sourceModel->rowCount();
|
||||
if (row_count > 0) {
|
||||
QModelIndex last_item = current_index.row() < row_count ?
|
||||
m_proxyModel->index(current_index.row(), MSG_DB_TITLE_INDEX) :
|
||||
m_proxyModel->index(row_count - 1, MSG_DB_TITLE_INDEX);
|
||||
|
||||
setCurrentIndex(last_item);
|
||||
scrollTo(last_item);
|
||||
reselectIndexes(QModelIndexList() << last_item);
|
||||
}
|
||||
else {
|
||||
emit currentMessagesRemoved();
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesView::restoreSelectedMessages() {
|
||||
QModelIndex current_index = selectionModel()->currentIndex();
|
||||
|
||||
if (!current_index.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndexList selected_indexes = selectionModel()->selectedRows();
|
||||
QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
|
||||
|
||||
m_sourceModel->setBatchMessagesRestored(mapped_indexes);
|
||||
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
|
||||
|
||||
int row_count = m_sourceModel->rowCount();
|
||||
|
@ -72,6 +72,7 @@ class MessagesView : public QTreeView {
|
||||
void markSelectedMessagesUnread();
|
||||
void switchSelectedMessagesImportance();
|
||||
void deleteSelectedMessages();
|
||||
void restoreSelectedMessages();
|
||||
|
||||
void selectNextItem();
|
||||
void selectPreviousItem();
|
||||
|
@ -623,6 +623,8 @@ bool StandardServiceRoot::onAfterMessagesRestoredFromBin(RootItem *selected_item
|
||||
Q_UNUSED(selected_item)
|
||||
Q_UNUSED(message_db_ids)
|
||||
|
||||
updateCounts(true);
|
||||
|
||||
emit dataChanged(getSubTree());
|
||||
emit readFeedsFilterInvalidationRequested();
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user