# # # patch "src/model/InventoryItem.cpp" # from [5f6c50c2278d777156a4fc510f8d1bffcb716d0a] # to [20b98c2c356cce9221ba958332b0791c44d97306] # # patch "src/model/InventoryItem.h" # from [48309b9513a8ed11f47567da52d494e38ee45620] # to [47cb4afae97d66984194dcb26e3f69bb605e5083] # ============================================================ --- src/model/InventoryItem.cpp 5f6c50c2278d777156a4fc510f8d1bffcb716d0a +++ src/model/InventoryItem.cpp 20b98c2c356cce9221ba958332b0791c44d97306 @@ -23,7 +23,7 @@ #include #include -ModelItem::ModelItem(const QString & l) : parentItem(0), label(l) +ModelItem::ModelItem(const QString & l) : parentItem(0), label(l), expanded(false) {} ModelItem::ModelItem(const ModelItem * other) @@ -60,6 +60,13 @@ void ModelItem::appendChild(ModelItem * children.append(child); } +void ModelItem::removeChild(ModelItem * child) +{ + int idx = children.indexOf(child); + if (idx == -1) return; + children.removeAt(idx); +} + void ModelItem::setChildren(QList items) { deleteAllChildren(); @@ -139,6 +146,16 @@ QVariant ModelItem::data(int column, int return QVariant(); } +void ModelItem::setExpanded() +{ + expanded = true; +} + +bool ModelItem::isExpanded() const +{ + return expanded; +} + const int InventoryItem::RenameSource = 1; const int InventoryItem::RenameTarget = 2; const int InventoryItem::Added = 4; @@ -334,7 +351,7 @@ QString InventoryItem::getBaseDirectory( QString InventoryItem::getBaseDirectory() const { int pos = path.lastIndexOf('/'); - return pos == -1 ? QString("") : path.left(pos + 1); + return pos == -1 ? QString("") : path.left(pos); } bool InventoryItem::hasStatus(int statusBits) const ============================================================ --- src/model/InventoryItem.h 48309b9513a8ed11f47567da52d494e38ee45620 +++ src/model/InventoryItem.h 47cb4afae97d66984194dcb26e3f69bb605e5083 @@ -40,6 +40,7 @@ public: void deleteAllChildren(); void appendChild(ModelItem *); + void removeChild(ModelItem *); void setChildren(QList); QList getChildren() const; void setParent(ModelItem *); @@ -48,23 +49,29 @@ public: int childCount() const; int row() const; + bool isExpanded() const; + void setExpanded(); + protected: ModelItem * parentItem; QList children; QString label; + bool expanded; }; class PseudoItem : public ModelItem { Q_OBJECT public: - enum Type { CdUp, Root }; + enum Type { CdUp = 1, Root }; PseudoItem(const QString & l, Type t) : ModelItem(l), type(t) { if (type == Root) parentItem = this; } + PseudoItem(const PseudoItem * other) : ModelItem(other), type(other->type) + {} bool isCdUp() const { return type == CdUp; } bool isRoot() const { return type == Root; }