# # # patch "src/model/Inventory.cpp" # from [300ecdfe2c509f6df1fb404f7536eb345caeb57e] # to [49b90828ab3f978f3a509428be97dd789f2ddb45] # # patch "src/model/Inventory.h" # from [323c88751637a3b78608bf9b980a0dde7bd25c0d] # to [255f1d2dbb9f60515e659894c43ef81ab528a04a] # # patch "src/model/InventoryItem.cpp" # from [d2953a68b908485df6c4a170d8df7acd039376cf] # to [b1414460c78705b725b01eb9455dbc74220c0bc3] # # patch "src/model/InventoryItem.h" # from [5bb9365545fa0ca8d1d7e913d4a7ec37d23560e3] # to [2f8c89970fb09c802554de1646fba71c0b1b5748] # ============================================================ --- src/model/Inventory.cpp 300ecdfe2c509f6df1fb404f7536eb345caeb57e +++ src/model/Inventory.cpp 49b90828ab3f978f3a509428be97dd789f2ddb45 @@ -26,6 +26,8 @@ #include #include +const int Inventory::QueryLevel = 1; + Inventory::Inventory(QObject * parent) : QAbstractItemModel(parent), AutomateCommand(0), workspacePath() { @@ -70,13 +72,9 @@ bool Inventory::canFetchMore(const QMode if (!invitem) return false; - if (invitem->isExpanded()) + if (invitem->isExpanded(QueryLevel)) return false; - if (lastRequests.size() > 0 && lastRequests.top() == invitem->getPath()) - return false; - - L(QString("fetching more for %1 (items: %2)").arg(invitem->getLabel()).arg(invitem->childCount())); return true; } @@ -105,7 +103,7 @@ void Inventory::fetchMore(const QModelIn if (invitem->getFSType() != InventoryItem::Directory) return; // again, if this item is already expanded, don't expand it again - if (invitem->isExpanded()) return; + if (invitem->isExpanded(QueryLevel)) return; readInventory(invitem->getPath()); } @@ -120,15 +118,13 @@ void Inventory::readInventory(const QStr cmd << path; } - lastRequests.push(path); - QStringList opts; // if requested, just read one directory level ahead // (useful for big directory trees) if (Settings::getBool("ReadWorkspaceIncrementally", true)) { - opts << "depth" << QString::number(1); + opts << "depth" << QString::number(QueryLevel); } MonotoneTask task(cmd, opts); @@ -216,6 +212,7 @@ void Inventory::processTaskResult(const { PseudoItem * cdUp = new PseudoItem("..", PseudoItem::CdUp); parentChildRelations[item].append(cdUp); + item->setExpanded(); } QString baseDir = item->getBaseDirectory(); @@ -255,7 +252,6 @@ void Inventory::processTaskResult(const reset(); } - I(lastRequests.pop() == queriedPath); I(itemMap.contains(queriedPath)); QModelIndex index = indexFromItem(itemMap.value(queriedPath), 0); I(index.isValid()); ============================================================ --- src/model/Inventory.h 323c88751637a3b78608bf9b980a0dde7bd25c0d +++ src/model/Inventory.h 255f1d2dbb9f60515e659894c43ef81ab528a04a @@ -25,7 +25,6 @@ #include "InventoryItem.h" #include -#include class Inventory : public QAbstractItemModel, public AutomateCommand { @@ -46,6 +45,8 @@ public: bool canFetchMore( const QModelIndex &) const; void fetchMore(const QModelIndex &); + static const int QueryLevel; + public slots: void setWorkspacePath(const WorkspacePath &); void refresh(); @@ -64,7 +65,6 @@ private: QString branchName; QMap itemMap; WorkspacePath workspacePath; - QStack lastRequests; private slots: void setWorkspacePath(); ============================================================ --- src/model/InventoryItem.cpp d2953a68b908485df6c4a170d8df7acd039376cf +++ src/model/InventoryItem.cpp b1414460c78705b725b01eb9455dbc74220c0bc3 @@ -165,7 +165,7 @@ InventoryItem::InventoryItem(const Stanz InventoryItem::InventoryItem(const Stanza & stanza) : ModelItem(), fs_type(Undefined), old_type(Undefined), new_type(Undefined), - status(0) + status(0), expanded(false) { foreach (StanzaEntry en, stanza) { @@ -494,23 +494,26 @@ QString InventoryItem::getRenameInfo() c return strings.join(", "); } -bool InventoryItem::isExpanded() const +void InventoryItem::setExpanded() { - // non-directory nodes are obviously always expanded - if (!isDirectory()) return true; + expanded = true; +} - // if we have no children, this was not yet expanded - if (childCount() == 0) return false; +bool InventoryItem::isExpanded(int level) const +{ + I(level >= 0); + if (level == 0) + { + if (!isDirectory()) return true; + return expanded; + } - // go through all the children and check if they have been expanded yet + I(childCount() > 0); foreach (ModelItem * child, children) { InventoryItem * invitem = dynamic_cast(child); - // skip non-inventory items if (!invitem) continue; - // expanded directories should have at least one child, - // the pseudo cdup item! - if (invitem->isDirectory() && invitem->childCount() == 0) + if (!invitem->isExpanded(level - 1)) { return false; } ============================================================ --- src/model/InventoryItem.h 5bb9365545fa0ca8d1d7e913d4a7ec37d23560e3 +++ src/model/InventoryItem.h 2f8c89970fb09c802554de1646fba71c0b1b5748 @@ -111,7 +111,8 @@ public: bool isTracked() const; bool hasChanged() const; - bool isExpanded() const; + void setExpanded(); + bool isExpanded(int) const; int getStatusRecursive() const; bool hasChangedRecursive() const; @@ -140,6 +141,7 @@ private: FileType new_type; int status; + bool expanded; }; #endif