Commit 4abec9ed authored by Joachim Eibl's avatar Joachim Eibl

KDiff3-0.9.91 (Qt3 based src)

git-svn-id: https://kdiff3.svn.sourceforge.net/svnroot/kdiff3/trunk@80 c8aa9fed-2811-0410-8543-893ada326672
parent cf77f4c3
# set the include path for X, qt and KDE
INCLUDES = $(all_includes)
# these are the headers for your project
noinst_HEADERS = kdiff3_part.h kdiff3_shell.h kdiff3.h common.h diff.h \
directorymergewindow.h merger.h optiondialog.h fileaccess.h version.h \
smalldialogs.h difftextwindow.h mergeresultwindow.h
# let automoc handle all of the meta source files (moc)
METASOURCES = AUTO
messages: rc.cpp
$(XGETTEXT) *.cpp -o $(podir)/kdiff3.pot
KDE_ICON = kdiff3
# this Makefile creates both a KPart application and a KPart
#########################################################################
# APPLICATION SECTION
#########################################################################
# this is the program that gets installed. it's name is used for all
# of the other Makefile.am variables
bin_PROGRAMS = kdiff3
# the application source, library search path, and link libraries
kdiff3_SOURCES = main.cpp kdiff3_shell.cpp
kdiff3_LDFLAGS = $(KDE_RPATH) $(all_libraries)
kdiff3_LDADD = $(LIB_KPARTS)
# this is where the desktop file will go
shelldesktopdir = $(kde_appsdir)/Development
shelldesktop_DATA = kdiff3.desktop
# this is where the shell's XML-GUI resource file goes
shellrcdir = $(kde_datadir)/kdiff3
shellrc_DATA = kdiff3_shell.rc
#########################################################################
# KPART SECTION
#########################################################################
kde_module_LTLIBRARIES = libkdiff3part.la
# the Part's source, library search path, and link libraries
libkdiff3part_la_SOURCES = kdiff3_part.cpp kdiff3.cpp directorymergewindow.cpp \
merger.cpp pdiff.cpp difftextwindow.cpp diff.cpp optiondialog.cpp \
mergeresultwindow.cpp fileaccess.cpp gnudiff_analyze.cpp gnudiff_io.cpp gnudiff_xmalloc.cpp \
common.cpp smalldialogs.cpp
libkdiff3part_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
libkdiff3part_la_LIBADD = $(LIB_KDEPRINT) $(LIB_KPARTS) $(LIB_KFILE)
# this is where the desktop file will go
partdesktopdir = $(kde_servicesdir)
partdesktop_DATA = kdiff3part.desktop
# this is where the part's XML-GUI resource file goes
partrcdir = $(kde_datadir)/kdiff3part
partrc_DATA = kdiff3_part.rc
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2004-2006 by Joachim Eibl *
* joachim.eibl at gmx.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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "common.h"
#include <map>
#include <qfont.h>
#include <qcolor.h>
#include <qsize.h>
#include <qpoint.h>
#include <qstringlist.h>
#include <qtextstream.h>
ValueMap::ValueMap()
{
}
ValueMap::~ValueMap()
{
}
void ValueMap::save( QTextStream& ts )
{
std::map<QString,QString>::iterator i;
for( i=m_map.begin(); i!=m_map.end(); ++i)
{
QString key = i->first;
QString val = i->second;
ts << key << "=" << val << "\n";
}
}
QString ValueMap::getAsString()
{
QString result;
std::map<QString,QString>::iterator i;
for( i=m_map.begin(); i!=m_map.end(); ++i)
{
QString key = i->first;
QString val = i->second;
result += key + "=" + val + "\n";
}
return result;
}
void ValueMap::load( QTextStream& ts )
{
while ( !ts.eof() )
{ // until end of file...
QString s = ts.readLine(); // line of text excluding '\n'
int pos = s.find('=');
if( pos > 0 ) // seems not to have a tag
{
QString key = s.left(pos);
QString val = s.mid(pos+1);
m_map[key] = val;
}
}
}
/*
void ValueMap::load( const QString& s )
{
int pos=0;
while ( pos<(int)s.length() )
{ // until end of file...
int pos2 = s.find('=', pos);
int pos3 = s.find('\n', pos2 );
if (pos3<0)
pos3=s.length();
if( pos2 > 0 ) // seems not to have a tag
{
QString key = s.mid(pos, pos2-pos);
QString val = s.mid(pos2+1, pos3-pos2-1);
m_map[key] = val;
}
pos = pos3;
}
}
*/
// safeStringJoin and safeStringSplit allow to convert a stringlist into a string and back
// safely, even if the individual strings in the list contain the separator character.
QString safeStringJoin(const QStringList& sl, char sepChar, char metaChar )
{
// Join the strings in the list, using the separator ','
// If a string contains the separator character, it will be replaced with "\,".
// Any occurances of "\" (one backslash) will be replaced with "\\" (2 backslashes)
assert(sepChar!=metaChar);
QString sep;
sep += sepChar;
QString meta;
meta += metaChar;
QString safeString;
QStringList::const_iterator i;
for (i=sl.begin(); i!=sl.end(); ++i)
{
QString s = *i;
s.replace(meta, meta+meta); // "\" -> "\\"
s.replace(sep, meta+sep); // "," -> "\,"
if ( i==sl.begin() )
safeString = s;
else
safeString += sep + s;
}
return safeString;
}
// Split a string that was joined with safeStringJoin
QStringList safeStringSplit(const QString& s, char sepChar, char metaChar )
{
assert(sepChar!=metaChar);
QStringList sl;
// Miniparser
int i=0;
int len=s.length();
QString b;
for(i=0;i<len;++i)
{
if ( i+1<len && s[i]==metaChar && s[i+1]==metaChar ){ b+=metaChar; ++i; }
else if ( i+1<len && s[i]==metaChar && s[i+1]==sepChar ){ b+=sepChar; ++i; }
else if ( s[i]==sepChar ) // real separator
{
sl.push_back(b);
b="";
}
else { b+=s[i]; }
}
if ( !b.isEmpty() )
sl.push_back(b);
return sl;
}
static QString numStr(int n)
{
QString s;
s.setNum( n );
return s;
}
static QString subSection( const QString& s, int idx, char sep )
{
int pos=0;
while( idx>0 )
{
pos = s.find( sep, pos );
--idx;
if (pos<0) break;
++pos;
}
if ( pos>=0 )
{
int pos2 = s.find( sep, pos );
if ( pos2>0 )
return s.mid(pos, pos2-pos);
else
return s.mid(pos);
}
return "";
}
static int num( QString& s, int idx )
{
return subSection( s, idx, ',').toInt();
}
void ValueMap::writeEntry(const QString& k, const QFont& v )
{
m_map[k] = v.family() + "," + QString::number(v.pointSize()) + "," + (v.bold() ? "bold" : "normal");
}
void ValueMap::writeEntry(const QString& k, const QColor& v )
{
m_map[k] = numStr(v.red()) + "," + numStr(v.green()) + "," + numStr(v.blue());
}
void ValueMap::writeEntry(const QString& k, const QSize& v )
{
m_map[k] = numStr(v.width()) + "," + numStr(v.height());
}
void ValueMap::writeEntry(const QString& k, const QPoint& v )
{
m_map[k] = numStr(v.x()) + "," + numStr(v.y());
}
void ValueMap::writeEntry(const QString& k, int v )
{
m_map[k] = numStr(v);
}
void ValueMap::writeEntry(const QString& k, bool v )
{
m_map[k] = numStr(v);
}
void ValueMap::writeEntry(const QString& k, const QString& v )
{
m_map[k] = v;
}
void ValueMap::writeEntry(const QString& k, const char* v )
{
m_map[k] = v;
}
void ValueMap::writeEntry(const QString& k, const QStringList& v, char separator )
{
m_map[k] = safeStringJoin(v, separator);
}
QFont ValueMap::readFontEntry(const QString& k, QFont* defaultVal )
{
QFont f = *defaultVal;
std::map<QString,QString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
f.setFamily( subSection( i->second, 0, ',' ) );
f.setPointSize( subSection( i->second, 1, ',' ).toInt() );
f.setBold( subSection( i->second, 2, ',' )=="bold" );
//f.fromString(i->second);
}
return f;
}
QColor ValueMap::readColorEntry(const QString& k, QColor* defaultVal )
{
QColor c= *defaultVal;
std::map<QString,QString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
QString s = i->second;
c = QColor( num(s,0),num(s,1),num(s,2) );
}
return c;
}
QSize ValueMap::readSizeEntry(const QString& k, QSize* defaultVal )
{
QSize size = defaultVal ? *defaultVal : QSize(600,400);
std::map<QString,QString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
QString s = i->second;
size = QSize( num(s,0),num(s,1) );
}
return size;
}
QPoint ValueMap::readPointEntry(const QString& k, QPoint* defaultVal)
{
QPoint point = defaultVal ? *defaultVal : QPoint(0,0);
std::map<QString,QString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
QString s = i->second;
point = QPoint( num(s,0),num(s,1) );
}
return point;
}
bool ValueMap::readBoolEntry(const QString& k, bool bDefault )
{
bool b = bDefault;
std::map<QString,QString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
QString s = i->second;
b = (bool)num(s,0);
}
return b;
}
int ValueMap::readNumEntry(const QString& k, int iDefault )
{
int ival = iDefault;
std::map<QString,QString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
QString s = i->second;
ival = num(s,0);
}
return ival;
}
QString ValueMap::readEntry(const QString& k, const QString& sDefault )
{
QString sval = sDefault;
std::map<QString,QString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
sval = i->second;
}
return sval;
}
QStringList ValueMap::readListEntry(const QString& k, const QStringList& defaultVal, char separator )
{
QStringList strList;
std::map<QString,QString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
strList = safeStringSplit( i->second, separator );
return strList;
}
else
return defaultVal;
}
/***************************************************************************
common.h - Things that are needed often
-------------------
begin : Mon Mar 18 2002
copyright : (C) 2002-2006 by Joachim Eibl
email : joachim.eibl at gmx.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; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _COMMON_H
#define _COMMON_H
#include <assert.h>
template< class T >
T min2( T x, T y )
{
return x<y ? x : y;
}
template< class T >
T max2( T x, T y )
{
return x>y ? x : y;
}
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
template <class T>
T min3( T d1, T d2, T d3 )
{
if ( d1 < d2 && d1 < d3 ) return d1;
if ( d2 < d3 ) return d2;
return d3;
}
template <class T>
T max3( T d1, T d2, T d3 )
{
if ( d1 > d2 && d1 > d3 ) return d1;
if ( d2 > d3 ) return d2;
return d3;
}
template <class T>
T minMaxLimiter( T d, T minimum, T maximum )
{
assert(minimum<=maximum);
if ( d < minimum ) return minimum;
if ( d > maximum ) return maximum;
return d;
}
#include <map>
#include <qstring.h>
class QFont;
class QColor;
class QSize;
class QPoint;
class QStringList;
class QTextStream;
class ValueMap
{
private:
std::map<QString,QString> m_map;
public:
ValueMap();
virtual ~ValueMap();
void save( QTextStream& ts );
void load( QTextStream& ts );
QString getAsString();
// void load( const QString& s );
virtual void writeEntry(const QString&, const QFont& );
virtual void writeEntry(const QString&, const QColor& );
virtual void writeEntry(const QString&, const QSize& );
virtual void writeEntry(const QString&, const QPoint& );
virtual void writeEntry(const QString&, int );
virtual void writeEntry(const QString&, bool );
virtual void writeEntry(const QString&, const QStringList&, char separator );
virtual void writeEntry(const QString&, const QString& );
virtual void writeEntry(const QString&, const char* );
virtual QFont readFontEntry (const QString&, QFont* defaultVal );
virtual QColor readColorEntry(const QString&, QColor* defaultVal );
virtual QSize readSizeEntry (const QString&, QSize* defaultVal );
virtual QPoint readPointEntry(const QString&, QPoint* defaultVal );
virtual bool readBoolEntry (const QString&, bool bDefault );
virtual int readNumEntry (const QString&, int iDefault );
virtual QStringList readListEntry (const QString&, const QStringList& defaultVal, char separator );
virtual QString readEntry (const QString&, const QString& );
};
QStringList safeStringSplit(const QString& s, char sepChar=',', char metaChar='\\' );
QString safeStringJoin(const QStringList& sl, char sepChar=',', char metaChar='\\' );
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/***************************************************************************
difftextwindow.h - description
-------------------
begin : Mon Mar 18 2002
copyright : (C) 2002-2005 by Joachim Eibl
email : joachim.eibl at gmx.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; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef DIFFTEXTWINDOW_H
#define DIFFTEXTWINDOW_H
#include "diff.h"
#include <qwidget.h>
class QStatusBar;
class OptionDialog;
class DiffTextWindowData;
class DiffTextWindowFrame;
class DiffTextWindow : public QWidget
{
Q_OBJECT
public:
DiffTextWindow(
DiffTextWindowFrame* pParent,
QStatusBar* pStatusBar,
OptionDialog* pOptionDialog,
int winIdx
);
~DiffTextWindow();
void init(
const QString& fileName,
const LineData* pLineData,
int size,
const Diff3LineVector* pDiff3LineVector,
const ManualDiffHelpList* pManualDiffHelpList,
bool bTriple
);
void reset();
void convertToLinePos( int x, int y, int& line, int& pos );
QString getSelection();
int getFirstLine();
int calcTopLineInFile( int firstLine );
int getNofColumns();
int getNofLines();
int getNofVisibleLines();
int getNofVisibleColumns();
int convertLineToDiff3LineIdx( int line );
int convertDiff3LineIdxToLine( int d3lIdx );
void convertD3LCoordsToLineCoords( int d3LIdx, int d3LPos, int& line, int& pos );
void convertLineCoordsToD3LCoords( int line, int pos, int& d3LIdx, int& d3LPos );
void convertSelectionToD3LCoords();
bool findString( const QString& s, int& d3vLine, int& posInLine, bool bDirDown, bool bCaseSensitive );
void setSelection( int firstLine, int startPos, int lastLine, int endPos, int& l, int& p );
void getSelectionRange( int* firstLine, int* lastLine, e_CoordType coordType );
void setPaintingAllowed( bool bAllowPainting );
void recalcWordWrap( bool bWordWrap, int wrapLineVectorSize, int nofVisibleColumns );
void print( MyPainter& painter, const QRect& r, int firstLine, int nofLinesPerPage );
signals:
void resizeSignal( int nofVisibleColumns, int nofVisibleLines );
void scroll( int deltaX, int deltaY );
void newSelection();
void selectionEnd();
void setFastSelectorLine( int line );
void gotFocus();
void lineClicked( int winIdx, int line );
public slots:
void setFirstLine( int line );
void setFirstColumn( int col );
void resetSelection();
void setFastSelectorRange( int line1, int nofLines );
protected:
virtual void mousePressEvent ( QMouseEvent * );
virtual void mouseReleaseEvent ( QMouseEvent * );
virtual void mouseMoveEvent ( QMouseEvent * );
virtual void mouseDoubleClickEvent ( QMouseEvent * e );
virtual void paintEvent( QPaintEvent* );
virtual void dragEnterEvent( QDragEnterEvent* e );
virtual void focusInEvent( QFocusEvent* e );
virtual void resizeEvent( QResizeEvent* );
virtual void timerEvent(QTimerEvent*);
private:
DiffTextWindowData* d;
void showStatusLine( int line );
friend class DiffTextWindowFrame;
};
class DiffTextWindowFrameData;
class DiffTextWindowFrame : public QWidget
{
Q_OBJECT
public:
DiffTextWindowFrame( QWidget* pParent, QStatusBar* pStatusBar, OptionDialog* pOptionDialog, int winIdx );
~DiffTextWindowFrame();
DiffTextWindow* getDiffTextWindow();
void init();
void setFirstLine(int firstLine);
signals:
void fileNameChanged(const QString&, int);
protected:
bool eventFilter( QObject*, QEvent* );
private slots:
void slotReturnPressed();
void slotBrowseButtonClicked();
private:
DiffTextWindowFrameData* d;
};
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2003-2006 by Joachim Eibl *
* joachim.eibl at gmx.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; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef FILEACCESS_H
#define FILEACCESS_H
#include <qdialog.h>
#include <qfileinfo.h>
#include <kprogress.h>
#include <kio/job.h>
#include <kio/jobclasses.h>
#include <kurldrag.h>
#include <list>