Commit 8e0c64e1 authored by Jeremy Whiting's avatar Jeremy Whiting

Remove kdelibs4support.

Change KUrl to QUrl.
Use QLayout/QFrame instead of KVBox.
Use QFileDialog instead of KFileDialog.
Add utility method for generating QUrl from strings.
REVIEW:120627
parent b3f4727e
......@@ -13,10 +13,15 @@ include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings)
include(ECMInstallIcons)
include(GenerateExportHeader)
find_package(KF5 REQUIRED COMPONENTS
CoreAddons
Codecs
DocTools
KDELibs4Support
IconThemes
JobWidgets
Config
Parts
TextEditor
WidgetsAddons
......
<?xml version="1.0" ?>
<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [
<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdedbx45.dtd" [
<!ENTITY kappname "&kompare;">
<!ENTITY version "4.4.0">
<!ENTITY package "kdesdk">
......
......@@ -25,7 +25,7 @@
#include <kdemacros.h>
class KConfig;
class KUrl;
class QUrl;
class KompareInterfacePrivate;
......@@ -43,7 +43,7 @@ public:
/**
* Open and parse the diff file at url.
*/
virtual bool openDiff( const KUrl& diffUrl ) = 0;
virtual bool openDiff( const QUrl& diffUrl ) = 0;
/**
* Open and parse the supplied diff output
......@@ -53,7 +53,7 @@ public:
/**
* Open and parse the diff3 file at url.
*/
virtual bool openDiff3( const KUrl& diff3Url ) = 0;
virtual bool openDiff3( const QUrl& diff3Url ) = 0;
/**
* Open and parse the supplied diff3 output
......@@ -66,42 +66,42 @@ public:
* they are (directory, file, diff output file) and call the
* appropriate method(s)
*/
virtual void compare( const KUrl& sourceFile, const KUrl& destinationFile ) = 0;
virtual void compare( const QUrl& sourceFile, const QUrl& destinationFile ) = 0;
/**
* Compare a Source file to a custom Destination string
*/
virtual void compareFileString( const KUrl & sourceFile, const QString & destination) = 0;
virtual void compareFileString( const QUrl & sourceFile, const QString & destination) = 0;
/**
* Compare a custom Source string to a Destination file
*/
virtual void compareStringFile( const QString & source, const KUrl & destinationFile) = 0;
virtual void compareStringFile( const QString & source, const QUrl & destinationFile) = 0;
/**
* Compare, with diff, source with destination files
*/
virtual void compareFiles( const KUrl& sourceFile, const KUrl& destinationFile ) = 0;
virtual void compareFiles( const QUrl& sourceFile, const QUrl& destinationFile ) = 0;
/**
* Compare, with diff, source with destination directories
*/
virtual void compareDirs ( const KUrl& sourceDir, const KUrl& destinationDir ) = 0;
virtual void compareDirs ( const QUrl& sourceDir, const QUrl& destinationDir ) = 0;
/**
* Compare, with diff3, originalFile with changedFile1 and changedFile2
*/
virtual void compare3Files( const KUrl& originalFile, const KUrl& changedFile1, const KUrl& changedFile2 ) = 0;
virtual void compare3Files( const QUrl& originalFile, const QUrl& changedFile1, const QUrl& changedFile2 ) = 0;
/**
* This will show the file and the file with the diff applied
*/
virtual void openFileAndDiff( const KUrl& file, const KUrl& diffFile ) = 0;
virtual void openFileAndDiff( const QUrl& file, const QUrl& diffFile ) = 0;
/**
* This will show the directory and the directory with the diff applied
*/
virtual void openDirAndDiff ( const KUrl& dir, const KUrl& diffFile ) = 0;
virtual void openDirAndDiff ( const QUrl& dir, const QUrl& diffFile ) = 0;
/**
* This will set the encoding to use for all files that are read or for the diffoutput
......
......@@ -23,21 +23,20 @@
#include <QFileDialog>
#include <QMimeDatabase>
#include <QPushButton>
#include <QStatusBar>
#include <ktexteditor/document.h>
#include <ktexteditor/view.h>
#include <kedittoolbar.h>
#include <kencodingfiledialog.h>
#include <kfile.h>
#include <kshortcutsdialog.h>
#include <klibloader.h>
#include <klocale.h>
#include <klocalizedstring.h>
#include <kmessagebox.h>
#include <ksqueezedtextlabel.h>
#include <kstatusbar.h>
#include <kstandardaction.h>
#include <kmimetypetrader.h>
#include <kservicetypetrader.h>
#include <ksharedconfig.h>
#include <ktoggleaction.h>
#include <kactioncollection.h>
#include <kconfiggroup.h>
......@@ -163,9 +162,9 @@ bool KompareShell::queryClose()
return rv;
}
void KompareShell::openDiff(const KUrl& url)
void KompareShell::openDiff(const QUrl& url)
{
qCDebug(KOMPARESHELL) << "Url = " << url.prettyUrl() ;
qCDebug(KOMPARESHELL) << "Url = " << url.toString( QUrl::RemovePassword );
m_diffURL = url;
viewPart()->openDiff( url );
}
......@@ -185,7 +184,7 @@ void KompareShell::openStdin()
}
void KompareShell::compare(const KUrl& source,const KUrl& destination )
void KompareShell::compare(const QUrl& source,const QUrl& destination )
{
m_sourceURL = source;
m_destinationURL = destination;
......@@ -193,7 +192,7 @@ void KompareShell::compare(const KUrl& source,const KUrl& destination )
viewPart()->compare( source, destination );
}
void KompareShell::blend( const KUrl& url1, const KUrl& diff )
void KompareShell::blend( const QUrl& url1, const QUrl& diff )
{
m_sourceURL = url1;
m_destinationURL = diff;
......@@ -325,7 +324,7 @@ void KompareShell::readProperties(const KConfigGroup &config)
void KompareShell::slotFileOpen()
{
// FIXME: use different filedialog which gets encoding
KUrl url = QFileDialog::getOpenFileUrl( this, QString(), QUrl(), QMimeDatabase().mimeTypeForName("text/x-patch").filterString() );
QUrl url = QFileDialog::getOpenFileUrl( this, QString(), QUrl(), QMimeDatabase().mimeTypeForName("text/x-patch").filterString() );
if( !url.isEmpty() ) {
KompareShell* shell = new KompareShell();
shell->show();
......@@ -458,7 +457,7 @@ void KompareShell::optionsConfigureKeys()
void KompareShell::optionsConfigureToolbars()
{
KConfigGroup group(KGlobal::config(), autoSaveGroup());
KConfigGroup group(KSharedConfig::openConfig(), autoSaveGroup());
saveMainWindowSettings(group);
// use the standard toolbar editor
KEditToolBar dlg(factory());
......@@ -468,7 +467,7 @@ void KompareShell::optionsConfigureToolbars()
void KompareShell::newToolbarConfig()
{
KConfigGroup group(KGlobal::config(), autoSaveGroup());
KConfigGroup group(KSharedConfig::openConfig(), autoSaveGroup());
applyMainWindowSettings(group);
}
......
......@@ -19,8 +19,6 @@
#ifndef KOMPARESHELL_H
#define KOMPARESHELL_H
#include <kapplication.h>
#include <kurl.h>
#include <kparts/mainwindow.h>
#include <kompare.h>
......@@ -75,7 +73,7 @@ public:
/**
* Use this method to load whatever file/URL you have
*/
void openDiff( const KUrl& url );
void openDiff( const QUrl& url );
/**
* Use this method to load the diff from stdin
......@@ -85,12 +83,12 @@ public:
/**
* Use this method to compare 2 URLs (files or directories)
*/
void compare( const KUrl& source, const KUrl& destination );
void compare( const QUrl& source, const QUrl& destination );
/**
* Use this method to blend diff into url1 (file or directory)
*/
void blend( const KUrl& url1, const KUrl& diff );
void blend( const QUrl& url1, const QUrl& diff );
public slots:
void slotUpdateStatusBar( int modelIndex, int differenceIndex, int modelCount, int differenceCount, int appliedCount );
......@@ -132,9 +130,9 @@ private:
void setupStatusBar();
private:
KUrl m_sourceURL;
KUrl m_destinationURL;
KUrl m_diffURL;
QUrl m_sourceURL;
QUrl m_destinationURL;
QUrl m_diffURL;
KParts::ReadWritePart* m_viewPart;
KParts::ReadOnlyPart* m_navTreePart;
......
......@@ -13,8 +13,8 @@ add_library(komparenavtreepart MODULE ${komparenavtreepart_PART_SRCS})
target_link_libraries(komparenavtreepart
Qt5::Widgets
KF5::KDELibs4Support
KF5::Parts
KF5::IconThemes
${LIBKOMPAREDIFF2_LIBRARIES}
)
......
......@@ -22,11 +22,10 @@
#include <QTreeWidgetItemIterator>
#include <klocale.h>
#include <kiconloader.h>
#include <kmimetype.h>
#include <k4aboutdata.h>
#include <kaboutdata.h>
#include <kcomponentdata.h>
#include <kpluginfactory.h>
#include <kiconloader.h>
#include <difference.h>
#include <diffmodel.h>
......@@ -766,11 +765,11 @@ KDirLVI::~KDirLVI()
m_modelList.clear();
}
static K4AboutData aboutData()
static KAboutData aboutData()
{
K4AboutData about("komparenavtreepart", 0, ki18n("KompareNavTreePart"), "1.2");
about.addAuthor(ki18n("John Firebaugh"), ki18n("Author"), "jfirebaugh@kde.org");
about.addAuthor(ki18n("Otto Bruggeman"), ki18n("Author"), "bruggie@gmail.com" );
KAboutData about("komparenavtreepart", i18n("KompareNavTreePart"), "1.2");
about.addAuthor(i18n("John Firebaugh"), i18n("Author"), "jfirebaugh@kde.org");
about.addAuthor(i18n("Otto Bruggeman"), i18n("Author"), "bruggie@gmail.com" );
return about;
}
......
......@@ -26,6 +26,9 @@ target_link_libraries(komparepart
${LIBKOMPAREDIFF2_LIBRARIES}
kompareinterface
KF5::ConfigWidgets
KF5::CoreAddons
KF5::JobWidgets
Qt5::PrintSupport
)
install(TARGETS komparepart DESTINATION ${PLUGIN_INSTALL_DIR} )
......
......@@ -20,31 +20,30 @@
#include "kompare_part.h"
#include <QDialog>
#include <QLayout>
#include <QWidget>
#include <QPainter>
#include <QPrinter>
#include <QPrintDialog>
#include <QPrintPreviewDialog>
#include <QTemporaryDir>
#include <QTemporaryFile>
#include <k4aboutdata.h>
#include <kaction.h>
#include <kaboutdata.h>
#include <kactioncollection.h>
#include <kapplication.h>
#include <kcomponentdata.h>
#include <kdeprintdialog.h>
#include <kdialog.h>
#include <kfiledialog.h>
#include <klocale.h>
#include <kjobwidgets.h>
#include <klocalizedstring.h>
#include <kmessagebox.h>
#include <kpluginfactory.h>
#include <kstandardaction.h>
#include <kstandarddirs.h>
#include <kstandardshortcut.h>
#include <ktemporaryfile.h>
#include <ktempdir.h>
#include <kio/netaccess.h>
#include <kglobal.h>
#include <kio/copyjob.h>
#include <kio/statjob.h>
#include <kio/filecopyjob.h>
#include <kio/mkdirjob.h>
#include <diffmodel.h>
#include "komparelistview.h"
......@@ -59,7 +58,6 @@
Q_LOGGING_CATEGORY(KOMPAREPART, "komparepart")
K_PLUGIN_FACTORY( KomparePartFactory, registerPlugin<KomparePart>(); )
K_EXPORT_PLUGIN( KomparePartFactory )
ViewSettings* KomparePart::m_viewSettings = 0L;
DiffSettings* KomparePart::m_diffSettings = 0L;
......@@ -76,7 +74,7 @@ KomparePart::KomparePart( QWidget *parentWidget, QObject *parent, const QVariant
m_diffSettings = new DiffSettings( 0 );
}
readProperties( KGlobal::config().data() );
readProperties( KSharedConfig::openConfig().data() );
m_view = new KompareView ( m_viewSettings, parentWidget );
setWidget( m_view );
......@@ -208,7 +206,7 @@ void KomparePart::setEncoding( const QString& encoding )
m_modelList->setEncoding( encoding );
}
bool KomparePart::openDiff( const KUrl& url )
bool KomparePart::openDiff( const QUrl& url )
{
qCDebug(KOMPAREPART) << "Url = " << url.url();
......@@ -254,7 +252,7 @@ bool KomparePart::openDiff( const QString& diffOutput )
return value;
}
bool KomparePart::openDiff3( const KUrl& diff3Url )
bool KomparePart::openDiff3( const QUrl& diff3Url )
{
// FIXME: Implement this !!!
qCDebug(KOMPAREPART) << "Not implemented yet. Filename is: " << diff3Url;
......@@ -275,63 +273,76 @@ bool KomparePart::exists( const QString& url )
return fi.exists();
}
bool KomparePart::fetchURL( const KUrl& url, bool addToSource )
bool KomparePart::fetchURL( const QUrl& url, bool addToSource )
{
// Default value if there is an error is "", we rely on it!
QString tempFileName( "" );
// Only in case of error do we set result to false, don't forget!!
bool result = true;
KTempDir* tmpDir = 0;
QTemporaryDir* tmpDir = 0;
if ( !url.isLocalFile() )
{
KIO::UDSEntry node;
KIO::NetAccess::stat( url, node, widget() );
if ( !node.isDir() )
{
if ( ! KIO::NetAccess::download( url, tempFileName, widget() ) )
{
slotShowError( i18n( "<qt>The URL <b>%1</b> cannot be downloaded.</qt>", url.toString(QUrl::RemovePassword) ) );
tempFileName = ""; // Not sure if download has already touched this tempFileName when there is an error
result = false;
}
}
else
{
tmpDir = new KTempDir(KStandardDirs::locateLocal("tmp", "kompare"));
tmpDir->setAutoRemove( true ); // Yes this is the default but just to make sure
if ( ! KIO::NetAccess::dircopy( url, KUrl( tmpDir->name() ), widget() ) )
{
slotShowError( i18n( "<qt>The URL <b>%1</b> cannot be downloaded.</qt>", url.toString(QUrl::RemovePassword) ) );
delete tmpDir;
tmpDir = 0;
result = false;
}
else
{
tempFileName = tmpDir->name();
qCDebug(KOMPAREPART) << "tempFileName = " << tempFileName;
// If a directory is copied into KTempDir then the directory in
// here is what I need to add to tempFileName
QDir dir( tempFileName );
QStringList entries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
if ( entries.size() == 1 ) // More than 1 entry in here means big problems!!!
{
if ( !tempFileName.endsWith( '/' ) )
tempFileName += '/';
tempFileName += entries.at( 0 );
tempFileName += '/';
}
else
{
qCDebug(KOMPAREPART) << "Yikes, nothing downloaded?";
delete tmpDir;
tmpDir = 0;
tempFileName = "";
result = false;
}
}
}
KIO::StatJob *statJob = KIO::stat( url );
KJobWidgets::setWindow( statJob, widget() );
if (statJob->exec() )
{
KIO::UDSEntry node;
node = statJob->statResult();
if ( !node.isDir() )
{
tmpDir = new QTemporaryDir(QDir::tempPath() + "/kompare");
tmpDir->setAutoRemove( true );
tempFileName = tmpDir->path() + QLatin1Char('/') + url.fileName();
KIO::FileCopyJob* copyJob = KIO::file_copy( url, QUrl::fromLocalFile( tempFileName ) );
KJobWidgets::setWindow( copyJob, widget() );
if ( ! copyJob->exec() )
{
qDebug() << "download error " << copyJob->errorString();
slotShowError( i18n( "<qt>The URL <b>%1</b> cannot be downloaded.</qt>", url.toString(QUrl::RemovePassword) ) );
tempFileName = ""; // Not sure if download has already touched this tempFileName when there is an error
result = false;
}
}
else
{
tmpDir = new QTemporaryDir(QDir::tempPath() + "/kompare");
tmpDir->setAutoRemove( true ); // Yes this is the default but just to make sure
KIO::CopyJob *copyJob = KIO::copy( url, QUrl::fromLocalFile( tmpDir->path() ));
KJobWidgets::setWindow( copyJob, widget() );
if ( ! copyJob->exec() )
{
slotShowError( i18n( "<qt>The URL <b>%1</b> cannot be downloaded.</qt>", url.toString(QUrl::RemovePassword) ) );
delete tmpDir;
tmpDir = 0;
result = false;
}
else
{
tempFileName = tmpDir->path();
qCDebug(KOMPAREPART) << "tempFileName = " << tempFileName;
// If a directory is copied into QTemporaryDir then the directory in
// here is what I need to add to tempFileName
QDir dir( tempFileName );
QStringList entries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
if ( entries.size() == 1 ) // More than 1 entry in here means big problems!!!
{
if ( !tempFileName.endsWith( '/' ) )
tempFileName += '/';
tempFileName += entries.at( 0 );
tempFileName += '/';
}
else
{
qCDebug(KOMPAREPART) << "Yikes, nothing downloaded?";
delete tmpDir;
tmpDir = 0;
tempFileName = "";
result = false;
}
}
}
}
}
else
{
......@@ -348,12 +359,12 @@ bool KomparePart::fetchURL( const KUrl& url, bool addToSource )
if ( addToSource )
{
m_info.localSource = tempFileName;
m_info.sourceKTempDir = tmpDir;
m_info.sourceQTempDir = tmpDir;
}
else
{
m_info.localDestination = tempFileName;
m_info.destinationKTempDir = tmpDir;
m_info.destinationQTempDir = tmpDir;
}
return result;
......@@ -364,34 +375,30 @@ void KomparePart::cleanUpTemporaryFiles()
qCDebug(KOMPAREPART) << "Cleaning temporary files.";
if ( !m_info.localSource.isEmpty() )
{
if ( m_info.sourceKTempDir == 0 )
KIO::NetAccess::removeTempFile( m_info.localSource );
else
if ( m_info.sourceQTempDir != 0 )
{
delete m_info.sourceKTempDir;
m_info.sourceKTempDir = 0;
delete m_info.sourceQTempDir;
m_info.sourceQTempDir = 0;
}
m_info.localSource = "";
}
if ( !m_info.localDestination.isEmpty() )
{
if ( m_info.destinationKTempDir == 0 )
KIO::NetAccess::removeTempFile( m_info.localDestination );
else
if ( m_info.destinationQTempDir != 0 )
{
delete m_info.destinationKTempDir;
m_info.destinationKTempDir = 0;
delete m_info.destinationQTempDir;
m_info.destinationQTempDir = 0;
}
m_info.localDestination = "";
}
}
void KomparePart::compare( const KUrl& source, const KUrl& destination )
void KomparePart::compare( const QUrl& source, const QUrl& destination )
{
// FIXME: This is silly, i can use NetAccess::stat to figure out what it is and not
// wait until i am in the modellist to determine the mode we're supposed to be in.
// That should make the code more readable
// I should store the KTempDir(s)/File(s) in the Info struct as well and delete it at the right time
// I should store the QTemporaryDir(s)/File(s) in the Info struct as well and delete it at the right time
m_info.source = source;
m_info.destination = destination;
......@@ -405,7 +412,7 @@ void KomparePart::compare( const KUrl& source, const KUrl& destination )
compareAndUpdateAll();
}
void KomparePart::compareFileString( const KUrl & sourceFile, const QString & destination)
void KomparePart::compareFileString( const QUrl & sourceFile, const QString & destination)
{
//Set the modeto specify that the source is a file, and the destination is a string
m_info.mode = Kompare::ComparingFileString;
......@@ -420,7 +427,7 @@ void KomparePart::compareFileString( const KUrl & sourceFile, const QString & de
compareAndUpdateAll();
}
void KomparePart::compareStringFile( const QString & source, const KUrl & destinationFile)
void KomparePart::compareStringFile( const QString & source, const QUrl & destinationFile)
{
//Set the modeto specify that the source is a file, and the destination is a string
m_info.mode = Kompare::ComparingStringFile;
......@@ -435,7 +442,7 @@ void KomparePart::compareStringFile( const QString & source, const KUrl & destin
compareAndUpdateAll();
}
void KomparePart::compareFiles( const KUrl& sourceFile, const KUrl& destinationFile )
void KomparePart::compareFiles( const QUrl& sourceFile, const QUrl& destinationFile )
{
m_info.mode = Kompare::ComparingFiles;
......@@ -452,7 +459,7 @@ void KomparePart::compareFiles( const KUrl& sourceFile, const KUrl& destinationF
compareAndUpdateAll();
}
void KomparePart::compareDirs( const KUrl& sourceDirectory, const KUrl& destinationDirectory )
void KomparePart::compareDirs( const QUrl& sourceDirectory, const QUrl& destinationDirectory )
{
m_info.mode = Kompare::ComparingDirs;
......@@ -467,7 +474,7 @@ void KomparePart::compareDirs( const KUrl& sourceDirectory, const KUrl& destinat
compareAndUpdateAll();
}
void KomparePart::compare3Files( const KUrl& /*originalFile*/, const KUrl& /*changedFile1*/, const KUrl& /*changedFile2*/ )
void KomparePart::compare3Files( const QUrl& /*originalFile*/, const QUrl& /*changedFile1*/, const QUrl& /*changedFile2*/ )
{
// FIXME: actually implement this some day :)
updateActions();
......@@ -475,7 +482,7 @@ void KomparePart::compare3Files( const KUrl& /*originalFile*/, const KUrl& /*cha
updateStatus();
}
void KomparePart::openFileAndDiff( const KUrl& file, const KUrl& diffFile )
void KomparePart::openFileAndDiff( const QUrl& file, const QUrl& diffFile )
{
m_info.source = file;
m_info.destination = diffFile;
......@@ -489,7 +496,7 @@ void KomparePart::openFileAndDiff( const KUrl& file, const KUrl& diffFile )
compareAndUpdateAll();
}
void KomparePart::openDirAndDiff ( const KUrl& dir, const KUrl& diffFile )
void KomparePart::openDirAndDiff ( const QUrl& dir, const QUrl& diffFile )
{
m_info.source = dir;
m_info.destination = diffFile;
......@@ -529,17 +536,18 @@ bool KomparePart::saveAll()
void KomparePart::saveDiff()
{
KDialog dlg( widget() );
QDialog dlg( widget() );
dlg.setObjectName( "save_options" );
dlg.setModal( true );
dlg.setWindowTitle( i18n("Diff Options") );
dlg.setButtons( KDialog::Ok|KDialog::Cancel );
QDialogButtonBox *buttons = new QDialogButtonBox( QDialogButtonBox::Save | QDialogButtonBox::Cancel, &dlg );
KompareSaveOptionsWidget* w = new KompareSaveOptionsWidget(
m_info.localSource,
m_info.localDestination,
m_diffSettings, &dlg );
dlg.setMainWidget( w );
dlg.setButtonGuiItem( KDialog::Ok, KStandardGuiItem::save() );