mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Add decent UI for VC_COMPARE
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35306 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d179943b8f
commit
e2c0424c17
@ -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
|
||||
|
@ -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
|
||||
|
124
src/frontends/qt4/GuiCompareHistory.cpp
Normal file
124
src/frontends/qt4/GuiCompareHistory.cpp
Normal file
@ -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"
|
61
src/frontends/qt4/GuiCompareHistory.h
Normal file
61
src/frontends/qt4/GuiCompareHistory.h
Normal file
@ -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
|
@ -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")
|
||||
|
@ -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 \
|
||||
|
205
src/frontends/qt4/ui/CompareHistoryUi.ui
Normal file
205
src/frontends/qt4/ui/CompareHistoryUi.ui
Normal file
@ -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>&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>&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>&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>&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>
|
Loading…
Reference in New Issue
Block a user