]> git.lyx.org Git - features.git/commitdiff
Factor out useful code into a function
authorScott Kostyshak <skostysh@lyx.org>
Thu, 21 Jul 2016 23:16:19 +0000 (19:16 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Fri, 22 Jul 2016 02:31:29 +0000 (22:31 -0400)
This code will be shared by TabWorkArea::mouseReleaseEvent,
which will be implemented shortly.

src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/GuiWorkArea.h

index e397a80c38c9fb93981e7f462e67f0b2d72a1c46..72a043e0bfd280955f361be383da7e87464b0e1d 100644 (file)
@@ -1628,6 +1628,15 @@ void TabWorkArea::paintEvent(QPaintEvent * event)
 }
 
 
+bool TabWorkArea::posIsTab(QPoint position)
+{
+       for (int i = 0; i < count(); ++i)
+               if (tabBar()->tabRect(i).contains(position))
+                       return true;
+       return false;
+}
+
+
 void TabWorkArea::mouseDoubleClickEvent(QMouseEvent * event)
 {
        if (event->button() != Qt::LeftButton)
@@ -1640,9 +1649,8 @@ void TabWorkArea::mouseDoubleClickEvent(QMouseEvent * event)
        // leave this code for now. (skostysh, 2016-07-21)
        //
        // return early if double click on existing tabs
-       for (int i = 0; i < count(); ++i)
-               if (tabBar()->tabRect(i).contains(event->pos()))
-                       return;
+       if (posIsTab(event->pos()))
+               return;
 
        dispatch(FuncRequest(LFUN_BUFFER_NEW));
 }
index df4b0c1177015240e89dc2b9575f7c1bed441cb6..9e4b1ab7a41268232b197f656b9d5e4309f28583 100644 (file)
@@ -234,7 +234,9 @@ private Q_SLOTS:
        void mouseDoubleClickEvent(QMouseEvent * event);
 
 private:
-       ///
+       /// true if position is a tab (rather than the blank space in tab bar)
+       bool posIsTab(QPoint position);
+
        int clicked_tab_;
        ///
        QToolButton * closeBufferButton;