changeset 95:6f42f5bd218e

- OS2-port by Silvan Scherrer - Fixed writing to KIO. - Fix crash on A/B-overview (infinite recursion)
author joachim99
date Sun, 28 Feb 2010 20:32:34 +0000
parents b2f22ae5f810
children 9000a9763f6f
files kdiff3/src-QT4/diff.cpp kdiff3/src-QT4/difftextwindow.cpp kdiff3/src-QT4/directorymergewindow.cpp kdiff3/src-QT4/fileaccess.cpp kdiff3/src-QT4/fileaccess.h kdiff3/src-QT4/guiutils.h kdiff3/src-QT4/kdiff3.cpp kdiff3/src-QT4/kdiff3.pro kdiff3/src-QT4/kdiff3_os2.ico kdiff3/src-QT4/kdiff3os2.rc kdiff3/src-QT4/kreplacements/kreplacements.cpp kdiff3/src-QT4/kreplacements/kreplacements.h kdiff3/src-QT4/main.cpp kdiff3/src-QT4/optiondialog.cpp
diffstat 14 files changed, 52 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/kdiff3/src-QT4/diff.cpp	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/diff.cpp	Sun Feb 28 20:32:34 2010 +0000
@@ -462,7 +462,7 @@
    if ( faIn.exists() ) // fileInSize > 0 )
    {
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(Q_OS_OS2)
       QString catCmd = "type";
       fileNameIn1.replace( '/', "\\" );
 #else
--- a/kdiff3/src-QT4/difftextwindow.cpp	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/difftextwindow.cpp	Sun Feb 28 20:32:34 2010 +0000
@@ -69,7 +69,7 @@
       m_bMyUpdate = false;
       m_bSelectionInProgress = false;
       m_pTextCodec = 0;
-      #ifdef _WIN32
+      #if defined(_WIN32) || defined(Q_OS_OS2)
       m_eLineEndStyle = eLineEndStyleDos;
       #else
       m_eLineEndStyle = eLineEndStyleUnix;
@@ -1089,7 +1089,7 @@
 
 void DiffTextWindowData::draw( MyPainter& p, const QRect& invalidRect, int deviceWidth, int beginLine, int endLine )
 {
-   m_lineNumberWidth =  m_pOptionDialog->m_bShowLineNumbers ? (int)log10((double)m_size)+1 : 0;
+   m_lineNumberWidth = m_pOptionDialog->m_bShowLineNumbers ? (int)log10((double)qMax(m_size,1))+1 : 0;
 
    if ( m_winIdx==1 )
    {
@@ -1310,7 +1310,7 @@
             !( d->m_bWordWrap && it+1<vectorSize && d3l == d->m_diff3WrapLineVector[it+1].pD3L ) 
            )
          {
-            #ifdef _WIN32
+            #if defined(_WIN32) || defined(Q_OS_OS2)
             selectionString += '\r';
             #endif
             selectionString += '\n';
@@ -1754,7 +1754,7 @@
    if ( pDTW && pDTW->d->m_pDiff3LineVector )
    {
       QString s= i18n("Top line");
-      int lineNumberWidth = (int)log10((double)pDTW->d->m_size)+1;
+      int lineNumberWidth = (int)log10((double)qMax(pDTW->d->m_size,1))+1;
 
       int l=pDTW->calcTopLineInFile(firstLine);
 
--- a/kdiff3/src-QT4/directorymergewindow.cpp	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/directorymergewindow.cpp	Sun Feb 28 20:32:34 2010 +0000
@@ -2516,7 +2516,7 @@
    if ( fi.isSymLink() && ((fi.isDir() && !m_bFollowDirLinks)  ||  (!fi.isDir() && !m_bFollowFileLinks)) )
    {
       m_pStatusInfo->addText(i18n("copyLink( %1 -> %2 )",srcName,destName));
-#ifdef _WIN32
+#if defined(_WIN32) || defined(Q_OS_OS2)
       // What are links?
 #else
       if ( m_bSimulatedMergeStarted )
--- a/kdiff3/src-QT4/fileaccess.cpp	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/fileaccess.cpp	Sun Feb 28 20:32:34 2010 +0000
@@ -479,7 +479,7 @@
    #ifdef KREPLACEMENTS_H
 
       QString fileName;
-      #ifdef _WIN32
+      #if defined(_WIN32) || defined(Q_OS_OS2)
          QString tmpDir = getenv("TEMP");
       #else
          QString tmpDir = "/tmp";
@@ -535,7 +535,7 @@
    return fh.rmDir( dirName );
 }
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(Q_OS_OS2)
 bool FileAccess::symLink( const QString& /*linkTarget*/, const QString& /*linkLocation*/ )
 {
    return false;
@@ -717,7 +717,7 @@
       m_pFileAccess->m_statusText = QString();
 
       connect( pJob, SIGNAL(result(KJob*)), this, SLOT(slotPutJobResult(KJob*)));
-      connect( pJob, SIGNAL(dataReq(KJob*, QByteArray&)), this, SLOT(slotPutData(KJob*, QByteArray&)));
+      connect( pJob, SIGNAL(dataReq(KIO::Job*, QByteArray&)), this, SLOT(slotPutData(KIO::Job*, QByteArray&)));
       connect( pJob, SIGNAL(percent(KJob*,unsigned long)), this, SLOT(slotPercent(KJob*, unsigned long)));
 
       g_pProgressDialog->enterEventLoop( pJob, i18n("Writing file: %1",m_pFileAccess->prettyAbsPath()) );
@@ -727,7 +727,7 @@
       return true;
 }
 
-void FileAccessJobHandler::slotPutData( KJob* pJob, QByteArray& data )
+void FileAccessJobHandler::slotPutData( KIO::Job* pJob, QByteArray& data )
 {
    if ( pJob->error() )
    {
@@ -1361,7 +1361,7 @@
    {
       cvsIgnoreList.init( *m_pFileAccess, cvsIgnoreExists(pDirList) );
    }
-#ifdef _WIN32
+#if defined(_WIN32) || defined(Q_OS_OS2)
    bool bCaseSensitive = false;
 #else
    bool bCaseSensitive = true;
--- a/kdiff3/src-QT4/fileaccess.h	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/fileaccess.h	Sun Feb 28 20:32:34 2010 +0000
@@ -163,7 +163,7 @@
    void slotPutJobResult( KJob* pJob );
 
    void slotGetData(KJob*,const QByteArray&);
-   void slotPutData(KJob*, QByteArray&);
+   void slotPutData(KIO::Job*, QByteArray&);
 
    void slotListDirInfoMessage( KJob*, const QString& msg );
    void slotListDirProcessNewEntries( KIO::Job *, const KIO::UDSEntryList& l );
--- a/kdiff3/src-QT4/guiutils.h	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/guiutils.h	Sun Feb 28 20:32:34 2010 +0000
@@ -52,7 +52,7 @@
       KToggleAction* theAction = new KToggleAction(ac);
       ac->addAction( actionName, theAction );
       theAction->setText( text );
-      QObject::connect( theAction, SIGNAL( toggled(bool) ), receiver, slot );
+      QObject::connect( theAction, SIGNAL( triggered(bool) ), receiver, slot );
       return theAction;
    }
    
--- a/kdiff3/src-QT4/kdiff3.cpp	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/kdiff3.cpp	Sun Feb 28 20:32:34 2010 +0000
@@ -175,7 +175,7 @@
       }
       if (!s.isEmpty())
       {
-#ifdef _WIN32 
+#if defined(_WIN32) || defined(Q_OS_OS2) 
          // A windows program has no console
          //KMessageBox::information(0, s,i18n("KDiff3-Usage"));
          QDialog* pDialog = new QDialog(this);
@@ -482,8 +482,10 @@
    fileSave->setStatusTip(i18n("Saves the merge result. All conflicts must be solved!"));
    fileSaveAs = KStandardAction::saveAs(this, SLOT(slotFileSaveAs()), ac);
    fileSaveAs->setStatusTip(i18n("Saves the current document as..."));
+#ifndef QT_NO_PRINTER
    filePrint = KStandardAction::print(this, SLOT(slotFilePrint()), ac);
    filePrint->setStatusTip(i18n("Print the differences"));
+#endif
    fileQuit = KStandardAction::quit(this, SLOT(slotFileQuit()), ac);
    fileQuit->setStatusTip(i18n("Quits the application"));
    editCut = KStandardAction::cut(this, SLOT(slotEditCut()), ac);
@@ -585,7 +587,7 @@
    addManualDiffHelp  = KDiff3::createAction< KAction >(i18n("Add Manual Diff Alignment"), KShortcut( Qt::CTRL+Qt::Key_Y ), this, SLOT(slotAddManualDiffHelp()), ac, "diff_add_manual_diff_help");
    clearManualDiffHelpList  = KDiff3::createAction< KAction >(i18n("Clear All Manual Diff Alignments"), KShortcut( Qt::CTRL+Qt::SHIFT+Qt::Key_Y ), this, SLOT(slotClearManualDiffHelpList()), ac, "diff_clear_manual_diff_help_list");
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(Q_OS_OS2)
    KDiff3::createAction< KAction >(i18n("Focus Next Window"), KShortcut(Qt::CTRL+Qt::Key_Tab), this, SLOT(slotWinFocusNext()), ac, "win_focus_next");
 #endif
    winFocusPrev = KDiff3::createAction< KAction >(i18n("Focus Prev Window"), KShortcut( Qt::ALT+Qt::Key_Left ), this, SLOT(slotWinFocusPrev()), ac, "win_focus_prev");
@@ -775,7 +777,10 @@
 {
    if ( !m_pDiffTextWindow1 )
       return;
-
+#ifdef QT_NO_PRINTER
+   slotStatusMsg( i18n( "Printing not implemented." ) );
+#endif
+#ifndef QT_NO_PRINTER
    QPrinter printer;
    QPrintDialog printDialog(&printer, this);
 
@@ -980,6 +985,7 @@
    {
       slotStatusMsg( i18n( "Printing aborted." ) );
    }
+#endif
 }
 
 void KDiff3App::slotFileQuit()
--- a/kdiff3/src-QT4/kdiff3.pro	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/kdiff3.pro	Sun Feb 28 20:32:34 2010 +0000
@@ -1,7 +1,7 @@
 TEMPLATE = app
 # When unresolved items remain during linking: Try adding "shared" in the CONFIG.
 CONFIG  += qt warn_on thread precompile_header
-PRECOMPILED_HEADER = stable.h
+!os2:PRECOMPILED_HEADER = stable.h
 HEADERS  = version.h                     \
            diff.h                        \
            difftextwindow.h              \
@@ -53,7 +53,9 @@
            QMAKE_LFLAGS += user32.lib shell32.lib
    }
 }
-
+os2 {
+  RC_FILE = kdiff3os2.rc
+}
 
 unix {
   documentation.path = /usr/local/share/doc/kdiff3
Binary file kdiff3/src-QT4/kdiff3_os2.ico has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kdiff3/src-QT4/kdiff3os2.rc	Sun Feb 28 20:32:34 2010 +0000
@@ -0,0 +1,1 @@
+ICON 1    DISCARDABLE     "kdiff3_os2.ico"
\ No newline at end of file
--- a/kdiff3/src-QT4/kreplacements/kreplacements.cpp	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/kreplacements/kreplacements.cpp	Sun Feb 28 20:32:34 2010 +0000
@@ -62,13 +62,8 @@
 
 static void showHelp()
 {
-   #ifdef _WIN32
-      char buf[200];
-      int r= SearchPathA( 0, ".",  0, sizeof(buf), buf, 0 );
-
-      QString exePath;
-      if (r!=0)  {  exePath = buf; }
-      else       {  exePath = "."; }
+   #if defined(_WIN32) || defined(Q_OS_OS2)
+      QString exePath = QCoreApplication::applicationDirPath();
 
       QFileInfo helpFile( exePath + "\\doc\\en\\index.html" );
       if ( ! helpFile.exists() ) {  helpFile.setFile( exePath + "\\..\\doc\\en\\index.html" );     }
@@ -83,24 +78,27 @@
          return;
       }
 
+#ifndef Q_OS_OS2
       HINSTANCE hi = FindExecutableA( helpFile.fileName().toAscii(), helpFile.absolutePath().toAscii(), buf );
       if ( int(hi)<=32 )
       {
+#endif
          static QTextBrowser* pBrowser = 0;
          if (pBrowser==0)
          {
             pBrowser = new QTextBrowser( 0 );
             pBrowser->setMinimumSize( 600, 400 );
          }
-         pBrowser->setSource(helpFile.filePath());
+         pBrowser->setSource(QUrl("file:///"+helpFile.filePath()));
          pBrowser->show();
+#ifndef Q_OS_OS2
       }
       else
       {
          QFileInfo prog( buf );
          QProcess::startDetached ( prog.filePath(), QStringList( "file:///"+helpFile.absoluteFilePath() ) );
       }
-
+#endif
    #else
       static QTextBrowser* pBrowser = 0;
       if (pBrowser==0)
@@ -115,14 +113,9 @@
 
 QString getTranslationDir(const QString& locale)
 {
-   #ifdef _WIN32
-      wchar_t buf[200];
-      int r= SearchPathW( 0, L".",  0, sizeof(buf)/sizeof(wchar_t), buf, 0 );
-
-      buf[ sizeof(buf)/sizeof(wchar_t) -1 ] = 0;
+   #if defined(_WIN32) || defined(Q_OS_OS2)
       QString exePath;
-      if (r!=0)  {  exePath = QString::fromUtf16( (ushort*)&buf[0] ); }
-      else       {  exePath = "."; }
+      exePath = QCoreApplication::applicationDirPath();
       return exePath+"/translations";
    #else
       return  (QString)"/usr/share/locale/" + locale + "/LC_MESSAGES";
@@ -842,6 +835,7 @@
    update();
 }
 
+#ifndef QT_NO_PRINTER
 KPrinter::KPrinter()
 {
 }
@@ -861,7 +855,7 @@
 void KPrinter::setPageSelection(e_PageSelection)
 {
 }
-
+#endif
 
 QPixmap KIconLoader::loadIcon( const QString&, int, int )
 {
@@ -1136,7 +1130,7 @@
             }
 
             s += "\n"+i18n("For more documentation, see the help-menu or the subdirectory doc.")+"\n";
-#ifdef _WIN32
+#if defined(_WIN32) || defined(Q_OS_OS2)
             // A windows program has no console
             if ( 0==QMessageBox::information(0, i18n("KDiff3-Usage"), s, i18n("Ignore"),i18n("Exit") ) )
                continue;
--- a/kdiff3/src-QT4/kreplacements/kreplacements.h	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/kreplacements/kreplacements.h	Sun Feb 28 20:32:34 2010 +0000
@@ -17,7 +17,9 @@
 
 #ifndef KREPLACEMENTS_H
 #define KREPLACEMENTS_H
+#ifndef __OS2__
 #pragma once
+#endif
 
 #include "common.h"
 
@@ -385,6 +387,7 @@
    void slotClicked();
 };
 
+#ifndef QT_NO_PRINTER
 class KPrinter : public QPrinter
 {
 public:
@@ -394,6 +397,7 @@
    void setCurrentPage(int);
    void setPageSelection(e_PageSelection);
 };
+#endif
 
 class KStandardDirs
 {
--- a/kdiff3/src-QT4/main.cpp	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/main.cpp	Sun Feb 28 20:32:34 2010 +0000
@@ -150,6 +150,11 @@
    }
 
 #endif
+#ifdef Q_OS_OS2
+   // expand wildcards on the command line
+   _wildcard(&argc, &argv);
+#endif
+
    //QApplication::setColorSpec( QApplication::ManyColor ); // Grab all 216 colors
 
    const QByteArray& appName = QByteArray("kdiff3");
--- a/kdiff3/src-QT4/optiondialog.cpp	Sun Feb 28 19:43:48 2010 +0000
+++ b/kdiff3/src-QT4/optiondialog.cpp	Sun Feb 28 20:32:34 2010 +0000
@@ -27,7 +27,7 @@
 #include <QRadioButton>
 #include <QGroupBox>
 #include <QTextCodec>
-
+#include <QDir>
 #include <QSettings>
 #include <QLocale>
 #include <QGridLayout>
@@ -1119,7 +1119,7 @@
 
    OptionCheckBox* pFindHidden = new OptionCheckBox( i18n("Find hidden files and directories"), true, "FindHidden", &m_bDmFindHidden, page, this );
    gbox->addWidget( pFindHidden, line, 0, 1, 2 );
-#ifdef _WIN32
+#if defined(_WIN32) || defined(Q_OS_OS2)
    pFindHidden->setToolTip( i18n("Finds files and directories with the hidden attribute.") );
 #else
    pFindHidden->setToolTip( i18n("Finds files and directories starting with '.'.") );
@@ -1148,7 +1148,7 @@
    //              "Files and directories without change will not appear in the list."));
    //++line;
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(Q_OS_OS2)
    bool bCaseSensitiveFilenameComparison = false;
 #else
    bool bCaseSensitiveFilenameComparison = true;
@@ -1429,7 +1429,7 @@
    pLanguage->addItem( "Auto" );  // Must not translate, won't work otherwise!
    pLanguage->addItem( "en_orig" );
       
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(Q_OS_OS2) 
    // Read directory: Find all kdiff3_*.qm-files and insert the found files here
    QDir localeDir( "/usr/share/locale" ); // See also kreplacements.cpp: getTranslationDir()
    QStringList dirList = localeDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);