summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/MUCSearch/MUCSearchModel.cpp')
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchModel.cpp16
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;
}
}