29 #if defined (HAVE_CONFIG_H)
78 int old_pos = currentIndex ();
79 int new_pos = currentIndex () + direction;
81 if (new_pos < 0 || new_pos >= tabs)
82 new_pos = new_pos - direction*tabs;
86 moveTab (old_pos, new_pos);
87 setCurrentIndex (old_pos);
88 setCurrentIndex (new_pos);
91 setCurrentIndex (new_pos);
96 QString current_title = tabText (currentIndex ());
97 int tab_with_focus = 0;
100 QStringList tab_texts;
102 for (
int i = 0; i < count (); i++)
103 tab_texts.append (tabText (i));
108 for (
int title = 0; title < tab_texts.count (); title++)
113 for (
int tab = title; tab < count (); tab++)
115 if (tabText (tab) == tab_texts.at (title))
118 moveTab (tab, title);
120 if (tab_texts.at (title) == current_title)
121 tab_with_focus = title;
128 setCurrentIndex (tab_with_focus);
138 QSize s = QTabBar::tabSizeHint (idx);
150 return QTabBar::paintEvent (e);
153 QStylePainter painter (
this);
156 for (
int idx = 0; idx < count(); idx++)
158 initStyleOption (&opt, idx);
159 painter.drawControl (QStyle::CE_TabBarTabShape, opt);
162 QSize s = opt.rect.size();
164 QRect rect (QPoint (), s);
165 rect.moveCenter (opt.rect.center ());
168 QPoint p = tabRect (idx).center ();
169 painter.translate (p);
171 painter.translate (-p);
172 painter.drawControl (QStyle::CE_TabBarTabLabel, opt);
181 int clicked_idx = -1;
184 for (
int i = 0; i < count (); i++)
186 click_pos = mapToGlobal (me->pos ());
187 if (tabRect (i).contains (mapFromGlobal (click_pos)))
195 if (clicked_idx >= 0)
197 int current_idx = currentIndex ();
198 int current_count = count ();
201 if ((me->type () == QEvent::MouseButtonDblClick
202 && me->button() == Qt::LeftButton)
203 || (me->type () != QEvent::MouseButtonDblClick
204 && me->button() == Qt::MiddleButton))
208 setCurrentIndex (clicked_idx);
212 if (current_idx - clicked_idx > 0)
213 setCurrentIndex (current_idx - 1);
214 else if (current_idx - clicked_idx < 0)
215 setCurrentIndex (current_idx);
217 else if (me->type () != QEvent::MouseButtonDblClick
218 && me->button() == Qt::RightButton)
221 setCurrentIndex (clicked_idx);
226 connect (&ctx_menu, &QMenu::triggered,
229 for (
int i = count () - 1; i >= 0; i--)
232 QAction *a =
new QAction (tabIcon (i), tabText (i), &ctx_menu);
238 if (! ctx_menu.exec (click_pos))
241 setCurrentIndex (current_idx);
243 else if (count () < current_count)
250 int new_idx = count () - 1;
253 if (current_idx - clicked_idx > 0)
254 new_idx = current_idx - 1;
255 else if (current_idx - clicked_idx < 0)
256 new_idx = current_idx;
259 setCurrentIndex (new_idx);
265 QTabBar::mousePressEvent (me);
271 QTabBar::mousePressEvent (me);
282 if ((i > -1) && (i < count ()))
void close_current_tab_signal(bool)
QList< QAction * > m_ctx_actions
void set_rotated(int rotated)
void ctx_menu_activated(QAction *a)
void paintEvent(QPaintEvent *e)
void switch_right_tab(void)
void switch_tab(int direction, bool movetab=false)
QSize tabSizeHint(int idx) const
void move_tab_right(void)
void switch_left_tab(void)
void sort_tabs_alph(void)
void mousePressEvent(QMouseEvent *event)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn