KDE/kdesdk/kompare
Kevin Kofler
kevin.kofler at chello.at
Tue Oct 14 03:19:25 CEST 2008
SVN commit 871152 by kkofler:
Kompare: Finally add support for refreshing diffs to the trunk. (Though it was possible to get that effect with the "swap and swap back" hack which I got all too accustomed to. ;-) ) Partly based on revision 418173 by jkeel from 3_way_kompare, also incorporates my followup (revision 871142), the actual implementation of the refreshing reimplemented to work in trunk.
CCMAIL: kompare-devel at kde.org
BUG: 73197
M +31 -1 komparepart/kompare_part.cpp
M +3 -1 komparepart/kompare_part.h
M +1 -0 komparepart/komparepartui.rc
M +10 -0 libdiff2/komparemodellist.cpp
M +2 -1 libdiff2/komparemodellist.h
--- trunk/KDE/kdesdk/kompare/komparepart/kompare_part.cpp #871151:871152
@@ -5,7 +5,7 @@
Copyright 2001-2004 Otto Bruggeman <otto.bruggeman at home.nl>
Copyright 2001-2003 John Firebaugh <jfirebaugh at kde.org>
Copyright 2004 Jeff Snyder <jeff at caffeinated.me.uk>
- Copyright 2007 Kevin Kofler <kevin.kofler at chello.at>
+ Copyright 2007-2008 Kevin Kofler <kevin.kofler at chello.at>
****************************************************************************/
/***************************************************************************
@@ -30,6 +30,7 @@
#include <klocale.h>
#include <kmessagebox.h>
#include <kstandardaction.h>
+#include <kstandardshortcut.h>
#include <kcomponentdata.h>
#include <ktemporaryfile.h>
#include <kparts/genericfactory.h>
@@ -169,6 +170,10 @@
m_swap->setText(i18n("Swap Source with Destination"));
m_diffStats = actionCollection()->addAction("file_diffstats", this, SLOT(slotShowDiffstats()));
m_diffStats->setText(i18n("Show Statistics"));
+ m_diffRefresh = actionCollection()->addAction("file_refreshdiff", this, SLOT(slotRefreshDiff()));
+ m_diffRefresh->setIcon(KIcon("reload"));
+ m_diffRefresh->setText(i18n("Refresh Diff"));
+ m_diffRefresh->setShortcut(KStandardShortcut::reload());
KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
}
@@ -178,6 +183,7 @@
m_saveAll->setEnabled ( m_modelList->isModified() );
m_saveDiff->setEnabled ( m_modelList->mode() == Kompare::ComparingFiles || m_modelList->mode() == Kompare::ComparingDirs );
m_swap->setEnabled ( m_modelList->mode() == Kompare::ComparingFiles || m_modelList->mode() == Kompare::ComparingDirs );
+ m_diffRefresh->setEnabled( m_modelList->mode() == Kompare::ComparingFiles || m_modelList->mode() == Kompare::ComparingDirs );
m_diffStats->setEnabled( m_modelList->modelCount() > 0 );
}
@@ -610,6 +616,30 @@
m_modelList->swap();
}
+void KomparePart::slotRefreshDiff()
+{
+ if ( isModified() )
+ {
+ int query = KMessageBox::warningYesNoCancel
+ (
+ widget(),
+ i18n( "You have made changes to the destination file(s).\n"
+ "Would you like to save them?" ),
+ i18n( "Save Changes?" ),
+ KStandardGuiItem::save(),
+ KStandardGuiItem::discard()
+ );
+
+ if ( query == KMessageBox::Yes )
+ m_modelList->saveAll();
+
+ if ( query == KMessageBox::Cancel )
+ return; // Abort prematurely so no swapping
+ }
+
+ m_modelList->refresh();
+}
+
void KomparePart::slotShowDiffstats( void )
{
// Fetch all the args needed for komparestatsmessagebox
--- trunk/KDE/kdesdk/kompare/komparepart/kompare_part.h #871151:871152
@@ -5,7 +5,7 @@
Copyright 2001-2004 Otto Bruggeman <otto.bruggeman at home.nl>
Copyright 2001-2003 John Firebaugh <jfirebaugh at kde.org>
Copyright 2004 Jeff Snyder <jeff at caffeinated.me.uk>
- Copyright 2007 Kevin Kofler <kevin.kofler at chello.at>
+ Copyright 2007-2008 Kevin Kofler <kevin.kofler at chello.at>
****************************************************************************/
/***************************************************************************
@@ -186,6 +186,7 @@
void slotSwap();
void slotShowDiffstats();
+ void slotRefreshDiff();
void optionsPreferences();
void updateActions();
void updateCaption();
@@ -213,6 +214,7 @@
KAction* m_saveDiff;
KAction* m_swap;
KAction* m_diffStats;
+ KAction* m_diffRefresh;
KTemporaryFile* m_tempDiff;
--- trunk/KDE/kdesdk/kompare/komparepart/komparepartui.rc #871151:871152
@@ -7,6 +7,7 @@
<Action name="file_save_as"/>
<Action name="file_save_diff"/>
<Separator/>
+ <Action name="file_refreshdiff"/>
<Action name="file_swap"/>
<Action name="file_diffstats"/>
</Menu>
--- trunk/KDE/kdesdk/kompare/libdiff2/komparemodellist.cpp #871151:871152
@@ -1209,6 +1209,16 @@
emit modelsChanged( m_models );
}
+void KompareModelList::refresh()
+{
+ QString source = m_source;
+ QString destination = m_destination;
+ if ( m_info.mode == Kompare::ComparingFiles )
+ compareFiles( source, destination );
+ else if ( m_info.mode == Kompare::ComparingDirs )
+ compareDirs( source, destination );
+}
+
void KompareModelList::swap()
{
QString source = m_source;
--- trunk/KDE/kdesdk/kompare/libdiff2/komparemodellist.h #871151:871152
@@ -4,7 +4,7 @@
begin : Tue Jun 26 2001
Copyright 2001-2003 John Firebaugh <jfirebaugh at kde.org>
Copyright 2001-2003 Otto Bruggeman <otto.bruggeman at home.nl>
- Copyright 2007 Kevin Kofler <kevin.kofler at chello.at>
+ Copyright 2007-2008 Kevin Kofler <kevin.kofler at chello.at>
***************************************************************************/
/***************************************************************************
@@ -46,6 +46,7 @@
~KompareModelList();
public:
+ void refresh();
// Swap source with destination and show differences
void swap();
More information about the Kompare-devel
mailing list