nextcloud-desktop/src/gui/tooltipupdater.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.5 KiB
C
Raw Normal View History

/*
* 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; either version 2 of the License, or
* (at your option) any later version.
*
* 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;
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