]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/QtView.C
Some string(widget->text()) fixes. Weirdness
[lyx.git] / src / frontends / qt2 / QtView.C
index 59c67ff3cadb1881025816bdc83608b4c2517b1a..4496cec0ce0279a496f9fd3d3cd84590d2b31328 100644 (file)
@@ -1,10 +1,12 @@
 /**
  * \file QtView.C
- * Copyright 1995-2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Lars Gullik Bjornes <larsbj@lyx.org>
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author Lars Gullik Bjornes
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
@@ -13,7 +15,6 @@
 #pragma implementation
 #endif
 
-//#include "minibuffer.h"
 #include "debug.h"
 #include "intl.h"
 #include "lyx_cb.h"
 #include "MenuBackend.h"
 #include "ToolbarDefaults.h"
 #include "lyxfunc.h"
+#include "bufferview_funcs.h"
 #include "BufferView.h"
 
 #include "frontends/Toolbar.h"
 #include "frontends/Menubar.h"
 #include "frontends/Dialogs.h"
 #include "frontends/Timeout.h"
+
+#include <boost/bind.hpp>
+
 #include "QtView.h"
 #include "qfont_loader.h"
+#include "QCommandBuffer.h"
+
 #include <qapplication.h>
 #include <qpixmap.h>
 #include <qmenubar.h>
+#include <qstatusbar.h>
+
 using std::endl;
 
+namespace {
+
+int const idle_timer_value = 3000;
+
+} // namespace anon
+
 // FIXME: this has to go away
 BufferView * current_view;
 
 qfont_loader fontloader;
 
+
 QtView::QtView(unsigned int width, unsigned int height)
        : QMainWindow(), LyXView()
 {
        resize(width, height);
-       qApp->setMainWidget(this);
-       menubar_.reset(new Menubar(this, menubackend));
 
-       connect(menuBar(), SIGNAL(activated(int)),
-               this, SLOT(activated(int)));
-       toolbar_.reset(new Toolbar(this, 0, 0, toolbardefaults));
-       toolbar_->set(true);
+       qApp->setMainWidget(this);
 
-       // FIXME minibuffer_.reset(new MiniBuffer(this, 0, 0, 30, 30));
        bufferview_.reset(new BufferView(this, 0, 0, width, height));
        ::current_view = bufferview_.get();
 
-       // FIXME: move 
-       // FIXME autosave_timeout_->timeout.connect(SigC::slot(this, &QtView::autoSave));
-       
-        //  assign an icon to main form
+       menubar_.reset(new Menubar(this, menubackend));
+       toolbar_.reset(new Toolbar(this, 0, 0, toolbardefaults));
+
+       statusBar()->setSizeGripEnabled(false);
+
+       view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
+       connect(&idle_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
+
+       idle_timer_.start(idle_timer_value);
+
+       focus_command_buffer.connect(boost::bind(&QtView::focus_command_widget, this));
+
+       commandbuffer_ = new QCommandBuffer(this, *controlcommand_);
+
+       addToolBar(commandbuffer_, Bottom, true);
+
+       //  assign an icon to main form
        string const iconname = LibFileSearch("images", "lyx", "xpm");
        if (!iconname.empty())
                setIcon(QPixmap(iconname.c_str()));
 
-#if 0
-       minibuffer_.reset(new MiniBuffer(this, air, height - (25 + air), 
-               width - (2 * air), 25));
-
-       // connect the minibuffer signals
-       minibuffer_->stringReady.connect(SigC::slot(getLyXFunc(),
-                                               &LyXFunc::miniDispatch));
-       minibuffer_->timeout.connect(SigC::slot(getLyXFunc(),
-                                              &LyXFunc::initMiniBuffer));
-       minibuffer_->dd_init(); 
-#endif
-       
        // make sure the buttons are disabled if needed
        updateToolbar();
 }
@@ -94,47 +96,62 @@ QtView::~QtView()
 }
 
 
-void QtView::activated(int id)
+void QtView::message(string const & str)
 {
-       getLyXFunc()->verboseDispatch(id, true);
+       statusBar()->message(str.c_str());
+       idle_timer_.stop();
+       idle_timer_.start(idle_timer_value);
 }
-void QtView::closeEvent(QCloseEvent *)
+
+
+void QtView::focus_command_widget()
 {
-       QuitLyX();
+       commandbuffer_->focus_command();
 }
 
-void QtView::redraw() 
+
+void QtView::update_view_state_qt()
 {
-       // FIXME: does this make any sense for us ? 
-       repaint();
+       statusBar()->message(currentState(view().get()).c_str());
 }
 
 
-void QtView::setPosition(unsigned int x, unsigned int y)
+void QtView::update_view_state()
 {
-       move(x, y);
+       statusBar()->message(currentState(view().get()).c_str());
 }
 
 
-void QtView::show(int, int, string const & title)
+void QtView::activated(int id)
 {
+       getLyXFunc().dispatch(id, true);
+}
+
+
+void QtView::closeEvent(QCloseEvent *)
+{
+       QuitLyX();
+}
+
+
+void QtView::show(int x, int y, string const & title)
+{
+       move(x, y);
        setCaption(title.c_str());
        QMainWindow::show();
 }
 
 
+// it's not at all clear that these are actually
+// needed anywhere in the source. Something to
+// check on a rainy day.
 void QtView::prohibitInput() const
 {
-       // FIXME
        //setFocusPolicy(QWidget::NoFocus);
 }
 
 
 void QtView::allowInput() const
 {
-       // FIXME
        //setFocusPolicy(QWidget::strongFocus);
 }