From 848c89564fce9c4bfec79b915746dc6bc47abc3d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sat, 11 Aug 2007 22:37:09 +0000 Subject: [PATCH] remove lyxrc dependence from support/* git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19441 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/cmake/modules/LyXMacros.cmake | 2 +- src/Text3.cpp | 13 +- src/frontends/LyXView.cpp | 2 +- src/frontends/Makefile.am | 2 - src/frontends/Timeout.cpp | 77 --------- src/frontends/WorkArea.h | 2 +- src/frontends/controllers/ControlChanges.cpp | 3 +- src/frontends/qt4/GuiWorkArea.h | 2 +- src/frontends/qt4/Makefile.am | 6 +- src/frontends/qt4/qtTimeout.cpp | 68 -------- src/frontends/qt4/qtTimeout.h | 55 ------- src/graphics/LoaderQueue.h | 2 +- src/support/FileMonitor.cpp | 4 +- src/support/Forkedcall.cpp | 3 +- src/support/Makefile.am | 2 + src/support/Timeout.cpp | 155 +++++++++++++++++++ src/{frontends => support}/Timeout.h | 4 +- src/support/lyxtime.cpp | 7 - src/support/lyxtime.h | 6 - src/tex2lyx/Makefile.am | 9 +- 20 files changed, 176 insertions(+), 248 deletions(-) delete mode 100644 src/frontends/Timeout.cpp delete mode 100644 src/frontends/qt4/qtTimeout.cpp delete mode 100644 src/frontends/qt4/qtTimeout.h create mode 100644 src/support/Timeout.cpp rename src/{frontends => support}/Timeout.h (97%) diff --git a/development/cmake/modules/LyXMacros.cmake b/development/cmake/modules/LyXMacros.cmake index 0749961f1c..43b1fd8bf3 100644 --- a/development/cmake/modules/LyXMacros.cmake +++ b/development/cmake/modules/LyXMacros.cmake @@ -42,7 +42,7 @@ macro (LYX_ADD_UI_FILES _sources _ui) get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE) get_filename_component(_basename ${_tmp_FILE} NAME_WE) - set(_header ${CMAKE_CURRENT_BINARY_DIR}/ui/${_basename}.h) + set(_header ${CMAKE_CURRENT_BINARY_DIR}/ui_${_basename}.h) # we need to run uic and replace some things in the generated file # this is done by executing the cmake script kde4uic.cmake diff --git a/src/Text3.cpp b/src/Text3.cpp index 7231f07cfa..1d3f0e30df 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -983,14 +983,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) break; } - case LFUN_DATE_INSERT: - if (cmd.argument().empty()) - lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, - formatted_time(current_time()))); - else - lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, - formatted_time(current_time(), to_utf8(cmd.argument())))); + case LFUN_DATE_INSERT: { + string const format = cmd.argument().empty() + ? lyxrc.date_insert_format : to_utf8(cmd.argument()); + string const time = formatted_time(current_time(), format); + lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, time)); break; + } case LFUN_MOUSE_TRIPLE: if (cmd.button() == mouse_button::button1) { diff --git a/src/frontends/LyXView.cpp b/src/frontends/LyXView.cpp index f2278c8662..dc95512f7f 100644 --- a/src/frontends/LyXView.cpp +++ b/src/frontends/LyXView.cpp @@ -13,7 +13,6 @@ #include "LyXView.h" #include "Dialogs.h" -#include "Timeout.h" #include "Toolbars.h" #include "Menubar.h" #include "WorkArea.h" @@ -43,6 +42,7 @@ #include "support/lstrings.h" #include "support/filetools.h" // OnlyFilename() +#include "support/Timeout.h" #include diff --git a/src/frontends/Makefile.am b/src/frontends/Makefile.am index 52f12db20a..30260859f8 100644 --- a/src/frontends/Makefile.am +++ b/src/frontends/Makefile.am @@ -31,8 +31,6 @@ liblyxfrontends_la_SOURCES = \ Menubar.h \ Painter.cpp \ Painter.h \ - Timeout.cpp \ - Timeout.h \ Toolbars.cpp \ Toolbars.h \ Clipboard.h \ diff --git a/src/frontends/Timeout.cpp b/src/frontends/Timeout.cpp deleted file mode 100644 index 7ef659b3d9..0000000000 --- a/src/frontends/Timeout.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/** - * \file Timeout.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Lars Gullik Bjønnes - * \author John Levon - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "Timeout.h" - - -namespace lyx { - - -Timeout::~Timeout() -{ - pimpl_->stop(); -} - - -bool Timeout::running() const -{ - return pimpl_->running(); -} - - -void Timeout::start() -{ - pimpl_->start(); -} - - -void Timeout::stop() -{ - pimpl_->stop(); -} - - -void Timeout::restart() -{ - pimpl_->stop(); - pimpl_->start(); -} - - -void Timeout::emit() -{ - pimpl_->reset(); - timeout(); - if (type == CONTINUOUS) - pimpl_->start(); -} - - -Timeout & Timeout::setType(Type t) -{ - type = t; - return * this; -} - - -Timeout & Timeout::setTimeout(unsigned int msec) -{ - // Can't have a timeout of zero! - BOOST_ASSERT(msec); - - timeout_ms = msec; - return * this; -} - - -} // namespace lyx diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h index f45e2eefd6..31ae9e717f 100644 --- a/src/frontends/WorkArea.h +++ b/src/frontends/WorkArea.h @@ -16,8 +16,8 @@ #include "frontends/key_state.h" #include "frontends/KeySymbol.h" -#include "frontends/Timeout.h" +#include "support/Timeout.h" #include "support/docstring.h" #include diff --git a/src/frontends/controllers/ControlChanges.cpp b/src/frontends/controllers/ControlChanges.cpp index 01983c2eca..a394498703 100644 --- a/src/frontends/controllers/ControlChanges.cpp +++ b/src/frontends/controllers/ControlChanges.cpp @@ -20,6 +20,7 @@ #include "Changes.h" #include "FuncRequest.h" #include "lyxfind.h" +#include "LyXRC.h" #include "support/lyxtime.h" @@ -47,7 +48,7 @@ docstring const ControlChanges::getChangeDate() return docstring(); // FIXME UNICODE - return from_utf8(formatted_time(c.changetime)); + return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format)); } diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h index 5a096d5574..f64ed84cae 100644 --- a/src/frontends/qt4/GuiWorkArea.h +++ b/src/frontends/qt4/GuiWorkArea.h @@ -16,7 +16,7 @@ #include "frontends/WorkArea.h" #include "FuncRequest.h" -#include "frontends/Timeout.h" +#include "support/Timeout.h" #include #include diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index 63129bb544..8e27693372 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -176,7 +176,8 @@ liblyxqt4_la_SOURCES = \ QShowFile.h \ QSpellchecker.cpp \ QSpellchecker.h \ - Qt2BC.cpp Qt2BC.h\ \ + Qt2BC.cpp \ + Qt2BC.h \ QTabular.cpp \ QTabularCreate.cpp \ QTabularCreate.h \ @@ -189,8 +190,6 @@ liblyxqt4_la_SOURCES = \ QThesaurus.h \ QToc.cpp \ QToc.h \ - qtTimeout.cpp \ - qtTimeout.h \ QURLDialog.cpp \ QURLDialog.h \ QViewSource.cpp \ @@ -282,4 +281,3 @@ UIFILES = \ ViewSourceUi.ui \ VSpaceUi.ui \ WrapUi.ui - diff --git a/src/frontends/qt4/qtTimeout.cpp b/src/frontends/qt4/qtTimeout.cpp deleted file mode 100644 index 3b1ea51eeb..0000000000 --- a/src/frontends/qt4/qtTimeout.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/** - * \file qtTimeout.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author John Levon - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "qtTimeout.h" - -#include - -#include "debug.h" - - -namespace lyx { - - -Timeout::Timeout(unsigned int msec, Type t) - : pimpl_(new qtTimeout(*this)), type(t), timeout_ms(msec) -{} - - -qtTimeout::qtTimeout(Timeout & owner) - : Timeout::Impl(owner), timeout_id(-1) -{} - - -void qtTimeout::timerEvent(QTimerEvent *) -{ - emit(); -} - - -void qtTimeout::reset() -{ - if (timeout_id != -1) - killTimer(timeout_id); - timeout_id = -1; -} - - -bool qtTimeout::running() const -{ - return timeout_id != -1; -} - - -void qtTimeout::start() -{ - if (running()) - lyxerr << "Timeout::start: already running!" << std::endl; - timeout_id = startTimer(timeout_ms()); -} - - -void qtTimeout::stop() -{ - if (running()) - reset(); -} - - -} // namespace lyx diff --git a/src/frontends/qt4/qtTimeout.h b/src/frontends/qt4/qtTimeout.h deleted file mode 100644 index 51e4fc84dd..0000000000 --- a/src/frontends/qt4/qtTimeout.h +++ /dev/null @@ -1,55 +0,0 @@ -// -*- C++ -*- -/** - * \file qtTimeout.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author John Levon - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef QTTIMEOUT_H -#define QTTIMEOUT_H - -#include "frontends/Timeout.h" -#include -//Added by qt3to4: -#include - - -namespace lyx { - -// stupid Qt -#undef emit - -/** - * This class executes the callback when the timeout expires - * using Qt mechanisms - */ -class qtTimeout : QObject, public Timeout::Impl { -public: - /// - qtTimeout(Timeout & owner_); - /// - virtual bool running() const; - /// start the timer - virtual void start(); - /// stop the timer - virtual void stop(); - /// reset - virtual void reset(); - -protected: - /// slot - virtual void timerEvent(QTimerEvent *); - -private: - /// timout id - int timeout_id; -}; - - -} // namespace lyx - -#endif // QTTIMEOUT_H diff --git a/src/graphics/LoaderQueue.h b/src/graphics/LoaderQueue.h index 8f886fac91..2259d74a2f 100644 --- a/src/graphics/LoaderQueue.h +++ b/src/graphics/LoaderQueue.h @@ -22,7 +22,7 @@ #define LOADERQUEUE_H #include "GraphicsCache.h" -#include "frontends/Timeout.h" +#include "support/Timeout.h" #include #include diff --git a/src/support/FileMonitor.cpp b/src/support/FileMonitor.cpp index 039d9a8978..595f3e0da0 100644 --- a/src/support/FileMonitor.cpp +++ b/src/support/FileMonitor.cpp @@ -13,9 +13,7 @@ #include "support/FileMonitor.h" #include "support/FileName.h" #include "support/lyxlib.h" - -// FIXME Interface violation -#include "frontends/Timeout.h" +#include "support/Timeout.h" #include #include diff --git a/src/support/Forkedcall.cpp b/src/support/Forkedcall.cpp index 3bb61df9a6..4a9d0539ae 100644 --- a/src/support/Forkedcall.cpp +++ b/src/support/Forkedcall.cpp @@ -30,11 +30,10 @@ #include "support/lyxlib.h" #include "support/filetools.h" #include "support/os.h" +#include "support/Timeout.h" #include "debug.h" -#include "frontends/Timeout.h" - #include #include diff --git a/src/support/Makefile.am b/src/support/Makefile.am index 3545b550be..2e6fc5aa0b 100644 --- a/src/support/Makefile.am +++ b/src/support/Makefile.am @@ -81,6 +81,8 @@ liblyxsupport_la_SOURCES = \ textutils.cpp \ textutils.h \ Translator.h \ + Timeout.cpp \ + Timeout.h \ types.h \ userinfo.cpp \ userinfo.h \ diff --git a/src/support/Timeout.cpp b/src/support/Timeout.cpp new file mode 100644 index 0000000000..e2123ac7bc --- /dev/null +++ b/src/support/Timeout.cpp @@ -0,0 +1,155 @@ +/** + * \file qtTimeout.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Levon + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include +#include + +#include "debug.h" +#include "Timeout.h" + + +namespace lyx { + +/** + * This class executes the callback when the timeout expires + * using Qt mechanisms + */ +class qtTimeout : QObject, public Timeout::Impl { +public: + /// + qtTimeout(Timeout & owner_); + /// + virtual bool running() const; + /// start the timer + virtual void start(); + /// stop the timer + virtual void stop(); + /// reset + virtual void reset(); + +protected: + /// slot + virtual void timerEvent(QTimerEvent *); + +private: + /// timout id + int timeout_id; +}; + + +Timeout::Timeout(unsigned int msec, Type t) + : pimpl_(new qtTimeout(*this)), type(t), timeout_ms(msec) +{} + + +qtTimeout::qtTimeout(Timeout & owner) + : Timeout::Impl(owner), timeout_id(-1) +{} + + +void qtTimeout::timerEvent(QTimerEvent *) +{ + emit(); +} + + +void qtTimeout::reset() +{ + if (timeout_id != -1) + killTimer(timeout_id); + timeout_id = -1; +} + + +bool qtTimeout::running() const +{ + return timeout_id != -1; +} + + +void qtTimeout::start() +{ + if (running()) + lyxerr << "Timeout::start: already running!" << std::endl; + timeout_id = startTimer(timeout_ms()); +} + + +void qtTimeout::stop() +{ + if (running()) + reset(); +} + + +// +// Timeoute +// + +Timeout::~Timeout() +{ + pimpl_->stop(); +} + + +bool Timeout::running() const +{ + return pimpl_->running(); +} + + +void Timeout::start() +{ + pimpl_->start(); +} + + +void Timeout::stop() +{ + pimpl_->stop(); +} + + +void Timeout::restart() +{ + pimpl_->stop(); + pimpl_->start(); +} + + +void Timeout::emit() +{ + pimpl_->reset(); + timeout(); + if (type == CONTINUOUS) + pimpl_->start(); +} + + +Timeout & Timeout::setType(Type t) +{ + type = t; + return * this; +} + + +Timeout & Timeout::setTimeout(unsigned int msec) +{ + // Can't have a timeout of zero! + BOOST_ASSERT(msec); + + timeout_ms = msec; + return * this; +} + + +} // namespace lyx diff --git a/src/frontends/Timeout.h b/src/support/Timeout.h similarity index 97% rename from src/frontends/Timeout.h rename to src/support/Timeout.h index f39197d478..62118b20ff 100644 --- a/src/frontends/Timeout.h +++ b/src/support/Timeout.h @@ -1,10 +1,9 @@ // -*- C++ -*- /** - * \file Timeout.h + * \file qtTimeout.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Lars Gullik Bjønnes * \author John Levon * * Full author contact details are available in file CREDITS. @@ -18,7 +17,6 @@ namespace lyx { - /** * This class executes the callback when the timeout expires. */ diff --git a/src/support/lyxtime.cpp b/src/support/lyxtime.cpp index 90fac03343..b24e19e917 100644 --- a/src/support/lyxtime.cpp +++ b/src/support/lyxtime.cpp @@ -11,7 +11,6 @@ #include #include "support/lyxtime.h" -#include "LyXRC.h" using std::string; @@ -31,10 +30,4 @@ string const formatted_time(time_type t, string const & fmt) return string(date); } - -string const formatted_time(time_type t) -{ - return formatted_time(t, lyxrc.date_insert_format); -} - } // namespace lyx diff --git a/src/support/lyxtime.h b/src/support/lyxtime.h index 71d62fcee9..a84e391bfe 100644 --- a/src/support/lyxtime.h +++ b/src/support/lyxtime.h @@ -29,12 +29,6 @@ time_type current_time(); */ std::string const formatted_time(time_type t, std::string const & fmt); -/** Returns a locale-dependent formatting of the date - *  and time encoded in \c time. For the formatting, - * \c lyxrc.date_insert_format is being used. - */ -std::string const formatted_time(time_type t); - }; // namespace lyx #endif // LYXTIME_H diff --git a/src/tex2lyx/Makefile.am b/src/tex2lyx/Makefile.am index d7cae0c868..9154ef60da 100644 --- a/src/tex2lyx/Makefile.am +++ b/src/tex2lyx/Makefile.am @@ -51,14 +51,7 @@ tex2lyx_SOURCES = \ tex2lyx_LDADD = \ $(top_builddir)/src/support/liblyxsupport.la \ - $(top_builddir)/src/liblyxcore.la \ - $(top_builddir)/src/liblyxinsets.la \ - $(top_builddir)/src/liblyxmathed.la \ - $(top_builddir)/src/liblyxgraphics.la \ - $(top_builddir)/src/frontends/liblyxfrontends.la \ - $(top_builddir)/src/frontends/controllers/liblyxcontrollers.la \ - $(top_builddir)/src/frontends/qt4/liblyxqt4.la \ - $(BOOST_LIBS) $(LIBICONV) @LIBS@ $(QT4_LIB) $(AIKSAURUS_LIBS) + $(top_builddir)/boost/liblyxboost.la $(LINKED_FILES) : @rm -f $@ ; \ -- 2.39.2