// Implementation of QTreeRevDialog. Similar to QTreeFileDialog.
#include "qtreerevdialog.h"
#include "qtreeitem.h"
QTreeRevDialog::QTreeRevDialog( QWidget* parent, FileRev* rev )
:QDialog( parent, "Revision Info", true ), fr( rev )
{
setCaption( "Revision Info" );
mainlayout = new QVBoxLayout( this, 5, 10 );
// FILE#REV
filerevname = new QLabel(
QString( rev->fh->name.Text() ) + "#" + rev->rev.Text() , this );
QFont fnamefont = QFont( filerevname->font() );
// Big and bold
fnamefont.setPointSize( fnamefont.pointSize() + 2 );
fnamefont.setBold( true );
filerevname->setFont( fnamefont );
mainlayout->addWidget( filerevname );
// ACTIONed on DATE by USER
QString firstl = QString( rev->action.Text() );
firstl.truncate( 1 );
QString capitaction = firstl.upper() + QString( rev->action.Text() + 1 );
QString pasttense;
if ( *( rev->action.End() - 1 ) == 'e' )
pasttense = QString( "d as " );
else pasttense = QString( "ed as " );
revinfo = new QLabel( capitaction +
pasttense + rev->ftype.Text() +
" on " + rev->date.Text() +
" by " + rev->user.Text(), this );
// Make it bold
QFont ftypefont = QFont( revinfo->font() );
ftypefont.setBold( true );
revinfo->setFont( ftypefont );
mainlayout->addWidget( revinfo );
// Color-coded integ records.
integfrom = integinto = NULL;
if ( rev->fromtexts )
{
QString fromtext = QString();
for (FileTextArrow* fta = rev->fromtexts; fta; fta = fta->next)
{
fromtext += "<font color=";
FLCArrowType atype = fta->type;
if ( rev->type == EDIT || rev->type == ADD ) atype = impure;
switch ( atype )
{
case edit:
fromtext += TREE_COLARROWR;
break;
case branch:
fromtext += TREE_COLARROWB;
break;
case copy:
fromtext += TREE_COLARROWC;
break;
case ignore:
fromtext += TREE_COLARROWI;
break;
case impure:
fromtext += TREE_COLARROWE;
break;
case merge:
fromtext += TREE_COLARROWM;
break;
}
fromtext += '>';
char* file;
for ( char* ptr = fta->record.Text() ; *ptr != '/' ; ptr++ )
{
fromtext += *ptr;
file = ptr + 1;
}
fromtext += "</font>";
fromtext += file;
fromtext += "<br>";
}
integfrom = new QLabel( fromtext, this );
mainlayout->addWidget( integfrom );
}
if ( rev->intotexts )
{
QString intotext = QString();
for ( FileTextArrow* fta = rev->intotexts ; fta ; fta = fta->next )
{
intotext += "<font color=";
switch ( fta->type )
{
case edit:
intotext += TREE_COLARROWR;
break;
case branch:
intotext += TREE_COLARROWB;
break;
case copy:
intotext += TREE_COLARROWC;
break;
case ignore:
intotext += TREE_COLARROWI;
break;
case impure:
intotext += TREE_COLARROWE;
break;
case merge:
intotext += TREE_COLARROWM;
break;
}
intotext += '>';
char* file;
for ( char* ptr = fta->record.Text() ; *ptr != '/'; ptr++ )
{
intotext += *ptr;
file = ptr + 1;
}
intotext += "</font>";
intotext += file;
intotext += "<br>";
}
integinto = new QLabel( intotext, this );
mainlayout->addWidget( integinto );
}
oklayout = new QHBoxLayout( mainlayout );
oklayout->addStretch( -1 );
ok = new QPushButton( "OK", this );
oklayout->addWidget( ok );
oklayout->addStretch( -1 );
connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) );
ok->setAutoDefault( TRUE );
ok->setFocus();
QSettings set;
set.insertSearchPath( QSettings::Windows, "\\perforce\\P4win" );
bool p4win;
set.readEntry( "Version", QString::null, &p4win );
if ( p4win )
{
revhist = new QPushButton( "P4Win Revision History", this );
oklayout->addWidget( revhist );
oklayout->addStretch( -1 );
connect( revhist, SIGNAL( clicked() ), this, SLOT( RevHistory() ) );
}
else revhist = NULL;
setMaximumSize( sizeHint() );
}
void QTreeRevDialog::RevHistory()
{
QProcess* pro = new QProcess
( QString( "P4Win" ), this, "P4Win Revision History" );
pro->addArgument( "-p" );
pro->addArgument( fr->fh->flc->client->GetPort().Text() );
pro->addArgument( "-u" );
pro->addArgument( fr->fh->flc->client->GetUser().Text() );
pro->addArgument( "-c" );
pro->addArgument( fr->fh->flc->client->GetClient().Text() );
if ( fr->fh->flc->client->GetPassword().Length() )
{
pro->addArgument( "-P" );
pro->addArgument( fr->fh->flc->client->GetPassword().Text() );
}
pro->addArgument( "-H" );
pro->addArgument( QString( fr->fh->name.Text() ) + "#" + fr->rev.Text() );
pro->launch( QString::null );
}
QTreeRevDialog::~QTreeRevDialog()
{
delete ok;
if ( revhist ) delete revhist;
delete filerevname;
delete integfrom;
delete integinto;
delete revinfo;
delete oklayout;
delete mainlayout;
}