// Implementation of QTreeChangeNum
#include <clientapi.h>
#include <qapplication.h>
#include <qcanvas.h>
#include <qlayout.h>
#include <qmessagebox.h>
#include <qtextedit.h>
#include "qtreeitem.h"
#define QTREECHANGEDIALOG_H
#include "qtreechangedialog.h"
#include "clientchangeuser.h"
#include "qtreechangenum.h"
QTreeChangeNum::QTreeChangeNum( QCanvas* canvas, QString chng, QString tip )
: QCanvasText( canvas ), ui( ClientChangeUser() ), ctext( chng ), ttext( tip )
{
setText( ctext );
setZ( TREE_ZBARTEXT );
}
QTreeChangeNum::~QTreeChangeNum()
{
}
// Run "p4 describe" and make a QTreeChangeDialog. Once
// we've succesfully gotten a change description, leave it
// in memory to avoid re-querying the server.
void QTreeChangeNum::InfoDialog( QWidget* p, ClientApi* client, Error* e )
{
if ( ui.desc.Length() == 0 ) // Do we need to query the server?
{
client->Init( e );
if ( !e->Test() )
{
char* args[2];
args[0] = "-s";
args[1] = (char*)ctext.latin1();
client->SetArgv( 2, args );
client->Run( "describe", &ui );
client->Final( e );
}
if ( e->Test() )
{
e->Set( E_FATAL, "Could not get change description." );
StrBuf msg;
e->Fmt( &msg );
QMessageBox::warning
(
p,
"P4QTree Warning",
msg.Text(),
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton
);
}
}
if ( ui.desc.Length() == 0 ) return; // Query unsuccessful.
// If we reached this point, we have a description.
QTreeChangeDialog* dia = new QTreeChangeDialog( p, ui.desc );
dia->exec();
delete dia;
}