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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
/*
*
* $Id: k3blistview.h 619556 2007-01-03 17:38:12Z trueg $
* Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#ifndef K3BLISTVIEW_H
#define K3BLISTVIEW_H
#include <klistview.h>
#include "k3b_export.h"
#include <qptrvector.h>
#include <qptrlist.h>
#include <qstringlist.h>
#include <kpixmap.h>
class QPainter;
class QPushButton;
class QIconSet;
class QResizeEvent;
class QComboBox;
class QSpinBox;
class QLineEdit;
class QEvent;
class QValidator;
class K3bMsfEdit;
class K3bListView;
class LIBK3B_EXPORT K3bListViewItem : public KListViewItem
{
public:
K3bListViewItem(QListView *parent);
K3bListViewItem(QListViewItem *parent);
K3bListViewItem(QListView *parent, QListViewItem *after);
K3bListViewItem(QListViewItem *parent, QListViewItem *after);
K3bListViewItem(QListView *parent,
const QString&, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null);
K3bListViewItem(QListViewItem *parent,
const QString&, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null);
K3bListViewItem(QListView *parent, QListViewItem *after,
const QString&, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null);
K3bListViewItem(QListViewItem *parent, QListViewItem *after,
const QString&, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null,
const QString& = QString::null, const QString& = QString::null);
virtual ~K3bListViewItem();
/**
* reimplemented from KListViewItem
*/
void setup();
virtual int width( const QFontMetrics& fm, const QListView* lv, int c ) const;
void setEditor( int col, int type, const QStringList& = QStringList() );
void setButton( int col, bool );
void setValidator( int col, QValidator* v );
QValidator* validator( int col ) const;
int editorType( int col ) const;
bool needButton( int col ) const;
const QStringList& comboStrings( int col ) const;
enum EditorType { NONE, COMBO, LINE, SPIN, MSF };
void setFont( int col, const QFont& f );
void setBackgroundColor( int col, const QColor& );
void setForegroundColor( int col, const QColor& );
void setDisplayProgressBar( int col, bool );
void setProgress( int, int );
void setTotalSteps( int col, int steps );
/**
* The margin left and right of the cell
*/
void setMarginHorizontal( int col, int margin );
/**
* The top and button margin of the cell
*/
void setMarginVertical( int margin );
int marginHorizontal( int col ) const;
int marginVertical() const;
/**
* Do not reimplement this but paintK3bCell to use the margin and background stuff.
*/
virtual void paintCell( QPainter* p, const QColorGroup& cg, int col, int width, int align );
virtual void paintK3bCell( QPainter* p, const QColorGroup& cg, int col, int width, int align );
private:
void paintProgressBar( QPainter* p, const QColorGroup& cgh, int col, int width );
class ColumnInfo;
mutable ColumnInfo* m_columns;
ColumnInfo* getColumnInfo( int ) const;
void init();
int m_vMargin;
};
class LIBK3B_EXPORT K3bCheckListViewItem : public K3bListViewItem
{
public:
K3bCheckListViewItem(QListView *parent);
K3bCheckListViewItem(QListViewItem *parent);
K3bCheckListViewItem(QListView *parent, QListViewItem *after);
K3bCheckListViewItem(QListViewItem *parent, QListViewItem *after);
virtual bool isChecked() const;
virtual void setChecked( bool checked );
protected:
virtual void paintK3bCell( QPainter* p, const QColorGroup& cg, int col, int width, int align );
private:
bool m_checked;
};
class LIBK3B_EXPORT K3bListView : public KListView
{
friend class K3bListViewItem;
Q_OBJECT
public:
K3bListView (QWidget *parent = 0, const char *name = 0);
virtual ~K3bListView();
virtual void setCurrentItem( QListViewItem* );
K3bListViewItem* currentlyEditedItem() const { return m_currentEditItem; }
QWidget* editor( K3bListViewItem::EditorType ) const;
enum BgPixPosition {
TOP_LEFT,
CENTER
};
/**
* This will set a background pixmap which is not tiled.
* @param pos position on the viewport.
*/
void setK3bBackgroundPixmap( const QPixmap&, int pos = CENTER );
/**
* Create a faded pixmap showing the items.
*/
KPixmap createDragPixmap( const QPtrList<QListViewItem>& items );
/**
* Searches for the first item above @p i which is one level higher.
* For 1st level items this will always be the listview's root item.
*/
static QListViewItem* parentItem( QListViewItem* i );
signals:
void editorButtonClicked( K3bListViewItem*, int );
public slots:
void setNoItemText( const QString& );
// void setNoItemPixmap( const QPixmap& );
void setNoItemVerticalMargin( int i ) { m_noItemVMargin = i; }
void setNoItemHorizontalMargin( int i ) { m_noItemHMargin = i; }
void setDoubleClickForEdit( bool b ) { m_doubleClickForEdit = b; }
void hideEditor();
void editItem( K3bListViewItem*, int );
virtual void clear();
private slots:
void updateEditorSize();
virtual void slotEditorLineEditReturnPressed();
virtual void slotEditorComboBoxActivated( const QString& );
virtual void slotEditorSpinBoxValueChanged( int );
virtual void slotEditorMsfEditValueChanged( int );
virtual void slotEditorButtonClicked();
protected slots:
void showEditor( K3bListViewItem*, int col );
void placeEditor( K3bListViewItem*, int col );
/**
* This is called whenever one of the editor's contents changes
* the default implementation just returnes true
*
* FIXME: should be called something like mayRename
*/
virtual bool renameItem( K3bListViewItem*, int, const QString& );
/**
* default impl just emits signal
* editorButtonClicked(...)
*/
virtual void slotEditorButtonClicked( K3bListViewItem*, int );
protected:
/**
* calls KListView::drawContentsOffset
* and paints a the noItemText if no item is in the list
*/
virtual void drawContentsOffset ( QPainter * p, int ox, int oy, int cx, int cy, int cw, int ch );
virtual void resizeEvent( QResizeEvent* );
virtual void paintEmptyArea( QPainter*, const QRect& rect );
/**
* Reimplemented for internal reasons.
*
* Further reimplementations should call this function or else some features may not work correctly.
*
* The API is unaffected.
*/
virtual void viewportResizeEvent( QResizeEvent* );
/**
* Reimplemented for internal reasons.
* Further reimplementations should call this function or else
* some features may not work correctly.
*
* The API is unaffected.
*/
virtual void viewportPaintEvent(QPaintEvent*);
virtual bool eventFilter( QObject*, QEvent* );
K3bListViewItem* currentEditItem() const { return m_currentEditItem; }
int currentEditColumn() const { return m_currentEditColumn; }
private:
QWidget* prepareEditor( K3bListViewItem* item, int col );
void prepareButton( K3bListViewItem* item, int col );
bool doRename();
QString m_noItemText;
// QPixmap m_noItemPixmap;
int m_noItemVMargin;
int m_noItemHMargin;
K3bListViewItem* m_currentEditItem;
int m_currentEditColumn;
bool m_doubleClickForEdit;
QListViewItem* m_lastClickedItem;
QPushButton* m_editorButton;
QComboBox* m_editorComboBox;
QSpinBox* m_editorSpinBox;
QLineEdit* m_editorLineEdit;
K3bMsfEdit* m_editorMsfEdit;
QPixmap m_backgroundPixmap;
int m_backgroundPixmapPosition;
class Private;
Private* d;
};
#endif
|