# # # patch "src/model/ProxyModel.cpp" # from [33a2aa64503af5ed6d785e1fcbc626fa9a54f934] # to [7b0da75db630ea4f85e1d2b77e666e20bd44479c] # # patch "src/model/ProxyModel.h" # from [6b9454fa9b6dd24bd6143a4e6324ecc0b4c8db58] # to [2076d7cc7a45f1965beae2c23c9b3a22912eaab6] # # patch "src/view/Guitone.cpp" # from [210d32133d10fd3815f5f365455042a535561ac7] # to [913b14d2673d800dc2ed3592e8f2247a83fcc6a0] # # patch "src/view/Guitone.h" # from [c461fbaadd94fd1d580e90c031ceb014ebfd095f] # to [a98636d06c384e82e671b09ae011696f03b6c44c] # # patch "src/view/WorkspaceView.cpp" # from [b806e88f671e91c33a0ef6ef5cfb147b1b691563] # to [16cc1101bfbf4997b2c1aa96861803b5653162ef] # # patch "src/view/WorkspaceView.h" # from [61e409a912c1dfec4aaeea5d38e6c87ea203af5e] # to [f9ddf6c3ccfc484353c49b82b8e948da760fa54b] # ============================================================ --- src/model/ProxyModel.cpp 33a2aa64503af5ed6d785e1fcbc626fa9a54f934 +++ src/model/ProxyModel.cpp 7b0da75db630ea4f85e1d2b77e666e20bd44479c @@ -1,22 +1,22 @@ /*************************************************************************** - * Copyright (C) 2006 by Ingo Maindorfer * - * address@hidden * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ +* Copyright (C) 2006 by Ingo Maindorfer * +* address@hidden * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ #include "stable.h" #include "ProxyModel.h" @@ -52,3 +52,30 @@ return true; } } + +bool ProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const +{ + //TODO: Need some tweaking for correct sorting when clicked on different headers + WorkspaceItem *itemLeft = static_cast(left.internalPointer()); + WorkspaceItem *itemRight = static_cast(right.internalPointer()); + + if(itemLeft->isDirectory() && itemRight->isDirectory()) + { + return itemLeft->getFilename() < itemRight->getFilename(); + } + + if(!itemLeft->isDirectory() && !itemRight->isDirectory()) + { + return itemLeft->getFilename() < itemRight->getFilename(); + } + + if(itemLeft->isDirectory() && !itemRight->isDirectory()) + { + return true; + } + + if(!itemLeft->isDirectory() && itemRight->isDirectory()) + { + return false; + } +} ============================================================ --- src/model/ProxyModel.h 6b9454fa9b6dd24bd6143a4e6324ecc0b4c8db58 +++ src/model/ProxyModel.h 2076d7cc7a45f1965beae2c23c9b3a22912eaab6 @@ -25,10 +25,13 @@ class ProxyModel : public QSortFilterProxyModel { + public: explicit ProxyModel(QObject * parent, bool folderTree_); ~ProxyModel(void); bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + bool lessThan(const QModelIndex &left, const QModelIndex &right) const; + private: bool folderTree; }; ============================================================ --- src/view/Guitone.cpp 210d32133d10fd3815f5f365455042a535561ac7 +++ src/view/Guitone.cpp 913b14d2673d800dc2ed3592e8f2247a83fcc6a0 @@ -66,25 +66,26 @@ proxyModelFolderTree->setSourceModel(myWorkspace); proxyModelFileList->setSourceModel(myWorkspace); - //QItemSelectionModel *selection = new QItemSelectionModel(myWorkspace); - // // TreeViews // treeView = new WorkspaceView(mainSplitter, WorkspaceView::FolderTree); - treeView->setModel(myWorkspace); - //treeView->setModel(proxyModelFolderTree); - //treeView->setSelectionModel(selection); + treeView->setModel(proxyModelFolderTree); listView = new WorkspaceView(mainSplitter, WorkspaceView::FileList); - listView->setModel(myWorkspace); - //listView->setModel(proxyModelFileList); - //listView->setSelectionModel(selection); - + listView->setModel(proxyModelFileList); + connect( - treeView, SIGNAL(pressed(const QModelIndex &)), - listView, SLOT(setRootIndex(const QModelIndex &)) + treeView, SIGNAL(clicked(const QModelIndex &)), + this, SLOT(slotMapFolderTreeToFileList(const QModelIndex &)) ); + + connect( + listView, SIGNAL(doubleClicked(const QModelIndex &)), + this, SLOT(slotMapFileListToFolderTree(const QModelIndex &)) + ); + + /* treeView->setRootIndex(mySandbox->index(0,0)); listView->setRootIndex(mySandbox->index(0,0)); @@ -112,6 +113,27 @@ Guitone::~Guitone() {} +void Guitone::slotMapFolderTreeToFileList( const QModelIndex &proxyIndex ) +{ + QModelIndex index = proxyModelFolderTree->mapToSource( proxyIndex ); + index = proxyModelFileList->mapFromSource( index ); + listView->setRootIndex(index); +} + +void Guitone::slotMapFileListToFolderTree( const QModelIndex &proxyIndex ) +{ + QModelIndex index = proxyModelFileList->mapToSource( proxyIndex ); + WorkspaceItem *item = static_cast(index.internalPointer()); + + if(item->isDirectory()) + { + listView->setRootIndex(proxyIndex); + index = proxyModelFolderTree->mapFromSource( index ); + treeView->expand(index); + treeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate); + } +} + void Guitone::criticalMtnError(const QString & msg) { if (gotError == false) ============================================================ --- src/view/Guitone.h c461fbaadd94fd1d580e90c031ceb014ebfd095f +++ src/view/Guitone.h a98636d06c384e82e671b09ae011696f03b6c44c @@ -24,13 +24,15 @@ // // Forward class declarations // +class QMenu; class QToolBar; -class QMenu; +class QListView; class QMainWindow; +class Workspace; class ProxyModel; -class Workspace; class WorkspaceView; + // // Lib-Includes // @@ -51,6 +53,8 @@ void chooseWorkspace(); void criticalMtnError(const QString &); //void doFindAndSelectItem( WorkspaceItem* ); + void slotMapFolderTreeToFileList( const QModelIndex & proxyIndex ); + void slotMapFileListToFolderTree( const QModelIndex & proxyIndex ); private: QMenu *menu; ============================================================ --- src/view/WorkspaceView.cpp b806e88f671e91c33a0ef6ef5cfb147b1b691563 +++ src/view/WorkspaceView.cpp 16cc1101bfbf4997b2c1aa96861803b5653162ef @@ -20,11 +20,21 @@ #include "WorkspaceView.h" -WorkspaceView::WorkspaceView(QWidget* parent, int type) -: QTreeView(parent) +WorkspaceView::WorkspaceView(QWidget* parent, Type type_) +: QTreeView(parent), type(type_) { + if(type == FileList) + { + setRootIsDecorated(false); + setItemsExpandable(false); + } + else + { + setRootIsDecorated(true); + } + setSelectionMode(QAbstractItemView::ExtendedSelection); - setRootIsDecorated(true); + header()->setClickable(true); header()->setSortIndicatorShown(true); ============================================================ --- src/view/WorkspaceView.h 61e409a912c1dfec4aaeea5d38e6c87ea203af5e +++ src/view/WorkspaceView.h f9ddf6c3ccfc484353c49b82b8e948da760fa54b @@ -32,13 +32,17 @@ Q_OBJECT public: - WorkspaceView(QWidget*, int); + enum Type{ + FolderTree = 1, + FileList = 2 + }; + + WorkspaceView(QWidget*, Type); ~WorkspaceView(); void contextMenuEvent(QContextMenuEvent * ev); + //void mouseDoubleClickEvent ( QMouseEvent * event ){} - static const int FolderTree = 1; - static const int FileList = 2; /* void setItems(QList*); bool selectItem(WorkspaceItem*); @@ -86,6 +90,8 @@ QAction *actRevert; QAction *actRename; + Type type; + private slots: void slotAdd(void); void slotRemove(void);