#
#
# patch "guitone/res/forms/main_window.ui"
# from [9bba67503299628052d9503b88909fec0aa4d7ab]
# to [09435419a1a50121c1dc99c17cf040aca87979e6]
#
# patch "guitone/src/model/Inventory.cpp"
# from [40891673d2f0b9c232012c2db529c3aab2700a43]
# to [0890179743d4c1ebec0fafe515a838979867324c]
#
# patch "guitone/src/model/Inventory.h"
# from [5833ddc9dfa3fcfb09b13621730469f59041751b]
# to [674d9096eb81627fde41a2dd58a98c8a83744216]
#
# patch "guitone/src/monotone/Monotone.cpp"
# from [37cbbf7e4353ac6e31ad206e37732cf85531e5b3]
# to [fefac914a23090c9e2df57c6dddc229bb69d8417]
#
# patch "guitone/src/view/MainWindow.cpp"
# from [386b1464f714fc595995dabbc3d1da1438e27f35]
# to [783f6c86b19c247880f2c0c4d4dcf6fb73ba71c8]
#
# patch "guitone/src/view/MainWindow.h"
# from [781c1b946f381431d22a9ef8fac33778b43e35de]
# to [828be9d558d41e9593b3d6e764a5987f3b99ad67]
#
============================================================
--- guitone/res/forms/main_window.ui 9bba67503299628052d9503b88909fec0aa4d7ab
+++ guitone/res/forms/main_window.ui 09435419a1a50121c1dc99c17cf040aca87979e6
@@ -5,8 +5,8 @@
0
0
- 926
- 790
+ 862
+ 703
@@ -70,51 +70,52 @@
- 0
+ 9
- 5
+ 6
-
-
-
- 0
+
+
+ Loaded database: %1
-
- 6
+
+ Qt::PlainText
-
-
-
-
- guitone is in database mode. This means that only parts of the functionality are available.
-You can switch back to the workspace mode at any time by loading a workspace.
-
-
- Qt::PlainText
-
-
- Qt::AlignBottom|Qt::AlignHCenter
-
-
-
- -
-
-
- Loaded database: %1
-
-
- Qt::PlainText
-
-
- Qt::AlignHCenter|Qt::AlignTop
-
-
-
-
+
+ Qt::AlignCenter
+
+
+ -
+
+
+
+ 9
+
+
+ 6
+
+
-
+
+
+ Currently there is no workspace or database loaded.
+
+To open a workspace, go to File > Open workspace
+or File > Open Database for a database respectively.
+
+
+ Qt::AlignCenter
+
+
+
+
+
+
@@ -124,7 +125,7 @@ You can switch back to the workspace mod
0
0
- 926
+ 862
22
@@ -454,16 +455,16 @@ You can switch back to the workspace mod
+ InventoryView
+ QTreeView
+
+
+
Splitter
QSplitter
- InventoryView
- QTreeView
-
-
-
AttributesView
QTreeView
============================================================
--- guitone/src/model/Inventory.cpp 40891673d2f0b9c232012c2db529c3aab2700a43
+++ guitone/src/model/Inventory.cpp 0890179743d4c1ebec0fafe515a838979867324c
@@ -105,7 +105,7 @@ void Inventory::parseOutput()
// FIXME: we shouldn't really add a workspace root item here, but
// mtn automate inventory currently doesn't print the root workspace dir
InventoryItem * branch = new InventoryItem(rootItem, ".", 0, true, true);
- branch->setLabel(getBranchName());
+ branch->setLabel(getBranchName(this));
rootItem->appendChild(branch);
branch->setChildren(buildTreeRecursive(tempItems, NULL));
@@ -372,9 +372,9 @@ bool Inventory::parseInventoryLine(
return true;
}
-QString Inventory::getOption(const QString & opt)
+QString Inventory::getOption(QObject * parent, const QString & opt)
{
- Monotone * mtn = MTN(this);
+ Monotone * mtn = MTN(parent);
int cmdNum;
mtn->executeCommand(QStringList() << "get_option" << opt, cmdNum);
@@ -383,7 +383,7 @@ QString Inventory::getOption(const QStri
if (mtn->getReturnCode(cmdNum) > 0)
{
- qCritical("Inventory::getOoption: Couldn't retrieve option %s: %s",
+ qCritical("Inventory::getOption: Couldn't retrieve option %s: %s",
qPrintable(opt), qPrintable(data));
return QString();
}
@@ -393,9 +393,9 @@ QString Inventory::getOption(const QStri
return data;
}
-QString Inventory::getBranchName()
+QString Inventory::getBranchName(QObject * parent)
{
- QString branchName = getOption("branch");
+ QString branchName = getOption(parent, "branch");
if (branchName.size() == 0)
{
@@ -404,11 +404,11 @@ QString Inventory::getBranchName()
return branchName;
}
-QString Inventory::getBranchNameShort()
+QString Inventory::getBranchNameShort(QObject * parent)
{
// FIXME: currently there is only support for the domain branch scheme
// tld.domain.project.branch
- QString branchName = getBranchName();
+ QString branchName = getBranchName(parent);
QStringList parts = branchName.split('.');
if (parts.size() == 1) return branchName;
@@ -423,3 +423,21 @@ QString Inventory::getBranchNameShort()
return shortBranchName;
}
+bool Inventory::handleError(int errCode)
+{
+ if (errCode != 2) return false;
+
+ // FIXME: normally there should only be an error if the workspace format
+ // itself is not readable (i.e. wrong monotone version for the given
+ // workspace version), but who knows what could bomb out here as well. in the
+ // meantime we ensure the user gets a proper error message. in the
+ // future we could do the task of upgrading a workspace / database
+ // format right here in guitone
+ // Starting with mtn 0.33 invalid databases are catched as early as
+ // automate stdio is run, only for 0.32 and below the database is checked
+ // on the very first command.
+
+ emit invalidWorkspaceFormat(Monotone::stripMtnPrefix(AutomateCommand::data));
+ return true;
+}
+
============================================================
--- guitone/src/model/Inventory.h 5833ddc9dfa3fcfb09b13621730469f59041751b
+++ guitone/src/model/Inventory.h 674d9096eb81627fde41a2dd58a98c8a83744216
@@ -38,9 +38,9 @@ class Inventory : public QAbstractItemMo
Inventory(QObject *parent);
~Inventory();
bool readInventory();
- QString getOption(const QString &);
- QString getBranchName();
- QString getBranchNameShort();
+ static QString getOption(QObject *, const QString &);
+ static QString getBranchName(QObject *);
+ static QString getBranchNameShort(QObject *);
// needed Qt Model methods
QVariant data(const QModelIndex&, int) const;
@@ -53,6 +53,7 @@ class Inventory : public QAbstractItemMo
private:
void parseOutput();
+ bool handleError(int);
bool parseInventoryLine(const QString &, int &, int &, int &, QString &, bool &);
QList buildTreeRecursive(QList &, InventoryItem*);
@@ -64,6 +65,7 @@ class Inventory : public QAbstractItemMo
signals:
void modelCreated();
+ void invalidWorkspaceFormat(const QString &);
};
#endif
============================================================
--- guitone/src/monotone/Monotone.cpp 37cbbf7e4353ac6e31ad206e37732cf85531e5b3
+++ guitone/src/monotone/Monotone.cpp fefac914a23090c9e2df57c6dddc229bb69d8417
@@ -628,7 +628,7 @@ QString Monotone::stripMtnPrefix(const Q
// FIXME: we should actually use basename(mtnBinaryPath) in case
// the binary is renamed, but I'm too lazy for this right now...
// and this would also require to make this method non-static
- QRegExp rx = QRegExp("^mtn:[^:]+:[ ]*(.+)");
+ QRegExp rx = QRegExp("^(?:mtn\\:)?[^:]+\\:[ ]*(.+)");
for (int i=0, j=list.size(); igetBranchNameShort())
- );
-
// add the workspace to the recent workspace list
// FIXME: the amount of recent workspaces should be made configurable
Settings::addItemToList("RecentWorkspaceList", mtn->getNormalizedWorkspacePath(), 5);
@@ -256,12 +267,6 @@ bool MainWindow::doLoadDatabase(QString
return false;
}
- QFileInfo fi(fn);
- setWindowTitle(
- tr("%1 - database mode - guitone").
- arg(fi.fileName())
- );
-
switchMode(Database);
Settings::addItemToList("RecentDatabaseList", fn, 5);
@@ -273,35 +278,55 @@ void MainWindow::switchMode(Mode m)
void MainWindow::switchMode(Mode m)
{
+ // FIXME: by switching the current mode we're also changing the window
+ // title - we should find an easy way to tell all other windows about
+ // that so a user can still recognize the entry properly
mode = m;
if (mode == Database)
{
databaseModeWidget->setVisible(true);
workspaceModeWidget->setVisible(false);
+ noneModeWidget->setVisible(false);
menuView->menuAction()->setVisible(false);
menuWorkspace->menuAction()->setVisible(false);
menuDatabase->menuAction()->setVisible(true);
+
+ QString path(MTN(this)->getDatabaseFilePath());
+
loadedDatabase->setText(tr("Loaded database: %1").arg(
MTN(this)->getDatabaseFilePath())
);
+
+ QFileInfo fi(path);
+ setWindowTitle(
+ tr("%1 - database mode - guitone").arg(fi.fileName())
+ );
}
else
if (mode == Workspace)
{
databaseModeWidget->setVisible(false);
workspaceModeWidget->setVisible(true);
+ noneModeWidget->setVisible(false);
menuView->menuAction()->setVisible(true);
menuWorkspace->menuAction()->setVisible(true);
menuDatabase->menuAction()->setVisible(true);
+
+ setWindowTitle(
+ tr("%1 - workspace mode - guitone").
+ arg(Inventory::getBranchNameShort(this))
+ );
}
else
{
- databaseModeWidget->setVisible(true);
+ databaseModeWidget->setVisible(false);
workspaceModeWidget->setVisible(false);
+ noneModeWidget->setVisible(true);
menuView->menuAction()->setVisible(false);
menuWorkspace->menuAction()->setVisible(false);
menuDatabase->menuAction()->setVisible(false);
- loadedDatabase->setText(tr("Loaded database: %1").arg(tr("No database loaded")));
+
+ setWindowTitle(tr("No workspace or database loaded - guitone"));
}
emit modeChanged(mode);
@@ -529,3 +554,31 @@ void MainWindow::on_actionAbout_Qt_trigg
qApp->aboutQt();
}
+void MainWindow::invalidWorkspaceFormat(const QString & error)
+{
+ QString workspacePath = MTN(this)->getNormalizedWorkspacePath();
+
+ QMessageBox::critical(
+ this,
+ tr("Unable to load workspace"),
+ tr("The workspace '%1' could not be loaded.\nmonotone returned:\n\n%2")
+ .arg(workspacePath)
+ .arg(error),
+ QMessageBox::Ok
+ );
+
+ Settings::removeItemFromList("RecentWorkspaceList", workspacePath);
+
+ emit updatePreviousWorkspacesMenu();
+
+ switchMode(None);
+}
+
+// this slot is called whenever a new workspace or database is loaded
+// if the current window is in "None" mode, we can safely close it because
+// it cannot be switched to something else anymore anyways
+void MainWindow::checkIfWindowClose()
+{
+ if (mode == None) QTimer::singleShot(0, this, SLOT(close()));
+}
+
============================================================
--- guitone/src/view/MainWindow.h 781c1b946f381431d22a9ef8fac33778b43e35de
+++ guitone/src/view/MainWindow.h 828be9d558d41e9593b3d6e764a5987f3b99ad67
@@ -76,6 +76,8 @@ private slots:
void openRecentDatabase();
void updateWindowList();
void activateOtherWindow();
+ void invalidWorkspaceFormat(const QString &);
+ void checkIfWindowClose();
private:
void closeEvent(QCloseEvent *);