]> git.lyx.org Git - lyx.git/blob - src/Compare.h
Remove updateInfo() calls in favor of doing the relevant work
[lyx.git] / src / Compare.h
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.
6  *
7  * \author Vincent van Ravesteijn
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef COMPARE_H
13 #define COMPARE_H
14
15 #include "Buffer.h"
16
17 #include <QObject>
18 #include <QThread>
19 #include <QTimer>
20 #include <QWaitCondition>
21
22
23 namespace lyx {
24
25 /**
26  * The options that are used by the Comparison algorithm
27  * and are set in the GuiCompare Dialog.
28  */
29 class CompareOptions {
30 public:
31         ///
32         CompareOptions()
33                 : settings_from_new(0)
34         {}
35
36         /// Copy the settings from the new or old document
37         bool settings_from_new;
38 };
39
40 /**
41  * A threaded object that does the Comparison between two documents
42  * and creates a new document with the differences marked with track
43  * changes.
44  */
45 class Compare : public QThread
46 {
47         Q_OBJECT
48
49 public:
50         ///
51         Compare(Buffer const * const old_buf, Buffer const * const new_buf,
52                 Buffer * const dest_buf, CompareOptions const & options);
53
54         ///
55         ~Compare() {
56                 abort();
57         }
58
59 Q_SIGNALS:
60         /// The thread has finished due to an error.
61         void error() const;
62
63         /// The thread has finished. If the thread is cancelled
64         /// by the user \c aborted is true.
65         void finished(bool aborted) const;
66
67         /// Adds \c progress to the value of the progress bar in the dialog
68         void progress(int progress) const ;
69
70         /// Sets the maximum value of the progress bar in the dialog.
71         void progressMax(int max) const;
72
73         /// A message describing the process
74         void statusMessage(QString msg) const;
75
76 public Q_SLOTS:
77         /// Emits the status message signal
78         void doStatusMessage();
79
80 public:
81         /// \name QThread inherited methods
82         //@{
83         void run();
84         //@}
85
86         /// Aborts the thread
87         void abort();
88
89 private:
90         /// Starts the comparison algorithm
91         int doCompare();
92
93         /// The new document's buffer
94         Buffer const * const new_buffer;
95         /// The old document's buffer
96         Buffer const * const old_buffer;
97         /// The buffer with the differences marked with track changes
98         Buffer * const dest_buffer;
99
100         /// The options that are set in the GuiCompare dialog
101         CompareOptions options_;
102
103         ///
104         QWaitCondition condition_;
105
106         /// Emit a statusMessage signal from time to time
107         QTimer status_timer_;
108
109         /// Use the Pimpl idiom to hide the internals.
110         class Impl;
111         ///
112         Impl * pimpl_;
113 };
114
115
116 } // namespace lyx
117
118 #endif