//
// QPerforce is a gui interface to the perforce revision control
// system. It is based on the qt library, and should be easily portable
// across any platform that has this toolkit available.
//
// Copyright (C) 2002 Jacob Gladish
//
// 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 "P4Process.h"
#include "ConfigOptions.h"
#include "qperforceWindow.h"
#include <qstring.h>
#include <qapplication.h>
static const QString ROOT_COMMAND = "p4";
P4Process::P4Process()
{
}
P4Process::~P4Process()
{
}
void P4Process::exec( const QString& args )
{
// print to status pane of configuration is set.
ConfigOptions* opts = ConfigOptions::getInstance();
if (opts->showP4Commands()) {
QString msg = "Executing ";
qperforceWindow* win = qperforceWindow::getInstance();
win->appendUserMessage( msg.append(args) );
}
qDebug( "Setting wait cursor." );
QApplication::setOverrideCursor( Qt::waitCursor );
#ifdef WIN32
_win32Exec( args );
#else
// other platofrm code here.
// use QProcess if we get qt > 3.x
#endif
qDebug( "Setting arrow cursor." );
QApplication::restoreOverrideCursor();
}
const Perforce::UserList P4Process::getUsers()
{
Perforce::UserList l;
// l.setAutoDelete( true );
// blocks here until command completes...
exec( "p4 users" );
// qDebug( "Number of lines: %d", _cmdStdOutput.count() );
// qDebug( "First Entry: %s", _cmdStdOutput[0].latin1() );
// qDebug( "Last Entry: %s", _cmdStdOutput[_cmdStdOutput.count()-1].latin1() );
// parse returned data, and construct list.
QStringList::Iterator iter;
for (iter = _cmdStdOutput.begin(); iter != _cmdStdOutput.end(); ++iter) {
Perforce::User* u = new Perforce::User( *iter );
l.append( u );
}
return l;
}