]> git.lyx.org Git - features.git/commitdiff
next one
authorAndré Pönitz <poenitz@gmx.net>
Sat, 6 Oct 2007 11:03:21 +0000 (11:03 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 6 Oct 2007 11:03:21 +0000 (11:03 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20776 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ControlChanges.cpp [deleted file]
src/frontends/controllers/ControlChanges.h [deleted file]
src/frontends/controllers/Makefile.am
src/frontends/qt4/Dialogs.cpp
src/frontends/qt4/GuiChanges.cpp
src/frontends/qt4/GuiChanges.h

diff --git a/src/frontends/controllers/ControlChanges.cpp b/src/frontends/controllers/ControlChanges.cpp
deleted file mode 100644 (file)
index 1746c51..0000000
+++ /dev/null
@@ -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
diff --git a/src/frontends/controllers/ControlChanges.h b/src/frontends/controllers/ControlChanges.h
deleted file mode 100644 (file)
index 8b600b3..0000000
+++ /dev/null
@@ -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
index b2f1ce2259b5c80f7138d669c055ae34ca6e5b71..9c55f22037b4370cd622601a71a7417bb9d824c5 100644 (file)
@@ -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 \
index 86b2f8647169ff50e9b7852b561f77b2dcd06336..fc3c4180e717f2725cbca1d6bc2f52b577374933 100644 (file)
@@ -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") {
index e615c14a0f13470dbc71c0550dc97bb9673112a8..a2568fed31ea54e9a722f38f698711dc0ba0fce6 100644 (file)
 #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
 
index ed895f0dfc2f3b4d7c4c0ed3274b0ca9f8d784ac..dc9b063503fc23101fed5073325591954d6d39b4 100644 (file)
@@ -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.
  */
 #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