[qet] [3809] Project view : use QTabWidget instead of QETTabWidget. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3809
Author: blacksun
Date: 2015-03-05 14:11:38 +0100 (Thu, 05 Mar 2015)
Log Message:
-----------
Project view : use QTabWidget instead of QETTabWidget.
Remove qetabwidget and qettabBar because are unused since this comit.
Modified Paths:
--------------
trunk/sources/projectview.cpp
trunk/sources/projectview.h
Removed Paths:
-------------
trunk/sources/qettabbar.cpp
trunk/sources/qettabbar.h
trunk/sources/qettabwidget.cpp
trunk/sources/qettabwidget.h
Modified: trunk/sources/projectview.cpp
===================================================================
--- trunk/sources/projectview.cpp 2015-03-05 11:45:37 UTC (rev 3808)
+++ trunk/sources/projectview.cpp 2015-03-05 13:11:38 UTC (rev 3809)
@@ -22,7 +22,6 @@
#include "diagramprintdialog.h"
#include "exportdialog.h"
#include "qetapp.h"
-#include "qettabwidget.h"
#include "qetelementeditor.h"
#include "interactivemoveelementshandler.h"
#include "borderpropertieswidget.h"
@@ -35,6 +34,8 @@
#include "diagramfoliolist.h"
#include "projectpropertiesdialog.h"
+#include <QTabWidget>
+
/**
Constructeur
@param project projet a visualiser
@@ -120,7 +121,7 @@
@return le schema actuellement active
*/
DiagramView *ProjectView::currentDiagram() const {
- int current_tab_index = tabs_ -> currentIndex();
+ int current_tab_index = m_tab -> currentIndex();
return(diagram_ids_[current_tab_index]);
}
@@ -314,7 +315,7 @@
DiagramView *new_diagram_view = new DiagramView(d);
addDiagram(new_diagram_view);
showDiagram(new_diagram_view);
- tabs_->moveTab(diagrams().size()-1, i);
+ m_tab->tabBar()->moveTab(diagrams().size()-1, i);
i++;
}
}
@@ -337,7 +338,7 @@
if (diagram_ids_.values().contains(diagram)) return;
// Add new tab for the diagram
- tabs_ -> addTab(diagram, QET::Icons::Diagram, diagram -> title());
+ m_tab -> addTab(diagram, QET::Icons::Diagram, diagram -> title());
diagram -> setFrameStyle(QFrame::Plain | QFrame::NoFrame);
diagrams_ << diagram;
@@ -379,7 +380,7 @@
// enleve le DiagramView des onglets
int diagram_tab_id = diagram_ids_.key(diagram_view);
- tabs_ -> removeTab(diagram_tab_id);
+ m_tab -> removeTab(diagram_tab_id);
diagrams_.removeAll(diagram_view);
rebuildDiagramsMap();
@@ -412,7 +413,7 @@
*/
void ProjectView::showDiagram(DiagramView *diagram) {
if (!diagram) return;
- tabs_ -> setCurrentWidget(diagram);
+ m_tab -> setCurrentWidget(diagram);
}
/**
@@ -422,7 +423,7 @@
void ProjectView::showDiagram(Diagram *diagram) {
if (!diagram) return;
if (DiagramView *diagram_view = findDiagram(diagram)) {
- tabs_ -> setCurrentWidget(diagram_view);
+ m_tab -> setCurrentWidget(diagram_view);
}
}
@@ -470,7 +471,7 @@
// le schema est le premier du projet
return;
}
- tabs_ -> moveTab(diagram_view_position, diagram_view_position - 1);
+ m_tab -> tabBar() -> moveTab(diagram_view_position, diagram_view_position - 1);
}
/**
@@ -491,7 +492,7 @@
// le schema est le dernier du projet
return;
}
- tabs_ -> moveTab(diagram_view_position, diagram_view_position + 1);
+ m_tab -> tabBar() -> moveTab(diagram_view_position, diagram_view_position + 1);
}
/**
@@ -502,28 +503,6 @@
}
/**
- Deplace le schema diagram_view vers le haut / la gauche en position 0
-*/
-void ProjectView::moveDiagramUpTop(DiagramView *diagram_view) {
- if (!diagram_view) return;
-
- int diagram_view_position = diagram_ids_.key(diagram_view);
- if (!diagram_view_position) {
- // le schema est le premier du projet
- return;
- }
- tabs_ -> moveTab(diagram_view_position, (diagrams().size(), 0));
-}
-
-/**
- Deplace le schema diagram vers le haut / la gauche en position 0
-*/
-void ProjectView::moveDiagramUpTop(Diagram *diagram) {
- moveDiagramUpTop(findDiagram(diagram));
-}
-
-
-/**
Deplace le schema diagram_view vers le haut / la gauche x10
*/
void ProjectView::moveDiagramUpx10(DiagramView *diagram_view) {
@@ -534,7 +513,7 @@
// le schema est le premier du projet
return;
}
- tabs_ -> moveTab(diagram_view_position, diagram_view_position - 10);
+ m_tab -> tabBar() -> moveTab(diagram_view_position, diagram_view_position - 10);
}
/**
@@ -555,7 +534,7 @@
// le schema est le dernier du projet
return;
}
- tabs_ -> moveTab(diagram_view_position, diagram_view_position + 10);
+ m_tab -> tabBar() -> moveTab(diagram_view_position, diagram_view_position + 10);
}
/**
@@ -771,22 +750,20 @@
fallback_label_ -> setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
// initialize tabs
- tabs_ = new QETTabWidget();
- tabs_ -> setMovable(true);
+ m_tab = new QTabWidget(this);
+ m_tab -> setMovable(true);
- QToolButton *add_new_diagram_button = new QToolButton();
+ QToolButton *add_new_diagram_button = new QToolButton;
add_new_diagram_button -> setDefaultAction(add_new_diagram_);
add_new_diagram_button -> setAutoRaise(true);
- tabs_ -> setCornerWidget(add_new_diagram_button, Qt::TopRightCorner);
+ m_tab -> setCornerWidget(add_new_diagram_button, Qt::TopRightCorner);
- connect(tabs_, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
- connect(tabs_, SIGNAL(tabDoubleClicked(int)), this, SLOT(tabDoubleClicked(int)));
- connect(tabs_, SIGNAL(firstTabInserted()), this, SLOT(firstTabInserted()));
- connect(tabs_, SIGNAL(lastTabRemoved()), this, SLOT(lastTabRemoved()));
- connect(tabs_, SIGNAL(tabMoved(int, int)), this, SLOT(tabMoved(int, int)));
+ connect(m_tab, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
+ connect(m_tab, SIGNAL(tabBarDoubleClicked(int)), this, SLOT(tabDoubleClicked(int)));
+ connect(m_tab->tabBar(), SIGNAL(tabMoved(int, int)), this, SLOT(tabMoved(int, int)));
fallback_widget_ -> setVisible(false);
- tabs_ -> setVisible(false);
+ m_tab -> setVisible(false);
}
/**
@@ -804,7 +781,7 @@
#endif
layout_ -> setSpacing(0);
layout_ -> addWidget(fallback_widget_);
- layout_ -> addWidget(tabs_);
+ layout_ -> addWidget(m_tab);
}
@@ -827,7 +804,7 @@
// If project have the folios list, move it at the beginning of the project
if (project_ -> getFolioSheetsQuantity()) {
for (int i = 0; i < project_->getFolioSheetsQuantity(); i++)
- tabs_ -> moveTab(diagrams().size()-1, + 1);
+ m_tab -> tabBar() -> moveTab(diagrams().size()-1, + 1);
}
}
@@ -853,7 +830,7 @@
bool editable = !(project_ -> isReadOnly());
// prevent users from moving existing diagrams
- tabs_ -> setMovable(editable);
+ m_tab -> setMovable(editable);
// prevent users from adding new diagrams
add_new_diagram_ -> setEnabled(editable);
@@ -869,7 +846,7 @@
void ProjectView::updateTabTitle(DiagramView *diagram, const QString &diagram_title) {
int diagram_tab_id = diagram_ids_.key(diagram, -1);
if (diagram_tab_id != -1) {
- tabs_ -> setTabText(diagram_tab_id, diagram_title);
+ m_tab -> setTabText(diagram_tab_id, diagram_title);
}
}
@@ -928,17 +905,25 @@
diagram_ids_.clear();
foreach(DiagramView *diagram_view, diagrams_) {
- int dv_idx = tabs_ -> indexOf(diagram_view);
+ int dv_idx = m_tab -> indexOf(diagram_view);
if (dv_idx == -1) continue;
diagram_ids_.insert(dv_idx, diagram_view);
}
}
/**
- Gere les changements d'onglets
- @param tab_id Index de l'onglet actif
-*/
+ * @brief ProjectView::tabChanged
+ * Manage the tab change.
+ * If tab_id == -1 (there is no diagram opened),
+ * we display the fallback widget.
+ * @param tab_id
+ */
void ProjectView::tabChanged(int tab_id) {
+ if (tab_id == -1)
+ setDisplayFallbackWidget(true);
+ else if(m_tab->count() == 1)
+ setDisplayFallbackWidget(false);
+
emit(diagramActivated(diagram_ids_[tab_id]));
}
@@ -955,20 +940,6 @@
}
/**
- Gere le fait que le premier schema d'un projet soit insere
-*/
-void ProjectView::firstTabInserted() {
- setDisplayFallbackWidget(false);
-}
-
-/**
- Gere le fait que le dernier schema d'un projet soit enleve
-*/
-void ProjectView::lastTabRemoved() {
- setDisplayFallbackWidget(true);
-}
-
-/**
@param fallback true pour afficher le widget de fallback, false pour
afficher les onglets.
Le widget de Fallback est le widget affiche lorsque le projet ne comporte
@@ -976,5 +947,5 @@
*/
void ProjectView::setDisplayFallbackWidget(bool fallback) {
fallback_widget_ -> setVisible(fallback);
- tabs_ -> setVisible(!fallback);
+ m_tab -> setVisible(!fallback);
}
Modified: trunk/sources/projectview.h
===================================================================
--- trunk/sources/projectview.h 2015-03-05 11:45:37 UTC (rev 3808)
+++ trunk/sources/projectview.h 2015-03-05 13:11:38 UTC (rev 3809)
@@ -24,7 +24,7 @@
class DiagramView;
class Diagram;
class ElementsLocation;
-class QETTabWidget;
+class QTabWidget;
/**
This class provides a widget displaying the diagrams of a particular
project using tabs.
@@ -73,8 +73,6 @@
void moveDiagramUp(Diagram *);
void moveDiagramDown(DiagramView *);
void moveDiagramDown(Diagram *);
- void moveDiagramUpTop(DiagramView *);
- void moveDiagramUpTop(Diagram *);
void moveDiagramUpx10(DiagramView *);
void moveDiagramUpx10(Diagram *);
void moveDiagramDownx10(DiagramView *);
@@ -119,8 +117,6 @@
private slots:
void tabChanged(int);
void tabDoubleClicked(int);
- void firstTabInserted();
- void lastTabRemoved();
void setDisplayFallbackWidget(bool);
void adjustReadOnlyState();
@@ -131,7 +127,7 @@
QVBoxLayout *layout_;
QWidget *fallback_widget_;
QLabel *fallback_label_;
- QETTabWidget *tabs_;
+ QTabWidget *m_tab;
QMap<int, DiagramView *> diagram_ids_;
QList<DiagramView *> diagrams_;
};
Deleted: trunk/sources/qettabbar.cpp
===================================================================
--- trunk/sources/qettabbar.cpp 2015-03-05 11:45:37 UTC (rev 3808)
+++ trunk/sources/qettabbar.cpp 2015-03-05 13:11:38 UTC (rev 3809)
@@ -1,334 +0,0 @@
-/*
- Copyright 2006-2015 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
-*/
-#include "qettabbar.h"
-#include <QWheelEvent>
-
-/**
- Constructeur
- @param parent QWidget parent
-*/
-QETTabBar::QETTabBar(QWidget *parent) :
- QTabBar(parent),
- no_more_tabs_(true),
- movable_tabs_(false),
- moved_tab_(-1)
-{
-}
-
-/**
- Destructeur
-*/
-QETTabBar::~QETTabBar() {
-}
-
-/**
- Active l'onglet suivant si possible
-*/
-void QETTabBar::activateNextTab() {
- int count_ = count();
- if (count_ < 2) return;
-
- int current_index = currentIndex();
- if (current_index == count_ - 1) {
- setCurrentIndex(0);
- } else {
- setCurrentIndex(current_index + 1);
- }
-}
-
-/**
- Active l'onglet precedent si possible
-*/
-void QETTabBar::activatePreviousTab() {
- int count_ = count();
- if (count_ < 2) return;
-
- int current_index = currentIndex();
- if (!current_index) {
- setCurrentIndex(count_ - 1);
- } else {
- setCurrentIndex(current_index - 1);
- }
-}
-
-/**
- @param movable true pour que les onglets soient deplacables, false sinon
-*/
-void QETTabBar::setMovable(bool movable) {
-#if QT_VERSION < 0x040500
- movable_tabs_ = movable;
-#else
- QTabBar::setMovable(movable);
-#endif
-}
-
-/**
- @return true si les onglets sont deplacables, false sinon
-*/
-bool QETTabBar::isMovable() const {
-#if QT_VERSION < 0x040500
- return(movable_tabs_);
-#else
- return(QTabBar::isMovable());
-#endif
-}
-
-/**
- @return true si les onglets sont dessines de maniere verticale
-*/
-bool QETTabBar::isVertical() const {
- int current_shape = shape();
- return(
- current_shape == QTabBar::RoundedEast ||
- current_shape == QTabBar::RoundedWest ||
- current_shape == QTabBar::TriangularEast ||
- current_shape == QTabBar::TriangularWest
- );
-}
-
-/**
- @return true si les onglets sont dessines de maniere horizontale
-*/
-bool QETTabBar::isHorizontal() const {
- int current_shape = shape();
- return(
- current_shape == QTabBar::RoundedNorth ||
- current_shape == QTabBar::RoundedSouth ||
- current_shape == QTabBar::TriangularNorth ||
- current_shape == QTabBar::TriangularSouth
- );
-}
-
-/**
- Gere l'insertion d'un onglet
- @param index indice de l'onglet insere
-*/
-void QETTabBar::tabInserted(int index) {
- QTabBar::tabInserted(index);
- if (no_more_tabs_) {
- emit(firstTabInserted());
- }
- no_more_tabs_ = false;
-}
-
-/**
- Gere le retrait d'un onglet
- @param index indice de l'onglet enleve
-*/
-void QETTabBar::tabRemoved(int index) {
- QTabBar::tabRemoved(index);
- if (!count()) {
- emit(lastTabRemoved());
- no_more_tabs_ = true;
- }
-}
-
-/**
- Gere les evenements rollette sur cette barre d'onglets
- @param event Evenement rollette
-*/
-void QETTabBar::wheelEvent(QWheelEvent *event) {
- int num_degrees = event -> delta() / 8;
- int num_steps = qAbs(num_degrees / 15);
-
- if (num_degrees <= 0) {
- // passe a l'onglet suivant
- for (int i = 0 ; i < num_steps ; ++ i) activateNextTab();
- } else {
- // passe a l'onglet precedent
- for (int i = 0 ; i < num_steps ; ++ i) activatePreviousTab();
- }
- event -> accept();
-}
-
-/**
- @param event Objet decrivant l'evenement souris
-*/
-void QETTabBar::mousePressEvent(QMouseEvent *event) {
- QTabBar::mousePressEvent(event);
- if (movable_tabs_) {
- if (event -> button() == Qt::LeftButton) {
- // retient l'onglet deplace et la position a laquelle le mouvement debute
- moved_tab_ = tabForPressedPosition(event -> pos());
- press_point_ = event -> pos();
- }
- }
-}
-
-/**
- @param event Objet decrivant l'evenement souris
-*/
-void QETTabBar::mouseMoveEvent(QMouseEvent *event) {
- QTabBar::mouseMoveEvent(event);
-
- // gere le deplacement d'onglets si celui-ci est active
- if (movable_tabs_ && moved_tab_ != -1) {
- // repere l'onglet de "destination"
- int dest_tab = tabForMovedPosition(event -> pos());
-
- // verifie s'il faut deplacer l'onglet puis le deplace
- if (mustMoveTab(moved_tab_, dest_tab, event -> pos())) {
- moveTab(moved_tab_, dest_tab);
- moved_tab_ = dest_tab;
- event -> accept();
- }
- }
-}
-
-/**
- @param event Objet decrivant l'evenement souris
-*/
-void QETTabBar::mouseReleaseEvent(QMouseEvent *event) {
- QTabBar::mouseReleaseEvent(event);
- moved_tab_ = -1;
-}
-
-/**
- @param event Objet decrivant l'evenement souris
-*/
-void QETTabBar::mouseDoubleClickEvent(QMouseEvent *event) {
- QTabBar::mouseDoubleClickEvent(event);
- int clicked_tab = tabForPressedPosition(event -> pos());
- emit(tabDoubleClicked(clicked_tab));
-}
-
-/**
- @param src_tab Index de l'onglet de depart
- @param dst_tab Index de l'onglet de destination
- @param pos Position de la souris dans le cadre du deplacement de l'onglet
- @return true s'il faut deplacer l'onglet src_tab a la place de l'onglet
- dst_tab.
- Cette methode
-*/
-bool QETTabBar::mustMoveTab(int src_tab, int dst_tab, const QPoint &pos) const {
- // les onglets sources et cibles doivent etre valides et differents
- if (src_tab == -1 || dst_tab == -1) return(false);
- if (src_tab == dst_tab) return(false);
-
- /*
- A ce stade, le deplacement est possible mais selon la position du
- pointeur de la souris, on peut assister a des deplacements prematures
- d'onglets, rendant l'interface plus difficilement utilisable.
- On s'assure donc que le curseur est assez "loin" pour eviter ces
- problemes.
- */
- // recupere les rectangles representant les onglets
- QRect source_rect = tabRect(src_tab);
- QRect target_rect = tabRect(dst_tab);
-
- if (isHorizontal()) {
- if (layoutDirection() == Qt::LeftToRight && source_rect.x() < target_rect.x()) {
- source_rect.moveRight(target_rect.right());
- } else {
- source_rect.moveLeft(target_rect.left());
- }
- } else {
- if (source_rect.y() < target_rect.y()) {
- source_rect.moveBottom(target_rect.bottom());
- } else {
- source_rect.moveTop(target_rect.top());
- }
- }
- return(posMatchesTabRect(source_rect, pos));
-}
-
-/**
- Deplace un onglet.
- @param src_tab Index de l'onglet de depart
- @param dst_tab Index de l'onglet de destination
-*/
-void QETTabBar::moveTab(int src_tab, int dst_tab) {
-#if QT_VERSION < 0x040500
- // sauvegarde les caracteristiques de l'onglet deplace
- QIcon old_tab_icon = tabIcon(src_tab);
- QVariant old_tab_data = tabData(src_tab);
- QString old_tab_text = tabText(src_tab);
- QColor old_tab_textcolor = tabTextColor(src_tab);
- QString old_tab_tooltip = tabToolTip(src_tab);
- QString old_tab_whatsthis = tabWhatsThis(src_tab);
-
- // si la QETTabBar est utilise dans un QTabWidget (ou une classe en
- // derivant), elle lui delegue le deplacement de l'onglet
- if (QTabWidget *qtabwidget = qobject_cast<QTabWidget *>(parent())) {
- QWidget *old_tab_widget = qtabwidget -> widget(src_tab);
- qtabwidget -> removeTab(src_tab);
- qtabwidget -> insertTab(dst_tab, old_tab_widget, old_tab_text);
- qtabwidget -> setCurrentIndex(dst_tab);
- } else {
- removeTab(src_tab);
- insertTab(dst_tab, old_tab_text);
- setCurrentIndex(dst_tab);
- }
-
- // remet en place les caracteristiques de l'onglet deplace
- setTabIcon (dst_tab, old_tab_icon );
- setTabData (dst_tab, old_tab_data );
- setTabTextColor(dst_tab, old_tab_textcolor);
- setTabToolTip (dst_tab, old_tab_tooltip );
- setTabWhatsThis(dst_tab, old_tab_whatsthis);
-
- // signale le deplacement de l'onglet
- emit(tabMoved(src_tab, dst_tab));
-#else
- QTabBar::moveTab(src_tab, dst_tab);
-#endif
-}
-
-/**
- @param pos Position
- @return l'index de l'onglet correspondant a la position pos, ou -1 si aucun
- onglet ne correspond.
-*/
-int QETTabBar::tabForPressedPosition(const QPoint &pos) {
- for (int tab_index = 0 ; tab_index < count() ; ++ tab_index) {
- if (tabRect(tab_index).contains(pos)) return(tab_index);
- }
- return(-1);
-}
-
-/**
- @param pos Position
- @return l'index de l'onglet correspondant a la position pos lors d'un
- deplacement d'onglet, ou -1 si aucun onglet ne correspond. Cette methode ne
- prend en compte que l'abscisse ou que l'ordonnee de la position en fonction
- de l'orientation des onglets.
-*/
-int QETTabBar::tabForMovedPosition(const QPoint &pos) {
- for (int tab_index = 0 ; tab_index < count() ; ++ tab_index) {
- if (posMatchesTabRect(tabRect(tab_index), pos)) return(tab_index);
- }
- return(-1);
-}
-
-/**
- @param rect Un rectangle cense representer un onglet
- @param pos Une position
- @return true si la position pos correspond a ce rectangle.
- Cette methode ne prend en compte que l'abscisse ou que
- l'ordonnee de la position en fonction de l'orientation des onglets.
-*/
-bool QETTabBar::posMatchesTabRect(const QRect &rect, const QPoint &pos) const {
- if (isVertical()) {
- // les onglets sont disposes de maniere verticale : on prend en compte l'ordonnee
- if (pos.y() >= rect.y() && pos.y() < rect.y() + rect.height()) return(true);
- } else {
- // les onglets sont disposes de maniere horizontale : on prend en compte l'abscisse
- if (pos.x() >= rect.x() && pos.x() < rect.x() + rect.width()) return(true);
- }
- return(false);
-}
Deleted: trunk/sources/qettabbar.h
===================================================================
--- trunk/sources/qettabbar.h 2015-03-05 11:45:37 UTC (rev 3808)
+++ trunk/sources/qettabbar.h 2015-03-05 13:11:38 UTC (rev 3809)
@@ -1,80 +0,0 @@
-/*
- Copyright 2006-2015 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
-*/
-#ifndef QET_TAB_BAR_H
-#define QET_TAB_BAR_H
-#include <QtWidgets>
-#include <QTabBar>
-/**
- This class provides a tab bar.
- It is different from a QTabBar on the following points:
- * it emits a signal when the last tab is closed;
- * it emits a signal whe the first is inserted;
- * it allows switching tabs using the mouse wheel.
-*/
-class QETTabBar : public QTabBar {
- Q_OBJECT
-
- // constructors, destructor
- public:
- QETTabBar(QWidget * = 0);
- virtual~QETTabBar();
-
- private:
- QETTabBar(const QETTabBar &);
-
- // methods
- public:
- void activateNextTab();
- void activatePreviousTab();
- void setMovable(bool);
- bool isMovable() const;
- bool isVertical() const;
- bool isHorizontal() const;
- void moveTab(int, int);
-
- protected:
- virtual void tabInserted(int);
- virtual void tabRemoved(int);
- virtual void wheelEvent(QWheelEvent *);
- virtual void mousePressEvent(QMouseEvent *);
- virtual void mouseMoveEvent(QMouseEvent *);
- virtual void mouseReleaseEvent(QMouseEvent *);
- virtual void mouseDoubleClickEvent(QMouseEvent *);
-
- signals:
- void lastTabRemoved();
- void firstTabInserted();
-#if QT_VERSION < 0x040500
- void tabMoved(int, int);
-#endif
- void tabDoubleClicked(int);
-
- private:
- bool mustMoveTab(int, int, const QPoint &) const;
- int tabForPressedPosition(const QPoint &);
- int tabForMovedPosition(const QPoint &);
- bool posMatchesTabRect(const QRect &, const QPoint &) const;
-
- // attributes
- private:
- bool no_more_tabs_;
- bool movable_tabs_;
- int moved_tab_;
- QPoint press_point_;
-};
-#endif
Deleted: trunk/sources/qettabwidget.cpp
===================================================================
--- trunk/sources/qettabwidget.cpp 2015-03-05 11:45:37 UTC (rev 3808)
+++ trunk/sources/qettabwidget.cpp 2015-03-05 13:11:38 UTC (rev 3809)
@@ -1,100 +0,0 @@
-/*
- Copyright 2006-2015 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "qettabwidget.h"
-#include <QCoreApplication>
-#include <QWheelEvent>
-#include "qettabbar.h"
-
-/**
- Constructeur
- @param parent QWidget parent
-*/
-QETTabWidget::QETTabWidget(QWidget *parent) :
- QTabWidget(parent)
-{
- tab_bar_ = new QETTabBar(this);
- setTabBar(tab_bar_);
-
- // re-emet les signaux emis par la barre d'onglets
- connect(tab_bar_, SIGNAL(lastTabRemoved()), this, SIGNAL(lastTabRemoved()));
- connect(tab_bar_, SIGNAL(firstTabInserted()), this, SIGNAL(firstTabInserted()));
- connect(tab_bar_, SIGNAL(tabMoved(int, int)), this, SIGNAL(tabMoved(int, int)));
- connect(tab_bar_, SIGNAL(tabDoubleClicked(int)), this, SIGNAL(tabDoubleClicked(int)));
-}
-
-/**
- Destructeur
-*/
-QETTabWidget::~QETTabWidget() {
-}
-
-/**
- @param movable true pour que les onglets soient deplacables, false sinon
-*/
-void QETTabWidget::setMovable(bool movable) {
-#if QT_VERSION < 0x040500
- tab_bar_ -> setMovable(movable);
-#else
- QTabWidget::setMovable(movable);
-#endif
-}
-
-/**
- @return true si les onglets sont deplacables, false sinon
-*/
-bool QETTabWidget::isMovable() const {
-#if QT_VERSION < 0x040500
- return(tab_bar_ -> isMovable());
-#else
- return(QTabWidget::isMovable());
-#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_);
-}
-
-/**
- Gere les evenements rollette sur cette barre d'onglets
- @param event Evenement rollette
-*/
-void QETTabWidget::wheelEvent(QWheelEvent *event) {
- QTabBar *tab_bar = tabBar();
- // rectangle occupe par la barre d'onglets
- QRect tab_bar_region(QPoint(0, 0), QSize(size().width(), tab_bar -> size().height()));
- if (tab_bar_region.contains(event -> pos())) {
- QCoreApplication::sendEvent(tab_bar, event);
- } else {
- event -> ignore();
- }
-}
Deleted: trunk/sources/qettabwidget.h
===================================================================
--- trunk/sources/qettabwidget.h 2015-03-05 11:45:37 UTC (rev 3808)
+++ trunk/sources/qettabwidget.h 2015-03-05 13:11:38 UTC (rev 3809)
@@ -1,58 +0,0 @@
-/*
- Copyright 2006-2015 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
-*/
-#ifndef QET_TAB_WIDGET_H
-#define QET_TAB_WIDGET_H
-#include <QTabWidget>
-class QETTabBar;
-/**
- This class behaves like a QTabWidget except it uses a QETTAbBar to manage its
- tabs. It also transmits the lastTabRemoved() and firstTabInserted() signals.
- @see QETTabBar
-*/
-class QETTabWidget : public QTabWidget {
- Q_OBJECT
-
- // constructors, destructor
- public:
- QETTabWidget(QWidget * = 0);
- virtual~QETTabWidget();
-
- private:
- QETTabWidget(const QETTabWidget &);
-
- // methods
- public:
- void setMovable(bool);
- bool isMovable() const;
- void moveTab(int, int);
- QETTabBar *tabBar() const;
-
- protected:
- void wheelEvent(QWheelEvent *);
-
- signals:
- void lastTabRemoved();
- void firstTabInserted();
- void tabMoved(int, int);
- void tabDoubleClicked(int);
-
- // attributes
- private:
- QETTabBar *tab_bar_;
-};
-#endif