// Implementation of QTreeFileDialog.
#include "qtreefiledialog.h"
QTreeFileDialog::QTreeFileDialog( QWidget* parent, FileHead* file )
:QDialog( parent, "File Info", true ), fh( file )
{
setCaption( "File Info" );
mainlayout = new QVBoxLayout( this, 5, 10 );
// Filename in big bold letters.
filename = new QLabel( file->name.Text(), this );
QFont fnamefont = filename->font();
fnamefont.setPointSize( fnamefont.pointSize() + 2 );
fnamefont.setBold( true );
filename->setFont( fnamefont );
mainlayout->addWidget( filename );
// File type and "(deleted)" message if applicable.
QString deld;
if ( file->head->type == DEL ) deld = " (deleted)";
else deld = "";
filetype = new QLabel( QString( "File type: " ) +
file->head->ftype.Text() + deld, this );
QFont ftypefont = filetype->font();
ftypefont.setBold( true );
filetype->setFont( ftypefont );
mainlayout->addWidget( filetype );
// Created on DATE by USER
created = new QLabel( QString( "Created on " ) +
file->tail->date.Text() + " by " +
file->tail->user.Text(), this );
mainlayout->addWidget(created);
// Last modified DATE by USER
modified = new QLabel( QString( "Last modified " ) +
file->head->date.Text() + " by " +
file->head->user.Text(), this );
mainlayout->addWidget( modified );
// Ok button
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();
// Figure out whether P4Win is around, and whether it supports
// the "-H" flag to spawn the rev history dialog. If it does,
// it'll have a "Version" registry entry as well. Note that this
// check will always fail quietly on not-Windows, which is good.
QSettings set;
set.insertSearchPath( QSettings::Windows, "\\perforce\\P4win" );
bool p4win;
set.readEntry( "Version", "", &p4win );
if ( p4win ) // Was it there? Add a new button!
{
revhist = new QPushButton( "P4Win Revision History", this );
oklayout->addWidget( revhist );
oklayout->addStretch( -1 );
connect( revhist, SIGNAL( clicked() ), this, SLOT( RevHistory() ) );
}
else revhist = NULL;
// This dialog is not resizable.
setFixedSize( sizeHint() );
}
void QTreeFileDialog::RevHistory()
{
QProcess* pro = new QProcess
( QString( "P4Win" ), this, "P4Win Revision History" );
// Pass appropriate client settings to P4Win.
pro->addArgument( "-p" );
pro->addArgument( fh->flc->client->GetPort().Text() );
pro->addArgument( "-u" );
pro->addArgument( fh->flc->client->GetUser().Text() );
pro->addArgument( "-c" );
pro->addArgument( fh->flc->client->GetClient().Text() );
pro->addArgument( "-P" );
pro->addArgument( fh->flc->client->GetPassword().Text() );
// Pass filename as "-H" arg.
pro->addArgument( "-H" );
pro->addArgument( fh->name.Text() );
// Launch process.
pro->launch( QString::null );
}
QTreeFileDialog::~QTreeFileDialog()
{
delete created;
delete filename;
delete filetype;
delete modified;
delete ok;
if ( revhist ) delete revhist;
delete oklayout;
delete mainlayout;
}