ATLAS Offline Software
Loading...
Searching...
No Matches
VP1TabWidget Class Reference

#include <VP1TabWidget.h>

Inheritance diagram for VP1TabWidget:
Collaboration diagram for VP1TabWidget:

Classes

class  Private

Public Slots

virtual void moveTab (int, int)
virtual QT_MOC_COMPAT void removePage (QWidget *w)
virtual void removeTab (int index)
void setTabReorderingEnabled (bool enable)
void setTabCloseActivatePrevious (bool previous)
void setAutomaticResizeTabs (bool enable)

Signals

void testCanDecode (const QDragMoveEvent *e, bool &accept)
void receivedDropEvent (QDropEvent *)
void receivedDropEvent (QWidget *, QDropEvent *)
void initiateDrag (QWidget *)
void contextMenu (const QPoint &)
void contextMenu (QWidget *, const QPoint &)
void movedTab (int, int)
void mouseDoubleClick ()
void mouseDoubleClick (QWidget *)
void mouseMiddleClick ()
void mouseMiddleClick (QWidget *)
void closeRequest (QWidget *)

Public Member Functions

VP1TabBargetVP1TabBar ()
 VP1TabWidget (QWidget *parent=0, Qt::WindowFlags flags=Qt::WindowFlags())
virtual ~VP1TabWidget ()
void setTabTextColor (int index, const QColor &color)
QColor tabTextColor (int index) const
bool isTabReorderingEnabled () const
bool tabCloseActivatePrevious () const
bool automaticResizeTabs () const
void setTabBarHidden (bool hide)
bool isTabBarHidden () const
QString tabText (int) const
void setTabText (int, const QString &)

Protected Slots

virtual void receivedDropEvent (int, QDropEvent *)
virtual void initiateDrag (int)
virtual void contextMenu (int, const QPoint &)
virtual void mouseDoubleClick (int)
virtual void mouseMiddleClick (int)
virtual void closeRequest (int)
virtual void wheelDelta (int)

Protected Member Functions

virtual void mouseDoubleClickEvent (QMouseEvent *)
virtual void mousePressEvent (QMouseEvent *)
virtual void dragEnterEvent (QDragEnterEvent *)
virtual void dragMoveEvent (QDragMoveEvent *)
virtual void dropEvent (QDropEvent *)
int tabBarWidthForMaxChars (int)
virtual void wheelEvent (QWheelEvent *)
virtual void resizeEvent (QResizeEvent *)
virtual void tabInserted (int)
virtual void tabRemoved (int)

Properties

bool tabReorderingEnabled
bool tabCloseActivatePrevious
bool automaticResizeTabs

Private Attributes

Private *const m_d

Detailed Description

Definition at line 44 of file VP1TabWidget.h.

Constructor & Destructor Documentation

◆ VP1TabWidget()

VP1TabWidget::VP1TabWidget ( QWidget * parent = 0,
Qt::WindowFlags flags = Qt::WindowFlags() )
explicit

Definition at line 162 of file VP1TabWidget.cxx.

163 : QTabWidget( parent ),
164 m_d( new Private( this ) )
165{
166 setWindowFlags( flags );
167 setTabBar( new VP1TabBar( this ) );
168 setObjectName( "tabbar" );
169 setAcceptDrops( true );
170
171 connect(tabBar(), SIGNAL(contextMenu( int, const QPoint & )), SLOT(contextMenu( int, const QPoint & )));
172 connect(tabBar(), SIGNAL(mouseDoubleClick( int )), SLOT(mouseDoubleClick( int )));
173 connect(tabBar(), SIGNAL(mouseMiddleClick( int )), SLOT(mouseMiddleClick( int )));
174 connect(tabBar(), SIGNAL(initiateDrag( int )), SLOT(initiateDrag( int )));
175 connect(tabBar(), SIGNAL(testCanDecode(const QDragMoveEvent *, bool & )), SIGNAL(testCanDecode(const QDragMoveEvent *, bool & )));
176 connect(tabBar(), SIGNAL(receivedDropEvent( int, QDropEvent * )), SLOT(receivedDropEvent( int, QDropEvent * )));
178 connect(tabBar(), SIGNAL(closeRequest( int )), SLOT(closeRequest( int )));
179#ifndef QT_NO_WHEELEVENT
181#endif
182}
void moveTab(int, int)
void wheelDelta(int)
void receivedDropEvent(QDropEvent *)
void mouseDoubleClick()
void testCanDecode(const QDragMoveEvent *e, bool &accept)
void closeRequest(QWidget *)
void mouseMiddleClick()
void initiateDrag(QWidget *)
Private *const m_d
VP1TabBar * getVP1TabBar()
void contextMenu(const QPoint &)
virtual void wheelDelta(int)
virtual void moveTab(int, int)

◆ ~VP1TabWidget()

VP1TabWidget::~VP1TabWidget ( )
virtual

Definition at line 184 of file VP1TabWidget.cxx.

185{
186 delete m_d;
187}

Member Function Documentation

◆ automaticResizeTabs()

bool VP1TabWidget::automaticResizeTabs ( ) const

Definition at line 497 of file VP1TabWidget.cxx.

498{
499 return m_d->m_automaticResizeTabs;
500}

◆ closeRequest [1/2]

void VP1TabWidget::closeRequest ( int index)
protectedvirtualslot

Definition at line 502 of file VP1TabWidget.cxx.

503{
504 emit( closeRequest( widget( index ) ) );
505}

◆ closeRequest [2/2]

void VP1TabWidget::closeRequest ( QWidget * )
signal

◆ contextMenu [1/3]

void VP1TabWidget::contextMenu ( const QPoint & )
signal

◆ contextMenu [2/3]

void VP1TabWidget::contextMenu ( int index,
const QPoint & point )
protectedvirtualslot

Definition at line 417 of file VP1TabWidget.cxx.

418{
419 emit( contextMenu( widget( index ), point ) );
420}

◆ contextMenu [3/3]

void VP1TabWidget::contextMenu ( QWidget * ,
const QPoint &  )
signal

◆ dragEnterEvent()

void VP1TabWidget::dragEnterEvent ( QDragEnterEvent * event)
protectedvirtual

Definition at line 315 of file VP1TabWidget.cxx.

316{
317 event->setAccepted( true );
318 QTabWidget::dragEnterEvent( event );
319}

◆ dragMoveEvent()

void VP1TabWidget::dragMoveEvent ( QDragMoveEvent * event)
protectedvirtual

Definition at line 321 of file VP1TabWidget.cxx.

322{
323 if ( m_d->isEmptyTabbarSpace( event->pos() ) ) {
324 bool accept = false;
325 // The receivers of the testCanDecode() signal has to adjust
326 // 'accept' accordingly.
327 emit testCanDecode( event, accept);
328
329 event->setAccepted( accept );
330 return;
331 }
332
333 event->setAccepted( false );
334 QTabWidget::dragMoveEvent( event );
335}
StatusCode accept(const xAOD::Muon *mu)

◆ dropEvent()

void VP1TabWidget::dropEvent ( QDropEvent * event)
protectedvirtual

Definition at line 337 of file VP1TabWidget.cxx.

338{
339 if ( m_d->isEmptyTabbarSpace( event->pos() ) ) {
340 emit ( receivedDropEvent( event ) );
341 return;
342 }
343
344 QTabWidget::dropEvent( event );
345}

◆ getVP1TabBar()

VP1TabBar * VP1TabWidget::getVP1TabBar ( )

Definition at line 75 of file VP1TabWidget.cxx.

75 {
76 return static_cast<VP1TabBar*>(tabBar());
77}

◆ initiateDrag [1/2]

void VP1TabWidget::initiateDrag ( int index)
protectedvirtualslot

Definition at line 412 of file VP1TabWidget.cxx.

413{
414 emit( initiateDrag( widget( index ) ) );
415}

◆ initiateDrag [2/2]

void VP1TabWidget::initiateDrag ( QWidget * )
signal

◆ isTabBarHidden()

bool VP1TabWidget::isTabBarHidden ( ) const

Definition at line 230 of file VP1TabWidget.cxx.

231{
232 return !( tabBar()->isVisible() );
233}

◆ isTabReorderingEnabled()

bool VP1TabWidget::isTabReorderingEnabled ( ) const

Definition at line 250 of file VP1TabWidget.cxx.

251{
252 return static_cast<VP1TabBar*>(tabBar())->isTabReorderingEnabled();
253}
bool isTabReorderingEnabled() const

◆ mouseDoubleClick [1/3]

void VP1TabWidget::mouseDoubleClick ( )
signal

◆ mouseDoubleClick [2/3]

void VP1TabWidget::mouseDoubleClick ( int index)
protectedvirtualslot

Definition at line 422 of file VP1TabWidget.cxx.

423{
424 emit( mouseDoubleClick( widget( index ) ) );
425}

◆ mouseDoubleClick [3/3]

void VP1TabWidget::mouseDoubleClick ( QWidget * )
signal

◆ mouseDoubleClickEvent()

void VP1TabWidget::mouseDoubleClickEvent ( QMouseEvent * event)
protectedvirtual

Definition at line 377 of file VP1TabWidget.cxx.

378{
379 if ( event->button() != Qt::LeftButton )
380 return;
381
382 if ( m_d->isEmptyTabbarSpace( event->pos() ) ) {
383 emit( mouseDoubleClick() );
384 return;
385 }
386
387 QTabWidget::mouseDoubleClickEvent( event );
388}

◆ mouseMiddleClick [1/3]

void VP1TabWidget::mouseMiddleClick ( )
signal

◆ mouseMiddleClick [2/3]

void VP1TabWidget::mouseMiddleClick ( int index)
protectedvirtualslot

Definition at line 427 of file VP1TabWidget.cxx.

428{
429 emit( mouseMiddleClick( widget( index ) ) );
430}

◆ mouseMiddleClick [3/3]

void VP1TabWidget::mouseMiddleClick ( QWidget * )
signal

◆ mousePressEvent()

void VP1TabWidget::mousePressEvent ( QMouseEvent * event)
protectedvirtual

Definition at line 390 of file VP1TabWidget.cxx.

391{
392 if ( event->button() == Qt::RightButton ) {
393 if ( m_d->isEmptyTabbarSpace( event->pos() ) ) {
394 emit( contextMenu( mapToGlobal( event->pos() ) ) );
395 return;
396 }
397 } else if ( event->button() == Qt::MiddleButton ) {
398 if ( m_d->isEmptyTabbarSpace( event->pos() ) ) {
399 emit( mouseMiddleClick() );
400 return;
401 }
402 }
403
404 QTabWidget::mousePressEvent( event );
405}

◆ movedTab

void VP1TabWidget::movedTab ( int ,
int  )
signal

◆ moveTab

void VP1TabWidget::moveTab ( int from,
int to )
virtualslot

Definition at line 432 of file VP1TabWidget.cxx.

433{
434 QString tablabel = tabText( from );
435 QWidget *w = widget( from );
436 QColor color = tabTextColor( from );
437 QIcon tabiconset = tabIcon( from );
438 QString tabtooltip = tabToolTip( from );
439 bool current = ( from == currentIndex() );
440 bool enabled = isTabEnabled( from );
441
442 bool blocked = blockSignals( true );
443 removeTab( from );
444
445 // Work-around kmdi brain damage which calls showPage() in insertTab()
446 insertTab( to, w, tablabel );
447 if ( m_d->m_automaticResizeTabs ) {
448 if ( to < 0 || to >= count() )
449 m_d->m_tabNames.append( QString() );
450 else
451 m_d->m_tabNames.insert( to, QString() );
452 }
453
454 setTabIcon( to, tabiconset );
455 setTabText( to, tablabel );
456 setTabToolTip( to, tabtooltip );
457 setTabTextColor( to, color );
458 if ( current )
459 setCurrentIndex( to );
460 setTabEnabled( to, enabled );
461 blockSignals( blocked );
462
463 emit ( movedTab( from, to ) );
464}
void setTabTextColor(int index, const QColor &color)
virtual void removeTab(int index)
void movedTab(int, int)
void setTabText(int, const QString &)
QColor tabTextColor(int index) const
QString tabText(int) const
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146

◆ receivedDropEvent [1/3]

void VP1TabWidget::receivedDropEvent ( int index,
QDropEvent * event )
protectedvirtualslot

Definition at line 407 of file VP1TabWidget.cxx.

408{
409 emit( receivedDropEvent( widget( index ), event ) );
410}

◆ receivedDropEvent [2/3]

void VP1TabWidget::receivedDropEvent ( QDropEvent * )
signal

◆ receivedDropEvent [3/3]

void VP1TabWidget::receivedDropEvent ( QWidget * ,
QDropEvent *  )
signal

◆ removePage

void VP1TabWidget::removePage ( QWidget * w)
virtualslot

Definition at line 466 of file VP1TabWidget.cxx.

467{
468 QTabWidget::removeTab( indexOf( widget ) );
469 if ( m_d->m_automaticResizeTabs )
470 m_d->resizeTabs();
471}

◆ removeTab

void VP1TabWidget::removeTab ( int index)
virtualslot

Definition at line 473 of file VP1TabWidget.cxx.

474{
475 QTabWidget::removeTab( index );
476 if ( m_d->m_automaticResizeTabs )
477 m_d->resizeTabs();
478}

◆ resizeEvent()

void VP1TabWidget::resizeEvent ( QResizeEvent * event)
protectedvirtual

Definition at line 507 of file VP1TabWidget.cxx.

508{
509 QTabWidget::resizeEvent( event );
510 m_d->resizeTabs();
511}

◆ setAutomaticResizeTabs

void VP1TabWidget::setAutomaticResizeTabs ( bool enable)
slot

Definition at line 480 of file VP1TabWidget.cxx.

481{
482 if ( m_d->m_automaticResizeTabs == enabled )
483 return;
484
485 m_d->m_automaticResizeTabs = enabled;
486 if ( enabled ) {
487 m_d->m_tabNames.clear();
488 for ( int i = 0; i < count(); ++i )
489 m_d->m_tabNames.append( tabBar()->tabText( i ) );
490 } else
491 for ( int i = 0; i < count(); ++i )
492 tabBar()->setTabText( i, m_d->m_tabNames[ i ] );
493
494 m_d->resizeTabs();
495}

◆ setTabBarHidden()

void VP1TabWidget::setTabBarHidden ( bool hide)

Definition at line 214 of file VP1TabWidget.cxx.

215{
216 QWidget *rightcorner = cornerWidget( Qt::TopRightCorner );
217 QWidget *leftcorner = cornerWidget( Qt::TopLeftCorner );
218
219 if ( hide ) {
220 if ( leftcorner ) leftcorner->hide();
221 if ( rightcorner ) rightcorner->hide();
222 tabBar()->hide();
223 } else {
224 tabBar()->show();
225 if ( leftcorner ) leftcorner->show();
226 if ( rightcorner ) rightcorner->show();
227 }
228}

◆ setTabCloseActivatePrevious

void VP1TabWidget::setTabCloseActivatePrevious ( bool previous)
slot

Definition at line 255 of file VP1TabWidget.cxx.

256{
257 static_cast<VP1TabBar*>(tabBar())->setTabCloseActivatePrevious( previous );
258}
void setTabCloseActivatePrevious(bool previous)

◆ setTabReorderingEnabled

void VP1TabWidget::setTabReorderingEnabled ( bool enable)
slot

Definition at line 245 of file VP1TabWidget.cxx.

246{
247 static_cast<VP1TabBar*>(tabBar())->setTabReorderingEnabled( on );
248}
void setTabReorderingEnabled(bool enable)

◆ setTabText()

void VP1TabWidget::setTabText ( int index,
const QString & text )

Definition at line 303 of file VP1TabWidget.cxx.

304{
305 QTabWidget::setTabText( index, text );
306 if ( m_d->m_automaticResizeTabs ) {
307 if ( index != -1 ) {
308 m_d->m_tabNames[ index ] = text;
309 m_d->resizeTabs( index );
310 }
311 }
312}
str index
Definition DeMoScan.py:362

◆ setTabTextColor()

void VP1TabWidget::setTabTextColor ( int index,
const QColor & color )

Definition at line 235 of file VP1TabWidget.cxx.

236{
237 tabBar()->setTabTextColor( index, color );
238}

◆ tabBarWidthForMaxChars()

int VP1TabWidget::tabBarWidthForMaxChars ( int )
protected

Definition at line 265 of file VP1TabWidget.cxx.

266{
267 int hframe /*, overlap*/;
268 hframe = tabBar()->style()->pixelMetric( QStyle::PM_TabBarTabHSpace, 0L, tabBar() );
269 //overlap = tabBar()->style()->pixelMetric( QStyle::PM_TabBarTabOverlap, 0L, tabBar() );
270
271 QFontMetrics fm = tabBar()->fontMetrics();
272 int x = 0;
273 for ( int i = 0; i < count(); ++i ) {
274 QString newTitle = m_d->m_tabNames[ i ];
275 //TK-fixme. Just use elide here?
276 //TK-fixme newTitle = KStringHandler::rsqueeze( newTitle, maxLength ).leftJustified( m_d->m_minLength, ' ' );
277
278 int lw = fm.horizontalAdvance( newTitle );
279 int iw = 0;
280 if ( !tabBar()->tabIcon( i ).isNull() ){
281 iw = tabBar()->tabIcon( i ).pixmap( style()->pixelMetric( QStyle::PM_SmallIconSize ), QIcon::Normal ).width() + 4;
282 }
283 x += ( tabBar()->style()->sizeFromContents( QStyle::CT_TabBarTab, 0L,
284 QSize( qMax( lw + hframe + iw, QApplication::globalStrut().width() ), 0 ),
285 this ) ).width();
286 }
287
288 return x;
289}
const double width
#define x

◆ tabCloseActivatePrevious()

bool VP1TabWidget::tabCloseActivatePrevious ( ) const

Definition at line 260 of file VP1TabWidget.cxx.

261{
262 return static_cast<VP1TabBar*>(tabBar())->tabCloseActivatePrevious();
263}
bool tabCloseActivatePrevious

◆ tabInserted()

void VP1TabWidget::tabInserted ( int idx)
protectedvirtual

Definition at line 513 of file VP1TabWidget.cxx.

514{
515 m_d->m_tabNames.insert( idx, tabBar()->tabText( idx ) );
516}

◆ tabRemoved()

void VP1TabWidget::tabRemoved ( int idx)
protectedvirtual

Definition at line 518 of file VP1TabWidget.cxx.

519{
520 m_d->m_tabNames.removeAt( idx );
521}

◆ tabText()

QString VP1TabWidget::tabText ( int index) const

Definition at line 291 of file VP1TabWidget.cxx.

292{
293 if ( m_d->m_automaticResizeTabs ) {
294 if ( index >= 0 && index < count() )
295 return m_d->m_tabNames[ index ];
296 else
297 return QString();
298 }
299 else
300 return QTabWidget::tabText( index );
301}

◆ tabTextColor()

QColor VP1TabWidget::tabTextColor ( int index) const

Definition at line 240 of file VP1TabWidget.cxx.

241{
242 return tabBar()->tabTextColor( index );
243}

◆ testCanDecode

void VP1TabWidget::testCanDecode ( const QDragMoveEvent * e,
bool & accept )
signal

◆ wheelDelta

void VP1TabWidget::wheelDelta ( int delta)
protectedvirtualslot

Definition at line 360 of file VP1TabWidget.cxx.

361{
362 if ( count() < 2 )
363 return;
364
365 int page = currentIndex();
366 if ( delta < 0 )
367 page = (page + 1) % count();
368 else {
369 page--;
370 if ( page < 0 )
371 page = count() - 1;
372 }
373 setCurrentIndex( page );
374}

◆ wheelEvent()

void VP1TabWidget::wheelEvent ( QWheelEvent * event)
protectedvirtual

Definition at line 348 of file VP1TabWidget.cxx.

349{
350#if QTGUI_VERSION >= 0x050E00
351 if ( m_d->isEmptyTabbarSpace( event->position().toPoint() ) )
352#else
353 if ( m_d->isEmptyTabbarSpace( event->pos() ) )
354#endif
355 wheelDelta( event->angleDelta().y() );
356 else
357 event->ignore();
358}

Member Data Documentation

◆ m_d

Private* const VP1TabWidget::m_d
private

Definition at line 143 of file VP1TabWidget.h.

Property Documentation

◆ automaticResizeTabs

bool VP1TabWidget::automaticResizeTabs
readwrite

Definition at line 49 of file VP1TabWidget.h.

◆ tabCloseActivatePrevious

bool VP1TabWidget::tabCloseActivatePrevious
readwrite

Definition at line 48 of file VP1TabWidget.h.

◆ tabReorderingEnabled

bool VP1TabWidget::tabReorderingEnabled
readwrite

Definition at line 47 of file VP1TabWidget.h.


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