[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdevelop/parts/diff
From: Harald Fernengel <harald () trolltech ! com>
Date: 2002-12-15 16:22:08
[Download RAW message or body]
CVS commit by harald:
code cleanups and fallback to QTextEdit if there is trouble with Kompare
M +42 -10 diffwidget.cpp 1.4
M +1 -1 diffwidget.h 1.3
--- kdevelop/parts/diff/diffwidget.cpp #1.3:1.4
@@ -51,4 +51,19 @@ DiffWidget::~DiffWidget()
}
+void DiffWidget::setKompareVisible( bool visible )
+{
+ if ( !komparePart || !komparePart->widget() ) {
+ te->show();
+ return;
+ }
+ if ( visible ) {
+ te->hide();
+ komparePart->widget()->show();
+ } else {
+ te->show();
+ komparePart->widget()->hide();
+ }
+}
+
void DiffWidget::loadKomparePart( QWidget* parent )
{
@@ -109,12 +124,24 @@ void DiffWidget::setDiff( const QString&
{
if ( komparePart ) {
+ bool ok = false;
+ if ( komparePart->openStream( "text/plain", KURL() ) ) {
+ komparePart->writeStream( diff.local8Bit() );
+ ok = komparePart->closeStream();
+ } else {
+ // workaround for old kompare versions < KDE 3.2
delete tempFile;
- // workaround until kompare can view patches directly from a QString
tempFile = new KTempFile();
tempFile->setAutoDelete( true );
*(tempFile->textStream()) << diff;
tempFile->close();
- openURL( tempFile->name() );
+ ok = komparePart->openURL( tempFile->name() );
+ }
+ if ( ok ) {
+ setKompareVisible( true );
return;
+ } else {
+ setKompareVisible( false );
+ te->setText( i18n("*** Error viewing diff with the diff KPart, falling back to plainText ***") );
+ }
}
@@ -126,5 +153,10 @@ void DiffWidget::openURL( const KURL& ur
{
if ( komparePart ) {
- komparePart->openURL( url );
+ if ( komparePart->openURL( url ) ) {
+ setKompareVisible( true );
+ } else {
+ setKompareVisible( false );
+ te->setText( i18n("<b>Error viewing diff with the diff KPart</b>") );
+ }
return;
}
@@ -137,5 +169,5 @@ void DiffWidget::openURL( const KURL& ur
return;
- connect( job, SIGNAL(data( KIO::Job *, const QByteArray &)),
+ connect( job, SIGNAL(data( KIO::Job *, const QByteArray & )),
this, SLOT(slotAppend( KIO::Job*, const QByteArray& )) );
connect( job, SIGNAL(result( KIO::Job * )),
--- kdevelop/parts/diff/diffwidget.h #1.2:1.3
@@ -57,4 +57,5 @@ private:
/** sets komparePart to 0 if kompare part is not installed */
void loadKomparePart( QWidget* parent );
+ void setKompareVisible( bool visible );
private:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic