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/QApplication>
20 #include <QtGui/QDesktopWidget>
21 #include <QtGui/QHeaderView>
22 #include <QtCore/QDebug>
23 #include "listwidget.h"
25 ListWidget::ListWidget(QWidget* parent): QTableWidget(parent)
27 connect(this, SIGNAL(cellClicked(int, int)), this, SLOT(handleClick(int)));
29 verticalHeader()->hide();
30 horizontalHeader()->hide();
31 setColumnWidth(0, QApplication::desktop()->availableGeometry().width());
32 setSelectionMode(QAbstractItemView::SingleSelection);
35 void ListWidget::addWidget(QWidget* widget, QVariant const& data)
39 setCellWidget(row, 0, widget);
41 widgets_[row] = widget;
42 resizeRowToContents (row);
45 QVariant ListWidget::getData(int index) const
47 if(data_.find(index) != data_.end())
55 QWidget* ListWidget::getWidget(int index) const
57 if(widgets_.find(index) != widgets_.end())
59 return widgets_[index];
65 void ListWidget::clear()
67 QTableWidget::clear();
73 void ListWidget::handleClick(int index)
76 emit itemClicked(index);