]> git.lyx.org Git - features.git/commitdiff
Pimpl stuff in GuiApplication.
authorAbdelrazak Younes <younes@lyx.org>
Fri, 23 May 2008 08:43:07 +0000 (08:43 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 23 May 2008 08:43:07 +0000 (08:43 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24895 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiApplication.h
src/frontends/qt4/GuiBranches.cpp
src/frontends/qt4/GuiDelimiter.cpp
src/frontends/qt4/GuiFontLoader.h
src/frontends/qt4/GuiPainter.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/GuiSymbols.cpp
src/frontends/qt4/GuiWorkArea.cpp

index 2a5e318a46538dc61b0270ce8d05278c37370f43..ed44a153d709131d9b368a541379420b56b5a40f 100644 (file)
 
 #include "GuiApplication.h"
 
-#include "qt_helpers.h"
+#include "ColorCache.h"
+#include "GuiClipboard.h"
 #include "GuiImage.h"
 #include "GuiKeySymbol.h"
+#include "GuiSelection.h"
 #include "GuiView.h"
+#include "Menus.h"
+#include "qt_helpers.h"
 
 #include "frontends/alert.h"
 #include "frontends/Application.h"
@@ -89,6 +93,7 @@
 #include <boost/bind.hpp>
 
 #include <exception>
+#include <map>
 
 using namespace std;
 using namespace lyx::support;
@@ -327,7 +332,7 @@ public:
 
 struct GuiApplication::Private
 {
-       Private(): global_menubar_(0)
+       Private(): language_model_(0), global_menubar_(0)
        {
 #ifdef Q_WS_MACX
                // Create the global default menubar which is shown for the dialogs
@@ -336,6 +341,37 @@ struct GuiApplication::Private
 #endif
        }
 
+       ///
+       QSortFilterProxyModel * language_model_;
+       ///
+       GuiClipboard clipboard_;
+       ///
+       GuiSelection selection_;
+       ///
+       FontLoader font_loader_;
+       ///
+       ColorCache color_cache_;
+       ///
+       QTranslator qt_trans_;
+       ///
+       std::map<int, SocketNotifier *> socket_notifiers_;
+       ///
+       Menus menus_;
+       /// this timer is used for any regular events one wants to
+       /// perform. at present it is used to check if forked processes
+       /// are done.
+       QTimer general_timer_;
+
+       /// Multiple views container.
+       /**
+       * Warning: This must not be a smart pointer as the destruction of the
+       * object is handled by Qt when the view is closed
+       * \sa Qt::WA_DeleteOnClose attribute.
+       */
+       std::map<int, GuiView *> views_;
+       ///
+       std::vector<int> view_ids_;
+
        /// Only used on mac.
        GlobalMenuBar * global_menubar_;
 
@@ -356,7 +392,6 @@ struct GuiApplication::Private
 
 GuiApplication * guiApp;
 
-
 GuiApplication::~GuiApplication()
 {
 #ifdef Q_WS_MACX
@@ -367,8 +402,7 @@ GuiApplication::~GuiApplication()
 
 
 GuiApplication::GuiApplication(int & argc, char ** argv)
-       : QApplication(argc, argv), Application(), language_model_(0),
-       current_view_(0), d(new GuiApplication::Private)
+       : QApplication(argc, argv),     current_view_(0), d(new GuiApplication::Private)
 {
        QString app_name = "LyX";
        QCoreApplication::setOrganizationName(app_name);
@@ -403,10 +437,10 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
        // Short-named translator can be loaded from a long name, but not the
        // opposite. Therefore, long name should be used without truncation.
        // c.f. http://doc.trolltech.com/4.1/qtranslator.html#load
-       if (qt_trans_.load(language_name,
+       if (d->qt_trans_.load(language_name,
                QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
        {
-               installTranslator(&qt_trans_);
+               installTranslator(&d->qt_trans_);
                // even if the language calls for RtL, don't do that
                setLayoutDirection(Qt::LeftToRight);
                LYXERR(Debug::GUI, "Successfully installed Qt translations for locale "
@@ -448,10 +482,10 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
        if (lyxrc.typewriter_font_name.empty())
                lyxrc.typewriter_font_name = fromqstr(typewriterFontName());
 
-       general_timer_.setInterval(500);
-       connect(&general_timer_, SIGNAL(timeout()),
+       d->general_timer_.setInterval(500);
+       connect(&d->general_timer_, SIGNAL(timeout()),
                this, SLOT(handleRegularEvents()));
-       general_timer_.start();
+       d->general_timer_.start();
 }
 
 
@@ -463,7 +497,7 @@ FuncStatus GuiApplication::getStatus(FuncRequest const & cmd)
        switch(cmd.action) {
 
        case LFUN_WINDOW_CLOSE:
-               enable = view_ids_.size() > 0;
+               enable = d->view_ids_.size() > 0;
                break;
 
        default:
@@ -506,7 +540,7 @@ bool GuiApplication::dispatch(FuncRequest const & cmd)
 
        case LFUN_SCREEN_FONT_UPDATE: {
                // handle the screen font changes.
-               font_loader_.update();
+               d->font_loader_.update();
                // Backup current_view_
                GuiView * view = current_view_;
                // Set current_view_ to zero to forbid GuiWorkArea::redraw()
@@ -567,7 +601,7 @@ bool GuiApplication::dispatch(FuncRequest const & cmd)
 void GuiApplication::resetGui()
 {
        map<int, GuiView *>::iterator it;
-       for (it = views_.begin(); it != views_.end(); ++it)
+       for (it = d->views_.begin(); it != d->views_.end(); ++it)
                it->second->resetDialogs();
 
        dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
@@ -591,9 +625,9 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow)
                d->global_menubar_->releaseKeyboard();
 
        // create new view
-       updateIds(views_, view_ids_);
+       updateIds(d->views_, d->view_ids_);
        int id = 0;
-       while (views_.find(id) != views_.end())
+       while (d->views_.find(id) != d->views_.end())
                id++;
        GuiView * view = new GuiView(id);
        
@@ -602,8 +636,8 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow)
                view->setIconSize(current_view_->iconSize());
 
        // register view
-       views_[id] = view;
-       updateIds(views_, view_ids_);
+       d->views_[id] = view;
+       updateIds(d->views_, d->view_ids_);
 
        if (autoShow) {
                view->show();
@@ -628,17 +662,50 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow)
 }
 
 
-
-
 Clipboard & GuiApplication::clipboard()
 {
-       return clipboard_;
+       return d->clipboard_;
 }
 
 
 Selection & GuiApplication::selection()
 {
-       return selection_;
+       return d->selection_;
+}
+
+
+FontLoader & GuiApplication::fontLoader() 
+{
+       return d->font_loader_;
+}
+
+
+Menus const & GuiApplication::menus() const 
+{
+       return d->menus_;
+}
+
+
+Menus & GuiApplication::menus()
+{
+       return d->menus_; 
+}
+
+
+size_t GuiApplication::viewCount() const
+{
+       return d->view_ids_.size();
+}
+
+
+vector<int> const & GuiApplication::viewIds()
+{
+       return d->view_ids_;
+}
+
+ColorCache & GuiApplication::colorCache()
+{
+       return d->color_cache_;
 }
 
 
@@ -662,8 +729,8 @@ void GuiApplication::execBatchCommands()
 
 QAbstractItemModel * GuiApplication::languageModel()
 {
-       if (language_model_)
-               return language_model_;
+       if (d->language_model_)
+               return d->language_model_;
 
        QStandardItemModel * lang_model = new QStandardItemModel(this);
        lang_model->insertColumns(0, 1);
@@ -677,12 +744,12 @@ QAbstractItemModel * GuiApplication::languageModel()
                lang_model->setData(item, qt_(it->second.display()), Qt::DisplayRole);
                lang_model->setData(item, toqstr(it->second.lang()), Qt::UserRole);
        }
-       language_model_ = new QSortFilterProxyModel(this);
-       language_model_->setSourceModel(lang_model);
+       d->language_model_ = new QSortFilterProxyModel(this);
+       d->language_model_->setSourceModel(lang_model);
 #if QT_VERSION >= 0x040300
-       language_model_->setSortLocaleAware(true);
+       d->language_model_->setSortLocaleAware(true);
 #endif
-       return language_model_;
+       return d->language_model_;
 }
 
 
@@ -823,7 +890,7 @@ bool GuiApplication::notify(QObject * receiver, QEvent * event)
 
 bool GuiApplication::getRgbColor(ColorCode col, RGBColor & rgbcol)
 {
-       QColor const & qcol = color_cache_.get(col);
+       QColor const & qcol = d->color_cache_.get(col);
        if (!qcol.isValid()) {
                rgbcol.r = 0;
                rgbcol.g = 0;
@@ -839,35 +906,35 @@ bool GuiApplication::getRgbColor(ColorCode col, RGBColor & rgbcol)
 
 string const GuiApplication::hexName(ColorCode col)
 {
-       return ltrim(fromqstr(color_cache_.get(col).name()), "#");
+       return ltrim(fromqstr(d->color_cache_.get(col).name()), "#");
 }
 
 
 void GuiApplication::updateColor(ColorCode)
 {
        // FIXME: Bleh, can't we just clear them all at once ?
-       color_cache_.clear();
+       d->color_cache_.clear();
 }
 
 
 void GuiApplication::registerSocketCallback(int fd, SocketCallback func)
 {
        SocketNotifier * sn = new SocketNotifier(this, fd, func);
-       socket_notifiers_[fd] = sn;
+       d->socket_notifiers_[fd] = sn;
        connect(sn, SIGNAL(activated(int)), this, SLOT(socketDataReceived(int)));
 }
 
 
 void GuiApplication::socketDataReceived(int fd)
 {
-       socket_notifiers_[fd]->func_();
+       d->socket_notifiers_[fd]->func_();
 }
 
 
 void GuiApplication::unregisterSocketCallback(int fd)
 {
-       socket_notifiers_[fd]->setEnabled(false);
-       socket_notifiers_.erase(fd);
+       d->socket_notifiers_[fd]->setEnabled(false);
+       d->socket_notifiers_.erase(fd);
 }
 
 
@@ -887,52 +954,52 @@ void GuiApplication::commitData(QSessionManager & sm)
 
 bool GuiApplication::unregisterView(int id)
 {
-       updateIds(views_, view_ids_);
-       LASSERT(views_.find(id) != views_.end(), /**/);
-       LASSERT(views_[id], /**/);
+       updateIds(d->views_, d->view_ids_);
+       LASSERT(d->views_.find(id) != d->views_.end(), /**/);
+       LASSERT(d->views_[id], /**/);
 
        map<int, GuiView *>::iterator it;
-       for (it = views_.begin(); it != views_.end(); ++it) {
+       for (it = d->views_.begin(); it != d->views_.end(); ++it) {
                if (it->first == id) {
-                       views_.erase(id);
+                       d->views_.erase(id);
                        break;
                }
        }
-       updateIds(views_, view_ids_);
+       updateIds(d->views_, d->view_ids_);
        return true;
 }
 
 
 bool GuiApplication::closeAllViews()
 {
-       updateIds(views_, view_ids_);
-       if (views_.empty())
+       updateIds(d->views_, d->view_ids_);
+       if (d->views_.empty())
                return true;
 
-       map<int, GuiView*> const cmap = views_;
+       map<int, GuiView*> const cmap = d->views_;
        map<int, GuiView*>::const_iterator it;
        for (it = cmap.begin(); it != cmap.end(); ++it) {
                if (!it->second->close())
                        return false;
        }
 
-       views_.clear();
-       view_ids_.clear();
+       d->views_.clear();
+       d->view_ids_.clear();
        return true;
 }
 
 
 GuiView & GuiApplication::view(int id) const
 {
-       LASSERT(views_.find(id) != views_.end(), /**/);
-       return *views_.find(id)->second;
+       LASSERT(d->views_.find(id) != d->views_.end(), /**/);
+       return *d->views_.find(id)->second;
 }
 
 
 void GuiApplication::hideDialogs(string const & name, Inset * inset) const
 {
-       vector<int>::const_iterator it = view_ids_.begin();
-       vector<int>::const_iterator const end = view_ids_.end();
+       vector<int>::const_iterator it = d->view_ids_.begin();
+       vector<int>::const_iterator const end = d->view_ids_.end();
        for (; it != end; ++it)
                view(*it).hideDialog(name, inset);
 }
@@ -941,8 +1008,8 @@ void GuiApplication::hideDialogs(string const & name, Inset * inset) const
 Buffer const * GuiApplication::updateInset(Inset const * inset) const
 {
        Buffer const * buffer_ = 0;
-       vector<int>::const_iterator it = view_ids_.begin();
-       vector<int>::const_iterator const end = view_ids_.end();
+       vector<int>::const_iterator it = d->view_ids_.begin();
+       vector<int>::const_iterator const end = d->view_ids_.end();
        for (; it != end; ++it) {
                Buffer const * ptr = view(*it).updateInset(inset);
                if (ptr)
index 4f8c02528edfd42ccdcba3a0de2df78d91d91c59..288679c1d7cf7fe21c4976347121115a96bcf355 100644 (file)
 #ifndef GUIAPPLICATION_H
 #define GUIAPPLICATION_H
 
-#include "ColorCache.h"
-#include "FontLoader.h"
-#include "GuiClipboard.h"
-#include "GuiSelection.h"
-#include "Menus.h"
-
 #include "frontends/Application.h"
 
 #include <QObject>
 #include <QApplication>
-#include <QTimer>
-#include <QTranslator>
 
-#include <map>
 #include <vector>
 
 class QSessionManager;
@@ -36,6 +27,7 @@ class QSortFilterProxyModel;
 namespace lyx {
 
 class BufferView;
+class ColorCache;
 
 namespace frontend {
 
@@ -43,6 +35,7 @@ class GuiView;
 class LyXView;
 class GlobalMenuBar;
 class GuiWorkArea;
+class Menus;
 class SocketNotifier;
 
 /// The Qt main application class
@@ -60,28 +53,30 @@ public:
 
        /// Method inherited from \c Application class
        //@{
-       virtual FuncStatus getStatus(FuncRequest const &);
-       virtual bool dispatch(FuncRequest const &);
-       virtual void resetGui();
+       FuncStatus getStatus(FuncRequest const &);
+       bool dispatch(FuncRequest const &);
+       void resetGui();
        void restoreGuiSession();
-       virtual Clipboard & clipboard();
-       virtual Selection & selection();
-       virtual FontLoader & fontLoader() { return font_loader_; }
-       virtual int exec();
-       virtual void exit(int status);
-       virtual bool event(QEvent * e);
-       virtual bool getRgbColor(ColorCode col, RGBColor & rgbcol);
-       virtual std::string const hexName(ColorCode col);
-       virtual void updateColor(ColorCode col);
-       virtual void readMenus(Lexer & lex);
-       virtual void initGlobalMenu();
-       virtual void registerSocketCallback(int fd, SocketCallback func);
+       Clipboard & clipboard();
+       Selection & selection();
+       FontLoader & fontLoader();
+       int exec();
+       void exit(int status);
+       bool event(QEvent * e);
+       bool getRgbColor(ColorCode col, RGBColor & rgbcol);
+       std::string const hexName(ColorCode col);
+       void updateColor(ColorCode col);
+       void readMenus(Lexer & lex);
+       void initGlobalMenu();
+       void registerSocketCallback(int fd, SocketCallback func);
        void unregisterSocketCallback(int fd);
        bool searchMenu(FuncRequest const & func, std::vector<docstring> & names) const;
+       void hideDialogs(std::string const & name, Inset * inset) const;
+       Buffer const * updateInset(Inset const * inset) const;
        //@}
 
-       Menus const & menus() const { return menus_; }
-       Menus & menus() { return menus_; }
+       Menus const & menus() const;
+       Menus & menus();
        /// Methods inherited from \c QApplication class
        //@{
        bool notify(QObject * receiver, QEvent * event);
@@ -102,31 +97,27 @@ public:
        ///
        void setCurrentView(GuiView * view) { current_view_ = view; }
        ///
-       virtual size_t viewCount() const { return view_ids_.size(); }
+       size_t viewCount() const;
        ///
-       std::vector<int> const & viewIds() { return view_ids_; }
+       std::vector<int> const & viewIds();
 
        ///
-       ColorCache & colorCache() { return color_cache_; }
+       ColorCache & colorCache();
 
        QAbstractItemModel * languageModel();
 
        /// return a suitable serif font name.
-       virtual QString const romanFontName();
+       QString const romanFontName();
 
        /// return a suitable sans serif font name.
-       virtual QString const sansFontName();
+       QString const sansFontName();
 
        /// return a suitable monospaced font name.
-       virtual QString const typewriterFontName();
-       ///
-       virtual bool unregisterView(int id);
-       ///
-       virtual GuiView & view(int id) const;
+       QString const typewriterFontName();
        ///
-       virtual void hideDialogs(std::string const & name, Inset * inset) const;
+       bool unregisterView(int id);
        ///
-       virtual Buffer const * updateInset(Inset const * inset) const;
+       GuiView & view(int id) const;
 
 private Q_SLOTS:
        ///
@@ -141,36 +132,6 @@ private Q_SLOTS:
 private:
        ///
        bool closeAllViews();
-       ///
-       GuiClipboard clipboard_;
-       ///
-       GuiSelection selection_;
-       ///
-       FontLoader font_loader_;
-       ///
-       ColorCache color_cache_;
-       ///
-       QSortFilterProxyModel * language_model_;
-       ///
-       QTranslator qt_trans_;
-       ///
-       std::map<int, SocketNotifier *> socket_notifiers_;
-       ///
-       Menus menus_;
-       /// this timer is used for any regular events one wants to
-       /// perform. at present it is used to check if forked processes
-       /// are done.
-       QTimer general_timer_;
-
-       /// Multiple views container.
-       /**
-       * Warning: This must not be a smart pointer as the destruction of the
-       * object is handled by Qt when the view is closed
-       * \sa Qt::WA_DeleteOnClose attribute.
-       */
-       std::map<int, GuiView *> views_;
-       ///
-       std::vector<int> view_ids_;
        /// This LyXView is the one receiving Clipboard and Selection
        /// events
        GuiView * current_view_;
index cbef8d399af7990f352be97be5c7554d15dcb30c..3ae5d9a6006086698312202a301342ba0452fb99 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "GuiBranches.h"
 
+#include "ColorCache.h"
 #include "GuiApplication.h"
 #include "Validator.h"
 #include "qt_helpers.h"
index 22fd1b6fbd60080db53303bf0428dd3432860c5f..3196cc5bf113e285a8fb28348ec3c1051d1bd7a0 100644 (file)
 #include "GuiApplication.h"
 #include "GuiFontLoader.h"
 #include "GuiView.h"
-
 #include "qt_helpers.h"
+
+#include "FontInfo.h"
+
 #include "support/gettext.h"
 
 #include <QPixmap>
index 35be5eae11add1ffb7942d0f6397f856ed3ee182..40c15f5ea0b60ab6391a5ae2532d76257b34f23d 100644 (file)
@@ -15,6 +15,9 @@
 class QFont;
 
 namespace lyx {
+
+class FontInfo;
+
 namespace frontend {
 
 class GuiFontMetrics;
index 07330aa4cde840de8fa3599b9e1660f658cb50d0..ebcbf74c593572b8bd91d226c41b605d455fd24e 100644 (file)
 
 #include "GuiPainter.h"
 
+#include "ColorCache.h"
 #include "GuiApplication.h"
 #include "GuiFontLoader.h"
 #include "GuiFontMetrics.h"
 #include "GuiImage.h"
 #include "qt_helpers.h"
 
+#include "FontInfo.h"
 #include "Language.h"
 #include "LyXRC.h"
 
+#include "insets/Inset.h"
+
 #include "support/lassert.h"
 #include "support/debug.h"
 
index 041d74df7bbcd186ef47bf92d36f2374a6b57652..6d34cf5e6a1bd304955266b81aaf2d0418111e24 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "GuiPrefs.h"
 
+#include "ColorCache.h"
 #include "FileDialog.h"
 #include "GuiApplication.h"
 #include "GuiFontExample.h"
@@ -23,6 +24,7 @@
 #include "BufferList.h"
 #include "Color.h"
 #include "ConverterCache.h"
+#include "FontEnums.h"
 #include "FuncRequest.h"
 #include "KeyMap.h"
 #include "KeySequence.h"
@@ -45,6 +47,7 @@
 
 #include "frontends/alert.h"
 #include "frontends/Application.h"
+#include "frontends/FontLoader.h"
 
 #include <QAbstractItemModel>
 #include <QCheckBox>
index 9eb902be32040dcd23d18872206ed2b75fd12690..864b7b49c41cd6ea416b7e65e4ac1311a33486c6 100644 (file)
@@ -19,6 +19,7 @@
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
+#include "Cursor.h"
 #include "Encoding.h"
 #include "FuncRequest.h"
 
index ca3cdb90ce7bb7923dc55560e56648baa7bd074c..d7d597021cfae7c4d4c3ca1b028f922e62dbab89 100644 (file)
 
 #include "GuiWorkArea.h"
 
+#include "ColorCache.h"
+#include "FontLoader.h"
+#include "Menus.h"
+
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"