Răsfoiți Sursa

Small changes

Kandrashin Denis 13 ani în urmă
părinte
comite
c9490082f9
2 a modificat fișierele cu 11 adăugiri și 0 ștergeri
  1. 6 0
      source/fb2tree.cpp
  2. 5 0
      source/fb2tree.hpp

+ 6 - 0
source/fb2tree.cpp

@@ -156,6 +156,12 @@ QModelIndex FbTreeModel::index(FbTreeItem *item, int column) const
     return parent ? createIndex(parent->index(item), column, (void*)item) : QModelIndex();
 }
 
+bool FbTreeModel::hasChildren(const QModelIndex &parent) const
+{
+    FbTreeItem *owner = item(parent);
+    return owner ? owner->hasChildren() : false;
+}
+
 QModelIndex FbTreeModel::index(int row, int column, const QModelIndex &parent) const
 {
     if (!m_root || row < 0 || column < 0) return QModelIndex();

+ 5 - 0
source/fb2tree.hpp

@@ -52,6 +52,10 @@ public:
         return m_list.takeAt(row);
     }
 
+    bool hasChildren() {
+        return m_list.size();
+    }
+
     int count() const {
         return m_list.size();
     }
@@ -110,6 +114,7 @@ public:
     void update();
 
 public:
+    virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
     virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
     virtual QModelIndex parent(const QModelIndex &child) const;
     virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;