diff kdiff3/src-QT4/kdiff3_part.cpp @ 80:fcd146072e0c

0.9.93
author joachim99
date Tue, 06 Jan 2009 17:51:29 +0000
parents 1184fc843210
children
line wrap: on
line diff
--- a/kdiff3/src-QT4/kdiff3_part.cpp	Tue Jan 06 17:15:53 2009 +0000
+++ b/kdiff3/src-QT4/kdiff3_part.cpp	Tue Jan 06 17:51:29 2009 +0000
@@ -19,9 +19,9 @@
 
 #include "kdiff3_part.h"
 
-#include <kinstance.h>
+#include <kcomponentdata.h>
 #include <kaction.h>
-#include <kstdaction.h>
+#include <kstandardaction.h>
 #include <kfiledialog.h>
 
 #include <qfile.h>
@@ -38,11 +38,11 @@
 #include "version.h"
 
 KDiff3Part::KDiff3Part( QWidget *parentWidget, const char *widgetName,
-                                  QObject *parent, const char *name )
-    : KParts::ReadOnlyPart(parent, name)
+                                  QObject *parent )
+    : KParts::ReadWritePart(parent)
 {
     // we need an instance
-    setInstance( KDiff3PartFactory::instance() );
+    setComponentData( *KDiff3PartFactory::instance() );
 
     // this should be your custom internal widget
     m_widget = new KDiff3App( parentWidget, widgetName, this );
@@ -54,9 +54,9 @@
     setWidget(m_widget);
 
     // create our actions
-    //KStdAction::open(this, SLOT(fileOpen()), actionCollection());
-    //KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
-    //KStdAction::save(this, SLOT(save()), actionCollection());
+    //KStandardAction::open(this, SLOT(fileOpen()), actionCollection());
+    //KStandardAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
+    //KStandardAction::save(this, SLOT(save()), actionCollection());
 
     setXMLFile("kdiff3_part.rc");
 
@@ -71,7 +71,7 @@
 {
    if ( m_widget!=0  && ! m_bIsShell )
    {
-      m_widget->saveOptions( m_widget->isPart() ? instance()->config() : kapp->config() );
+      m_widget->saveOptions( m_widget->isPart() ? componentData().config() : KGlobal::config() );
    }
 }
 
@@ -84,7 +84,7 @@
 {
 /*
     // get a handle on our Save action and make sure it is valid
-    KAction *save = actionCollection()->action(KStdAction::stdName(KStdAction::Save));
+    KAction *save = actionCollection()->action(KStandardAction::stdName(KStandardAction::Save));
     if (!save)
         return;
 
@@ -130,8 +130,8 @@
 bool KDiff3Part::openFile()
 {
    // m_file is always local so we can use QFile on it
-   std::cerr << "KDiff3: " << m_file.toLatin1().constData() << std::endl;
-   QFile file(m_file);
+   std::cerr << "KDiff3: " << localFilePath().toLatin1().constData() << std::endl;
+   QFile file(localFilePath());
    if (file.open(QIODevice::ReadOnly) == false)
       return false;
 
@@ -171,7 +171,7 @@
       // Normal patch
       // patch -f -u --ignore-whitespace -i [inputfile] -o [outfile] [patchfile]
       QString tempFileName = FileAccess::tempFileName();
-      QString cmd = "patch -f -u --ignore-whitespace -i \"" + m_file +
+      QString cmd = "patch -f -u --ignore-whitespace -i \"" + localFilePath() +
                   "\" -o \""+tempFileName + "\" \"" + fileName1+ "\"";
 
       QProcess process;
@@ -180,7 +180,7 @@
 
       m_widget->slotFileOpen2( fileName1, tempFileName, "", "",
                                "", version2.isEmpty() ? fileName2 : "REV:"+version2+":"+fileName2, "", 0 ); // alias names
-//    std::cerr << "KDiff3: f1:" << fileName1.latin1() <<"<->"<<tempFileName.latin1()<< std::endl;
+//    std::cerr << "KDiff3: f1:" << fileName1.toLatin1() <<"<->"<<tempFileName.toLatin1()<< std::endl;
       FileAccess::removeTempFile( tempFileName );
    }
    else if ( version2.isEmpty() && f2.exists() )
@@ -188,7 +188,7 @@
       // Reverse patch
       // patch -f -u -R --ignore-whitespace -i [inputfile] -o [outfile] [patchfile]
       QString tempFileName = FileAccess::tempFileName();
-      QString cmd = "patch -f -u -R --ignore-whitespace -i \"" + m_file +
+      QString cmd = "patch -f -u -R --ignore-whitespace -i \"" + localFilePath() +
                   "\" -o \""+tempFileName + "\" \"" + fileName2+"\"";
 
       QProcess process;
@@ -197,7 +197,7 @@
 
       m_widget->slotFileOpen2( tempFileName, fileName2, "", "",
                                version1.isEmpty() ? fileName1 : "REV:"+version1+":"+fileName1, "", "", 0 ); // alias name
-//    std::cerr << "KDiff3: f2:" << fileName2.latin1() <<"<->"<<tempFileName.latin1()<< std::endl;
+//    std::cerr << "KDiff3: f2:" << fileName2.toLatin1() <<"<->"<<tempFileName.toLatin1()<< std::endl;
       FileAccess::removeTempFile( tempFileName );
    }
    else if ( !version1.isEmpty() && !version2.isEmpty() )
@@ -224,7 +224,7 @@
          "", 0
       );
 
-//    std::cerr << "KDiff3: f1/2:" << tempFileName1.latin1() <<"<->"<<tempFileName2.latin1()<< std::endl;
+//    std::cerr << "KDiff3: f1/2:" << tempFileName1.toLatin1() <<"<->"<<tempFileName2.toLatin1()<< std::endl;
       FileAccess::removeTempFile( tempFileName1 );
       FileAccess::removeTempFile( tempFileName2 );
       return true;
@@ -243,8 +243,8 @@
     if (isReadWrite() == false)
         return false;
 
-    // m_file is always local, so we use QFile
-    QFile file(m_file);
+    // localFilePath() is always local, so we use QFile
+    QFile file(localFilePath());
     if (file.open(IO_WriteOnly) == false)
         return false;
 
@@ -263,8 +263,9 @@
 // notable exception of the KAboutData data
 #include <kaboutdata.h>
 #include <klocale.h>
+#include <kglobal.h>
 
-KInstance*  KDiff3PartFactory::s_instance = 0L;
+KComponentData*  KDiff3PartFactory::s_instance = 0L;
 KAboutData* KDiff3PartFactory::s_about = 0L;
 
 KDiff3PartFactory::KDiff3PartFactory()
@@ -280,12 +281,12 @@
     s_instance = 0L;
 }
 
-KParts::Part* KDiff3PartFactory::createPartObject( QWidget *parentWidget, const char *widgetName,
-                                                        QObject *parent, const char *name,
+KParts::Part* KDiff3PartFactory::createPartObject( QWidget *parentWidget,
+                                                        QObject *parent,
                                                         const char *classname, const QStringList&/*args*/ )
 {
     // Create an instance of our Part
-    KDiff3Part* obj = new KDiff3Part( parentWidget, widgetName, parent, name );
+    KDiff3Part* obj = new KDiff3Part( parentWidget, 0, parent );
 
     // See if we are to be read-write or not
     if (QString(classname) == "KParts::ReadOnlyPart")
@@ -294,13 +295,13 @@
     return obj;
 }
 
-KInstance* KDiff3PartFactory::instance()
+KComponentData* KDiff3PartFactory::instance()
 {
     if( !s_instance )
     {
-        s_about = new KAboutData("kdiff3part", I18N_NOOP("KDiff3Part"), VERSION);
-        s_about->addAuthor("Joachim Eibl", 0, "joachim.eibl at gmx.de");
-        s_instance = new KInstance(s_about);
+        s_about = new KAboutData(QByteArray("kdiff3part"), QByteArray("kdiff3part"), ki18n("KDiff3Part"), QByteArray(VERSION));
+        s_about->addAuthor(ki18n("Joachim Eibl"), KLocalizedString(), QByteArray("joachim.eibl at gmx.de"));
+        s_instance = new KComponentData(s_about);
     }
     return s_instance;
 }