: QApplication(argc, argv), Application(argc, argv)
{
#ifdef Q_WS_X11
- // doubleClickInterval() is 400 ms on X11 witch is just too long.
+ // doubleClickInterval() is 400 ms on X11 which is just too long.
// On Windows and Mac OS X, the operating system's value is used.
// On Microsoft Windows, calling this function sets the double
// click interval for all applications. So we don't!
#include "QCommandBuffer.h"
#include "qt_helpers.h"
+#include <QAction>
#include <QApplication>
+#include <QCloseEvent>
#include <QPixmap>
#include <QStatusBar>
#include <QToolBar>
-#include <QCloseEvent>
-#include <QAction>
#include <boost/bind.hpp>
void GuiView::init()
{
menubar_.reset(new QLMenubar(this, menubackend));
- QObject::connect(menuBar(), SIGNAL(triggered(QAction *)), this, SLOT(updateMenu(QAction *)));
+ QObject::connect(menuBar(), SIGNAL(triggered(QAction *)),
+ this, SLOT(updateMenu(QAction *)));
getToolbars().init();
statusBar()->setSizeGripEnabled(false);
- QObject::connect(&statusbar_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
+ QObject::connect(&statusbar_timer_, SIGNAL(timeout()),
+ this, SLOT(update_view_state_qt()));
// make sure the buttons are disabled if needed
updateToolbars();
#include "QCommandBuffer.h"
#include "QCommandEdit.h"
#include "qt_helpers.h"
-//Added by qt3to4:
-#include <QVBoxLayout>
-#include <QMouseEvent>
-#include <QPixmap>
-#include <QHBoxLayout>
-#include <QKeyEvent>
#include "controllers/ControlCommandBuffer.h"
#include "support/filetools.h"
-#include <QListWidget>
+#include <QHBoxLayout>
+#include <QKeyEvent>
#include <QLayout>
-#include <QToolTip>
+#include <QListWidget>
+#include <QMouseEvent>
+#include <QPixmap>
#include <QPushButton>
+#include <QToolTip>
+#include <QVBoxLayout>
using lyx::support::libFileSearch;
setAttribute(Qt::WA_DeleteOnClose);
}
protected:
- void mouseReleaseEvent(QMouseEvent * e) {
- if (e->x() < 0 || e->y() < 0
- || e->x() > width() || e->y() > height()) {
+ void mouseReleaseEvent(QMouseEvent * ev) {
+ if (ev->x() < 0 || ev->y() < 0
+ || ev->x() > width() || ev->y() > height()) {
hide();
} else {
- // emit signal
+ // emit signal
itemPressed(currentItem());
}
}
- void keyPressEvent(QKeyEvent * e) {
- if (e->key() == Qt::Key_Escape) {
+ void keyPressEvent(QKeyEvent * ev) {
+ if (ev->key() == Qt::Key_Escape) {
hide();
return;
}
- QListWidget::keyPressEvent(e);
+ QListWidget::keyPressEvent(ev);
}
};
} // end of anon
-QCommandBuffer::QCommandBuffer(GuiView * view, ControlCommandBuffer & control, QWidget * parent)
+QCommandBuffer::QCommandBuffer(GuiView * view, ControlCommandBuffer & control,
+ QWidget * parent)
: QWidget(parent), view_(view), controller_(control)
{
QPixmap qpup(toqstr(libFileSearch("images", "up", "xpm")));
layout->addWidget(up, 0);
layout->addWidget(down, 0);
layout->addWidget(edit_, 10);
+ layout->setMargin(0);
top->addLayout(layout);
+ top->setMargin(0);
}
void QCommandBuffer::cancel()
{
view_->centralWidget()->setFocus();
- edit_->setText("");
+ edit_->setText(QString());
}
{
controller_.dispatch(fromqstr(edit_->text()));
view_->centralWidget()->setFocus();
- edit_->setText("");
+ edit_->setText(QString());
edit_->clearFocus();
}
vector<string> comp = controller_.completions(input, new_input);
if (comp.empty() && new_input == input) {
- // show_info_suffix(qt_("[no match]"), input);
+ // show_info_suffix(qt_("[no match]"), input);
return;
}
// than the number of actual items...
vector<string>::const_iterator cit = comp.begin();
vector<string>::const_iterator end = comp.end();
- for (; cit != end; ++cit) {
+ for (; cit != end; ++cit)
list->addItem(toqstr(*cit));
- }
-
- // width() is not big enough by a few pixels. Qt Sucks.
-// list->setMinimumWidth(list->sizeHint().width() + 10);
list->resize(list->sizeHint());
- QPoint pos(edit_->mapToGlobal(QPoint(0, 0)));
+ QPoint const pos = edit_->mapToGlobal(QPoint(0, 0));
- int y = std::max(0, pos.y() - list->height());
+ int const y = std::max(0, pos.y() - list->height());
list->move(pos.x(), y);
void QCommandBuffer::up()
{
- string const input(fromqstr(edit_->text()));
- string const h(controller_.historyUp());
+ string const input = fromqstr(edit_->text());
+ string const h = controller_.historyUp();
if (h.empty()) {
// show_info_suffix(qt_("[Beginning of history]"), input);
void QCommandBuffer::down()
{
- string const input(fromqstr(edit_->text()));
- string const h(controller_.historyDown());
+ string const input = fromqstr(edit_->text());
+ string const h = controller_.historyDown();
if (h.empty()) {
// show_info_suffix(qt_("[End of history]"), input);
class QCommandBuffer : public QWidget {
Q_OBJECT
public:
- QCommandBuffer(GuiView * view, ControlCommandBuffer & control, QWidget * parent=NULL);
+ QCommandBuffer(GuiView * view, ControlCommandBuffer & control,
+ QWidget * parent=NULL);
/// focus the edit widget
void focus_command();
#include <config.h>
#include "QCommandEdit.h"
-//Added by qt3to4:
+
#include <QKeyEvent>
#include <QEvent>
{
switch (e->key()) {
case Qt::Key_Escape:
- // emit signal
+ // emit signal
escapePressed();
break;
case Qt::Key_Up:
- // emit signal
+ // emit signal
upPressed();
break;
case Qt::Key_Down:
- // emit signal
+ // emit signal
downPressed();
break;
if (ev->key() != Qt::Key_Tab)
return QLineEdit::event(e);
- // emit signal
+ // emit signal
tabPressed();
return true;
}
Q_SIGNALS:
/// cancel
void escapePressed();
-
/// up history
void upPressed();
-
/// down history
void downPressed();
-
/// complete
void tabPressed();
protected:
+ ///
virtual bool event(QEvent * e);
-
+ ///
virtual void keyPressEvent(QKeyEvent * e);
};
// Start the real execution loop.
// FIXME
- /* Create a CoreApplication class that will provide the main event loop and
- * the socket callback registering. With Qt4, only QtCore library would be needed.
- * When this done, a server_mode could be created and the following two
+ /* Create a CoreApplication class that will provide the main event loop
+ * and the socket callback registering. With Qt4, only QtCore
+ * library would be needed.
+ * When this is done, a server_mode could be created and the following two
* line would be moved out from here.
*/
pimpl_->lyx_server_.reset(new LyXServer(&pimpl_->lyxfunc_, lyxrc.lyxpipes));
void MacroTable::insert(docstring const & def)
{
//lyxerr << "MacroTable::insert, def: " << to_utf8(def) << endl;
- std::istringstream is(to_utf8(def));
- MathMacroTemplate mac(is);
+ MathMacroTemplate mac(def);
insert(mac.name(), mac.asMacroData());
}
}
-MathMacroTemplate::MathMacroTemplate(std::istream & is)
+MathMacroTemplate::MathMacroTemplate(docstring const & str)
: InsetMathNest(2), numargs_(0), name_()
{
initMath();
MathArray ar;
- mathed_parse_cell(ar, is);
+ mathed_parse_cell(ar, str);
if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
- lyxerr << "cannot read macro from '" << ar << "'" << endl;
+ lyxerr << "Cannot read macro from '" << ar << "'" << endl;
return;
}
operator=( *(ar[0]->asMacroTemplate()) );
void MathMacroTemplate::read(Buffer const &, LyXLex & lex)
{
MathArray ar;
- mathed_parse_cell(ar, lex.getDocString());
+ lex.next(); // eat \begin_inset FormulaMacro line
+ docstring const str = lex.getDocString();
+ lex.next(); // eat that macro definition
+ lex.next(); // eat the \\end_insrt line
+ lyxerr << "Got to read from: " << to_utf8(str) << endl;
+ mathed_parse_cell(ar, str);
if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
- lyxerr << "cannot read macro from '" << ar << "'" << endl;
+ lyxerr << "Cannot read macro from '" << ar << "'" << endl;
+ lyxerr << "Read: " << to_utf8(asString(ar)) << endl;
return;
}
operator=( *(ar[0]->asMacroTemplate()) );
MathArray const & = MathArray(),
MathArray const & = MathArray());
///
- explicit MathMacroTemplate(std::istream & is);
+ explicit MathMacroTemplate(const docstring & str);
///
void edit(LCursor & cur, bool left);
///
void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
{
recordUndo(cur);
- string sel = to_utf8(cur.selectionAsString(false));
+ docstring sel = cur.selectionAsString(false);
//lyxerr << "selection is: '" << sel << "'" << endl;
// It may happen that sel is empty but there is a selection
// create a macro if we see "\\newcommand"
// somewhere, and an ordinary formula
// otherwise
- istringstream is(sel);
- if (sel.find("\\newcommand") == string::npos
- && sel.find("\\def") == string::npos)
+ if (sel.find(from_ascii("\\newcommand")) == string::npos
+ && sel.find(from_ascii("\\def")) == string::npos)
{
InsetMathHull * formula = new InsetMathHull;
+ istringstream is(to_utf8(sel));
LyXLex lex(0, 0);
lex.setStream(is);
formula->read(cur.buffer(), lex);
// delimiters are left out
formula->mutate(hullSimple);
cur.insert(formula);
- } else
- cur.insert(new MathMacroTemplate(is));
+ } else {
+ cur.insert(new MathMacroTemplate(sel));
+ }
}
cur.message(from_utf8(N_("Math editor mode")));
}