ATLAS Offline Software
Loading...
Searching...
No Matches
VP1TabWidget::Private Class Reference
Collaboration diagram for VP1TabWidget::Private:

Public Member Functions

 Private (VP1TabWidget *parent)
bool isEmptyTabbarSpace (const QPoint &) const
void resizeTabs (int changedTabIndex=-1)
void updateTab (int index)

Public Attributes

VP1TabWidgetm_parent
bool m_automaticResizeTabs
int m_maxLength
int m_minLength
int m_currentMaxLength
QStringList m_tabNames

Detailed Description

Definition at line 48 of file VP1TabWidget.cxx.

Constructor & Destructor Documentation

◆ Private()

VP1TabWidget::Private::Private ( VP1TabWidget * parent)
inline

Definition at line 51 of file VP1TabWidget.cxx.

Member Function Documentation

◆ isEmptyTabbarSpace()

bool VP1TabWidget::Private::isEmptyTabbarSpace ( const QPoint & point) const

Definition at line 79 of file VP1TabWidget.cxx.

80{
81 QSize size( m_parent->tabBar()->sizeHint() );
82 if ( ( m_parent->tabPosition() == QTabWidget::North && point.y() < size.height() ) ||
83 ( m_parent->tabPosition() == QTabWidget::South && point.y() > (m_parent->height() - size.height() ) ) ) {
84
85 QWidget *rightcorner = m_parent->cornerWidget( Qt::TopRightCorner );
86 if ( rightcorner ) {
87 if ( point.x() >= m_parent->width()-rightcorner->width() )
88 return false;
89 }
90
91 QWidget *leftcorner = m_parent->cornerWidget( Qt::TopLeftCorner );
92 if ( leftcorner ) {
93 if ( point.x() <= leftcorner->width() )
94 return false;
95 }
96
97 for ( int i = 0; i < m_parent->count(); ++i )
98 if ( m_parent->tabBar()->tabRect( i ).contains( m_parent->tabBar()->mapFromParent( point ) ) )
99 return false;
100
101 return true;
102 }
103
104 return false;
105}

◆ resizeTabs()

void VP1TabWidget::Private::resizeTabs ( int changedTabIndex = -1)

Definition at line 107 of file VP1TabWidget.cxx.

108{
109 int newMaxLength;
110 if ( m_automaticResizeTabs ) {
111 // Calculate new max length
112 newMaxLength = m_maxLength;
113 int lcw = 0, rcw = 0;
114
115 int tabBarHeight = m_parent->tabBar()->sizeHint().height();
116 if ( m_parent->cornerWidget( Qt::TopLeftCorner ) && m_parent->cornerWidget( Qt::TopLeftCorner )->isVisible() )
117 lcw = qMax( m_parent->cornerWidget( Qt::TopLeftCorner )->width(), tabBarHeight );
118
119 if ( m_parent->cornerWidget( Qt::TopRightCorner ) && m_parent->cornerWidget( Qt::TopRightCorner )->isVisible() )
120 rcw = qMax( m_parent->cornerWidget( Qt::TopRightCorner )->width(), tabBarHeight );
121
122 int maxTabBarWidth = m_parent->width() - lcw - rcw;
123
124 for ( ; newMaxLength > m_minLength; newMaxLength-- ) {
125 if ( m_parent->tabBarWidthForMaxChars( newMaxLength ) < maxTabBarWidth )
126 break;
127 }
128 } else
129 newMaxLength = 4711;
130
131 // Update hinted or all tabs
132 if ( m_currentMaxLength != newMaxLength ) {
133 m_currentMaxLength = newMaxLength;
134 for ( int i = 0; i < m_parent->count(); ++i )
135 updateTab( i );
136 } else if ( changeTabIndex != -1 )
137 updateTab( changeTabIndex );
138}
void updateTab(int index)

◆ updateTab()

void VP1TabWidget::Private::updateTab ( int index)

Definition at line 140 of file VP1TabWidget.cxx.

141{
142 QString title = m_automaticResizeTabs ? m_tabNames[ index ] : m_parent->QTabWidget::tabText( index );
143 m_parent->setTabToolTip( index, QString() );
144
145 if ( title.length() > m_currentMaxLength ) {
146 if ( Qt::mightBeRichText( title ) )
147 // m_parent->setTabToolTip( index, Qt::escape( title ) ); // old Qt code
148 m_parent->setTabToolTip( index, QString(title).toHtmlEscaped() );
149 else
150 m_parent->setTabToolTip( index, title );
151 }
152
153 //TK-fixme. Just use elide here?
154 //TK-fixme title = KStringHandler::rsqueeze( title, m_currentMaxLength ).leftJustified( m_minLength, ' ' );
155 title.replace( '&', "&&" );
156
157 if ( m_parent->QTabWidget::tabText( index ) != title )
158 m_parent->QTabWidget::setTabText( index, title );
159}
str index
Definition DeMoScan.py:362

Member Data Documentation

◆ m_automaticResizeTabs

bool VP1TabWidget::Private::m_automaticResizeTabs

Definition at line 60 of file VP1TabWidget.cxx.

◆ m_currentMaxLength

int VP1TabWidget::Private::m_currentMaxLength

Definition at line 63 of file VP1TabWidget.cxx.

◆ m_maxLength

int VP1TabWidget::Private::m_maxLength

Definition at line 61 of file VP1TabWidget.cxx.

◆ m_minLength

int VP1TabWidget::Private::m_minLength

Definition at line 62 of file VP1TabWidget.cxx.

◆ m_parent

VP1TabWidget* VP1TabWidget::Private::m_parent

Definition at line 59 of file VP1TabWidget.cxx.

◆ m_tabNames

QStringList VP1TabWidget::Private::m_tabNames

Definition at line 67 of file VP1TabWidget.cxx.


The documentation for this class was generated from the following file: