// Implementation of QTreeJobText
#include <clientapi.h>
#include <qcanvas.h>
#include <qlayout.h>
#include <qmessagebox.h>
#include <qtextedit.h>
#include "qtreeitem.h"
#include "clientjobdescuser.h"
#include "qtreejobtext.h"
#define QTREEJOBDIALOG_H
#include "qtreejobdialog.h"
QTreeJobText::QTreeJobText( QCanvas* canvas )
: QCanvasText( canvas ), ui( ClientJobDescUser() )
{
setZ( TREE_ZBARTEXT );
setColor( QColor( "black" ) );
}
QTreeJobText::~QTreeJobText()
{
}
// This function is provided to allow QTreeJobBar to maintain the
// JobTexts as a linked list.
QTreeJobText* QTreeJobText::AddNext( StrBuf &jname, StrBuf &truename )
{
next = new QTreeJobText( canvas() );
next->setText( QString( jname.Text() ) );
next->jobname = truename.Text();
return next;
}
// This is nearly identical to QTreeChangeNum::InfoDialog. //
// The main difference lies in the ClientUser classes used.
void QTreeJobText::InfoDialog( QWidget* parent, ClientApi* client, Error* e )
{
if ( ui.desc.Length() == 0 )
{
client->Init( e );
if ( !e->Test() )
{
char* args[2];
args[0] = "-o";
args[1] = (char*)jobname.latin1();
client->SetArgv( 2, args );
client->Run( "job", &ui );
client->Final( e );
}
if ( e->Test() )
{
e->Set( E_FATAL, "Could not get job description." );
StrBuf msg;
e->Fmt( &msg );
QMessageBox::warning
(
parent,
QString( "P4QTree Warning" ),
QString( msg.Text() ),
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton
);
}
}
if ( ui.desc.Length() == 0 ) return;
QTreeJobDialog* dia = new QTreeJobDialog( parent, ui.desc );
dia->exec();
delete dia;
}
QString QTreeJobText::Tip()
{
if ( jobname != text() ) return jobname;
else return QString("Job ") + jobname;
}