summaryrefslogtreecommitdiffstats
path: root/src/kdiff3.h
blob: ff0ed8c613dee328b5d125bf5ef4284ff51c5f30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
/***************************************************************************
                          kdiff3.h  -  description
                             -------------------
    begin                : Don Jul 11 12:31:29 CEST 2002
    copyright            : (C) 2002-2007 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 KDIFF3_H
#define KDIFF3_H

#include "diff.h"

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

// include files for TQt
#include <tqdialog.h>
#include <tqsplitter.h>
#include <tqscrollbar.h>

// include files for KDE
#include <kapplication.h>
#include <tdemainwindow.h>
#include <tdeaccel.h>
#include <tdeaction.h>
#include <kurl.h>
#include <tdeparts/mainwindow.h>


// forward declaration of the KDiff3 classes
class OptionDialog;
class FindDialog;
class ManualDiffHelpDialog;
class DiffTextWindow;
class DiffTextWindowFrame;
class MergeResultWindow;
class WindowTitleWidget;
class Overview;

class TQScrollBar;
class TQComboBox;
class TQLineEdit;
class TQCheckBox;
class TQSplitter;


class KDiff3Part;
class DirectoryMergeWindow;
class DirectoryMergeInfo;


class ReversibleScrollBar : public TQScrollBar
{
   Q_OBJECT
  
   bool* m_pbRightToLeftLanguage;
   int m_realVal;
public:
   ReversibleScrollBar( Qt::Orientation o, TQWidget* pParent, bool* pbRightToLeftLanguage )
      : TQScrollBar( o, pParent )
   {
      m_pbRightToLeftLanguage=pbRightToLeftLanguage;
      m_realVal=0;
      connect( this, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotValueChanged(int)));
   }
   void setAgain(){ setValue(m_realVal); }
public slots:
   void slotValueChanged(int i)
   {
      m_realVal = i;
      if(m_pbRightToLeftLanguage && *m_pbRightToLeftLanguage)
         m_realVal = maxValue()-(i-minValue());
      emit valueChanged2(m_realVal);
   }
   void setValue(int i)
   {
      if(m_pbRightToLeftLanguage && *m_pbRightToLeftLanguage)
         TQScrollBar::setValue( maxValue()-(i-minValue())  );
      else
         TQScrollBar::setValue( i );
   }
signals:
   void valueChanged2(int);
};

class KDiff3App : public TQSplitter
{
  Q_OBJECT
  

  public:
    /** constructor of KDiff3App, calls all init functions to create the application.
     */
    KDiff3App( TQWidget* parent, const char* name, KDiff3Part* pKDiff3Part );
    ~KDiff3App();

    bool isPart();

    /** initializes the TDEActions of the application */
    void initActions( TDEActionCollection* );

    /** save general Options like all bar positions and status as well as the geometry
        and the recent file list to the configuration file */
    void saveOptions( TDEConfig* );

    /** read general Options again and initialize all variables like the recent file list */
    void readOptions( TDEConfig* );

    // Finish initialisation (virtual, so that it can be called from the shell too.)
    virtual void completeInit(const TQString& fn1="", const TQString& fn2="", const TQString& fn3="");

    /** queryClose is called by TDEMainWindow on each closeEvent of a window. Against the
     * default implementation (only returns true), this calles saveModified() on the document object to ask if the document shall
     * be saved if Modified; on cancel the closeEvent is rejected.
     * @see TDEMainWindow#queryClose
     * @see TDEMainWindow#closeEvent
     */
    virtual bool queryClose();
    virtual bool isFileSaved();

  signals:
     void createNewInstance( const TQString& fn1, const TQString& fn2, const TQString& fn3 );
  protected:
    void initDirectoryMergeActions();
    /** sets up the statusbar for the main window by initialzing a statuslabel. */
    void initStatusBar();

    /** creates the centerwidget of the TDEMainWindow instance and sets it as the view */
    void initView();

  public slots:

    /** open a file and load it into the document*/
    void slotFileOpen();
    void slotFileOpen2( TQString fn1, TQString fn2, TQString fn3, TQString ofn,
                        TQString an1, TQString an2, TQString an3, TotalDiffStatus* pTotalDiffStatus );

    void slotFileNameChanged(const TQString& fileName, int winIdx);

    /** save a document */
    void slotFileSave();
    /** save a document by a new filename*/
    void slotFileSaveAs();

    void slotFilePrint();

    /** closes all open windows by calling close() on each memberList item until the list is empty, then quits the application.
     * If queryClose() returns false because the user canceled the saveModified() dialog, the closing breaks.
     */
    void slotFileQuit();
    /** put the marked text/object into the clipboard and remove
     *  it from the document
     */
    void slotEditCut();
    /** put the marked text/object into the clipboard
     */
    void slotEditCopy();
    /** paste the clipboard into the document
     */
    void slotEditPaste();
    /** toggles the toolbar
     */
    void slotViewToolBar();
    /** toggles the statusbar
     */
    void slotViewStatusBar();
    /** changes the statusbar contents for the standard label permanently, used to indicate current actions.
     * @param text the text that is displayed in the statusbar
     */
    void slotStatusMsg(const TQString &text);

  private:
    /** the configuration object of the application */
    //TDEConfig *config;

    // TDEAction pointers to enable/disable actions
    TDEAction* fileOpen;
    TDEAction* fileSave;
    TDEAction* fileSaveAs;
    TDEAction* filePrint;
    TDEAction* fileQuit;
    TDEAction* fileReload;
    TDEAction* editCut;
    TDEAction* editCopy;
    TDEAction* editPaste;
    TDEAction* editSelectAll;
    TDEToggleAction* viewToolBar;
    TDEToggleAction* viewStatusBar;

////////////////////////////////////////////////////////////////////////
// Special KDiff3 specific stuff starts here
    TDEAction *editFind;
    TDEAction *editFindNext;

    TDEAction *goCurrent;
    TDEAction *goTop;
    TDEAction *goBottom;
    TDEAction *goPrevUnsolvedConflict;
    TDEAction *goNextUnsolvedConflict;
    TDEAction *goPrevConflict;
    TDEAction *goNextConflict;
    TDEAction *goPrevDelta;
    TDEAction *goNextDelta;
    TDEToggleAction *chooseA;
    TDEToggleAction *chooseB;
    TDEToggleAction *chooseC;
    TDEToggleAction *autoAdvance;
    TDEToggleAction *wordWrap;
    TDEAction* splitDiff;
    TDEAction* joinDiffs;
    TDEAction* addManualDiffHelp;
    TDEAction* clearManualDiffHelpList;
    TDEToggleAction *showWhiteSpaceCharacters;
    TDEToggleAction *showWhiteSpace;
    TDEToggleAction *showLineNumbers;
    TDEAction* chooseAEverywhere;
    TDEAction* chooseBEverywhere;
    TDEAction* chooseCEverywhere;
    TDEAction* chooseAForUnsolvedConflicts;
    TDEAction* chooseBForUnsolvedConflicts;
    TDEAction* chooseCForUnsolvedConflicts;
    TDEAction* chooseAForUnsolvedWhiteSpaceConflicts;
    TDEAction* chooseBForUnsolvedWhiteSpaceConflicts;
    TDEAction* chooseCForUnsolvedWhiteSpaceConflicts;
    TDEAction* autoSolve;
    TDEAction* unsolve;
    TDEAction* mergeHistory;
    TDEAction* mergeRegExp;
    TDEToggleAction *showWindowA;
    TDEToggleAction *showWindowB;
    TDEToggleAction *showWindowC;
    TDEAction *winFocusNext;
    TDEAction *winFocusPrev;
    TDEAction* winToggleSplitOrientation;
    TDEToggleAction *dirShowBoth;
    TDEAction *dirViewToggle;
    TDEToggleAction *overviewModeNormal;
    TDEToggleAction *overviewModeAB;
    TDEToggleAction *overviewModeAC;
    TDEToggleAction *overviewModeBC;


    TQPopupMenu* m_pMergeEditorPopupMenu;

    TQSplitter*  m_pMainSplitter;
    TQWidget*    m_pMainWidget;
    TQWidget*    m_pMergeWindowFrame;
    ReversibleScrollBar* m_pHScrollBar;
    TQScrollBar* m_pDiffVScrollBar;
    TQScrollBar* m_pMergeVScrollBar;

    DiffTextWindow* m_pDiffTextWindow1;
    DiffTextWindow* m_pDiffTextWindow2;
    DiffTextWindow* m_pDiffTextWindow3;
    DiffTextWindowFrame* m_pDiffTextWindowFrame1;
    DiffTextWindowFrame* m_pDiffTextWindowFrame2;
    DiffTextWindowFrame* m_pDiffTextWindowFrame3;
    TQSplitter* m_pDiffWindowSplitter;

    MergeResultWindow* m_pMergeResultWindow;
    WindowTitleWidget* m_pMergeResultWindowTitle;
    bool m_bTripleDiff;

    TQSplitter* m_pDirectoryMergeSplitter;
    DirectoryMergeWindow* m_pDirectoryMergeWindow;
    DirectoryMergeInfo* m_pDirectoryMergeInfo;
    bool m_bDirCompare;

    Overview* m_pOverview;

    TQWidget* m_pCornerWidget;

    TotalDiffStatus m_totalDiffStatus;

    SourceData m_sd1;
    SourceData m_sd2;
    SourceData m_sd3;

   TQString m_outputFilename;
   bool m_bDefaultFilename;

   DiffList m_diffList12;
   DiffList m_diffList23;
   DiffList m_diffList13;

   DiffBufferInfo m_diffBufferInfo;
   Diff3LineList m_diff3LineList;
   Diff3LineVector m_diff3LineVector;
   //ManualDiffHelpDialog* m_pManualDiffHelpDialog;
   ManualDiffHelpList m_manualDiffHelpList;

   int m_neededLines;
   int m_maxWidth;
   int m_DTWHeight;
   bool m_bOutputModified;
   bool m_bFileSaved;
   bool m_bTimerBlock;      // Synchronisation

   OptionDialog* m_pOptionDialog;
   FindDialog*   m_pFindDialog;

   void init( bool bAuto=false, TotalDiffStatus* pTotalDiffStatus=0, bool bLoadFiles=true );

   virtual bool eventFilter( TQObject* o, TQEvent* e );
   virtual void resizeEvent(TQResizeEvent*);

   bool improveFilenames(bool bCreateNewInstance);

   bool runDiff( const LineData* p1, int size1, const LineData* p2, int size2, DiffList& diffList, int winIdx1, int winIdx2 );
   bool runDiff( const LineData* p1, int size1, const LineData* p2, int size2, DiffList& diffList );
   bool canContinue();

   void choose(int choice);

   TDEActionCollection* actionCollection();
   KStatusBar*        statusBar();
   TDEToolBar*          toolBar(const char*);
   KDiff3Part*        m_pKDiff3Part;
   KParts::MainWindow*       m_pKDiff3Shell;
   bool m_bAutoFlag;
   bool m_bAutoMode;
   void recalcWordWrap(int nofVisibleColumns=-1);

public slots:
   void resizeDiffTextWindow(int newWidth, int newHeight);
   void resizeMergeResultWindow();
   void slotRecalcWordWrap();

   void showPopupMenu( const TQPoint& point );

   void scrollDiffTextWindow( int deltaX, int deltaY );
   void scrollMergeResultWindow( int deltaX, int deltaY );
   void setDiff3Line( int line );
   void sourceMask( int srcMask, int enabledMask );

   void slotDirShowBoth();
   void slotDirViewToggle();

   void slotUpdateAvailabilities();
   void slotEditSelectAll();
   void slotEditFind();
   void slotEditFindNext();
   void slotGoCurrent();
   void slotGoTop();
   void slotGoBottom();
   void slotGoPrevUnsolvedConflict();
   void slotGoNextUnsolvedConflict();
   void slotGoPrevConflict();
   void slotGoNextConflict();
   void slotGoPrevDelta();
   void slotGoNextDelta();
   void slotChooseA();
   void slotChooseB();
   void slotChooseC();
   void slotAutoSolve();
   void slotUnsolve();
   void slotMergeHistory();
   void slotRegExpAutoMerge();
   void slotChooseAEverywhere();
   void slotChooseBEverywhere();
   void slotChooseCEverywhere();
   void slotChooseAForUnsolvedConflicts();
   void slotChooseBForUnsolvedConflicts();
   void slotChooseCForUnsolvedConflicts();
   void slotChooseAForUnsolvedWhiteSpaceConflicts();
   void slotChooseBForUnsolvedWhiteSpaceConflicts();
   void slotChooseCForUnsolvedWhiteSpaceConflicts();
   void slotConfigure();
   void slotConfigureKeys();
   void slotRefresh();
   void slotSelectionEnd();
   void slotSelectionStart();
   void slotClipboardChanged();
   void slotOutputModified(bool);
   void slotAfterFirstPaint();
   void slotMergeCurrentFile();
   void slotReload();
   void slotCheckIfCanContinue( bool* pbContinue );
   void slotShowWhiteSpaceToggled();
   void slotShowLineNumbersToggled();
   void slotAutoAdvanceToggled();
   void slotWordWrapToggled();
   void slotShowWindowAToggled();
   void slotShowWindowBToggled();
   void slotShowWindowCToggled();
   void slotWinFocusNext();
   void slotWinFocusPrev();
   void slotWinToggleSplitterOrientation();
   void slotOverviewNormal();
   void slotOverviewAB();
   void slotOverviewAC();
   void slotOverviewBC();
   void slotSplitDiff();
   void slotJoinDiffs();
   void slotAddManualDiffHelp();
   void slotClearManualDiffHelpList();

   void slotNoRelevantChangesDetected();
};

#endif // KDIFF3_H