Hi Thomas/Thomas,
there's a bug in how the header view works (right-click on any message in the
MsgListView and select "View Message Headers.." to invoke the viewer). When I
resize the newly appearing window, no scrollbars are shown and the wheel events
take no effect -- this is due to the missing call to installEventFilter,
similar to how it's done in the MessageView case.
Unfortunately, I wasn't able to fix that myself, even though I tried (see the
patch for how I tried to tackle this down; it's basically a copy-paste from the
MessageView's eventFilter() impelmentation changed not to call QWidget::event
as that's a protected method). If some of you has some spare time, I'll be
happy to receive a patch fixing this hiccup.
With kind regards,
Jan
diff --git a/src/Gui/Gui.pro b/src/Gui/Gui.pro
index 5adaf48..81403c0 100644
--- a/src/Gui/Gui.pro
+++ b/src/Gui/Gui.pro
@@ -39,7 +39,8 @@ SOURCES += \
TagWidget.cpp \
UserAgentWebPage.cpp \
MessageListWidget.cpp \
- MailBoxTreeView.cpp
+ MailBoxTreeView.cpp \
+ ScrollEventForwarder.cpp
HEADERS += \
../Imap/Model/ModelTest/modeltest.h \
ComposeWidget.h \
@@ -66,7 +67,8 @@ HEADERS += \
TagWidget.h \
UserAgentWebPage.h \
MessageListWidget.h \
- MailBoxTreeView.h
+ MailBoxTreeView.h \
+ ScrollEventForwarder.h
FORMS += CreateMailboxDialog.ui \
ComposeWidget.ui \
SettingsImapPage.ui \
diff --git a/src/Gui/ScrollEventForwarder.cpp b/src/Gui/ScrollEventForwarder.cpp
new file mode 100644
index 0000000..02e73d6
--- /dev/null
+++ b/src/Gui/ScrollEventForwarder.cpp
@@ -0,0 +1,66 @@
+/* Copyright (C) 2006 - 2012 Jan Kundrát <[email protected]>
+
+ This file is part of the Trojita Qt IMAP e-mail client,
+ http://trojita.flaska.net/
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or the version 3 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <QCoreApplication>
+#include <QKeyEvent>
+#include <QWidget>
+#include "ScrollEventForwarder.h"
+
+#include <QDebug>
+
+namespace Gui
+{
+
+ScrollEventForwarder::ScrollEventForwarder(QWidget *targetOfEvents):
+ QObject(targetOfEvents), m_target(targetOfEvents)
+{
+}
+
+bool ScrollEventForwarder::eventFilter(QObject *object, QEvent *event)
+{
+ if (event->type() == QEvent::Wheel) {
+ qDebug() << Q_FUNC_INFO << "WHEEL";
+ return qApp->notify(m_target, event);
+ } else if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ switch (keyEvent->key()) {
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_PageUp:
+ case Qt::Key_PageDown:
+ case Qt::Key_Home:
+ case Qt::Key_End:
+ qDebug() << Q_FUNC_INFO << "KEY";
+ return qApp->notify(m_target, event);
+ default:
+ return QObject::eventFilter(object, event);
+ }
+ } else {
+ return QObject::eventFilter(object, event);
+ }
+}
+
+}
+
+
+
diff --git a/src/Gui/ScrollEventForwarder.h b/src/Gui/ScrollEventForwarder.h
new file mode 100644
index 0000000..385fbae
--- /dev/null
+++ b/src/Gui/ScrollEventForwarder.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 2006 - 2012 Jan Kundrát <[email protected]>
+
+ This file is part of the Trojita Qt IMAP e-mail client,
+ http://trojita.flaska.net/
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or the version 3 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef GUI_SCROLLEVENTFORWARDER_H
+#define GUI_SCROLLEVENTFORWARDER_H
+
+#include <QObject>
+
+namespace Gui
+{
+
+/** @short An event filter passing any "let's move the contents" event to another object */
+class ScrollEventForwarder : public QObject
+{
+ Q_OBJECT
+public:
+ ScrollEventForwarder(QWidget *targetOfEvents);
+private:
+ bool eventFilter(QObject *object, QEvent *event);
+
+ QWidget *m_target;
+};
+
+}
+
+#endif // GUI_SCROLLEVENTFORWARDER_H
diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index 2e4d08c..872a3ab 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -61,6 +61,7 @@
#include "MessageView.h"
#include "MsgListView.h"
#include "ProtocolLoggerWidget.h"
+#include "ScrollEventForwarder.h"
#include "SettingsDialog.h"
#include "SimplePartWidget.h"
#include "Streams/SocketFactory.h"
@@ -1269,11 +1270,13 @@ void MainWindow::slotViewMsgHeaders()
netAccess->setModelMessage(messageIndex);
QScrollArea *area = new QScrollArea();
+ ScrollEventForwarder *forwarder = new ScrollEventForwarder(area);
area->setWidgetResizable(true);
SimplePartWidget *headers = new SimplePartWidget(0, netAccess,
messageIndex.model()->index(
0, Imap::Mailbox::TreeItem::OFFSET_HEADER, messageIndex)
);
+ headers->installEventFilter(forwarder);
area->setWidget(headers);
area->setAttribute(Qt::WA_DeleteOnClose);
connect(area, SIGNAL(destroyed()), headers, SLOT(deleteLater()));