# # # add_file "src/model/Manifest.cpp" # content [1e6f8ec9929d88ea4414c7dfdfc00f07301c433d] # # add_file "src/model/Manifest.h" # content [7d896190c8ae3ff10ab30c458a97ff2991dd60c0] # # patch "guitone.pro" # from [3aade435b0c69eb7ec3fb8a0f9b2e95c7ef49f41] # to [b74cf308de08421ab0678cc1bcdec204cbe8e7ec] # # set "build.sh" # attr "bar" # value "bar # wahla # baz" # # set "build.sh" # attr "foo" # value "bar\"baz" # ============================================================ --- src/model/Manifest.cpp 1e6f8ec9929d88ea4414c7dfdfc00f07301c433d +++ src/model/Manifest.cpp 1e6f8ec9929d88ea4414c7dfdfc00f07301c433d @@ -0,0 +1,95 @@ +/*************************************************************************** + * 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 "Manifest.h" +#include "../monotone/Monotone.h" + +Manifest::Manifest() : revision("") {} + +Manifest::Manifest(QString rev) : revision(rev) {} + +Manifest::~Manifest() {} + +bool Manifest::readManifest() +{ + QString cmd("get_manifest_of"); + if (revision.size() > 0) + { + cmd.append(" ").append(revision); + } + + Monotone *mtn = Monotone::singleton(); + + connect( + mtn, SIGNAL(commandFinished(int)), + this, SLOT(parseOutput(int)) + ); + + return mtn->triggerCommand(cmd); +} + +void Manifest::parseOutput(int returnCode) +{ + QStringList *output = Monotone::singleton()->getOutput(); + + if ((returnCode > 0) && (!output->isEmpty())) + { + QString error = output->front(); + qWarning("Manifest::parseOutput: A monotone error occured: %s", qPrintable(error)); + return; + } + else if (returnCode > 0) + { + qWarning("Manifest::parseOutput: A monotone error occured (no further information available)"); + return; + } + + QStringList *lines = new QStringList(); + for (QStringList::Iterator it = output->begin(); it != output->end(); ++it) + { + QStringList tmp = (*it).split("\n"); + for (QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it) + { + lines->append(*it2); + } + } + + ManifestMap * map = new ManifestMap(); + + QRegExp regex("^\\s*(file|content)\\s+(?:\\[\")(.+?)(?:\"|\\])$"); + QString lastFile; + + for (QStringList::Iterator it = output->begin(); it != output->end(); ++it) + { + if (regex.indexIn(*it) == -1) + { + continue; + } + QStringList list = regex.capturedTexts(); + if (list[0] == "file") + { + lastFile = list[0]; + continue; + } + + map->insert(lastFile, list[1]); + } + emit manifestRead(map); +} ============================================================ --- src/model/Manifest.h 7d896190c8ae3ff10ab30c458a97ff2991dd60c0 +++ src/model/Manifest.h 7d896190c8ae3ff10ab30c458a97ff2991dd60c0 @@ -0,0 +1,45 @@ +/*************************************************************************** + * 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 MANIFEST_H +#define MANIFEST_H + +typedef QMap ManifestMap; + +class Manifest : public QObject +{ + Q_OBJECT +public: + Manifest(); + Manifest(QString); + virtual ~Manifest(); + bool readManifest(); + +signals: + void manifestRead(ManifestMap*); + +private slots: + void parseOutput(int); + +private: + QString revision; +}; + +#endif ============================================================ --- guitone.pro 3aade435b0c69eb7ec3fb8a0f9b2e95c7ef49f41 +++ guitone.pro b74cf308de08421ab0678cc1bcdec204cbe8e7ec @@ -6,6 +6,7 @@ src/model/Workspace.h \ src/model/WorkspaceItem.h \ src/model/ProxyModel.h \ + src/model/Manifest.h \ src/util/IconProvider.h \ src/util/Settings.h SOURCES += src/view/Guitone.cpp \ @@ -15,6 +16,7 @@ src/model/Workspace.cpp \ src/model/WorkspaceItem.cpp \ src/model/ProxyModel.cpp \ + src/model/Manifest.cpp \ src/util/IconProvider.cpp \ src/util/Settings.cpp \ src/main.cpp @@ -24,7 +26,7 @@ OBJECTS_DIR = tmp MOC_DIR = tmp DESTDIR = bin -TRANSLATIONS = i18n/guitone_de.ts +TRANSLATIONS = res/i18n/guitone_de.ts RESOURCES = res/guitone.qrc RCC_DIR = tmp PRECOMPILED_HEADER = src/stable.h