diff options
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidget.cpp | 14 | ||||
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidget.h | 6 | ||||
-rw-r--r-- | Swift/QtUI/Roster/main.cpp | 24 |
3 files changed, 23 insertions, 21 deletions
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp index 714beb2..67afd14 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.cpp +++ b/Swift/QtUI/Roster/QtTreeWidget.cpp @@ -19,7 +19,7 @@ QtTreeWidget::QtTreeWidget(QWidget* parent) : QTreeView(parent) { setAnimated(true); setIndentation(0); setRootIsDecorated(true); - //connect(this, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(handleItemActivated(QTreeWidgetItem*, int))); + connect(this, SIGNAL(activated(const QModelIndex&)), this, SLOT(handleItemActivated(const QModelIndex&))); } QtTreeWidget::~QtTreeWidget() { @@ -31,12 +31,12 @@ QtTreeWidgetItem* QtTreeWidget::getRoot() { return treeRoot_; } -// void QtTreeWidget::handleItemActivated(QTreeWidgetItem* item, int column) { -// QtTreeWidgetItem* qtItem = dynamic_cast<QtTreeWidgetItem*>(item); -// if (qtItem) { -// qtItem->performUserAction(boost::shared_ptr<UserRosterAction>(new OpenChatRosterAction())); -// } -// } +void QtTreeWidget::handleItemActivated(const QModelIndex& index) { + QtTreeWidgetItem* qtItem = static_cast<QtTreeWidgetItem*>(index.internalPointer()); + if (qtItem) { + qtItem->performUserAction(boost::shared_ptr<UserRosterAction>(new OpenChatRosterAction())); + } +} void QtTreeWidget::drawBranches(QPainter*, const QRect&, const QModelIndex&) const { } diff --git a/Swift/QtUI/Roster/QtTreeWidget.h b/Swift/QtUI/Roster/QtTreeWidget.h index b8d3c23..bb8f618 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.h +++ b/Swift/QtUI/Roster/QtTreeWidget.h @@ -2,7 +2,7 @@ #define SWIFT_QtTreeWidget_H #include <QTreeView> - +#include <QModelIndex> #include "Swiften/Roster/TreeWidgetFactory.h" #include "Swiften/Roster/TreeWidget.h" #include "Swiften/Roster/TreeWidgetItem.h" @@ -20,8 +20,8 @@ class QtTreeWidget : public QTreeView, public TreeWidget { ~QtTreeWidget(); void show(); QtTreeWidgetItem* getRoot(); - //private slots: - // void handleItemActivated(QTreeWidgetItem*, int); + private slots: + void handleItemActivated(const QModelIndex&); private: void drawBranches(QPainter*, const QRect&, const QModelIndex&) const; RosterModel* model_; diff --git a/Swift/QtUI/Roster/main.cpp b/Swift/QtUI/Roster/main.cpp index f3623ac..60ee592 100644 --- a/Swift/QtUI/Roster/main.cpp +++ b/Swift/QtUI/Roster/main.cpp @@ -15,17 +15,19 @@ int main(int argc, char *argv[]) Swift::QtTreeWidgetFactory treeWidgetFactory; Swift::QtTreeWidget* tree = dynamic_cast<Swift::QtTreeWidget*>(treeWidgetFactory.createTreeWidget()); - Swift::QtTreeWidgetItem* group = dynamic_cast<Swift::QtTreeWidgetItem*>(treeWidgetFactory.createTreeWidgetItem(tree)); - group->setText("People"); - group->setBackgroundColor(0xBBBBBB); - Swift::QtTreeWidgetItem* item1 = dynamic_cast<Swift::QtTreeWidgetItem*>(treeWidgetFactory.createTreeWidgetItem(group)); - Swift::QtTreeWidgetItem* item2 = dynamic_cast<Swift::QtTreeWidgetItem*>(treeWidgetFactory.createTreeWidgetItem(group)); - Swift::QtTreeWidgetItem* item3 = dynamic_cast<Swift::QtTreeWidgetItem*>(treeWidgetFactory.createTreeWidgetItem(group)); - Swift::QtTreeWidgetItem* item4 = dynamic_cast<Swift::QtTreeWidgetItem*>(treeWidgetFactory.createTreeWidgetItem(group)); - item1->setText("Remko"); - item2->setText("Kevin"); - item3->setText("Cath"); - item4->setText("Kim"); + for (int i = 0; i < 500; i++) { + Swift::QtTreeWidgetItem* group = dynamic_cast<Swift::QtTreeWidgetItem*>(treeWidgetFactory.createTreeWidgetItem(tree)); + group->setText("People"); + group->setBackgroundColor(0xBBBBBB); + Swift::QtTreeWidgetItem* item1 = dynamic_cast<Swift::QtTreeWidgetItem*>(treeWidgetFactory.createTreeWidgetItem(group)); + Swift::QtTreeWidgetItem* item2 = dynamic_cast<Swift::QtTreeWidgetItem*>(treeWidgetFactory.createTreeWidgetItem(group)); + Swift::QtTreeWidgetItem* item3 = dynamic_cast<Swift::QtTreeWidgetItem*>(treeWidgetFactory.createTreeWidgetItem(group)); + Swift::QtTreeWidgetItem* item4 = dynamic_cast<Swift::QtTreeWidgetItem*>(treeWidgetFactory.createTreeWidgetItem(group)); + item1->setText("Remko"); + item2->setText("Kevin"); + item3->setText("Cath"); + item4->setText("Kim"); + } tree->show(); return app.exec(); }
\ No newline at end of file |