diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e9ae80694875f869892f13f4fcaf1170a00dea41 (patch) | |
tree | aa2f8d8a217e2d376224c8d46b7397b68d35de2d /quanta/components/cvsservice | |
download | tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'quanta/components/cvsservice')
-rw-r--r-- | quanta/components/cvsservice/Makefile.am | 13 | ||||
-rw-r--r-- | quanta/components/cvsservice/cvscommitdlgs.ui | 150 | ||||
-rw-r--r-- | quanta/components/cvsservice/cvsservice.cpp | 555 | ||||
-rw-r--r-- | quanta/components/cvsservice/cvsservice.h | 118 | ||||
-rw-r--r-- | quanta/components/cvsservice/cvsservicedcopif.h | 30 | ||||
-rw-r--r-- | quanta/components/cvsservice/cvsupdatetodlgs.ui | 198 |
6 files changed, 1064 insertions, 0 deletions
diff --git a/quanta/components/cvsservice/Makefile.am b/quanta/components/cvsservice/Makefile.am new file mode 100644 index 00000000..79429348 --- /dev/null +++ b/quanta/components/cvsservice/Makefile.am @@ -0,0 +1,13 @@ +noinst_LTLIBRARIES = libcvsservice.la + +libcvsservice_la_SOURCES = cvsservice.cpp cvscommitdlgs.ui \ + cvsservicedcopif.skel cvsupdatetodlgs.ui +libcvsservice_la_METASOURCES = AUTO + +AM_CPPFLAGS = -I$(top_srcdir)/quanta/src \ + -I$(top_srcdir)/quanta/utility \ + -I$(top_srcdir)/quanta/parsers \ + -I$(top_srcdir)/quanta/project \ + -I$(top_srcdir)/lib \ + $(KMDI_INCLUDES) $(all_includes) +noinst_HEADERS = cvsservicedcopif.h diff --git a/quanta/components/cvsservice/cvscommitdlgs.ui b/quanta/components/cvsservice/cvscommitdlgs.ui new file mode 100644 index 00000000..ce2c9fd0 --- /dev/null +++ b/quanta/components/cvsservice/cvscommitdlgs.ui @@ -0,0 +1,150 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>CVSCommitDlgS</class> +<comment>/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; version 2 of the License. * + * * +***************************************************************************/ +</comment> +<author>(C) 2004 Andras Mantia <amantia@kde.org></author> +<widget class="QDialog"> + <property name="name"> + <cstring>CVSCommitDlgS</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>600</width> + <height>480</height> + </rect> + </property> + <property name="caption"> + <string>CVS Commit </string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KListBox" row="1" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>fileList</cstring> + </property> + </widget> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Commit the following files:</string> + </property> + </widget> + <widget class="KComboBox" row="3" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>messageCombo</cstring> + </property> + <property name="duplicatesEnabled"> + <bool>false</bool> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Older &messages:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>messageCombo</cstring> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>&Log message:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>logEdit</cstring> + </property> + </widget> + <widget class="QTextEdit" row="5" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>logEdit</cstring> + </property> + </widget> + <widget class="KPushButton" row="6" column="3"> + <property name="name"> + <cstring>cancelButton</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + </widget> + <widget class="KPushButton" row="6" column="2"> + <property name="name"> + <cstring>okButton</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <spacer row="6" column="1"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>80</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>okButton</sender> + <signal>clicked()</signal> + <receiver>CVSCommitDlgS</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>cancelButton</sender> + <signal>clicked()</signal> + <receiver>CVSCommitDlgS</receiver> + <slot>reject()</slot> + </connection> + <connection> + <sender>messageCombo</sender> + <signal>activated(const QString&)</signal> + <receiver>logEdit</receiver> + <slot>setText(const QString&)</slot> + </connection> +</connections> +<tabstops> + <tabstop>fileList</tabstop> + <tabstop>messageCombo</tabstop> + <tabstop>logEdit</tabstop> + <tabstop>okButton</tabstop> + <tabstop>cancelButton</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klistbox.h</includehint> +</includehints> +</UI> diff --git a/quanta/components/cvsservice/cvsservice.cpp b/quanta/components/cvsservice/cvsservice.cpp new file mode 100644 index 00000000..043af54e --- /dev/null +++ b/quanta/components/cvsservice/cvsservice.cpp @@ -0,0 +1,555 @@ +/*************************************************************************** + cvsservice.cpp - description + ------------------------------ + begin : Sun May 16 17:50:25 2004 + copyright : (C) 2004, 2005 by Andras Mantia <amantia@kde.org> + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; version 2 + * + ***************************************************************************/ + +//qt include +#include <qfile.h> +#include <qfileinfo.h> +#include <qradiobutton.h> +#include <qtextedit.h> +#include <qtextstream.h> +#include <qtimer.h> + +//kde includes +#include <kaction.h> +#include <kapplication.h> +#include <kcombobox.h> +#include <kdeversion.h> +#include <kiconloader.h> +#include <klineedit.h> +#include <klistbox.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kpopupmenu.h> + +// CvsService +#include <repository_stub.h> +#include <cvsservice_stub.h> +#include <cvsjob_stub.h> + +#include "cvsservice.h" +#include "cvscommitdlgs.h" +#include "cvsupdatetodlgs.h" + +#define CVSSERVICE_TIMEOUT 1000*60 + +CVSService::CVSService(KActionCollection *ac) +{ + m_menu = new KPopupMenu(); + KAction *action = new KAction(i18n("&Commit..."), "vcs_commit", 0, this, SLOT(slotCommit()), ac, "vcs_commit"); + action->plug(m_menu); + action = new KAction(i18n("&Update"), "vcs_update", 0, this, SLOT(slotUpdate()), ac, "vcs_update"); + action->plug(m_menu); + KPopupMenu *updateToMenu = new KPopupMenu(m_menu); + m_menu->insertItem(SmallIconSet("vcs_update"), i18n("Update &To"), updateToMenu); + action = new KAction(i18n("&Tag/Date..."), "vcs_update", 0, this, SLOT(slotUpdateToTag()), ac, "vcs_update_tag_date"); + action->plug(updateToMenu); + action = new KAction(i18n("&HEAD"), "vcs_update", 0, this, SLOT(slotUpdateToHead()), ac, "vcs_update_head"); + action->plug(updateToMenu); + action = new KAction(i18n("Re&vert"), "reload", 0, this, SLOT(slotRevert()), ac, "vcs_revert"); + action->plug(m_menu); + m_menu->insertSeparator(); + action = new KAction(i18n("&Add to Repository..."), "vcs_add", 0, this, SLOT(slotAdd()), ac, "vcs_add"); + action->plug(m_menu); + action = new KAction(i18n("&Remove From Repository..."), "vcs_remove", 0, this, SLOT(slotRemove()), ac, "vcs_remove"); + action->plug(m_menu); + action = new KAction(i18n("&Ignore in CVS Operations"), 0, this, SLOT(slotAddToCVSIgnore()), ac); + action->plug(m_menu); + action = new KAction(i18n("Do &Not Ignore in CVS Operations"), 0, this, SLOT(slotRemoveFromCVSIgnore()), ac); + action->plug(m_menu); + + m_menu->insertSeparator(); + action = new KAction(i18n("Show &Log Messages"), 0, this, SLOT(slotBrowseLog()), ac); + action->plug(m_menu); + + m_cvsJob = 0L; + m_repository = 0L; + m_cvsService =0L; + m_commitDlg = new CVSCommitDlgS(); + m_updateToDlg = new CVSUpdateToDlgS(); + m_timer = new QTimer(this); + connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimeout())); +} + +CVSService::~CVSService() +{ + if (m_cvsService) + m_cvsService->quit(); + delete m_cvsService; + delete m_menu; + delete m_repository; + m_repository = 0L; + m_cvsService = 0L; + delete m_commitDlg; + delete m_updateToDlg; +} + +void CVSService::setAppId(const QCString &id) +{ + m_appId = id; + m_cvsService = new CvsService_stub(m_appId, "CvsService"); + m_timer->start(CVSSERVICE_TIMEOUT, true); +} + +void CVSService::setRepository(const QString &repository) +{ + startService(); + delete m_repository; + m_repository = new Repository_stub(m_appId, "CvsRepository"); + if (m_repository->setWorkingCopy(repository)) + { + m_repositoryPath = repository; + if (!m_repositoryPath.endsWith("/")) + m_repositoryPath += "/"; + } +} + +void CVSService::slotUpdate() +{ + QStringList files; + if (!m_defaultFile.isEmpty()) + { + if (m_defaultFile.startsWith(m_repositoryPath)) + { + files += m_defaultFile.remove(m_repositoryPath); + slotUpdate(files); + } else + { + notInRepository(); + } + } +} + +void CVSService::slotUpdate(const QStringList &files) +{ + startService(); + if (m_repository && !m_appId.isEmpty()) + { + emit clearMessages(); + emit showMessage(i18n("Running CVS update...") + "\n", false); + m_files = files; + m_job = m_cvsService->update(files, true, true, true, ""); + m_cvsCommand = "update"; + m_cvsJob = new CvsJob_stub(m_job.app(), m_job.obj()); + + connectDCOPSignal(m_job.app(), m_job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStdout(QString)", "slotReceivedStdout(QString)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStderr(QString)", "slotReceivedStderr(QString)", true); + m_cvsJob->execute(); + } +} + +void CVSService::slotUpdateToTag() +{ + QStringList files; + if (!m_defaultFile.isEmpty()) + { + if (m_defaultFile.startsWith(m_repositoryPath)) + { + files += m_defaultFile.remove(m_repositoryPath); + slotUpdateToTag(files); + } else + { + notInRepository(); + } + } +} + +void CVSService::slotUpdateToTag(const QStringList &files) +{ + startService(); + if (m_repository && !m_appId.isEmpty() && m_updateToDlg->exec()) + { + QString extraOpts; + QString commandStr; + if (m_updateToDlg->tagRadioButton->isChecked()) + { + extraOpts = "-r " + m_updateToDlg->tagCombo->currentText(); + commandStr = i18n("Updating to revision %1 ...").arg(m_updateToDlg->tagCombo->currentText()); + } else + { + extraOpts = "-D " + m_updateToDlg->dateLineEdit->text(); + commandStr = i18n("Updating to the version from %1 ...").arg(+ m_updateToDlg->dateLineEdit->text()); + } + emit clearMessages(); + emit showMessage(commandStr + "\n", false); + m_files = files; + m_job = m_cvsService->update(files, true, true, true, extraOpts); + m_cvsCommand = "update"; + m_cvsJob = new CvsJob_stub(m_job.app(), m_job.obj()); + + connectDCOPSignal(m_job.app(), m_job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStdout(QString)", "slotReceivedStdout(QString)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStderr(QString)", "slotReceivedStderr(QString)", true); + m_cvsJob->execute(); + } +} + +void CVSService::slotUpdateToHead() +{ + QStringList files; + if (!m_defaultFile.isEmpty()) + { + if (m_defaultFile.startsWith(m_repositoryPath)) + { + files += m_defaultFile.remove(m_repositoryPath); + slotUpdateToHead(files); + } else + { + notInRepository(); + } + } +} + +void CVSService::slotUpdateToHead(const QStringList &files) +{ + startService(); + if (m_repository && !m_appId.isEmpty()) + { + emit clearMessages(); + emit showMessage(i18n("Updating to HEAD...") + "\n", false); + m_files = files; + m_job = m_cvsService->update(files, true, true, true, "-A"); + m_cvsCommand = "update"; + m_cvsJob = new CvsJob_stub(m_job.app(), m_job.obj()); + + connectDCOPSignal(m_job.app(), m_job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStdout(QString)", "slotReceivedStdout(QString)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStderr(QString)", "slotReceivedStderr(QString)", true); + m_cvsJob->execute(); + } +} + +void CVSService::slotCommit() +{ + QStringList files; + if (!m_defaultFile.isEmpty()) + { + if (m_defaultFile.startsWith(m_repositoryPath)) + { + files += m_defaultFile.remove(m_repositoryPath); + slotCommit(files); + } else + { + notInRepository(); + } + } +} + +void CVSService::slotCommit(const QStringList &files) +{ + startService(); + m_commitDlg->fileList->clear(); + m_commitDlg->fileList->insertStringList(files); + m_commitDlg->logEdit->clear(); + m_commitDlg->messageCombo->insertItem(i18n("Current"), 0); + m_commitDlg->messageCombo->setCurrentItem(0); + + if (m_repository && !m_appId.isEmpty() && m_commitDlg->exec()) + { + m_commitDlg->messageCombo->removeItem(0); + QString message = m_commitDlg->logEdit->text(); + if (message != m_commitDlg->messageCombo->currentText()) + m_commitDlg->messageCombo->insertItem(message, 0); + emit clearMessages(); + emit showMessage(i18n("Running CVS commit...") + "\n", false); + m_files = files; + m_job = m_cvsService->commit(files, message, true); + m_cvsCommand = "commit"; + m_cvsJob = new CvsJob_stub(m_job.app(), m_job.obj()); + + connectDCOPSignal(m_job.app(), m_job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStdout(QString)", "slotReceivedStdout(QString)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStderr(QString)", "slotReceivedStderr(QString)", true); + m_cvsJob->execute(); + } +} + +void CVSService::slotRevert() +{ + QStringList files; + if (!m_defaultFile.isEmpty()) + { + if (m_defaultFile.startsWith(m_repositoryPath)) + { + files += m_defaultFile.remove(m_repositoryPath); + slotRevert(files); + } else + { + notInRepository(); + } + } +} + +void CVSService::slotRevert(const QStringList &files) +{ + startService(); + if (m_repository && !m_appId.isEmpty()) + { + emit clearMessages(); + emit showMessage(i18n("Reverting to the version from the repository...") + "\n", false); + m_files = files; + m_job = m_cvsService->update(files, true, true, true, "-C"); + m_cvsCommand = "update"; + m_cvsJob = new CvsJob_stub(m_job.app(), m_job.obj()); + + connectDCOPSignal(m_job.app(), m_job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStdout(QString)", "slotReceivedStdout(QString)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStderr(QString)", "slotReceivedStderr(QString)", true); + m_cvsJob->execute(); + } +} + +void CVSService::slotAdd() +{ + QStringList files; + if (!m_defaultFile.isEmpty()) + { + if (m_defaultFile.startsWith(m_repositoryPath)) + { + files += m_defaultFile.remove(m_repositoryPath); + slotAdd(files); + } else + { + notInRepository(); + } + } +} + +void CVSService::slotAdd(const QStringList &files) +{ + startService(); + if (m_repository && !m_appId.isEmpty() && (KMessageBox::questionYesNoList(0, i18n("Add the following files to repository?"), files, i18n("CVS Add"), KStdGuiItem::add(), i18n("Do Not Add")) == KMessageBox::Yes)) + { + emit clearMessages(); + emit showMessage(i18n("Adding file to the repository...") + "\n", false); + m_files = files; + m_job = m_cvsService->add(files, false); + m_cvsCommand = "add"; + m_cvsJob = new CvsJob_stub(m_job.app(), m_job.obj()); + + connectDCOPSignal(m_job.app(), m_job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStdout(QString)", "slotReceivedStdout(QString)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStderr(QString)", "slotReceivedStderr(QString)", true); + m_cvsJob->execute(); + } +} + +void CVSService::slotRemove() +{ + QStringList files; + if (!m_defaultFile.isEmpty()) + { + if (m_defaultFile.startsWith(m_repositoryPath)) + { + files += m_defaultFile.remove(m_repositoryPath); + slotRemove(files); + } else + { + notInRepository(); + } + } +} + +void CVSService::slotRemove(const QStringList &files) +{ + startService(); + if (m_repository && !m_appId.isEmpty() && (KMessageBox::warningContinueCancelList(0, i18n("<qt>Remove the following files from the repository?<br>This will remove your <b>working copy</b> as well.</qt>"), files, i18n("CVS Remove")) == KMessageBox::Continue)) + { + emit clearMessages(); + emit showMessage(i18n("Removing files from the repository...") + "\n", false); + m_files = files; + m_job = m_cvsService->remove(files, true); + m_cvsCommand = "remove"; + m_cvsJob = new CvsJob_stub(m_job.app(), m_job.obj()); + + connectDCOPSignal(m_job.app(), m_job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStdout(QString)", "slotReceivedStdout(QString)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStderr(QString)", "slotReceivedStderr(QString)", true); + m_cvsJob->execute(); + } +} + +void CVSService::slotBrowseLog() +{ + startService(); + if (!m_defaultFile.isEmpty()) + { + if (m_defaultFile.startsWith(m_repositoryPath)) + { + QString file = m_defaultFile.remove(m_repositoryPath); + if (m_repository && !m_appId.isEmpty() ) + { + emit clearMessages(); + emit showMessage(i18n("Showing CVS log...") + "\n", false); + m_files += file; + m_job = m_cvsService->log(file); + m_cvsCommand = "log"; + m_cvsJob = new CvsJob_stub(m_job.app(), m_job.obj()); + + connectDCOPSignal(m_job.app(), m_job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStdout(QString)", "slotReceivedStdout(QString)", true); + connectDCOPSignal(m_job.app(), m_job.obj(), "receivedStderr(QString)", "slotReceivedStderr(QString)", true); + m_cvsJob->execute(); + } + } else + { + notInRepository(); + } + } +} + +void CVSService::slotAddToCVSIgnore() +{ + if (!m_defaultFile.isEmpty()) + { + if (m_defaultFile.startsWith(m_repositoryPath)) + { + emit clearMessages(); + QFileInfo fInfo(m_defaultFile); + QFile f(fInfo.dirPath()+ "/.cvsignore"); + if (f.open(IO_ReadWrite)) + { + bool found = false; + QTextStream str(&f); + str.setEncoding(QTextStream::UnicodeUTF8); + QString line; + while (!str.atEnd()) + { + line = str.readLine().stripWhiteSpace(); + if (line == fInfo.fileName()) + { + emit showMessage(i18n("\"%1\" is already in the CVS ignore list.").arg(fInfo.fileName()) + "\n", false); + found = true; + break; + } + } + if (!found) + { + str << fInfo.fileName() << endl; + emit showMessage(i18n("\"%1\" added to the CVS ignore list.").arg(fInfo.fileName()) + "\n", false); + } + f.close(); + } + + } else + { + notInRepository(); + } + } +} + +void CVSService::slotRemoveFromCVSIgnore() +{ + if (!m_defaultFile.isEmpty()) + { + if (m_defaultFile.startsWith(m_repositoryPath)) + { + emit clearMessages(); + QString content; + QFileInfo fInfo(m_defaultFile); + QFile f(fInfo.dirPath()+ "/.cvsignore"); + bool found = false; + if (f.open(IO_ReadWrite)) + { + QTextStream str(&f); + str.setEncoding(QTextStream::UnicodeUTF8); + QString line; + while (!str.atEnd()) + { + line = str.readLine().stripWhiteSpace(); + if (line != fInfo.fileName()) + { + content += line + "\n"; + } else + found = true; + } + if (!found) + { + emit showMessage(i18n("\"%1\" is not in the CVS ignore list.").arg(fInfo.fileName()) + "\n", false); + } + f.close(); + } + if (found && f.open(IO_WriteOnly)) + { + QTextStream str(&f); + str.setEncoding(QTextStream::UnicodeUTF8); + str << content; + emit showMessage(i18n("\"%1\" removed from the CVS ignore list.").arg(fInfo.fileName()) + "\n", false); + f.close(); + } + + } else + { + notInRepository(); + } + } +} + +void CVSService::slotJobExited(bool normalExit, int exitStatus) +{ + if (!normalExit) + { + KMessageBox::sorry(0, i18n("<qt>The CVS command <b>%1</b> has failed. The error code was <i>%2</i>.</qt>").arg(m_cvsCommand).arg(exitStatus), i18n("Command Failed")); + } + if (exitStatus == 0) + { + emit commandExecuted(m_cvsCommand, m_files); + } + disconnectDCOPSignal(m_job.app(), m_job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)"); + disconnectDCOPSignal(m_job.app(), m_job.obj(), "receivedStdout(QString)", "slotReceivedStdout(QString)"); + disconnectDCOPSignal(m_job.app(), m_job.obj(), "receivedStderr(QString)", "slotReceivedStderr(QString)"); + //delete m_cvsJob; + //m_cvsJob = 0L; + emit showMessage(i18n("CVS command finished."), false); + emit showMessage(" ", false); +} + +void CVSService::slotReceivedStdout(QString output) +{ + emit showMessage(output, true); +} + +void CVSService::slotReceivedStderr(QString output) +{ + emit showMessage(output, true); +} + +void CVSService::notInRepository() +{ + emit clearMessages(); + emit showMessage(i18n("Error: \"%1\" is not part of the\n\"%2\" repository.").arg(m_defaultFile).arg(m_repositoryPath) + "\n", false); +} + +void CVSService::startService() +{ + if (!m_cvsService) + { + QString error; + KApplication::startServiceByDesktopName("cvsservice", QStringList(), &error, + &m_appId); + m_cvsService = new CvsService_stub(m_appId, "CvsService"); + } + m_timer->start(CVSSERVICE_TIMEOUT, true); +} + +void CVSService::slotTimeout() +{ + if (m_cvsService) + m_cvsService->quit(); + delete m_cvsService; + m_cvsService = 0L; +} + +#include "cvsservice.moc" diff --git a/quanta/components/cvsservice/cvsservice.h b/quanta/components/cvsservice/cvsservice.h new file mode 100644 index 00000000..ebfcb402 --- /dev/null +++ b/quanta/components/cvsservice/cvsservice.h @@ -0,0 +1,118 @@ +/*************************************************************************** + cvsservice.h - description + ------------------------------ + begin : Sun May 16 17:50:25 2004 + copyright : (C) 2004, 2005 by Andras Mantia <amantia@kde.org> + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; version 2 + * + ***************************************************************************/ + +#ifndef CVSSERVICE_H +#define CVSSERVICE_H + +//qt includes +#include <qobject.h> + +//kde includes +#include <dcopref.h> + +//own includes +#include "cvsservicedcopif.h" + +class QTimer; +class KPopupMenu; +class KActionCollection; +class CvsJob_stub; +class CvsService_stub; +class Repository_stub; + +class CVSCommitDlgS; +class CVSUpdateToDlgS; + +/** @short This class manages the CVS repositories from withing Quanta with the help of "cvsservice" + * + */ +class CVSService : public QObject, public CVSServiceDCOPIf +{ + Q_OBJECT + +public: + + /** + * since this class is a singleton you must use this function to access it + * @return the class pointer + */ + static CVSService* ref(KActionCollection *ac = 0L) + { + static CVSService *m_ref; + if (!m_ref) m_ref = new CVSService(ac); + return m_ref; + } + + ~CVSService(); + + void setAppId(const QCString& id); + /** Returns true if the cvsservice was found */ + bool exists() {return !m_appId.isEmpty();} + void setRepository(const QString &repository); + void setCurrentFile(const QString &file) {m_defaultFile = file;} + KPopupMenu *menu() {return m_menu;} + +public slots: + void slotUpdate(); + void slotUpdate(const QStringList &files); + void slotUpdateToTag(); + void slotUpdateToTag(const QStringList &files); + void slotUpdateToHead(); + void slotUpdateToHead(const QStringList &files); + void slotCommit(); + void slotCommit(const QStringList &files); + void slotRevert(); + void slotRevert(const QStringList &files); + void slotAdd(); + void slotAdd(const QStringList &files); + void slotRemove(); + void slotRemove(const QStringList &files); + void slotBrowseLog(); + void slotAddToCVSIgnore(); + void slotRemoveFromCVSIgnore(); + + virtual void slotJobExited(bool normalExit, int exitStatus); + virtual void slotReceivedStdout(QString output); + virtual void slotReceivedStderr(QString output); + +signals: + void clearMessages(); + void showMessage(const QString &msg, bool append); + void commandExecuted(const QString& command, const QStringList& files); + +private slots: + void slotTimeout(); + +private: + CVSService(KActionCollection *ac); + void notInRepository(); + void startService(); + + QCString m_appId; + KPopupMenu *m_menu; + Repository_stub *m_repository; + CvsJob_stub *m_cvsJob; + CvsService_stub *m_cvsService; + QString m_defaultFile; + QString m_repositoryPath; + QString m_cvsCommand; + QStringList m_files; + CVSCommitDlgS *m_commitDlg; + CVSUpdateToDlgS *m_updateToDlg; + DCOPRef m_job; + QTimer *m_timer; +}; + +#endif diff --git a/quanta/components/cvsservice/cvsservicedcopif.h b/quanta/components/cvsservice/cvsservicedcopif.h new file mode 100644 index 00000000..75c0434a --- /dev/null +++ b/quanta/components/cvsservice/cvsservicedcopif.h @@ -0,0 +1,30 @@ +/*************************************************************************** + cvsservicedcopif.h - description + ------------------------------ + begin : Sun May 16 22:50:25 2004 + copyright : (C) 2004 by Andras Mantia <amantia@kde.org> + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; version 2 + * + ***************************************************************************/ + +#ifndef CVSSERVICEDCOPIF_H +#define CVSSERVICEDCOPIF_H + +#include <qstring.h> +#include <dcopobject.h> + +class CVSServiceDCOPIf : virtual public DCOPObject +{ + K_DCOP +k_dcop: + virtual void slotJobExited( bool normalExit, int exitStatus ) = 0; + virtual void slotReceivedStdout( QString someOutput ) = 0; +}; + +#endif diff --git a/quanta/components/cvsservice/cvsupdatetodlgs.ui b/quanta/components/cvsservice/cvsupdatetodlgs.ui new file mode 100644 index 00000000..ef646f92 --- /dev/null +++ b/quanta/components/cvsservice/cvsupdatetodlgs.ui @@ -0,0 +1,198 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>CVSUpdateToDlgS</class> +<comment>/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; version 2 of the License. * + * * +***************************************************************************/ +</comment> +<author>(C) 2005 Andras Mantia <amantia@kde.org></author> +<widget class="QDialog"> + <property name="name"> + <cstring>CVSUpdateToDlgS</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>499</width> + <height>213</height> + </rect> + </property> + <property name="caption"> + <string>CVS Update</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QButtonGroup" row="0" column="0"> + <property name="name"> + <cstring>buttonGroup1</cstring> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <property name="title"> + <string></string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>dateRadioButton</cstring> + </property> + <property name="text"> + <string>Update to &date ('yyyy-mm-dd'):</string> + </property> + </widget> + <widget class="QRadioButton" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>tagRadioButton</cstring> + </property> + <property name="text"> + <string>Update to &tag/branch:</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="KComboBox" row="1" column="1"> + <property name="name"> + <cstring>tagCombo</cstring> + </property> + <property name="editable"> + <bool>true</bool> + </property> + </widget> + <spacer row="1" column="0"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KLineEdit" row="3" column="1"> + <property name="name"> + <cstring>dateLineEdit</cstring> + </property> + </widget> + <spacer row="3" column="0"> + <property name="name"> + <cstring>spacer2_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="QLayoutWidget" row="1" column="0"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KPushButton" row="0" column="2"> + <property name="name"> + <cstring>cancelButton</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + </widget> + <spacer row="0" column="0"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>295</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KPushButton" row="0" column="1"> + <property name="name"> + <cstring>okButton</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>cancelButton</sender> + <signal>clicked()</signal> + <receiver>CVSUpdateToDlgS</receiver> + <slot>reject()</slot> + </connection> + <connection> + <sender>okButton</sender> + <signal>clicked()</signal> + <receiver>CVSUpdateToDlgS</receiver> + <slot>accept()</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +</UI> |