# # # patch "src/model/Inventory.cpp" # from [8de0c627ef63a50a8d4641fafb59863cf614ea55] # to [2133b530b618105104e29b72f1ca34db5907512f] # # patch "src/model/Inventory.h" # from [5f721ad6fa46ed5f994688debe1d0708381607b7] # to [e9d25b6dda9dcb6b3678cb3699da93695f4ac1ca] # # patch "src/monotone/MonotoneDelegate.cpp" # from [ad54da748affdc935bcfd2d6cd2f4242ff734a34] # to [7f53f5b2ce57902cd2522ded0d3ae08b770d6640] # ============================================================ --- src/model/Inventory.cpp 8de0c627ef63a50a8d4641fafb59863cf614ea55 +++ src/model/Inventory.cpp 2133b530b618105104e29b72f1ca34db5907512f @@ -34,6 +34,11 @@ Inventory::Inventory(QObject *parent) : regex->setMinimal(true); mtnDelegate = new MonotoneDelegate(this); + + connect( + this, SIGNAL(modelCreated()), + this, SLOT(loadBranchName()) + ); } Inventory::~Inventory() @@ -106,7 +111,6 @@ void Inventory::parseOutput() branch->setParent(rootItem); branch->setPath("."); branch->setStatus(0); - branch->setLabel(MonotoneDelegate::getBranchName(this)); branch->setChildren(buildTreeRecursive(tempItems, NULL)); rootItem->appendChild(branch); @@ -121,6 +125,14 @@ void Inventory::parseOutput() emit modelCreated(); } +void Inventory::loadBranchName() +{ + QList children = rootItem->getChildren(); + I(children.size() > 0); + children[0]->setLabel(MonotoneDelegate::getBranchName(this)); + emit layoutChanged(); +} + QList Inventory::buildTreeRecursive(QList &items, InventoryItem* parentItem) { QList finalItems; ============================================================ --- src/model/Inventory.h 5f721ad6fa46ed5f994688debe1d0708381607b7 +++ src/model/Inventory.h e9d25b6dda9dcb6b3678cb3699da93695f4ac1ca @@ -63,6 +63,9 @@ class Inventory : public QAbstractItemMo MonotoneDelegate * mtnDelegate; QString branchName; + private slots: + void loadBranchName(); + signals: void modelCreated(); void invalidWorkspaceFormat(const QString &); ============================================================ --- src/monotone/MonotoneDelegate.cpp ad54da748affdc935bcfd2d6cd2f4242ff734a34 +++ src/monotone/MonotoneDelegate.cpp 7f53f5b2ce57902cd2522ded0d3ae08b770d6640 @@ -143,14 +143,26 @@ QString MonotoneDelegate::getBranchNameS QStringList parts = branchName.split('.'); if (parts.size() == 1) return branchName; + int maxSize = 20; + int minNeededChars = (parts.size() * 2) - 1; + QString shortBranchName; - for (int i=0, j=parts.size()-1; i=0 ; i--) { - if (parts.at(i).length() == 0) continue; - shortBranchName.append(parts.at(i).at(0)); + QString part = parts.at(i); + if ((part.size() + shortBranchName.size() + minNeededChars) > maxSize) + { + shortBranchName.prepend(part.at(0)); + } + else + { + shortBranchName.prepend(part); + } + + if (i != 0) shortBranchName.prepend("."); + minNeededChars -= 2; } - // add the rightmost part - shortBranchName.append('.').append(parts.last()); + return shortBranchName; }