00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include <qcheckbox.h>
00013
#include <qlineedit.h>
00014
#include <qpushbutton.h>
00015
#include <qcombobox.h>
00016
00017
#include <klistview.h>
00018
#include <kurlrequester.h>
00019
#include <klocale.h>
00020
#include <kmessagebox.h>
00021
#include <kfiledialog.h>
00022
#include <kcursor.h>
00023
#include <kdebug.h>
00024
00025
#include <dcopref.h>
00026
#include <cvsjob_stub.h>
00027
#include <repository_stub.h>
00028
#include <cvsservice_stub.h>
00029
00030
#include "checkoutdialogbase.h"
00031
00032
#include "checkoutdialog.h"
00033
00035
00037
00038
const QString SSS(
":" );
00039
00041
00043
00044 class ModuleListViewItem :
public KListViewItem
00045 {
00046
public:
00047 ModuleListViewItem(
KListView *listview,
00048
const QString &moduleAlias,
const QString &moduleRealPath )
00049 :
KListViewItem( listview )
00050 {
00051
setAlias( moduleAlias );
00052
setRealPath( moduleRealPath );
00053 }
00054
00055 void setAlias(
const QString &aName ) { setText( 0, aName); }
00056 QString alias()
const {
return text(0); }
00057 void setRealPath(
const QString &aRealPath ) { setText(1, aRealPath); }
00058 QString realPath()
const {
return text(1); }
00059
00060
00061 };
00062
00064
00066
00067 CheckoutDialog::CheckoutDialog( CvsService_stub *cvsService,
00068
QWidget *parent,
const char *name, WFlags ) :
00069
DCOPObject( "CheckoutDialogDCOPIface" ),
00070
KDialogBase( parent, name? name : "checkoutdialog", true, i18n("CVS Checkout"),
00071 Ok | Cancel, Ok, true ),
00072 m_service( cvsService ), m_job( 0 )
00073 {
00074
m_base =
new CheckoutDialogBase(
this,
"checkoutdialogbase" );
00075 setMainWidget(
m_base );
00076
00077 connect(
m_base->
fetchModulesButton, SIGNAL(clicked()),
00078
this, SLOT(
slotFetchModulesList()) );
00079 connect(
m_base->
modulesListView, SIGNAL(executed(
QListViewItem*)),
00080
this, SLOT(
slotModuleSelected(
QListViewItem*)) );
00081
00082
00083
m_base->
workURLRequester->
setShowLocalProtocol(
false );
00084
m_base->
workURLRequester->
setMode( KFile::Directory );
00085 }
00086
00088
00089 CheckoutDialog::~CheckoutDialog()
00090 {
00091
delete m_job;
00092 }
00093
00095
00096 QString CheckoutDialog::cvsRsh()
const
00097
{
00098
return m_base->
cvsRshEdit->text();
00099 }
00100
00102
00103 QString CheckoutDialog::serverPath()
const
00104
{
00105
return m_base->
serverPathLineEdit->text();
00106 }
00107
00109
00110 void CheckoutDialog::setServerPath(
const QString &aPath )
00111 {
00112
m_base->
serverPathLineEdit->setText( aPath );
00113 }
00114
00116
00117 QString CheckoutDialog::workDir()
const
00118
{
00119
return m_base->
workURLRequester->
url();
00120 }
00121
00123
00124 void CheckoutDialog::setWorkDir(
const QString &aDir )
00125 {
00126
m_base->
workURLRequester->
setURL( aDir );
00127 }
00128
00130
00131 bool CheckoutDialog::pruneDirs()
const
00132
{
00133
return m_base->
pruneDirsCheck->isChecked();
00134 }
00135
00137
00138 QString CheckoutDialog::tag()
const
00139
{
00140
return m_base->
tagEdit->text();
00141 }
00142
00144
00145 QString CheckoutDialog::module()
const
00146
{
00147
return m_base->
moduleEdit->text();
00148 }
00149
00151
00152 void CheckoutDialog::slotFetchModulesList()
00153 {
00154 setCursor( KCursor::waitCursor() );
00155
00156
if (
serverPath().isEmpty() ||
workDir().isEmpty())
00157
return;
00158
00159
DCOPRef job =
m_service->moduleList(
serverPath() );
00160
if (!
m_service->ok())
00161
return;
00162
00163
m_job =
new CvsJob_stub( job.
app(), job.
obj() );
00164
00165
00166 connectDCOPSignal( job.
app(), job.
obj(),
"jobFinished(bool,int)",
"slotJobExited(bool,int)",
true );
00167 connectDCOPSignal( job.
app(), job.
obj(),
"receivedStdout(QString)",
"receivedOutput(QString)",
true );
00168
00169
kdDebug() <<
"Running: " <<
m_job->cvsCommand() <<
endl;
00170
m_job->execute();
00171 }
00172
00174
00175 void CheckoutDialog::slotJobExited(
bool ,
int )
00176 {
00177
kdDebug(9000) <<
"CheckoutDialog::slotModulesListFetched() here!" <<
endl;
00178
00179
kdDebug(9000) <<
"Received: " <<
m_job->output().join(
"\n" ) <<
endl;
00180
00181
00182 }
00183
00185
00186 void CheckoutDialog::slotReceivedOutput(
QString someOutput )
00187 {
00188
kdDebug( 9000 ) <<
" Received output: " << someOutput <<
endl;
00189
00190 setCursor( KCursor::arrowCursor() );
00191
00192
00193
00194
QStringList modules = QStringList::split(
"\n", someOutput );
00195
if (modules.count() <= 0)
00196
return;
00197
00198 QStringList::iterator it = modules.begin();
00199
for ( ; it != modules.end(); ++it )
00200 {
00201
QStringList l = QStringList::split(
" ", (*it) );
00202
00203
new ModuleListViewItem(
m_base->
modulesListView, l[0], l[1] );
00204 }
00205 }
00206
00207 void CheckoutDialog::slotReceivedErrors(
QString someErrors )
00208 {
00209
kdDebug( 9000 ) <<
" Received errors: " << someErrors <<
endl;
00210 }
00211
00213
00214 void CheckoutDialog::slotModuleSelected(
QListViewItem * )
00215 {
00216
ModuleListViewItem *aModuleItem = static_cast<ModuleListViewItem*>(
00217
m_base->
modulesListView->selectedItem()
00218 );
00219
if (!aModuleItem)
00220
return;
00221
00222
m_base->
moduleEdit->setText( aModuleItem->
alias() );
00223 }
00224
00225
00226
#include "checkoutdialog.moc"