]> git.lyx.org Git - features.git/commitdiff
some remnaming
authorAndré Pönitz <poenitz@gmx.net>
Sat, 15 Sep 2007 20:31:50 +0000 (20:31 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 15 Sep 2007 20:31:50 +0000 (20:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20298 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/Application.h
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiApplication.h
src/frontends/qt4/Makefile.am
src/frontends/qt4/SocketCallback.cpp
src/frontends/qt4/SocketCallback.h

index 3907669f07767475872e9f764e13e073be1987cc..90bd21b5074efa388f59d1253b5616a3d98287f9 100644 (file)
@@ -203,8 +203,8 @@ public:
        * add a callback for socket read notification
        * @param fd socket descriptor (file/socket/etc)
        */
-       virtual void registerSocketCallback(
-               int fd, boost::function<void()> func) = 0;
+       typedef boost::function<void()> SocketCallback;
+       virtual void registerSocketCallback( int fd, SocketCallback func) = 0;
 
        /**
        * remove a I/O read callback
index a65f1d0a3367139d39bb49a99d24c59a5fe63ac7..45426165a74d7f449b06e90ff3f3aa7571391a9e 100644 (file)
@@ -16,7 +16,6 @@
 
 #include "qt_helpers.h"
 #include "GuiImage.h"
-#include "SocketCallback.h"
 
 #include "frontends/LyXView.h"
 
@@ -45,6 +44,7 @@
 #include <QLibraryInfo>
 #include <QPixmapCache>
 #include <QSessionManager>
+#include <QSocketNotifier>
 #include <QTextCodec>
 #include <QTimer>
 #include <QTranslator>
@@ -73,12 +73,30 @@ frontend::Application * createApplication(int & argc, char * argv[])
 
 namespace frontend {
 
+class SocketNotifier : public QSocketNotifier
+{
+public:
+       /// connect a connection notification from the LyXServerSocket
+       SocketNotifier(QObject * parent, int fd, Application::SocketCallback func)
+               : QSocketNotifier(fd, QSocketNotifier::Read, parent), func_(func)
+       {}
+
+public:
+       /// The callback function
+       Application::SocketCallback func_;
+};
+
+
 ////////////////////////////////////////////////////////////////////////
 // Mac specific stuff goes here...
 
 class MenuTranslator : public QTranslator
 {
 public:
+       MenuTranslator(QObject * parent)
+               : QTranslator(parent)
+       {}
+
        QString translate(const char * /*context*/, 
          const char * sourceText, 
          const char * /*comment*/ = 0) 
@@ -105,7 +123,7 @@ GuiApplication * guiApp;
 
 
 GuiApplication::GuiApplication(int & argc, char ** argv)
-       : QApplication(argc, argv), Application(argc, argv), menu_trans_(0)
+       : QApplication(argc, argv), Application(argc, argv)
 {
        // Qt bug? setQuitOnLastWindowClosed(true); does not work
        setQuitOnLastWindowClosed(false);
@@ -165,8 +183,7 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
 
 GuiApplication::~GuiApplication()
 {
-       delete menu_trans_;
-       socket_callbacks_.clear();
+       socket_notifiers_.clear();
 }
 
 
@@ -321,15 +338,23 @@ void GuiApplication::updateColor(Color_color)
 }
 
 
-void GuiApplication::registerSocketCallback(int fd, boost::function<void()> func)
+void GuiApplication::registerSocketCallback(int fd, SocketCallback func)
+{
+       SocketNotifier * sn = new SocketNotifier(this, fd, func);
+       socket_notifiers_[fd] = sn;
+       connect(sn, SIGNAL(activated(int)), this, SLOT(socketDataReceived(int)));
+}
+
+
+void GuiApplication::socketDataReceived(int fd)
 {
-       socket_callbacks_[fd] = new SocketCallback(this, fd, func);
+       socket_notifiers_[fd]->func_();
 }
 
 
 void GuiApplication::unregisterSocketCallback(int fd)
 {
-       socket_callbacks_.erase(fd);
+       socket_notifiers_.erase(fd);
 }
 
 
@@ -383,8 +408,7 @@ bool GuiApplication::x11EventFilter(XEvent * xev)
 
 void GuiApplication::addMenuTranslator()
 {
-       menu_trans_ = new MenuTranslator();
-       installTranslator(menu_trans_);
+       installTranslator(new MenuTranslator(this));
 }
 
 
index 17dfd1a3b5307c95eaecd95d3ba4e2c2264abfb0..87b7391e38aaa0a7467eda9eeb9d3bda36a4d246 100644 (file)
@@ -29,12 +29,12 @@ class QSessionManager;
 namespace lyx {
 
 class BufferView;
-class SocketCallback;
 
 namespace frontend {
 
 class GuiWorkArea;
 class MenuTranslator;
+class SocketNotifier;
 
 /// The Qt main application class
 /**
@@ -69,8 +69,7 @@ public:
        virtual bool getRgbColor(Color_color col, RGBColor & rgbcol);
        virtual std::string const hexName(Color_color col);
        virtual void updateColor(Color_color col);
-       virtual void registerSocketCallback(
-               int fd, boost::function<void()> func);
+       virtual void registerSocketCallback(int fd, SocketCallback func);
        void unregisterSocketCallback(int fd);
        //@}
 
@@ -89,6 +88,8 @@ public:
 private Q_SLOTS:
        ///
        void execBatchCommands();
+       ///
+       void socketDataReceived(int fd);
 
 private:
        ///
@@ -104,7 +105,7 @@ private:
        ///
        QTranslator qt_trans_;
        ///
-       std::map<int, SocketCallback *> socket_callbacks_;
+       std::map<int, SocketNotifier *> socket_notifiers_;
 
 #ifdef Q_WS_X11
 public:
index 60e2802bdba79faf3f4df08c828d1d6d22b9688e..6b3d7bc1db8ef961e1e669a76e9b3b2f5a8bcdc2 100644 (file)
@@ -111,7 +111,6 @@ SOURCEFILES = \
        LyXFileDialog.cpp \
        PanelStack.cpp \
        qt_helpers.cpp \
-       SocketCallback.cpp \
        TocModel.cpp \
        TocWidget.cpp \
        Validator.cpp 
@@ -194,7 +193,6 @@ MOCHEADER = \
        LyXFileDialog.h \
        PanelStack.h \
        qlkey.h \
-       SocketCallback.h \
        TocModel.h \
        TocWidget.h \
        Validator.h
index 83971edd8cc4a63b972042ddb195fd26d7723498..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,36 +0,0 @@
-/**
- * \file io_callback.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author unknown
- * \author John Levon
- * \author João Luis M. Assirati
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "SocketCallback.h"
-
-
-namespace lyx {
-
-SocketCallback::SocketCallback(QObject * parent,
-               int fd, boost::function<void()> func)
-       : QObject(parent), func_(func)
-{
-       sn_ = new QSocketNotifier(fd, QSocketNotifier::Read, this);
-       connect(sn_, SIGNAL(activated(int)), this, SLOT(dataReceived()));
-}
-
-
-void SocketCallback::dataReceived()
-{
-       func_();
-}
-
-} // namespace lyx
-
-#include "SocketCallback_moc.cpp"
index 1c6b4633e3650a3e1cf47669fd949831ca98eed5..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,55 +0,0 @@
-// -*- C++ -*-
-/**
- * \file io_callback.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author unknown
- * \author John Levon
- * \author João Luis M. Assirati
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef SOCKET_CALLBACK_H
-#define SOCKET_CALLBACK_H
-
-#include <QObject>
-#include <QSocketNotifier>
-
-#include <boost/function.hpp>
-
-
-namespace lyx {
-
-/**
- * socket_callback - a simple wrapper for asynchronous socket notification
- *
- * This is used by the lyxsocket to notice the socket is ready to be
- * connected/read.
- *
- * FIXME: this code apparently will not work on Windows.
- */
-
-class SocketCallback : public QObject
-{
-       Q_OBJECT
-
-public:
-       /// connect a connection notification from the LyXServerSocket
-       SocketCallback(QObject * parent, int fd, boost::function<void()> func);
-
-public Q_SLOTS:
-       void dataReceived();
-
-private:
-       /// Our notifier
-       QSocketNotifier * sn_;
-       /// The callback function
-       boost::function<void()> func_;
-};
-
-
-} // namespace lyx
-
-#endif // SOCKET_CALLBACK_H