We now have a current svn snapshot of libqxt in our contrib dir, and
[quassel.git] / src / contrib / libqxt-2007-10-24 / src / gui / qxttablewidget.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
4 **
5 ** This file is part of the QxtGui module of the Qt eXTension library
6 **
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
9 ** IBM.
10 **
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.
15 **
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.
20 **
21 ** <http://libqxt.sourceforge.net>  <foundation@libqxt.org>
22 **
23 ****************************************************************************/
24 #include "qxttablewidget.h"
25 #include "qxtitemdelegate.h"
26 #include "qxttablewidget_p.h"
27
28 QxtTableWidgetPrivate::QxtTableWidgetPrivate()
29 {}
30
31 void QxtTableWidgetPrivate::informStartEditing(const QModelIndex& index)
32 {
33     QTableWidgetItem* item = qxt_p().itemFromIndex(index);
34     Q_ASSERT(item);
35     emit qxt_p().itemEditingStarted(item);
36 }
37
38 void QxtTableWidgetPrivate::informFinishEditing(const QModelIndex& index)
39 {
40     QTableWidgetItem* item = qxt_p().itemFromIndex(index);
41     Q_ASSERT(item);
42     emit qxt_p().itemEditingFinished(item);
43 }
44
45 /*!
46     \class QxtTableWidget QxtTableWidget
47     \ingroup QxtGui
48     \brief An extended QTableWidget with additional signals.
49
50     QxtTableWidget offers a few most commonly requested signals.
51
52     \image html qxttablewidget.png "QxtTableWidget in Plastique style."
53  */
54
55 /*!
56     \fn QxtTableWidget::itemEditingStarted(QTableWidgetItem* item)
57
58     This signal is emitted after the editing of \a item has been started.
59
60     \sa itemEditingFinished()
61  */
62
63 /*!
64     \fn QxtTableWidget::itemEditingFinished(QTableWidgetItem* item)
65
66     This signal is emitted after the editing of \a item has been finished.
67
68     \sa itemEditingStarted()
69  */
70
71 /*!
72     \fn QxtTableWidget::itemCheckStateChanged(QxtTableWidgetItem* item)
73
74     This signal is emitted whenever the check state of \a item has changed.
75
76     \note Use QxtTableWidgetItem in order to enable this feature.
77
78     \sa QxtTableWidgetItem, QTableWidgetItem::checkState()
79  */
80
81 /*!
82     Constructs a new QxtTableWidget with \a parent.
83  */
84 QxtTableWidget::QxtTableWidget(QWidget* parent)
85         : QTableWidget(parent)
86 {
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);
95 }
96
97 /*!
98     Constructs a new QxtTableWidget with \a rows, \a columns and \a parent.
99  */
100 QxtTableWidget::QxtTableWidget(int rows, int columns, QWidget* parent)
101         : QTableWidget(rows, columns, parent)
102 {
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);
111 }
112
113 /*!
114     Destructs the table widget.
115  */
116 QxtTableWidget::~QxtTableWidget()
117 {}