1 /****************************************************************************
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
5 ** This file is part of the QxtGui module of the Qt eXTension library
7 ** This library is free software; you can redistribute it and/or modify it
8 ** under the terms of th Common Public License, version 1.0, as published by
11 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
12 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
13 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
14 ** FITNESS FOR A PARTICULAR PURPOSE.
16 ** You should have received a copy of the CPL along with this file.
17 ** See the LICENSE file and the cpl1.0.txt file included with the source
18 ** distribution for more information. If you did not receive a copy of the
19 ** license, contact the Qxt Foundation.
21 ** <http://libqxt.sourceforge.net> <foundation@libqxt.org>
23 ****************************************************************************/
24 #include "qxttablewidget.h"
25 #include "qxtitemdelegate.h"
26 #include "qxttablewidget_p.h"
28 QxtTableWidgetPrivate::QxtTableWidgetPrivate()
31 void QxtTableWidgetPrivate::informStartEditing(const QModelIndex& index)
33 QTableWidgetItem* item = qxt_p().itemFromIndex(index);
35 emit qxt_p().itemEditingStarted(item);
38 void QxtTableWidgetPrivate::informFinishEditing(const QModelIndex& index)
40 QTableWidgetItem* item = qxt_p().itemFromIndex(index);
42 emit qxt_p().itemEditingFinished(item);
46 \class QxtTableWidget QxtTableWidget
48 \brief An extended QTableWidget with additional signals.
50 QxtTableWidget offers a few most commonly requested signals.
52 \image html qxttablewidget.png "QxtTableWidget in Plastique style."
56 \fn QxtTableWidget::itemEditingStarted(QTableWidgetItem* item)
58 This signal is emitted after the editing of \a item has been started.
60 \sa itemEditingFinished()
64 \fn QxtTableWidget::itemEditingFinished(QTableWidgetItem* item)
66 This signal is emitted after the editing of \a item has been finished.
68 \sa itemEditingStarted()
72 \fn QxtTableWidget::itemCheckStateChanged(QxtTableWidgetItem* item)
74 This signal is emitted whenever the check state of \a item has changed.
76 \note Use QxtTableWidgetItem in order to enable this feature.
78 \sa QxtTableWidgetItem, QTableWidgetItem::checkState()
82 Constructs a new QxtTableWidget with \a parent.
84 QxtTableWidget::QxtTableWidget(QWidget* parent)
85 : QTableWidget(parent)
87 QXT_INIT_PRIVATE(QxtTableWidget);
88 setItemPrototype(new QxtTableWidgetItem);
89 QxtItemDelegate* delegate = new QxtItemDelegate(this);
90 connect(delegate, SIGNAL(editingStarted(const QModelIndex&)),
91 &qxt_d(), SLOT(informStartEditing(const QModelIndex&)));
92 connect(delegate, SIGNAL(editingFinished(const QModelIndex&)),
93 &qxt_d(), SLOT(informFinishEditing(const QModelIndex&)));
94 setItemDelegate(delegate);
98 Constructs a new QxtTableWidget with \a rows, \a columns and \a parent.
100 QxtTableWidget::QxtTableWidget(int rows, int columns, QWidget* parent)
101 : QTableWidget(rows, columns, parent)
103 QXT_INIT_PRIVATE(QxtTableWidget);
104 setItemPrototype(new QxtTableWidgetItem);
105 QxtItemDelegate* delegate = new QxtItemDelegate(this);
106 connect(delegate, SIGNAL(editingStarted(const QModelIndex&)),
107 &qxt_d(), SLOT(informStartEditing(const QModelIndex&)));
108 connect(delegate, SIGNAL(editingFinished(const QModelIndex&)),
109 &qxt_d(), SLOT(informFinishEditing(const QModelIndex&)));
110 setItemDelegate(delegate);
114 Destructs the table widget.
116 QxtTableWidget::~QxtTableWidget()