//
//
// 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
//
// TODO: find legit copyright.
//
#include "P4Process.h"
#include "ConfigOptions.h"
#include "qperforceWindow.h"
#include "SubmittedChangeList.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 = Perforce::User::createNewUser( *iter );
l.append( u );
}
return l;
}
const Perforce::SubmittedChangeListList P4Process::getSubmittedChangeLists()
{
Perforce::SubmittedChangeListList l;
exec( "p4 changes -m 100 -s submitted" );
QStringList::Iterator iter;
for (iter = _cmdStdOutput.begin(); iter != _cmdStdOutput.end(); ++iter) {
Perforce::SubmittedChangeList* scl =
Perforce::SubmittedChangeList::createNewChangeList( *iter );
l.append( scl );
}
return l;
}