Commit f17c7ce8 authored by Michael Reeves's avatar Michael Reeves

*reformat source files.

parent 0bd4dd9c
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
......@@ -35,52 +35,48 @@
#include "gnudiff_diff.h"
/* If non NULL, call this function when memory is exhausted. */
//void (*xalloc_fail_func) PARAMS ((void)) = 0;
void (*xalloc_fail_func)(void) = 0;
void GnuDiff::xalloc_die (void)
{
if (xalloc_fail_func)
(*xalloc_fail_func) ();
//error (exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
/* The `noreturn' cannot be given to error, since it may return if
its first argument is 0. To help compilers understand the
xalloc_die does terminate, call exit. */
exit (EXIT_FAILURE);
void ( *xalloc_fail_func )( void ) = 0;
void GnuDiff::xalloc_die( void ) {
if( xalloc_fail_func )
( *xalloc_fail_func )();
//error (exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
/* The `noreturn' cannot be given to error, since it may return if
its first argument is 0. To help compilers understand the
xalloc_die does terminate, call exit. */
exit( EXIT_FAILURE );
}
/* Allocate N bytes of memory dynamically, with error checking. */
void *
GnuDiff::xmalloc (size_t n)
{
void *p;
p = malloc (n == 0 ? 1 : n); // There are systems where malloc returns 0 for n==0.
if (p == 0)
xalloc_die ();
return p;
GnuDiff::xmalloc( size_t n ) {
void *p;
p = malloc( n == 0 ? 1 : n ); // There are systems where malloc returns 0 for n==0.
if( p == 0 )
xalloc_die();
return p;
}
/* Change the size of an allocated block of memory P to N bytes,
with error checking. */
void *
GnuDiff::xrealloc (void *p, size_t n)
{
p = realloc (p, n==0 ? 1 : n);
if (p == 0)
xalloc_die ();
return p;
GnuDiff::xrealloc( void *p, size_t n ) {
p = realloc( p, n == 0 ? 1 : n );
if( p == 0 )
xalloc_die();
return p;
}
/* Yield a new block of SIZE bytes, initialized to zero. */
void *
GnuDiff::zalloc (size_t size)
{
void *p = xmalloc (size);
memset (p, 0, size);
return p;
GnuDiff::zalloc( size_t size ) {
void *p = xmalloc( size );
memset( p, 0, size );
return p;
}
This diff is collapsed.
......@@ -44,7 +44,7 @@
appVersion += " (64 bit)";
else if ( sizeof(void*)==4 )
appVersion += " (32 bit)";
KAboutData aboutData( "kdiff3part", i18n( "KDiff3 Part" ),
appVersion, i18n( "A KPart to display SVG images" ),
KAboutLicense::GPL_V2,
......@@ -56,9 +56,8 @@
K_PLUGIN_FACTORY( KDiff3PartFactory, registerPlugin<KDiff3Part>(); )
//K_EXPORT_PLUGIN( KDiff3PartFactory(createAboutData()))
KDiff3Part::KDiff3Part( QWidget *parentWidget, QObject *parent, const QVariantList &args)
: KParts::ReadWritePart( parent )
{
KDiff3Part::KDiff3Part( QWidget *parentWidget, QObject *parent, const QVariantList &args )
: KParts::ReadWritePart( parent ) {
// we need an instance
//setComponentData( KPluginFactory::componentData() );
const char *widgetName = args[0].toString().toUtf8().data();
......@@ -86,20 +85,17 @@ KDiff3Part::KDiff3Part( QWidget *parentWidget, QObject *parent, const QVariantLi
setModified( false );
}
KDiff3Part::~KDiff3Part()
{
KDiff3Part::~KDiff3Part() {
if( m_widget != 0 && ! m_bIsShell ) {
m_widget->saveOptions( KSharedConfig::openConfig() );
}
}
void KDiff3Part::setReadWrite( bool /*rw*/ )
{
void KDiff3Part::setReadWrite( bool /*rw*/ ) {
// ReadWritePart::setReadWrite(rw);
}
void KDiff3Part::setModified( bool /*modified*/ )
{
void KDiff3Part::setModified( bool /*modified*/ ) {
/*
// get a handle on our Save action and make sure it is valid
QAction *save = actionCollection()->action(KStandardAction::stdName(KStandardAction::Save));
......@@ -118,8 +114,7 @@ void KDiff3Part::setModified( bool /*modified*/ )
*/
}
static void getNameAndVersion( const QString& str, const QString& lineStart, QString& fileName, QString& version )
{
static void getNameAndVersion( const QString& str, const QString& lineStart, QString& fileName, QString& version ) {
if( str.left( lineStart.length() ) == lineStart && fileName.isEmpty() ) {
int pos = lineStart.length();
while( pos < str.length() && ( str[pos] == ' ' || str[pos] == '\t' ) ) ++pos;
......@@ -142,8 +137,7 @@ static void getNameAndVersion( const QString& str, const QString& lineStart, QSt
}
bool KDiff3Part::openFile()
{
bool KDiff3Part::openFile() {
// m_file is always local so we can use QFile on it
fprintf( stderr, "KDiff3: %s\n", localFilePath().toLatin1().constData() );
QFile file( localFilePath() );
......@@ -245,8 +239,7 @@ bool KDiff3Part::openFile()
return true;
}
bool KDiff3Part::saveFile()
{
bool KDiff3Part::saveFile() {
/* // if we aren't read-write, return immediately
if (isReadWrite() == false)
return false;
......
......@@ -45,49 +45,46 @@
KDiff3Shell::KDiff3Shell( bool bCompleteInit )
: KParts::MainWindow( )
{
: KParts::MainWindow( ) {
m_bUnderConstruction = true;
// set the shell's ui resource file
setXMLFile("kdiff3_shell.rc");
setXMLFile( "kdiff3_shell.rc" );
// and a status bar
statusBar()->show();
const QVector<KPluginMetaData> plugin_offers = KPluginLoader::findPlugins("kf5/kdiff3part");
foreach (const KPluginMetaData &service, plugin_offers) {
KPluginFactory *factory = KPluginLoader(service.fileName()).factory();
m_part = factory->create<KDiff3Part>(this, QVariantList() << QVariant(QLatin1String("KDiff3Part")));
if (m_part)
break;
const QVector<KPluginMetaData> plugin_offers = KPluginLoader::findPlugins( "kf5/kdiff3part" );
foreach( const KPluginMetaData & service, plugin_offers ) {
KPluginFactory *factory = KPluginLoader( service.fileName() ).factory();
m_part = factory->create<KDiff3Part>( this, QVariantList() << QVariant( QLatin1String( "KDiff3Part" ) ) );
if( m_part )
break;
}
//m_part = new KDiff3Part( this, this, QVariantList() << QVariant(QLatin1String("KDiff3Part")) );
if (m_part)
{
// and integrate the part's GUI with the shell's
createGUI(m_part);
//toolBar()->setToolButtonStyle( Qt::ToolButtonIconOnly );
if( m_part ) {
// and integrate the part's GUI with the shell's
createGUI( m_part );
//toolBar()->setToolButtonStyle( Qt::ToolButtonIconOnly );
// tell the KParts::MainWindow that this is indeed the main widget
setCentralWidget(m_part->widget());
// tell the KParts::MainWindow that this is indeed the main widget
setCentralWidget( m_part->widget() );
if (bCompleteInit)
((KDiff3App*)m_part->widget())->completeInit();
connect(((KDiff3App*)m_part->widget()), SIGNAL(createNewInstance(const QString&, const QString&, const QString&)), this, SLOT(slotNewInstance(const QString&, const QString&, const QString&)));
}
else
{
if( bCompleteInit )
( ( KDiff3App* )m_part->widget() )->completeInit();
connect( ( ( KDiff3App* )m_part->widget() ), SIGNAL( createNewInstance( const QString&, const QString&, const QString& ) ), this, SLOT( slotNewInstance( const QString&, const QString&, const QString& ) ) );
}
else {
// if we couldn't find our Part, we exit since the Shell by
// itself can't do anything useful
KMessageBox::error(this, i18n("Could not initialize the KDiff3 part.\n"
"This usually happens due to an installation problem. "
"Please read the README-file in the source package for details.")
);
KMessageBox::error( this, i18n( "Could not initialize the KDiff3 part.\n"
"This usually happens due to an installation problem. "
"Please read the README-file in the source package for details." )
);
//kapp->quit();
::exit(-1); //kapp->quit() doesn't work here yet.
::exit( -1 ); //kapp->quit() doesn't work here yet.
// we return here, cause kapp->quit() only means "exit the
// next time we enter the event loop...
......@@ -102,82 +99,71 @@ KDiff3Shell::KDiff3Shell( bool bCompleteInit )
m_bUnderConstruction = false;
}
KDiff3Shell::~KDiff3Shell()
{
KDiff3Shell::~KDiff3Shell() {
}
bool KDiff3Shell::queryClose()
{
if (m_part)
return ((KDiff3App*)m_part->widget())->queryClose();
else
return true;
bool KDiff3Shell::queryClose() {
if( m_part )
return ( ( KDiff3App* )m_part->widget() )->queryClose();
else
return true;
}
bool KDiff3Shell::queryExit()
{
return true;
bool KDiff3Shell::queryExit() {
return true;
}
void KDiff3Shell::closeEvent(QCloseEvent*e)
{
if ( queryClose() )
{
e->accept();
bool bFileSaved = ((KDiff3App*)m_part->widget())->isFileSaved();
bool bDirCompare = ((KDiff3App*)m_part->widget())->isDirComparison();
QApplication::exit( bFileSaved || bDirCompare ? 0 : 1 );
}
else
e->ignore();
void KDiff3Shell::closeEvent( QCloseEvent*e ) {
if( queryClose() ) {
e->accept();
bool bFileSaved = ( ( KDiff3App* )m_part->widget() )->isFileSaved();
bool bDirCompare = ( ( KDiff3App* )m_part->widget() )->isDirComparison();
QApplication::exit( bFileSaved || bDirCompare ? 0 : 1 );
}
else
e->ignore();
}
void KDiff3Shell::optionsShowToolbar()
{
void KDiff3Shell::optionsShowToolbar() {
// this is all very cut and paste code for showing/hiding the
// toolbar
if (m_toolbarAction->isChecked())
if( m_toolbarAction->isChecked() )
toolBar()->show();
else
toolBar()->hide();
}
void KDiff3Shell::optionsShowStatusbar()
{
void KDiff3Shell::optionsShowStatusbar() {
// this is all very cut and paste code for showing/hiding the
// statusbar
if (m_statusbarAction->isChecked())
if( m_statusbarAction->isChecked() )
statusBar()->show();
else
statusBar()->hide();
}
void KDiff3Shell::optionsConfigureKeys()
{
KShortcutsDialog::configure(actionCollection() /*, "kdiff3_shell.rc" */ );
void KDiff3Shell::optionsConfigureKeys() {
KShortcutsDialog::configure( actionCollection() /*, "kdiff3_shell.rc" */ );
}
void KDiff3Shell::optionsConfigureToolbars()
{
KConfigGroup mainWindowGroup( KSharedConfig::openConfig(), "MainWindow" );
saveMainWindowSettings( mainWindowGroup );
void KDiff3Shell::optionsConfigureToolbars() {
KConfigGroup mainWindowGroup( KSharedConfig::openConfig(), "MainWindow" );
saveMainWindowSettings( mainWindowGroup );
// use the standard toolbar editor
KEditToolBar dlg(factory());
connect(&dlg, &KEditToolBar::newToolbarConfig, this, &KDiff3Shell::applyNewToolbarConfig);
KEditToolBar dlg( factory() );
connect( &dlg, &KEditToolBar::newToolbarConfig, this, &KDiff3Shell::applyNewToolbarConfig );
dlg.exec();
}
void KDiff3Shell::applyNewToolbarConfig()
{
KConfigGroup mainWindowGroup( KSharedConfig::openConfig(), "MainWindow" );
applyMainWindowSettings( mainWindowGroup );
void KDiff3Shell::applyNewToolbarConfig() {
KConfigGroup mainWindowGroup( KSharedConfig::openConfig(), "MainWindow" );
applyMainWindowSettings( mainWindowGroup );
}
void KDiff3Shell::slotNewInstance( const QString& fn1, const QString& fn2, const QString& fn3 )
{
KDiff3Shell* pKDiff3Shell = new KDiff3Shell(false);
((KDiff3App*)pKDiff3Shell->m_part->widget())->completeInit(fn1,fn2,fn3);
void KDiff3Shell::slotNewInstance( const QString& fn1, const QString& fn2, const QString& fn3 ) {
KDiff3Shell* pKDiff3Shell = new KDiff3Shell( false );
( ( KDiff3App* )pKDiff3Shell->m_part->widget() )->completeInit( fn1, fn2, fn3 );
}
#include "kdiff3_shell.moc"
This diff is collapsed.
......@@ -19,67 +19,57 @@
#include <assert.h>
Merger::Merger( const DiffList* pDiffListAB, const DiffList* pDiffListCA )
: md1( pDiffListAB, 0 ), md2( pDiffListCA, 1 )
{
: md1( pDiffListAB, 0 ), md2( pDiffListCA, 1 ) {
}
Merger::MergeData::MergeData( const DiffList* p, int i )
: d(0,0,0)
{
idx=i;
pDiffList = p;
if ( p!=0 )
{
it=p->begin();
update();
}
: d( 0, 0, 0 ) {
idx = i;
pDiffList = p;
if( p != 0 ) {
it = p->begin();
update();
}
}
bool Merger::MergeData::eq()
{
return pDiffList==0 || d.nofEquals > 0;
bool Merger::MergeData::eq() {
return pDiffList == 0 || d.nofEquals > 0;
}
bool Merger::MergeData::isEnd()
{
return ( pDiffList==0 || ( it==pDiffList->end() && d.nofEquals==0 &&
( idx == 0 ? d.diff1==0 : d.diff2==0 )
) );
bool Merger::MergeData::isEnd() {
return ( pDiffList == 0 || ( it == pDiffList->end() && d.nofEquals == 0 &&
( idx == 0 ? d.diff1 == 0 : d.diff2 == 0 )
) );
}
void Merger::MergeData::update()
{
if ( d.nofEquals > 0 )
--d.nofEquals;
else if ( idx==0 && d.diff1 > 0 )
--d.diff1;
else if ( idx==1 && d.diff2 > 0 )
--d.diff2;
void Merger::MergeData::update() {
if( d.nofEquals > 0 )
--d.nofEquals;
else if( idx == 0 && d.diff1 > 0 )
--d.diff1;
else if( idx == 1 && d.diff2 > 0 )
--d.diff2;
while( d.nofEquals == 0 && ((idx==0 && d.diff1 == 0) || (idx==1 && d.diff2 == 0))
&& pDiffList!=0 && it != pDiffList->end() )
{
d = *it;
++it;
}
while( d.nofEquals == 0 && ( ( idx == 0 && d.diff1 == 0 ) || ( idx == 1 && d.diff2 == 0 ) )
&& pDiffList != 0 && it != pDiffList->end() ) {
d = *it;
++it;
}
}
void Merger::next()
{
md1.update();
md2.update();
void Merger::next() {
md1.update();
md2.update();
}
int Merger::whatChanged()
{
int changed = 0;
changed |= md1.eq() ? 0 : 1;
changed |= md2.eq() ? 0 : 2;
return changed;
int Merger::whatChanged() {
int changed = 0;
changed |= md1.eq() ? 0 : 1;
changed |= md2.eq() ? 0 : 2;
return changed;
}
bool Merger::isEndReached()
{
return md1.isEnd() && md2.isEnd();
bool Merger::isEndReached() {
return md1.isEnd() && md2.isEnd();
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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