[kde-doc-english] [trojita] src/Gui: GUI: manage the enabled state of buttons which modify the message flags
Jan Kundrát
jkt at flaska.net
Wed Aug 21 21:46:31 UTC 2013
Git commit 2c563d108a3ff536a27196fbfe96d95e3360e8b1 by Jan Kundrát.
Committed on 21/08/2013 at 08:28.
Pushed by jkt into branch 'master'.
GUI: manage the enabled state of buttons which modify the message flags
BUG: 320618
M +12 -2 src/Gui/Window.cpp
http://commits.kde.org/trojita/2c563d108a3ff536a27196fbfe96d95e3360e8b1
diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index c435fdb..800a49e 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -467,6 +467,8 @@ void MainWindow::createActions()
m_mainToolbar->addSeparator();
m_mainToolbar->addAction(showMenuBar);
m_mainToolbar->addAction(configSettings);
+
+ updateMessageFlags();
}
void MainWindow::connectModelActions()
@@ -715,8 +717,11 @@ void MainWindow::setupModels()
connect(msgListModel, SIGNAL(messagesAvailable()), msgListWidget->tree, SLOT(scrollToBottom()));
connect(msgListModel, SIGNAL(rowsInserted(QModelIndex,int,int)), msgListWidget, SLOT(slotAutoEnableDisableSearch()));
connect(msgListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), msgListWidget, SLOT(slotAutoEnableDisableSearch()));
+ connect(msgListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(updateMessageFlags()));
connect(msgListModel, SIGNAL(layoutChanged()), msgListWidget, SLOT(slotAutoEnableDisableSearch()));
+ connect(msgListModel, SIGNAL(layoutChanged()), this, SLOT(updateMessageFlags()));
connect(msgListModel, SIGNAL(modelReset()), msgListWidget, SLOT(slotAutoEnableDisableSearch()));
+ connect(msgListModel, SIGNAL(modelReset()), this, SLOT(updateMessageFlags()));
connect(msgListModel, SIGNAL(mailboxChanged(QModelIndex)), this, SLOT(slotMailboxChanged(QModelIndex)));
connect(model, SIGNAL(alertReceived(const QString &)), this, SLOT(alertReceived(const QString &)));
@@ -1446,8 +1451,11 @@ void MainWindow::updateMessageFlags()
void MainWindow::updateMessageFlags(const QModelIndex &index)
{
- markAsRead->setChecked(index.data(Imap::Mailbox::RoleMessageIsMarkedRead).toBool());
- markAsDeleted->setChecked(index.data(Imap::Mailbox::RoleMessageIsMarkedDeleted).toBool());
+ bool okToModify = model->isNetworkAvailable() && index.isValid() && index.data(Imap::Mailbox::RoleMessageUid).toUInt() > 0;
+ markAsRead->setEnabled(okToModify);
+ markAsDeleted->setEnabled(okToModify);
+ markAsRead->setChecked(okToModify && index.data(Imap::Mailbox::RoleMessageIsMarkedRead).toBool());
+ markAsDeleted->setChecked(okToModify && index.data(Imap::Mailbox::RoleMessageIsMarkedDeleted).toBool());
}
void MainWindow::updateActionsOnlineOffline(bool online)
@@ -1652,6 +1660,8 @@ void MainWindow::slotMailboxChanged(const QModelIndex &mailbox)
tree->showColumn(MsgListModel::FROM);
}
}
+
+ updateMessageFlags();
}
void MainWindow::showConnectionStatus(QObject *parser, Imap::ConnectionState state)
More information about the kde-doc-english
mailing list