[PATCH] MainTab: tweak the scrolling while inside the notes
Dirk Hohndel
dirk at hohndel.org
Fri Dec 13 07:14:59 UTC 2013
I know that Tomaz had a solution for this one as well, but I haven't
seen a patch from him, yet.
I want to make sure that we have the 'right' solution. Given that it's
so close before the release we'll have limited testing...
/D
On Fri, 2013-12-13 at 14:00 +0200, Lubomir I. Ivanov wrote:
> From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
>
> Patch makes a couple of changes:
> - if the notes receive focus set the 'inNotes' flag and scroll to the bottom
> of the tab widget
> - if 'inNotes' is set disable the mouse wheel for the entire widget except
> the notes
>
> This makes scrolling to the top of the notes not engage scrolling the
> entire tab widget.
>
> Fixes #176
>
> Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
> ---
> qt-ui/maintab.cpp | 17 ++++++++++++++++-
> qt-ui/maintab.h | 1 +
> 2 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
> index edc425b..654ce98 100644
> --- a/qt-ui/maintab.cpp
> +++ b/qt-ui/maintab.cpp
> @@ -28,7 +28,8 @@
> MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
> weightModel(new WeightModel()),
> cylindersModel(CylindersModel::instance()),
> - editMode(NONE)
> + editMode(NONE),
> + inNotes(false)
> {
> ui.setupUi(this);
> ui.cylinders->setModel(cylindersModel);
> @@ -57,6 +58,8 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
> ui.divemaster->installEventFilter(this);
> ui.buddy->installEventFilter(this);
> ui.suit->installEventFilter(this);
> + ui.scrollArea->installEventFilter(this);
> + ui.notes->installEventFilter(this);
> ui.notes->viewport()->installEventFilter(this);
> ui.rating->installEventFilter(this);
> ui.visibility->installEventFilter(this);
> @@ -281,6 +284,18 @@ void MainTab::enableEdition(EditMode newEditMode)
>
> bool MainTab::eventFilter(QObject* object, QEvent* event)
> {
> + // if the notes receive focus set the inNotes flag and scroll to the bottom
> + if (isEnabled() && object == ui.notes) {
> + if (event->type() == QEvent::FocusIn) {
> + inNotes = true;
> + ui.scrollArea->verticalScrollBar()->setSliderPosition(ui.scrollArea->verticalScrollBar()->maximum());
> + }
> + if (event->type() == QEvent::FocusOut)
> + inNotes = false;
> + }
> + // if in notes disable the mouse wheel
> + if (isEnabled() && event->type() == QEvent::Wheel && object != ui.notes->viewport() && inNotes)
> + return true;
> if (isEnabled() && event->type() == QEvent::KeyPress && object == ui.dateTimeEdit) {
> tabBar()->setTabIcon(currentIndex(), QIcon(":warning"));
> enableEdition();
> diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
> index aed8f9e..40b55a4 100644
> --- a/qt-ui/maintab.h
> +++ b/qt-ui/maintab.h
> @@ -94,6 +94,7 @@ private:
> CylindersModel *cylindersModel;
> QMap<dive*, NotesBackup> notesBackup;
> EditMode editMode;
> + bool inNotes;
>
> /* since the multi-edition of the equipment is fairly more
> * complex than a single item, because it involves a Qt
More information about the subsurface
mailing list