GuiClipboard.h
GuiCommandBuffer.h
GuiCommandEdit.h
+ GuiCompare.h
GuiCompleter.h
GuiDelimiter.h
GuiDialog.h
GuiClipboard.cpp
GuiCommandBuffer.cpp
GuiCommandEdit.cpp
+ GuiCompare.cpp
GuiCompleter.cpp
GuiDelimiter.cpp
GuiDialog.cpp
Item "Statistics...|a" "statistics"
OptItem "Check TeX|h" "buffer-chktex"
Item "TeX Information|I" "dialog-show texinfo"
+ Item "Compare...|C" "dialog-show compare"
Separator
# A LOT of applications have Tools->Prefs. Remember this
# should be rarely used - Edit menu is not a good place to
* \li Action: Shows hidden dialog or create new one for a given function/inset settings etc.
* \li Syntax: dialog-show <NAME> [<DATA>]
* \li Params: <NAME>: aboutlyx|bibitem|bibtex|box|branch|changes|character|citation|\n
- document|errorlist|ert|external|file|findreplace|findreplaceadv|float|graphics|\n
- href|include|index|index_print|info|label|listings|log|mathdelimiter|\n
+ compare|document|errorlist|ert|external|file|findreplace|findreplaceadv|float|\n
+ graphics|href|include|index|index_print|info|label|listings|log|mathdelimiter|\n
mathmatrix|mathspace|nomenclature|nomencl_print|note|paragraph|phantom|prefs|\n
print|ref|sendto|space|spellchecker|symbols|tabular|tabularcreate|\n
thesaurus|texinfo|toc|view-source|vspace|wrap|<SPECIAL> \n
--- /dev/null
+/**\r
+ * \file GuiCompare.cpp\r
+ * This file is part of LyX, the document processor.\r
+ * Licence details can be found in the file COPYING.\r
+ *\r
+ * \author Vincent van Ravesteijn\r
+ *\r
+ * Full author contact details are available in file CREDITS.\r
+ */\r
+\r
+#include <config.h>\r
+\r
+#include "GuiCompare.h"\r
+\r
+#include "Buffer.h"\r
+#include "BufferView.h"\r
+#include "BufferList.h"\r
+#include "buffer_funcs.h"\r
+#include "FuncRequest.h"\r
+#include "GuiView.h"\r
+#include "LyXRC.h"\r
+#include "qt_helpers.h"\r
+\r
+#include "frontends/alert.h"\r
+\r
+#include "support/debug.h"\r
+#include "support/filetools.h"\r
+#include "support/FileName.h"\r
+#include "support/gettext.h"\r
+\r
+#include <QThread>\r
+\r
+\r
+using namespace std;\r
+using namespace lyx::support;\r
+\r
+namespace lyx {\r
+namespace frontend {\r
+\r
+\r
+GuiCompare::GuiCompare(GuiView & lv)\r
+ : GuiDialog(lv, "compare", qt_("Compare LyX files")),\r
+ compare_(0), dest_buffer_(0)\r
+{\r
+ setupUi(this);\r
+ setModal(Qt::WindowModal);\r
+\r
+ connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));\r
+ connect(closePB, SIGNAL(clicked()), this, SLOT(slotCancel()));\r
+\r
+ connect(newFilePB, SIGNAL(clicked()), this, SLOT(select_newfile()));\r
+ connect(oldFilePB, SIGNAL(clicked()), this, SLOT(select_oldfile()));\r
+\r
+ connect(newFileCB, SIGNAL(currentIndexChanged(int)),\r
+ this, SLOT(change_adaptor()));\r
+ connect(newFileCB, SIGNAL(editTextChanged(const QString &)),\r
+ this, SLOT(change_adaptor()));\r
+ connect(oldFileCB, SIGNAL(currentIndexChanged(int)),\r
+ this, SLOT(change_adaptor()));\r
+ connect(oldFileCB, SIGNAL(editTextChanged(const QString &)),\r
+ this, SLOT(change_adaptor()));\r
+\r
+ newSettingsRB->setChecked(true);\r
+\r
+ progressBar->setValue(0);\r
+ progressBar->setEnabled(false);\r
+\r
+ bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);\r
+ bc().setOK(okPB);\r
+}\r
+\r
+GuiCompare::~GuiCompare()\r
+{\r
+}\r
+\r
+void GuiCompare::closeEvent(QCloseEvent *)\r
+{\r
+ slotCancel(); \r
+}\r
+\r
+\r
+void GuiCompare::change_adaptor()\r
+{\r
+ changed();\r
+}\r
+\r
+\r
+bool GuiCompare::isValid()\r
+{\r
+ bool const valid = !newFileCB->currentText().isEmpty()\r
+ && !oldFileCB->currentText().isEmpty();\r
+ return valid;\r
+}\r
+\r
+\r
+void GuiCompare::updateContents()\r
+{\r
+ QString restore_filename1 = newFileCB->currentText();\r
+ QString restore_filename2 = oldFileCB->currentText();\r
+ newFileCB->clear();\r
+ oldFileCB->clear();\r
+ progressBar->setValue(0);\r
+ BufferList::iterator it = theBufferList().begin();\r
+ BufferList::iterator const end = theBufferList().end();\r
+ for (; it != end; ++it) {\r
+ QString filename = toqstr((*it)->absFileName());\r
+ newFileCB->addItem(filename);\r
+ oldFileCB->addItem(filename);\r
+ }\r
+ if (lyxview().documentBufferView())\r
+ newFileCB->setEditText(toqstr(buffer().absFileName()));\r
+ else\r
+ newFileCB->setEditText(restore_filename1);\r
+\r
+ if (!restore_filename2.isEmpty())\r
+ oldFileCB->setEditText(restore_filename2);\r
+ else\r
+ oldFileCB->clearEditText();\r
+\r
+ if (isValid()) {\r
+ bc().setValid(isValid());\r
+ bc().apply();\r
+ }\r
+}\r
+\r
+\r
+void GuiCompare::select_newfile()\r
+{\r
+ QString name = browse(newFileCB->currentText());\r
+ if (!name.isEmpty())\r
+ newFileCB->setEditText(name);\r
+ changed();\r
+}\r
+\r
+\r
+void GuiCompare::select_oldfile()\r
+{\r
+ QString name = browse(oldFileCB->currentText());\r
+ if (!name.isEmpty())\r
+ oldFileCB->setEditText(name);\r
+ changed();\r
+}\r
+\r
+\r
+QString GuiCompare::browse(QString const & in_name) const\r
+{\r
+ QString const title = qt_("Select document");\r
+\r
+ QStringList const & filters = fileFilters(qt_("LyX Documents (*.lyx)"));\r
+ \r
+ QString filename;\r
+ if (lyxview().documentBufferView()) {\r
+ QString path = bufferFilepath();\r
+ filename = browseRelFile(in_name, path, title, filters, false, \r
+ qt_("Documents|#o#O"), toqstr(lyxrc.document_path));\r
+ } else {\r
+ QString path = toqstr(lyxrc.document_path);\r
+ QString rel_filename = browseRelFile(in_name, path, title, filters, false, \r
+ qt_("Documents|#o#O"), toqstr(lyxrc.document_path));\r
+ filename = makeAbsPath(rel_filename, path);\r
+ }\r
+ return filename; \r
+}\r
+\r
+\r
+void GuiCompare::enableControls(bool enable) const\r
+{\r
+ newFileLA->setEnabled(enable);\r
+ newFilePB->setEnabled(enable);\r
+ newFileCB->setEnabled(enable);\r
+ oldFileLA->setEnabled(enable);\r
+ oldFilePB->setEnabled(enable);\r
+ oldFileCB->setEnabled(enable);\r
+ okPB->setEnabled(enable);\r
+ groupBox->setEnabled(enable);\r
+ progressBar->setEnabled(!enable);\r
+\r
+ if (enable)\r
+ closePB->setText(qt_("Close"));\r
+ else\r
+ closePB->setText(qt_("Cancel"));\r
+}\r
+\r
+\r
+void GuiCompare::finished(bool aborted)\r
+{\r
+ enableControls(true);\r
+ \r
+ if (aborted) {\r
+ dest_buffer_->markClean();\r
+ theBufferList().release(dest_buffer_);\r
+ setWindowTitle(window_title_);\r
+ progressBar->setValue(0);\r
+ } else {\r
+ hideView();\r
+ bc().ok();\r
+ dispatch(FuncRequest(LFUN_BUFFER_SWITCH, dest_buffer_->absFileName()));\r
+ }\r
+}\r
+\r
+\r
+void GuiCompare::nextIt(int val)\r
+{\r
+ progressBar->setValue(progressBar->value() + val);\r
+}\r
+\r
+\r
+void GuiCompare::progress_max(int max) const\r
+{\r
+ progressBar->setMaximum(max);\r
+}\r
+ \r
+\r
+void GuiCompare::slotOK()\r
+{\r
+ enableControls(false);\r
+ if (!run()) {\r
+ Alert::error(_("Error"),\r
+ _("Unable to compare files."));\r
+ finished(true);\r
+ }\r
+}\r
+\r
+\r
+void GuiCompare::slotCancel()\r
+{\r
+ GuiDialog::slotClose();\r
+ progressBar->setValue(0);\r
+}\r
+\r
+\r
+Buffer const * GuiCompare::bufferFromFileName(string const & file) const\r
+{\r
+ FileName fname;\r
+ if (FileName::isAbsolute(file))\r
+ fname.set(file);\r
+ else if (lyxview().documentBufferView())\r
+ fname = support::makeAbsPath(file, fromqstr(bufferFilepath()));\r
+\r
+ if (fname.empty()\r
+ || (!fname.exists() && !theBufferList().getBuffer(fname))) {\r
+ LYXERR0( "Unable to read: " << file);\r
+ return 0;\r
+ }\r
+ return loadIfNeeded(fname);\r
+}\r
+\r
+\r
+int GuiCompare::run()\r
+{\r
+ progressBar->setValue(0);\r
+\r
+ new_buffer_ = bufferFromFileName(fromqstr(newFileCB->currentText()));\r
+ old_buffer_ = bufferFromFileName(fromqstr(oldFileCB->currentText()));\r
+\r
+ // new buffer that will carry the output\r
+ FileName initpath(lyxrc.document_path);\r
+ dest_buffer_ = newUnnamedFile(initpath, to_utf8(_("differences")));\r
+ dest_buffer_->changed();\r
+ dest_buffer_->markDirty();\r
+\r
+ return 0;\r
+}\r
+\r
+\r
+Dialog * createGuiCompare(GuiView & lv) { return new GuiCompare(lv); }\r
+\r
+\r
+} // namespace frontend\r
+} // namespace lyx\r
+\r
+\r
+#include "moc_GuiCompare.cpp"\r
--- /dev/null
+// -*- C++ -*-\r
+/**\r
+ * \file GuiCompare.h\r
+ * This file is part of LyX, the document processor.\r
+ * Licence details can be found in the file COPYING.\r
+ *\r
+ * \author Vincent van Ravesteijn\r
+ *\r
+ * Full author contact details are available in file CREDITS.\r
+ */\r
+\r
+#ifndef GUICOMPARE_H\r
+#define GUICOMPARE_H\r
+\r
+#include "GuiDialog.h"\r
+#include "ui_CompareUi.h"\r
+#include "qt_helpers.h"\r
+\r
+#include "Compare.h"\r
+\r
+namespace lyx {\r
+namespace frontend {\r
+\r
+\r
+class GuiCompare : public GuiDialog, public Ui::CompareUi\r
+{\r
+ Q_OBJECT\r
+\r
+public:\r
+ ///\r
+ GuiCompare(GuiView & lv);\r
+ ~GuiCompare();\r
+\r
+ void closeEvent(QCloseEvent *);\r
+ \r
+private Q_SLOTS:\r
+ ///\r
+ void slotOK();\r
+ ///\r
+ void slotCancel();\r
+ ///\r
+ void change_adaptor();\r
+ ///\r
+ void select_newfile();\r
+ ///\r
+ void select_oldfile();\r
+\r
+ ///\r
+ void finished(bool aborted);\r
+ ///\r
+ void nextIt(int);\r
+ ///\r
+ void progress_max(int) const;\r
+\r
+private:\r
+ ///\r
+ void updateContents();\r
+ ///\r
+ bool isValid();\r
+ ///\r
+ bool initialiseParams(std::string const &) { return true; }\r
+ ///\r
+ bool isBufferDependent() const { return false; }\r
+ ///\r
+ void clearParams() {}\r
+ ///\r
+ void dispatchParams() {}\r
+ ///\r
+ void apply() {}\r
+\r
+\r
+ /// enable or disable all controls and rename the Close/Cancel button\r
+ void enableControls(bool enable) const;\r
+ \r
+ /// browse for a file\r
+ QString browse(QString const & in_name) const;\r
+ /// retrieve the buffer from the specified filename\r
+ Buffer const * bufferFromFileName(std::string const & file) const;\r
+\r
+ /// create the compare object and run the comparison\r
+ int run();\r
+\r
+private:\r
+ /// the object that will do the comparison\r
+ Compare * compare_;\r
+\r
+ /// the buffer that will contain the result\r
+ Buffer * dest_buffer_;\r
+ /// the buffer that will contain the result\r
+ Buffer const * old_buffer_;\r
+ /// the buffer that will contain the result\r
+ Buffer const * new_buffer_;\r
+\r
+ /// the window title\r
+ mutable QString window_title_;\r
+};\r
+\r
+\r
+\r
+} // namespace frontend\r
+} // namespace lyx\r
+\r
+#endif // GUICOMPARE_H\r
enable = name == "aboutlyx"
|| name == "file" //FIXME: should be removed.
|| name == "prefs"
- || name == "texinfo";
+ || name == "texinfo"
+ || name == "compare";
else if (name == "print")
enable = doc_buffer->isExportable("dvi")
&& lyxrc.print_command != "none";
char const * const dialognames[] = {
"aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
-"citation", "document", "errorlist", "ert", "external", "file", "findreplace",
-"findreplaceadv", "float", "graphics", "href", "include", "index",
-"index_print", "info", "listings", "label", "log", "mathdelimiter",
+"citation", "compare", "document", "errorlist", "ert", "external", "file",
+"findreplace", "findreplaceadv", "float", "graphics", "href", "include",
+"index", "index_print", "info", "listings", "label", "log", "mathdelimiter",
"mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
"paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
"spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
Dialog * createGuiChanges(GuiView & lv);
Dialog * createGuiCharacter(GuiView & lv);
Dialog * createGuiCitation(GuiView & lv);
+Dialog * createGuiCompare(GuiView & lv);
Dialog * createGuiDelimiter(GuiView & lv);
Dialog * createGuiDocument(GuiView & lv);
Dialog * createGuiErrorList(GuiView & lv);
return createGuiCharacter(*this);
if (name == "citation")
return createGuiCitation(*this);
+ if (name == "compare")
+ return createGuiCompare(*this);
if (name == "document")
return createGuiDocument(*this);
if (name == "errorlist")
GuiClipboard.cpp \
GuiCommandBuffer.cpp \
GuiCommandEdit.cpp \
+ GuiCompare.cpp \
GuiCompleter.cpp \
GuiDelimiter.cpp \
GuiDialog.cpp \
GuiClipboard.h \
GuiCommandBuffer.h \
GuiCommandEdit.h \
+ GuiCompare.h \
GuiCompleter.h \
GuiDelimiter.h \
GuiDialog.h \
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CompareUi</class>
+ <widget class="QDialog" name="CompareUi">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>495</width>
+ <height>302</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string/>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="newFileLA">
+ <property name="text">
+ <string>&New Document:</string>
+ </property>
+ <property name="buddy">
+ <cstring>newFileCB</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QComboBox" name="newFileCB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <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="buddy">
+ <cstring>oldFileCB</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QComboBox" name="oldFileCB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <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 hsizetype="Expanding" vsizetype="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>
+ <attribute name="buttonGroup">
+ <string>buttonGroup</string>
+ </attribute>
+ </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>
+ <attribute name="buttonGroup">
+ <string>buttonGroup</string>
+ </attribute>
+ </widget>
+ <widget class="QLabel" name="label">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>20</y>
+ <width>161</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Copy Document Settings from:</string>
+ </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>
+ </widget>
+ <includes>
+ <include location="local">qt_i18n.h</include>
+ </includes>
+ <resources/>
+ <connections/>
+ <buttongroups>
+ <buttongroup name="buttonGroup"/>
+ </buttongroups>
+</ui>
uic ChangesUi.ui -o ChangesUi.h
uic CharacterUi.ui -o CharacterUi.h
uic CitationUi.ui -o CitationUi.h
+uic CompareUi.ui -o CompareUi.h
uic DelimiterUi.ui -o DelimiterUi.h
uic DocumentUi.ui -o DocumentUi.h
uic ErrorListUi.ui -o ErrorListUi.h