1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/***************************************************************************
* Copyright (C) 2015 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef LISTWIDGETDRAWER_H
#define LISTWIDGETDRAWER_H
#include <QString>
#include <QColor>
#include <QRect>
#include <QFontMetrics>
class Skin;
class QPainter;
struct ListWidgetRow
{
ListWidgetRow()
{
flags = NO_FLAGS;
}
QString title;
QString length;
QString extraString;
int number;
enum
{
NO_FLAGS = 0x00,
GROUP = 0x01,
SELECTED = 0x02,
CURRENT = 0x04,
ANCHOR = 0x08
};
int flags;
enum
{
NUMBER = 0,
TITLE,
EXTRA_STRING,
LENGTH
};
int x[LENGTH + 1];
QRect rect; //geometry
};
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
*/
class ListWidgetDrawer
{
public:
ListWidgetDrawer();
~ListWidgetDrawer();
void readSettings();
void loadColors();
int rowHeight() const;
void calculateNumberWidth(int count);
void prepareRow(ListWidgetRow *row);
void fillBackground(QPainter *painter, int width, int height);
void drawBackground(QPainter *painter, ListWidgetRow *row);
void drawSeparator(QPainter *painter, ListWidgetRow *row, bool rtl);
void drawTrack(QPainter *painter, ListWidgetRow *row);
void drawDropLine(QPainter *painter, int row_number, int width);
void drawVerticalLine(QPainter *painter, int row_count, int width, bool rtl);
private:
QColor m_normal, m_current, m_normal_bg, m_selected_bg;
Skin *m_skin;
QFontMetrics *m_metrics;
QFontMetrics *m_extra_metrics;
QFont m_font, m_extra_font;
bool m_update;
bool m_show_number;
bool m_show_anchor;
bool m_align_numbres;
int m_number_width;
int m_row_height;
};
#endif // LISTWIDGETDRAWER_H
|