[kde-doc-english] [trojita] src/Gui: GUI: don't auto-advance to the message view when within the one-at-time layout

Jan Kundrát jkt at flaska.net
Sun May 26 23:39:49 UTC 2013


Git commit c868147fb7189b468f04440eaf1903bc114b9e44 by Jan Kundrát.
Committed on 26/05/2013 at 19:39.
Pushed by jkt into branch 'master'.

GUI: don't auto-advance to the message view when within the one-at-time layout

M  +7    -2    src/Gui/MsgListView.cpp
M  +2    -0    src/Gui/MsgListView.h
M  +4    -0    src/Gui/Window.cpp

http://commits.kde.org/trojita/c868147fb7189b468f04440eaf1903bc114b9e44

diff --git a/src/Gui/MsgListView.cpp b/src/Gui/MsgListView.cpp
index 860fb78..2295fd3 100644
--- a/src/Gui/MsgListView.cpp
+++ b/src/Gui/MsgListView.cpp
@@ -37,7 +37,7 @@
 namespace Gui
 {
 
-MsgListView::MsgListView(QWidget *parent): QTreeView(parent)
+MsgListView::MsgListView(QWidget *parent): QTreeView(parent), m_autoActivateAfterKeyNavigation(true)
 {
     connect(header(), SIGNAL(geometriesChanged()), this, SLOT(slotFixSize()));
     connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(slotExpandWholeSubtree(QModelIndex)));
@@ -93,7 +93,7 @@ void MsgListView::keyReleaseEvent(QKeyEvent *ke)
 
 void MsgListView::slotCurrentActivated()
 {
-    if (currentIndex().isValid())
+    if (currentIndex().isValid() && m_autoActivateAfterKeyNavigation)
         emit activated(currentIndex());
 }
 
@@ -356,6 +356,11 @@ Imap::Mailbox::PrettyMsgListModel *MsgListView::findPrettyMsgListModel(QAbstract
     return 0;
 }
 
+void MsgListView::setAutoActivateAfterKeyNavigation(bool enabled)
+{
+    m_autoActivateAfterKeyNavigation = enabled;
+}
+
 }
 
 
diff --git a/src/Gui/MsgListView.h b/src/Gui/MsgListView.h
index 97f91b7..426d84a 100644
--- a/src/Gui/MsgListView.h
+++ b/src/Gui/MsgListView.h
@@ -48,6 +48,7 @@ public:
     explicit MsgListView(QWidget *parent=0);
     virtual ~MsgListView() {}
     void setModel(QAbstractItemModel *model);
+    void setAutoActivateAfterKeyNavigation(bool enabled);
 protected:
     void keyPressEvent(QKeyEvent *ke);
     void keyReleaseEvent(QKeyEvent *ke);
@@ -70,6 +71,7 @@ private:
 
     QSignalMapper *headerFieldsMapper;
     QTimer *m_naviActivationTimer;
+    bool m_autoActivateAfterKeyNavigation;
 };
 
 }
diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index cef7c27..4fa609c 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -1924,6 +1924,9 @@ void MainWindow::slotLayoutWide()
 void MainWindow::slotLayoutOneAtTime()
 {
     slotLayoutCompact();
+    // The list view is configured to auto-emit activated(QModelIndex) after a short while when the user has navigated
+    // to an index through keyboard. Of course, this doesn't play terribly well with this layout.
+    msgListWidget->tree->setAutoActivateAfterKeyNavigation(false);
     m_mainVSplitter->hide();
     connect(msgListWidget->tree, SIGNAL(clicked(QModelIndex)), this, SLOT(slotOneAtTimeMessagesToOne()));
     connect(msgListWidget->tree, SIGNAL(activated(QModelIndex)), this, SLOT(slotOneAtTimeMessagesToOne()));
@@ -1935,6 +1938,7 @@ void MainWindow::slotLayoutOneAtTime()
 
 void MainWindow::undoOneAtTimeLayout()
 {
+    msgListWidget->tree->setAutoActivateAfterKeyNavigation(true);
     disconnect(msgListWidget->tree, SIGNAL(clicked(QModelIndex)), this, SLOT(slotOneAtTimeMessagesToOne()));
     disconnect(msgListWidget->tree, SIGNAL(activated(QModelIndex)), this, SLOT(slotOneAtTimeMessagesToOne()));
     disconnect(mboxTree, SIGNAL(clicked(QModelIndex)), this, SLOT(slotOneAtTimeMailboxesToMessages()));



More information about the kde-doc-english mailing list