2 * This file is part of Jenirok.
4 * Jenirok is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Jenirok is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Jenirok. If not, see <http://www.gnu.org/licenses/>.
19 #include <QtGui/QHeaderView>
20 #include <QtCore/QDebug>
21 #include "listwidget.h"
23 ListWidget::ListWidget(QWidget* parent): QTableWidget(parent)
25 connect(this, SIGNAL(cellClicked(int, int)), this, SLOT(handleClick(int)));
27 verticalHeader()->hide();
28 horizontalHeader()->hide();
29 setColumnWidth(0, 800);
30 setSelectionMode(QAbstractItemView::SingleSelection);
33 void ListWidget::addWidget(QWidget* widget, QVariant const& data)
37 setCellWidget(row, 0, widget);
39 widgets_[row] = widget;
40 resizeRowToContents (row);
43 QVariant ListWidget::getData(int index) const
45 if(data_.find(index) != data_.end())
53 QWidget* ListWidget::getWidget(int index) const
55 if(widgets_.find(index) != widgets_.end())
57 return widgets_[index];
63 void ListWidget::clear()
65 QTableWidget::clear();
71 void ListWidget::handleClick(int index)
74 emit itemClicked(index);