From b20e982cf9ee165db09dbafc69882bad2a589730 Mon Sep 17 00:00:00 2001 From: xavier Date: Sun, 15 Jul 2012 13:01:04 +0000 Subject: [PATCH] Circumvented a display bug occuring when moving the current diagram from the elements panel. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@1912 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/projectview.cpp | 4 ++-- sources/qettabwidget.cpp | 14 ++++++++++++++ sources/qettabwidget.h | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sources/projectview.cpp b/sources/projectview.cpp index 5249ab288..1fac0de88 100644 --- a/sources/projectview.cpp +++ b/sources/projectview.cpp @@ -476,7 +476,7 @@ void ProjectView::moveDiagramUp(DiagramView *diagram_view) { // le schema est le premier du projet return; } - tabs_ -> tabBar() -> moveTab(diagram_view_position, diagram_view_position - 1); + tabs_ -> moveTab(diagram_view_position, diagram_view_position - 1); } /** @@ -497,7 +497,7 @@ void ProjectView::moveDiagramDown(DiagramView *diagram_view) { // le schema est le dernier du projet return; } - tabs_ -> tabBar() -> moveTab(diagram_view_position, diagram_view_position + 1); + tabs_ -> moveTab(diagram_view_position, diagram_view_position + 1); } /** diff --git a/sources/qettabwidget.cpp b/sources/qettabwidget.cpp index ca8eba7de..d72c219b1 100644 --- a/sources/qettabwidget.cpp +++ b/sources/qettabwidget.cpp @@ -66,6 +66,20 @@ bool QETTabWidget::isMovable() const { #endif } +/** + Move the tab from index \a from to index \a to. +*/ +void QETTabWidget::moveTab(int from, int to) { + tab_bar_ -> moveTab(from, to); + // workaround to a weird bug when moving the current tab + if (count() > 1) { + int current_index = tab_bar_ -> currentIndex(); + // switch to any other index then back to the current one + tab_bar_ -> setCurrentIndex(current_index ? 0 : 1); + tab_bar_ -> setCurrentIndex(current_index); + } +} + QETTabBar *QETTabWidget::tabBar() const { return(tab_bar_); } diff --git a/sources/qettabwidget.h b/sources/qettabwidget.h index 4fa898217..c071425f9 100644 --- a/sources/qettabwidget.h +++ b/sources/qettabwidget.h @@ -40,6 +40,7 @@ class QETTabWidget : public QTabWidget { public: void setMovable(bool); bool isMovable() const; + void moveTab(int, int); QETTabBar *tabBar() const; protected: