tufte layout files:
[lyx.git] / src / Compare.h
blobf2583aebaa87346b42c29091fed9a9090ff12ca4
1 // -*- C++ -*-
2 /**
3 * \file Compare.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Vincent van Ravesteijn
9 * Full author contact details are available in file CREDITS.
12 #ifndef COMPARE_H
13 #define COMPARE_H
15 #include "Buffer.h"
17 #include "support/FileName.h"
19 #include <string>
21 #include <QObject>
22 #include <QThread>
23 #include <QWaitCondition>
26 namespace lyx {
28 /**
29 * The options that are used by the Comparison algorithm
30 * and are set in the GuiCompare Dialog.
32 class CompareOptions {
33 public:
34 ///
35 CompareOptions()
36 : settings_from_new(0)
39 /// Copy the settings from the new or old document
40 bool settings_from_new;
43 /**
44 * A threaded object that does the Comparison between two documents
45 * and creates a new document with the differences marked with track
46 * changes.
48 class Compare : public QThread
50 Q_OBJECT
52 public:
53 ///
54 Compare(Buffer const * const old_buf, Buffer const * const new_buf,
55 Buffer * const dest_buf, CompareOptions const & options);
57 ///
58 ~Compare() {
59 abort();
62 Q_SIGNALS:
63 /// The thread has finished due to an error.
64 void error() const;
66 /// The thread has finished. If the thread is cancelled
67 /// by the user \c aborted is true.
68 void finished(bool aborted) const;
70 /// Adds \c progress to the value of the progress bar in the dialog
71 void progress(int progress) const ;
73 /// Sets the maximum value of the progress bar in the dialog.
74 void progressMax(int max) const;
76 public:
77 /// QThread inherited methods
78 //@{
79 void run();
80 //@}
82 /// Aborts the thread
83 void abort();
85 private:
86 /// Starts the comparison algorithm
87 int doCompare();
89 /// The new document's buffer
90 Buffer const * const new_buffer;
91 /// The old document's buffer
92 Buffer const * const old_buffer;
93 /// The buffer with the differences marked with track changes
94 Buffer * const dest_buffer;
96 /// The options that are set in the GuiCompare dialog
97 CompareOptions options_;
99 ///
100 QWaitCondition condition_;
102 /// Use the Pimpl idiom to hide the internals.
103 class Impl;
105 Impl * pimpl_;
109 } // namespace lyx
111 #endif