summaryrefslogtreecommitdiffstats
path: root/src/kreplacements
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-10 01:27:27 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-10 01:27:27 +0000
commit76718abdb2138623102398a10f3228e576dd0ae8 (patch)
treeddb098baac9689b9e661a41c2a28a8a23ef246d4 /src/kreplacements
downloadkdiff3-76718abdb2138623102398a10f3228e576dd0ae8.tar.gz
kdiff3-76718abdb2138623102398a10f3228e576dd0ae8.zip
Added abandoned KDE3 version of kdiff3
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdiff3@1088041 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/kreplacements')
-rw-r--r--src/kreplacements/README30
-rwxr-xr-xsrc/kreplacements/ShellContextMenu.cpp492
-rw-r--r--src/kreplacements/ShellContextMenu.h60
-rw-r--r--src/kreplacements/kaboutdata.h2
-rw-r--r--src/kreplacements/kaccel.h2
-rw-r--r--src/kreplacements/kaction.h2
-rw-r--r--src/kreplacements/kapplication.h2
-rw-r--r--src/kreplacements/kcmdlineargs.h2
-rw-r--r--src/kreplacements/kcolorbtn.h2
-rw-r--r--src/kreplacements/kconfig.h2
-rw-r--r--src/kreplacements/kdialogbase.h2
-rw-r--r--src/kreplacements/kedittoolbar.h2
-rw-r--r--src/kreplacements/kfiledialog.h2
-rw-r--r--src/kreplacements/kfontdialog.h2
-rw-r--r--src/kreplacements/kiconloader.h2
-rw-r--r--src/kreplacements/kinstance.h2
-rw-r--r--src/kreplacements/kio/global.h2
-rw-r--r--src/kreplacements/kio/job.h2
-rw-r--r--src/kreplacements/kio/jobclasses.h2
-rw-r--r--src/kreplacements/kkeydialog.h2
-rw-r--r--src/kreplacements/klibloader.h2
-rw-r--r--src/kreplacements/klocale.h2
-rw-r--r--src/kreplacements/kmainwindow.h2
-rw-r--r--src/kreplacements/kmenubar.h2
-rw-r--r--src/kreplacements/kmessagebox.h2
-rw-r--r--src/kreplacements/konq_popupmenu.h2
-rw-r--r--src/kreplacements/kparts/factory.h2
-rw-r--r--src/kreplacements/kparts/mainwindow.h2
-rw-r--r--src/kreplacements/kparts/part.h2
-rw-r--r--src/kreplacements/kpopupmenu.h2
-rw-r--r--src/kreplacements/kprinter.h2
-rw-r--r--src/kreplacements/kprogress.h2
-rw-r--r--src/kreplacements/kreplacements.cpp1185
-rw-r--r--src/kreplacements/kreplacements.h505
-rw-r--r--src/kreplacements/kstandarddirs.h2
-rw-r--r--src/kreplacements/kstatusbar.h2
-rw-r--r--src/kreplacements/kstdaction.h2
-rw-r--r--src/kreplacements/ktempfile.h2
-rw-r--r--src/kreplacements/kunload.h2
-rw-r--r--src/kreplacements/kurl.h2
-rw-r--r--src/kreplacements/kurldrag.h2
41 files changed, 2344 insertions, 0 deletions
diff --git a/src/kreplacements/README b/src/kreplacements/README
new file mode 100644
index 0000000..fd9411c
--- /dev/null
+++ b/src/kreplacements/README
@@ -0,0 +1,30 @@
+About the "kreplacements"-directory:
+====================================
+
+I want to be able to compile and use KDiff3 without KDE too.
+Since KDiff3 is a KDE program, which uses many KDE-classes and
+functions there must be some replacement.
+
+In many cases this is just the corresponding Qt-class, but often
+I wrote something myself. For several very KDE-specific functions
+there is no real replacement, but only stub functions that allow
+the program to compile and link.
+
+This stuff is not intended to be used for anything else but KDiff3.
+Think of it rather as a big hack, that only has the advantage
+that I need not mess up the normal program with many ugly
+#ifdef/#endif-clauses.
+
+Most include files in this directory only include kreplacements.h
+where the actual declarations are. The implementions are in
+kreplacements.cpp.
+
+The *.moc-files are dummies. The new KDE-philosophy seems to be
+that *.moc-files are directly included into the sources.
+The Qt-philosophy still is to generate moc*.cpp files which will
+be compiled seperately. With these dummy-moc-files both versions
+can be compiled.
+
+
+Joachim
+(2003-10-02)
diff --git a/src/kreplacements/ShellContextMenu.cpp b/src/kreplacements/ShellContextMenu.cpp
new file mode 100755
index 0000000..e1a6d2d
--- /dev/null
+++ b/src/kreplacements/ShellContextMenu.cpp
@@ -0,0 +1,492 @@
+/***************************************************************************
+ ShellContextMenu.cpp - description
+ -------------------
+ begin : Sat Mar 4 2006
+ copyright : (C) 2005-2007 by Joachim Eibl
+ email : joachim dot eibl at gmx dot de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+// ShellContextMenu.cpp: Implementierung der Klasse CShellContextMenu.
+//
+//////////////////////////////////////////////////////////////////////
+#ifdef _WIN32
+#include <windows.h>
+#include <shlobj.h>
+#include <malloc.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qwidget.h>
+#include <qdir.h>
+#include <qpopupmenu.h>
+#include "ShellContextMenu.h"
+
+#ifdef _DEBUG
+#undef THIS_FILE
+static char THIS_FILE[]=__FILE__;
+#define new DEBUG_NEW
+#endif
+
+//////////////////////////////////////////////////////////////////////
+// Konstruktion/Destruktion
+//////////////////////////////////////////////////////////////////////
+
+#define MIN_ID 100
+#define MAX_ID 10000
+
+
+void showShellContextMenu( const QString& itemPath, QPoint pt, QWidget* pParentWidget, QPopupMenu* pMenu )
+{
+ CShellContextMenu scm;
+ scm.SetObjects(QDir::convertSeparators(itemPath));
+ int id = scm.ShowContextMenu (pParentWidget, pt, pMenu);
+ if (id>=1)
+ pMenu->activateItemAt(id-1);
+}
+
+IContextMenu2 * g_IContext2 = NULL;
+IContextMenu3 * g_IContext3 = NULL;
+
+CShellContextMenu::CShellContextMenu()
+{
+ m_psfFolder = NULL;
+ m_pidlArray = NULL;
+ m_hMenu = NULL;
+}
+
+CShellContextMenu::~CShellContextMenu()
+{
+ // free all allocated datas
+ if (m_psfFolder && bDelete)
+ m_psfFolder->Release ();
+ m_psfFolder = NULL;
+ FreePIDLArray (m_pidlArray);
+ m_pidlArray = NULL;
+
+ if (m_hMenu)
+ DestroyMenu( m_hMenu );
+}
+
+
+
+// this functions determines which version of IContextMenu is avaibale for those objects (always the highest one)
+// and returns that interface
+BOOL CShellContextMenu::GetContextMenu (void ** ppContextMenu, int & iMenuType)
+{
+ *ppContextMenu = NULL;
+ LPCONTEXTMENU icm1 = NULL;
+
+ if ( m_psfFolder==0 )
+ return FALSE;
+ // first we retrieve the normal IContextMenu interface (every object should have it)
+ m_psfFolder->GetUIObjectOf (NULL, nItems, (LPCITEMIDLIST *) m_pidlArray, IID_IContextMenu, NULL, (void**) &icm1);
+
+ if (icm1)
+ { // since we got an IContextMenu interface we can now obtain the higher version interfaces via that
+ if (icm1->QueryInterface (IID_IContextMenu3, ppContextMenu) == NOERROR)
+ iMenuType = 3;
+ else if (icm1->QueryInterface (IID_IContextMenu2, ppContextMenu) == NOERROR)
+ iMenuType = 2;
+
+ if (*ppContextMenu)
+ icm1->Release(); // we can now release version 1 interface, cause we got a higher one
+ else
+ {
+ iMenuType = 1;
+ *ppContextMenu = icm1; // since no higher versions were found
+ } // redirect ppContextMenu to version 1 interface
+ }
+ else
+ return (FALSE); // something went wrong
+
+ return (TRUE); // success
+}
+
+
+LRESULT CALLBACK CShellContextMenu::HookWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_MENUCHAR: // only supported by IContextMenu3
+ if (g_IContext3)
+ {
+ LRESULT lResult = 0;
+ g_IContext3->HandleMenuMsg2 (message, wParam, lParam, &lResult);
+ return (lResult);
+ }
+ break;
+
+ case WM_DRAWITEM:
+ case WM_MEASUREITEM:
+ if (wParam)
+ break; // if wParam != 0 then the message is not menu-related
+
+ case WM_INITMENUPOPUP:
+ if (g_IContext2)
+ g_IContext2->HandleMenuMsg (message, wParam, lParam);
+ else // version 3
+ g_IContext3->HandleMenuMsg (message, wParam, lParam);
+ return (message == WM_INITMENUPOPUP ? 0 : TRUE); // inform caller that we handled WM_INITPOPUPMENU by ourself
+ break;
+
+ default:
+ break;
+ }
+
+ // call original WndProc of window to prevent undefined bevhaviour of window
+ return ::CallWindowProc ((WNDPROC) GetProp ( hWnd, TEXT ("OldWndProc")), hWnd, message, wParam, lParam);
+}
+
+
+UINT CShellContextMenu::ShowContextMenu(QWidget * pParentWidget, QPoint pt, QPopupMenu* pMenu )
+{
+ HWND hWnd = pParentWidget->winId();
+ int iMenuType = 0; // to know which version of IContextMenu is supported
+ LPCONTEXTMENU pContextMenu; // common pointer to IContextMenu and higher version interface
+
+ if (!GetContextMenu ((void**) &pContextMenu, iMenuType))
+ return (0); // something went wrong
+
+ if (!m_hMenu)
+ {
+ DestroyMenu( m_hMenu );
+ m_hMenu = CreatePopupMenu ();
+ }
+
+ UINT_PTR i;
+ for( i=0; i<pMenu->count(); ++i )
+ {
+ QString s = pMenu->text(pMenu->idAt(i));
+ if (!s.isEmpty())
+ AppendMenuW( m_hMenu, MF_STRING, i+1, (LPCWSTR)s.ucs2() );
+ }
+ AppendMenuW( m_hMenu, MF_SEPARATOR, i+1, L"" );
+
+ // lets fill the our popupmenu
+ pContextMenu->QueryContextMenu (m_hMenu, GetMenuItemCount (m_hMenu), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE);
+
+ // subclass window to handle menurelated messages in CShellContextMenu
+ WNDPROC OldWndProc;
+ if (iMenuType > 1) // only subclass if its version 2 or 3
+ {
+ OldWndProc = (WNDPROC) SetWindowLong (hWnd, GWL_WNDPROC, (DWORD) HookWndProc);
+ if (iMenuType == 2)
+ g_IContext2 = (LPCONTEXTMENU2) pContextMenu;
+ else // version 3
+ g_IContext3 = (LPCONTEXTMENU3) pContextMenu;
+ }
+ else
+ OldWndProc = NULL;
+
+ UINT idCommand = TrackPopupMenu (m_hMenu,TPM_RETURNCMD | TPM_LEFTALIGN, pt.x(), pt.y(), 0, pParentWidget->winId(), 0);
+
+ if (OldWndProc) // unsubclass
+ SetWindowLong (hWnd, GWL_WNDPROC, (DWORD) OldWndProc);
+
+ if (idCommand >= MIN_ID && idCommand <= MAX_ID) // see if returned idCommand belongs to shell menu entries
+ {
+ InvokeCommand (pContextMenu, idCommand - MIN_ID); // execute related command
+ idCommand = 0;
+ }
+
+ pContextMenu->Release();
+ g_IContext2 = NULL;
+ g_IContext3 = NULL;
+
+ return (idCommand);
+}
+
+
+void CShellContextMenu::InvokeCommand (LPCONTEXTMENU pContextMenu, UINT idCommand)
+{
+ CMINVOKECOMMANDINFO cmi = {0};
+ cmi.cbSize = sizeof (CMINVOKECOMMANDINFO);
+ cmi.lpVerb = (LPSTR) MAKEINTRESOURCE (idCommand);
+ cmi.nShow = SW_SHOWNORMAL;
+
+ pContextMenu->InvokeCommand (&cmi);
+}
+
+
+void CShellContextMenu::SetObjects(const QString& strObject)
+{
+ // only one object is passed
+ QStringList strArray;
+ strArray << strObject; // create a CStringArray with one element
+
+ SetObjects (strArray); // and pass it to SetObjects (CStringArray &strArray)
+ // for further processing
+}
+
+
+void CShellContextMenu::SetObjects(const QStringList &strList)
+{
+ // free all allocated datas
+ if (m_psfFolder && bDelete)
+ m_psfFolder->Release ();
+ m_psfFolder = NULL;
+ FreePIDLArray (m_pidlArray);
+ m_pidlArray = NULL;
+
+ // get IShellFolder interface of Desktop (root of shell namespace)
+ IShellFolder * psfDesktop = NULL;
+ SHGetDesktopFolder (&psfDesktop); // needed to obtain full qualified pidl
+
+ // ParseDisplayName creates a PIDL from a file system path relative to the IShellFolder interface
+ // but since we use the Desktop as our interface and the Desktop is the namespace root
+ // that means that it's a fully qualified PIDL, which is what we need
+ LPITEMIDLIST pidl = NULL;
+
+ psfDesktop->ParseDisplayName (NULL, 0, (LPOLESTR)strList[0].ucs2(), NULL, &pidl, NULL);
+
+ // now we need the parent IShellFolder interface of pidl, and the relative PIDL to that interface
+ LPITEMIDLIST pidlItem = NULL; // relative pidl
+ SHBindToParentEx (pidl, IID_IShellFolder, (void **) &m_psfFolder, NULL);
+ free (pidlItem);
+ // get interface to IMalloc (need to free the PIDLs allocated by the shell functions)
+ LPMALLOC lpMalloc = NULL;
+ SHGetMalloc (&lpMalloc);
+ lpMalloc->Free (pidl);
+
+ // now we have the IShellFolder interface to the parent folder specified in the first element in strArray
+ // since we assume that all objects are in the same folder (as it's stated in the MSDN)
+ // we now have the IShellFolder interface to every objects parent folder
+
+ IShellFolder * psfFolder = NULL;
+ nItems = strList.size ();
+ for (int i = 0; i < nItems; i++)
+ {
+ pidl=0;
+ psfDesktop->ParseDisplayName (NULL, 0, (LPOLESTR)strList[i].ucs2(), NULL, &pidl, NULL);
+ if (pidl)
+ {
+ m_pidlArray = (LPITEMIDLIST *) realloc (m_pidlArray, (i + 1) * sizeof (LPITEMIDLIST));
+ // get relative pidl via SHBindToParent
+ SHBindToParentEx (pidl, IID_IShellFolder, (void **) &psfFolder, (LPCITEMIDLIST *) &pidlItem);
+ m_pidlArray[i] = CopyPIDL (pidlItem); // copy relative pidl to pidlArray
+ free (pidlItem);
+ lpMalloc->Free (pidl); // free pidl allocated by ParseDisplayName
+ psfFolder->Release ();
+ }
+ }
+ lpMalloc->Release ();
+ psfDesktop->Release ();
+
+ bDelete = TRUE; // indicates that m_psfFolder should be deleted by CShellContextMenu
+}
+
+
+// only one full qualified PIDL has been passed
+void CShellContextMenu::SetObjects(LPITEMIDLIST /*pidl*/)
+{
+/*
+ // free all allocated datas
+ if (m_psfFolder && bDelete)
+ m_psfFolder->Release ();
+ m_psfFolder = NULL;
+ FreePIDLArray (m_pidlArray);
+ m_pidlArray = NULL;
+
+ // full qualified PIDL is passed so we need
+ // its parent IShellFolder interface and its relative PIDL to that
+ LPITEMIDLIST pidlItem = NULL;
+ SHBindToParent ((LPCITEMIDLIST) pidl, IID_IShellFolder, (void **) &m_psfFolder, (LPCITEMIDLIST *) &pidlItem);
+
+ m_pidlArray = (LPITEMIDLIST *) malloc (sizeof (LPITEMIDLIST)); // allocate ony for one elemnt
+ m_pidlArray[0] = CopyPIDL (pidlItem);
+
+
+ // now free pidlItem via IMalloc interface (but not m_psfFolder, that we need later
+ LPMALLOC lpMalloc = NULL;
+ SHGetMalloc (&lpMalloc);
+ lpMalloc->Free (pidlItem);
+ lpMalloc->Release();
+
+ nItems = 1;
+ bDelete = TRUE; // indicates that m_psfFolder should be deleted by CShellContextMenu
+*/
+}
+
+
+// IShellFolder interface with a relative pidl has been passed
+void CShellContextMenu::SetObjects(IShellFolder *psfFolder, LPITEMIDLIST pidlItem)
+{
+ // free all allocated datas
+ if (m_psfFolder && bDelete)
+ m_psfFolder->Release ();
+ m_psfFolder = NULL;
+ FreePIDLArray (m_pidlArray);
+ m_pidlArray = NULL;
+
+ m_psfFolder = psfFolder;
+
+ m_pidlArray = (LPITEMIDLIST *) malloc (sizeof (LPITEMIDLIST));
+ m_pidlArray[0] = CopyPIDL (pidlItem);
+
+ nItems = 1;
+ bDelete = FALSE; // indicates wheter m_psfFolder should be deleted by CShellContextMenu
+}
+
+void CShellContextMenu::SetObjects(IShellFolder * psfFolder, LPITEMIDLIST *pidlArray, int nItemCount)
+{
+ // free all allocated datas
+ if (m_psfFolder && bDelete)
+ m_psfFolder->Release ();
+ m_psfFolder = NULL;
+ FreePIDLArray (m_pidlArray);
+ m_pidlArray = NULL;
+
+ m_psfFolder = psfFolder;
+
+ m_pidlArray = (LPITEMIDLIST *) malloc (nItemCount * sizeof (LPITEMIDLIST));
+
+ for (int i = 0; i < nItemCount; i++)
+ m_pidlArray[i] = CopyPIDL (pidlArray[i]);
+
+ nItems = nItemCount;
+ bDelete = FALSE; // indicates wheter m_psfFolder should be deleted by CShellContextMenu
+}
+
+
+void CShellContextMenu::FreePIDLArray(LPITEMIDLIST *pidlArray)
+{
+ if (!pidlArray)
+ return;
+
+ int iSize = _msize (pidlArray) / sizeof (LPITEMIDLIST);
+
+ for (int i = 0; i < iSize; i++)
+ free (pidlArray[i]);
+ free (pidlArray);
+}
+
+
+LPITEMIDLIST CShellContextMenu::CopyPIDL (LPCITEMIDLIST pidl, int cb)
+{
+ if (cb == -1)
+ cb = GetPIDLSize (pidl); // Calculate size of list.
+
+ LPITEMIDLIST pidlRet = (LPITEMIDLIST) calloc (cb + sizeof (USHORT), sizeof (BYTE));
+ if (pidlRet)
+ CopyMemory(pidlRet, pidl, cb);
+
+ return (pidlRet);
+}
+
+
+UINT CShellContextMenu::GetPIDLSize (LPCITEMIDLIST pidl)
+{
+ if (!pidl)
+ return 0;
+ int nSize = 0;
+ LPITEMIDLIST pidlTemp = (LPITEMIDLIST) pidl;
+ while (pidlTemp->mkid.cb)
+ {
+ nSize += pidlTemp->mkid.cb;
+ pidlTemp = (LPITEMIDLIST) (((LPBYTE) pidlTemp) + pidlTemp->mkid.cb);
+ }
+ return nSize;
+}
+
+HMENU CShellContextMenu::GetMenu()
+{
+ if (!m_hMenu)
+ {
+ m_hMenu = CreatePopupMenu(); // create the popupmenu (its empty)
+ }
+ return (m_hMenu);
+}
+
+
+// this is workaround function for the Shell API Function SHBindToParent
+// SHBindToParent is not available under Win95/98
+HRESULT CShellContextMenu::SHBindToParentEx (LPCITEMIDLIST pidl, REFIID riid, VOID **ppv, LPCITEMIDLIST *ppidlLast)
+{
+ HRESULT hr = 0;
+ if (!pidl || !ppv)
+ return E_POINTER;
+
+ int nCount = GetPIDLCount (pidl);
+ if (nCount == 0) // desktop pidl of invalid pidl
+ return E_POINTER;
+
+ IShellFolder * psfDesktop = NULL;
+ SHGetDesktopFolder (&psfDesktop);
+ if (nCount == 1) // desktop pidl
+ {
+ if ((hr = psfDesktop->QueryInterface(riid, ppv)) == S_OK)
+ {
+ if (ppidlLast)
+ *ppidlLast = CopyPIDL (pidl);
+ }
+ psfDesktop->Release ();
+ return hr;
+ }
+
+ LPBYTE pRel = GetPIDLPos (pidl, nCount - 1);
+ LPITEMIDLIST pidlParent = NULL;
+ pidlParent = CopyPIDL (pidl, pRel - (LPBYTE) pidl);
+ IShellFolder * psfFolder = NULL;
+
+ if ((hr = psfDesktop->BindToObject (pidlParent, NULL, IID_IShellFolder, (void **) &psfFolder)) != S_OK)
+ {
+ free (pidlParent);
+ psfDesktop->Release ();
+ return hr;
+ }
+ if ((hr = psfFolder->QueryInterface (riid, ppv)) == S_OK)
+ {
+ if (ppidlLast)
+ *ppidlLast = CopyPIDL ((LPCITEMIDLIST) pRel);
+ }
+ free (pidlParent);
+ psfFolder->Release ();
+ psfDesktop->Release ();
+ return hr;
+}
+
+
+LPBYTE CShellContextMenu::GetPIDLPos (LPCITEMIDLIST pidl, int nPos)
+{
+ if (!pidl)
+ return 0;
+ int nCount = 0;
+
+ BYTE * pCur = (BYTE *) pidl;
+ while (((LPCITEMIDLIST) pCur)->mkid.cb)
+ {
+ if (nCount == nPos)
+ return pCur;
+ nCount++;
+ pCur += ((LPCITEMIDLIST) pCur)->mkid.cb; // + sizeof(pidl->mkid.cb);
+ }
+ if (nCount == nPos)
+ return pCur;
+ return NULL;
+}
+
+
+int CShellContextMenu::GetPIDLCount (LPCITEMIDLIST pidl)
+{
+ if (!pidl)
+ return 0;
+
+ int nCount = 0;
+ BYTE* pCur = (BYTE *) pidl;
+ while (((LPCITEMIDLIST) pCur)->mkid.cb)
+ {
+ nCount++;
+ pCur += ((LPCITEMIDLIST) pCur)->mkid.cb;
+ }
+ return nCount;
+}
+
+#endif
+
diff --git a/src/kreplacements/ShellContextMenu.h b/src/kreplacements/ShellContextMenu.h
new file mode 100644
index 0000000..ae67483
--- /dev/null
+++ b/src/kreplacements/ShellContextMenu.h
@@ -0,0 +1,60 @@
+/***************************************************************************
+ ShellContextMenu.h - description
+ -------------------
+ begin : Sat Mar 4 2006
+ copyright : (C) 2005-2007 by Joachim Eibl
+ email : joachim dot eibl at gmx dot de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+// ShellContextMenu.h: Schnittstelle fr die Klasse CShellContextMenu.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef SHELLCONTEXTMENU_H
+#define SHELLCONTEXTMENU_H
+
+/////////////////////////////////////////////////////////////////////
+// class to show shell contextmenu of files/folders/shell objects
+// developed by R. Engels 2003
+/////////////////////////////////////////////////////////////////////
+
+class CShellContextMenu
+{
+public:
+ HMENU GetMenu ();
+ void SetObjects (IShellFolder * psfFolder, LPITEMIDLIST pidlItem);
+ void SetObjects (IShellFolder * psfFolder, LPITEMIDLIST * pidlArray, int nItemCount);
+ void SetObjects (LPITEMIDLIST pidl);
+ void SetObjects (const QString& strObject);
+ void SetObjects (const QStringList& strList);
+ UINT ShowContextMenu (QWidget* pParent, QPoint pt, QPopupMenu* pMenu);
+ CShellContextMenu();
+ virtual ~CShellContextMenu();
+
+private:
+ int nItems;
+ BOOL bDelete;
+ HMENU m_hMenu;
+ IShellFolder * m_psfFolder;
+ LPITEMIDLIST * m_pidlArray;
+
+ void InvokeCommand (LPCONTEXTMENU pContextMenu, UINT idCommand);
+ BOOL GetContextMenu (void ** ppContextMenu, int & iMenuType);
+ HRESULT SHBindToParentEx (LPCITEMIDLIST pidl, REFIID riid, VOID **ppv, LPCITEMIDLIST *ppidlLast);
+ static LRESULT CALLBACK HookWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+ void FreePIDLArray (LPITEMIDLIST * pidlArray);
+ LPITEMIDLIST CopyPIDL (LPCITEMIDLIST pidl, int cb = -1);
+ UINT GetPIDLSize (LPCITEMIDLIST pidl);
+ LPBYTE GetPIDLPos (LPCITEMIDLIST pidl, int nPos);
+ int GetPIDLCount (LPCITEMIDLIST pidl);
+};
+
+#endif
diff --git a/src/kreplacements/kaboutdata.h b/src/kreplacements/kaboutdata.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kaboutdata.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kaccel.h b/src/kreplacements/kaccel.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kaccel.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kaction.h b/src/kreplacements/kaction.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kaction.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kapplication.h b/src/kreplacements/kapplication.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kapplication.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kcmdlineargs.h b/src/kreplacements/kcmdlineargs.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kcmdlineargs.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kcolorbtn.h b/src/kreplacements/kcolorbtn.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kcolorbtn.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kconfig.h b/src/kreplacements/kconfig.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kconfig.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kdialogbase.h b/src/kreplacements/kdialogbase.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kdialogbase.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kedittoolbar.h b/src/kreplacements/kedittoolbar.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kedittoolbar.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kfiledialog.h b/src/kreplacements/kfiledialog.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kfiledialog.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kfontdialog.h b/src/kreplacements/kfontdialog.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kfontdialog.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kiconloader.h b/src/kreplacements/kiconloader.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kiconloader.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kinstance.h b/src/kreplacements/kinstance.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kinstance.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kio/global.h b/src/kreplacements/kio/global.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kio/global.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kio/job.h b/src/kreplacements/kio/job.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kio/job.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kio/jobclasses.h b/src/kreplacements/kio/jobclasses.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kio/jobclasses.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kkeydialog.h b/src/kreplacements/kkeydialog.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kkeydialog.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/klibloader.h b/src/kreplacements/klibloader.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/klibloader.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/klocale.h b/src/kreplacements/klocale.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/klocale.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kmainwindow.h b/src/kreplacements/kmainwindow.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kmainwindow.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kmenubar.h b/src/kreplacements/kmenubar.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kmenubar.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kmessagebox.h b/src/kreplacements/kmessagebox.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kmessagebox.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/konq_popupmenu.h b/src/kreplacements/konq_popupmenu.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/konq_popupmenu.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kparts/factory.h b/src/kreplacements/kparts/factory.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kparts/factory.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kparts/mainwindow.h b/src/kreplacements/kparts/mainwindow.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kparts/mainwindow.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kparts/part.h b/src/kreplacements/kparts/part.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kparts/part.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kpopupmenu.h b/src/kreplacements/kpopupmenu.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kpopupmenu.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kprinter.h b/src/kreplacements/kprinter.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kprinter.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kprogress.h b/src/kreplacements/kprogress.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kprogress.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kreplacements.cpp b/src/kreplacements/kreplacements.cpp
new file mode 100644
index 0000000..95885a5
--- /dev/null
+++ b/src/kreplacements/kreplacements.cpp
@@ -0,0 +1,1185 @@
+/***************************************************************************
+ kreplacements.cpp - description
+ -------------------
+ begin : Sat Aug 3 2002
+ copyright : (C) 2002-2007 by Joachim Eibl
+ email : joachim.eibl at gmx.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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 "kreplacements.h"
+#include "common.h"
+
+#include <assert.h>
+
+#include <qnamespace.h>
+#include <qmessagebox.h>
+#include <qpopupmenu.h>
+#include <qmenubar.h>
+#include <qpainter.h>
+#include <qcolordialog.h>
+#include <qfontdialog.h>
+#include <qlabel.h>
+#include <qtextbrowser.h>
+#include <qtextstream.h>
+#include <qlayout.h>
+#include <qdockarea.h>
+
+#include <vector>
+#include <iostream>
+#include <algorithm>
+
+
+static QString s_copyright;
+static QString s_email;
+static QString s_description;
+static QString s_appName;
+static QString s_version;
+static QString s_homepage;
+static KAboutData* s_pAboutData;
+
+
+#ifdef _WIN32
+#include <process.h>
+#include <windows.h>
+#endif
+
+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 = "."; }
+
+ QFileInfo helpFile( exePath + "\\doc\\en\\index.html" );
+ if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\..\\doc\\en\\index.html" ); }
+ if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\doc\\index.html" ); }
+ if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\..\\doc\\index.html" ); }
+ if ( ! helpFile.exists() )
+ {
+ QMessageBox::warning( 0, "KDiff3 documentation not found",
+ "Couldn't find the documentation. \n\n"
+ "The documentation can also be found at the homepage:\n\n "
+ " http://kdiff3.sourceforge.net/");
+ return;
+ }
+
+ HINSTANCE hi = FindExecutableA( helpFile.fileName().ascii(), helpFile.dirPath(true).ascii(), buf );
+ if ( int(hi)<=32 )
+ {
+ static QTextBrowser* pBrowser = 0;
+ if (pBrowser==0)
+ {
+ pBrowser = new QTextBrowser( 0 );
+ pBrowser->setMinimumSize( 600, 400 );
+ }
+ pBrowser->setSource(helpFile.filePath());
+ pBrowser->show();
+ }
+ else
+ {
+ QFileInfo prog( buf );
+ _spawnlp( _P_NOWAIT , prog.filePath().ascii(), prog.fileName().ascii(), ("\"file:///"+helpFile.absFilePath()+"\"").ascii(), NULL );
+ }
+
+ #else
+ static QTextBrowser* pBrowser = 0;
+ if (pBrowser==0)
+ {
+ pBrowser = new QTextBrowser( 0 );
+ pBrowser->setMinimumSize( 600, 400 );
+ }
+ pBrowser->setSource("/usr/local/share/doc/kdiff3/en/index.html");
+ pBrowser->show();
+ #endif
+}
+
+QString getTranslationDir()
+{
+ #ifdef _WIN32
+ char buf[200];
+ int r= SearchPathA( 0, ".", 0, sizeof(buf), buf, 0 );
+
+ QString exePath;
+ if (r!=0) { exePath = buf; }
+ else { exePath = "."; }
+ return exePath+"/translations";
+ #else
+ return ".";
+ #endif
+}
+
+// static
+void KMessageBox::error( QWidget* parent, const QString& text, const QString& caption )
+{
+ QMessageBox::critical( parent, caption, text );
+}
+
+int KMessageBox::warningContinueCancel( QWidget* parent, const QString& text, const QString& caption,
+ const QString& button1 )
+{
+ return 0 == QMessageBox::warning( parent, caption, text, button1, "Cancel" ) ? Continue : Cancel;
+}
+
+void KMessageBox::sorry( QWidget* parent, const QString& text, const QString& caption )
+{
+ QMessageBox::information( parent, caption, text );
+}
+
+void KMessageBox::information( QWidget* parent, const QString& text, const QString& caption )
+{
+ QMessageBox::information( parent, caption, text );
+}
+
+int KMessageBox::warningYesNo( QWidget* parent, const QString& text, const QString& caption,
+ const QString& button1, const QString& button2 )
+{
+ return 0 == QMessageBox::warning( parent, caption, text, button1, button2, QString::null, 1, 1 ) ? Yes : No;
+}
+
+int KMessageBox::warningYesNoCancel( QWidget* parent, const QString& text, const QString& caption,
+ const QString& button1, const QString& button2 )
+{
+ int val = QMessageBox::warning( parent, caption, text,
+ button1, button2, i18n("Cancel") );
+ if ( val==0 ) return Yes;
+ if ( val==1 ) return No;
+ else return Cancel;
+}
+
+
+KDialogBase::KDialogBase( int, const QString& caption, int, int, QWidget* parent, const char* name,
+ bool /*modal*/, bool )
+: QTabDialog( parent, name, true /* modal */ )
+{
+ setCaption( caption );
+ setDefaultButton();
+ setHelpButton();
+ setCancelButton();
+ //setApplyButton();
+ setOkButton();
+ setDefaultButton();
+
+ connect( this, SIGNAL( defaultButtonPressed() ), this, SLOT(slotDefault()) );
+ connect( this, SIGNAL( helpButtonPressed() ), this, SLOT(slotHelp()));
+ connect( this, SIGNAL( applyButtonPressed() ), this, SLOT( slotApply() ));
+}
+
+KDialogBase::~KDialogBase()
+{
+}
+
+void KDialogBase::incInitialSize ( const QSize& )
+{
+}
+
+void KDialogBase::setHelp(const QString&, const QString& )
+{
+}
+
+
+int KDialogBase::BarIcon(const QString& /*iconName*/, int )
+{
+ return 0; // Not used for replacement.
+}
+
+
+QVBox* KDialogBase::addVBoxPage( const QString& name, const QString& /*info*/, int )
+{
+ QVBox* p = new QVBox(this, name.ascii());
+ addTab( p, name );
+ return p;
+}
+
+QFrame* KDialogBase::addPage( const QString& name, const QString& /*info*/, int )
+{
+ QFrame* p = new QFrame( this, name.ascii() );
+ addTab( p, name );
+ return p;
+}
+
+int KDialogBase::spacingHint()
+{
+ return 5;
+}
+
+static bool s_inAccept = false;
+static bool s_bAccepted = false;
+void KDialogBase::accept()
+{
+ if( ! s_inAccept )
+ {
+ s_bAccepted = false;
+ s_inAccept = true;
+ slotOk();
+ s_inAccept = false;
+ if ( s_bAccepted )
+ QTabDialog::accept();
+ }
+ else
+ {
+ s_bAccepted = true;
+ }
+}
+
+void KDialogBase::slotDefault( )
+{
+}
+void KDialogBase::slotOk()
+{
+}
+void KDialogBase::slotCancel( )
+{
+}
+void KDialogBase::slotApply( )
+{
+ emit applyClicked();
+}
+void KDialogBase::slotHelp( )
+{
+ showHelp();
+}
+
+KURL KFileDialog::getSaveURL( const QString &startDir,
+ const QString &filter,
+ QWidget *parent, const QString &caption)
+{
+ QString s = QFileDialog::getSaveFileName(startDir, filter, parent, 0, caption);
+ return KURL(s);
+}
+
+KURL KFileDialog::getOpenURL( const QString & startDir,
+ const QString & filter,
+ QWidget * parent,
+ const QString & caption )
+{
+ QString s = QFileDialog::getOpenFileName(startDir, filter, parent, 0, caption);
+ return KURL(s);
+}
+
+KURL KFileDialog::getExistingURL( const QString & startDir,
+ QWidget * parent,
+ const QString & caption)
+{
+ QString s = QFileDialog::getExistingDirectory(startDir, parent, 0, caption);
+ return KURL(s);
+}
+
+QString KFileDialog::getSaveFileName (const QString &startDir,
+ const QString &filter,
+ QWidget *parent,
+ const QString &caption)
+{
+ return QFileDialog::getSaveFileName( startDir, filter, parent, 0, caption );
+}
+
+
+KToolBar::BarPosition KToolBar::barPos()
+{
+ if ( m_pMainWindow->leftDock()->hasDockWindow(this) ) return Left;
+ if ( m_pMainWindow->rightDock()->hasDockWindow(this) ) return Right;
+ if ( m_pMainWindow->topDock()->hasDockWindow(this) ) return Top;
+ if ( m_pMainWindow->bottomDock()->hasDockWindow(this) ) return Bottom;
+ return Top;
+}
+
+void KToolBar::setBarPos(BarPosition bp)
+{
+ if ( bp == Left ) m_pMainWindow->moveDockWindow( this, DockLeft );
+ else if ( bp == Right ) m_pMainWindow->moveDockWindow( this, DockRight );
+ else if ( bp == Bottom ) m_pMainWindow->moveDockWindow( this, DockBottom );
+ else if ( bp == Top ) m_pMainWindow->moveDockWindow( this, DockTop );
+}
+
+KToolBar::KToolBar( QMainWindow* parent )
+: QToolBar( parent )
+{
+ m_pMainWindow = parent;
+}
+
+
+KMainWindow::KMainWindow( QWidget* parent, const char* name )
+: QMainWindow( parent, name ), m_actionCollection(this)
+{
+ fileMenu = new QPopupMenu();
+ menuBar()->insertItem(i18n("&File"), fileMenu);
+ editMenu = new QPopupMenu();
+ menuBar()->insertItem(i18n("&Edit"), editMenu);
+ directoryMenu = new QPopupMenu();
+ menuBar()->insertItem(i18n("&Directory"), directoryMenu);
+ dirCurrentItemMenu = 0;
+ dirCurrentSyncItemMenu = 0;
+ movementMenu = new QPopupMenu();
+ menuBar()->insertItem(i18n("&Movement"), movementMenu);
+ diffMenu = new QPopupMenu();
+ menuBar()->insertItem(i18n("D&iffview"), diffMenu);
+ mergeMenu = new QPopupMenu();
+ menuBar()->insertItem(i18n("&Merge"), mergeMenu);
+ windowsMenu = new QPopupMenu();
+ menuBar()->insertItem(i18n("&Window"), windowsMenu);
+ settingsMenu = new QPopupMenu();
+ menuBar()->insertItem(i18n("&Settings"), settingsMenu);
+ helpMenu = new QPopupMenu();
+ menuBar()->insertItem(i18n("&Help"), helpMenu);
+
+ m_pToolBar = new KToolBar(this);
+
+ memberList = new QList<KMainWindow>;
+ memberList->append(this);
+}
+
+KToolBar* KMainWindow::toolBar(const QString&)
+{
+ return m_pToolBar;
+}
+
+KActionCollection* KMainWindow::actionCollection()
+{
+ return &m_actionCollection;
+}
+
+void KMainWindow::createGUI()
+{
+ KStdAction::help(this, SLOT(slotHelp()), actionCollection());
+ KStdAction::about(this, SLOT(slotAbout()), actionCollection());
+ KStdAction::aboutQt(actionCollection());
+}
+
+void KMainWindow::slotAbout()
+{
+ QTabDialog d;
+ d.setCaption("About " + s_appName);
+ QTextBrowser* tb1 = new QTextBrowser(&d);
+ tb1->setWordWrap( QTextEdit::NoWrap );
+ tb1->setText(
+ s_appName + " Version " + s_version +
+ "\n\n" + s_description +
+ "\n\n" + s_copyright +
+ "\n\nHomepage: " + s_homepage +
+ "\n\nLicence: GNU GPL Version 2"
+ );
+ d.addTab(tb1,i18n("&About"));
+
+ std::list<KAboutData::AboutDataEntry>::iterator i;
+
+ QString s2;
+ for( i=s_pAboutData->m_authorList.begin(); i!=s_pAboutData->m_authorList.end(); ++i )
+ {
+ if ( !i->m_name.isEmpty() ) s2 += i->m_name + "\n";
+ if ( !i->m_task.isEmpty() ) s2 += " " + i->m_task + "\n";
+ if ( !i->m_email.isEmpty() ) s2 += " " + i->m_email + "\n";
+ if ( !i->m_weblink.isEmpty() ) s2 += " " + i->m_weblink + "\n";
+ s2 += "\n";
+ }
+ QTextBrowser* tb2 = new QTextBrowser(&d);
+ tb2->setWordWrap( QTextEdit::NoWrap );
+ tb2->setText(s2);
+ d.addTab(tb2,i18n("A&uthor"));
+
+ QString s3;
+ for( i=s_pAboutData->m_creditList.begin(); i!=s_pAboutData->m_creditList.end(); ++i )
+ {
+ if ( !i->m_name.isEmpty() ) s3 += i->m_name + "\n";
+ if ( !i->m_task.isEmpty() ) s3 += " " + i->m_task + "\n";
+ if ( !i->m_email.isEmpty() ) s3 += " " + i->m_email + "\n";
+ if ( !i->m_weblink.isEmpty() ) s3 += " " + i->m_weblink + "\n";
+ s3 += "\n";
+ }
+ QTextBrowser* tb3 = new QTextBrowser(&d);
+ tb3->setWordWrap( QTextEdit::NoWrap );
+ tb3->setText(s3);
+ d.addTab(tb3,i18n("&Thanks To"));
+
+ d.resize(400,300);
+ d.exec();
+/*
+ QMessageBox::information(
+ this,
+ "About " + s_appName,
+ s_appName + " Version " + s_version +
+ "\n\n" + s_description +
+ "\n\n" + s_copyright +
+ "\n\nHomepage: " + s_homepage +
+ "\n\nLicence: GNU GPL Version 2"
+ );
+*/
+}
+
+void KMainWindow::slotHelp()
+{
+ showHelp();
+}
+
+
+QString KStandardDirs::findResource(const QString& resource, const QString& /*appName*/)
+{
+ if (resource=="config")
+ {
+ QString home = QDir::homeDirPath();
+ return home + "/.kdiff3rc";
+ }
+ return QString();
+}
+
+KConfig::KConfig()
+{
+}
+
+void KConfig::readConfigFile( const QString& configFileName )
+{
+ if ( !configFileName.isEmpty() )
+ {
+ m_fileName = configFileName;
+ }
+ else
+ {
+ m_fileName = KStandardDirs().findResource("config","kdiff3rc");
+ }
+
+ QFile f( m_fileName );
+ if ( f.open(IO_ReadOnly) )
+ { // file opened successfully
+ QTextStream t( &f ); // use a text stream
+ load(t);
+ f.close();
+ }
+}
+
+KConfig::~KConfig()
+{
+ QFile f(m_fileName);
+ if ( f.open( IO_WriteOnly | IO_Translate ) )
+ { // file opened successfully
+ QTextStream t( &f ); // use a text stream
+ save(t);
+ f.close();
+ }
+}
+
+void KConfig::setGroup(const QString&)
+{
+}
+
+void KAction::init(QObject* receiver, const char* slot, KActionCollection* actionCollection,
+ const char* name, bool bToggle, bool bMenu)
+{
+ QString n(name);
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ if( slot!=0 )
+ {
+ if (!bToggle)
+ connect(this, SIGNAL(activated()), receiver, slot);
+ else
+ {
+ connect(this, SIGNAL(toggled(bool)), receiver, slot);
+ }
+ }
+
+ if (bMenu)
+ {
+ if( n[0]=='g') addTo( p->movementMenu );
+ else if( n.left(16)=="dir_current_sync")
+ {
+ if ( p->dirCurrentItemMenu==0 )
+ {
+ p->dirCurrentItemMenu = new QPopupMenu();
+ p->directoryMenu->insertItem(i18n("Current Item Merge Operation"), p->dirCurrentItemMenu);
+ p->dirCurrentSyncItemMenu = new QPopupMenu();
+ p->directoryMenu->insertItem(i18n("Current Item Sync Operation"), p->dirCurrentSyncItemMenu);
+ }
+ addTo( p->dirCurrentItemMenu );
+ }
+ else if( n.left(11)=="dir_current")
+ {
+ if ( p->dirCurrentItemMenu==0 )
+ {
+ p->dirCurrentItemMenu = new QPopupMenu();
+ p->directoryMenu->insertItem(i18n("Current Item Merge Operation"), p->dirCurrentItemMenu);
+ p->dirCurrentSyncItemMenu = new QPopupMenu();
+ p->directoryMenu->insertItem(i18n("Current Item Sync Operation"), p->dirCurrentSyncItemMenu);
+ }
+ addTo( p->dirCurrentSyncItemMenu );
+ }
+ else if( n.left(4)=="diff") addTo( p->diffMenu );
+ else if( name[0]=='d') addTo( p->directoryMenu );
+ else if( name[0]=='f') addTo( p->fileMenu );
+ else if( name[0]=='w') addTo( p->windowsMenu );
+ else addTo( p->mergeMenu );
+ }
+}
+
+
+KAction::KAction(const QString& text, const QIconSet& icon, int accel,
+ QObject* receiver, const char* slot, KActionCollection* actionCollection,
+ const char* name, bool bToggle, bool bMenu
+ )
+: QAction ( text, icon, text, accel, actionCollection->m_pMainWindow, name, bToggle )
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ if ( !icon.isNull() && p ) this->addTo( p->m_pToolBar );
+
+ init(receiver,slot,actionCollection,name,bToggle,bMenu);
+}
+
+KAction::KAction(const QString& text, int accel,
+ QObject* receiver, const char* slot, KActionCollection* actionCollection,
+ const char* name, bool bToggle, bool bMenu
+ )
+: QAction ( text, text, accel, actionCollection->m_pMainWindow, name, bToggle )
+{
+ init(receiver,slot,actionCollection,name,bToggle,bMenu);
+}
+
+void KAction::setStatusText(const QString&)
+{
+}
+
+void KAction::plug(QPopupMenu* menu)
+{
+ addTo(menu);
+}
+
+
+KToggleAction::KToggleAction(const QString& text, const QIconSet& icon, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu)
+: KAction( text, icon, accel, receiver, slot, actionCollection, name, true, bMenu)
+{
+}
+
+KToggleAction::KToggleAction(const QString& text, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu)
+: KAction( text, accel, receiver, slot, actionCollection, name, true, bMenu)
+{
+}
+
+KToggleAction::KToggleAction(const QString& text, const QIconSet& icon, int accel, KActionCollection* actionCollection, const char* name, bool bMenu)
+: KAction( text, icon, accel, 0, 0, actionCollection, name, true, bMenu)
+{
+}
+
+void KToggleAction::setChecked(bool bChecked)
+{
+ blockSignals( true );
+ setOn( bChecked );
+ blockSignals( false );
+}
+
+bool KToggleAction::isChecked()
+{
+ return isOn();
+}
+
+
+
+//static
+KAction* KStdAction::open( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ #include "../xpm/fileopen.xpm"
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Open"), QIconSet(QPixmap(fileopen)), Qt::CTRL+Qt::Key_O, parent, slot, actionCollection, "open", false, false);
+ if(p){ a->addTo( p->fileMenu ); }
+ return a;
+}
+
+KAction* KStdAction::save( QWidget* parent, const char* slot, KActionCollection* actionCollection )
+{
+ #include "../xpm/filesave.xpm"
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Save"), QIconSet(QPixmap(filesave)), Qt::CTRL+Qt::Key_S, parent, slot, actionCollection, "save", false, false);
+ if(p){ a->addTo( p->fileMenu ); }
+ return a;
+}
+
+KAction* KStdAction::saveAs( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Save As..."), 0, parent, slot, actionCollection, "saveas", false, false);
+ if(p) a->addTo( p->fileMenu );
+ return a;
+}
+
+KAction* KStdAction::print( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ #include "../xpm/fileprint.xpm"
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Print..."), QIconSet(QPixmap(fileprint)),Qt::CTRL+Qt::Key_P, parent, slot, actionCollection, "print", false, false);
+ if(p) a->addTo( p->fileMenu );
+ return a;
+}
+
+KAction* KStdAction::quit( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Quit"), Qt::CTRL+Qt::Key_Q, parent, slot, actionCollection, "quit", false, false);
+ if(p) a->addTo( p->fileMenu );
+ return a;
+}
+
+KAction* KStdAction::cut( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Cut"), Qt::CTRL+Qt::Key_X, parent, slot, actionCollection, "cut", false, false );
+ if(p) a->addTo( p->editMenu );
+ return a;
+}
+
+KAction* KStdAction::copy( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Copy"), Qt::CTRL+Qt::Key_C, parent, slot, actionCollection, "copy", false, false );
+ if(p) a->addTo( p->editMenu );
+ return a;
+}
+
+KAction* KStdAction::paste( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Paste"), Qt::CTRL+Qt::Key_V, parent, slot, actionCollection, "paste", false, false );
+ if(p) a->addTo( p->editMenu );
+ return a;
+}
+
+KAction* KStdAction::selectAll( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Select All"), Qt::CTRL+Qt::Key_A, parent, slot, actionCollection, "selectall", false, false );
+ if(p) a->addTo( p->editMenu );
+ return a;
+}
+
+KToggleAction* KStdAction::showToolbar( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KToggleAction* a = new KToggleAction( i18n("Show Toolbar"), 0, parent, slot, actionCollection, "showtoolbar", false );
+ if(p) a->addTo( p->settingsMenu );
+ return a;
+}
+
+KToggleAction* KStdAction::showStatusbar( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KToggleAction* a = new KToggleAction( i18n("Show &Statusbar"), 0, parent, slot, actionCollection, "showstatusbar", false );
+ if(p) a->addTo( p->settingsMenu );
+ return a;
+}
+
+KAction* KStdAction::preferences( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("&Configure %1...").arg("KDiff3"), 0, parent, slot, actionCollection, "settings", false, false );
+ if(p) a->addTo( p->settingsMenu );
+ return a;
+}
+KAction* KStdAction::keyBindings( QWidget*, const char*, KActionCollection*)
+{
+ return 0;
+}
+
+KAction* KStdAction::about( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("About")+" KDiff3", 0, parent, slot, actionCollection, "about_kdiff3", false, false );
+ if(p) a->addTo( p->helpMenu );
+ return a;
+}
+
+KAction* KStdAction::aboutQt( KActionCollection* actionCollection )
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("About")+" Qt", 0, qApp, SLOT(aboutQt()), actionCollection, "about_qt", false, false );
+ if(p) a->addTo( p->helpMenu );
+ return a;
+}
+
+KAction* KStdAction::help( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Help"), Qt::Key_F1, parent, slot, actionCollection, "help", false, false );
+ if(p) a->addTo( p->helpMenu );
+ return a;
+}
+KAction* KStdAction::find( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Find"), Qt::CTRL+Qt::Key_F, parent, slot, actionCollection, "find", false, false );
+ if(p) a->addTo( p->editMenu );
+ return a;
+}
+
+KAction* KStdAction::findNext( QWidget* parent, const char* slot, KActionCollection* actionCollection)
+{
+ KMainWindow* p = actionCollection->m_pMainWindow;
+ KAction* a = new KAction( i18n("Find Next"), Qt::Key_F3, parent, slot, actionCollection, "findNext", false, false );
+ if(p) a->addTo( p->editMenu );
+ return a;
+}
+
+
+
+
+KFontChooser::KFontChooser( QWidget* pParent, const QString& /*name*/, bool, const QStringList&, bool, int )
+: QWidget(pParent)
+{
+ m_pParent = pParent;
+ QVBoxLayout* pLayout = new QVBoxLayout( this );
+ m_pSelectFont = new QPushButton(i18n("Select Font"), this );
+ connect(m_pSelectFont, SIGNAL(clicked()), this, SLOT(slotSelectFont()));
+ pLayout->addWidget(m_pSelectFont);
+
+ m_pLabel = new QLabel( "", this );
+ m_pLabel->setFont( m_font );
+ m_pLabel->setMinimumWidth(200);
+ m_pLabel->setText( "The quick brown fox jumps over the river\n"
+ "but the little red hen escapes with a shiver.\n"
+ ":-)");
+ pLayout->addWidget(m_pLabel);
+}
+
+QFont KFontChooser::font()
+{
+ return m_font;//QFont("courier",10);
+}
+
+void KFontChooser::setFont( const QFont& font, bool )
+{
+ m_font = font;
+ m_pLabel->setFont( m_font );
+ //update();
+}
+
+void KFontChooser::slotSelectFont()
+{
+ for(;;)
+ {
+ bool bOk;
+ m_font = QFontDialog::getFont(&bOk, m_font );
+ m_pLabel->setFont( m_font );
+ QFontMetrics fm(m_font);
+
+ // Variable width font.
+ if ( fm.width('W')!=fm.width('i') )
+ {
+ int result = KMessageBox::warningYesNo(m_pParent, i18n(
+ "You selected a variable width font.\n\n"
+ "Because this program doesn't handle variable width fonts\n"
+ "correctly, you might experience problems while editing.\n\n"
+ "Do you want to continue or do you want to select another font."),
+ i18n("Incompatible font."),
+ i18n("Continue at my own risk"), i18n("Select another font"));
+ if (result==KMessageBox::Yes)
+ return;
+ }
+ else
+ return;
+ }
+}
+
+
+KColorButton::KColorButton(QWidget* parent)
+: QPushButton(parent)
+{
+ connect( this, SIGNAL(clicked()), this, SLOT(slotClicked()));
+}
+
+QColor KColorButton::color()
+{
+ return m_color;
+}
+
+void KColorButton::setColor( const QColor& color )
+{
+ m_color = color;
+ update();
+}
+
+void KColorButton::paintEvent( QPaintEvent* e )
+{
+ QPushButton::paintEvent(e);
+ QPainter p(this);
+
+ int w = width();
+ int h = height();
+ p.fillRect( 10, 5, w-20, h-10, m_color );
+ p.drawRect( 10, 5, w-20, h-10 );
+}
+
+void KColorButton::slotClicked()
+{
+ // Under Windows ChooseColor() should be used. (Nicer if few colors exist.)
+ QColor c = QColorDialog::getColor ( m_color, this );
+ if ( c.isValid() ) m_color = c;
+ update();
+}
+
+KPrinter::KPrinter()
+{
+}
+QValueList<int> KPrinter::pageList()
+{
+ QValueList<int> vl;
+ int to = toPage();
+ for(int i=fromPage(); i<=to; ++i)
+ {
+ vl.push_back(i);
+ }
+ return vl;
+}
+void KPrinter::setCurrentPage(int)
+{
+}
+void KPrinter::setPageSelection(e_PageSelection)
+{
+}
+
+
+QPixmap KIconLoader::loadIcon( const QString&, int )
+{
+ return QPixmap();
+}
+
+KAboutData::KAboutData( const QString& /*name*/, const QString& appName, const QString& version,
+ const QString& description, int,
+ const QString& copyright, int, const QString& homepage, const QString& email)
+{
+ s_copyright = copyright;
+ s_email = email;
+ s_appName = appName;
+ s_description = description;
+ s_version = version;
+ s_homepage = homepage;
+}
+
+KAboutData::KAboutData( const QString& /*name*/, const QString& /*appName*/, const QString& /*version*/ )
+{
+}
+
+void KAboutData::addAuthor(const char* name, const char* task, const char* email, const char* weblink)
+{
+ m_authorList.push_back( AboutDataEntry( name, task, email, weblink) );
+}
+
+void KAboutData::addCredit(const char* name, const char* task, const char* email, const char* weblink)
+{
+ m_creditList.push_back( AboutDataEntry( name, task, email, weblink) );
+}
+
+/* Option structure: e.g.:
+ { "m", 0, 0 },
+ { "merge", I18N_NOOP("Automatically merge the input."), 0 },
+ { "o", 0, 0 },
+ { "output file", I18N_NOOP("Output file. Implies -m. E.g.: -o newfile.txt"), 0 },
+ { "+[File1]", I18N_NOOP("file1 to open (base)"), 0 },
+ { "+[File2]", I18N_NOOP("file2 to open"), 0 },
+ { "+[File3]", I18N_NOOP("file3 to open"), 0 },
+*/
+////////////////
+static KCmdLineArgs s_cmdLineArgs;
+static int s_argc;
+static char** s_argv;
+static KCmdLineOptions* s_pOptions;
+
+static std::vector<QCStringList> s_vOption;
+static std::vector<const char*> s_vArg;
+
+KCmdLineArgs* KCmdLineArgs::parsedArgs() // static
+{
+ return &s_cmdLineArgs;
+}
+
+void KCmdLineArgs::init( int argc, char**argv, KAboutData* pAboutData ) // static
+{
+ s_argc = argc;
+ s_argv = argv;
+ s_pAboutData = pAboutData;
+}
+
+void KCmdLineArgs::addCmdLineOptions( KCmdLineOptions* options ) // static
+{
+ s_pOptions = options;
+}
+
+int KCmdLineArgs::count()
+{
+ return s_vArg.size();
+}
+
+QString KCmdLineArgs::arg(int idx)
+{
+ return QString::fromLocal8Bit( s_vArg[idx] );
+}
+
+void KCmdLineArgs::clear()
+{
+}
+
+QString KCmdLineArgs::getOption( const QString& s )
+{
+ // Find the option
+ int j=0;
+ for( j=0; j<(int)s_vOption.size(); ++j )
+ {
+ const char* optName = s_pOptions[j].name;
+ const char* pos = strchr( optName,' ' );
+ int len = pos==0 ? strlen( optName ) : pos - optName;
+
+ if( s == (const char*)( QCString( optName, len+1) ) )
+ {
+ return s_vOption[j].isEmpty() ? QString() : s_vOption[j].last();
+ }
+ }
+ assert(false);
+ return QString();
+}
+
+QCStringList KCmdLineArgs::getOptionList( const QString& s )
+{
+ // Find the option
+ int j=0;
+ for( j=0; j<(int)s_vOption.size(); ++j )
+ {
+ const char* optName = s_pOptions[j].name;
+ const char* pos = strchr( optName,' ' );
+ int len = pos==0 ? strlen( optName ) : pos - optName;
+
+ if( s == (const char*)( QCString( optName, len+1) ) )
+ {
+ return s_vOption[j];
+ }
+ }
+
+ assert(false);
+ return QCStringList();
+}
+
+bool KCmdLineArgs::isSet(const QString& s)
+{
+ // Find the option
+ int j=0;
+ for( j=0; j<(int)s_vOption.size(); ++j )
+ {
+ const char* optName = s_pOptions[j].name;
+ if( s == QString( optName ) )
+ {
+ return ! s_vOption[j].isEmpty();
+ }
+ }
+ assert(false);
+ return false;
+}
+
+///////////////////
+KApplication* kapp;
+
+KApplication::KApplication()
+: QApplication( s_argc,s_argv )
+{
+ kapp = this;
+
+ int nofOptions=0;
+ int nofArgs=0;
+ int i=0;
+ while( s_pOptions[i].name != 0 )
+ {
+ if ( s_pOptions[i].name[0]=='[' )
+ nofArgs++;
+ else
+ nofOptions++;
+
+ ++i;
+ }
+
+ // First find the option "-config" or "--config" to allow loading of options
+ QString configFileName;
+ for( i=1; i<s_argc-1; ++i )
+ {
+ QString arg = s_argv[i];
+ if ( arg == "-config" || arg == "--config" )
+ {
+ configFileName = s_argv[i+1];
+ }
+ }
+ m_config.readConfigFile(configFileName);
+
+ QStringList ignorableCmdLineOptionsList = m_config.readListEntry("IgnorableCmdLineOptions", QString("-u;-query;-html;-abort"), '|');
+ QString ignorableCmdLineOptions;
+ if ( !ignorableCmdLineOptionsList.isEmpty() )
+ ignorableCmdLineOptions = ignorableCmdLineOptionsList.front() + ";";
+
+ s_vOption.resize(nofOptions);
+
+ for( i=1; i<s_argc; ++i )
+ {
+ if ( s_argv[i][0]=='-' ) // An option
+ {
+ if ( ignorableCmdLineOptions.contains(QString(s_argv[i])+";") )
+ continue;
+ // Find the option
+ int j=0;
+ for( j=0; j<nofOptions; ++j )
+ {
+ const char* optName = s_pOptions[j].name;
+ const char* pos = strchr( optName,' ' );
+ int len = pos==0 ? strlen( optName ) : pos - optName;
+ int len2 = strlen(s_argv[i]);
+
+ if( len>0 && ( s_argv[i][1]=='-' && len2-2==len && memcmp( &s_argv[i][2], optName, len )==0 ||
+ len2-1==len && memcmp( &s_argv[i][1], optName, len )==0 ))
+ {
+ if (s_pOptions[j].description == 0) // alias, because without description.
+ {
+ ++j;
+ optName = s_pOptions[j].name;
+ pos = strchr( optName,' ' );
+ }
+ if (pos!=0){ ++i; s_vOption[j].append(s_argv[i]); } //use param
+ else { s_vOption[j].append("1"); } //set state
+ break;
+ }
+ }
+ if (j==nofOptions)
+ {
+ QString s;
+ s = QString("Unknown option: ") + s_argv[i] + "\n";
+ s += "If KDiff3 should ignore this option, run KDiff3 normally and edit\n"
+ "the \"Command line options to ignore\" in the \"Integration Settings\".\n\n";
+
+ s += "KDiff3-Usage when starting via commandline: \n";
+ s += "- Comparing 2 files:\t\tkdiff3 file1 file2\n";
+ s += "- Merging 2 files: \t\tkdiff3 file1 file2 -o outputfile\n";
+ s += "- Comparing 3 files:\t\tkdiff3 file1 file2 file3\n";
+ s += "- Merging 3 files: \t\tkdiff3 file1 file2 file3 -o outputfile\n";
+ s += " Note that file1 will be treated as base of file2 and file3.\n";
+ s += "\n";
+ s += "If you start without arguments, then a dialog will appear\n";
+ s += "where you can select your files via a filebrowser.\n";
+ s += "\n";
+
+ s += "Options:\n";
+
+ j=0;
+ int pos=s.length();
+ for( j=0; j<nofOptions; ++j )
+ {
+ if ( s_pOptions[j].description!=0 )
+ {
+ if (s_pOptions[j].name[0]!='+')
+ {
+ s += "-";
+ if ( strlen(s_pOptions[j].name)>1 ) s += "-";
+ }
+ s += s_pOptions[j].name;
+ s += QString().fill(' ', minMaxLimiter( 20 - ((int)s.length()-pos), 3, 20 ) );
+ s += s_pOptions[j].description;
+ s +="\n";
+ pos=s.length();
+ }
+ else
+ {
+ s += "-";
+ if ( strlen(s_pOptions[j].name)>1 ) s += "-";
+ s += s_pOptions[j].name;
+ s += ", ";
+ }
+ }
+
+ s += "\n"+i18n("For more documentation, see the help-menu or the subdirectory doc.")+"\n";
+#ifdef _WIN32
+ // A windows program has no console
+ if ( 0==QMessageBox::information(0, i18n("KDiff3-Usage"), s, i18n("Ignore"),i18n("Exit") ) )
+ continue;
+#else
+ std::cerr << s.latin1() << std::endl;
+#endif
+
+ ::exit(-1);
+ }
+ }
+ else
+ s_vArg.push_back( s_argv[i] );
+ }
+}
+
+KConfig* KApplication::config()
+{
+ return &m_config;
+}
+
+bool KApplication::isRestored()
+{
+ return false;
+}
+
+KApplication* KApplication::kApplication()
+{
+ return kapp;
+}
+
+KIconLoader* KApplication::iconLoader()
+{
+ return &m_iconLoader;
+}
+
+
+namespace KIO
+{
+ SimpleJob* mkdir( KURL ){return 0;}
+ SimpleJob* rmdir( KURL ){return 0;}
+ SimpleJob* file_delete( KURL, bool ){return 0;}
+ FileCopyJob* file_move( KURL, KURL, int, bool, bool, bool ) {return 0;}
+ FileCopyJob* file_copy( KURL, KURL, int, bool, bool, bool ) {return 0;}
+ CopyJob* link( KURL, KURL, bool ) {return 0;}
+ ListJob* listRecursive( KURL, bool, bool ){return 0;}
+ ListJob* listDir( KURL, bool, bool ){return 0;}
+ StatJob* stat( KURL, bool, int, bool ){return 0;}
+ TransferJob* get( KURL, bool, bool ){return (TransferJob*)0;}
+ TransferJob* put( KURL, int, bool, bool, bool ){return (TransferJob*)0;}
+};
+
+KActionCollection* KParts::Part::actionCollection()
+{
+ return 0;
+}
+
+KApplication* KParts::Part::instance()
+{
+ return kapp;
+}
+
+
+KLibLoader* KLibLoader::self()
+{
+ static KLibLoader ll;
+ return &ll;
+}
+
+extern "C" void* init_libkdiff3part();
+KLibFactory* KLibLoader::factory(QString const&)
+{
+ return (KLibFactory*) init_libkdiff3part();
+}
+
+QObject* KLibFactory::create(QObject* pParent, const QString& name, const QString& classname )
+{
+ KParts::Factory* f = dynamic_cast<KParts::Factory*>(this);
+ if (f!=0)
+ return f->createPartObject( (QWidget*)pParent, name.ascii(),
+ pParent, name.ascii(),
+ classname.ascii(), QStringList() );
+ else
+ return 0;
+}
+
+
+
+
+#include "kreplacements.moc"
diff --git a/src/kreplacements/kreplacements.h b/src/kreplacements/kreplacements.h
new file mode 100644
index 0000000..1402d51
--- /dev/null
+++ b/src/kreplacements/kreplacements.h
@@ -0,0 +1,505 @@
+/***************************************************************************
+ kreplacements.h - description
+ -------------------
+ begin : Sat Aug 3 2002
+ copyright : (C) 2002-2007 by Joachim Eibl
+ email : joachim.eibl at gmx.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef KREPLACEMENTS_H
+#define KREPLACEMENTS_H
+
+#include "common.h"
+
+#include <qobject.h>
+#include <qtabdialog.h>
+#include <qmainwindow.h>
+#include <qaction.h>
+#include <qfiledialog.h>
+#include <qapplication.h>
+#include <qvbox.h>
+#include <qpushbutton.h>
+#include <qstatusbar.h>
+#include <qtoolbar.h>
+#include <qprogressbar.h>
+#include <qpopupmenu.h>
+#include <qstringlist.h>
+#include <qprinter.h>
+
+#include <map>
+#include <list>
+
+QString getTranslationDir();
+
+class KMainWindow;
+
+class KURL
+{
+public:
+ KURL(){}
+ KURL(const QString& s){ m_s = s; }
+ static KURL fromPathOrURL( const QString& s ){ return KURL(s); }
+ QString url() const { return m_s; }
+ bool isEmpty() const { return m_s.isEmpty(); }
+ QString prettyURL() const { return m_s; }
+ bool isLocalFile() const { return true; }
+ bool isValid() const { return true; }
+ QString path() const { return m_s; }
+ void setPath( const QString& s ){ m_s=s; }
+ QString fileName() const { return m_s; } // not really needed
+ void addPath( const QString& s ){ m_s += "/" + s; }
+private:
+ QString m_s;
+};
+
+class KMessageBox
+{
+public:
+ static void error( QWidget* parent, const QString& text, const QString& caption=QString() );
+ static int warningContinueCancel( QWidget* parent, const QString& text, const QString& caption=QString(),
+ const QString& button1=QString("Continue") );
+ static void sorry( QWidget* parent, const QString& text, const QString& caption=QString() );
+ static void information( QWidget* parent, const QString& text, const QString& caption=QString() );
+ static int warningYesNo( QWidget* parent, const QString& text, const QString& caption,
+ const QString& button1, const QString& button2 );
+ static int warningYesNoCancel(
+ QWidget* parent, const QString& text, const QString& caption,
+ const QString& button1, const QString& button2 );
+
+ enum {Cancel=-1, No=0, Yes=1, Continue=1};
+};
+
+#define i18n(x) QObject::tr(x)
+#define I18N_NOOP(x) x
+#define RESTORE(x)
+#define _UNLOAD(x)
+
+typedef QPopupMenu KPopupMenu;
+
+class KDialogBase : public QTabDialog
+{
+ Q_OBJECT
+public:
+ KDialogBase( int, const QString& caption, int, int, QWidget* parent, const char* name,
+ bool /*modal*/, bool );
+ ~KDialogBase();
+
+ void incInitialSize ( const QSize& );
+ void setHelp(const QString& helpfilename, const QString& );
+ enum {IconList, Help, Default, Apply, Ok, Cancel };
+
+ int BarIcon(const QString& iconName, int );
+
+ QVBox* addVBoxPage( const QString& name, const QString& info, int );
+ QFrame* addPage( const QString& name, const QString& info, int );
+ int spacingHint();
+
+ virtual void accept();
+signals:
+ void applyClicked();
+
+protected slots:
+ virtual void slotOk( void );
+ virtual void slotApply( void );
+ virtual void slotHelp( void );
+ virtual void slotCancel( void );
+ virtual void slotDefault( void );
+};
+
+class KFileDialog : public QFileDialog
+{
+public:
+ static KURL getSaveURL( const QString &startDir=QString::null,
+ const QString &filter=QString::null,
+ QWidget *parent=0, const QString &caption=QString::null);
+ static KURL getOpenURL( const QString & startDir = QString::null,
+ const QString & filter = QString::null,
+ QWidget * parent = 0,
+ const QString & caption = QString::null );
+ static KURL getExistingURL( const QString & startDir = QString::null,
+ QWidget * parent = 0,
+ const QString & caption = QString::null );
+ static QString getSaveFileName (const QString &startDir=QString::null,
+ const QString &filter=QString::null,
+ QWidget *parent=0,
+ const QString &caption=QString::null);
+};
+
+typedef QStatusBar KStatusBar;
+
+class KToolBar : public QToolBar
+{
+public:
+ KToolBar(QMainWindow* parent);
+
+ enum BarPosition {Top, Bottom, Left, Right};
+ BarPosition barPos();
+ void setBarPos(BarPosition);
+private:
+ QMainWindow* m_pMainWindow;
+};
+
+class KActionCollection
+{
+public:
+ KMainWindow* m_pMainWindow;
+ KActionCollection( KMainWindow* p){ m_pMainWindow=p; }
+};
+
+class KKeyDialog
+{
+public:
+ static void configure(void*, QWidget*){}
+ static void configureKeys(KActionCollection*, const QString&){}
+ static void configure(KActionCollection*, const QString&){}
+};
+
+namespace KParts
+{
+ class ReadWritePart;
+}
+
+class KMainWindow : public QMainWindow
+{
+ Q_OBJECT
+private:
+ KStatusBar m_statusBar;
+ KActionCollection m_actionCollection;
+protected:
+ virtual bool queryClose() = 0;
+ virtual bool queryExit() = 0;
+public:
+ QPopupMenu* fileMenu;
+ QPopupMenu* editMenu;
+ QPopupMenu* directoryMenu;
+ QPopupMenu* dirCurrentItemMenu;
+ QPopupMenu* dirCurrentSyncItemMenu;
+ QPopupMenu* movementMenu;
+ QPopupMenu* mergeMenu;
+ QPopupMenu* diffMenu;
+ QPopupMenu* windowsMenu;
+ QPopupMenu* settingsMenu;
+ QPopupMenu* helpMenu;
+
+ KToolBar* m_pToolBar;
+
+ KMainWindow( QWidget* parent, const char* name );
+ KToolBar* toolBar(const QString& s = QString::null);
+ KActionCollection* actionCollection();
+ void createGUI();
+ void createGUI(KParts::ReadWritePart*){createGUI();}
+
+ QList<KMainWindow>* memberList;
+public slots:
+ void slotHelp();
+ void slotAbout();
+};
+
+class KConfig : public ValueMap
+{
+ QString m_fileName;
+public:
+ KConfig();
+ ~KConfig();
+ void readConfigFile(const QString& configFileName);
+
+ void setGroup(const QString&);
+};
+
+class KAction : public QAction
+{
+ Q_OBJECT
+public:
+ KAction(const QString& text, const QIconSet& icon, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bToggle=false, bool bMenu=true);
+ KAction(const QString& text, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bToggle=false, bool bMenu=true);
+ void init(QObject* receiver, const char* slot, KActionCollection* actionCollection,
+ const char* name, bool bToggle, bool bMenu);
+ void setStatusText(const QString&);
+ void plug(QPopupMenu*);
+};
+
+class KToggleAction : public KAction
+{
+public:
+ KToggleAction(const QString& text, const QIconSet& icon, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu=true);
+ KToggleAction(const QString& text, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu=true);
+ KToggleAction(const QString& text, const QIconSet& icon, int accel, KActionCollection* actionCollection, const char* name, bool bMenu=true);
+ void setChecked(bool);
+ bool isChecked();
+};
+
+
+class KStdAction
+{
+public:
+ static KAction* open( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* save( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* saveAs( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* print( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* quit( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* cut( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* copy( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* paste( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* selectAll( QWidget* parent, const char* slot, KActionCollection* );
+ static KToggleAction* showToolbar( QWidget* parent, const char* slot, KActionCollection* );
+ static KToggleAction* showStatusbar( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* preferences( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* about( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* aboutQt( KActionCollection* );
+ static KAction* help( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* find( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* findNext( QWidget* parent, const char* slot, KActionCollection* );
+ static KAction* keyBindings( QWidget* parent, const char* slot, KActionCollection* );
+};
+
+class KIcon
+{
+public:
+ enum {SizeMedium,Small};
+};
+
+class KFontChooser : public QWidget
+{
+ Q_OBJECT
+ QFont m_font;
+ QPushButton* m_pSelectFont;
+ QLabel* m_pLabel;
+ QWidget* m_pParent;
+public:
+ KFontChooser( QWidget* pParent, const QString& name, bool, const QStringList&, bool, int );
+ QFont font();
+ void setFont( const QFont&, bool );
+private slots:
+ void slotSelectFont();
+};
+
+class KColorButton : public QPushButton
+{
+ Q_OBJECT
+ QColor m_color;
+public:
+ KColorButton(QWidget* parent);
+ QColor color();
+ void setColor(const QColor&);
+ virtual void paintEvent(QPaintEvent* e);
+public slots:
+ void slotClicked();
+};
+
+class KPrinter : public QPrinter
+{
+public:
+ KPrinter();
+ enum e_PageSelection {ApplicationSide};
+ QValueList<int> pageList();
+ void setCurrentPage(int);
+ void setPageSelection(e_PageSelection);
+};
+
+class KStandardDirs
+{
+public:
+ QString findResource(const QString& resource, const QString& appName);
+};
+
+struct KCmdLineOptions
+{
+ const char* name;
+ const char* description;
+ int def;
+};
+
+#define KCmdLineLastOption {0,0,0}
+
+class KAboutData
+{
+public:
+ KAboutData( const QString& name, const QString& appName, const QString& version,
+ const QString& description, int licence,
+ const QString& copyright, int w, const QString& homepage, const QString& email);
+ KAboutData( const QString& name, const QString& appName, const QString& version );
+ void addAuthor(const char* name=0, const char* task=0, const char* email=0, const char* weblink=0);
+ void addCredit(const char* name=0, const char* task=0, const char* email=0, const char* weblink=0);
+ enum { License_GPL };
+
+ struct AboutDataEntry
+ {
+ AboutDataEntry(const QString& name, const QString& task, const QString& email, const QString& weblink)
+ : m_name(name), m_task(task), m_email(email), m_weblink(weblink)
+ {}
+ QString m_name;
+ QString m_task;
+ QString m_email;
+ QString m_weblink;
+ };
+
+ std::list<AboutDataEntry> m_authorList;
+ std::list<AboutDataEntry> m_creditList;
+};
+
+typedef QValueList<QCString> QCStringList;
+
+class KCmdLineArgs
+{
+public:
+ static KCmdLineArgs* parsedArgs();
+ static void init( int argc, char**argv, KAboutData* );
+ static void addCmdLineOptions( KCmdLineOptions* options ); // Add our own options.
+
+ int count();
+ QString arg(int);
+ KURL url(int i){ return KURL(arg(i)); }
+ void clear();
+ QString getOption(const QString&);
+ QCStringList getOptionList( const QString& );
+ bool isSet(const QString&);
+};
+
+class KIconLoader
+{
+public:
+ QPixmap loadIcon(const QString& name, int);
+};
+
+class KApplication : public QApplication
+{
+ KConfig m_config;
+ KIconLoader m_iconLoader;
+public:
+ KApplication();
+ static KApplication* kApplication();
+ KIconLoader* iconLoader();
+ KConfig* config();
+ bool isRestored();
+};
+
+extern KApplication* kapp;
+
+class KLibFactory : public QObject
+{
+ Q_OBJECT
+public:
+ QObject* create(QObject*,const QString&,const QString&);
+};
+
+class KLibLoader
+{
+public:
+ static KLibLoader* self();
+ KLibFactory* factory(const QString&);
+};
+
+class KEditToolbar : public QDialog
+{
+public:
+ KEditToolbar( int ){}
+};
+
+class KGlobal
+{
+public:
+ static KConfig* config() { return 0; }
+};
+
+namespace KIO
+{
+ enum UDSEntry {};
+ typedef QValueList<UDSEntry> UDSEntryList;
+ class Job : public QObject
+ {
+ public:
+ void kill(bool){}
+ bool error() {return false;}
+ void showErrorDialog( QWidget* ) {}
+ };
+ class SimpleJob : public Job {};
+ SimpleJob* mkdir( KURL );
+ SimpleJob* rmdir( KURL );
+ SimpleJob* file_delete( KURL, bool );
+ class FileCopyJob : public Job {};
+ FileCopyJob* file_move( KURL, KURL, int, bool, bool, bool );
+ FileCopyJob* file_copy( KURL, KURL, int, bool, bool, bool );
+ class CopyJob : public Job {};
+ CopyJob* link( KURL, KURL, bool );
+ class ListJob : public Job {};
+ ListJob* listRecursive( KURL, bool, bool );
+ ListJob* listDir( KURL, bool, bool );
+ class StatJob : public Job {
+ public: UDSEntry statResult(){ return (UDSEntry)0; }
+ };
+ StatJob* stat( KURL, bool, int, bool );
+ class TransferJob : public Job {};
+ TransferJob* get( KURL, bool, bool );
+ TransferJob* put( KURL, int, bool, bool, bool );
+};
+
+typedef QProgressBar KProgress;
+
+class KInstance : public QObject
+{
+public:
+ KInstance(KAboutData*){}
+};
+
+namespace KParts
+{
+ class MainWindow : public KMainWindow
+ {
+ public:
+ MainWindow( QWidget* parent, const char* name ) : KMainWindow(parent,name) {}
+ void setXMLFile(const QString&){}
+ void setAutoSaveSettings(){}
+ void saveMainWindowSettings(KConfig*){}
+ void applyMainWindowSettings(KConfig*){}
+ int factory(){return 0;}
+ };
+
+ class Part : public QObject
+ {
+ public:
+ KActionCollection* actionCollection();
+ KApplication* instance();
+ void setWidget( QWidget* w ){ m_pWidget=w; }
+ QWidget* widget(){return m_pWidget;}
+ void setXMLFile(const QString&){}
+ private:
+ QWidget* m_pWidget;
+ };
+
+ class ReadOnlyPart : public Part
+ {
+ public:
+ ReadOnlyPart(){}
+ ReadOnlyPart(QObject*,const QCString&){}
+ void setInstance( KInstance* ){}
+ QString m_file;
+ };
+
+ class ReadWritePart : public ReadOnlyPart
+ {
+ public:
+ ReadWritePart(QObject*,const QCString&){}
+ void setReadWrite(bool){}
+ };
+
+ class Factory : public KLibFactory
+ {
+ Q_OBJECT
+ public:
+ virtual KParts::Part* createPartObject( QWidget *parentWidget, const char *widgetName,
+ QObject *parent, const char *name,
+ const char *classname, const QStringList &args )=0;
+ };
+};
+#endif
+
+
diff --git a/src/kreplacements/kstandarddirs.h b/src/kreplacements/kstandarddirs.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kstandarddirs.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kstatusbar.h b/src/kreplacements/kstatusbar.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kstatusbar.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kstdaction.h b/src/kreplacements/kstdaction.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kstdaction.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/ktempfile.h b/src/kreplacements/ktempfile.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/ktempfile.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kunload.h b/src/kreplacements/kunload.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kunload.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kurl.h b/src/kreplacements/kurl.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kurl.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+
diff --git a/src/kreplacements/kurldrag.h b/src/kreplacements/kurldrag.h
new file mode 100644
index 0000000..53443ee
--- /dev/null
+++ b/src/kreplacements/kurldrag.h
@@ -0,0 +1,2 @@
+#include "kreplacements.h"
+