# # # patch "guitone/src/model/Inventory.cpp" # from [547fc8cf017c30da0f7a2772013d83f42c63a28f] # to [1af9a8899413850895713e97f1dbce9bc77840fb] # # patch "guitone/src/model/Inventory.h" # from [06b97a117b824cfa76995e6895a711a1d41e6076] # to [c2e138ad64013bad901b7070063e3b18548161bf] # # patch "guitone/src/model/InventoryItem.cpp" # from [940ee31302a885f24f2658630ba64e259b6fda42] # to [9eb81493b6092c46b528a522164a675de9fef054] # # patch "guitone/src/model/InventoryItem.h" # from [74e2924b72a68f29d5f0eb7b4f791e1c8c6a05d5] # to [464d95ea5c0e49c0eed7c07353de955bc69ef26f] # ============================================================ --- guitone/src/model/Inventory.cpp 547fc8cf017c30da0f7a2772013d83f42c63a28f +++ guitone/src/model/Inventory.cpp 1af9a8899413850895713e97f1dbce9bc77840fb @@ -252,6 +252,11 @@ bool Inventory::setData(const QModelInde return true; } +bool Inventory::setItemData(const QModelIndex & index, const QMap & roles) +{ + return false; +} + Qt::ItemFlags Inventory::flags(const QModelIndex &index) const { if (!index.isValid()) return 0; @@ -313,6 +318,18 @@ int Inventory::rowCount(const QModelInde return parentItem->childCount(); } +bool Inventory::insertRows(int row, int count, const QModelIndex & parent) +{ + // FIXME: implement item adding + return false; +} + +bool Inventory::insertColumns(int column, int count, const QModelIndex & parent) +{ + // FIXME: implement item adding + return false; +} + bool Inventory::parseInventoryLine( const QString &inputString, int &status, ============================================================ --- guitone/src/model/Inventory.h 06b97a117b824cfa76995e6895a711a1d41e6076 +++ guitone/src/model/Inventory.h c2e138ad64013bad901b7070063e3b18548161bf @@ -45,12 +45,15 @@ class Inventory : public QAbstractItemMo // needed Qt Model methods QVariant data(const QModelIndex&, int) const; bool setData(const QModelIndex &, const QVariant &, int role = Qt::EditRole); + bool setItemData(const QModelIndex &, const QMap &); Qt::ItemFlags flags(const QModelIndex&) const; QVariant headerData(int, Qt::Orientation, int) const; QModelIndex index(int, int, const QModelIndex&) const; QModelIndex parent(const QModelIndex&) const; int rowCount(const QModelIndex&) const; - int columnCount(const QModelIndex&) const; + int columnCount(const QModelIndex&) const; + bool insertRows(int, int, const QModelIndex & parent = QModelIndex()); + bool insertColumns(int, int, const QModelIndex & parent = QModelIndex()); private: void parseOutput(); ============================================================ --- guitone/src/model/InventoryItem.cpp 940ee31302a885f24f2658630ba64e259b6fda42 +++ guitone/src/model/InventoryItem.cpp 9eb81493b6092c46b528a522164a675de9fef054 @@ -62,21 +62,14 @@ InventoryItem::~InventoryItem() children.clear(); } - -void InventoryItem::setLabel(const QString & l) +QString InventoryItem::getItemName() const { - label = l; -} - -QString InventoryItem::getLabel() const -{ - QString labelString(getFilename()); if (label.size() > 0) { - labelString = label; + return label; } - return labelString; + return getFilename(); } void InventoryItem::deleteAllChildren(void) @@ -138,7 +131,7 @@ QVariant InventoryItem::data(int column, switch (column) { - case 0: return QVariant(getLabel()); + case 0: return QVariant(getItemName()); case 1: return QVariant(getStatusString()); case 2: return QVariant(getRenameInfo()); default: return QVariant(); @@ -310,6 +303,8 @@ bool InventoryItem::rename(const QString // apparently its not, lets create a new rename entry InventoryItem * renamedItem = new InventoryItem(this); + parentItem->appendChild(renamedItem); + renamedItem->setStatus(status | InventoryItem::RenamedTo); setStatus(status | InventoryItem::RenamedFrom); @@ -318,6 +313,16 @@ bool InventoryItem::rename(const QString renamedItem->setRenamedFrom(this); this->setRenamedTo(renamedItem); + // remove any children from the renamed_from item, these entries + // are now part of the renamed_to item + // FIXME: this crashes, we probably need to do this directly in the model + /* + if (isDirectory()) + { + deleteAllChildren(); + } + */ + qDebug("InventoryItem::rename: created new rename item"); return true; ============================================================ --- guitone/src/model/InventoryItem.h 74e2924b72a68f29d5f0eb7b4f791e1c8c6a05d5 +++ guitone/src/model/InventoryItem.h 464d95ea5c0e49c0eed7c07353de955bc69ef26f @@ -50,6 +50,8 @@ public: inline bool isRootDirectory(void) const { return rootFlag; } inline int getStatus(void) const { return status; } inline void setStatus(int st) { status = st; } + inline void setLabel(const QString & l) { label = l; } + inline QString getLabel() const { return label; } inline InventoryItem * child(int row) const { return children.value(row); } inline int childCount(void) const { return children.count(); }; @@ -62,9 +64,6 @@ public: QString getFilename(void) const; QString getBaseDirectory(void) const; - void setLabel(const QString &); - QString getLabel() const; - bool hasStatus(int) const; bool hasNotStatus(int) const; int getStatusRecursive() const; @@ -87,6 +86,7 @@ private: static const int Ignored; private: + QString getItemName(void) const; QString getStatusString(void) const; QString getRenameInfo(void) const;