improved performance for face search -- some debugging required
[engrid-github.git] / src / libengrid / guivolumedelegate.cpp
blobf4042111e327897eb3f39d273cb04596aa603a7d
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008-2013 enGits GmbH +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 //
23 #include "guivolumedelegate.h"
25 #include <QComboBox>
26 #include <QtDebug>
28 void GuiVolumeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
30 if (index.column() >= first_column) {
31 QString text = index.model()->data(index, Qt::DisplayRole).toString();
32 QStyleOptionViewItem myOption = option;
33 myOption.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
34 drawDisplay(painter, myOption, myOption.rect, text);
35 drawFocus(painter, myOption, myOption.rect);
36 } else{
37 QItemDelegate::paint(painter, option, index);
41 QWidget *GuiVolumeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
43 if (index.column() >= first_column) {
44 QComboBox *comboBox = new QComboBox(parent);
45 comboBox->addItem("A <<");
46 comboBox->addItem(">> B");
47 comboBox->addItem(" ");
48 connect(comboBox, SIGNAL(currentIndexChanged ( int )), this, SLOT(commitAndCloseEditor()));
49 return comboBox;
50 } else {
51 return QItemDelegate::createEditor(parent, option, index);
55 void GuiVolumeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
57 if (index.column() >= first_column) {
58 int secs = index.model()->data(index, Qt::DisplayRole).toInt();
59 QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
60 comboBox->setCurrentIndex(secs);
61 } else {
62 QItemDelegate::setEditorData(editor, index);
66 void GuiVolumeDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
68 if (index.column() >= first_column) {
69 QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
70 model->setData(index, comboBox->currentText());
71 } else {
72 QItemDelegate::setModelData(editor, model, index);
76 void GuiVolumeDelegate::commitAndCloseEditor()
78 qDebug()<<"commitAndCloseEditor called";
79 QComboBox *editor = qobject_cast<QComboBox *>(sender());
80 emit commitData(editor);
81 emit closeEditor(editor);