libyui-qt
QY2DiskUsageList.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: QY2DiskUsageList.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23  This is a pure Qt widget - it can be used independently of YaST2.
24 
25 /-*/
26 
27 
28 #ifndef QY2DiskUsageList_h
29 #define QY2DiskUsageList_h
30 
31 #include <QColor>
32 #include <yui/FSize.h>
33 
34 #include "QY2ListView.h"
35 
36 
38 
39 
44 {
45  Q_OBJECT
46 
47 public:
48 
55  QY2DiskUsageList( QWidget * parent, bool addStdColumns = true );
56 
60  virtual ~QY2DiskUsageList();
61 
62 
63  // Column numbers
64 
65  int nameCol() const { return _nameCol; }
66  int percentageBarCol() const { return _percentageBarCol; }
67  int usedSizeCol() const { return _usedSizeCol; }
68  int freeSizeCol() const { return _freeSizeCol; }
69  int totalSizeCol() const { return _totalSizeCol; }
70  int deviceNameCol() const { return _deviceNameCol; }
71 
72 
73  virtual void drawRow ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
74 
75  // make it public
76  QTreeWidgetItem * itemFromIndex ( const QModelIndex & index ) const
77  { return QY2ListView::itemFromIndex(index); }
78 
79 protected:
80 
81  int _nameCol;
82  int _percentageBarCol;
83  int _usedSizeCol;
84  int _freeSizeCol;
85  int _totalSizeCol;
86  int _deviceNameCol;
87 };
88 
89 
90 
98 {
99 protected:
109 
110 
114  virtual ~QY2DiskUsageListItem();
115 
116 
117 public:
118 
125  virtual FSize usedSize() const = 0;
126 
132  virtual FSize totalSize() const = 0;
133 
141  virtual FSize freeSize() const;
142 
150  virtual int usedPercent() const;
151 
159  virtual QString name() const = 0;
160 
167  virtual QString deviceName() const { return ""; }
168 
169 
176  virtual void updateStatus();
177 
184  virtual void updateData();
185 
190  void setText( int column, const QString & text )
191  { QTreeWidgetItem::setText( column, text ); }
192 
196  void setText( int column, const FSize & size );
197 
202  virtual bool operator< ( const QTreeWidgetItem & other ) const;
203 
204  // Columns
205 
206  int nameCol() const { return _diskUsageList->nameCol(); }
207  int percentageBarCol() const { return _diskUsageList->percentageBarCol(); }
208  int usedSizeCol() const { return _diskUsageList->usedSizeCol(); }
209  int freeSizeCol() const { return _diskUsageList->freeSizeCol(); }
210  int totalSizeCol() const { return _diskUsageList->totalSizeCol(); }
211  int deviceNameCol() const { return _diskUsageList->deviceNameCol(); }
212 
213 
214 protected:
215 
220  void init( bool allFields );
221 
222  public:
230  void paintPercentageBar( QPainter * painter,
231  QStyleOptionViewItem option,
232  const QColor & fillColor);
233 
234 protected:
235 
236 
237  //
238  // Data members
239  //
240 
241  QY2DiskUsageList * _diskUsageList;
242 };
243 
244 
245 
246 
247 #endif // ifndef QY2DiskUsageList_h
virtual FSize totalSize() const =0
QY2DiskUsageList(QWidget *parent, bool addStdColumns=true)
Definition: QY2DiskUsageList.cc:161
virtual FSize usedSize() const =0
virtual void updateStatus()
Definition: QY2DiskUsageList.cc:284
QY2DiskUsageListItem(QY2DiskUsageList *parent)
Definition: QY2DiskUsageList.cc:215
virtual QString deviceName() const
Definition: QY2DiskUsageList.h:167
virtual void updateData()
Definition: QY2DiskUsageList.cc:291
virtual QString name() const =0
Definition: QY2DiskUsageList.h:97
void init(bool allFields)
Definition: QY2DiskUsageList.cc:233
Definition: QY2DiskUsageList.h:43
virtual FSize freeSize() const
Definition: QY2DiskUsageList.cc:265
virtual int usedPercent() const
Definition: QY2DiskUsageList.cc:272
Enhanced QTreeWidget.
Definition: QY2ListView.h:47
void setText(int column, const QString &text)
Definition: QY2DiskUsageList.h:190
virtual ~QY2DiskUsageListItem()
Definition: QY2DiskUsageList.cc:224
void paintPercentageBar(QPainter *painter, QStyleOptionViewItem option, const QColor &fillColor)
Definition: QY2DiskUsageList.cc:338
Definition: QY2ListView.h:233
virtual ~QY2DiskUsageList()
Definition: QY2DiskUsageList.cc:201
virtual bool operator<(const QTreeWidgetItem &other) const
Definition: QY2DiskUsageList.cc:305