]> git.lyx.org Git - features.git/commitdiff
Move more methods from WorkArea to Clipboard in qt3 and gtk
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 8 Jul 2006 15:11:18 +0000 (15:11 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 8 Jul 2006 15:11:18 +0000 (15:11 +0000)
* src/frontends/gtk/GWorkArea.[Ch]
(getClipboard): Move to GuiClipboard.[Ch]
(putClipboard): ditto

* src/frontends/gtk/Makefile.am: add GuiClipboard.C

* src/frontends/gtk/GuiClipboard.C: new file

* src/frontends/gtk/GuiClipboard.h
(get, put): only declare

* src/frontends/qt3/Makefile.am: add GuiClipboard.C

* src/frontends/qt3/QWorkArea.[Ch]
(getClipboard): Move to GuiClipboard.[Ch]
(putClipboard): ditto

* src/frontends/qt3/GuiClipboard.C: new file

* src/frontends/qt3/GuiClipboard.h
(get, put): only declare

* src/frontends/qt4/GuiClipboard.C: remove unneeded include
(GuiClipboard::get): adjust debug output
(GuiClipboard::put): ditto

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14378 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/gtk/GWorkArea.C
src/frontends/gtk/GWorkArea.h
src/frontends/gtk/GuiClipboard.C [new file with mode: 0644]
src/frontends/gtk/GuiClipboard.h
src/frontends/gtk/Makefile.am
src/frontends/qt3/GuiClipboard.C [new file with mode: 0644]
src/frontends/qt3/GuiClipboard.h
src/frontends/qt3/Makefile.am
src/frontends/qt3/QWorkArea.C
src/frontends/qt3/QWorkArea.h
src/frontends/qt4/GuiClipboard.C

index 5eda32f7397ccbd0cb48b0b0135cfe0d58567715..19cad5cecffc4dedeb638b78f1669a1388dabafb 100644 (file)
@@ -519,27 +519,5 @@ void GWorkArea::haveSelection(bool toHave)
        }
 }
 
-
-// ENCODING: Gtk::Clipboard returns UTF-8, we assume that the backend
-// wants ISO-8859-1 and convert it to that.
-string const GWorkArea::getClipboard() const
-{
-       Glib::RefPtr<Gtk::Clipboard> clipboard =
-               Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
-       return Glib::convert_with_fallback(
-               clipboard->wait_for_text(), "ISO-8859-1", "UTF-8");
-}
-
-
-// ENCODING: we assume that the backend passes us ISO-8859-1 and
-// convert from that to UTF-8 before passing to GTK
-void GWorkArea::putClipboard(string const & str)
-{
-       Glib::RefPtr<Gtk::Clipboard> clipboard =
-               Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
-       clipboard->set_text(Glib::convert(str, "UTF-8", "ISO-8859-1"));
-}
-
-
 } // namespace frontend
 } // namespace lyx
index 46160aa451fae4c855fa37de7f656d5646105306..7c397c5c2eb107d5f05f1d43ccb17ae2a9f84748 100644 (file)
@@ -81,10 +81,6 @@ public:
        virtual void setScrollbarParams(int height, int pos, int line_height);
        /// a selection exists
        virtual void haveSelection(bool);
-       ///
-       virtual std::string const getClipboard() const;
-       ///
-       virtual void putClipboard(std::string const &);
        void inputCommit(gchar * str);
 private:
        bool onExpose(GdkEventExpose * event);
diff --git a/src/frontends/gtk/GuiClipboard.C b/src/frontends/gtk/GuiClipboard.C
new file mode 100644 (file)
index 0000000..7aecf52
--- /dev/null
@@ -0,0 +1,58 @@
+// -*- C++ -*-
+/**
+ * \file gtk/GuiClipboard.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Huang Ying
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+// Too hard to make concept checks work with this file
+#ifdef _GLIBCXX_CONCEPT_CHECKS
+#undef _GLIBCXX_CONCEPT_CHECKS
+#endif
+#ifdef _GLIBCPP_CONCEPT_CHECKS
+#undef _GLIBCPP_CONCEPT_CHECKS
+#endif
+
+#include "GuiClipboard.h"
+#include "debug.h"
+
+#include <gtkmm.h>
+
+using std::endl;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+// ENCODING: Gtk::Clipboard returns UTF-8, we assume that the backend
+// wants ISO-8859-1 and convert it to that.
+string const GuiClipboard::get() const
+{
+       Glib::RefPtr<Gtk::Clipboard> clipboard =
+               Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
+       string const str = Glib::convert_with_fallback(
+                       clipboard->wait_for_text(), "ISO-8859-1", "UTF-8");
+       lyxerr[Debug::ACTION] << "GuiClipboard::get: " << str << endl;
+       return str;
+}
+
+
+// ENCODING: we assume that the backend passes us ISO-8859-1 and
+// convert from that to UTF-8 before passing to GTK
+void GuiClipboard::put(string const & str)
+{
+       lyxerr[Debug::ACTION] << "GuiClipboard::put: " << str << endl;
+       Glib::RefPtr<Gtk::Clipboard> clipboard =
+               Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
+       clipboard->set_text(Glib::convert(str, "UTF-8", "ISO-8859-1"));
+}
+
+} // namespace frontend
+} // namespace lyx
index 1b481a2d9800dad10143bfe527e1211ce499ab78..93edbfe321814afa50f0f8e9fe9bd86c45d53729 100644 (file)
@@ -40,15 +40,9 @@ public:
                old_work_area_->haveSelection(own);
        }
 
-       std::string const get() const
-       {
-               return old_work_area_->getClipboard();
-       }
+       std::string const get() const;
 
-       void put(std::string const & str)
-       {
-               old_work_area_->putClipboard(str);
-       }
+       void put(std::string const & str);
        //@}
 
 private:
index 515d74b8a22bce6aa6f698b16d0b897130eb9e56..04d6ca53687e40862ec2ca626a1f9eb32538c545 100644 (file)
@@ -111,7 +111,7 @@ libgtk_la_SOURCES = \
        GToolbar.h \
        GUrl.C \
        GUrl.h \
-       GuiClipboard.h \
+       GuiClipboard.C GuiClipboard.h \
        GuiWorkArea.h \
        GView.C \
        GView.h \
diff --git a/src/frontends/qt3/GuiClipboard.C b/src/frontends/qt3/GuiClipboard.C
new file mode 100644 (file)
index 0000000..0961ded
--- /dev/null
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+/**
+ * \file qt3/GuiClipboard.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiClipboard.h"
+#include "qt_helpers.h"
+
+#include "debug.h"
+
+#include <qapplication.h>
+#include <qclipboard.h>
+#include <qstring.h>
+
+#include "support/lstrings.h"
+using lyx::support::internalLineEnding;
+using lyx::support::externalLineEnding;
+
+using std::endl;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+string const GuiClipboard::get() const
+{
+       QString const str = qApp->clipboard()->text(QClipboard::Selection);
+       lyxerr[Debug::ACTION] << "GuiClipboard::get: " << (const char*) str
+                             << endl;
+       if (str.isNull())
+               return string();
+
+       return internalLineEnding(fromqstr(str));
+}
+
+
+void GuiClipboard::put(string const & str)
+{
+       lyxerr[Debug::ACTION] << "GuiClipboard::put: " << str << endl;
+
+       qApp->clipboard()->setText(toqstr(externalLineEnding(str)),
+                                  QClipboard::Selection);
+}
+
+} // namespace frontend
+} // namespace lyx
index f79c697d56ea6039ff49431992cc746db8386532..89de0470343c79f5e189d0709d9a67f5d030d5d1 100644 (file)
 namespace lyx {
 namespace frontend {
 
-typedef QWorkArea FWorkArea;
-
 /**
  * The Qt3 version of the Clipboard.
  */
 class GuiClipboard: public lyx::frontend::Clipboard
 {
 public:
-       GuiClipboard(FWorkArea * work_area)
+       GuiClipboard(QWorkArea * work_area)
                : old_work_area_(work_area)
        {
        }
@@ -42,19 +40,13 @@ public:
                old_work_area_->haveSelection(own);
        }
 
-       std::string const get() const
-       {
-               return old_work_area_->getClipboard();
-       }
+       std::string const get() const;
 
-       void put(std::string const & str)
-       {
-               old_work_area_->putClipboard(str);
-       }
+       void put(std::string const & str);
        //@}
 
 private:
-       FWorkArea * old_work_area_;
+       QWorkArea * old_work_area_;
 };
 
 } // namespace frontend
index abaf567d01df2e49ec278046df6e8ab4c6f8a2b6..42af82c82b4aafdd3e98d4417dfea2a74e550811 100644 (file)
@@ -27,7 +27,7 @@ libqt3_la_SOURCES = \
        Alert_pimpl.C \
        Dialogs.C \
        FileDialog.C \
-       GuiClipboard.h \
+       GuiClipboard.C GuiClipboard.h \
        GuiImplementation.h \
        GuiWorkArea.h \
        LyXKeySymFactory.C \
index b16075f7e2e9d567100babbb0b80746433cc5842..9fe3273d42e215da6a642398cb6a683da83f3602 100644 (file)
@@ -210,23 +210,6 @@ void QWorkArea::haveSelection(bool own)
 }
 
 
-string const QWorkArea::getClipboard() const
-{
-       QApplication::clipboard()->setSelectionMode(true);
-       QString str = QApplication::clipboard()->text();
-       if (str.isNull())
-               return string();
-       return internalLineEnding(fromqstr(str));
-}
-
-
-void QWorkArea::putClipboard(string const & str)
-{
-       QApplication::clipboard()->setSelectionMode(true);
-       QApplication::clipboard()->setText(toqstr(externalLineEnding(str)));
-}
-
-
 void QWorkArea::dragEnterEvent(QDragEnterEvent * event)
 {
        event->accept(QUriDrag::canDecode(event));
index 84affb94295e5c1178e690aef1f3e0219d3a0065..f558d4817c5d52d030eb58e81a20cdd45330c376 100644 (file)
@@ -52,10 +52,6 @@ public:
        /// a selection exists
        virtual void haveSelection(bool);
        ///
-       virtual std::string const getClipboard() const;
-       ///
-       virtual void putClipboard(std::string const &);
-       ///
        virtual void dragEnterEvent(QDragEnterEvent * event);
        ///
        virtual void dropEvent(QDropEvent* event);
index 483fa814144f7212a1ae18def180976e24cb7674..6e951a4f45d14d73f25ae18554d8f15686b8c3da 100644 (file)
@@ -21,8 +21,6 @@
 #include <QClipboard>
 #include <QString>
 
-#include <string>
-
 #include "support/lstrings.h"
 using lyx::support::internalLineEnding;
 using lyx::support::externalLineEnding;
@@ -58,7 +56,8 @@ void GuiClipboard::haveSelection(bool own)
 string const GuiClipboard::get() const
 {
        QString str = qApp->clipboard()->text(CLIPBOARD_MODE);
-       lyxerr[Debug::ACTION] << "getClipboard: " << (const char*) str << endl;
+       lyxerr[Debug::ACTION] << "GuiClipboard::get: " << (const char*) str
+                             << endl;
        if (str.isNull())
                return string();
 
@@ -68,7 +67,7 @@ string const GuiClipboard::get() const
 
 void GuiClipboard::put(string const & str)
 {
-       lyxerr[Debug::ACTION] << "putClipboard: " << str << endl;
+       lyxerr[Debug::ACTION] << "GuiClipboard::put: " << str << endl;
 
        qApp->clipboard()->setText(toqstr(externalLineEnding(str)), CLIPBOARD_MODE);
 }