2023-11-13 22:05:26 +00:00
|
|
|
/*
|
|
|
|
* Squawk messenger.
|
|
|
|
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
|
|
|
*
|
|
|
|
* 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 3 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2023-01-07 14:30:22 +00:00
|
|
|
|
|
|
|
#include <QStyledItemDelegate>
|
2023-01-08 15:16:41 +00:00
|
|
|
#include <QString>
|
2023-11-13 22:05:26 +00:00
|
|
|
|
2023-01-08 15:16:41 +00:00
|
|
|
#include <vector>
|
2023-01-07 14:30:22 +00:00
|
|
|
|
|
|
|
namespace UI {
|
|
|
|
|
2023-11-13 22:05:26 +00:00
|
|
|
class KeyDelegate : public QStyledItemDelegate {
|
|
|
|
Q_OBJECT
|
2023-01-07 14:30:22 +00:00
|
|
|
public:
|
2023-11-13 22:05:26 +00:00
|
|
|
KeyDelegate(QObject* parent = nullptr);
|
2023-01-07 14:30:22 +00:00
|
|
|
~KeyDelegate();
|
|
|
|
|
2023-11-13 22:05:26 +00:00
|
|
|
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
2023-01-07 14:30:22 +00:00
|
|
|
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
|
|
|
|
|
|
|
private:
|
2023-01-14 15:34:14 +00:00
|
|
|
const QFont& defaultFont;
|
2023-01-12 17:56:01 +00:00
|
|
|
const QFont& fingerPrintFont;
|
|
|
|
const QFont& labelFont;
|
2023-01-14 15:34:14 +00:00
|
|
|
const QFontMetrics& defaultMetrics;
|
2023-01-12 17:56:01 +00:00
|
|
|
const QFontMetrics& fingerPrintMetrics;
|
2023-01-14 15:34:14 +00:00
|
|
|
const QFontMetrics& labelMetrics;
|
2023-01-08 15:16:41 +00:00
|
|
|
int spaceWidth;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static std::vector<QString> getParts(const QByteArray& data);
|
2023-01-07 14:30:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|