#
#
# add_file "res/overlays/cdup.png"
# content [9d51d79a1e09b20ef68e57325dbaece4cf7cd83f]
#
# patch "res/guitone.qrc"
# from [4e2419e7607ad77efca5eb1f2562b0baebdc68ec]
# to [96be255eb7e90ac40df9ac4c68c8164759206b51]
#
# patch "res/i18n/guitone_de.ts"
# from [1aaaadfcb3efe96c55074583710159c1727c8832]
# to [fb8a1be96607a2c9585ff3d68c8afebe235ca1e1]
#
# patch "src/model/ProxyModel.cpp"
# from [1b27de97ee5a5b66212ae25020a22f639a7afb1a]
# to [35f2ae8f4389f091be0bf5c9f7ebe81802160341]
#
# patch "src/model/Workspace.cpp"
# from [c10e5044c0e1e6058de6a1e56c3c05ec9cbec79f]
# to [2ffc6109d1b6b53b8bae6d37909abf3a54e4be21]
#
# patch "src/model/WorkspaceItem.cpp"
# from [5cb2062ad4db01c76fcfb3a054361b94ee995262]
# to [c5dc354c387ae744864c2cb622a4bc4008270e7f]
#
# patch "src/model/WorkspaceItem.h"
# from [f66c7b5b3b8aa9522f20024f79af0448bb0c1283]
# to [e5de0897933311633bfc75c3e72a3bf931981fce]
#
# patch "src/util/IconProvider.cpp"
# from [aa0a13247a31308920846176b9c75bed31a7b28a]
# to [6904dc901b05aabb301e8fcf0324fe024a45567a]
#
# patch "src/util/IconProvider.h"
# from [107e25867b3c2f41cca16469b8de3d669f096966]
# to [f85dc7375240290c0deee174334de6e7bab3f0b5]
#
# patch "src/view/Guitone.cpp"
# from [98b4cd6b85e68b5ca5765a2dd2b1b48271a62f50]
# to [00d963cf85f3e884aa359622d75eee11427144f1]
#
# set "res/overlays/cdup.png"
# attr "mtn:manual_merge"
# value "true"
#
============================================================
# res/overlays/cdup.png is binary
============================================================
--- res/guitone.qrc 4e2419e7607ad77efca5eb1f2562b0baebdc68ec
+++ res/guitone.qrc 96be255eb7e90ac40df9ac4c68c8164759206b51
@@ -24,11 +24,12 @@
overlays/rename_target.png
overlays/unchanged.png
overlays/unknown.png
+ overlays/cdup.png
- i18n/guitone_de.qm
+ i18n/guitone_de.qm
============================================================
--- res/i18n/guitone_de.ts 1aaaadfcb3efe96c55074583710159c1727c8832
+++ res/i18n/guitone_de.ts fb8a1be96607a2c9585ff3d68c8afebe235ca1e1
@@ -320,6 +320,10 @@
Ignored
ignoriert
+
+ one level up
+ ein Verzeichnis höher
+
WorkspaceView
============================================================
--- src/model/ProxyModel.cpp 1b27de97ee5a5b66212ae25020a22f639a7afb1a
+++ src/model/ProxyModel.cpp 35f2ae8f4389f091be0bf5c9f7ebe81802160341
@@ -43,8 +43,10 @@
acceptRow &= !hideIgnored || !item->hasStatus(WorkspaceItem::Ignored);
// check if we should only display folders
acceptRow &= !folderTree || item->isDirectory();
+ // make sure we don't display pseudo "cdUp" items in the tree view
+ acceptRow &= !folderTree || !item->isCdUp();
- return acceptRow;
+ return acceptRow;
}
bool ProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
@@ -56,6 +58,9 @@
// We shall sort by the name of the item
if (sortColumn == 0)
{
+ // place cd up items always on the first position
+ if (itemLeft->isCdUp() || itemRight->isCdUp()) return false;
+
if (itemLeft->isDirectory() && itemRight->isDirectory())
{
return itemLeft->getFilename() < itemRight->getFilename();
============================================================
--- src/model/Workspace.cpp c10e5044c0e1e6058de6a1e56c3c05ec9cbec79f
+++ src/model/Workspace.cpp 2ffc6109d1b6b53b8bae6d37909abf3a54e4be21
@@ -195,11 +195,16 @@
WorkspaceItem *currentItem;
QString parentPath = "";
+ int parentStatus = 0;
if (parentItem != NULL)
{
parentPath = parentItem->getPath();
+ parentStatus = parentItem->getStatus();
}
+
+ // add pseudo item "cd up" for each directory
+ items.prepend(new WorkspaceItem(parentItem, parentPath+QString("/.."), parentStatus, true));
while (items.size() > 0)
{
@@ -226,11 +231,10 @@
//
// if the item is directory a directory, make sure we catch decendant items... recursion!
- if (currentItem->isDirectory())
+ if (currentItem->isDirectory() && !currentItem->isCdUp())
{
- //currentItem->setChildren(*(buildTreeRecursive(items, currentItem)));
currentItem->setChildren(buildTreeRecursive(items, currentItem));
- }
+ }
// append item to final list
finalItems.push_back(currentItem);
============================================================
--- src/model/WorkspaceItem.cpp 5cb2062ad4db01c76fcfb3a054361b94ee995262
+++ src/model/WorkspaceItem.cpp c5dc354c387ae744864c2cb622a4bc4008270e7f
@@ -153,17 +153,27 @@
{
switch (column)
{
- case 0: return QVariant(QString(tr("File")));
- case 1: return QVariant(QString(tr("Status")));
- default: return QVariant();
+ case 0: return QVariant(QString(tr("File")));
+ case 1: return QVariant(QString(tr("Status")));
+ default: return QVariant();
}
}
+ if (this->isCdUp())
+ {
+ switch (column)
+ {
+ case 0: return QVariant(tr("one level up"));
+ case 1: return QVariant();
+ default: return QVariant();
+ }
+ }
+
switch (column)
{
- case 0: return QVariant(getFilename());
- case 1: return QVariant(statusString());
- default: return QVariant();
+ case 0: return QVariant(getFilename());
+ case 1: return QVariant(statusString());
+ default: return QVariant();
}
}
else if (role == Qt::DecorationRole)
============================================================
--- src/model/WorkspaceItem.h f66c7b5b3b8aa9522f20024f79af0448bb0c1283
+++ src/model/WorkspaceItem.h e5de0897933311633bfc75c3e72a3bf931981fce
@@ -44,6 +44,7 @@
inline QList getChildren(void) const { return children; };
inline QString getPath(void) const { return path; };
QString getFilename(void) const;
+ inline bool isCdUp() const { return getFilename() == ".."; };
bool hasStatus(int) const;
bool hasNotStatus(int) const;
@@ -62,7 +63,6 @@
WorkspaceItem* parent(void);
QVariant data(int, int) const;
-
static const int RenamedFrom;
static const int RenamedTo;
static const int Added;
============================================================
--- src/util/IconProvider.cpp aa0a13247a31308920846176b9c75bed31a7b28a
+++ src/util/IconProvider.cpp 6904dc901b05aabb301e8fcf0324fe024a45567a
@@ -22,6 +22,8 @@
#include "IconProvider.h"
#include "../model/WorkspaceItem.h"
+const int IconProvider::CdUp = -1;
+
/**
* There are 45 possible status combinations, some of them are invalid
* We only provide for a bunch of these own icons
@@ -172,7 +174,9 @@
states[WorkspaceItem::RenamedFrom|WorkspaceItem::RenamedTo|WorkspaceItem::Ignored] = QString(":/overlays/rename_source_target_missing.png");
states[WorkspaceItem::RenamedFrom|WorkspaceItem::RenamedTo|WorkspaceItem::Missing] = QString(":/overlays/rename_source_target_missing.png");
-
+ // some special icon overlays
+ states[IconProvider::CdUp] = QString(":/overlays/cdup.png");
+
QMapIterator i(states);
while (i.hasNext())
@@ -219,6 +223,11 @@
QIcon IconProvider::getIcon(WorkspaceItem* item)
{
+ if (item->isCdUp())
+ {
+ return folderIcons.value(IconProvider::CdUp);
+ }
+
int status = item->getStatus();
if (item->isDirectory())
============================================================
--- src/util/IconProvider.h 107e25867b3c2f41cca16469b8de3d669f096966
+++ src/util/IconProvider.h f85dc7375240290c0deee174334de6e7bab3f0b5
@@ -29,6 +29,8 @@
IconProvider(void);
~IconProvider(void);
QIcon getIcon(WorkspaceItem* item);
+
+ static const int CdUp;
private:
// file and folder icons
============================================================
--- src/view/Guitone.cpp 98b4cd6b85e68b5ca5765a2dd2b1b48271a62f50
+++ src/view/Guitone.cpp 00d963cf85f3e884aa359622d75eee11427144f1
@@ -144,28 +144,45 @@
void Guitone::slotMapFolderTreeToFileList( const QModelIndex &proxyIndex )
{
-// treeView->setExpanded(treeView->selectionModel()->currentIndex(), false);
QModelIndex index = proxyModelFolderTree->mapToSource( proxyIndex );
index = proxyModelFileList->mapFromSource( index );
listView->setRootIndex(index);
}
-void Guitone::slotMapFileListToFolderTree( const QModelIndex &proxyIndex )
+void Guitone::slotMapFileListToFolderTree( const QModelIndex &proxyFileIndex )
{
- QModelIndex index = proxyModelFileList->mapToSource( proxyIndex );
- WorkspaceItem *item = static_cast(index.internalPointer());
+ // get the model index of the Workspace model
+ QModelIndex workspaceIndex = proxyModelFileList->mapToSource(proxyFileIndex);
+ WorkspaceItem *item = static_cast(workspaceIndex.internalPointer());
- if(item->isDirectory())
- {
-// treeView->setExpanded(treeView->selectionModel()->currentIndex(), false);
- listView->setRootIndex(proxyIndex);
- index = proxyModelFolderTree->mapFromSource( index );
- if(item->hasChildDirs())
- {
- treeView->expand(index);
- }
- treeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect);
- }
+ // nothing todo since we didn't receive a click on a folder
+ if (!item->isDirectory()) { return; }
+
+
+ // check if this is a pseudo diretory with which we actually go up
+ // and not down in the hierarchy
+ if (item->isCdUp())
+ {
+ // for cdUp items select the parent in the actual model instead of
+ // the proxy model, since it is filtered out in proxyModelFolderTree
+ workspaceIndex = workspaceIndex.parent().parent();
+ // list the contents of the parent of the parent directory
+ listView->setRootIndex(proxyFileIndex.parent().parent());
+ }
+ else
+ {
+ listView->setRootIndex(proxyFileIndex);
+ }
+
+ // map the workspace model index on the proxy model index of the folder tree
+ QModelIndex proxyFolderIndex = proxyModelFolderTree->mapFromSource(workspaceIndex);
+ // expand the selection if needed
+ if (item->hasChildDirs()) { treeView->expand(proxyFolderIndex); }
+ // select the item
+ treeView->selectionModel()->setCurrentIndex(
+ proxyFolderIndex,
+ QItemSelectionModel::ClearAndSelect
+ );
}
void Guitone::criticalMtnError(const QString & msg)