From 12a82dd4f2657e683d4f44fb9168aa177b776e00 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 22 Sep 2006 15:02:41 +0000 Subject: [PATCH] This commit replaces BufferView->LyXView->Gui->[selection,clipboard] with theApp->[selection,clipboard] git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15125 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 2 -- src/CutAndPaste.C | 8 +++----- src/frontends/Application.h | 8 +++++++- src/frontends/Gui.h | 7 ------- src/frontends/LyXView.C | 10 +--------- src/frontends/LyXView.h | 6 +----- src/frontends/qt4/GuiApplication.C | 12 ++++++++++++ src/frontends/qt4/GuiApplication.h | 11 +++++++++-- src/frontends/qt4/GuiImplementation.C | 14 +------------- src/frontends/qt4/GuiImplementation.h | 9 --------- src/frontends/qt4/GuiView.C | 4 ++-- src/frontends/qt4/GuiView.h | 2 +- src/insets/insettabular.C | 8 +++----- src/mathed/InsetMathNest.C | 6 ++---- src/text3.C | 15 +++++++-------- 15 files changed, 49 insertions(+), 73 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index 6b03a41239..95d093b777 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -64,7 +64,6 @@ #include "frontends/Dialogs.h" #include "frontends/FileDialog.h" #include "frontends/font_metrics.h" -#include "frontends/Gui.h" #include "frontends/LyXView.h" #include "frontends/Selection.h" @@ -84,7 +83,6 @@ using lyx::frontend::Clipboard; -using lyx::frontend::Gui; using lyx::docstring; using lyx::pos_type; diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 27fa600a16..cb7c556bfc 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -45,7 +45,6 @@ #include "support/lstrings.h" -#include "frontends/Gui.h" #include "frontends/LyXView.h" #include "frontends/Clipboard.h" @@ -57,7 +56,6 @@ using lyx::textclass_type; using lyx::support::bformat; -using lyx::frontend::Gui; using lyx::frontend::Clipboard; using std::endl; @@ -513,8 +511,8 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut) // solved by running the line below only when the selection has // finished. The solution used currently just works, to make it // faster we need to be more clever and probably also have more - // calls to cur.bv().owner()->gui().selection().put. (Lgb) -// cur.bv().owner()->gui().selection().put(cur.selectionAsString(true)); + // calls to theApp->selection().put. (Lgb) +// theApp->selection().put(cur.selectionAsString(true)); // make sure that the depth behind the selection are restored, too @@ -578,7 +576,7 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut) void copySelection(LCursor & cur) { // stuff the selection onto the X clipboard, from an explicit copy request - cur.bv().owner()->gui().clipboard().put(cur.selectionAsString(true)); + theApp->clipboard().put(cur.selectionAsString(true)); // this doesn't make sense, if there is no selection if (!cur.selection()) diff --git a/src/frontends/Application.h b/src/frontends/Application.h index a7efd78342..3b2fefe0bc 100644 --- a/src/frontends/Application.h +++ b/src/frontends/Application.h @@ -25,8 +25,9 @@ class LyXView; namespace lyx { namespace frontend { -//class GuiWorkArea; +class Clipboard; class Gui; +class Selection; /// The main application class @@ -50,6 +51,11 @@ public: /// virtual void exit(int status) = 0; + /// + virtual Clipboard & clipboard() = 0; + /// + virtual Selection & selection() = 0; + /// LyXFunc & lyxFunc(); LyXFunc const & lyxFunc() const; diff --git a/src/frontends/Gui.h b/src/frontends/Gui.h index 0260b1a366..9b5e7a9949 100644 --- a/src/frontends/Gui.h +++ b/src/frontends/Gui.h @@ -24,8 +24,6 @@ class BufferView; namespace lyx { namespace frontend { -class Clipboard; -class Selection; class WorkArea; @@ -37,11 +35,6 @@ class Gui public: virtual ~Gui() {} - /// - virtual Clipboard & clipboard() = 0; - /// - virtual Selection & selection() = 0; - /// virtual int newView(unsigned int width, unsigned int height) = 0; /// diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index 6e08fc4d0c..8a8274e966 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -12,7 +12,6 @@ #include #include "LyXView.h" -#include "Gui.h" #include "Dialogs.h" #include "Timeout.h" #include "Toolbars.h" @@ -50,7 +49,6 @@ # include #endif -using lyx::frontend::Gui; using lyx::frontend::WorkArea; using lyx::docstring; @@ -65,15 +63,9 @@ using lyx::frontend::ControlCommandBuffer; string current_layout; -Gui & LyXView::gui() -{ - return owner_; -} - -LyXView::LyXView(Gui & owner) +LyXView::LyXView() : work_area_(0), - owner_(owner), toolbars_(new Toolbars(*this)), autosave_timeout_(new Timeout(5000)), lyxfunc_(new LyXFunc(this)), diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index d083869887..bda7da3f43 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -58,7 +58,7 @@ class ControlCommandBuffer; class LyXView : public boost::signals::trackable, boost::noncopyable { public: - LyXView(lyx::frontend::Gui & owner); + LyXView(); virtual ~LyXView(); @@ -162,9 +162,6 @@ public: /// returns true if this view has the focus. virtual bool hasFocus() const = 0; - /// - virtual lyx::frontend::Gui & gui(); - /// Temporary method used by the kernel to redraw the work area. virtual void redrawWorkArea(); @@ -191,7 +188,6 @@ protected: boost::scoped_ptr menubar_; private: - lyx::frontend::Gui & owner_; /** * setWindowTitle - set title of window * @param t main window title diff --git a/src/frontends/qt4/GuiApplication.C b/src/frontends/qt4/GuiApplication.C index 764251bede..eff55cccec 100644 --- a/src/frontends/qt4/GuiApplication.C +++ b/src/frontends/qt4/GuiApplication.C @@ -137,6 +137,18 @@ GuiApplication::GuiApplication(int & argc, char ** argv) } +Clipboard& GuiApplication::clipboard() +{ + return clipboard_; +} + + +Selection& GuiApplication::selection() +{ + return selection_; +} + + int const GuiApplication::exec() { return QApplication::exec(); diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index efd54a45f0..8e11369c9e 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -13,8 +13,10 @@ #ifndef QT4_APPLICATION_H #define QT4_APPLICATION_H -#include "GuiImplementation.h" #include "FontLoader.h" +#include "GuiClipboard.h" +#include "GuiImplementation.h" +#include "GuiSelection.h" #include "frontends/Application.h" @@ -50,6 +52,8 @@ public: /// Method inherited from \c Application class //@{ + virtual Clipboard& clipboard(); + virtual Selection& selection(); virtual int const exec(); virtual Gui & gui() { return gui_; } virtual void exit(int status); @@ -65,7 +69,10 @@ public: private: /// GuiImplementation gui_; - + /// + GuiClipboard clipboard_; + /// + GuiSelection selection_; /// FontLoader font_loader_; diff --git a/src/frontends/qt4/GuiImplementation.C b/src/frontends/qt4/GuiImplementation.C index 3ec3c01952..5ead31e726 100644 --- a/src/frontends/qt4/GuiImplementation.C +++ b/src/frontends/qt4/GuiImplementation.C @@ -31,24 +31,12 @@ GuiImplementation::GuiImplementation(): max_view_id_(0), max_wa_id_(0) } -Clipboard& GuiImplementation::clipboard() -{ - return clipboard_; -} - - -Selection& GuiImplementation::selection() -{ - return selection_; -} - - int GuiImplementation::newView(unsigned int /*w*/, unsigned int /*h*/) { size_t const id = max_view_id_; ++max_view_id_; - views_[id].reset(new GuiView(*this)); + views_[id].reset(new GuiView()); return id; } diff --git a/src/frontends/qt4/GuiImplementation.h b/src/frontends/qt4/GuiImplementation.h index d31437cfa5..312227dc0c 100644 --- a/src/frontends/qt4/GuiImplementation.h +++ b/src/frontends/qt4/GuiImplementation.h @@ -14,8 +14,6 @@ #define GUI_H #include "frontends/Gui.h" -#include "GuiClipboard.h" -#include "GuiSelection.h" #include @@ -38,9 +36,6 @@ public: GuiImplementation(); virtual ~GuiImplementation() {} - Clipboard& clipboard(); - Selection& selection(); - int newView(unsigned int width, unsigned int height); LyXView& view(int id); void destroyView(int id); @@ -51,10 +46,6 @@ public: private: - /// - GuiClipboard clipboard_; - /// - GuiSelection selection_; /// std::map > views_; /// diff --git a/src/frontends/qt4/GuiView.C b/src/frontends/qt4/GuiView.C index b54e9a5334..59bc76c6a2 100644 --- a/src/frontends/qt4/GuiView.C +++ b/src/frontends/qt4/GuiView.C @@ -68,8 +68,8 @@ int const statusbar_timer_value = 3000; } // namespace anon -GuiView::GuiView(Gui & owner) - : QMainWindow(), LyXView(owner), commandbuffer_(0) +GuiView::GuiView() + : QMainWindow(), LyXView(), commandbuffer_(0) { // setToolButtonStyle(Qt::ToolButtonIconOnly); // setIconSize(QSize(12,12)); diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 43535538ff..d4858a6acd 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -47,7 +47,7 @@ class GuiView : public QMainWindow, public LyXView { Q_OBJECT public: /// create a main window of the given dimensions - GuiView(Gui & owner); + GuiView(); ~GuiView(); diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index b5af539eb9..5e9e4da802 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -38,7 +38,6 @@ #include "frontends/Alert.h" #include "frontends/font_metrics.h" -#include "frontends/Gui.h" #include "frontends/LyXView.h" #include "frontends/Clipboard.h" #include "frontends/Painter.h" @@ -59,7 +58,6 @@ using lyx::graphics::PreviewLoader; using lyx::support::ltrim; using lyx::frontend::Painter; -using lyx::frontend::Gui; using lyx::frontend::Clipboard; using boost::shared_ptr; @@ -700,8 +698,8 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd) case LFUN_CLIPBOARD_PASTE: case LFUN_PRIMARY_SELECTION_PASTE: { docstring const clip = (cmd.action == LFUN_CLIPBOARD_PASTE) ? - cur.bv().owner()->gui().clipboard().get() : - cur.bv().owner()->gui().selection().get(); + theApp->clipboard().get() : + theApp->selection().get(); if (clip.empty()) break; // pass to InsertAsciiString, but @@ -1780,7 +1778,7 @@ bool InsetTabular::copySelection(LCursor & cur) ostringstream os; OutputParams const runparams; paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t'); - cur.bv().owner()->gui().clipboard().put(lyx::from_utf8(os.str())); + theApp->clipboard().put(lyx::from_utf8(os.str())); // mark tabular stack dirty // FIXME: this is a workaround for bug 1919. Should be removed for 1.5, // when we (hopefully) have a one-for-all paste mechanism. diff --git a/src/mathed/InsetMathNest.C b/src/mathed/InsetMathNest.C index 775543a63c..bf374d3581 100644 --- a/src/mathed/InsetMathNest.C +++ b/src/mathed/InsetMathNest.C @@ -50,7 +50,6 @@ #include "support/lstrings.h" #include "frontends/Dialogs.h" -#include "frontends/Gui.h" #include "frontends/LyXView.h" #include "frontends/Painter.h" #include "frontends/Selection.h" @@ -64,7 +63,6 @@ using lyx::cap::cutSelection; using lyx::cap::replaceSelection; using lyx::cap::selClearOrDel; -using lyx::frontend::Gui; using lyx::frontend::Clipboard; using std::endl; @@ -1089,7 +1087,7 @@ void InsetMathNest::lfunMousePress(LCursor & cur, FuncRequest & cmd) if (cur.selection()) asArray(lyx::to_utf8(bv.cursor().selectionAsString(false)), ar); else - asArray(lyx::to_utf8(bv.owner()->gui().selection().get()), ar); + asArray(lyx::to_utf8(theApp->selection().get()), ar); cur.insert(ar); bv.mouseSetCursor(cur); @@ -1120,7 +1118,7 @@ void InsetMathNest::lfunMouseRelease(LCursor & cur, FuncRequest & cmd) //lyxerr << "## lfunMouseRelease: buttons: " << cmd.button() << endl; if (cmd.button() == mouse_button::button1) { - //cur.bv().owner()->gui().selection().put(cur.grabSelection()); + //theApp->selection().put(cur.grabSelection()); return; } diff --git a/src/text3.C b/src/text3.C index b6d0634a32..823eb16eb4 100644 --- a/src/text3.C +++ b/src/text3.C @@ -48,7 +48,6 @@ #include "pariterator.h" #include "frontends/Dialogs.h" -#include "frontends/Gui.h" #include "frontends/LyXView.h" #include "frontends/Clipboard.h" #include "frontends/Selection.h" @@ -125,7 +124,7 @@ namespace { if (selecting || cur.mark()) cur.setSelection(); if (!cur.selection()) - cur.bv().owner()->gui().selection().haveSelection(false); + theApp->selection().haveSelection(false); cur.bv().switchKeyMap(); } @@ -883,7 +882,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_CLIPBOARD_PASTE: { cur.clearSelection(); - docstring const clip = bv->owner()->gui().clipboard().get(); + docstring const clip = theApp->clipboard().get(); if (!clip.empty()) { recordUndo(cur); if (cmd.argument() == "paragraph") @@ -896,7 +895,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_PRIMARY_SELECTION_PASTE: { cur.clearSelection(); - docstring const clip = bv->owner()->gui().selection().get(); + docstring const clip = theApp->selection().get(); if (!clip.empty()) { recordUndo(cur); if (cmd.argument() == "paragraph") @@ -956,7 +955,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) cursorEnd(cur); cur.setSelection(); bv->cursor() = cur; - bv->owner()->gui().selection().haveSelection(cur.selection()); + theApp->selection().haveSelection(cur.selection()); } break; @@ -964,7 +963,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) if (cmd.button() == mouse_button::button1) { selectWord(cur, lyx::WHOLE_WORD_STRICT); bv->cursor() = cur; - bv->owner()->gui().selection().haveSelection(cur.selection()); + theApp->selection().haveSelection(cur.selection()); } break; @@ -1046,7 +1045,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) // finish selection if (cmd.button() == mouse_button::button1) - bv->owner()->gui().selection().haveSelection(cur.selection()); + theApp->selection().haveSelection(cur.selection()); bv->switchKeyMap(); bv->owner()->updateMenubar(); @@ -1067,7 +1066,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) if (lyxrc.auto_region_delete) { if (cur.selection()) cutSelection(cur, false, false); - bv->owner()->gui().selection().haveSelection(false); + theApp->selection().haveSelection(false); } cur.clearSelection();