KDevelop API Documentation

vcs/subversion/subversion_part.cpp

Go to the documentation of this file.
00001 /* Copyright (C) 2003 00002 Mickael Marchand <marchand@kde.org> 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; see the file COPYING. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #include <qwhatsthis.h> 00021 #include <kiconloader.h> 00022 #include <klocale.h> 00023 #include <kdevgenericfactory.h> 00024 #include <kaction.h> 00025 #include <kpopupmenu.h> 00026 00027 #include "kdevcore.h" 00028 #include "kdevmainwindow.h" 00029 #include "subversion_core.h" 00030 #include "subversion_part.h" 00031 #include "subversionoptionswidgetimpl.h" 00032 #include "subversionprojectwidget.h" 00033 #include "urlutil.h" 00034 #include <qvbox.h> 00035 #include <kdialogbase.h> 00036 #include <kparts/part.h> 00037 #include <kdevpartcontroller.h> 00038 #include <kdevproject.h> 00039 #include <domutil.h> 00040 #include <kurlrequester.h> 00041 #include <qradiobutton.h> 00042 #include <kdebug.h> 00043 #include <qwidget.h> 00044 00045 static const KAboutData data("kdevsubversion", I18N_NOOP("Subversion"), "1.0"); 00046 00047 typedef KDevGenericFactory<subversionPart> subversionFactory; 00048 K_EXPORT_COMPONENT_FACTORY( libkdevsubversion, subversionFactory( &data ) ) 00049 00050 //bool g_projectWasJustCreated = false; 00051 00052 subversionPart::subversionPart(QObject *parent, const char *name, const QStringList& ) 00053 : KDevVersionControl("KDevsubversionPart", "kdevsubversionpart", parent, name ? name : "Subversion" ) { 00054 setInstance(subversionFactory::instance()); 00055 setXMLFile("kdevpart_subversion.rc"); 00056 m_projWidget = 0; 00057 00058 m_impl = new subversionCore( this ); 00059 00060 m_checkout_recurse = true; 00061 m_update_recurse = true; 00062 m_switch_recurse = true; 00063 m_add_recurse = true; 00064 m_remove_force = true; 00065 m_commit_recurse = true; 00066 m_diff_recurse = true; 00067 m_merge_recurse = true; 00068 m_merge_overwrite = true; 00069 m_relocate_recurse = true; 00070 m_revert_recurse = true; 00071 m_resolve_recurse = true; 00072 m_move_force = true; 00073 m_propset_recurse = true; 00074 m_propget_recurse = true; 00075 m_proplist_recurse = true; 00076 00077 //m_impl->processWidget()->setIcon( SmallIcon("db") ); 00078 00079 setupActions(); 00080 00081 connect( m_impl, SIGNAL(checkoutFinished(QString)), SIGNAL(finishedFetching(QString)) ); 00082 00083 // Context menu 00084 connect( core(), SIGNAL(contextMenu(QPopupMenu *, const Context *)), this, SLOT(contextMenu(QPopupMenu *, const Context *)) ); 00085 connect( core(), SIGNAL(projectConfigWidget(KDialogBase*)), this, SLOT(projectConfigWidget(KDialogBase*)) ); 00086 connect( core(), SIGNAL(stopButtonClicked(KDevPlugin*)), this, SLOT(slotStopButtonClicked(KDevPlugin*)) ); 00087 connect( core(), SIGNAL(projectOpened()), this, SLOT(slotProjectOpened()) ); 00088 connect( core(), SIGNAL(projectClosed()), this, SLOT(slotProjectClosed()) ); 00089 00090 mainWindow()->embedOutputView( (QWidget*)m_impl->processWidget(), i18n( "Subversion" ), i18n( "Subversion messages" ) ); 00091 QWhatsThis::add((QWidget*)m_impl->processWidget(), i18n("<b>Subversion</b><p>Subversion operations window.")); 00092 setVersionControl( this ); 00093 } 00094 00095 subversionPart::~subversionPart() { 00096 if ( m_projWidget ){ 00097 delete (subversionProjectWidget*) m_projWidget; 00098 m_projWidget = 0; 00099 } 00100 delete m_impl; 00101 } 00102 00103 void subversionPart::setupActions() { 00104 actionCommit = new KAction( i18n("&Commit to Repository"), 0, this, 00105 SLOT(slotActionCommit()), actionCollection(), "subversion_commit" ); 00106 actionCommit->setToolTip( i18n("Commit file(s)") ); 00107 actionCommit->setWhatsThis( i18n("<b>Commit file(s)</b><p>Commits file to repository if modified.") ); 00108 00109 /* actionDiff = new KAction( i18n("&Difference Between Revisions"), 0, this, SLOT(slotActionDiff()), 00110 actionCollection(), "subversion_diff" ); 00111 actionDiff->setToolTip( i18n("Build difference") ); 00112 actionDiff->setWhatsThis( i18n("<b>Build difference</b><p>Builds difference between releases.") ); 00113 */ 00114 actionAdd = new KAction( i18n("&Add to Repository"), 0, this, SLOT(slotActionAdd()), 00115 actionCollection(), "subversion_add" ); 00116 actionAdd->setToolTip( i18n("Add file to repository") ); 00117 actionAdd->setWhatsThis( i18n("<b>Add file to repository</b><p>Adds file to repository.") ); 00118 00119 actionRemove = new KAction( i18n("&Remove From Repository"), 0, this, 00120 SLOT(slotActionRemove()), actionCollection(), "subversion_remove" ); 00121 actionRemove->setToolTip( i18n("Remove from repository") ); 00122 actionRemove->setWhatsThis( i18n("<b>Remove from repository</b><p>Removes file(s) from repository.") ); 00123 00124 actionUpdate = new KAction( i18n("&Update"), 0, this, 00125 SLOT(slotActionUpdate()), actionCollection(), "subversion_update" ); 00126 actionUpdate->setToolTip( i18n("Update") ); 00127 actionUpdate->setWhatsThis( i18n("<b>Update</b><p>Updates file(s) from repository.") ); 00128 00129 actionAddToIgnoreList = new KAction( i18n("&Ignore in Subversion Operations"), 0, 00130 this, SLOT(slotActionAddToIgnoreList()), actionCollection(), "subversion_ignore" ); 00131 actionAddToIgnoreList->setToolTip( i18n("Ignore in Subversion operations") ); 00132 actionAddToIgnoreList->setWhatsThis( i18n("<b>Ignore in Subversion operations</b><p>Ignores file(s).") ); 00133 00134 actionRemoveFromIgnoreList = new KAction( i18n("Do &Not Ignore in Subversion Operations"), 0, 00135 this, SLOT(slotActionRemoveFromIgnoreList()), actionCollection(), "subversion_donot_ignore" ); 00136 actionRemoveFromIgnoreList->setToolTip( i18n("Do not ignore in Subversion operations") ); 00137 actionRemoveFromIgnoreList->setWhatsThis( i18n("<b>Do not ignore in Subversion operations</b><p>Do not ignore file(s).") ); 00138 } 00139 00140 QWidget* subversionPart::newProjectWidget( QWidget* parent ) { 00141 if ( !m_projWidget ) 00142 m_projWidget = new subversionProjectWidget(parent,"projectwidget"); 00143 return m_projWidget; 00144 } 00145 00146 void subversionPart::projectConfigWidget( KDialogBase *dlg ) { 00147 QVBox *vbox = dlg->addVBoxPage( i18n("Subversion") ); 00148 subversionOptionsWidgetImpl *w = new subversionOptionsWidgetImpl( (QWidget *)vbox, this, "svn config widget" ); 00149 connect( dlg, SIGNAL(okClicked()), w, SLOT(accept()) ); 00150 } 00151 00152 void subversionPart::createNewProject( const QString& dirname ) { 00153 if ( !m_projWidget ) return; 00154 00155 m_impl->createNewProject( dirname, m_projWidget->importURL->url(), m_projWidget->yes->isChecked() ); 00156 00157 } 00158 00159 bool subversionPart::fetchFromRepository() { 00160 m_impl->checkout(); 00161 return true; 00162 } 00163 00164 KDevVCSFileInfoProvider * subversionPart::fileInfoProvider() const { 00165 return 0; 00166 } 00167 00168 bool subversionPart::isValidDirectory( const QString& dirPath) { 00169 return true; 00170 } 00171 00172 void subversionPart::contextMenu( QPopupMenu *popup, const Context *context ) { 00173 kdDebug() << "contextMenu()" << endl; 00174 if (context->hasType( Context::FileContext ) || 00175 context->hasType( Context::EditorContext )) 00176 { 00177 00178 if (context->hasType( Context::FileContext )) 00179 { 00180 kdDebug() << "Requested for a FileContext" << endl; 00181 const FileContext *fcontext = static_cast<const FileContext*>( context ); 00182 m_urls = fcontext->urls(); 00183 } 00184 else 00185 { 00186 kdDebug() << "Requested for an EditorContext" << endl; 00187 const EditorContext *editorContext = static_cast<const EditorContext*>( context ); 00188 m_urls << editorContext->url(); 00189 } 00190 // THis stuff should end up into prepareOperation() 00191 URLUtil::dump( m_urls ); 00192 if (m_urls.count() <= 0) 00193 return; 00194 00195 KPopupMenu *subMenu = new KPopupMenu( popup ); 00196 popup->insertSeparator(); 00197 00198 int id = subMenu->insertItem( actionCommit->text(), this, SLOT(slotCommit()) ); 00199 // CvsService let to do log and diff operations only on one file (or directory) at time 00200 /* if (m_urls.count() == 1) 00201 { 00202 subMenu->insertItem( actionDiff->text(), this, SLOT(slotDiff()) ); 00203 subMenu->insertItem( actionLog->text(), this, SLOT(slotLog()) ); 00204 }*/ 00205 subMenu->setWhatsThis(id, i18n("<b>Commit file(s)</b><p>Commits file to repository if modified.")); 00206 id = subMenu->insertItem( actionAdd->text(), this, SLOT(slotAdd()) ); 00207 subMenu->setWhatsThis(id, i18n("<b>Add file to repository</b><p>Adds file to repository.")); 00208 id = subMenu->insertItem( actionRemove->text(), this, SLOT(slotRemove()) ); 00209 subMenu->setWhatsThis(id, i18n("<b>Remove from repository</b><p>Removes file(s) from repository.")); 00210 00211 subMenu->insertSeparator(); 00212 id = subMenu->insertItem( actionUpdate->text(), this, SLOT(slotUpdate()) ); 00213 subMenu->setWhatsThis(id, i18n("<b>Update</b><p>Updates file(s) from repository.")); 00214 00215 subMenu->insertSeparator(); 00216 id = subMenu->insertItem( actionAddToIgnoreList->text(), this, SLOT(slotAddToIgnoreList()) ); 00217 subMenu->setWhatsThis(id, i18n("<b>Ignore in Subversion operations</b><p>Ignores file(s).")); 00218 id = subMenu->insertItem( actionRemoveFromIgnoreList->text(), this, SLOT(slotRemoveFromIgnoreList()) ); 00219 subMenu->setWhatsThis(id, i18n("<b>Do not ignore in Subversion operations</b><p>Do not ignore file(s).")); 00220 00221 // Now insert in parent menu 00222 popup->insertItem( i18n("Subversion"), subMenu ); 00223 } 00224 } 00225 00226 bool subversionPart::urlFocusedDocument( KURL &url ) { 00227 KParts::ReadOnlyPart *part = dynamic_cast<KParts::ReadOnlyPart*>( partController()->activePart() ); 00228 if ( part ) { 00229 if (part->url().isLocalFile() ) { 00230 url = part->url(); 00231 return true; 00232 } 00233 } 00234 return false; 00235 } 00236 00237 void subversionPart::slotActionUpdate() { 00238 kdDebug() << "subversion: slotActionUpdate()" << endl; 00239 KURL doc; 00240 if (urlFocusedDocument( doc )) { 00241 m_impl->update( doc ); 00242 } 00243 } 00244 00245 void subversionPart::slotUpdate() { 00246 m_impl->update (m_urls); 00247 } 00248 00249 void subversionPart::slotActionCommit() { 00250 kdDebug() << "subversion: slotActionCommit()" << endl; 00251 KURL doc; 00252 if (urlFocusedDocument( doc )) { 00253 m_impl->commit( doc ); 00254 } 00255 } 00256 00257 void subversionPart::slotCommit() { 00258 m_impl->commit (m_urls); 00259 } 00260 00261 void subversionPart::slotProjectOpened() { 00262 kdDebug() << "subversion :projectOpened" << endl; 00263 /* if ( g_projectWasJustCreated ) { 00264 //saveOptions(); 00265 g_projectWasJustCreated = false; 00266 } */ 00267 //loadOptions(); 00269 //connect( project(), SIGNAL(addedFilesToProject(const QStringList&)), this, SLOT(slotAddFilesToProject(const QStringList &)) ); 00270 //connect( project(), SIGNAL(removedFilesFromProject(const QStringList&)), this, SLOT(slotRemovedFilesFromProject(const QStringList &)) ); 00271 } 00272 00273 void subversionPart::slotProjectClosed() { 00274 kdDebug() << "subversion :projectClosed" << endl; 00275 //saveOptions(); 00277 //disconnect( project(), SIGNAL(addedFilesToProject(const QStringList&)), this, SLOT(slotAddFilesToProject(const QStringList &)) ); 00278 //disconnect( project(), SIGNAL(removedFilesFromProject(const QStringList&)), this, SLOT(slotRemovedFilesFromProject(const QStringList &)) ); 00279 } 00280 00281 void subversionPart::savePartialProjectSession(QDomElement* dom) { 00282 kdDebug() << "subversion : savePartialProjectSession" << endl; 00283 QDomDocument doc = dom->ownerDocument(); 00284 QDomElement svn = doc.createElement( "subversion" ); 00285 svn.setAttribute("recursecheckout", m_checkout_recurse); 00286 svn.setAttribute("recurseupdate", m_update_recurse); 00287 svn.setAttribute("recurseswitch", m_switch_recurse); 00288 svn.setAttribute("recurseadd", m_add_recurse); 00289 svn.setAttribute("forceremove",m_remove_force); 00290 svn.setAttribute("recursecommit",m_commit_recurse); 00291 svn.setAttribute("recursediff", m_diff_recurse); 00292 svn.setAttribute("recursemerge", m_merge_recurse); 00293 svn.setAttribute("forcemerge", m_merge_overwrite); 00294 svn.setAttribute("recurserelocate", m_relocate_recurse); 00295 svn.setAttribute("recurserevert", m_revert_recurse); 00296 svn.setAttribute("recurseresolve", m_resolve_recurse); 00297 svn.setAttribute("forcemove", m_move_force); 00298 svn.setAttribute("recursepropset", m_propset_recurse); 00299 svn.setAttribute("recursepropget", m_propget_recurse); 00300 svn.setAttribute("recurseproplist", m_proplist_recurse); 00301 svn.setAttribute( "base", base.url() ); 00302 dom->appendChild( svn ); 00303 } 00304 00305 void subversionPart::restorePartialProjectSession(const QDomElement* dom) { 00306 kdDebug() << "subversion : restorePartialProjectSession" << endl; 00307 QDomElement svn = dom->namedItem("subversion").toElement(); 00308 00309 m_checkout_recurse = svn.attribute( "recursecheckout", "1" ).toInt(); 00310 m_update_recurse = svn.attribute("recurseupdate","1").toInt(); 00311 m_switch_recurse = svn.attribute("recurseswitch","1").toInt(); 00312 m_add_recurse = svn.attribute("recurseadd","1").toInt(); 00313 m_remove_force = svn.attribute("forceremove","1").toInt(); 00314 m_commit_recurse = svn.attribute("recursecommit","1").toInt(); 00315 m_diff_recurse = svn.attribute("recursediff","1").toInt(); 00316 m_merge_recurse = svn.attribute("recursemerge","1").toInt(); 00317 m_merge_overwrite = svn.attribute("forcemerge","1").toInt(); 00318 m_relocate_recurse = svn.attribute("recurserelocate","1").toInt(); 00319 m_revert_recurse = svn.attribute("recurserevert","1").toInt(); 00320 m_move_force = svn.attribute("forcemove","1").toInt(); 00321 m_resolve_recurse = svn.attribute("recurseresolve","1").toInt(); 00322 m_propset_recurse = svn.attribute("recursepropset","1").toInt(); 00323 m_propget_recurse = svn.attribute("recursepropget","1").toInt(); 00324 m_proplist_recurse = svn.attribute("recurseproplist","1").toInt(); 00325 base = svn.attribute( "base", "" ); 00326 } 00327 00328 #include "subversion_part.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Oct 19 08:01:54 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003