[kde-doc-english] [trojita] src/Gui: GUI: do not "load" messages when the viewer is not visible
Jan Kundrát
jkt at flaska.net
Mon Jun 17 10:34:38 UTC 2013
Git commit ad0e7e3059c5d68c59e8cc50a7fc35c8da16ff23 by Jan Kundrát.
Committed on 12/06/2013 at 18:15.
Pushed by jkt into branch 'master'.
GUI: do not "load" messages when the viewer is not visible
The idea is to save bandwidth (and prevent marking message as read) when the
message pane is not shown.
Thanks to Vayu <vayu at sklinks.com> on the ML for his suggestion.
Thomas Lübking also provided a better way of checking the sizing and suggested
loading the current message when the widget comes back into view.
REVIEW: 110978
M +21 -1 src/Gui/Window.cpp
M +1 -0 src/Gui/Window.h
http://commits.kde.org/trojita/ad0e7e3059c5d68c59e8cc50a7fc35c8da16ff23
diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index 0da14bb..6ce7cbc 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -882,7 +882,10 @@ void MainWindow::msgListClicked(const QModelIndex &index)
Imap::Mailbox::FLAG_REMOVE : Imap::Mailbox::FLAG_ADD;
model->markMessagesRead(QModelIndexList() << translated, flagOp);
} else {
- m_messageWidget->messageView->setMessage(index);
+ if (m_messageWidget->isVisible() && !m_messageWidget->size().isEmpty()) {
+ // isVisible() won't work, the splitter manipulates width, not the visibility state
+ m_messageWidget->messageView->setMessage(index);
+ }
msgListWidget->tree->setCurrentIndex(index);
}
}
@@ -2069,11 +2072,13 @@ void MainWindow::slotLayoutCompact()
if (!m_mainHSplitter) {
m_mainHSplitter = new QSplitter();
connect(m_mainHSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(saveSizesAndState()));
+ connect(m_mainHSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(possiblyLoadMessageOnSplittersChanged()));
}
if (!m_mainVSplitter) {
m_mainVSplitter = new QSplitter();
m_mainVSplitter->setOrientation(Qt::Vertical);
connect(m_mainVSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(saveSizesAndState()));
+ connect(m_mainVSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(possiblyLoadMessageOnSplittersChanged()));
}
m_mainVSplitter->addWidget(msgListWidget);
@@ -2108,6 +2113,7 @@ void MainWindow::slotLayoutWide()
if (!m_mainHSplitter) {
m_mainHSplitter = new QSplitter();
connect(m_mainHSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(saveSizesAndState()));
+ connect(m_mainHSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(possiblyLoadMessageOnSplittersChanged()));
}
m_mainHSplitter->addWidget(mboxTree);
@@ -2297,4 +2303,18 @@ void MainWindow::resizeEvent(QResizeEvent *)
saveSizesAndState();
}
+/** @short Make sure that the message gets loaded after the splitters have changed their position */
+void MainWindow::possiblyLoadMessageOnSplittersChanged()
+{
+ if (m_messageWidget->isVisible() && !m_messageWidget->size().isEmpty()) {
+ // We do not have to check whether it's a different message; the setMessage() will do this or us
+ // and there are multiple proxy models involved anyway
+ QModelIndex index = msgListWidget->tree->currentIndex();
+ if (index.isValid()) {
+ // OTOH, setting an invalid QModelIndex would happily assert-fail
+ m_messageWidget->messageView->setMessage(msgListWidget->tree->currentIndex());
+ }
+ }
+}
+
}
diff --git a/src/Gui/Window.h b/src/Gui/Window.h
index 5620860..ffb1f5e 100644
--- a/src/Gui/Window.h
+++ b/src/Gui/Window.h
@@ -175,6 +175,7 @@ private slots:
void slotLayoutWide();
void slotLayoutOneAtTime();
void saveSizesAndState();
+ void possiblyLoadMessageOnSplittersChanged();
void desktopGeometryChanged();
More information about the kde-doc-english
mailing list