mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
next one
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20776 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7a32331ab2
commit
64e5b6de92
@ -1,87 +0,0 @@
|
||||
/**
|
||||
* \file ControlChanges.cpp
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Michael Gerz
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "ControlChanges.h"
|
||||
|
||||
#include "Author.h"
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
#include "BufferView.h"
|
||||
#include "Changes.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "lyxfind.h"
|
||||
#include "LyXRC.h"
|
||||
|
||||
#include "support/lyxtime.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace frontend {
|
||||
|
||||
|
||||
ControlChanges::ControlChanges(Dialog & parent)
|
||||
: Controller(parent)
|
||||
{}
|
||||
|
||||
|
||||
void ControlChanges::next()
|
||||
{
|
||||
dispatch(FuncRequest(LFUN_CHANGE_NEXT));
|
||||
}
|
||||
|
||||
|
||||
docstring const ControlChanges::getChangeDate()
|
||||
{
|
||||
Change const & c = bufferview()->getCurrentChange();
|
||||
if (c.type == Change::UNCHANGED)
|
||||
return docstring();
|
||||
|
||||
// FIXME UNICODE
|
||||
return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format));
|
||||
}
|
||||
|
||||
|
||||
docstring const ControlChanges::getChangeAuthor()
|
||||
{
|
||||
Change const & c = bufferview()->getCurrentChange();
|
||||
if (c.type == Change::UNCHANGED)
|
||||
return docstring();
|
||||
|
||||
Author const & a = buffer().params().authors().get(c.author);
|
||||
|
||||
docstring author = a.name();
|
||||
|
||||
if (!a.email().empty())
|
||||
author += " (" + a.email() + ")";
|
||||
|
||||
return author;
|
||||
}
|
||||
|
||||
|
||||
void ControlChanges::accept()
|
||||
{
|
||||
dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
|
||||
next();
|
||||
}
|
||||
|
||||
|
||||
void ControlChanges::reject()
|
||||
{
|
||||
dispatch(FuncRequest(LFUN_CHANGE_REJECT));
|
||||
next();
|
||||
}
|
||||
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,60 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file ControlChanges.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Michael Gerz
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef CONTROLCHANGES_H
|
||||
#define CONTROLCHANGES_H
|
||||
|
||||
#include "Dialog.h"
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
/**
|
||||
* A controller for the merge changes dialog.
|
||||
*/
|
||||
class ControlChanges : public Controller {
|
||||
public:
|
||||
///
|
||||
ControlChanges(Dialog &);
|
||||
/// Nothing to initialise in this case.
|
||||
virtual bool initialiseParams(std::string const &) { return true; }
|
||||
///
|
||||
virtual void clearParams() {}
|
||||
///
|
||||
virtual void dispatchParams() {}
|
||||
///
|
||||
virtual bool isBufferDependent() const { return true; }
|
||||
/// always true since dispatchParams() is empty
|
||||
virtual bool canApply() const { return true; }
|
||||
|
||||
/// find the next change and highlight it
|
||||
void next();
|
||||
|
||||
/// return date of change
|
||||
docstring const getChangeDate();
|
||||
|
||||
/// return author of change
|
||||
docstring const getChangeAuthor();
|
||||
|
||||
/// accept the current change
|
||||
void accept();
|
||||
|
||||
/// reject the current change
|
||||
void reject();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // CONTROLCHANGES_H
|
@ -10,7 +10,6 @@ SOURCEFILES = \
|
||||
Dialog.cpp \
|
||||
ButtonPolicy.cpp \
|
||||
ControlCharacter.cpp \
|
||||
ControlChanges.cpp \
|
||||
ControlCitation.cpp \
|
||||
ControlCommand.cpp \
|
||||
ControlCommandBuffer.cpp \
|
||||
@ -36,7 +35,6 @@ SOURCEFILES = \
|
||||
HEADERFILES = \
|
||||
ButtonPolicy.h \
|
||||
ControlCharacter.h \
|
||||
ControlChanges.h \
|
||||
ControlCitation.h \
|
||||
ControlCommand.h \
|
||||
ControlCommandBuffer.h \
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "DialogView.h"
|
||||
#include "DockView.h"
|
||||
#include "GuiBibitem.h"
|
||||
#include "GuiChanges.h"
|
||||
#include "GuiCharacter.h"
|
||||
#include "GuiCitation.h"
|
||||
#include "GuiDelimiter.h"
|
||||
@ -161,7 +160,7 @@ Dialog * Dialogs::build(string const & name)
|
||||
} else if (name == "branch") {
|
||||
dialog = createGuiBranch(lyxview_);
|
||||
} else if (name == "changes") {
|
||||
dialog = new GuiChangesDialog(lyxview_);
|
||||
dialog = createGuiChanges(lyxview_);
|
||||
} else if (name == "character") {
|
||||
dialog = new GuiCharacterDialog(lyxview_);
|
||||
} else if (name == "citation") {
|
||||
|
@ -12,32 +12,41 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "GuiChanges.h"
|
||||
#include "ControlChanges.h"
|
||||
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxtime.h"
|
||||
|
||||
#include "Author.h"
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
#include "BufferView.h"
|
||||
#include "Changes.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "lyxfind.h"
|
||||
#include "LyXRC.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QTextBrowser>
|
||||
|
||||
using lyx::support::bformat;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
GuiChangesDialog::GuiChangesDialog(LyXView & lv)
|
||||
: GuiDialog(lv, "changes")
|
||||
using support::bformat;
|
||||
|
||||
GuiChanges::GuiChanges(LyXView & lv)
|
||||
: GuiDialog(lv, "changes"), Controller(this)
|
||||
{
|
||||
setupUi(this);
|
||||
setController(new ControlChanges(*this));
|
||||
setController(this, false);
|
||||
setViewTitle(_("Merge Changes"));
|
||||
|
||||
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
||||
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed()));
|
||||
connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectPressed()));
|
||||
connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptPressed()));
|
||||
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextChange()));
|
||||
connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectChange()));
|
||||
connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptChange()));
|
||||
|
||||
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
||||
bc().setCancel(closePB);
|
||||
@ -46,24 +55,18 @@ GuiChangesDialog::GuiChangesDialog(LyXView & lv)
|
||||
}
|
||||
|
||||
|
||||
ControlChanges & GuiChangesDialog::controller()
|
||||
{
|
||||
return static_cast<ControlChanges &>(GuiDialog::controller());
|
||||
}
|
||||
|
||||
|
||||
void GuiChangesDialog::closeEvent(QCloseEvent *e)
|
||||
void GuiChanges::closeEvent(QCloseEvent *e)
|
||||
{
|
||||
slotClose();
|
||||
e->accept();
|
||||
}
|
||||
|
||||
|
||||
void GuiChangesDialog::updateContents()
|
||||
void GuiChanges::updateContents()
|
||||
{
|
||||
docstring text;
|
||||
docstring author = controller().getChangeAuthor();
|
||||
docstring date = controller().getChangeDate();
|
||||
docstring author = changeAuthor();
|
||||
docstring date = changeDate();
|
||||
|
||||
if (!author.empty())
|
||||
text += bformat(_("Change by %1$s\n\n"), author);
|
||||
@ -74,23 +77,57 @@ void GuiChangesDialog::updateContents()
|
||||
}
|
||||
|
||||
|
||||
void GuiChangesDialog::nextPressed()
|
||||
void GuiChanges::nextChange()
|
||||
{
|
||||
controller().next();
|
||||
dispatch(FuncRequest(LFUN_CHANGE_NEXT));
|
||||
}
|
||||
|
||||
|
||||
void GuiChangesDialog::acceptPressed()
|
||||
docstring GuiChanges::changeDate() const
|
||||
{
|
||||
controller().accept();
|
||||
Change const & c = bufferview()->getCurrentChange();
|
||||
if (c.type == Change::UNCHANGED)
|
||||
return docstring();
|
||||
|
||||
// FIXME UNICODE
|
||||
return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format));
|
||||
}
|
||||
|
||||
|
||||
void GuiChangesDialog::rejectPressed()
|
||||
docstring GuiChanges::changeAuthor() const
|
||||
{
|
||||
controller().reject();
|
||||
Change const & c = bufferview()->getCurrentChange();
|
||||
if (c.type == Change::UNCHANGED)
|
||||
return docstring();
|
||||
|
||||
Author const & a = buffer().params().authors().get(c.author);
|
||||
|
||||
docstring author = a.name();
|
||||
|
||||
if (!a.email().empty())
|
||||
author += " (" + a.email() + ")";
|
||||
|
||||
return author;
|
||||
}
|
||||
|
||||
|
||||
void GuiChanges::acceptChange()
|
||||
{
|
||||
dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
|
||||
nextChange();
|
||||
}
|
||||
|
||||
|
||||
void GuiChanges::rejectChange()
|
||||
{
|
||||
dispatch(FuncRequest(LFUN_CHANGE_REJECT));
|
||||
nextChange();
|
||||
}
|
||||
|
||||
|
||||
Dialog * createGuiChanges(LyXView & lv) { return new GuiChanges(lv); }
|
||||
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Michael Gerz
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -13,28 +14,48 @@
|
||||
#define GUICHANGES_H
|
||||
|
||||
#include "GuiDialog.h"
|
||||
#include "ControlChanges.h"
|
||||
#include "ui_ChangesUi.h"
|
||||
#include "support/docstring.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class GuiChangesDialog : public GuiDialog, public Ui::ChangesUi
|
||||
class GuiChanges : public GuiDialog, public Ui::ChangesUi, public Controller
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiChangesDialog(LyXView & lv);
|
||||
GuiChanges(LyXView & lv);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void nextPressed();
|
||||
void acceptPressed();
|
||||
void rejectPressed();
|
||||
/// accept the current change
|
||||
void acceptChange();
|
||||
/// reject the current change
|
||||
void rejectChange();
|
||||
/// find the next change and highlight it
|
||||
void nextChange();
|
||||
|
||||
private:
|
||||
void closeEvent(QCloseEvent * e);
|
||||
ControlChanges & controller();
|
||||
Controller & controller() { return *this; }
|
||||
void updateContents();
|
||||
|
||||
/// Nothing to initialise in this case.
|
||||
bool initialiseParams(std::string const &) { return true; }
|
||||
///
|
||||
void clearParams() {}
|
||||
///
|
||||
void dispatchParams() {}
|
||||
///
|
||||
bool isBufferDependent() const { return true; }
|
||||
/// always true since dispatchParams() is empty
|
||||
bool canApply() const { return true; }
|
||||
|
||||
/// return date of change
|
||||
docstring changeDate() const;
|
||||
/// return author of change
|
||||
docstring changeAuthor() const;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
Loading…
Reference in New Issue
Block a user