# # # patch "src/model/Inventory.cpp" # from [373c92ab5041cd2c2784ff59052369d32166f2ec] # to [a052d31df3cd4f5a9f1fc589e5168941c7f913f1] # # patch "src/model/InventoryItem.cpp" # from [5b80373f14f1992b39d36749aa2673b608888ba5] # to [668653d908eb9fb5bd06ae29a33df9849471acdd] # # patch "src/model/InventoryItem.h" # from [0d5f6eaa88eabf56459ed348fc653e2ac08b802c] # to [eafe5180624e27a2ca9fc560c32da755554396bd] # # patch "src/model/InventoryModel.cpp" # from [4013f1123d48df9ea48a4f312bd82fa301319413] # to [df0040b8a0d5172ae7e5e18186d37e1fa1360d49] # # patch "src/model/InventoryModel.h" # from [35bf3a8954e46ffa15de39942e2bace8623723b7] # to [5973c6741bd2c0bfac492c906a7d14538ac1d3b7] # ============================================================ --- src/model/Inventory.cpp 373c92ab5041cd2c2784ff59052369d32166f2ec +++ src/model/Inventory.cpp a052d31df3cd4f5a9f1fc589e5168941c7f913f1 @@ -192,14 +192,24 @@ void Inventory::processTaskResult(const { itemDepth = path.split("/", QString::SkipEmptyParts).size(); } + else + { + QString displayPath = workspacePath; + QString homePath = QDir::homePath(); + if (workspacePath.indexOf(homePath) == 0) + { + displayPath = QDir(homePath).relativeFilePath(workspacePath); + displayPath.prepend("~/"); + } + item->setLabel(displayPath); + } // add a cdup item for this item if we either queried everything // already or the current directory level corresponds to the queried one - if (item->isDirectory() && (queriedDepth == -1 || queriedDepth >= itemDepth)) + if (item->isDirectory() && (queriedDepth == -1 || queriedDepth > itemDepth)) { PseudoItem * cdUp = new PseudoItem("..", PseudoItem::CdUp); parentChildRelations[item].append(cdUp); - item->setExpanded(); } QString baseDir = item->getBaseDirectory(); ============================================================ --- src/model/InventoryItem.cpp 5b80373f14f1992b39d36749aa2673b608888ba5 +++ src/model/InventoryItem.cpp 668653d908eb9fb5bd06ae29a33df9849471acdd @@ -173,7 +173,7 @@ InventoryItem::InventoryItem(const Stanz InventoryItem::InventoryItem(const Stanza & stanza) : ModelItem(), fs_type(Undefined), old_type(Undefined), new_type(Undefined), - status(0), expanded(false), aboutToBeExpanded(false) + status(0), aboutToBeExpanded(false) { foreach (const StanzaEntry & en, stanza) { @@ -513,33 +513,25 @@ QString InventoryItem::getStatusString() return list.join(", "); } -void InventoryItem::setExpanded() -{ - expanded = true; -} - bool InventoryItem::isExpanded(int level) const { I(level >= 0); - if (level == 0) - { - if (!isDirectory()) return true; - return expanded; - } - if (isDirectory() && childCount() == 0) - { - D(QString("node %1 has no children").arg(getPath())); + if (!isDirectory()) + return true; + + if (childCount() == 0) return false; - } - foreach (ModelItem * child, children) + if (level > 0) { - InventoryItem * invitem = dynamic_cast(child); - if (!invitem) continue; - if (!invitem->isExpanded(level - 1)) + foreach (ModelItem * child, children) { - return false; + InventoryItem * invitem = dynamic_cast(child); + if (!invitem) + continue; + if (!invitem->isExpanded(level - 1)) + return false; } } ============================================================ --- src/model/InventoryItem.h 0d5f6eaa88eabf56459ed348fc653e2ac08b802c +++ src/model/InventoryItem.h eafe5180624e27a2ca9fc560c32da755554396bd @@ -111,11 +111,9 @@ public: bool isTracked() const; bool hasChanged() const; - void setExpanded(); - bool isExpanded(int) const; - void setAboutToBeExpanded(); bool isAboutToBeExpanded() const; + bool isExpanded(int) const; void setStatusRecursive(int); int getStatusRecursive() const; @@ -147,7 +145,6 @@ private: QString birthRev; int status; - bool expanded; bool aboutToBeExpanded; }; ============================================================ --- src/model/InventoryModel.cpp 4013f1123d48df9ea48a4f312bd82fa301319413 +++ src/model/InventoryModel.cpp df0040b8a0d5172ae7e5e18186d37e1fa1360d49 @@ -25,11 +25,6 @@ InventoryModel::InventoryModel(QObject * inventory = new Inventory(this); connect( - inventory, SIGNAL(inventoryRead(const QString &)), - this, SLOT(maybeResetModel(const QString &)) - ); - - connect( inventory, SIGNAL(invalidWorkspaceFormat()), this, SIGNAL(invalidWorkspaceFormat()) ); @@ -58,6 +53,11 @@ InventoryModel::InventoryModel(QObject * inventory, SIGNAL(dataChanged(ModelItem *)), this, SLOT(triggerDataChanged(ModelItem *)) ); + + connect( + inventory, SIGNAL(inventoryRead(const QString &)), + this, SIGNAL(layoutChanged()) + ); } InventoryModel::~InventoryModel() @@ -138,39 +138,6 @@ void InventoryModel::fetchMore(const QMo inventory->read(invitem->getPath()); } -void InventoryModel::maybeResetModel(const QString & queriedPath) -{ - if (queriedPath.isEmpty()) - { - // we need to call reset() before we emit dataChanged, - // otherwise the view doesn't know anything of the new - // index we're going to present her afterwards - reset(); - - // give the root item a proper label, which is in our case the path - // to the workspace root directory - QList children = inventory->rootItem->getChildren(); - - int workspaceRootRow = 0; - - I(children.size() > workspaceRootRow); - - QString displayPath = workspacePath; - QString homePath = QDir::homePath(); - if (workspacePath.indexOf(homePath) == 0) - { - displayPath = QDir(homePath).relativeFilePath(workspacePath); - displayPath.prepend("~/"); - } - children[workspaceRootRow]->setLabel(displayPath); - - emit dataChanged( - index(workspaceRootRow, 0, QModelIndex()), - index(workspaceRootRow, 1, QModelIndex()) - ); - } -} - QModelIndex InventoryModel::indexFromItem(ModelItem * item, int col) const { if (item->isRoot()) ============================================================ --- src/model/InventoryModel.h 35bf3a8954e46ffa15de39942e2bace8623723b7 +++ src/model/InventoryModel.h 5973c6741bd2c0bfac492c906a7d14538ac1d3b7 @@ -81,8 +81,6 @@ private slots: void triggerDataChanged(ModelItem *); - void maybeResetModel(const QString &); - signals: //! forward void invalidWorkspaceFormat();