summaryrefslogtreecommitdiffstats
path: root/vcs/cvsservice/cvsdiffpage.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /vcs/cvsservice/cvsdiffpage.cpp
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.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/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'vcs/cvsservice/cvsdiffpage.cpp')
-rw-r--r--vcs/cvsservice/cvsdiffpage.cpp134
1 files changed, 134 insertions, 0 deletions
diff --git a/vcs/cvsservice/cvsdiffpage.cpp b/vcs/cvsservice/cvsdiffpage.cpp
new file mode 100644
index 00000000..12947b36
--- /dev/null
+++ b/vcs/cvsservice/cvsdiffpage.cpp
@@ -0,0 +1,134 @@
+/***************************************************************************
+ * Copyright (C) 200?-2003 by KDevelop Authors *
+ * www.kdevelop.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; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qtextedit.h>
+#include <qlayout.h>
+#include <qregexp.h>
+#include <qdir.h>
+#include <qstringlist.h>
+
+#include <kmessagebox.h>
+#include <kcursor.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+#include <cvsjob_stub.h>
+#include <cvsservice_stub.h>
+
+#include "cvsoptions.h"
+#include "cvsdiffpage.h"
+
+#include "diffwidget.h"
+
+///////////////////////////////////////////////////////////////////////////////
+// class CVSDiffPage
+///////////////////////////////////////////////////////////////////////////////
+
+CVSDiffPage::CVSDiffPage( CvsService_stub *cvsService,
+ QWidget *parent, const char *name, int )
+ // Leaving it anonymous let us to have multiple objects at the same time!
+ : DCOPObject(), // "CVSDiffPageDCOPIface"
+ QWidget( parent, name? name : "logformdialog" ),
+ m_diffText( 0 ), m_cvsService( cvsService ), m_cvsDiffJob( 0 )
+{
+ QLayout *thisLayout = new QVBoxLayout( this );
+ // This should be replaced by the diff part
+// m_diffText = new QTextEdit( this, "difftextedit" );
+// m_diffText->setReadOnly( true );
+ m_diffText = new DiffWidget( this, "difftextedit" );
+
+ thisLayout->add( m_diffText );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+CVSDiffPage::~CVSDiffPage()
+{
+ kdDebug(9006) << "CVSDiffPage::~CVSDiffPage()" << endl;
+ cancel();
+ delete m_cvsDiffJob;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void CVSDiffPage::startDiff( const QString &fileName, const QString &v1, const QString &v2 )
+{
+ kdDebug(9006) << "CVSDiffPage::startDiff()" << endl;
+
+ if ( v1.isEmpty() || v2.isEmpty() )
+ {
+ KMessageBox::error( this, i18n("Error: passed revisions are empty!"), i18n( "Error During Diff") );
+ return;
+ }
+
+ CvsOptions *options = CvsOptions::instance();
+ DCOPRef job = m_cvsService->diff( fileName, v1, v2, options->diffOptions(), options->contextLines() );
+ m_cvsDiffJob = new CvsJob_stub( job.app(), job.obj() );
+
+ kdDebug(9006) << "Running command : " << m_cvsDiffJob->cvsCommand() << endl;
+ connectDCOPSignal( job.app(), job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true );
+ connectDCOPSignal( job.app(), job.obj(), "receivedStdout(QString)", "slotReceivedOutput(QString)", true );
+ bool success = m_cvsDiffJob->execute();
+ if (!success)
+ {
+ kdDebug(9006) << "Argh ... cannot start the diff job!" << endl;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void CVSDiffPage::slotJobExited( bool normalExit, int /*exitStatus*/ )
+{
+ kdDebug(9006) << "CVSDiffPage::slotJobExited(bool, int)" << endl;
+
+ if (normalExit)
+ {
+ QString diffText = m_cvsDiffJob->output().join( "\n" );
+ kdDebug(9006) << "*** Received: " << diffText << endl;
+// m_diffText->setText( diffText );
+ m_diffText->setDiff( m_diffString );
+ }
+ else
+ {
+ KMessageBox::error( this, i18n("An error occurred during diffing."), i18n( "Error During Diff"));
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void CVSDiffPage::slotReceivedOutput( QString someOutput )
+{
+ kdDebug(9006) << "CVSDiffPage::slotReceivedOutput(QString)" << endl;
+ kdDebug(9006) << "OUTPUT: " << someOutput << endl;
+
+ QStringList strings = m_outputBuffer.process(someOutput);
+ m_diffString += strings.join("\n");
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void CVSDiffPage::slotReceivedErrors( QString someErrors )
+{
+ kdDebug(9006) << "CVSDiffPage::slotReceivedErrors(QString)" << endl;
+ kdDebug(9006) << "ERRORS: " << someErrors << endl;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void CVSDiffPage::cancel()
+{
+ if (m_cvsDiffJob && m_cvsDiffJob->isRunning())
+ m_cvsDiffJob->cancel();
+}
+
+#include "cvsdiffpage.moc"
+
+