20#include "moc_qgstabwidget.cpp"
23 : QTabWidget( parent )
25 QgsTabBar *qgsTabBar =
new QgsTabBar(
this );
26 setTabBar( qgsTabBar );
27 mTabBarStyle =
new QgsTabBarProxyStyle( tabBar() );
28 qgsTabBar->setTabBarStyle( mTabBarStyle );
29 setStyle( mTabBarStyle );
38 mSetTabVisibleFlag =
true;
39 removeTab( info.sourceIndex );
41 mSetTabVisibleFlag =
false;
51 mSetTabVisibleFlag =
true;
52 insertTab( info.sourceIndex + 1, info.widget, info.label );
54 mSetTabVisibleFlag =
false;
69 const auto constMTabs = mTabs;
70 for (
const TabInformation &info : constMTabs )
72 if ( info.widget == widget )
81 mTabBarStyle->addStyle( tabIndex, labelStyle );
86 if ( !mSetTabVisibleFlag )
88 QWidget *newWidget = widget( index );
92 mTabs.insert( 0, TabInformation( newWidget, tabText( index ) ) );
96 bool inserted =
false;
97 QList<TabInformation>::iterator it;
99 for ( it = mTabs.begin(); it != mTabs.end(); ++it )
101 if ( it->sourceIndex == index )
103 mTabs.insert( it, TabInformation( newWidget, tabText( index ) ) );
111 mTabs.append( TabInformation( newWidget, tabText( index ) ) );
116 synchronizeIndexes();
121 if ( !mSetTabVisibleFlag )
123 QList<TabInformation>::iterator it;
125 for ( it = mTabs.begin(); it != mTabs.end(); ++it )
127 if ( it->sourceIndex == index )
129 mTabs.removeOne( *it );
135 synchronizeIndexes();
138void QgsTabWidget::synchronizeIndexes()
142 QWidget *nextWidget = widget( 0 );
144 QList<TabInformation>::iterator it;
146 for ( it = mTabs.begin(); it != mTabs.end(); ++it )
148 if ( it->widget == nextWidget )
151 nextWidget = widget( i + 1 );
154 QgsDebugMsgLevel( QStringLiteral(
"Tab %1 (%2): %3" ).arg( it->sourceIndex ).arg( it->label ).arg( i ), 3 );
158QgsTabWidget::TabInformation QgsTabWidget::tabInfo( QWidget *widget )
160 const auto constMTabs = mTabs;
161 for (
const TabInformation &info : constMTabs )
163 if ( info.widget == widget )
166 return TabInformation();
169bool QgsTabWidget::TabInformation::operator==(
const QgsTabWidget::TabInformation &other )
const
171 return other.widget == widget && other.sourceIndex == sourceIndex;
174bool QgsTabWidget::TabInformation::operator!=(
const TabInformation &other )
const
176 return !( *
this == other );
#define QgsDebugMsgLevel(str, level)
The TabStyle struct defines color and font overrides for form fields, tabs and groups labels.