mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Compare: Add a statusbar to the dialog and show a message every second. The message now shows at which recursion level the algorithm is and which D-path it is currently processing.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33018 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7c083bae07
commit
d378b5d8ee
@ -18,6 +18,7 @@
|
||||
#include "insets/InsetText.h"
|
||||
|
||||
#include "support/lassert.h"
|
||||
#include "support/qstring_helpers.h"
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
@ -219,7 +220,7 @@ class Compare::Impl {
|
||||
public:
|
||||
///
|
||||
Impl(Compare const & compare)
|
||||
: abort_(false), compare_(compare)
|
||||
: abort_(false), compare_(compare), recursion_level_(0), D_(0)
|
||||
{}
|
||||
|
||||
///
|
||||
@ -234,6 +235,14 @@ public:
|
||||
/// Set to true to cancel the algorithm
|
||||
bool abort_;
|
||||
|
||||
///
|
||||
QString status() {
|
||||
QString status;
|
||||
status += toqstr("recursion level:") + " " + QString::number(recursion_level_)
|
||||
+ " " + toqstr("differences:") + " " + QString::number(D_);
|
||||
return status;
|
||||
}
|
||||
|
||||
private:
|
||||
/// Finds the middle snake and returns the length of the
|
||||
/// shortest edit script.
|
||||
@ -322,6 +331,10 @@ private:
|
||||
compl_vector<DocIterator> nrp;
|
||||
compl_vector<DocIterator> ors;
|
||||
compl_vector<DocIterator> nrs;
|
||||
|
||||
/// The number of differences in the path the algorithm
|
||||
/// is currently processing.
|
||||
int D_;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -335,6 +348,15 @@ Compare::Compare(Buffer const * new_buf, Buffer const * old_buf,
|
||||
: new_buffer(new_buf), old_buffer(old_buf), dest_buffer(dest_buf),
|
||||
options_(options), pimpl_(new Impl(*this))
|
||||
{
|
||||
connect(&status_timer_, SIGNAL(timeout()),
|
||||
this, SLOT(doStatusMessage()));
|
||||
status_timer_.start(1000);
|
||||
}
|
||||
|
||||
|
||||
void Compare::doStatusMessage()
|
||||
{
|
||||
statusMessage(pimpl_->status());
|
||||
}
|
||||
|
||||
|
||||
@ -347,6 +369,8 @@ void Compare::run()
|
||||
dest_buffer->params() = options_.settings_from_new
|
||||
? new_buffer->params() : old_buffer->params();
|
||||
|
||||
doStatusMessage();
|
||||
|
||||
// do the real work
|
||||
if (!doCompare())
|
||||
return;
|
||||
@ -605,6 +629,8 @@ int Compare::Impl::findMiddleSnake(DocRangePair const & rp,
|
||||
// different characters in the old and new chunk.
|
||||
int const D_max = ceil(((double)M_ + N_)/2);
|
||||
for (int D = 0; D <= D_max; ++D) {
|
||||
// to be used in the status messages
|
||||
D_ = D;
|
||||
|
||||
// Forward and reverse paths
|
||||
for (int f = 0; f < 2; ++f) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include <QWaitCondition>
|
||||
|
||||
#include <string>
|
||||
@ -73,6 +74,13 @@ Q_SIGNALS:
|
||||
/// Sets the maximum value of the progress bar in the dialog.
|
||||
void progressMax(int max) const;
|
||||
|
||||
/// A message describing the process
|
||||
void statusMessage(QString msg) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
/// Emits the status message signal
|
||||
void doStatusMessage();
|
||||
|
||||
public:
|
||||
/// QThread inherited methods
|
||||
//@{
|
||||
@ -99,6 +107,9 @@ private:
|
||||
///
|
||||
QWaitCondition condition_;
|
||||
|
||||
/// Emit a statusMessage signal from time to time
|
||||
QTimer status_timer_;
|
||||
|
||||
/// Use the Pimpl idiom to hide the internals.
|
||||
class Impl;
|
||||
///
|
||||
|
@ -106,6 +106,7 @@ void GuiCompare::updateContents()
|
||||
newFileCB->clear();
|
||||
oldFileCB->clear();
|
||||
progressBar->setValue(0);
|
||||
statusBar->clearMessage();
|
||||
BufferList::iterator it = theBufferList().begin();
|
||||
BufferList::iterator const end = theBufferList().end();
|
||||
for (; it != end; ++it) {
|
||||
@ -211,6 +212,7 @@ void GuiCompare::finished(bool aborted)
|
||||
}
|
||||
setWindowTitle(window_title_);
|
||||
progressBar->setValue(0);
|
||||
statusBar->showMessage(qt_("Aborted"));
|
||||
} else {
|
||||
hideView();
|
||||
bc().ok();
|
||||
@ -218,6 +220,7 @@ void GuiCompare::finished(bool aborted)
|
||||
dispatch(FuncRequest(LFUN_BUFFER_SWITCH,
|
||||
dest_buffer_->absFileName()));
|
||||
}
|
||||
statusBar->showMessage(qt_("Finished"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,6 +237,13 @@ void GuiCompare::progressMax(int max) const
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GuiCompare::setStatusMessage(QString msg)
|
||||
{
|
||||
statusBar->showMessage(msg);
|
||||
}
|
||||
|
||||
|
||||
void GuiCompare::slotOK()
|
||||
{
|
||||
enableControls(false);
|
||||
@ -247,10 +257,12 @@ void GuiCompare::slotCancel()
|
||||
if (compare_ && compare_->isRunning()) {
|
||||
window_title_ = windowTitle();
|
||||
setWindowTitle(window_title_ + " " + qt_("(cancelling)"));
|
||||
statusBar->showMessage(qt_("Aborting process..."));
|
||||
compare_->abort();
|
||||
} else {
|
||||
GuiDialog::slotClose();
|
||||
progressBar->setValue(0);
|
||||
statusBar->clearMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,6 +311,8 @@ int GuiCompare::run()
|
||||
connect(compare_, SIGNAL(finished(bool)), this, SLOT(finished(bool)));
|
||||
connect(compare_, SIGNAL(progress(int)), this, SLOT(progress(int)));
|
||||
connect(compare_, SIGNAL(progressMax(int)), this, SLOT(progressMax(int)));
|
||||
connect(compare_, SIGNAL(statusMessage(QString)),
|
||||
this, SLOT(setStatusMessage(QString)));
|
||||
compare_->start(QThread::LowPriority);
|
||||
return 1;
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ private Q_SLOTS:
|
||||
void progress(int);
|
||||
///
|
||||
void progressMax(int) const;
|
||||
///
|
||||
void setStatusMessage(QString);
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -1,7 +1,7 @@
|
||||
<ui version="4.0" >
|
||||
<ui version="4.0">
|
||||
<class>CompareUi</class>
|
||||
<widget class="QDialog" name="CompareUi" >
|
||||
<property name="geometry" >
|
||||
<widget class="QDialog" name="CompareUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
@ -9,211 +9,233 @@
|
||||
<height>302</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="sizeGripEnabled" >
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
||||
<layout class="QVBoxLayout" name="verticalLayout_1">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="newFileLA" >
|
||||
<property name="text" >
|
||||
<string>&New Document:</string>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>newFileCB</cstring>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||
<item>
|
||||
<widget class="QComboBox" name="newFileCB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="newFilePB" >
|
||||
<property name="text" >
|
||||
<string>&Browse...</string>
|
||||
</property>
|
||||
<property name="autoDefault" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="oldFileLA" >
|
||||
<property name="text" >
|
||||
<string>&Old Document:</string>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>oldFileCB</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" >
|
||||
<item>
|
||||
<widget class="QComboBox" name="oldFileCB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="oldFilePB" >
|
||||
<property name="text" >
|
||||
<string>Bro&wse...</string>
|
||||
</property>
|
||||
<property name="autoDefault" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="newSettingsRB" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>151</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>New Document</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="oldSettingsRB" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>60</y>
|
||||
<width>151</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Old Document</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>237</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Copy Document Settings from:</string>
|
||||
</property>
|
||||
<property name="scaledContents" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="progressBar" >
|
||||
<property name="value" >
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<widget class="QLabel" name="newFileLA">
|
||||
<property name="text">
|
||||
<string>&New Document:</string>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okPB" >
|
||||
<property name="toolTip" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>true</bool>
|
||||
<property name="buddy">
|
||||
<cstring>newFileCB</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closePB" >
|
||||
<property name="text" >
|
||||
<string>&Close</string>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="newFileCB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="newFilePB">
|
||||
<property name="text">
|
||||
<string>&Browse...</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="oldFileLA">
|
||||
<property name="text">
|
||||
<string>&Old Document:</string>
|
||||
</property>
|
||||
<property name="autoDefault" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>false</bool>
|
||||
<property name="buddy">
|
||||
<cstring>oldFileCB</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QComboBox" name="oldFileCB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="oldFilePB">
|
||||
<property name="text">
|
||||
<string>Bro&wse...</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="newSettingsRB">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>151</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New Document</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="oldSettingsRB">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>60</y>
|
||||
<width>151</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Old Document</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>237</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copy Document Settings from:</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okPB">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closePB">
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<includes>
|
||||
<include location="local" >qt_i18n.h</include>
|
||||
<include location="local">qt_i18n.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
Loading…
Reference in New Issue
Block a user