summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp3
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.h2
-rw-r--r--Swift/QtUI/Roster/QtTreeWidgetItem.cpp16
-rw-r--r--Swift/QtUI/Roster/QtTreeWidgetItem.h2
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.cpp16
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.h10
6 files changed, 41 insertions, 8 deletions
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp
index 0aebc24..714beb2 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidget.cpp
@@ -10,6 +10,8 @@ QtTreeWidget::QtTreeWidget(QWidget* parent) : QTreeView(parent) {
model_ = new RosterModel();
model_->setRoot(treeRoot_);
setModel(model_);
+ delegate_ = new RosterDelegate();
+ setItemDelegate(delegate_);
setHeaderHidden(true);
#ifdef SWIFT_PLATFORM_MACOSX
setAlternatingRowColors(true);
@@ -22,6 +24,7 @@ QtTreeWidget::QtTreeWidget(QWidget* parent) : QTreeView(parent) {
QtTreeWidget::~QtTreeWidget() {
delete model_;
+ delete delegate_;
}
QtTreeWidgetItem* QtTreeWidget::getRoot() {
diff --git a/Swift/QtUI/Roster/QtTreeWidget.h b/Swift/QtUI/Roster/QtTreeWidget.h
index 73ac86c..b8d3c23 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.h
+++ b/Swift/QtUI/Roster/QtTreeWidget.h
@@ -9,6 +9,7 @@
#include "Swift/QtUI/Roster/QtTreeWidgetItem.h"
#include "Swift/QtUI/Roster/QtTreeWidget.h"
#include "Swift/QtUI/Roster/RosterModel.h"
+#include "Swift/QtUI/Roster/RosterDelegate.h"
namespace Swift {
@@ -24,6 +25,7 @@ class QtTreeWidget : public QTreeView, public TreeWidget {
private:
void drawBranches(QPainter*, const QRect&, const QModelIndex&) const;
RosterModel* model_;
+ RosterDelegate* delegate_;
QtTreeWidgetItem* treeRoot_;
};
diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
index 6ebeb7f..2c05053 100644
--- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
@@ -14,17 +14,17 @@ void QtTreeWidgetItem::setText(const String& text) {
}
void QtTreeWidgetItem::setTextColor(unsigned long color) {
- // QTreeWidgetItem::setTextColor(0, QColor(
- // ((color & 0xFF0000)>>16),
- // ((color & 0xFF00)>>8),
- // (color & 0xFF)));
+ textColor_ = 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)));
+ backgroundColor_ = QColor(
+ ((color & 0xFF0000)>>16),
+ ((color & 0xFF00)>>8),
+ (color & 0xFF));
}
void QtTreeWidgetItem::setExpanded(bool b) {
diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h
index daffcc2..017258b 100644
--- a/Swift/QtUI/Roster/QtTreeWidgetItem.h
+++ b/Swift/QtUI/Roster/QtTreeWidgetItem.h
@@ -43,6 +43,8 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem {
QList<QtTreeWidgetItem*> children_;
QtTreeWidgetItem* parent_;
QString displayName_;
+ QColor textColor_;
+ QColor backgroundColor_;
};
}
diff --git a/Swift/QtUI/Roster/RosterDelegate.cpp b/Swift/QtUI/Roster/RosterDelegate.cpp
index e69de29..925f66c 100644
--- a/Swift/QtUI/Roster/RosterDelegate.cpp
+++ b/Swift/QtUI/Roster/RosterDelegate.cpp
@@ -0,0 +1,16 @@
+#include "RosterDelegate.h"
+
+#include <QPainter>
+
+namespace Swift {
+QSize RosterDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index ) const {
+ return QSize(100,50);
+}
+
+void RosterDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex index) const {
+ painter->save();
+ QStyledItemDelegate::paint(painter, option, index);
+ painter->restore();
+}
+
+} \ No newline at end of file
diff --git a/Swift/QtUI/Roster/RosterDelegate.h b/Swift/QtUI/Roster/RosterDelegate.h
index e69de29..32bba80 100644
--- a/Swift/QtUI/Roster/RosterDelegate.h
+++ b/Swift/QtUI/Roster/RosterDelegate.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#import <QStyledItemDelegate>
+
+namespace Swift {
+ class RosterDelegate : public QStyledItemDelegate {
+ QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
+ void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex index) const;
+ };
+} \ No newline at end of file