2016-01-21 13:32:27 +03:00
|
|
|
/*
|
|
|
|
* 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
|
2016-10-25 12:00:07 +03:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2016-01-21 13:32:27 +03:00
|
|
|
*
|
|
|
|
* 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;
|
2016-03-30 10:21:28 +03:00
|
|
|
class QModelIndex;
|
2016-01-21 13:32:27 +03:00
|
|
|
|
|
|
|
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
|