diff --git a/src/DirectoryInfo.h b/src/DirectoryInfo.h index 2d417f3..e84cb4c 100644 --- a/src/DirectoryInfo.h +++ b/src/DirectoryInfo.h @@ -1,55 +1,51 @@ /** * Copyright (C) 2018 Michael Reeves * * This file is part of KDiff3. * * KDiff3 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. * * KDiff3 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 KDiff3. If not, see . */ #ifndef DIRECTORYINFO_H #define DIRECTORYINFO_H #include "fileaccess.h" class DirectoryInfo { public: - DirectoryInfo( - FileAccess& dirA, - FileAccess& dirB, - FileAccess& dirC, - FileAccess& dirDest) + DirectoryInfo(FileAccess& dirA, FileAccess& dirB, FileAccess& dirC, FileAccess& dirDest) { m_dirA = dirA; m_dirB = dirB; m_dirC = dirC; m_dirDest = dirDest; } inline FileAccess dirA() const { return m_dirA; } inline FileAccess dirB() const { return m_dirB; } inline FileAccess dirC() const { return m_dirC; } inline FileAccess destDir() const { if(m_dirDest.isValid()) return m_dirDest; else return m_dirC.isValid() ? m_dirC : m_dirB; } private: FileAccess m_dirA, m_dirB, m_dirC; FileAccess m_dirDest; }; #endif diff --git a/src/difftextwindow.h b/src/difftextwindow.h index 05f0013..a3e0ff4 100644 --- a/src/difftextwindow.h +++ b/src/difftextwindow.h @@ -1,161 +1,155 @@ /*************************************************************************** * Copyright (C) 2003-2007 by Joachim Eibl * * joachim.eibl at gmx.de * * Copyright (C) 2018 Michael Reeves reeves.87@gmail.com * * * * 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 class QMenu; class QStatusBar; class Options; class DiffTextWindowData; class DiffTextWindowFrame; class EncodingLabel; class DiffTextWindow : public QWidget { Q_OBJECT public: - DiffTextWindow( - DiffTextWindowFrame* pParent, - QStatusBar* pStatusBar, - Options* pOptions, - - int winIdx - ); + DiffTextWindow(DiffTextWindowFrame* pParent, QStatusBar* pStatusBar, Options* pOptions, int winIdx); ~DiffTextWindow() override; void init( const QString& fileName, QTextCodec* pCodec, e_LineEndStyle eLineEndStyle, 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 getMaxTextWidth(); int getNofLines(); int getNofVisibleLines(); int getVisibleTextAreaWidth(); 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 recalcWordWrapHelper( int wrapLineVectorSize, int visibleTextWidth, int cacheListIdx); void print( MyPainter& painter, const QRect& r, int firstLine, int nofLinesPerPage ); Q_SIGNALS: void resizeHeightChangedSignal(int nofVisibleLines); void resizeWidthChangedSignal(int nofVisibleColumns); void scrollDiffTextWindow( int deltaX, int deltaY ); void newSelection(); void selectionEnd(); void setFastSelectorLine( int line ); void gotFocus(); void lineClicked( int winIdx, int line ); public Q_SLOTS: void setFirstLine( int line ); void setHorizScrollOffset( int horizScrollOffset ); void resetSelection(); void setFastSelectorRange( int line1, int nofLines ); protected: void mousePressEvent ( QMouseEvent * ) override; void mouseReleaseEvent ( QMouseEvent * ) override; void mouseMoveEvent ( QMouseEvent * ) override; void mouseDoubleClickEvent ( QMouseEvent * e ) override; void paintEvent( QPaintEvent* ) override; void dragEnterEvent( QDragEnterEvent* e ) override; void focusInEvent( QFocusEvent* e ) override; void resizeEvent( QResizeEvent* ) override; void timerEvent(QTimerEvent*) override; private: DiffTextWindowData* d; void showStatusLine( int line ); friend class DiffTextWindowFrame; }; class DiffTextWindowFrameData; class DiffTextWindowFrame : public QWidget { Q_OBJECT public: DiffTextWindowFrame( QWidget* pParent, QStatusBar* pStatusBar, Options* pOptions, int winIdx, SourceData* psd); ~DiffTextWindowFrame() override; DiffTextWindow* getDiffTextWindow(); void init(); void setFirstLine(int firstLine); void sendEncodingChangedSignal(QTextCodec* c); Q_SIGNALS: void fileNameChanged(const QString&, int); void encodingChanged(QTextCodec*); protected: bool eventFilter( QObject*, QEvent* ) override; //void paintEvent(QPaintEvent*); private Q_SLOTS: void slotReturnPressed(); void slotBrowseButtonClicked(); private: DiffTextWindowFrameData* d; }; class EncodingLabel : public QLabel { Q_OBJECT public: EncodingLabel( const QString & text, DiffTextWindowFrame* pDiffTextWindowFrame, SourceData* psd, Options* pOptions); protected: void mouseMoveEvent(QMouseEvent *ev) override; void mousePressEvent(QMouseEvent *ev) override; private Q_SLOTS: void slotEncodingChanged(); private: DiffTextWindowFrame* m_pDiffTextWindowFrame; //To send "EncodingChanged" signal QMenu* m_pContextEncodingMenu; SourceData* m_pSourceData; //SourceData to get access to "isEmpty()" and "isFromBuffer()" functions static const int m_maxRecentEncodings = 5; Options* m_pOptions; void insertCodec( const QString& visibleCodecName, QTextCodec* pCodec, QList &CodecEnumList, QMenu* pMenu, int currentTextCodecEnum); }; bool startRunnables(); #endif diff --git a/src/fileaccess.h b/src/fileaccess.h index 123b483..7a5b5aa 100644 --- a/src/fileaccess.h +++ b/src/fileaccess.h @@ -1,192 +1,192 @@ /*************************************************************************** * Copyright (C) 2003-2007 by Joachim Eibl * * Copyright (C) 2018 Michael Reeves reeves.87@gmail.com * * * * 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 "progress.h" #include "ProgressProxyExtender.h" #include #include #include #include #include #include #include namespace KIO { class Job; } class t_DirectoryList; class FileAccess { public: FileAccess(); ~FileAccess(); - FileAccess( const QString& name, bool bWantToWrite=false ); // name: local file or dirname or url (when supported) + explicit FileAccess( const QString& name, bool bWantToWrite=false ); // name: local file or dirname or url (when supported) void setFile( const QString& name, bool bWantToWrite=false ); void setFile( const QUrl& name, bool bWantToWrite = false); void setFile( FileAccess* pParent, QFileInfo fi ); void loadData(); bool isNormal() const; bool isValid() const; bool isFile() const; bool isDir() const; bool isSymLink() const; bool exists() const; qint64 size() const; // Size as returned by stat(). qint64 sizeForReading(); // If the size can't be determined by stat() then the file is copied to a local temp file. bool isReadable() const; bool isWritable() const; bool isExecutable() const; bool isHidden() const; QString readLink() const; QDateTime lastModified() const; QString fileName(bool needTmp = false) const; // Just the name-part of the path, without parent directories QString fileRelPath() const; // The path relative to base comparison directory QString prettyAbsPath() const; QUrl url() const; void setUrl(const QUrl inUrl) { m_url = inUrl; } QString absoluteFilePath() const; bool isLocal() const; bool readFile(void* pDestBuffer, qint64 maxLength ); bool writeFile(const void* pSrcBuffer, qint64 length ); bool listDir( t_DirectoryList* pDirList, bool bRecursive, bool bFindHidden, const QString& filePattern, const QString& fileAntiPattern, const QString& dirAntiPattern, bool bFollowDirLinks, bool bUseCvsIgnore ); bool copyFile( const QString& destUrl ); bool createBackup( const QString& bakExtension ); QString getTempName() const; bool createLocalCopy(); static void createTempFile(QTemporaryFile& ); static bool removeTempFile( const QString& ); bool removeFile(); static bool removeFile( const QString& ); static bool makeDir( const QString& ); static bool removeDir( const QString& ); static bool exists( const QString& ); static QString cleanPath( const QString& ); //bool chmod( const QString& ); bool rename( const QString& ); static bool symLink( const QString& linkTarget, const QString& linkLocation ); void addPath( const QString& txt ); QString getStatusText(); FileAccess* parent() const; // !=0 for listDir-results, but only valid if the parent was not yet destroyed. void doError(); void filterList(t_DirectoryList* pDirList, const QString& filePattern, const QString& fileAntiPattern, const QString& dirAntiPattern, const bool bUseCvsIgnore); QDir getBaseDirectory() const { return m_baseDir; } private: friend class FileAccessJobHandler; void setUdsEntry(const KIO::UDSEntry& e); void setStatusText( const QString& s ); void reset(); QUrl m_url; bool m_bValidData; //long m_fileType; // for testing only FileAccess* m_pParent; QDir m_baseDir; QFileInfo m_fileInfo; QString m_linkTarget; QString m_name; QString m_localCopy; QSharedPointer tmpFile; qint64 m_size; QDateTime m_modificationTime; bool m_bSymLink; bool m_bFile; bool m_bDir; bool m_bExists; bool m_bWritable; bool m_bReadable; bool m_bExecutable; bool m_bHidden; QString m_statusText; // Might contain an error string, when the last operation didn't succeed. }; class t_DirectoryList : public std::list {}; class FileAccessJobHandler : public QObject { Q_OBJECT public: explicit FileAccessJobHandler( FileAccess* pFileAccess ); bool get( void* pDestBuffer, long maxLength ); bool put( const void* pSrcBuffer, long maxLength, bool bOverwrite, bool bResume=false, int permissions=-1 ); bool stat(int detailLevel=2, bool bWantToWrite=false ); bool copyFile( const QString& dest ); bool rename( const QString& dest ); bool listDir( t_DirectoryList* pDirList, bool bRecursive, bool bFindHidden, const QString& filePattern, const QString& fileAntiPattern, const QString& dirAntiPattern, bool bFollowDirLinks, bool bUseCvsIgnore ); bool mkDir( const QString& dirName ); bool rmDir( const QString& dirName ); bool removeFile( const QUrl& dirName ); bool symLink( const QUrl& linkTarget, const QUrl& linkLocation ); private: FileAccess* m_pFileAccess; bool m_bSuccess; // Data needed during Job qint64 m_transferredBytes; char* m_pTransferBuffer = nullptr; // Needed during get or put qint64 m_maxLength; QString m_filePattern; QString m_fileAntiPattern; QString m_dirAntiPattern; t_DirectoryList* m_pDirList = nullptr; bool m_bFindHidden = false; bool m_bRecursive = false; bool m_bFollowDirLinks = false; bool scanLocalDirectory( const QString& dirName, t_DirectoryList* dirList ); private Q_SLOTS: void slotStatResult( KJob* ); void slotSimpleJobResult( KJob* pJob ); void slotPutJobResult( KJob* pJob ); void slotGetData(KJob*,const QByteArray&); void slotPutData(KIO::Job*, QByteArray&); void slotListDirProcessNewEntries( KIO::Job *, const KIO::UDSEntryList& l ); }; #endif diff --git a/src/kdiff3_shell.h b/src/kdiff3_shell.h index 45f15b7..761316f 100644 --- a/src/kdiff3_shell.h +++ b/src/kdiff3_shell.h @@ -1,82 +1,82 @@ /*************************************************************************** * Copyright (C) 2003-2007 by Joachim Eibl * * Copyright (C) 2018 Michael Reeves reeves.87@gmail.com * * * * 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef _KDIFF3SHELL_H_ #define _KDIFF3SHELL_H_ #include #include class KToggleAction; namespace KParts { class ReadWritePart; } class KDiff3App; /** * This is the application "Shell". It has a menubar, toolbar, and * statusbar but relies on the "Part" to do all the real work. * * @short Application Shell * @author Joachim Eibl */ class KDiff3Shell : public KParts::MainWindow { Q_OBJECT public: /** * Default Constructor */ - KDiff3Shell(bool bCompleteInit=true); + explicit KDiff3Shell(bool bCompleteInit=true); /** * Default Destructor */ ~KDiff3Shell() override; bool queryClose() override; bool queryExit(); void closeEvent(QCloseEvent*e) override; static inline QCommandLineParser* getParser(){ static QCommandLineParser *parser = new QCommandLineParser(); return parser; }; private Q_SLOTS: void optionsShowToolbar(); void optionsShowStatusbar(); void optionsConfigureKeys(); void optionsConfigureToolbars(); void applyNewToolbarConfig(); void slotNewInstance( const QString& fn1, const QString& fn2, const QString& fn3 ); private: KParts::ReadWritePart *m_part; KDiff3App *m_widget; KToggleAction *m_toolbarAction; KToggleAction *m_statusbarAction; bool m_bUnderConstruction; }; #endif // _KDIFF3_H_ diff --git a/src/mergeresultwindow.h b/src/mergeresultwindow.h index d830d91..2d915fd 100644 --- a/src/mergeresultwindow.h +++ b/src/mergeresultwindow.h @@ -1,459 +1,455 @@ /*************************************************************************** * Copyright (C) 2003-2007 by Joachim Eibl * * Copyright (C) 2018 Michael Reeves reeves.87@gmail.com * * * * 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 MERGERESULTWINDOW_H #define MERGERESULTWINDOW_H #include "diff.h" #include "selection.h" #include #include #include #include #include class QPainter; class Overview : public QWidget { Q_OBJECT public: explicit Overview( Options* pOptions ); void init( Diff3LineList* pDiff3LineList, bool bTripleDiff ); void reset(); void setRange( int firstLine, int pageHeight ); void setPaintingAllowed( bool bAllowPainting ); enum e_OverviewMode { eOMNormal, eOMAvsB, eOMAvsC, eOMBvsC }; void setOverviewMode( e_OverviewMode eOverviewMode ); e_OverviewMode getOverviewMode(); public Q_SLOTS: void setFirstLine(int firstLine); void slotRedraw(); Q_SIGNALS: void setLine(int); private: const Diff3LineList* m_pDiff3LineList; Options* m_pOptions; bool m_bTripleDiff; int m_firstLine; int m_pageHeight; QPixmap m_pixmap; bool m_bPaintingAllowed; e_OverviewMode m_eOverviewMode; int m_nofLines; void paintEvent( QPaintEvent* e ) override; void mousePressEvent( QMouseEvent* e ) override; void mouseMoveEvent( QMouseEvent* e ) override; void drawColumn( QPainter& p, e_OverviewMode eOverviewMode, int x, int w, int h, int nofLines ); }; enum e_MergeDetails { eDefault, eNoChange, eBChanged, eCChanged, eBCChanged, // conflict eBCChangedAndEqual, // possible conflict eBDeleted, eCDeleted, eBCDeleted, // possible conflict eBChanged_CDeleted, // conflict eCChanged_BDeleted, // conflict eBAdded, eCAdded, eBCAdded, // conflict eBCAddedAndEqual // possible conflict }; void mergeOneLine( const Diff3Line& d, e_MergeDetails& mergeDetails, bool& bConflict, bool& bLineRemoved, int& src, bool bTwoInputs ); enum e_MergeSrcSelector { A=1, B=2, C=3 }; class MergeResultWindow : public QWidget { Q_OBJECT public: - MergeResultWindow( - QWidget* pParent, - Options* pOptions, - QStatusBar* pStatusBar - ); + MergeResultWindow(QWidget* pParent, Options* pOptions, QStatusBar* pStatusBar); void init( const LineData* pLineDataA, LineRef sizeA, const LineData* pLineDataB, LineRef sizeB, const LineData* pLineDataC, LineRef sizeC, const Diff3LineList* pDiff3LineList, const QSharedPointer& pTotalDiffStatus ); void reset(); bool saveDocument( const QString& fileName, QTextCodec* pEncoding, e_LineEndStyle eLineEndStyle ); int getNrOfUnsolvedConflicts(int* pNrOfWhiteSpaceConflicts=nullptr); void choose(int selector); void chooseGlobal(int selector, bool bConflictsOnly, bool bWhiteSpaceOnly ); int getMaxTextWidth(); // width of longest text line int getNofLines(); int getVisibleTextAreaWidth(); // text area width without the border int getNofVisibleLines(); QString getSelection(); void resetSelection(); void showNrOfConflicts(); bool isDeltaAboveCurrent(); bool isDeltaBelowCurrent(); bool isConflictAboveCurrent(); bool isConflictBelowCurrent(); bool isUnsolvedConflictAtCurrent(); bool isUnsolvedConflictAboveCurrent(); bool isUnsolvedConflictBelowCurrent(); bool findString( const QString& s, int& d3vLine, int& posInLine, bool bDirDown, bool bCaseSensitive ); void setSelection( int firstLine, int startPos, int lastLine, int endPos ); void setOverviewMode( Overview::e_OverviewMode eOverviewMode ); Overview::e_OverviewMode getOverviewMode(); public Q_SLOTS: void setFirstLine(int firstLine); void setHorizScrollOffset(int horizScrollOffset); void slotGoCurrent(); void slotGoTop(); void slotGoBottom(); void slotGoPrevDelta(); void slotGoNextDelta(); void slotGoPrevUnsolvedConflict(); void slotGoNextUnsolvedConflict(); void slotGoPrevConflict(); void slotGoNextConflict(); void slotAutoSolve(); void slotUnsolve(); void slotMergeHistory(); void slotRegExpAutoMerge(); void slotSplitDiff( int firstD3lLineIdx, int lastD3lLineIdx ); void slotJoinDiffs( int firstD3lLineIdx, int lastD3lLineIdx ); void slotSetFastSelectorLine(int); void setPaintingAllowed(bool); void updateSourceMask(); void slotStatusMessageChanged( const QString& ); Q_SIGNALS: void scrollMergeResultWindow( int deltaX, int deltaY ); void modifiedChanged(bool bModified); void setFastSelectorRange( int line1, int nofLines ); void sourceMask( int srcMask, int enabledMask ); void resizeSignal(); void selectionEnd(); void newSelection(); void updateAvailabilities(); void showPopupMenu( const QPoint& point ); void noRelevantChangesDetected(); private: void merge(bool bAutoSolve, int defaultSelector, bool bConflictsOnly=false, bool bWhiteSpaceOnly=false ); QString getString( int lineIdx ); Options* m_pOptions; const LineData* m_pldA; const LineData* m_pldB; const LineData* m_pldC; LineRef m_sizeA; LineRef m_sizeB; LineRef m_sizeC; const Diff3LineList* m_pDiff3LineList; QSharedPointer m_pTotalDiffStatus; bool m_bPaintingAllowed; int m_delayedDrawTimer; Overview::e_OverviewMode m_eOverviewMode; QString m_persistentStatusMessage; void showUnsolvedConflictsStatusMessage(); private: class MergeEditLine { public: - MergeEditLine(Diff3LineList::const_iterator i, int src=0){m_id3l=i; m_src=src; m_bLineRemoved=false; } + explicit MergeEditLine(Diff3LineList::const_iterator i, int src=0){m_id3l=i; m_src=src; m_bLineRemoved=false; } void setConflict() { m_src=0; m_bLineRemoved=false; m_str=QString(); } bool isConflict() { return m_src==0 && !m_bLineRemoved && m_str.isEmpty(); } void setRemoved(int src=0) { m_src=src; m_bLineRemoved=true; m_str=QString(); } bool isRemoved() { return m_bLineRemoved; } bool isEditableText() { return !isConflict() && !isRemoved(); } void setString( const QString& s ){ m_str=s; m_bLineRemoved=false; m_src=0; } QString getString( const MergeResultWindow* ); bool isModified() { return ! m_str.isEmpty() || (m_bLineRemoved && m_src==0); } void setSource( int src, bool bLineRemoved ) { m_src=src; m_bLineRemoved =bLineRemoved; } int src() { return m_src; } Diff3LineList::const_iterator id3l(){return m_id3l;} // getString() is implemented as MergeResultWindow::getString() private: Diff3LineList::const_iterator m_id3l; int m_src; // 1, 2 or 3 for A, B or C respectively, or 0 when line is from neither source. QString m_str; // String when modified by user or null-string when orig data is used. bool m_bLineRemoved; }; class MergeEditLineList : private std::list { // I want to know the size immediately! private: typedef std::list BASE; int m_size; int* m_pTotalSize; public: typedef std::list::iterator iterator; typedef std::list::reverse_iterator reverse_iterator; typedef std::list::const_iterator const_iterator; MergeEditLineList(){m_size=0; m_pTotalSize=nullptr; } void clear() { ds(-m_size); BASE::clear(); } void push_back( const MergeEditLine& m) { ds(+1); BASE::push_back(m); } void push_front( const MergeEditLine& m) { ds(+1); BASE::push_front(m); } void pop_back() { ds(-1); BASE::pop_back(); } iterator erase( iterator i ) { ds(-1); return BASE::erase(i); } iterator insert( iterator i, const MergeEditLine& m ) { ds(+1); return BASE::insert(i,m); } int size(){ if (!m_pTotalSize) m_size = (int) BASE::size(); return m_size; } iterator begin(){return BASE::begin();} iterator end(){return BASE::end();} reverse_iterator rbegin(){return BASE::rbegin();} reverse_iterator rend(){return BASE::rend();} MergeEditLine& front(){return BASE::front();} MergeEditLine& back(){return BASE::back();} bool empty() { return m_size==0; } void splice(iterator destPos, MergeEditLineList& srcList, iterator srcFirst, iterator srcLast) { int* pTotalSize = getTotalSizePtr() ? getTotalSizePtr() : srcList.getTotalSizePtr(); srcList.setTotalSizePtr(nullptr); // Force size-recalc after splice, because splice doesn't handle size-tracking setTotalSizePtr(nullptr); BASE::splice( destPos, srcList, srcFirst, srcLast ); srcList.setTotalSizePtr( pTotalSize ); setTotalSizePtr( pTotalSize ); } void setTotalSizePtr(int* pTotalSize) { if ( pTotalSize==nullptr && m_pTotalSize!=nullptr ) { *m_pTotalSize -= size(); } else if ( pTotalSize!=nullptr && m_pTotalSize==nullptr ) { *pTotalSize += size(); } m_pTotalSize = pTotalSize; } int* getTotalSizePtr() { return m_pTotalSize; } private: void ds(int deltaSize) { m_size+=deltaSize; if (m_pTotalSize!=nullptr) *m_pTotalSize+=deltaSize; } }; friend class MergeEditLine; struct MergeLine { MergeLine() { srcSelect=0; mergeDetails=eDefault; d3lLineIdx = -1; srcRangeLength=0; bConflict=false; bDelta=false; bWhiteSpaceConflict=false; } Diff3LineList::const_iterator id3l; int d3lLineIdx; // Needed to show the correct window pos. int srcRangeLength; // how many src-lines have this properties e_MergeDetails mergeDetails; bool bConflict; bool bWhiteSpaceConflict; bool bDelta; int srcSelect; MergeEditLineList mergeEditLineList; void split( MergeLine& ml2, int d3lLineIdx2 ) // The caller must insert the ml2 after this ml in the m_mergeLineList { if ( d3lLineIdx2= d3lLineIdx + srcRangeLength ) return; //Error ml2.mergeDetails = mergeDetails; ml2.bConflict = bConflict; ml2.bWhiteSpaceConflict = bWhiteSpaceConflict; ml2.bDelta = bDelta; ml2.srcSelect = srcSelect; ml2.d3lLineIdx = d3lLineIdx2; ml2.srcRangeLength = srcRangeLength - (d3lLineIdx2-d3lLineIdx); srcRangeLength = d3lLineIdx2-d3lLineIdx; // current MergeLine controls fewer lines ml2.id3l = id3l; for(int i=0; iid3l()==ml2.id3l) { ml2.mergeEditLineList.splice( ml2.mergeEditLineList.begin(), mergeEditLineList, i, mergeEditLineList.end() ); return; } } ml2.mergeEditLineList.setTotalSizePtr( mergeEditLineList.getTotalSizePtr() ); ml2.mergeEditLineList.push_back(MergeEditLine(ml2.id3l)); } void join( MergeLine& ml2 ) // The caller must remove the ml2 from the m_mergeLineList after this call { srcRangeLength += ml2.srcRangeLength; ml2.mergeEditLineList.clear(); mergeEditLineList.clear(); mergeEditLineList.push_back(MergeEditLine(id3l)); // Create a simple conflict if ( ml2.bConflict ) bConflict = true; if ( !ml2.bWhiteSpaceConflict ) bWhiteSpaceConflict = false; if ( ml2.bDelta ) bDelta = true; } }; private: static bool sameKindCheck( const MergeLine& ml1, const MergeLine& ml2 ); struct HistoryMapEntry { MergeEditLineList mellA; MergeEditLineList mellB; MergeEditLineList mellC; MergeEditLineList& choice( bool bThreeInputs ); bool staysInPlace( bool bThreeInputs, Diff3LineList::const_iterator& iHistoryEnd ); }; typedef std::map HistoryMap; void collectHistoryInformation( int src, Diff3LineList::const_iterator iHistoryBegin, Diff3LineList::const_iterator iHistoryEnd, HistoryMap& historyMap, std::list< HistoryMap::iterator >& hitList ); typedef std::list MergeLineList; MergeLineList m_mergeLineList; MergeLineList::iterator m_currentMergeLineIt; bool isItAtEnd( bool bIncrement, MergeLineList::iterator i ) { if ( bIncrement ) return i!=m_mergeLineList.end(); else return i!=m_mergeLineList.begin(); } int m_currentPos; bool checkOverviewIgnore(MergeLineList::iterator &i); enum e_Direction { eUp, eDown }; enum e_EndPoint { eDelta, eConflict, eUnsolvedConflict, eLine, eEnd }; void go( e_Direction eDir, e_EndPoint eEndPoint ); void calcIteratorFromLineNr( int line, MergeLineList::iterator& mlIt, MergeEditLineList::iterator& melIt ); MergeLineList::iterator splitAtDiff3LineIdx( int d3lLineIdx ); void paintEvent( QPaintEvent* e ) override; int getTextXOffset(); QVector getTextLayoutForLine(int line, const QString& s, QTextLayout& textLayout ); void myUpdate(int afterMilliSecs); void timerEvent(QTimerEvent*) override; void writeLine( MyPainter& p, int line, const QString& str, int srcSelect, e_MergeDetails mergeDetails, int rangeMark, bool bUserModified, bool bLineRemoved, bool bWhiteSpaceConflict ); void setFastSelector(MergeLineList::iterator i); int convertToLine( int y ); bool event(QEvent*) override; void mousePressEvent ( QMouseEvent* e ) override; void mouseDoubleClickEvent ( QMouseEvent* e ) override; void mouseReleaseEvent ( QMouseEvent * ) override; void mouseMoveEvent ( QMouseEvent * ) override; void resizeEvent( QResizeEvent* e ) override; void keyPressEvent( QKeyEvent* e ) override; void wheelEvent( QWheelEvent* e ) override; void focusInEvent( QFocusEvent* e ) override; QPixmap m_pixmap; int m_firstLine; int m_horizScrollOffset; int m_nofLines; int m_totalSize; //Same as m_nofLines, but calculated differently int m_maxTextWidth; bool m_bMyUpdate; bool m_bInsertMode; bool m_bModified; void setModified(bool bModified=true); int m_scrollDeltaX; int m_scrollDeltaY; int m_cursorXPos; int m_cursorXPixelPos; int m_cursorYPos; int m_cursorOldXPixelPos; bool m_bCursorOn; // blinking on and off each second QTimer m_cursorTimer; bool m_bCursorUpdate; QStatusBar* m_pStatusBar; Selection m_selection; bool deleteSelection2( QString& str, int& x, int& y, MergeLineList::iterator& mlIt, MergeEditLineList::iterator& melIt ); bool doRelevantChangesExist(); public Q_SLOTS: void deleteSelection(); void pasteClipboard(bool bFromSelection); private Q_SLOTS: void slotCursorUpdate(); }; class QLineEdit; class QTextCodec; class QComboBox; class QLabel; class WindowTitleWidget : public QWidget { Q_OBJECT private: QLabel* m_pLabel; QLineEdit* m_pFileNameLineEdit; //QPushButton* m_pBrowseButton; QLabel* m_pModifiedLabel; QLabel* m_pLineEndStyleLabel; QComboBox* m_pLineEndStyleSelector; QLabel* m_pEncodingLabel; QComboBox* m_pEncodingSelector; Options* m_pOptions; public: explicit WindowTitleWidget(Options* pOptions); QTextCodec* getEncoding(); void setFileName(const QString& fileName ); QString getFileName(); void setEncodings( QTextCodec* pCodecForA, QTextCodec* pCodecForB, QTextCodec* pCodecForC ); void setEncoding( QTextCodec* pCodec ); void setLineEndStyles( e_LineEndStyle eLineEndStyleA, e_LineEndStyle eLineEndStyleB, e_LineEndStyle eLineEndStyleC); e_LineEndStyle getLineEndStyle(); bool eventFilter( QObject* o, QEvent* e ) override; public Q_SLOTS: void slotSetModified( bool bModified ); //private Q_SLOTS: // void slotBrowseButtonClicked(); }; #endif diff --git a/src/optiondialog.h b/src/optiondialog.h index 7b3acbb..79540ee 100644 --- a/src/optiondialog.h +++ b/src/optiondialog.h @@ -1,132 +1,132 @@ /* * kdiff3 - Text Diff And Merge Tool * Copyright (C) 2002-2007 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #ifndef OPTION_DIALOG_H #define OPTION_DIALOG_H #include #include #include #include #include "options.h" class QLabel; class QPlainTextEdit; class OptionItem; class OptionCheckBox; class OptionEncodingComboBox; class OptionLineEdit; class KKeyDialog; class OptionDialog : public KPageDialog { Q_OBJECT public: - OptionDialog( bool bShowDirMergeSettings, QWidget *parent = nullptr ); + explicit OptionDialog( bool bShowDirMergeSettings, QWidget *parent = nullptr ); ~OptionDialog( void ) override; QString parseOptions( const QStringList& optionList ); QString calcOptionHelp(); Options m_options; void saveOptions(KSharedConfigPtr config); void readOptions(KSharedConfigPtr config); void setState(); // Must be called before calling exec(); void addOptionItem(OptionItem*); KKeyDialog* m_pKeyDialog; protected Q_SLOTS: virtual void slotDefault( void ); virtual void slotOk( void ); virtual void slotApply( void ); //virtual void buttonClicked( QAbstractButton* ); virtual void helpRequested(); void slotEncodingChanged(); void slotHistoryMergeRegExpTester(); Q_SIGNALS: void applyDone(); private: void resetToDefaults(); std::list m_optionItemList; //QDialogButtonBox *mButtonBox; OptionCheckBox* m_pSameEncoding; OptionEncodingComboBox* m_pEncodingAComboBox; OptionCheckBox* m_pAutoDetectUnicodeA; OptionEncodingComboBox* m_pEncodingBComboBox; OptionCheckBox* m_pAutoDetectUnicodeB; OptionEncodingComboBox* m_pEncodingCComboBox; OptionCheckBox* m_pAutoDetectUnicodeC; OptionEncodingComboBox* m_pEncodingOutComboBox; OptionCheckBox* m_pAutoSelectOutEncoding; OptionEncodingComboBox* m_pEncodingPPComboBox; OptionCheckBox* m_pHistoryAutoMerge; OptionLineEdit* m_pAutoMergeRegExpLineEdit; OptionLineEdit* m_pHistoryStartRegExpLineEdit; OptionLineEdit* m_pHistoryEntryStartRegExpLineEdit; OptionCheckBox* m_pHistoryMergeSorting; OptionLineEdit* m_pHistorySortKeyOrderLineEdit; private: void setupFontPage(); void setupColorPage(); void setupEditPage(); void setupDiffPage(); void setupMergePage(); void setupDirectoryMergePage(); void setupKeysPage(); void setupRegionalPage(); void setupIntegrationPage(); void setupOtherOptions(); }; class FontChooser : public QGroupBox { Q_OBJECT QFont m_font; QPushButton* m_pSelectFont; QPlainTextEdit* m_pExampleTextEdit; QLabel* m_pLabel; public: explicit FontChooser( QWidget* pParent ); QFont font(); void setFont( const QFont&, bool ); private slots: void slotSelectFont(); }; #endif diff --git a/src/smalldialogs.h b/src/smalldialogs.h index 224997b..2ddc26c 100644 --- a/src/smalldialogs.h +++ b/src/smalldialogs.h @@ -1,118 +1,118 @@ /*************************************************************************** * Copyright (C) 2005 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef SMALLDIALOGS_H #define SMALLDIALOGS_H #include class Options; class QComboBox; class QCheckBox; class QLineEdit; class OpenDialog : public QDialog { Q_OBJECT public: - OpenDialog( + OpenDialog(// krazy:exclude=explicit QWidget* pParent, const QString& n1, const QString& n2, const QString& n3, bool bMerge, const QString& outputName, const char* slotConfigure, Options* pOptions ); QComboBox* m_pLineA; QComboBox* m_pLineB; QComboBox* m_pLineC; QComboBox* m_pLineOut; QCheckBox* m_pMerge; void accept() override; bool eventFilter(QObject* o, QEvent* e) override; private: Options* m_pOptions; void selectURL( QComboBox* pLine, bool bDir, int i, bool bSave ); bool m_bInputFileNameChanged; private Q_SLOTS: void selectFileA(); void selectFileB(); void selectFileC(); void selectDirA(); void selectDirB(); void selectDirC(); void selectOutputName(); void selectOutputDir(); void internalSlot(int); void inputFilenameChanged(); void slotSwapCopyNames(QAction*); Q_SIGNALS: void internalSignal(bool); }; class FindDialog : public QDialog { Q_OBJECT public: explicit FindDialog(QWidget* pParent); void setVisible(bool) override; Q_SIGNALS: void findNext(); public: QLineEdit* m_pSearchString; QCheckBox* m_pSearchInA; QCheckBox* m_pSearchInB; QCheckBox* m_pSearchInC; QCheckBox* m_pSearchInOutput; QCheckBox* m_pCaseSensitive; int currentLine; int currentPos; int currentWindow; }; class RegExpTester : public QDialog { Q_OBJECT private: QLineEdit* m_pAutoMergeRegExpEdit; QLineEdit* m_pAutoMergeMatchResult; QLineEdit* m_pAutoMergeExampleEdit; QLineEdit* m_pHistoryStartRegExpEdit; QLineEdit* m_pHistoryStartMatchResult; QLineEdit* m_pHistoryStartExampleEdit; QLineEdit* m_pHistoryEntryStartRegExpEdit; QLineEdit* m_pHistorySortKeyOrderEdit; QLineEdit* m_pHistoryEntryStartExampleEdit; QLineEdit* m_pHistoryEntryStartMatchResult; QLineEdit* m_pHistorySortKeyResult; public: RegExpTester( QWidget* pParent, const QString& autoMergeRegExpToolTip, const QString& historyStartRegExpToolTip, const QString& historyEntryStartRegExpToolTip, const QString& historySortKeyOrderToolTip ); void init( const QString& autoMergeRegExp, const QString& historyStartRegExp, const QString& historyEntryStartRegExp, const QString sortKeyOrder ); QString autoMergeRegExp(); QString historyStartRegExp(); QString historyEntryStartRegExp(); QString historySortKeyOrder(); public Q_SLOTS: void slotRecalc(); }; #endif