]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlChanges.C
convert author names and status messages to docstring
[lyx.git] / src / frontends / controllers / ControlChanges.C
index 3d173d6242e1f2e67e1a8f23d784a8ebc5250acb..9c67cc57c50cfec7a713526fe254f5e9d6421c96 100644 (file)
@@ -5,78 +5,91 @@
  *
  * \author John Levon
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
-#include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
 
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "ControlChanges.h"
-#include "frontends/Dialogs.h"
-#include "frontends/LyXView.h"
+
+#include "author.h"
 #include "buffer.h"
-#include "lyxfind.h"
-#include "lyxfunc.h"
-#include "debug.h"
+#include "bufferparams.h"
 #include "BufferView.h"
-#include "support/lstrings.h"
+#include "changes.h"
 #include "funcrequest.h"
-#include "author.h"
+#include "lyxfind.h"
+#include "support/lyxtime.h"
+
+using std::string;
+
+namespace lyx {
+
+namespace frontend {
 
-ControlChanges::ControlChanges(LyXView & lv, Dialogs & d)
-       : ControlDialogBD(lv, d)
+
+ControlChanges::ControlChanges(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlChanges::find()
 {
+       return findNextChange(kernel().bufferview());
 }
 
 
-void ControlChanges::find()
+bool ControlChanges::changed()
 {
-       lyxfind::findNextChange(bufferview());
+       Change c(kernel().bufferview()->getCurrentChange());
+       return c.type != Change::UNCHANGED;
 }
 
 
-string const ControlChanges::getChangeDate()
+docstring const ControlChanges::getChangeDate()
 {
-       Change c(bufferview()->getCurrentChange());
+       Change c(kernel().bufferview()->getCurrentChange());
        if (c.type == Change::UNCHANGED || !c.changetime)
-               return string();
-       return ctime(&c.changetime);
+               return docstring();
+
+       // FIXME UNICODE
+       return from_utf8(formatted_time(c.changetime));
 }
 
 
-string const ControlChanges::getChangeAuthor()
+docstring const ControlChanges::getChangeAuthor()
 {
-       Change c(bufferview()->getCurrentChange());
+       Change c(kernel().bufferview()->getCurrentChange());
        if (c.type == Change::UNCHANGED)
-               return string();
-       Author const & a(bufferview()->buffer()->authors().get(c.author));
+               return docstring();
+
+       Author const & a(kernel().buffer().params().authors().get(c.author));
+
+       docstring author(a.name());
 
-       string author(a.name());
        if (!a.email().empty()) {
                author += " (";
-               author += a.email() + ")";
+               author += a.email();
+               author += ")";
        }
 
        return author;
 }
 
-void ControlChanges::accept()
+
+bool ControlChanges::accept()
 {
-       lv_.dispatch(FuncRequest(LFUN_ACCEPT_CHANGE));
-       lyxfind::findNextChange(bufferview());
+       kernel().dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
+       return findNextChange(kernel().bufferview());
 }
 
-void ControlChanges::reject()
+
+bool ControlChanges::reject()
 {
-       lv_.dispatch(FuncRequest(LFUN_REJECT_CHANGE));
-       lyxfind::findNextChange(bufferview());
+       kernel().dispatch(FuncRequest(LFUN_CHANGE_REJECT));
+       return findNextChange(kernel().bufferview());
 }
+
+
+} // namespace frontend
+} // namespace lyx