# # # add_file "guitone/src/model/MonotoneDelegate.cpp" # content [f564813b79704ada15184afc670d077161002e85] # # add_file "guitone/src/model/MonotoneDelegate.h" # content [61fc188fc86544101896e814b779003e670dc2b7] # ============================================================ --- guitone/src/model/MonotoneDelegate.cpp f564813b79704ada15184afc670d077161002e85 +++ guitone/src/model/MonotoneDelegate.cpp f564813b79704ada15184afc670d077161002e85 @@ -0,0 +1,75 @@ +/*************************************************************************** +* Copyright (C) 2007 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 "MonotoneDelegate.h" +#include "Monotone.h" + +#include + +MonotoneDelegate::MonotoneDelegate(AutomateCommand * cmd) : cmdModel(cmd) +{} + +MonotoneDelegate::~MonotoneDelegate() {} + +bool MonotoneDelegate::triggerCommand(const QStringList & cmd) +{ + return triggerCommand(cmd, QStringList()); +} + +bool MonotoneDelegate::triggerCommand(const QStringList & cmd, const QStringList & opts) +{ + Monotone *mtn = Monotone::singleton(); + + connect( + mtn, SIGNAL(commandFinished(int)), + this, SLOT(commandFinished(int)) + ); + + qApp->setOverrideCursor(Qt::WaitCursor); + + return mtn->triggerCommand(cmd, opts); +} + +void MonotoneDelegate::commandFinished(int retCode) +{ + Monotone *mtn = Monotone::singleton(); + + disconnect( + mtn, SIGNAL(commandFinished(int)), + this, SLOT(commandFinished(int)) + ); + + cmdModel->setAutomateData(mtn->getDataAndReset()); + + if (retCode == 0) + { + cmdModel->parseOutput(); + } + else + { + if (!cmdModel->handleError(retCode)) + { + qDebug("MonotoneDelegate::commandFinished: couldn't handle error %d", retCode); + } + } + + qApp->restoreOverrideCursor(); +} + ============================================================ --- guitone/src/model/MonotoneDelegate.h 61fc188fc86544101896e814b779003e670dc2b7 +++ guitone/src/model/MonotoneDelegate.h 61fc188fc86544101896e814b779003e670dc2b7 @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2007 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 MONOTONE_DELEGATE_H +#define MONOTONE_DELEGATE_H + +#include "AutomateCommand.h" + +#include + +class MonotoneDelegate : public QObject +{ + Q_OBJECT + +public: + MonotoneDelegate(AutomateCommand *); + ~MonotoneDelegate(); + bool triggerCommand(const QStringList &); + bool triggerCommand(const QStringList &, const QStringList &); + +private: + AutomateCommand * cmdModel; + +private slots: + void commandFinished(int); +}; + +#endif