From e9ae80694875f869892f13f4fcaf1170a00dea41 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- quanta/dialogs/dirtydlg.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 quanta/dialogs/dirtydlg.cpp (limited to 'quanta/dialogs/dirtydlg.cpp') diff --git a/quanta/dialogs/dirtydlg.cpp b/quanta/dialogs/dirtydlg.cpp new file mode 100644 index 00000000..ad9e408b --- /dev/null +++ b/quanta/dialogs/dirtydlg.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** + dirtydlg.cpp - description + ------------------- + begin : Fri Sep 13 2002 + copyright : (C) 2002, 2003 by Andras Mantia + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +//qt includes +#include +#include +#include +#include + +//kde includes +#include +#include +#include +#include +#include +#include +#include + +//app includes +#include "dirtydialog.h" +#include "dirtydlg.h" +#include "resource.h" +#include "qextfileinfo.h" + +DirtyDlg::DirtyDlg(const QString& srcName, const QString& destName, bool createBackup, QWidget *parent, const char *name ) : KDialogBase(parent, name, true, i18n("File Changed"), KDialogBase::Ok) +{ + m_src.setPath(srcName); + m_dest.setPath(destName); + m_busy = false; + m_createBackup = createBackup; + m_mainWidget = new DirtyDialog(this); + m_mainWidget->textLabel->setText(i18n("The file %1 was changed outside of the Quanta editor.").arg(srcName)); + setMainWidget(m_mainWidget); +} + +DirtyDlg::~DirtyDlg(){ +} +/** No descriptions */ +void DirtyDlg::slotOk() +{ + if (m_mainWidget->buttonCompare->isChecked()) + { + m_busy = true; + KProcess *proc = new KProcess(); + *proc << "kompare" << m_src.path() << m_dest.path(); + proc->start(); + connect(proc, SIGNAL(processExited(KProcess*)),SLOT(slotCompareDone(KProcess*))); + enableButton(KDialogBase::Ok, false); + enableButton(KDialogBase::Cancel, false); + } else + if (m_mainWidget->buttonLoad->isChecked()) + { + accept(); + } else + { + reject(); + } +} + +/** No descriptions */ +void DirtyDlg::slotCompareDone(KProcess* proc) +{ + delete proc; + + if (m_createBackup) + { + KURL backupURL = m_src; + backupURL.setPath(backupURL.path()+".backup"); + QExtFileInfo::copy(m_src, backupURL, -1, true, false, this); + } + + KIO::UDSEntry entry; + KIO::NetAccess::stat(m_src, entry, this); + KFileItem item(entry, m_src, false, true); + m_permissions = item.permissions(); + //TODO: Replace with KIO::NetAccess::file_move, when KDE 3.1 support + //is dropped + KIO::FileCopyJob *job = KIO::file_move(m_dest, m_src, m_permissions, true, false,false ); + connect( job, SIGNAL(result( KIO::Job *)), + SLOT (slotResult( KIO::Job *))); +} + + +/** No descriptions */ +void DirtyDlg::slotResult(KIO::Job *) +{ + m_busy = false; + accept(); +} + +/** No descriptions */ +void DirtyDlg::closeEvent(QCloseEvent* ev) +{ + if (m_busy) + ev->ignore(); + else + ev->accept(); +} + +#include "dirtydlg.moc" -- cgit v1.2.3