Qt 4.8
Classes | Public Functions | Static Public Functions | Public Variables | List of all members
QTabBarPrivate Class Reference

#include <qtabbar_p.h>

Inheritance diagram for QTabBarPrivate:
QWidgetPrivate QObjectPrivate QObjectData

Classes

struct  Tab
 

Public Functions

void _q_closeTab ()
 
void _q_scrollTabs ()
 
Tabat (int index)
 
const Tabat (int index) const
 
int calculateNewPosition (int from, int to, int index) const
 
int extraWidth () const
 
int indexAtPos (const QPoint &p) const
 
void init ()
 
void layoutTab (int index)
 
void layoutTabs ()
 
void layoutWidgets (int start=0)
 
void makeVisible (int index)
 
QSize minimumTabSizeHint (int index)
 
void moveTab (int index, int offset)
 em>Reimplemented Function More...
 
void moveTabFinished (int index)
 em>Reimplemented Function More...
 
 QTabBarPrivate ()
 
void refresh ()
 
void setCurrentNextEnabledIndex (int offset)
 em>Reimplemented Function More...
 
void setupMovableTab ()
 
void slide (int from, int to)
 
void updateMacBorderMetrics ()
 
bool validIndex (int index) const
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static void initStyleBaseOption (QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

bool closeButtonOnTabs
 
int currentIndex
 
bool documentMode
 
bool dragInProgress
 
QPoint dragStartPosition
 
bool drawBase
 
Qt::TextElideMode elideMode
 
bool elideModeSetByUser
 
bool expanding
 
QRect hoverRect
 
QSize iconSize
 
bool layoutDirty
 
QToolButtonleftB
 
bool movable
 
QWidgetmovingTab
 
bool paintWithOffsets
 
int pressedIndex
 
int previousPressedIndex
 
QToolButtonrightB
 
int scrollOffset
 
QTabBar::SelectionBehavior selectionBehaviorOnRemove
 
QTabBar::Shape shape
 
QList< TabtabList
 
bool useScrollButtons
 
bool useScrollButtonsSetByUser
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 72 of file qtabbar_p.h.

Constructors and Destructors

◆ QTabBarPrivate()

QTabBarPrivate::QTabBarPrivate ( )
inline

Definition at line 76 of file qtabbar_p.h.

80  dragInProgress(false), documentMode(false), movingTab(0)
81 #ifdef Q_WS_MAC
83 #endif
84  {}
int previousPressedIndex
Definition: qtabbar_p.h:205
QTabBar::SelectionBehavior selectionBehaviorOnRemove
Definition: qtabbar_p.h:195
QWidget * movingTab
Definition: qtabbar_p.h:203
bool layoutDirty
Definition: qtabbar_p.h:89
QTabBar::Shape shape
Definition: qtabbar_p.h:88
bool paintWithOffsets
Definition: qtabbar_p.h:198
bool useScrollButtonsSetByUser
Definition: qtabbar_p.h:191
bool dragInProgress
Definition: qtabbar_p.h:200
int pressedIndex
Definition: qtabbar_p.h:87
bool closeButtonOnTabs
Definition: qtabbar_p.h:194
bool documentMode
Definition: qtabbar_p.h:201
int currentIndex
Definition: qtabbar_p.h:86
bool elideModeSetByUser
Definition: qtabbar_p.h:189
int scrollOffset
Definition: qtabbar_p.h:91

Functions

◆ _q_closeTab()

void QTabBarPrivate::_q_closeTab ( )

Definition at line 655 of file qtabbar.cpp.

656 {
657  Q_Q(QTabBar);
658  QObject *object = q->sender();
659  int tabToClose = -1;
661  for (int i = 0; i < tabList.count(); ++i) {
662  if (closeSide == QTabBar::LeftSide) {
663  if (tabList.at(i).leftWidget == object) {
664  tabToClose = i;
665  break;
666  }
667  } else {
668  if (tabList.at(i).rightWidget == object) {
669  tabToClose = i;
670  break;
671  }
672  }
673  }
674  if (tabToClose != -1)
675  emit q->tabCloseRequested(tabToClose);
676 }
ButtonPosition
This enum type lists the location of the widget on a tab.
Definition: qtabbar.h:89
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition: qobject.cpp:2327
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
QList< Tab > tabList
Definition: qtabbar_p.h:153

◆ _q_scrollTabs()

void QTabBarPrivate::_q_scrollTabs ( )

Definition at line 678 of file qtabbar.cpp.

Referenced by init().

679 {
680  Q_Q(QTabBar);
681  const QObject *sender = q->sender();
682  int i = -1;
683  if (!verticalTabs(shape)) {
684  if (sender == leftB) {
685  for (i = tabList.count() - 1; i >= 0; --i) {
686  if (tabList.at(i).rect.left() - scrollOffset < 0) {
687  makeVisible(i);
688  return;
689  }
690  }
691  } else if (sender == rightB) {
692  int availableWidth = q->width() - extraWidth();
693  for (i = 0; i < tabList.count(); ++i) {
694  if (tabList.at(i).rect.right() - scrollOffset > availableWidth) {
695  makeVisible(i);
696  return;
697  }
698  }
699  }
700  } else { // vertical
701  if (sender == leftB) {
702  for (i = tabList.count() - 1; i >= 0; --i) {
703  if (tabList.at(i).rect.top() - scrollOffset < 0) {
704  makeVisible(i);
705  return;
706  }
707  }
708  } else if (sender == rightB) {
709  int available = q->height() - extraWidth();
710  for (i = 0; i < tabList.count(); ++i) {
711  if (tabList.at(i).rect.bottom() - scrollOffset > available) {
712  makeVisible(i);
713  return;
714  }
715  }
716  }
717  }
718 }
QToolButton * rightB
Definition: qtabbar_p.h:170
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
int extraWidth() const
Definition: qtabbar.cpp:354
QToolButton * leftB
Definition: qtabbar_p.h:171
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition: qobject.cpp:2327
#define Q_Q(Class)
Definition: qglobal.h:2483
QTabBar::Shape shape
Definition: qtabbar_p.h:88
QList< Tab > tabList
Definition: qtabbar_p.h:153
int scrollOffset
Definition: qtabbar_p.h:91
static bool verticalTabs(QTabBar::Shape shape)
Definition: qtabbar.cpp:77
void makeVisible(int index)
Definition: qtabbar.cpp:585

◆ at() [1/2]

QTabBarPrivate::Tab * QTabBarPrivate::at ( int  index)

Definition at line 385 of file qtabbar.cpp.

386 {
387  return validIndex(index)?&tabList[index]:0;
388 }
bool validIndex(int index) const
Definition: qtabbar_p.h:165
QList< Tab > tabList
Definition: qtabbar_p.h:153
quint16 index

◆ at() [2/2]

const QTabBarPrivate::Tab * QTabBarPrivate::at ( int  index) const

Definition at line 390 of file qtabbar.cpp.

391 {
392  return validIndex(index)?&tabList[index]:0;
393 }
bool validIndex(int index) const
Definition: qtabbar_p.h:165
QList< Tab > tabList
Definition: qtabbar_p.h:153
quint16 index

◆ calculateNewPosition()

int QTabBarPrivate::calculateNewPosition ( int  from,
int  to,
int  index 
) const

Definition at line 1654 of file qtabbar.cpp.

1655 {
1656  if (index == from)
1657  return to;
1658 
1659  int start = qMin(from, to);
1660  int end = qMax(from, to);
1661  if (index >= start && index <= end)
1662  index += (from < to) ? -1 : 1;
1663  return index;
1664 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
quint16 index
static const KeyPair *const end

◆ extraWidth()

int QTabBarPrivate::extraWidth ( ) const

Definition at line 354 of file qtabbar.cpp.

Referenced by _q_scrollTabs(), layoutTabs(), and makeVisible().

355 {
356  Q_Q(const QTabBar);
357  return 2 * qMax(q->style()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, 0, q),
359 }
static QSize globalStrut()
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define Q_Q(Class)
Definition: qglobal.h:2483
int width() const
Returns the width.
Definition: qsize.h:126

◆ indexAtPos()

int QTabBarPrivate::indexAtPos ( const QPoint p) const

Definition at line 395 of file qtabbar.cpp.

396 {
397  Q_Q(const QTabBar);
398  if (q->tabRect(currentIndex).contains(p))
399  return currentIndex;
400  for (int i = 0; i < tabList.count(); ++i)
401  if (tabList.at(i).enabled && q->tabRect(i).contains(p))
402  return i;
403  return -1;
404 }
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
#define Q_Q(Class)
Definition: qglobal.h:2483
QList< Tab > tabList
Definition: qtabbar_p.h:153
int currentIndex
Definition: qtabbar_p.h:86

◆ init()

void QTabBarPrivate::init ( )

Definition at line 361 of file qtabbar.cpp.

362 {
363  Q_Q(QTabBar);
364  leftB = new QToolButton(q);
365  leftB->setAutoRepeat(true);
366  QObject::connect(leftB, SIGNAL(clicked()), q, SLOT(_q_scrollTabs()));
367  leftB->hide();
368  rightB = new QToolButton(q);
369  rightB->setAutoRepeat(true);
370  QObject::connect(rightB, SIGNAL(clicked()), q, SLOT(_q_scrollTabs()));
371  rightB->hide();
372 #ifdef QT_KEYPAD_NAVIGATION
373  if (QApplication::keypadNavigationEnabled()) {
376  q->setFocusPolicy(Qt::NoFocus);
377  } else
378 #endif
379  q->setFocusPolicy(Qt::TabFocus);
380  q->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
381  elideMode = Qt::TextElideMode(q->style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, q));
382  useScrollButtons = !q->style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, q);
383 }
QToolButton * rightB
Definition: qtabbar_p.h:170
#define SLOT(a)
Definition: qobjectdefs.h:226
TextElideMode
Definition: qnamespace.h:263
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
QToolButton * leftB
Definition: qtabbar_p.h:171
#define Q_Q(Class)
Definition: qglobal.h:2483
void setAutoRepeat(bool)
bool useScrollButtons
Definition: qtabbar_p.h:190
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void hide()
Hides the widget.
Definition: qwidget.h:501
Qt::TextElideMode elideMode
Definition: qtabbar_p.h:188
void _q_scrollTabs()
Definition: qtabbar.cpp:678
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
void setFocusPolicy(Qt::FocusPolicy policy)
Definition: qwidget.cpp:7631

◆ initStyleBaseOption()

static void QTabBarPrivate::initStyleBaseOption ( QStyleOptionTabBarBaseV2 optTabBase,
QTabBar tabbar,
QSize  size 
)
inlinestatic

Definition at line 208 of file qtabbar_p.h.

Referenced by QTabWidget::paintEvent(), and QTabBar::paintEvent().

209  {
210  QStyleOptionTab tabOverlap;
211  tabOverlap.shape = tabbar->shape();
212  int overlap = tabbar->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap, tabbar);
213  QWidget *theParent = tabbar->parentWidget();
214  optTabBase->init(tabbar);
215  optTabBase->shape = tabbar->shape();
216  optTabBase->documentMode = tabbar->documentMode();
217  if (theParent && overlap > 0) {
218  QRect rect;
219  switch (tabOverlap.shape) {
222  rect.setRect(0, size.height()-overlap, size.width(), overlap);
223  break;
226  rect.setRect(0, 0, size.width(), overlap);
227  break;
230  rect.setRect(0, 0, overlap, size.height());
231  break;
234  rect.setRect(size.width() - overlap, 0, overlap, size.height());
235  break;
236  }
237  optTabBase->rect = rect;
238  }
239  }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void init(const QWidget *w)
Use initFrom(widget) instead.
QTabBar::Shape shape
the tab shape used to draw the tab; by default QTabBar::RoundedNorth
Definition: qstyleoption.h:316
QStyle * style() const
Definition: qwidget.cpp:2742
int width() const
Returns the width.
Definition: qsize.h:126
bool documentMode
whether the tabbar is in document mode.
Definition: qstyleoption.h:239
bool documentMode
Whether or not the tab bar is rendered in a mode suitable for the main window.
Definition: qtabbar.h:75
Shape shape
the shape of the tabs in the tab bar
Definition: qtabbar.h:64
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QTabBar::Shape shape
the shape of the tab bar
Definition: qstyleoption.h:224
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ layoutTab()

void QTabBarPrivate::layoutTab ( int  index)

Definition at line 611 of file qtabbar.cpp.

Referenced by layoutWidgets().

612 {
613  Q_Q(QTabBar);
614  Q_ASSERT(index >= 0);
615 
616  Tab &tab = tabList[index];
617  bool vertical = verticalTabs(shape);
618  if (!(tab.leftWidget || tab.rightWidget))
619  return;
620 
621  QStyleOptionTabV3 opt;
622  q->initStyleOption(&opt, index);
623  if (tab.leftWidget) {
624  QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, q);
625  QPoint p = rect.topLeft();
626  if ((index == pressedIndex) || paintWithOffsets) {
627  if (vertical)
628  p.setY(p.y() + tabList[index].dragOffset);
629  else
630  p.setX(p.x() + tabList[index].dragOffset);
631  }
632  tab.leftWidget->move(p);
633  }
634  if (tab.rightWidget) {
635  QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabRightButton, &opt, q);
636  QPoint p = rect.topLeft();
637  if ((index == pressedIndex) || paintWithOffsets) {
638  if (vertical)
639  p.setY(p.y() + tab.dragOffset);
640  else
641  p.setX(p.x() + tab.dragOffset);
642  }
643  tab.rightWidget->move(p);
644  }
645 }
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
QTabBar::Shape shape
Definition: qtabbar_p.h:88
bool paintWithOffsets
Definition: qtabbar_p.h:198
QList< Tab > tabList
Definition: qtabbar_p.h:153
int pressedIndex
Definition: qtabbar_p.h:87
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
Definition: qpoint.h:137
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QStyleOptionTabV3 class is used to describe the parameters necessary for drawing a tabs in Qt 4...
Definition: qstyleoption.h:347
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
quint16 index
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
Definition: qpoint.h:134
static bool verticalTabs(QTabBar::Shape shape)
Definition: qtabbar.cpp:77
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ layoutTabs()

void QTabBarPrivate::layoutTabs ( )

Definition at line 406 of file qtabbar.cpp.

Referenced by refresh().

407 {
408  Q_Q(QTabBar);
409  scrollOffset = 0;
410  layoutDirty = false;
411  QSize size = q->size();
412  int last, available;
413  int maxExtent;
414  int i;
415  bool vertTabs = verticalTabs(shape);
416  int tabChainIndex = 0;
417 
418  Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, 0, q));
419  QVector<QLayoutStruct> tabChain(tabList.count() + 2);
420 
421  // We put an empty item at the front and back and set its expansive attribute
422  // depending on tabAlignment.
423  tabChain[tabChainIndex].init();
424  tabChain[tabChainIndex].expansive = (tabAlignment != Qt::AlignLeft)
425  && (tabAlignment != Qt::AlignJustify);
426  tabChain[tabChainIndex].empty = true;
427  ++tabChainIndex;
428 
429  // We now go through our list of tabs and set the minimum size and the size hint
430  // This will allow us to elide text if necessary. Since we don't set
431  // a maximum size, tabs will EXPAND to fill up the empty space.
432  // Since tab widget is rather *ahem* strict about keeping the geometry of the
433  // tab bar to its absolute minimum, this won't bleed through, but will show up
434  // if you use tab bar on its own (a.k.a. not a bug, but a feature).
435  // Update: if expanding is false, we DO set a maximum size to prevent the tabs
436  // being wider than necessary.
437  if (!vertTabs) {
438  int minx = 0;
439  int x = 0;
440  int maxHeight = 0;
441  for (i = 0; i < tabList.count(); ++i, ++tabChainIndex) {
442  QSize sz = q->tabSizeHint(i);
443  tabList[i].maxRect = QRect(x, 0, sz.width(), sz.height());
444  x += sz.width();
445  maxHeight = qMax(maxHeight, sz.height());
446  sz = minimumTabSizeHint(i);
447  tabList[i].minRect = QRect(minx, 0, sz.width(), sz.height());
448  minx += sz.width();
449  tabChain[tabChainIndex].init();
450  tabChain[tabChainIndex].sizeHint = tabList.at(i).maxRect.width();
451  tabChain[tabChainIndex].minimumSize = sz.width();
452  tabChain[tabChainIndex].empty = false;
453  tabChain[tabChainIndex].expansive = true;
454 
455  if (!expanding)
456  tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
457  }
458 
459  last = minx;
460  available = size.width();
461  maxExtent = maxHeight;
462  } else {
463  int miny = 0;
464  int y = 0;
465  int maxWidth = 0;
466  for (i = 0; i < tabList.count(); ++i, ++tabChainIndex) {
467  QSize sz = q->tabSizeHint(i);
468  tabList[i].maxRect = QRect(0, y, sz.width(), sz.height());
469  y += sz.height();
470  maxWidth = qMax(maxWidth, sz.width());
471  sz = minimumTabSizeHint(i);
472  tabList[i].minRect = QRect(0, miny, sz.width(), sz.height());
473  miny += sz.height();
474  tabChain[tabChainIndex].init();
475  tabChain[tabChainIndex].sizeHint = tabList.at(i).maxRect.height();
476  tabChain[tabChainIndex].minimumSize = sz.height();
477  tabChain[tabChainIndex].empty = false;
478  tabChain[tabChainIndex].expansive = true;
479 
480  if (!expanding)
481  tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
482  }
483 
484  last = miny;
485  available = size.height();
486  maxExtent = maxWidth;
487  }
488 
489  Q_ASSERT(tabChainIndex == tabChain.count() - 1); // add an assert just to make sure.
490  // Mirror our front item.
491  tabChain[tabChainIndex].init();
492  tabChain[tabChainIndex].expansive = (tabAlignment != Qt::AlignRight)
493  && (tabAlignment != Qt::AlignJustify);
494  tabChain[tabChainIndex].empty = true;
495 
496  // Do the calculation
497  qGeomCalc(tabChain, 0, tabChain.count(), 0, qMax(available, last), 0);
498 
499  // Use the results
500  for (i = 0; i < tabList.count(); ++i) {
501  const QLayoutStruct &lstruct = tabChain.at(i + 1);
502  if (!vertTabs)
503  tabList[i].rect.setRect(lstruct.pos, 0, lstruct.size, maxExtent);
504  else
505  tabList[i].rect.setRect(0, lstruct.pos, maxExtent, lstruct.size);
506  }
507 
508  if (useScrollButtons && tabList.count() && last > available) {
509  int extra = extraWidth();
510 #ifndef QT_NO_STYLE_S60
511  QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style());
512 #endif
513  if (!vertTabs) {
514  Qt::LayoutDirection ld = q->layoutDirection();
515  QRect arrows = QStyle::visualRect(ld, q->rect(),
516  QRect(available - extra, 0, extra, size.height()));
517  int buttonOverlap = q->style()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, 0, q);
518 
519  if (ld == Qt::LeftToRight) {
520 // In S60style, tab scroll buttons are layoutted separately, on the sides of the tabbar.
521 #ifndef QT_NO_STYLE_S60
522  if (s60Style) {
523  rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height());
524  leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height());
525  } else {
526 #endif
527  leftB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height());
528  rightB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(),
529  extra/2, arrows.height());
530 #ifndef QT_NO_STYLE_S60
531  }
532 #endif
535  } else {
536 #ifndef QT_NO_STYLE_S60
537  if (s60Style) {
538  rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height());
539  leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height());
540  } else {
541 #endif
542  rightB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height());
543  leftB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(),
544  extra/2, arrows.height());
545 #ifndef QT_NO_STYLE_S60
546  }
547 #endif
550  }
551  } else {
552 #ifndef QT_NO_STYLE_S60
553  if (s60Style) {
554  QRect arrows = QRect(0, 0, size.width(), available );
555  leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra / 2);
557  rightB->setGeometry(arrows.left(), arrows.bottom() - extra / 2 + 1,
558  arrows.width(), extra / 2);
560  } else {
561 #endif
562  QRect arrows = QRect(0, available - extra, size.width(), extra );
563  leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra/2);
565  rightB->setGeometry(arrows.left(), arrows.bottom() - extra/2 + 1,
566  arrows.width(), extra/2);
568 #ifndef QT_NO_STYLE_S60
569  }
570 #endif
571  }
573  rightB->setEnabled(last - scrollOffset >= available - extra);
574  leftB->show();
575  rightB->show();
576  } else {
577  rightB->hide();
578  leftB->hide();
579  }
580 
581  layoutWidgets();
582  q->tabLayoutChange();
583 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QToolButton * rightB
Definition: qtabbar_p.h:170
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
static QStyle * style()
Returns the application&#39;s style object.
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool empty() const
This function is provided for STL compatibility.
Definition: qvector.h:285
int extraWidth() const
Definition: qtabbar.cpp:354
QToolButton * leftB
Definition: qtabbar_p.h:171
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define Q_Q(Class)
Definition: qglobal.h:2483
bool useScrollButtons
Definition: qtabbar_p.h:190
bool layoutDirty
Definition: qtabbar_p.h:89
QTabBar::Shape shape
Definition: qtabbar_p.h:88
int width() const
Returns the width.
Definition: qsize.h:126
LayoutDirection
Definition: qnamespace.h:1580
QList< Tab > tabList
Definition: qtabbar_p.h:153
QSize minimumTabSizeHint(int index)
Definition: qtabbar.cpp:1373
void show()
Shows the widget and its child widgets.
void setEnabled(bool)
Definition: qwidget.cpp:3447
void hide()
Hides the widget.
Definition: qwidget.h:501
void setArrowType(Qt::ArrowType type)
void qGeomCalc(QVector< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void layoutWidgets(int start=0)
Definition: qtabbar.cpp:647
QWExtra * extra
Definition: qwidget_p.h:700
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int scrollOffset
Definition: qtabbar_p.h:91
static bool verticalTabs(QTabBar::Shape shape)
Definition: qtabbar.cpp:77

◆ layoutWidgets()

void QTabBarPrivate::layoutWidgets ( int  start = 0)

Definition at line 647 of file qtabbar.cpp.

Referenced by layoutTabs(), and makeVisible().

648 {
649  Q_Q(QTabBar);
650  for (int i = start; i < q->count(); ++i) {
651  layoutTab(i);
652  }
653 }
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
#define Q_Q(Class)
Definition: qglobal.h:2483
void layoutTab(int index)
Definition: qtabbar.cpp:611

◆ makeVisible()

void QTabBarPrivate::makeVisible ( int  index)

Definition at line 585 of file qtabbar.cpp.

Referenced by _q_scrollTabs(), and refresh().

586 {
587  Q_Q(QTabBar);
588  if (!validIndex(index) || leftB->isHidden())
589  return;
590 
591  const QRect tabRect = tabList.at(index).rect;
592  const int oldScrollOffset = scrollOffset;
593  const bool horiz = !verticalTabs(shape);
594  const int available = (horiz ? q->width() : q->height()) - extraWidth();
595  const int start = horiz ? tabRect.left() : tabRect.top();
596  const int end = horiz ? tabRect.right() : tabRect.bottom();
597  if (start < scrollOffset) // too far left
598  scrollOffset = start - (index ? 8 : 0);
599  else if (end > scrollOffset + available) // too far right
600  scrollOffset = end - available + 1;
601 
603  const int last = horiz ? tabList.last().rect.right() : tabList.last().rect.bottom();
604  rightB->setEnabled(last - scrollOffset >= available);
605  if (oldScrollOffset != scrollOffset) {
606  q->update();
607  layoutWidgets();
608  }
609 }
bool validIndex(int index) const
Definition: qtabbar_p.h:165
QToolButton * rightB
Definition: qtabbar_p.h:170
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
int extraWidth() const
Definition: qtabbar.cpp:354
QToolButton * leftB
Definition: qtabbar_p.h:171
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
QTabBar::Shape shape
Definition: qtabbar_p.h:88
QList< Tab > tabList
Definition: qtabbar_p.h:153
void setEnabled(bool)
Definition: qwidget.cpp:3447
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void layoutWidgets(int start=0)
Definition: qtabbar.cpp:647
quint16 index
static const KeyPair *const end
int scrollOffset
Definition: qtabbar_p.h:91
static bool verticalTabs(QTabBar::Shape shape)
Definition: qtabbar.cpp:77

◆ minimumTabSizeHint()

QSize QTabBarPrivate::minimumTabSizeHint ( int  index)

Definition at line 1373 of file qtabbar.cpp.

Referenced by layoutTabs(), and validIndex().

1374 {
1375  Q_Q(QTabBar);
1376  // ### Qt 5: make this a protected virtual function in QTabBar
1377  Tab &tab = tabList[index];
1378  QString oldText = tab.text;
1379  tab.text = computeElidedText(elideMode, oldText);
1380  QSize size = q->tabSizeHint(index);
1381  tab.text = oldText;
1382  return size;
1383 }
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_Q(Class)
Definition: qglobal.h:2483
QList< Tab > tabList
Definition: qtabbar_p.h:153
static QString computeElidedText(Qt::TextElideMode mode, const QString &text)
Definition: qtabbar.cpp:1349
Qt::TextElideMode elideMode
Definition: qtabbar_p.h:188
quint16 index
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ moveTab()

void QTabBarPrivate::moveTab ( int  index,
int  offset 
)

em>Reimplemented Function

Definition at line 1768 of file qtabbar.cpp.

Referenced by QTabBarPrivate::Tab::TabBarAnimation::updateCurrentValue().

◆ moveTabFinished()

void QTabBarPrivate::moveTabFinished ( int  index)

em>Reimplemented Function

Definition at line 1936 of file qtabbar.cpp.

Referenced by refresh(), QTabBarPrivate::Tab::startAnimation(), and QTabBarPrivate::Tab::TabBarAnimation::updateState().

◆ refresh()

void QTabBarPrivate::refresh ( )

Definition at line 720 of file qtabbar.cpp.

721 {
722  Q_Q(QTabBar);
723 
724  // be safe in case a subclass is also handling move with the tabs
725  if (pressedIndex != -1
726  && movable
729  if (!validIndex(pressedIndex))
730  pressedIndex = -1;
731  }
732 
733  if (!q->isVisible()) {
734  layoutDirty = true;
735  } else {
736  layoutTabs();
738  q->update();
739  q->updateGeometry();
740  }
741 }
bool validIndex(int index) const
Definition: qtabbar_p.h:165
void moveTabFinished(int index)
em>Reimplemented Function
Definition: qtabbar.cpp:1936
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
#define Q_Q(Class)
Definition: qglobal.h:2483
bool layoutDirty
Definition: qtabbar_p.h:89
void layoutTabs()
Definition: qtabbar.cpp:406
int pressedIndex
Definition: qtabbar_p.h:87
int currentIndex
Definition: qtabbar_p.h:86
static Qt::MouseButtons mouseButtons()
Returns the current state of the buttons on the mouse.
void makeVisible(int index)
Definition: qtabbar.cpp:585

◆ setCurrentNextEnabledIndex()

void QTabBarPrivate::setCurrentNextEnabledIndex ( int  offset)

em>Reimplemented Function

Definition at line 2027 of file qtabbar.cpp.

Referenced by validIndex().

◆ setupMovableTab()

void QTabBarPrivate::setupMovableTab ( )

Definition at line 1896 of file qtabbar.cpp.

1897 {
1898  Q_Q(QTabBar);
1899  if (!movingTab)
1900  movingTab = new QWidget(q);
1901 
1902  int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q);
1903  QRect grabRect = q->tabRect(pressedIndex);
1904  grabRect.adjust(-taboverlap, 0, taboverlap, 0);
1905 
1906  QPixmap grabImage(grabRect.size());
1907  grabImage.fill(Qt::transparent);
1908  QStylePainter p(&grabImage, q);
1909  p.initFrom(q);
1910 
1911  QStyleOptionTabV3 tab;
1912  q->initStyleOption(&tab, pressedIndex);
1913  tab.rect.moveTopLeft(QPoint(taboverlap, 0));
1914  p.drawControl(QStyle::CE_TabBarTab, tab);
1915  p.end();
1916 
1917  QPalette pal;
1918  pal.setBrush(QPalette::All, QPalette::Window, grabImage);
1919  movingTab->setPalette(pal);
1920  movingTab->setGeometry(grabRect);
1922  movingTab->raise();
1923 
1924  // Re-arrange widget order to avoid overlaps
1925  if (tabList[pressedIndex].leftWidget)
1926  tabList[pressedIndex].leftWidget->raise();
1927  if (tabList[pressedIndex].rightWidget)
1928  tabList[pressedIndex].rightWidget->raise();
1929  if (leftB)
1930  leftB->raise();
1931  if (rightB)
1932  rightB->raise();
1933  movingTab->setVisible(true);
1934 }
QToolButton * rightB
Definition: qtabbar_p.h:170
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
QWidget * movingTab
Definition: qtabbar_p.h:203
QToolButton * leftB
Definition: qtabbar_p.h:171
#define Q_Q(Class)
Definition: qglobal.h:2483
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
QList< Tab > tabList
Definition: qtabbar_p.h:153
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
Definition: qrect.h:368
void setAutoFillBackground(bool enabled)
Definition: qwidget.cpp:631
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
int pressedIndex
Definition: qtabbar_p.h:87
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QStyleOptionTabV3 class is used to describe the parameters necessary for drawing a tabs in Qt 4...
Definition: qstyleoption.h:347
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget...
Definition: qstylepainter.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
void setPalette(const QPalette &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4858
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ slide()

void QTabBarPrivate::slide ( int  from,
int  to 
)

Definition at line 1750 of file qtabbar.cpp.

1751 {
1752  Q_Q(QTabBar);
1753  if (from == to
1754  || !validIndex(from)
1755  || !validIndex(to))
1756  return;
1757  bool vertical = verticalTabs(shape);
1758  int preLocation = vertical ? q->tabRect(from).y() : q->tabRect(from).x();
1759  q->setUpdatesEnabled(false);
1760  q->moveTab(from, to);
1761  q->setUpdatesEnabled(true);
1762  int postLocation = vertical ? q->tabRect(to).y() : q->tabRect(to).x();
1763  int length = postLocation - preLocation;
1764  tabList[to].dragOffset -= length;
1765  tabList[to].startAnimation(this, ANIMATION_DURATION);
1766 }
bool validIndex(int index) const
Definition: qtabbar_p.h:165
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
#define Q_Q(Class)
Definition: qglobal.h:2483
QTabBar::Shape shape
Definition: qtabbar_p.h:88
#define ANIMATION_DURATION
Definition: qtabbar_p.h:66
QList< Tab > tabList
Definition: qtabbar_p.h:153
static bool verticalTabs(QTabBar::Shape shape)
Definition: qtabbar.cpp:77

◆ updateMacBorderMetrics()

void QTabBarPrivate::updateMacBorderMetrics ( )

Definition at line 85 of file qtabbar.cpp.

86 {
87 #if (defined Q_WS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
89  Q_Q(QTabBar);
90  ::HIContentBorderMetrics metrics;
91 
92  // TODO: get metrics to preserve the bottom value
93  // TODO: test tab bar position
94 
96 
97  // push base line separator down to the client are so we can paint over it (Carbon)
98  metrics.top = (documentMode && q->isVisible()) ? 1 : 0;
99  metrics.bottom = 0;
100  metrics.left = 0;
101  metrics.right = 0;
102  qt_mac_updateContentBorderMetricts(window, metrics);
103 #if QT_MAC_USE_COCOA
104  // In Cocoa we need to keep track of the drawRect method.
105  // If documentMode is enabled we need to change it, unless
106  // a toolbar is present.
107  // Notice that all the information is kept in the window,
108  // that's why we get the private widget for it instead of
109  // the private widget for this widget.
110  QWidgetPrivate *privateWidget = qt_widget_private(q->window());
111  if(privateWidget)
112  privateWidget->changeMethods = documentMode;
113  // Since in Cocoa there is no simple way to remove the baseline, so we just ask the
114  // top level to do the magic for us.
115  privateWidget->syncUnifiedMode();
116 #endif // QT_MAC_USE_COCOA
117  }
118 #endif
119 }
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
OSWindowRef qt_mac_window_for(const QWidget *)
Definition: qwidget_mac.mm:484
#define Q_Q(Class)
Definition: qglobal.h:2483
NSWindow * window
WindowRef OSWindowRef
bool documentMode
Definition: qtabbar_p.h:201
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
void qt_mac_updateContentBorderMetricts(void *window, const ::HIContentBorderMetrics &metrics)

◆ validIndex()

bool QTabBarPrivate::validIndex ( int  index) const
inline

Definition at line 165 of file qtabbar_p.h.

Referenced by at(), makeVisible(), and refresh().

165 { return index >= 0 && index < tabList.count(); }
QList< Tab > tabList
Definition: qtabbar_p.h:153
quint16 index

Properties

◆ closeButtonOnTabs

bool QTabBarPrivate::closeButtonOnTabs

Definition at line 194 of file qtabbar_p.h.

◆ currentIndex

int QTabBarPrivate::currentIndex

Definition at line 86 of file qtabbar_p.h.

Referenced by indexAtPos(), and refresh().

◆ documentMode

bool QTabBarPrivate::documentMode

Definition at line 201 of file qtabbar_p.h.

Referenced by updateMacBorderMetrics().

◆ dragInProgress

bool QTabBarPrivate::dragInProgress

Definition at line 200 of file qtabbar_p.h.

◆ dragStartPosition

QPoint QTabBarPrivate::dragStartPosition

Definition at line 197 of file qtabbar_p.h.

◆ drawBase

bool QTabBarPrivate::drawBase

Definition at line 90 of file qtabbar_p.h.

◆ elideMode

Qt::TextElideMode QTabBarPrivate::elideMode

Definition at line 188 of file qtabbar_p.h.

Referenced by init().

◆ elideModeSetByUser

bool QTabBarPrivate::elideModeSetByUser

Definition at line 189 of file qtabbar_p.h.

◆ expanding

bool QTabBarPrivate::expanding

Definition at line 193 of file qtabbar_p.h.

Referenced by layoutTabs().

◆ hoverRect

QRect QTabBarPrivate::hoverRect

Definition at line 177 of file qtabbar_p.h.

◆ iconSize

QSize QTabBarPrivate::iconSize

Definition at line 187 of file qtabbar_p.h.

Referenced by QTabBar::initStyleOption().

◆ layoutDirty

bool QTabBarPrivate::layoutDirty

Definition at line 89 of file qtabbar_p.h.

Referenced by layoutTabs(), and refresh().

◆ leftB

QToolButton* QTabBarPrivate::leftB

Definition at line 171 of file qtabbar_p.h.

Referenced by _q_scrollTabs(), QAccessibleTabBar::button(), init(), layoutTabs(), and makeVisible().

◆ movable

bool QTabBarPrivate::movable

Definition at line 199 of file qtabbar_p.h.

Referenced by refresh().

◆ movingTab

QWidget* QTabBarPrivate::movingTab

Definition at line 203 of file qtabbar_p.h.

◆ paintWithOffsets

bool QTabBarPrivate::paintWithOffsets

Definition at line 198 of file qtabbar_p.h.

Referenced by layoutTab().

◆ pressedIndex

int QTabBarPrivate::pressedIndex

Definition at line 87 of file qtabbar_p.h.

Referenced by layoutTab(), and refresh().

◆ previousPressedIndex

int QTabBarPrivate::previousPressedIndex

Definition at line 205 of file qtabbar_p.h.

◆ rightB

QToolButton* QTabBarPrivate::rightB

Definition at line 170 of file qtabbar_p.h.

Referenced by _q_scrollTabs(), QAccessibleTabBar::button(), init(), layoutTabs(), and makeVisible().

◆ scrollOffset

int QTabBarPrivate::scrollOffset

Definition at line 91 of file qtabbar_p.h.

Referenced by _q_scrollTabs(), layoutTabs(), and makeVisible().

◆ selectionBehaviorOnRemove

QTabBar::SelectionBehavior QTabBarPrivate::selectionBehaviorOnRemove

Definition at line 195 of file qtabbar_p.h.

◆ shape

QTabBar::Shape QTabBarPrivate::shape

Definition at line 88 of file qtabbar_p.h.

Referenced by _q_scrollTabs(), layoutTab(), layoutTabs(), and makeVisible().

◆ tabList

QList<Tab> QTabBarPrivate::tabList

◆ useScrollButtons

bool QTabBarPrivate::useScrollButtons

Definition at line 190 of file qtabbar_p.h.

Referenced by init(), and layoutTabs().

◆ useScrollButtonsSetByUser

bool QTabBarPrivate::useScrollButtonsSetByUser

Definition at line 191 of file qtabbar_p.h.


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