seems like i have found solution how to properly render buttons

This commit is contained in:
Blue 2021-02-02 01:55:15 +03:00
parent 00ffbac6b0
commit b3c6860e25
7 changed files with 196 additions and 41 deletions

View file

@ -19,13 +19,21 @@
#ifndef MESSAGEDELEGATE_H
#define MESSAGEDELEGATE_H
#include <map>
#include <set>
#include <QStyledItemDelegate>
#include <QStyleOptionButton>
#include <QFont>
#include <QFontMetrics>
#include <QPushButton>
#include "shared/icons.h"
namespace Models {
struct FeedItem;
};
class MessageDelegate : public QStyledItemDelegate
{
Q_OBJECT
@ -39,8 +47,20 @@ public:
void initializeFonts(const QFont& font);
bool editorEvent(QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index) override;
void endClearWidgets();
void beginClearWidgets();
protected:
void paintButton(QPushButton* btn, QPainter* painter, bool sentByMe, QStyleOptionViewItem& option) const;
QPushButton* getButton(const Models::FeedItem& data) const;
private:
class FeedButton : public QPushButton {
public:
QString messageId;
bool download;
};
QFont bodyFont;
QFont nickFont;
QFont dateFont;
@ -48,8 +68,11 @@ private:
QFontMetrics nickMetrics;
QFontMetrics dateMetrics;
QPushButton* downloadButton;
QPushButton* uploadButton;
int buttonHeight;
std::map<QString, FeedButton*>* buttons;
std::set<QString>* idsToKeep;
bool clearingWidgets;
};
#endif // MESSAGEDELEGATE_H