]> git.lyx.org Git - lyx.git/blob - src/Compare.h
Output keys with bibliography, too.
[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 "support/FileName.h"
18
19 #include <string>
20
21 #include <QObject>
22 #include <QThread>
23 #include <QWaitCondition>
24
25
26 namespace lyx {
27
28 /** 
29  * The options that are used by the Comparison algorithm
30  * and are set in the GuiCompare Dialog.
31  */
32 class CompareOptions {
33 public:
34         ///
35         CompareOptions()
36                 : settings_from_new(0)
37         {}
38         
39         /// Copy the settings from the new or old document
40         bool settings_from_new;
41 };
42
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.
47  */
48 class Compare : public QThread
49 {
50         Q_OBJECT
51
52 public:
53         ///
54         Compare(Buffer const * const old_buf, Buffer const * const new_buf,
55                 Buffer * const dest_buf, CompareOptions const & options);
56
57         ///
58         ~Compare() {
59                 abort();
60         }
61
62 Q_SIGNALS:
63         /// The thread has finished due to an error.
64         void error() const;
65
66         /// The thread has finished. If the thread is cancelled
67         /// by the user \c aborted is true.
68         void finished(bool aborted) const;
69
70         /// Adds \c progress to the value of the progress bar in the dialog
71         void progress(int progress) const ;
72
73         /// Sets the maximum value of the progress bar in the dialog.
74         void progressMax(int max) const;
75
76 public:
77         /// QThread inherited methods
78         //@{
79         void run();
80         //@}
81
82         /// Aborts the thread
83         void abort();
84
85 private:
86         /// Starts the comparison algorithm
87         int doCompare();
88         
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;
95         
96         /// The options that are set in the GuiCompare dialog
97         CompareOptions options_;
98
99         ///
100         QWaitCondition condition_;
101
102         /// Use the Pimpl idiom to hide the internals.
103         class Impl;
104         ///
105         Impl * pimpl_;
106 };
107
108
109 } // namespace lyx
110
111 #endif