X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcontrib%2Flibqxt-2007-10-24%2Fsrc%2Fgui%2Fqxtlistwidgetitem.cpp;fp=src%2Fcontrib%2Flibqxt-2007-10-24%2Fsrc%2Fgui%2Fqxtlistwidgetitem.cpp;h=76cc156eea154b3e9656e82cf5a8e8e19261c79e;hp=0000000000000000000000000000000000000000;hb=a634acadbcf6017474f68a3eaf7cb632660e9e49;hpb=cd122ca8e0d2c0ffc5397e0a813c75d791a7e6e3 diff --git a/src/contrib/libqxt-2007-10-24/src/gui/qxtlistwidgetitem.cpp b/src/contrib/libqxt-2007-10-24/src/gui/qxtlistwidgetitem.cpp new file mode 100644 index 00000000..76cc156e --- /dev/null +++ b/src/contrib/libqxt-2007-10-24/src/gui/qxtlistwidgetitem.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) Qxt Foundation. Some rights reserved. +** +** This file is part of the QxtGui module of the Qt eXTension library +** +** This library is free software; you can redistribute it and/or modify it +** under the terms of th Common Public License, version 1.0, as published by +** IBM. +** +** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY +** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY +** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR +** FITNESS FOR A PARTICULAR PURPOSE. +** +** You should have received a copy of the CPL along with this file. +** See the LICENSE file and the cpl1.0.txt file included with the source +** distribution for more information. If you did not receive a copy of the +** license, contact the Qxt Foundation. +** +** +** +****************************************************************************/ +#include "qxtlistwidgetitem.h" +#include "qxtlistwidget.h" + +/*! + \class QxtListWidgetItem QxtListWidgetItem + \ingroup QxtGui + \brief An extended QListWidgetItem. + + QxtListWidgetItem provides means for offering check state change signals and + convenience methods for testing and setting flags. + + \sa QxtListWidget + */ + + +QxtListWidgetItem::QxtListWidgetItem(QListWidget* parent, int type) + : QListWidgetItem(parent, type) +{} + +QxtListWidgetItem::QxtListWidgetItem(const QString& text, QListWidget* parent, int type) + : QListWidgetItem(text, parent, type) +{} + +QxtListWidgetItem::QxtListWidgetItem(const QIcon& icon, const QString& text, QListWidget* parent, int type) + : QListWidgetItem(icon, text, parent, type) +{} + +QxtListWidgetItem::QxtListWidgetItem(const QxtListWidgetItem& other) + : QListWidgetItem(other) +{} + +QxtListWidgetItem::~QxtListWidgetItem() +{} + +/*! + Returns \b true if the \a flag is set, otherwise \b false. + + \sa setFlag(), QListWidgetItem::flags(), Qt::ItemFlag + */ +bool QxtListWidgetItem::testFlag(Qt::ItemFlag flag) const +{ + return (flags() & flag); +} + +/*! + If \a enabled is \b true, the item \a flag is enabled; otherwise, it is disabled. + + \sa testFlag(), QListWidgetItem::setFlags(), Qt::ItemFlag + */ +void QxtListWidgetItem::setFlag(Qt::ItemFlag flag, bool enabled) +{ + if (enabled) + setFlags(flags() | flag); + else + setFlags(flags() & ~flag); +} + +void QxtListWidgetItem::setData(int role, const QVariant& value) +{ + if (role == Qt::CheckStateRole) + { + const Qt::CheckState newState = static_cast(value.toInt()); + const Qt::CheckState oldState = static_cast(data(role).toInt()); + + QListWidgetItem::setData(role, value); + + if (newState != oldState) + { + QxtListWidget* list = qobject_cast(listWidget()); + if (list) + { + emit list->itemCheckStateChanged(this); + } + } + } + else + { + QListWidgetItem::setData(role, value); + } +}