diff options
Diffstat (limited to 'Swift/QtUI/Roster/QtTreeWidgetItem.cpp')
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidgetItem.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp index f65c3bf..4ac2164 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp @@ -1,7 +1,45 @@ #include "Swift/QtUI/Roster/QtTreeWidgetItem.h" #include "Swift/QtUI/Roster/QtTreeWidget.h" + +#include <qdebug.h> + namespace Swift { +QtTreeWidgetItem::QtTreeWidgetItem(QtTreeWidgetItem* parentItem) : QObject() { + parent_ = parentItem; +} + +void QtTreeWidgetItem::setText(const String& text) { + setName(P2QSTRING(text)); +} + +void QtTreeWidgetItem::setTextColor(unsigned long color) { + // QTreeWidgetItem::setTextColor(0, QColor( + // ((color & 0xFF0000)>>16), + // ((color & 0xFF00)>>8), + // (color & 0xFF))); +} + +void QtTreeWidgetItem::setBackgroundColor(unsigned long color) { + // QTreeWidgetItem::setBackgroundColor(0, QColor( + // ((color & 0xFF0000)>>16), + // ((color & 0xFF00)>>8), + // (color & 0xFF))); +} + +void QtTreeWidgetItem::setExpanded(bool b) { + //treeWidget()->setItemExpanded(this, b); +} + +void QtTreeWidgetItem::hide() { + //setHidden(true); +} + +void QtTreeWidgetItem::show() { + //setHidden(false); +} + + QWidget* QtTreeWidgetItem::getCollapsedRosterWidget() { QWidget* widget = new QWidget(); @@ -14,4 +52,51 @@ QWidget* QtTreeWidgetItem::getExpandedRosterWidget() { return widget; } +QtTreeWidgetItem::~QtTreeWidgetItem() { + qDeleteAll(children_); +} + +QtTreeWidgetItem* QtTreeWidgetItem::getParentItem() { + return parent_; +} + +void QtTreeWidgetItem::addChild(QtTreeWidgetItem* child) { + printf("Boing\n"); + children_.append(child); + connect(child, SIGNAL(changed()), this, SIGNAL(changed())); + emit changed(); +} + +int QtTreeWidgetItem::rowCount() { + qDebug() << "Returning size of " << children_.size() << " for item " << name_; + return children_.size(); +} + +int QtTreeWidgetItem::rowOf(QtTreeWidgetItem* item) { + return children_.indexOf(item); +} + +int QtTreeWidgetItem::row() { + return parent_ ? parent_->rowOf(this) : 0; +} + +QtTreeWidgetItem* QtTreeWidgetItem::getItem(int row) { + qDebug() << "Returning row " << row << " from item " << name_; + return children_[row]; +} + +QVariant QtTreeWidgetItem::data(int role) { + if (role != Qt::DisplayRole) { + return QVariant(); + } + qDebug() << "Returning name " << name_ << " for role " << role; + return name_; +} + +void QtTreeWidgetItem::setName(QString name) { + name_ = name; + qDebug() << "Name changed to " << name; + changed(); +} + }
\ No newline at end of file |