# # # add_file "src/model/ProxyModel.cpp" # content [33a2aa64503af5ed6d785e1fcbc626fa9a54f934] # # add_file "src/model/ProxyModel.h" # content [6b9454fa9b6dd24bd6143a4e6324ecc0b4c8db58] # # patch "guitone.pro" # from [13e47531d4419f9a868239eae3466057cab440be] # to [4cff513996bc63b4312d8af30f0d5a41be2dae96] # # patch "src/model/IconProvider.cpp" # from [c96947be26f0a3665a14b501416afbeaff7be2d4] # to [6112b4df6ccc25ffdabb9ced7fe8fb148b2181da] # # patch "src/model/IconProvider.h" # from [885144fb251922aa222e90a0cbd3de49583ead14] # to [ad472297ccdf1b6de1f0460ebbf83b82a6f3eeb7] # # patch "src/stable.h" # from [3a167b78f2f1c2aa7cb024962a1d9e7b0b0438e3] # to [6be564f3b1a5223104450daf8e28e5111d82042d] # # patch "src/view/Guitone.cpp" # from [613f05389f207af2e7a267b624a7d754e1d86e71] # to [210d32133d10fd3815f5f365455042a535561ac7] # # patch "src/view/Guitone.h" # from [8f614347750418fabecb935530e5037eda3b703d] # to [c461fbaadd94fd1d580e90c031ceb014ebfd095f] # # patch "src/view/WorkspaceView.cpp" # from [3f738b532f9a844a84c890d48bbafc84bac38a9b] # to [b806e88f671e91c33a0ef6ef5cfb147b1b691563] # ============================================================ --- src/model/ProxyModel.cpp 33a2aa64503af5ed6d785e1fcbc626fa9a54f934 +++ src/model/ProxyModel.cpp 33a2aa64503af5ed6d785e1fcbc626fa9a54f934 @@ -0,0 +1,54 @@ +/*************************************************************************** + * 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" +#include "WorkspaceItem.h" + +ProxyModel::ProxyModel(QObject *parent, bool folderTree_) +: QSortFilterProxyModel(parent), folderTree(folderTree_) +{ +} + +ProxyModel::~ProxyModel(void) +{ +} + +bool ProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const +{ + QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); + WorkspaceItem *item = static_cast(index.internalPointer()); + + if(folderTree) + { + if(item->isDirectory()) + { + return true; + } + else + { + return false; + } + } + else + { + return true; + } +} ============================================================ --- src/model/ProxyModel.h 6b9454fa9b6dd24bd6143a4e6324ecc0b4c8db58 +++ src/model/ProxyModel.h 6b9454fa9b6dd24bd6143a4e6324ecc0b4c8db58 @@ -0,0 +1,36 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + +#ifndef PROXYMODEL_H +#define PROXYMODEL_H + +#include + +class ProxyModel : public QSortFilterProxyModel +{ +public: + explicit ProxyModel(QObject * parent, bool folderTree_); + ~ProxyModel(void); + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; +private: + bool folderTree; +}; + +#endif ============================================================ --- guitone.pro 13e47531d4419f9a868239eae3466057cab440be +++ guitone.pro 4cff513996bc63b4312d8af30f0d5a41be2dae96 @@ -1,16 +1,18 @@ CONFIG += qt debug precompile_header HEADERS += src/view/Guitone.h \ src/view/WorkspaceView.h \ src/model/Monotone.h \ src/model/Workspace.h \ src/model/WorkspaceItem.h \ - src/model/IconProvider.h + src/model/IconProvider.h \ + src/model/ProxyModel.h SOURCES += src/view/Guitone.cpp \ src/view/WorkspaceView.cpp \ src/model/Monotone.cpp \ src/model/Workspace.cpp \ src/model/WorkspaceItem.cpp \ src/model/IconProvider.cpp \ + src/model/ProxyModel.cpp \ src/main.cpp TEMPLATE = app DEPENDPATH += src ============================================================ --- src/model/IconProvider.cpp c96947be26f0a3665a14b501416afbeaff7be2d4 +++ src/model/IconProvider.cpp 6112b4df6ccc25ffdabb9ced7fe8fb148b2181da @@ -26,11 +26,14 @@ { iconDirUnchanged = new QIcon(); iconDirChanged = new QIcon(); + iconDirUnknown = new QIcon(); QStyle *style = QApplication::style(); iconDirUnchanged->addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon)); iconDirUnchanged->addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon), QIcon::Normal, QIcon::On); iconDirChanged->addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon)); iconDirChanged->addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon), QIcon::Normal, QIcon::On); + iconDirUnknown->addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon)); + iconDirUnknown->addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon), QIcon::Normal, QIcon::On); } IconProvider::~IconProvider(void) @@ -51,6 +54,10 @@ { return *iconDirChanged; } + else if(item->hasStatus(WorkspaceItem::Unknown)) + { + return *iconDirUnknown; + } } ============================================================ --- src/model/IconProvider.h 885144fb251922aa222e90a0cbd3de49583ead14 +++ src/model/IconProvider.h ad472297ccdf1b6de1f0460ebbf83b82a6f3eeb7 @@ -34,6 +34,7 @@ private: QIcon *iconDirUnchanged; QIcon *iconDirChanged; + QIcon *iconDirUnknown; }; #endif ============================================================ --- src/stable.h 3a167b78f2f1c2aa7cb024962a1d9e7b0b0438e3 +++ src/stable.h 6be564f3b1a5223104450daf8e28e5111d82042d @@ -35,13 +35,14 @@ #include #include #include +#include #include #include #include #include #include #include - +#include // Other lib includes #include ============================================================ --- src/view/Guitone.cpp 613f05389f207af2e7a267b624a7d754e1d86e71 +++ src/view/Guitone.cpp 210d32133d10fd3815f5f365455042a535561ac7 @@ -20,6 +20,9 @@ #include "Guitone.h" #include "../model/Monotone.h" +#include "../model/Workspace.h" +#include "../model/ProxyModel.h" +#include "../view/WorkspaceView.h" Guitone::Guitone() : QMainWindow() @@ -55,15 +58,33 @@ // Main view // QSplitter *mainSplitter = new QSplitter(this); - QItemSelectionModel *selection = new QItemSelectionModel(myWorkspace); + // + // ProxyModels + // + proxyModelFolderTree = new ProxyModel(this, true); + proxyModelFileList = new ProxyModel(this, false); + proxyModelFolderTree->setSourceModel(myWorkspace); + proxyModelFileList->setSourceModel(myWorkspace); + //QItemSelectionModel *selection = new QItemSelectionModel(myWorkspace); + + // + // TreeViews + // treeView = new WorkspaceView(mainSplitter, WorkspaceView::FolderTree); treeView->setModel(myWorkspace); - treeView->setSelectionModel(selection); + //treeView->setModel(proxyModelFolderTree); + //treeView->setSelectionModel(selection); listView = new WorkspaceView(mainSplitter, WorkspaceView::FileList); listView->setModel(myWorkspace); - listView->setSelectionModel(selection); + //listView->setModel(proxyModelFileList); + //listView->setSelectionModel(selection); + + connect( + treeView, SIGNAL(pressed(const QModelIndex &)), + listView, SLOT(setRootIndex(const QModelIndex &)) + ); /* treeView->setRootIndex(mySandbox->index(0,0)); listView->setRootIndex(mySandbox->index(0,0)); ============================================================ --- src/view/Guitone.h 8f614347750418fabecb935530e5037eda3b703d +++ src/view/Guitone.h c461fbaadd94fd1d580e90c031ceb014ebfd095f @@ -28,6 +28,9 @@ class QMenu; class QMainWindow; +class ProxyModel; +class Workspace; +class WorkspaceView; // // Lib-Includes // @@ -36,8 +39,6 @@ // // Own-Includes // -#include "../model/Workspace.h" -#include "../view/WorkspaceView.h" class Guitone: public QMainWindow { @@ -55,6 +56,8 @@ QMenu *menu; QToolBar *toolBar; Workspace *myWorkspace; + ProxyModel *proxyModelFolderTree; + ProxyModel *proxyModelFileList; WorkspaceView *treeView; WorkspaceView *listView; ============================================================ --- src/view/WorkspaceView.cpp 3f738b532f9a844a84c890d48bbafc84bac38a9b +++ src/view/WorkspaceView.cpp b806e88f671e91c33a0ef6ef5cfb147b1b691563 @@ -25,6 +25,8 @@ { setSelectionMode(QAbstractItemView::ExtendedSelection); setRootIsDecorated(true); + header()->setClickable(true); + header()->setSortIndicatorShown(true); createAndConnectContextActions(); /*