Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 624f1fee authored by Michael Reeves's avatar Michael Reeves

clean up headers, formatting, remove unneeded files.

# Conflicts:
#	src/main.cpp
parent 21ba753d
########### kdiff3 plugin ###############
find_package(LibKonq REQUIRED)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS KDELibs4Support Parts)
set(kdiff3plugin_SRCS
kdiff3plugin.cpp )
add_library(kdiff3plugin MODULE ${kdiff3plugin_SRCS})
target_link_libraries(kdiff3plugin KF5::KDELibs4Support KF5::Parts konq )
install(TARGETS kdiff3plugin DESTINATION ${KDE_INSTALL_PLUGINDIR} )
########## install files ###############
install( FILES kdiff3_plugin.desktop DESTINATION ${KDE_INSTALL_PLUGINDIR} )
#! /usr/bin/env bash
$XGETTEXT -kaliasLocal `find -name \*.cpp -o -name \*.h` -o $podir/kdiff3plugin.pot
[Desktop Entry]
Encoding=UTF-8
Type=Service
Name=Compare/Merge Files/Directories
Name[bg]=Сравняване/Сливане на файлове/директории
Name[bs]=Poredi/Spoji datoteke/Direktorije
Name[ca]=Compara/fusiona fitxers/directoris
Name[ca@valencia]=Compara/fusiona fitxers/directoris
Name[cs]=Porovnat/spojit soubory/adresáře
Name[da]=Sammenlign/sammenflet filer/mapper
Name[de]=Dateien und Ordner vergleichen und zusammenführen
Name[el]=Σύγκριση/Συγχώνευση αρχείων/καταλόγων
Name[en_GB]=Compare/Merge Files/Directories
Name[es]=Comparar/fusionar archivos/directorios
Name[et]=Failide/kataloogide võrdlemine/liitmine
Name[fr]=Comparaison / Fusion de fichiers / de dossiers
Name[ga]=Cuir Comhaid/Comhadlanna i gComparáid agus Cumaisc iad
Name[gl]=Comparar e fusionar ficheiros e cartafoles
Name[hi]=तुलना करें/मिलाएं फ़ाइलें/डिरेक्ट्रीज़
Name[hne]=फाइल/डिरेक्टरीज मन ल तुलना करव / मिलाव
Name[hu]=Fájlok/Könyvtárak összehasonlítása/egyesítése
Name[it]=Confronta o fondi file e cartelle
Name[ja]=ファイルやディレクトリを比較/マージ
Name[km]=ប្រៀបធៀប/បញ្ចូល​ឯកសារ​ចូល​គ្នា/ថត
Name[ko]=파일과 디렉터리를 비교하거나 병합
Name[ml]=ഫയലുകള്‍/അറകള്‍ താരതമ്യം ചെയ്യുക/ലയിപ്പിക്കുക
Name[nb]=Samenlikne/flette filer/mapper
Name[nds]=Verglieken/Tosamenföhren Dateien Ornern
Name[nl]=Bestanden/mappen vergelijken/samenvoegen
Name[nn]=Samanlikn/flett filer og mapper
Name[pl]=Porównanie/Łączenie plików i katalogów
Name[pt]=Comparar/Juntar os Ficheiros/Pastas
Name[pt_BR]=Comparar/Mesclar arquivos/pastas
Name[ro]=Compară/unește fișiere/directoare
Name[ru]=Сравнение и объединение файлов и каталогов
Name[sv]=Jämför, sammanfoga filer, kataloger
Name[tr]=Dosyaları/Klasörleri Karşılaştır/Birleştir
Name[uk]=Порівняння/З’єднання Файлів/Тек
Name[x-test]=xxCompare/Merge Files/Directoriesxx
Name[zh_CN]=比较/合并 文件/目录
Name[zh_TW]=比較/合併檔案與目錄
X-KDE-Library=libkdiff3plugin
ServiceTypes=KonqPopupMenu/Plugin,application/octet-stream,inode/directory
/* This file is part of the KDiff3 project
Copyright (C) 2008 Joachim Eibl <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; version 2
of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "kdiff3plugin.h"
#include <QApplication>
#include <kstandarddirs.h>
#include <QAction>
#include <kactionmenu.h>
#include <KLocalizedString>
#include <kgenericfactory.h>
#include <QUrl>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <konq_popupmenuinformation.h>
#include <kmessagebox.h>
#include <kprocess.h>
//#include <iostream>
static QStringList* s_pHistory=0;
class KDiff3PluginFactory : public KGenericFactory < KDiff3Plugin, KonqPopupMenu >
{
KConfig* m_pConfig;
KConfigGroup* m_pConfigGroup;
public:
KDiff3PluginFactory( const char* instanceName = 0 )
: KGenericFactory< KDiff3Plugin, KonqPopupMenu >( instanceName )
{
m_pConfig = 0;
if (s_pHistory==0)
{
//std::cout << "New History: " << instanceName << std::endl;
s_pHistory = new QStringList;
m_pConfig = new KConfig( "kdiff3pluginrc", KConfig::SimpleConfig );
m_pConfigGroup = new KConfigGroup( m_pConfig, "KDiff3Plugin" );
*s_pHistory = m_pConfigGroup->readEntry("HistoryStack", QStringList() );
}
}
~KDiff3PluginFactory()
{
//std::cout << "Delete History" << std::endl;
if ( s_pHistory && m_pConfigGroup )
m_pConfigGroup->writeEntry("HistoryStack",*s_pHistory);
delete s_pHistory;
delete m_pConfigGroup;
delete m_pConfig;
s_pHistory = 0;
m_pConfig = 0;
}
};
K_EXPORT_COMPONENT_FACTORY (libkdiff3plugin, KDiff3PluginFactory ("kdiff3plugin"))
KDiff3Plugin::KDiff3Plugin( KonqPopupMenu* pPopupMenu, const QStringList & /* list */ )
:KonqPopupMenuPlugin(pPopupMenu)
{
KLocalizedString::setApplicationDomain("kdiff3plugin");
m_pPopupMenu = pPopupMenu;
m_pParentWidget = pPopupMenu->parentWidget();
}
void KDiff3Plugin::setup( KActionCollection* actionCollection, const KonqPopupMenuInformation& popupMenuInfo, QMenu* pMenu )
{
if (KStandardDirs::findExe("kdiff3").isEmpty ())
return;
// remember currently selected files (copy to a QStringList)
KFileItemList itemList = popupMenuInfo.items();
foreach ( const KFileItem& item, itemList )
{
//m_urlList.append( item.url() );
m_list.append( item.url().url() );
}
/* Menu structure:
KDiff3 -> (1 File selected): Save 'selection' for later comparison (push onto history stack)
Compare 'selection' with first file on history stack.
Compare 'selection' with -> choice from history stack
Merge 'selection' with first file on history stack.
Merge 'selection' with last two files on history stack.
(2 Files selected): Compare 's1' with 's2'
Merge 's1' with 's2'
(3 Files selected): Compare 's1', 's2' and 's3'
*/
KActionMenu* pActionMenu = new KActionMenu (i18n ("KDiff3"), actionCollection );
QAction * pAction = 0;
QString s;
if(m_list.count() == 1)
{
int historyCount = s_pHistory ? s_pHistory->count() : 0;
s = i18n("Compare with %1", (historyCount>0 ? s_pHistory->front() : QString()) );
pAction = new QAction ( s, actionCollection );
connect(pAction, &QAction::triggered, this, &KDiff3Plugin::slotCompareWith);
pAction->setEnabled( m_list.count()>0 && historyCount>0 );
pActionMenu->addAction(pAction);
s = i18n("Merge with %1", historyCount>0 ? s_pHistory->front() : QString() );
pAction = new QAction( s, actionCollection);
connect(pAction, &QAction::triggered, this, &KDiff3Plugin::slotMergeWith);
pAction->setEnabled( m_list.count()>0 && historyCount>0 );
pActionMenu->addAction (pAction);
s = i18n("Save '%1' for later", ( m_list.front() ) );
pAction = new QAction ( s, actionCollection);
connect(pAction, &QAction::triggered, this, &KDiff3Plugin::slotSaveForLater);
pAction->setEnabled( m_list.count()>0 );
pActionMenu->addAction(pAction);
pAction = new QAction (i18n("3-way merge with base"), actionCollection);
connect(pAction, &QAction::triggered, this, &KDiff3Plugin::slotMergeThreeWay);
pAction->setEnabled( m_list.count()>0 && historyCount>=2 );
pActionMenu->addAction (pAction);
if ( s_pHistory && !s_pHistory->empty() )
{
KActionMenu* pHistoryMenu = new KActionMenu( i18n("Compare with ..."), actionCollection );
pHistoryMenu->setEnabled( m_list.count()>0 && historyCount>0 );
pActionMenu->addAction(pHistoryMenu);
for (QStringList::iterator i = s_pHistory->begin(); i!=s_pHistory->end(); ++i)
{
pAction = new QAction( *i, actionCollection);
connect(pAction, &QAction::triggered, this, &KDiff3Plugin::slotCompareWithHistoryItem);
pHistoryMenu->addAction (pAction);
}
pAction = new QAction (i18n("Clear list"), actionCollection);
connect(pAction, &QAction::triggered, this, &KDiff3Plugin::slotClearList);
pActionMenu->addAction (pAction);
pAction->setEnabled( historyCount>0 );
}
}
else if(m_list.count() == 2)
{
pAction = new QAction (i18n("Compare"), actionCollection);
connect(pAction, &QAction::triggered, this, &KDiff3Plugin::slotCompareTwoFiles);
pActionMenu->addAction (pAction);
}
else if ( m_list.count() == 3 )
{
pAction = new QAction (i18n("3 way comparison"), actionCollection);
connect(pAction, &QAction::triggered, this, &KDiff3Plugin::slotCompareThreeFiles);
pActionMenu->addAction (pAction);
}
pAction = new QAction (i18n("About KDiff3 menu plugin ..."), actionCollection);
connect(pAction, &QAction::triggered, this, &KDiff3Plugin::slotAbout);
pActionMenu->addAction (pAction);
pMenu->addSeparator();
pMenu->addAction( pActionMenu );
pMenu->addSeparator();
}
KDiff3Plugin::~KDiff3Plugin ()
{
}
void KDiff3Plugin::slotCompareWith()
{
if ( m_list.count() > 0 && s_pHistory && ! s_pHistory->empty() )
{
QStringList args;
args << s_pHistory->front();
args << m_list.front();
KProcess::startDetached("kdiff3", args);
}
}
void KDiff3Plugin::slotCompareWithHistoryItem()
{
const QAction * pAction = dynamic_cast<const QAction*>( sender() );
if ( m_list.count() > 0 && pAction )
{
QStringList args;
args << pAction->text();
args << m_list.front();
KProcess::startDetached ("kdiff3", args);
}
}
void KDiff3Plugin::slotCompareTwoFiles()
{
if ( m_list.count() == 2 )
{
QStringList args;
args << m_list.front();
args << m_list.back();
KProcess::startDetached ("kdiff3", args);
}
}
void KDiff3Plugin::slotCompareThreeFiles()
{
if ( m_list.count() == 3 )
{
QStringList args;
args << m_list[0];
args << m_list[1];
args << m_list[2];
KProcess::startDetached ("kdiff3", args);
}
}
void KDiff3Plugin::slotMergeWith()
{
if ( m_list.count() > 0 && s_pHistory && ! s_pHistory->empty() )
{
QStringList args;
args << s_pHistory->front();
args << m_list.front();
args << ( "-o" + m_list.front() );
KProcess::startDetached ("kdiff3", args);
}
}
void KDiff3Plugin::slotMergeThreeWay()
{
if ( m_list.count() > 0 && s_pHistory && s_pHistory->count()>=2 )
{
QStringList args;
args << (*s_pHistory)[1];
args << (*s_pHistory)[0];
args << m_list.front();
args << ("-o" + m_list.front());
KProcess::startDetached ("kdiff3", args);
}
}
void KDiff3Plugin::slotSaveForLater()
{
if ( !m_list.isEmpty() && s_pHistory )
{
while ( s_pHistory->count()>=10 )
s_pHistory->pop_back();
s_pHistory->push_front( m_list.front() );
}
}
void KDiff3Plugin::slotClearList()
{
if ( s_pHistory )
s_pHistory->clear();
}
void KDiff3Plugin::slotAbout()
{
QString s = i18n("KDiff3 Menu Plugin: Copyright (C) 2008 Joachim Eibl\n"
"KDiff3 homepage: http://kdiff3.sourceforge.net\n\n");
s += i18n("Using the context menu extension:\n"
"For simple comparison of two selected files choose \"Compare\".\n"
"If the other file is somewhere else, \"Save\" the first file for later, "
"and it will appear in the \"Compare With ...\" submenu. "
"Then, use \"Compare With\" on the second file.\n"
"For a 3-way merge first, \"Save\" the base file, then the branch to merge, and "
"then \"3-way merge with base\" on the other branch which will be used as the destination.\n"
"The same also applies to directory comparison and merge.");
KMessageBox::information(m_pParentWidget, s, i18n("About KDiff3 Menu Plugin") );
}
[Desktop Entry]
Encoding=UTF-8
Type=Service
Name=Compare/Merge Files/Directories with KDiff3
Name[bg]=Сравняване/Сливане на файлове/директории с KDiff3
Name[bs]=Poredi/Spoji datoteke/Direktorije sa KDiff3
Name[ca]=Compara/fusiona fitxers/directoris amb KDiff3
Name[ca@valencia]=Compara/fusiona fitxers/directoris amb KDiff3
Name[cs]=Porovnat/spojit soubory/adresáře pomocí KDiff3
Name[da]=Sammenlign/sammenflet filer/mapper med KDiff3
Name[de]=Dateien und Ordner vergleichen und zusammenführen mit KDiff3
Name[el]=Σύγκριση/Συγχώνευση αρχείων/καταλόγων με το KDiff3
Name[en_GB]=Compare/Merge Files/Directories with KDiff3
Name[es]=Comparar/fusionar archivos/directorios con KDiff3
Name[et]=Failide/kataloogide võrdlemine/liitmine KDiff3-ga
Name[fr]=Comparaison / Fusion de fichiers / de dossiers à l'aide de KDiff3
Name[ga]=Cuir Comhaid/Comhadlanna i gComparáid agus Cumaisc iad le KDiff3
Name[gl]=Compara e fusionar ficheiros e cartafoles con KDiff3
Name[hi]=केडिफ़३ के साथ तुलना करें/मिलाएं फ़ाइलें/डिरेक्ट्रीज़
Name[hne]=केडिफ३ के साथ तुलना करव/मिलाव फाइल/डिरेक्टरीज मन ल
Name[hu]=Fájlok/Könyvtárat KDiff3-mal való összehasonlítása/egyesítése
Name[it]=Confronta o fondi file e cartelle con KDiff3
Name[ja]=KDiff3 でファイルやディレクトリを比較/マージ
Name[km]=ប្រៀបធៀប/បញ្ចូល​ឯកសារ​ចូល​គ្នា/ថត​ជាមួយ KDiff3
Name[ko]=KDiff3으로 파일과 디렉터리를 비교하거나 병합합니다
Name[ml]=ഫയലുകള്‍/അറകള്‍ താരതമ്യം ചെയ്യുക/കെഡിഫ്3 ഉപയോഗിച്ചു് ലയിപ്പിക്കുക
Name[nb]=Samenlikne/flette filer/mapper med KDiff3
Name[nds]=Verglieken Tosamenföhren vun Dateien/Ornern mit KDiff3
Name[nl]=Bestanden/mappen vergelijken/samenvoegen met KDiff3
Name[nn]=Samanlikn/flett filer og mapper med KDiff3
Name[pl]=Porównaj/Scal pliki/katalogi przy pomocy KDiff3
Name[pt]=Comparar/Juntar os Ficheiros/Pastas com o KDiff3
Name[pt_BR]=Comparar/Mesclar arquivos/pastas com o KDiff3
Name[ro]=Compară/unește fișiere/directoare cu KDiff3
Name[ru]=Сравнение и объединение файлов и каталогов в KDiff3
Name[sv]=Jämför, sammanfoga filer, kataloger med Kdiff3
Name[tr]=KDiff3 ile Dosyaları/Klasörleri Karşılaştır/Birleştir
Name[uk]=Порівнюйте або з’єднуйте файли або теки з KDiff3
Name[x-test]=xxCompare/Merge Files/Directories with KDiff3xx
Name[zh_CN]=使用 KDiff3 比较/合并 文件/目录
Name[zh_TW]=用 KDiff3 比較/合併檔案與目錄
Icon=kdiff3
#X-KDE-ParentApp=konqueror
#DocPath=konq-plugins/kdiff3plugin/index.html
NoDisplay=true
/* This file is part of the KDiff3 project
Copyright (C) 2008 Joachim Eibl <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; version 2
of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef _KDIFF3PLUGIN_H_
#define _KDIFF3PLUGIN_H_
#include <konq_popupmenu.h>
#include <konq_popupmenuplugin.h>
#include <QStringList>
class QStringList;
class KDiff3Plugin : public KonqPopupMenuPlugin
{
Q_OBJECT
public:
KDiff3Plugin (KonqPopupMenu *, const QStringList & list);
virtual ~KDiff3Plugin();
// implement pure virtual method from KonqPopupMenuPlugin
virtual void setup( KActionCollection* actionCollection, const KonqPopupMenuInformation& popupMenuInfo, QMenu* menu );
private Q_SLOTS:
void slotCompareWith();
void slotCompareTwoFiles();
void slotCompareThreeFiles();
void slotMergeWith();
void slotMergeThreeWay();
void slotSaveForLater();
void slotClearList();
void slotCompareWithHistoryItem();
void slotAbout();
private:
QStringList m_list;
QWidget* m_pParentWidget;
KonqPopupMenu* m_pPopupMenu;
};
#endif
......@@ -18,9 +18,10 @@
#ifndef _COMMON_H
#define _COMMON_H
#include <assert.h>
#include <QAtomicInt>
#include <QString>
#include <assert.h>
#include <map>
template< class T >
T min2( T x, T y )
......@@ -37,7 +38,6 @@ typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
template <class T>
T min3( T d1, T d2, T d3 )
{
......@@ -76,8 +76,6 @@ inline int getAtomic(QAtomicInt& ai)
#endif
}
#include <map>
#include <QString>
class QFont;
class QColor;
class QSize;
......
......@@ -14,7 +14,9 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include "stable.h"
#ifdef _WIN32
#include <qt_windows.h>
#endif
#include <cstdlib>
......
......@@ -842,7 +842,8 @@ void DiffTextWindowData::prepareTextLayout(QTextLayout& textLayout, bool /*bFirs
textWidth = m_pDiffTextWindow->width() - xOffset;
int indentation = 0;
while(1) {
while(1)
{
QTextLine line = textLayout.createLine();
if(!line.isValid())
break;
......
......@@ -14,7 +14,10 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include "stable.h"
#ifdef _WIN32
#include <qt_windows.h>
#endif
#include "directorymergewindow.h"
#include "options.h"
#include "progress.h"
......
......@@ -19,7 +19,7 @@
//
//////////////////////////////////////////////////////////////////////
#ifdef _WIN32
#include "stable.h"
#include <qt_windows.h>
#include <windows.h>
......@@ -31,11 +31,12 @@
#include <shlobj.h>
#include <shlguid.h>
#include <malloc.h>
//#include <QString>
//#include <QStringList>
//#include <qwidget.h>
//#include <QDir>
//#include <QMenu>
#include <QString>
#include <QStringList>
#include <qwidget.h>
#include <QDir>
#include <QMenu>
#include "ShellContextMenu.h"
#ifdef _DEBUG
......
This diff is collapsed.
......@@ -14,7 +14,13 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include "stable.h"
#include <QtCore>
#include <QtGui>
#include <QtWidgets/QtWidgets>
#ifdef _WIN32
#include <qt_windows.h>
#endif
#include "difftextwindow.h"
#include "mergeresultwindow.h"
......
#include "stable.h"
......@@ -2,9 +2,7 @@
#define STABLE_H
#include <QtCore>
#include <QtGui>
#if QT_VERSION>=0x050000
#include <QtWidgets/QtWidgets>
#endif
#ifdef _WIN32
#include <qt_windows.h>
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment