mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-01 02:48:05 +01:00
Work on selective message restoring.
This commit is contained in:
parent
1a9a121709
commit
47ad127fca
Binary file not shown.
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
@ -365,7 +365,7 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList &messages, int
|
||||
|
||||
if (m_messageMode == MessagesFromFeeds) {
|
||||
sql_delete_query = QString("UPDATE Messages SET is_deleted = %2 WHERE id IN (%1);").arg(message_ids.join(", "),
|
||||
QString::number(deleted));
|
||||
QString::number(deleted));
|
||||
}
|
||||
else {
|
||||
sql_delete_query = QString("DELETE FROM Messages WHERE id in (%1);").arg(message_ids.join(", "));
|
||||
@ -408,6 +408,14 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList &messages, int re
|
||||
}
|
||||
}
|
||||
|
||||
bool MessagesModel::setBatchMessagesRestored(const QModelIndexList &messages) {
|
||||
// TODO: Model -> setBatchMessagesRestored();
|
||||
// obnovime zpravy, po obnoveni je treba jako ve funkci setBatchMessagesDeleted
|
||||
// pres feedCountsChanged dat informaci ze pocty zprav se zmenily, ale oni
|
||||
// se zmenily nejen ve vybranych kanalech (je vybran odkadkovy kos) ale v kanalech do kterych patri
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant MessagesModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
Q_UNUSED(orientation)
|
||||
|
||||
|
@ -102,6 +102,7 @@ class MessagesModel : public QSqlTableModel {
|
||||
bool switchBatchMessageImportance(const QModelIndexList &messages);
|
||||
bool setBatchMessagesDeleted(const QModelIndexList &messages, int deleted);
|
||||
bool setBatchMessagesRead(const QModelIndexList &messages, int read);
|
||||
bool setBatchMessagesRestored(const QModelIndexList &messages);
|
||||
|
||||
// Fetches ALL available data to the model.
|
||||
void fetchAll();
|
||||
|
@ -235,6 +235,8 @@ void FeedMessageViewer::createConnections() {
|
||||
SIGNAL(triggered()), m_messagesView, SLOT(switchSelectedMessagesImportance()));
|
||||
connect(form_main->m_ui->m_actionDeleteSelectedMessages,
|
||||
SIGNAL(triggered()), m_messagesView, SLOT(deleteSelectedMessages()));
|
||||
connect(form_main->m_ui->m_actionRestoreSelectedMessagesFromRecycleBin,
|
||||
SIGNAL(triggered()), m_messagesView, SLOT(restoreSelectedMessages()));
|
||||
connect(form_main->m_ui->m_actionMarkSelectedMessagesAsRead,
|
||||
SIGNAL(triggered()), m_messagesView, SLOT(markSelectedMessagesRead()));
|
||||
connect(form_main->m_ui->m_actionMarkSelectedMessagesAsUnread,
|
||||
@ -269,7 +271,7 @@ void FeedMessageViewer::createConnections() {
|
||||
SIGNAL(triggered()), m_feedsView, SLOT(openSelectedFeedsInNewspaperMode()));
|
||||
connect(form_main->m_ui->m_actionEmptyRecycleBin,
|
||||
SIGNAL(triggered()), m_feedsView, SLOT(emptyRecycleBin()));
|
||||
connect(form_main->m_ui->m_actionRestoreAllMessages,
|
||||
connect(form_main->m_ui->m_actionRestoreRecycleBin,
|
||||
SIGNAL(triggered()), m_feedsView, SLOT(restoreRecycleBin()));
|
||||
connect(form_main->m_ui->m_actionDeleteSelectedFeedCategory,
|
||||
SIGNAL(triggered()), m_feedsView, SLOT(deleteSelectedItem()));
|
||||
|
@ -521,7 +521,7 @@ void FeedsView::initializeContextMenuEmptySpace() {
|
||||
void FeedsView::initializeContextMenuRecycleBin() {
|
||||
m_contextMenuRecycleBin = new QMenu(tr("Context menu for recycle bin"), this);
|
||||
m_contextMenuRecycleBin->addActions(QList<QAction*>() <<
|
||||
qApp->mainForm()->m_ui->m_actionRestoreAllMessages <<
|
||||
qApp->mainForm()->m_ui->m_actionRestoreRecycleBin <<
|
||||
qApp->mainForm()->m_ui->m_actionEmptyRecycleBin);
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ QList<QAction*> FormMain::allActions() {
|
||||
actions << m_ui->m_actionDefragmentDatabase;
|
||||
|
||||
// Add recycle bin actions.
|
||||
actions << m_ui->m_actionRestoreAllMessages;
|
||||
actions << m_ui->m_actionRestoreRecycleBin;
|
||||
actions << m_ui->m_actionEmptyRecycleBin;
|
||||
|
||||
return actions;
|
||||
@ -222,7 +222,8 @@ void FormMain::setupIcons() {
|
||||
|
||||
// Recycle bin.
|
||||
m_ui->m_actionEmptyRecycleBin->setIcon(icon_theme_factory->fromTheme("recycle-bin-empty"));
|
||||
m_ui->m_actionRestoreAllMessages->setIcon(icon_theme_factory->fromTheme("recycle-bin-restore"));
|
||||
m_ui->m_actionRestoreRecycleBin->setIcon(icon_theme_factory->fromTheme("recycle-bin-restore-all"));
|
||||
m_ui->m_actionRestoreSelectedMessagesFromRecycleBin->setIcon(icon_theme_factory->fromTheme("recycle-bin-restore-one"));
|
||||
|
||||
// Web browser.
|
||||
m_ui->m_actionAddBrowser->setIcon(icon_theme_factory->fromTheme("list-add"));
|
||||
|
@ -170,7 +170,8 @@
|
||||
<string>&Recycle bin</string>
|
||||
</property>
|
||||
<addaction name="m_actionEmptyRecycleBin"/>
|
||||
<addaction name="m_actionRestoreAllMessages"/>
|
||||
<addaction name="m_actionRestoreRecycleBin"/>
|
||||
<addaction name="m_actionRestoreSelectedMessagesFromRecycleBin"/>
|
||||
</widget>
|
||||
<addaction name="m_menuFile"/>
|
||||
<addaction name="m_menuView"/>
|
||||
@ -598,11 +599,16 @@
|
||||
<string>&Empty recycle bin</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionRestoreAllMessages">
|
||||
<action name="m_actionRestoreRecycleBin">
|
||||
<property name="text">
|
||||
<string>&Restore all messages</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionRestoreSelectedMessagesFromRecycleBin">
|
||||
<property name="text">
|
||||
<string>Restore &selected messages</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -155,7 +155,8 @@ void MessagesView::initializeContextMenu() {
|
||||
qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsRead <<
|
||||
qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsUnread <<
|
||||
qApp->mainForm()->m_ui->m_actionSwitchImportanceOfSelectedMessages <<
|
||||
qApp->mainForm()->m_ui->m_actionDeleteSelectedMessages);
|
||||
qApp->mainForm()->m_ui->m_actionDeleteSelectedMessages <<
|
||||
qApp->mainForm()->m_ui->m_actionRestoreSelectedMessagesFromRecycleBin);
|
||||
}
|
||||
|
||||
void MessagesView::mousePressEvent(QMouseEvent *event) {
|
||||
@ -357,6 +358,36 @@ void MessagesView::deleteSelectedMessages() {
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
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::switchSelectedMessagesImportance() {
|
||||
QModelIndex current_index = selectionModel()->currentIndex();
|
||||
|
||||
|
@ -74,6 +74,7 @@ class MessagesView : public QTreeView {
|
||||
void markSelectedMessagesUnread();
|
||||
void switchSelectedMessagesImportance();
|
||||
void deleteSelectedMessages();
|
||||
void restoreSelectedMessages();
|
||||
|
||||
void selectNextItem();
|
||||
void selectPreviousItem();
|
||||
|
Loading…
Reference in New Issue
Block a user