Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "qxtlistwidgetitem.h"
00026 #include "qxtlistwidget.h"
00027
00040 QxtListWidgetItem::QxtListWidgetItem(QListWidget* parent, int type)
00041 : QListWidgetItem(parent, type)
00042 {}
00043
00044 QxtListWidgetItem::QxtListWidgetItem(const QString& text, QListWidget* parent, int type)
00045 : QListWidgetItem(text, parent, type)
00046 {}
00047
00048 QxtListWidgetItem::QxtListWidgetItem(const QIcon& icon, const QString& text, QListWidget* parent, int type)
00049 : QListWidgetItem(icon, text, parent, type)
00050 {}
00051
00052 QxtListWidgetItem::QxtListWidgetItem(const QxtListWidgetItem& other)
00053 : QListWidgetItem(other)
00054 {}
00055
00056 QxtListWidgetItem::~QxtListWidgetItem()
00057 {}
00058
00064 bool QxtListWidgetItem::testFlag(Qt::ItemFlag flag) const
00065 {
00066 return (flags() & flag);
00067 }
00068
00074 void QxtListWidgetItem::setFlag(Qt::ItemFlag flag, bool enabled)
00075 {
00076 if (enabled)
00077 setFlags(flags() | flag);
00078 else
00079 setFlags(flags() & ~flag);
00080 }
00081
00085 void QxtListWidgetItem::setData(int role, const QVariant& value)
00086 {
00087 if (role == Qt::CheckStateRole)
00088 {
00089 const Qt::CheckState newState = static_cast<Qt::CheckState>(value.toInt());
00090 const Qt::CheckState oldState = static_cast<Qt::CheckState>(data(role).toInt());
00091
00092 QListWidgetItem::setData(role, value);
00093
00094 if (newState != oldState)
00095 {
00096 QxtListWidget* list = qobject_cast<QxtListWidget*>(listWidget());
00097 if (list)
00098 {
00099 emit list->itemCheckStateChanged(this);
00100 }
00101 }
00102 }
00103 else
00104 {
00105 QListWidgetItem::setData(role, value);
00106 }
00107 }