diff options
author | Christian Kamm <mail@ckamm.de> | 2016-01-21 13:32:27 +0300 |
---|---|---|
committer | Christian Kamm <mail@ckamm.de> | 2016-03-29 13:26:09 +0300 |
commit | 10a7128d1aac7549b9f5b59f6f4aa7b6c1a3c321 (patch) | |
tree | 530d75d5658ad1d9abbc1898c50a056bcf090885 /src/gui/tooltipupdater.h | |
parent | 41f43feecf36a4ebbdf8c74904f875a94a77e6e5 (diff) |
Update QTreeView tooltips as they change #3403
Diffstat (limited to 'src/gui/tooltipupdater.h')
-rw-r--r-- | src/gui/tooltipupdater.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/gui/tooltipupdater.h b/src/gui/tooltipupdater.h new file mode 100644 index 000000000..ae32882d4 --- /dev/null +++ b/src/gui/tooltipupdater.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) by Christian Kamm <mail@ckamm.de> + * + * 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; version 2 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. + */ + +#include <QObject> +#include <QPoint> + +class QTreeView; + +namespace OCC { + +/** + * @brief Updates tooltips of items in a QTreeView when they change. + * @ingroup gui + * + * Usually tooltips are not updated as they change. Since we want to + * use tooltips to show rapidly updating progress information, we + * need to make sure that that information is displayed to the user + * as it changes. + * + * To accomplish that, the eventFilter() stores the tooltip's position + * and the dataChanged() slot updates the tooltip if Qt::ToolTipRole + * gets updated while a tooltip is shown. + */ +class ToolTipUpdater : public QObject +{ + Q_OBJECT +public: + ToolTipUpdater(QTreeView* treeView); + +protected: + bool eventFilter(QObject* obj, QEvent* ev) Q_DECL_OVERRIDE; + +private slots: + void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles); + +private: + QTreeView* _treeView; + QPoint _toolTipPos; +}; + +} // namespace OCC |