//
// 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
//
#include "ClientSpecMenu.h"
#include "ImageManager.h"
#include "ServerThread.h"
#include "todo.h"
#include "WidgetId.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ClientSpecMenu::ClientSpecMenu( QWidget* parent, const char* name ) :
QPopupMenu( parent, name )
{
insertItem( "New...", this, SLOT(slotNew()) );
insertItem( "Edit...", this, SLOT(slotEdit()) );
insertItem( "Describe...", this, SLOT(slotDescribe()) );
insertItem( "Delete", this, SLOT(slotDelete()) );
insertSeparator();
insertItem( "Switch to Client", this, SLOT(slotSwitchToClient()) );
insertItem( "Set Default Client", this, SLOT(slotSetDefaultClient()) );
insertItem( "Create or Update Client From Template", this,
SLOT(slotCreateOrUpdateClientFromTemplate()) );
insertSeparator();
insertItem( "View Changes by", this, SLOT(slotViewChangesBy()) );
insertItem( "View Client Specs", this, SLOT(slotViewClientSpecs()) );
}
ClientSpecMenu::~ClientSpecMenu()
{
}
void ClientSpecMenu::setClientListView( ClientTable* t )
{
_clientTable = t;
}
void ClientSpecMenu::slotNew()
{
TODO();
}
void ClientSpecMenu::slotEdit()
{
TODO();
}
void ClientSpecMenu::slotDescribe()
{
TODO();
}
void ClientSpecMenu::slotDelete()
{
TODO();
}
void ClientSpecMenu::slotSwitchToClient()
{
TODO();
}
void ClientSpecMenu::slotSetDefaultClient()
{
TODO();
}
void ClientSpecMenu::slotViewChangesBy()
{
TODO();
}
void ClientSpecMenu::slotViewClientSpecs()
{
ServerThread< ClientSpecMenu, ClientSpecMenuFuncPtr >* t =
new ServerThread< ClientSpecMenu, ClientSpecMenuFuncPtr >
( this, &ClientSpecMenu::_viewClientSpecs );
}
void ClientSpecMenu::_viewClientSpecs()
{
ASSERT( _clientTable != NULL );
_clientTable->clear();
Perforce::Client* c;
Perforce::ClientList clients = Perforce::Client::getClients();
for (c = clients.first(); c != NULL; c = clients.next()) {
_clientTable->addClient( c );
}
emit showClientTable( CLIENTS_TABLE );
}
void ClientSpecMenu::slotCreateOrUpdateClientFromTemplate()
{
TODO();
}
ClientTable::ClientTable( QWidget* parent, const char* name ) :
QListView( parent, name )
{
setSelectionMode( Single );
setAllColumnsShowFocus( true );
addColumn( "Client" );
addColumn( "Owner" );
addColumn( "Host" );
addColumn( "Date" );
addColumn( "Root" );
addColumn( "Description" );
}
void ClientTable::addClient( const Perforce::Client* c )
{
QListViewItem* item = new QListViewItem( this,
c->getName(),
c->getOwner(),
c->getHost(),
c->getDate().toString(),
c->getRoot(),
c->getDescription() );
item->setPixmap( 0, ImageManager::getInstance()->getPixmap("client.png") );
}