]> git.lyx.org Git - features.git/commitdiff
Add decent UI for VC_COMPARE
authorPavel Sanda <sanda@lyx.org>
Tue, 7 Sep 2010 11:28:57 +0000 (11:28 +0000)
committerPavel Sanda <sanda@lyx.org>
Tue, 7 Sep 2010 11:28:57 +0000 (11:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35306 a592a061-630c-0410-9148-cb99ea01b6c8

development/scons/scons_manifest.py
src/LyXAction.cpp
src/frontends/qt4/GuiCompareHistory.cpp [new file with mode: 0644]
src/frontends/qt4/GuiCompareHistory.h [new file with mode: 0644]
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/Makefile.am
src/frontends/qt4/ui/CompareHistoryUi.ui [new file with mode: 0644]

index 160898c5a4873b29dc55c0423e753d5e457e9504..ad70ed3c138a7dc7a4dbfa38aa418f2831aad84b 100644 (file)
@@ -721,6 +721,7 @@ src_frontends_qt4_header_files = Split('''
     GuiCommandBuffer.h
     GuiCommandEdit.h
     GuiCompare.h
+    GuiCompareHistory.h
     GuiCompleter.h
     GuiDelimiter.h
     GuiDialog.h
@@ -823,6 +824,7 @@ src_frontends_qt4_files = Split('''
     GuiCommandBuffer.cpp
     GuiCommandEdit.cpp
     GuiCompare.cpp
+    GuiCompareHistory.cpp
     GuiCompleter.cpp
     GuiDelimiter.cpp
     GuiDialog.cpp
@@ -921,6 +923,7 @@ src_frontends_qt4_ui_files = Split('''
     CitationUi.ui
     ColorUi.ui
     CompareUi.ui
+    CompareHistoryUi.ui
     DelimiterUi.ui
     DocumentUi.ui
     ERTUi.ui
index 963cfd2b1adfbe45b295783694ea622a6d3fda57..1a55e24044db3f76c3cb512b911a8a5e3d924d2a 100644 (file)
@@ -2192,13 +2192,14 @@ void LyXAction::init()
  * \var lyx::FuncCode lyx::LFUN_VC_COMPARE
  * \li Action: Compares two revisions of the same file under version control.
  * \li Notion: This is currently implemented only for SVN and RCS.
- * \li Syntax: vc-compare <REV1> [<REV2>]
+ * \li Syntax: vc-compare [<REV1>] [<REV2>]
  * \li Params: Revision number either points directly to commit in history
-               or if negative number -x it points to last commit - x.\n
+               or if negative number -x it points to (last commit - x).\n
               In RCS we subtract only in the last number of revision specification.
                Special case "0" is reserved for the last committed revision.\n
                <REV1>: Older file.\n
-              <REV2>: Newer file. Used only if REV1 > 0.
+              <REV2>: Newer file. Used only if REV1 > 0.\n
+               If no parameter is given, interactive dialog will be shown.
  * \li Sample: Compare current document against last commit\n
                vc-compare 0
  * \li Sample: Compare current document against current revision - 5 commits\n
diff --git a/src/frontends/qt4/GuiCompareHistory.cpp b/src/frontends/qt4/GuiCompareHistory.cpp
new file mode 100644 (file)
index 0000000..35cff62
--- /dev/null
@@ -0,0 +1,124 @@
+/**
+ * \file GuiCompareHistory.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Pavel Sanda
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiCompareHistory.h"
+
+#include "Buffer.h"
+#include "BufferView.h"
+#include "FuncRequest.h"
+#include "GuiView.h"
+#include "LyXVC.h"
+
+#include "support/convert.h"
+#include "support/lstrings.h"
+
+
+
+using namespace std;
+using namespace lyx::support;
+
+namespace lyx {
+namespace frontend {
+
+
+GuiCompareHistory::GuiCompareHistory(GuiView & lv)
+       : GuiDialog(lv, "comparehistory", qt_("Compare different revisions"))
+
+{
+       setupUi(this);
+       setModal(Qt::WindowModal);
+
+       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
+       connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotCancel()));
+
+       connect(revbackRB, SIGNAL(clicked()), this, SLOT(selectRevback()));
+       connect(betweenrevRB, SIGNAL(clicked()), this, SLOT(selectBetweenrev()));
+
+       string revstring = lv.currentBufferView()->buffer().lyxvc().revisionInfo(LyXVC::File);
+       int rev=0;
+       if (prefixIs(revstring, "r"))
+               revstring = ltrim(revstring,"r");
+       if (isStrInt(revstring))
+               rev = convert<int>(revstring);
+
+       okPB->setEnabled(rev);
+       rev1SB->setMaximum(rev);
+       rev2SB->setMaximum(rev);
+       revbackSB->setMaximum(rev);
+       rev2SB->setValue(rev);
+       rev1SB->setValue(rev-1);
+
+       //bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
+       //bc().setOK(okPB);
+       //bc().setCancel(cancelPB);
+       enableControls();
+}
+
+
+void GuiCompareHistory::updateContents()
+{
+       enableControls();
+}
+
+
+void GuiCompareHistory::selectRevback()
+{
+       betweenrevRB->setChecked(false);
+       enableControls();
+}
+
+
+void GuiCompareHistory::selectBetweenrev()
+{
+       revbackRB->setChecked(false);
+       enableControls();
+}
+
+
+void GuiCompareHistory::enableControls()
+{
+       bool rb = revbackRB->isChecked();
+       rev1SB->setEnabled(!rb);
+       rev2SB->setEnabled(!rb);
+       betweenrevRB->setChecked(!rb);
+       revbackSB->setEnabled(rb);
+}
+
+
+void GuiCompareHistory::slotOK()
+{
+       string param;
+       if (revbackRB->isChecked())
+               param = "-" + convert<string>(revbackSB->value());
+       else
+               param = convert<string>(rev1SB->value()) +
+                       + " " + convert<string>(rev2SB->value());
+
+       GuiDialog::slotClose();
+       dispatch(FuncRequest(LFUN_VC_COMPARE, param));
+}
+
+
+void GuiCompareHistory::slotCancel()
+{
+       GuiDialog::slotClose();
+}
+
+
+Dialog * createGuiCompareHistory(GuiView & lv) { return new GuiCompareHistory(lv); }
+
+
+} // namespace frontend
+} // namespace lyx
+
+
+#include "moc_GuiCompareHistory.cpp"
diff --git a/src/frontends/qt4/GuiCompareHistory.h b/src/frontends/qt4/GuiCompareHistory.h
new file mode 100644 (file)
index 0000000..bb9eac5
--- /dev/null
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+/**
+ * \file GuiCompareHistory.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Pavel Sanda
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef GUICOMPAREHISTORY_H
+#define GUICOMPAREHISTORY_H
+
+#include "GuiDialog.h"
+#include "ui_CompareHistoryUi.h"
+#include "qt_helpers.h"
+
+
+namespace lyx {
+namespace frontend {
+
+
+class GuiCompareHistory : public GuiDialog, public Ui::CompareHistoryUi
+{
+       Q_OBJECT
+
+public:
+       ///
+       GuiCompareHistory(GuiView & lv);
+
+private Q_SLOTS:
+       ///
+       void slotOK();
+       ///
+       void slotCancel();
+       ///
+       void selectRevback();
+       ///
+       void selectBetweenrev();
+private:
+       ///
+       void updateContents();
+       ///
+       bool initialiseParams(std::string const &) { return true; }
+       ///
+       bool isBufferDependent() const { return true; }
+       ///
+       void clearParams() {}
+       ///
+       void dispatchParams() {}
+       ///
+       void enableControls();
+       
+private:
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // GUICOMPAREHISTORY_H
index 0a1b4ba15074eff00c65491f6d8f33ab0c48c5ae..1e0433800281e6ae98aaabac34358547393daca0 100644 (file)
@@ -1667,8 +1667,7 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                break;
        }
        case LFUN_VC_COMPARE:
-               enable = doc_buffer && !cmd.argument().empty()
-                        && doc_buffer->lyxvc().prepareFileRevisionEnabled();
+               enable = doc_buffer && doc_buffer->lyxvc().prepareFileRevisionEnabled();
                break;
 
        case LFUN_SERVER_GOTO_FILE_ROW:
@@ -2665,6 +2664,11 @@ void GuiView::dispatchVC(FuncRequest const & cmd)
 
        case LFUN_VC_COMPARE: {
 
+               if (cmd.argument().empty()) {
+                       lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, "comparehistory"));
+                       break;
+               }
+
                string rev1 = cmd.getArg(0);
                string f1, f2;
 
@@ -3456,15 +3460,15 @@ namespace {
 // docs in LyXAction.cpp.
 
 char const * const dialognames[] = {
+
 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
-"citation", "compare", "document", "errorlist", "ert", "external",
-"file", "findreplace", "findreplaceadv", "float", "graphics", "href",
-"include", "index", "index_print", "info", "listings", "label", "line",
+"citation", "compare", "comparehistory", "document", "errorlist", "ert",
+"external", "file", "findreplace", "findreplaceadv", "float", "graphics",
+"href", "include", "index", "index_print", "info", "listings", "label", "line",
 "log", "mathdelimiter", "mathmatrix", "mathspace", "nomenclature",
 "nomencl_print", "note", "paragraph", "phantom", "prefs", "print", "ref",
 "sendto", "space", "spellchecker", "symbols", "tabular", "tabularcreate",
-"thesaurus", "texinfo", "toc", "view-source", "vspace", "wrap",
-"progress"};
+"thesaurus", "texinfo", "toc", "view-source", "vspace", "wrap", "progress"};
 
 char const * const * const end_dialognames =
        dialognames + (sizeof(dialognames) / sizeof(char *));
@@ -3643,6 +3647,7 @@ Dialog * createGuiChanges(GuiView & lv);
 Dialog * createGuiCharacter(GuiView & lv);
 Dialog * createGuiCitation(GuiView & lv);
 Dialog * createGuiCompare(GuiView & lv);
+Dialog * createGuiCompareHistory(GuiView & lv);
 Dialog * createGuiDelimiter(GuiView & lv);
 Dialog * createGuiDocument(GuiView & lv);
 Dialog * createGuiErrorList(GuiView & lv);
@@ -3701,6 +3706,8 @@ Dialog * GuiView::build(string const & name)
                return createGuiCitation(*this);
        if (name == "compare")
                return createGuiCompare(*this);
+       if (name == "comparehistory")
+               return createGuiCompareHistory(*this);
        if (name == "document")
                return createGuiDocument(*this);
        if (name == "errorlist")
index 12b3d0d4da49f237d72c96edfc5efc392c11e73e..83c940e20654820589f05b6ba0ab475760fd9e9b 100644 (file)
@@ -74,6 +74,7 @@ SOURCEFILES = \
        GuiCommandBuffer.cpp \
        GuiCommandEdit.cpp \
        GuiCompare.cpp \
+       GuiCompareHistory.cpp \
        GuiCompleter.cpp \
        GuiDelimiter.cpp \
        GuiDialog.cpp \
@@ -185,6 +186,7 @@ MOCHEADER = \
        GuiCommandBuffer.h \
        GuiCommandEdit.h \
        GuiCompare.h \
+       GuiCompareHistory.h \
        GuiCompleter.h \
        GuiDelimiter.h \
        GuiDialog.h \
@@ -263,6 +265,7 @@ UIFILES = \
        CitationUi.ui \
        ColorUi.ui \
        CompareUi.ui \
+       CompareHistoryUi.ui \
        DelimiterUi.ui \
        DocumentUi.ui \
        ErrorListUi.ui \
diff --git a/src/frontends/qt4/ui/CompareHistoryUi.ui b/src/frontends/qt4/ui/CompareHistoryUi.ui
new file mode 100644 (file)
index 0000000..019a066
--- /dev/null
@@ -0,0 +1,205 @@
+<ui version="4.0" >
+ <class>CompareHistoryUi</class>
+ <widget class="QWidget" name="CompareHistoryUi" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>356</width>
+    <height>172</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string/>
+  </property>
+  <property name="sizeGripEnabled" stdset="0" >
+   <bool>true</bool>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout" >
+   <item>
+    <widget class="QGroupBox" name="groupBox" >
+     <property name="title" >
+      <string>Compare Revisions</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_2" >
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_2" >
+        <item>
+         <widget class="QRadioButton" name="revbackRB" >
+          <property name="text" >
+           <string>&amp;Revisions back</string>
+          </property>
+          <property name="checked" >
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="revbackSB" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="minimumSize" >
+           <size>
+            <width>80</width>
+            <height>0</height>
+           </size>
+          </property>
+          <property name="minimum" >
+           <number>1</number>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer" >
+          <property name="orientation" >
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0" >
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <widget class="Line" name="line" >
+        <property name="orientation" >
+         <enum>Qt::Horizontal</enum>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout" >
+        <item>
+         <widget class="QRadioButton" name="betweenrevRB" >
+          <property name="text" >
+           <string>&amp;Between revisions</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="rev1SB" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="minimumSize" >
+           <size>
+            <width>80</width>
+            <height>0</height>
+           </size>
+          </property>
+          <property name="minimum" >
+           <number>1</number>
+          </property>
+          <property name="maximum" >
+           <number>1</number>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="rev2SB" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="minimumSize" >
+           <size>
+            <width>80</width>
+            <height>0</height>
+           </size>
+          </property>
+          <property name="minimum" >
+           <number>1</number>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3" >
+     <item>
+      <spacer name="horizontalSpacer_2" >
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="okPB" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text" >
+        <string>&amp;Ok</string>
+       </property>
+       <property name="autoDefault" >
+        <bool>false</bool>
+       </property>
+       <property name="default" >
+        <bool>true</bool>
+       </property>
+       <property name="flat" >
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="cancelPB" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text" >
+        <string>&amp;Cancel</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_3" >
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <includes>
+  <include location="local" >qt_i18n.h</include>
+ </includes>
+ <resources/>
+ <connections/>
+</ui>