]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/QCommandBuffer.C
Some string(widget->text()) fixes. Weirdness
[lyx.git] / src / frontends / qt2 / QCommandBuffer.C
index 65bee21cf8a4bcb1e705f4824dd1774883ec4f93..9d04a931e29a663792c972f8deb3289770df6a02 100644 (file)
@@ -38,14 +38,13 @@ class QTempListBox : public QListBox {
 public:
        QTempListBox()
                : QListBox(0, 0,
-               WType_Modal | WType_Popup | WDestructiveClose) {
+                          WType_Modal | WType_Popup | WDestructiveClose) {
                setHScrollBarMode(AlwaysOff);
        }
-
 protected:
        void mouseReleaseEvent(QMouseEvent * e) {
                if (e->x() < 0 || e->y() < 0
-                       || e->x() > width() || e->y() > height()) {
+                   || e->x() > width() || e->y() > height()) {
                        hide();
                } else {
                        emit selected(currentText());
@@ -61,7 +60,8 @@ protected:
        }
 };
 
-}
+} // end of anon
+
 
 QCommandBuffer::QCommandBuffer(QtView * view, ControlCommandBuffer & control)
        : QToolBar(view), view_(view), controller_(control)
@@ -70,11 +70,8 @@ QCommandBuffer::QCommandBuffer(QtView * view, ControlCommandBuffer & control)
 
        QPixmap qp(LibFileSearch("images", "unknown", "xpm").c_str());
 
-       QToolButton * upb = new QToolButton(qp, _("Up"), "", this, SLOT(up()), this);
-       upb->show();
-
-       QToolButton * downb = new QToolButton(qp, _("Down"), "", this, SLOT(down()), this);
-       downb->show();
+       (new QToolButton(qp, _("Up"), "", this, SLOT(up()), this))->show();
+       (new QToolButton(qp, _("Down"), "", this, SLOT(down()), this))->show();
 
        edit_ = new QCommandEdit(this);
        edit_->setMinimumSize(edit_->sizeHint());
@@ -126,13 +123,13 @@ void QCommandBuffer::complete()
 
        if (comp.empty()) {
                edit_->setText(new_input.c_str());
-       //      show_info_suffix(("[only completion]"), new_input + " ");
+       //      show_info_suffix(("[only completion]"), new_input + ' ');
                return;
        }
 
        edit_->setText(new_input.c_str());
 
-       QTempListBox * list = new QTempListBox();
+       QTempListBox * list = new QTempListBox;
 
        // For some reason the scrollview's contents are larger
        // than the number of actual items...
@@ -147,9 +144,9 @@ void QCommandBuffer::complete()
 
        list->resize(list->sizeHint());
        QPoint pos(edit_->mapToGlobal(QPoint(0, 0)));
-       int y = pos.y() - list->height();
-       if (y < 0)
-               y = 0;
+
+       int y = std::max(0, pos.y() - list->height());
+
        list->move(pos.x(), y);
 
        connect(list, SIGNAL(selected(const QString &)),
@@ -160,9 +157,9 @@ void QCommandBuffer::complete()
 }
 
 
-void QCommandBuffer::complete_selected(const QString & str)
+void QCommandBuffer::complete_selected(QString const & str)
 {
-       edit_->setText(str + " ");
+       edit_->setText(str + ' ');
        QWidget const * widget = static_cast<QWidget const *>(sender());
        const_cast<QWidget *>(widget)->hide();
 }
@@ -170,7 +167,7 @@ void QCommandBuffer::complete_selected(const QString & str)
 
 void QCommandBuffer::up()
 {
-       string const input = edit_->text().latin1();
+       string const input(edit_->text().latin1());
        string const h(controller_.historyUp());
 
        if (h.empty()) {
@@ -183,7 +180,7 @@ void QCommandBuffer::up()
 
 void QCommandBuffer::down()
 {
-       string const input = edit_->text().latin1();
+       string const input(edit_->text().latin1());
        string const h(controller_.historyDown());
 
        if (h.empty()) {
@@ -199,7 +196,7 @@ void XMiniBuffer::show_info_suffix(string const & suffix, string const & input)
 {
        stored_input_ = input;
        info_suffix_shown_ = true;
-       set_input(input + " " + suffix);
+       set_input(input + ' ' + suffix);
        suffix_timer_->start();
 }