diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-01-16 19:56:10 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-01-20 21:40:49 (GMT) |
commit | 004dfd8d4305b767b624be10072597ef3e311753 (patch) | |
tree | 7f9a70ce336e9eca3bc78397640530939e55fa20 /Swift/QtUI/MUCSearch/MUCSearchModel.cpp | |
parent | 03d69bfd11549e1c8dcbf3b5300029ba9892cf8a (diff) | |
download | swift-contrib-004dfd8d4305b767b624be10072597ef3e311753.zip swift-contrib-004dfd8d4305b767b624be10072597ef3e311753.tar.bz2 |
Use a dedicated Join MUC dialog.
Diffstat (limited to 'Swift/QtUI/MUCSearch/MUCSearchModel.cpp')
-rw-r--r-- | Swift/QtUI/MUCSearch/MUCSearchModel.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Swift/QtUI/MUCSearch/MUCSearchModel.cpp b/Swift/QtUI/MUCSearch/MUCSearchModel.cpp index 2526039..c657190 100644 --- a/Swift/QtUI/MUCSearch/MUCSearchModel.cpp +++ b/Swift/QtUI/MUCSearch/MUCSearchModel.cpp @@ -5,6 +5,7 @@ */ #include "Swift/QtUI/MUCSearch/MUCSearchModel.h" +#include "Swift/QtUI/MUCSearch/MUCSearchEmptyItem.h" namespace Swift { @@ -39,7 +40,6 @@ QModelIndex MUCSearchModel::index(int row, int column, const QModelIndex & paren if (parent.isValid()) { MUCSearchServiceItem* parentItem = static_cast<MUCSearchServiceItem*>(parent.internalPointer()); return row < parentItem->rowCount() ? createIndex(row, column, parentItem->getItem(row)) : QModelIndex(); - } else { return row < services_.size() ? createIndex(row, column, services_[row]) : QModelIndex(); } @@ -55,10 +55,17 @@ QModelIndex MUCSearchModel::parent(const QModelIndex& index) const { if (!item) { return QModelIndex(); } - if (dynamic_cast<MUCSearchServiceItem*>(item)) { + else if (dynamic_cast<MUCSearchServiceItem*>(item)) { return QModelIndex(); } - MUCSearchServiceItem* parent = dynamic_cast<MUCSearchRoomItem*>(item)->getParent(); + + MUCSearchServiceItem* parent = NULL; + if (MUCSearchRoomItem* roomItem = dynamic_cast<MUCSearchRoomItem*>(item)) { + parent = roomItem->getParent(); + } + else if (MUCSearchEmptyItem* emptyItem = dynamic_cast<MUCSearchEmptyItem*>(item)) { + parent = emptyItem->getParent(); + } if (parent) { int row = services_.indexOf(parent); return createIndex(row, 1, parent); @@ -74,7 +81,8 @@ int MUCSearchModel::rowCount(const QModelIndex& parentIndex) const { } if (dynamic_cast<MUCSearchServiceItem*>(static_cast<MUCSearchItem*>(parentIndex.internalPointer()))) { return services_[parentIndex.row()]->rowCount(); - } else { + } + else { return 0; } } |