# # # add_file "guitone/src/view/FileAssignments.cpp" # content [4f57c943b8a854127c1af4619bdbf76018ede5c0] # # add_file "guitone/src/view/FileAssignments.h" # content [03e1be9d35eab65737b4b4dd82dbd0963c1a67d7] # # patch "guitone/guitone.pro" # from [5bd80b82a718f83b2d28c60a5c8de9d78d06811a] # to [b03dd7c79d305cd0a61ebda2f2f6df58b60a9d16] # # patch "guitone/res/dialogs/preferences.ui" # from [29af39c15dc51aa1da5783125bccbc00f4086feb] # to [ca6e42971070facfb334bdc8194ae2e51ab912a0] # # patch "guitone/src/view/dialogs/Preferences.cpp" # from [0521f0b9c40bbfcd7100fbf12ff91ea68ce14279] # to [f621ddf5b91e44b27dfc798985d0af4603099102] # ============================================================ --- guitone/src/view/FileAssignments.cpp 4f57c943b8a854127c1af4619bdbf76018ede5c0 +++ guitone/src/view/FileAssignments.cpp 4f57c943b8a854127c1af4619bdbf76018ede5c0 @@ -0,0 +1,84 @@ +/*************************************************************************** + * Copyright (C) 2006 by Thomas Keller * + * 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 "FileAssignments.h" +#include "../util/Settings.h" + +FileAssignments::FileAssignments(QWidget* parent) +: QTreeWidget(parent) +{ + setColumnCount(2); + setSelectionMode(SingleSelection); + setSortingEnabled(true); + setRootIsDecorated(false); + + currentEditItem = 0; + + QStringList labels; + labels << tr("Wildcard") << tr("Open with..."); + setHeaderLabels(labels); + + connect( + this, SIGNAL(itemActivated(QTreeWidgetItem *, int)), + this, SLOT(openEditor(QTreeWidgetItem *, int)) + ); +} + +FileAssignments::~FileAssignments() +{ + closeEditor(); +} + +void FileAssignments::openEditor(QTreeWidgetItem * item, int column) +{ + closeEditor(); + openPersistentEditor(item, 0); + currentEditItem = item; +} + +void FileAssignments::closeEditor() +{ + if (currentEditItem) closePersistentEditor(currentEditItem, 0); +} + +void FileAssignments::addNewRow() +{ + closeEditor(); + static int foo = 0; + QTreeWidgetItem * newItem = new QTreeWidgetItem(); + newItem->setText(0, QString("FOO %1").arg(foo++)); + addTopLevelItem(newItem); + + openPersistentEditor(newItem, 0); + currentEditItem = newItem; +} + +void FileAssignments::removeCurrentRow() +{ + QList items = selectedItems(); + Q_ASSERT(items.size() <= 1); + if (items.size() == 1) + { + QModelIndex index = indexFromItem(items.at(0)); + // there is no explicit remove() function... + takeTopLevelItem(index.row()); + } +} + ============================================================ --- guitone/src/view/FileAssignments.h 03e1be9d35eab65737b4b4dd82dbd0963c1a67d7 +++ guitone/src/view/FileAssignments.h 03e1be9d35eab65737b4b4dd82dbd0963c1a67d7 @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2006 by Thomas Keller * + * 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 FILE_ASSIGNMENTS_H +#define FILE_ASSIGNMENTS_H + +#include + +class FileAssignments : public QTreeWidget +{ + Q_OBJECT + +public: + FileAssignments(QWidget*); + ~FileAssignments(); + +public slots: + void addNewRow(); + void removeCurrentRow(); + +private: + QTreeWidgetItem * currentEditItem; + void closeEditor(); + +private slots: + void openEditor(QTreeWidgetItem *, int); +}; + +#endif ============================================================ --- guitone/guitone.pro 5bd80b82a718f83b2d28c60a5c8de9d78d06811a +++ guitone/guitone.pro b03dd7c79d305cd0a61ebda2f2f6df58b60a9d16 @@ -12,6 +12,7 @@ HEADERS += src/view/Guitone.h \ src/view/AttributesView.h \ src/view/DiffView.h \ src/view/DiffStatusView.h \ + src/view/FileAssignments.h \ src/view/dialogs/SwitchWorkspaceRevision.h \ src/view/dialogs/Preferences.h \ src/view/dialogs/AncestryGraph.h \ @@ -45,6 +46,7 @@ SOURCES += src/view/Guitone.cpp \ src/view/AttributesView.cpp \ src/view/DiffView.cpp \ src/view/DiffStatusView.cpp \ + src/view/FileAssignments.cpp \ src/view/dialogs/SwitchWorkspaceRevision.cpp \ src/view/dialogs/Preferences.cpp \ src/view/dialogs/AncestryGraph.cpp \ ============================================================ --- guitone/res/dialogs/preferences.ui 29af39c15dc51aa1da5783125bccbc00f4086feb +++ guitone/res/dialogs/preferences.ui ca6e42971070facfb334bdc8194ae2e51ab912a0 @@ -1,15 +1,12 @@ - - - PreferencesDialog 0 0 - 404 - 140 + 431 + 316 @@ -93,6 +90,71 @@ + + + Open file assignments + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + + + + 0 + + + 6 + + + + + Add + + + + + + + Remove + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 0 @@ -133,7 +195,13 @@ - + + + FileAssignments + QTreeView +
../FileAssignments.h
+
+
mtnExecutablePath selectMtnExecutable ============================================================ --- guitone/src/view/dialogs/Preferences.cpp 0521f0b9c40bbfcd7100fbf12ff91ea68ce14279 +++ guitone/src/view/dialogs/Preferences.cpp f621ddf5b91e44b27dfc798985d0af4603099102 @@ -36,6 +36,16 @@ Preferences::Preferences(QWidget* parent selectMtnExecutable, SIGNAL(clicked()), this, SLOT(openFileBrowser()) ); + + connect( + addAssignment, SIGNAL(clicked()), + fileAssignments, SLOT(addNewRow()) + ); + + connect( + removeAssignment, SIGNAL(clicked()), + fileAssignments, SLOT(removeCurrentRow()) + ); } Preferences::~Preferences() {}