ProgressbarDelegate.cpp
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @package ArmarX::
17* @author Mirko Waechter ( mirko.waechter at kit dot edu)
18* @date 2013
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23#include "ProgressbarDelegate.h"
24
25#include <QApplication>
26#include <QPainter>
27#include <QProgressBar>
28
29namespace armarx
30{
31 void
32 ProgressbarDelegate::paint(QPainter* painter,
33 const QStyleOptionViewItem& option,
34 const QModelIndex& index) const
35 {
36 if (index.column() == 3)
37 {
38 int progress = index.data().toInt();
39
40 QStyleOptionProgressBar progressBarOption;
41 progressBarOption.rect = option.rect;
42 progressBarOption.minimum = 0;
43 progressBarOption.maximum = 100;
44 progressBarOption.progress = progress;
45 progressBarOption.text = QString::number(progress) + "%";
46 progressBarOption.textVisible = true;
47 QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter);
48
49 // QProgressBar renderer;
50 // int progressPercentage = index.model()->data(index, Qt::DisplayRole).toInt();
51
52 // // Customize style using style-sheet..
53
54 // QString style = "";
55 // style += "QProgressBar::chunk { background-color: #"+QString::number((int)(255*0.01*progressPercentage), 16,2)+"0000; }";
56
57 // renderer.resize(option.rect.size());
58 // renderer.setMinimum(0);
59 // renderer.setMaximum(100);
60 // renderer.setValue(progressPercentage);
61
62 // renderer.setStyleSheet(style);
63 // painter->save();
64 // painter->translate(option.rect.topLeft());
65 // renderer.render(painter);
66 // painter->restore();
67 }
68 else
69 {
70 QStyledItemDelegate::paint(painter, option, index);
71 }
72 }
73} // namespace armarx
uint8_t index
#define option(type, fn)
This file offers overloads of toIce() and fromIce() functions for STL container types.