subversion_core.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <kparts/part.h>
00021 #include <kdevcore.h>
00022
00023 #include "subversion_part.h"
00024 #include "subversion_core.h"
00025 #include "subversion_widget.h"
00026 #include <kdevmainwindow.h>
00027 #include "svn_co.h"
00028 #include <kurlrequester.h>
00029 #include <klineedit.h>
00030 #include <kio/job.h>
00031 #include <kdebug.h>
00032 #include <kdebugclasses.h>
00033 #include <kmainwindow.h>
00034
00035 using namespace KIO;
00036
00037 subversionCore::subversionCore(subversionPart *part)
00038 : QObject(this, "subversion core") {
00039 m_part = part;
00040 m_widget = new subversionWidget(part, 0 , "subversionprocesswidget");
00041 }
00042
00043 subversionCore::~subversionCore() {
00044 if ( processWidget() ) {
00045 m_part->mainWindow()->removeView( m_widget );
00046 delete m_widget;
00047 }
00048 }
00049
00050 subversionWidget *subversionCore::processWidget() const {
00051 return m_widget;
00052 }
00053
00054 void subversionCore::update( const KURL::List& list ) {
00055 KURL servURL = m_part->baseURL();
00056 if ( servURL.isEmpty() ) servURL="svn+http://blah/";
00057 if ( ! servURL.protocol().startsWith( "svn" ) ) {
00058 servURL.setProtocol( "svn+" + servURL.protocol() );
00059 }
00060 kdDebug() << "servURL : " << servURL.prettyURL() << endl;
00061 for ( QValueListConstIterator<KURL> it = list.begin(); it != list.end() ; ++it ) {
00062 kdDebug() << "updating : " << (*it).prettyURL() << endl;
00063 QByteArray parms;
00064 QDataStream s( parms, IO_WriteOnly );
00065 int cmd = 2;
00066 int rev = -1;
00067 s << cmd << *it << rev << QString( "HEAD" );
00068 SimpleJob * job = KIO::special(servURL, parms, true);
00069 job->setWindow( m_part->mainWindow()->main() );
00070 connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotResult( KIO::Job * ) ) );
00071 }
00072 }
00073
00074 void subversionCore::commit( const KURL::List& list ) {
00075 KURL servURL = m_part->baseURL();
00076 if ( servURL.isEmpty() ) servURL="svn+http://blah/";
00077 if ( ! servURL.protocol().startsWith( "svn" ) ) {
00078 servURL.setProtocol( "svn+" + servURL.protocol() );
00079 }
00080 kdDebug() << "servURL : " << servURL.prettyURL() << endl;
00081 for ( QValueListConstIterator<KURL> it = list.begin(); it != list.end() ; ++it ) {
00082 kdDebug() << "commiting : " << (*it).prettyURL() << endl;
00083 QByteArray parms;
00084 QDataStream s( parms, IO_WriteOnly );
00085 int cmd = 3;
00086 s << cmd << *it;
00087 SimpleJob * job = KIO::special(servURL, parms, true);
00088 job->setWindow( m_part->mainWindow()->main() );
00089 connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotResult( KIO::Job * ) ) );
00090 }
00091 }
00092
00093 void subversionCore::checkout() {
00094 svn_co checkoutDlg;
00095
00096 if ( checkoutDlg.exec() == QDialog::Accepted ) {
00097
00098 QByteArray parms;
00099 QDataStream s( parms, IO_WriteOnly );
00100 KURL servURL ( checkoutDlg.serverURL->url() );
00101 wcPath = checkoutDlg.localDir->url() + "/" + checkoutDlg.newDir->text();
00102 int cmd = 1;
00103 int rev = -1;
00104 s << cmd << servURL << KURL( wcPath ) << rev << QString( "HEAD" );
00105 servURL.setProtocol( "svn+" + servURL.protocol() );
00106 SimpleJob * job = KIO::special(servURL,parms, true);
00107 job->setWindow( m_part->mainWindow()->main() );
00108 connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotEndCheckout( KIO::Job * ) ) );
00109 }
00110 }
00111
00112 void subversionCore::slotEndCheckout( KIO::Job * job ) {
00113 if ( job->error() ) {
00114 job->showErrorDialog( m_part->mainWindow()->main() );
00115 emit checkoutFinished( QString::null );
00116 } else
00117 emit checkoutFinished(wcPath);
00118 }
00119
00120 void subversionCore::slotResult( KIO::Job * job ) {
00121 if ( job->error() )
00122 job->showErrorDialog( m_part->mainWindow()->main() );
00123 }
00124
00125 void subversionCore::createNewProject( const QString& dirName, const KURL& importURL, bool init ) {
00126
00127 }
00128
00129 #include "subversion_core.moc"
This file is part of the documentation for KDevelop Version 3.1.2.