diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2016-05-20 10:47:37 -0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2016-08-10 01:04:53 +0000 |
commit | 89d7c904e5f7c0cd230e59a4cd8b2ee2a1cbcac1 (patch) | |
tree | 23502eb4756399416d669b2d82b78cec29919eb9 /src/widgets/widgets/qtabbar_p.h | |
parent | 8ebe8ae35ee7556de0749bc27737ced7c61f5153 (diff) |
QTabBar: Cache title text sizes
The first part adds QTabBarPrivate::initBasicStyleOption()
which is basically QTabBar::initStyleOption() but
without the expensive QFontMetrics::elidedText() call.
That is because QTabBar::tabSizeHint() would call
initStyleOption() and then immediately discard the result
of that computation.
Then, QTabBar::tabSizeHint() is modified to cache the calls
to QFontMetrics::size(), which is also expensive. The cache
is invalidated when the style or the font changes, or when
the elide mode is set.
Change-Id: I591b2e401af3576a2ebabc5b94f19ae157e28cf2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Wayne Arnold <wayne.arnold@autodesk.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/widgets/widgets/qtabbar_p.h')
-rw-r--r-- | src/widgets/widgets/qtabbar_p.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index e58fde160c..d34f45071d 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -159,6 +159,7 @@ public: #endif //QT_NO_ANIMATION }; QList<Tab> tabList; + mutable QHash<QString, QSize> textSizes; int calculateNewPosition(int from, int to, int index) const; void slide(int from, int to); @@ -192,6 +193,8 @@ public: void setupMovableTab(); void autoHideTabs(); + void initBasicStyleOption(QStyleOptionTab *option, int tabIndex) const; + void makeVisible(int index); QSize iconSize; Qt::TextElideMode elideMode; |