pgLab/pglab/IconColumnDelegate.h
eelke 42432b06a9 Restructuring catalog tabs
- Moved detail tabs of table to their own components
- Table list has become seperate component on seperate tab
- Table list does not use designer anymore
- Moved sequences and functions tabs into the catalog inspector
2019-02-09 11:36:22 +01:00

29 lines
811 B
C++

#ifndef ICONCOLUMNDELEGATE_H
#define ICONCOLUMNDELEGATE_H
#include <QStyledItemDelegate>
#include <map>
/** This class asumes that the string values supplies for the column data
* can be Resolved by QIcon to an actual icon. Icons are cached and reused.
*
*/
class IconColumnDelegate: public QStyledItemDelegate {
public:
IconColumnDelegate(QWidget *parent = nullptr);
~IconColumnDelegate() override;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
void clearCache();
private:
using t_IconCache = std::map<QString, QIcon*>;
mutable t_IconCache m_Icons;
QIcon* getIcon(const QString &name) const;
};
#endif // ICONCOLUMNDELEGATE_H