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 #include <QApplication>
25 #include <QPainter>
26 #include <QProgressBar>
27 
28 namespace armarx
29 {
30  void ProgressbarDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
31  {
32  if (index.column() == 3)
33  {
34  int progress = index.data().toInt();
35 
36  QStyleOptionProgressBar progressBarOption;
37  progressBarOption.rect = option.rect;
38  progressBarOption.minimum = 0;
39  progressBarOption.maximum = 100;
40  progressBarOption.progress = progress;
41  progressBarOption.text = QString::number(progress) + "%";
42  progressBarOption.textVisible = true;
43  QApplication::style()->drawControl(QStyle::CE_ProgressBar,
44  &progressBarOption, painter);
45 
46  // QProgressBar renderer;
47  // int progressPercentage = index.model()->data(index, Qt::DisplayRole).toInt();
48 
49  // // Customize style using style-sheet..
50 
51  // QString style = "";
52  // style += "QProgressBar::chunk { background-color: #"+QString::number((int)(255*0.01*progressPercentage), 16,2)+"0000; }";
53 
54  // renderer.resize(option.rect.size());
55  // renderer.setMinimum(0);
56  // renderer.setMaximum(100);
57  // renderer.setValue(progressPercentage);
58 
59  // renderer.setStyleSheet(style);
60  // painter->save();
61  // painter->translate(option.rect.topLeft());
62  // renderer.render(painter);
63  // painter->restore();
64  }
65  else
66  {
67  QStyledItemDelegate::paint(painter, option, index);
68  }
69  }
70 }
index
uint8_t index
Definition: EtherCATFrame.h:59
option
#define option(type, fn)
ProgressbarDelegate.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28