2009-10-25 10:43:16 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file Compare.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Vincent van Ravesteijn
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef COMPARE_H
|
|
|
|
#define COMPARE_H
|
|
|
|
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
|
|
|
#include "support/FileName.h"
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QThread>
|
2010-01-14 00:41:47 +00:00
|
|
|
#include <QTimer>
|
2009-10-25 10:43:16 +00:00
|
|
|
#include <QWaitCondition>
|
|
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The options that are used by the Comparison algorithm
|
|
|
|
* and are set in the GuiCompare Dialog.
|
|
|
|
*/
|
|
|
|
class CompareOptions {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
CompareOptions()
|
|
|
|
: settings_from_new(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/// Copy the settings from the new or old document
|
|
|
|
bool settings_from_new;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A threaded object that does the Comparison between two documents
|
|
|
|
* and creates a new document with the differences marked with track
|
|
|
|
* changes.
|
|
|
|
*/
|
|
|
|
class Compare : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
Compare(Buffer const * const old_buf, Buffer const * const new_buf,
|
|
|
|
Buffer * const dest_buf, CompareOptions const & options);
|
|
|
|
|
|
|
|
///
|
|
|
|
~Compare() {
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
2009-10-25 13:41:46 +00:00
|
|
|
/// The thread has finished due to an error.
|
|
|
|
void error() const;
|
|
|
|
|
2009-10-25 10:43:16 +00:00
|
|
|
/// The thread has finished. If the thread is cancelled
|
2009-10-25 13:41:46 +00:00
|
|
|
/// by the user \c aborted is true.
|
2009-10-25 10:43:16 +00:00
|
|
|
void finished(bool aborted) const;
|
|
|
|
|
|
|
|
/// Adds \c progress to the value of the progress bar in the dialog
|
|
|
|
void progress(int progress) const ;
|
|
|
|
|
|
|
|
/// Sets the maximum value of the progress bar in the dialog.
|
|
|
|
void progressMax(int max) const;
|
|
|
|
|
2010-01-14 00:41:47 +00:00
|
|
|
/// A message describing the process
|
|
|
|
void statusMessage(QString msg) const;
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
/// Emits the status message signal
|
|
|
|
void doStatusMessage();
|
|
|
|
|
2009-10-25 10:43:16 +00:00
|
|
|
public:
|
2010-01-27 18:10:33 +00:00
|
|
|
/// \name QThread inherited methods
|
2009-10-25 10:43:16 +00:00
|
|
|
//@{
|
|
|
|
void run();
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/// Aborts the thread
|
|
|
|
void abort();
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// Starts the comparison algorithm
|
|
|
|
int doCompare();
|
|
|
|
|
|
|
|
/// The new document's buffer
|
|
|
|
Buffer const * const new_buffer;
|
2009-11-02 15:20:36 +00:00
|
|
|
/// The old document's buffer
|
|
|
|
Buffer const * const old_buffer;
|
|
|
|
/// The buffer with the differences marked with track changes
|
|
|
|
Buffer * const dest_buffer;
|
2009-10-25 10:43:16 +00:00
|
|
|
|
|
|
|
/// The options that are set in the GuiCompare dialog
|
|
|
|
CompareOptions options_;
|
|
|
|
|
|
|
|
///
|
|
|
|
QWaitCondition condition_;
|
|
|
|
|
2010-01-14 00:41:47 +00:00
|
|
|
/// Emit a statusMessage signal from time to time
|
|
|
|
QTimer status_timer_;
|
|
|
|
|
2009-10-25 10:43:16 +00:00
|
|
|
/// Use the Pimpl idiom to hide the internals.
|
|
|
|
class Impl;
|
|
|
|
///
|
|
|
|
Impl * pimpl_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif
|