mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 10:22:55 +00:00
get rid of QWidgetItemV2
round 2, see 6d3fe9312c
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
a343e9db24
commit
0c143f2e1d
14 changed files with 35 additions and 237 deletions
|
@ -742,7 +742,6 @@ katie_generate_obsolete(QWhatsThisClickedEvent QtGui qevent.h)
|
|||
katie_generate_obsolete(QWheelEvent QtGui qevent.h)
|
||||
katie_generate_obsolete(QWidgetData QtGui qwidget.h)
|
||||
katie_generate_obsolete(QWidgetItem QtGui qlayoutitem.h)
|
||||
katie_generate_obsolete(QWidgetItemV2 QtGui qlayoutitem.h)
|
||||
katie_generate_obsolete(QWidgetList QtGui qwindowdefs.h)
|
||||
katie_generate_obsolete(QWidgetMapper QtGui qwindowdefs.h)
|
||||
katie_generate_obsolete(QWidgetSet QtGui qwindowdefs.h)
|
||||
|
|
|
@ -680,7 +680,6 @@ include/katie/QtGui/QWidget
|
|||
include/katie/QtGui/QWidgetAction
|
||||
include/katie/QtGui/QWidgetData
|
||||
include/katie/QtGui/QWidgetItem
|
||||
include/katie/QtGui/QWidgetItemV2
|
||||
include/katie/QtGui/QWidgetList
|
||||
include/katie/QtGui/QWidgetMapper
|
||||
include/katie/QtGui/QWidgetSet
|
||||
|
|
|
@ -260,7 +260,6 @@ incmap = {
|
|||
'QWheelEvent': 'qevent.h',
|
||||
'QWidgetData': 'qwidget.h',
|
||||
'QWidgetItem': 'qlayoutitem.h',
|
||||
'QWidgetItemV2': 'qlayoutitem.h',
|
||||
'QWidgetList': 'qwindowdefs.h',
|
||||
'QWidgetMapper': 'qwindowdefs.h',
|
||||
'QWidgetSet': 'qwindowdefs.h',
|
||||
|
|
|
@ -607,7 +607,6 @@ classlist = [
|
|||
"QWidgetAction",
|
||||
"QWidgetData",
|
||||
"QWidgetItem",
|
||||
"QWidgetItemV2",
|
||||
"QWidgetList",
|
||||
"QWidgetMapper",
|
||||
"QWidgetSet",
|
||||
|
|
|
@ -164,7 +164,7 @@ QWidgetItem *QLayoutPrivate::createWidgetItem(const QLayout *layout, QWidget *wi
|
|||
if (widgetItemFactoryMethod)
|
||||
if (QWidgetItem *wi = (*widgetItemFactoryMethod)(layout, widget))
|
||||
return wi;
|
||||
return new QWidgetItemV2(widget);
|
||||
return new QWidgetItem(widget);
|
||||
}
|
||||
|
||||
QSpacerItem *QLayoutPrivate::createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy)
|
||||
|
|
|
@ -280,26 +280,26 @@ void QLayoutItem::invalidate()
|
|||
|
||||
/*!
|
||||
If this item is a QLayout, it is returned as a QLayout; otherwise
|
||||
0 is returned. This function provides type-safe casting.
|
||||
null is returned. This function provides type-safe casting.
|
||||
*/
|
||||
QLayout * QLayoutItem::layout()
|
||||
QLayout* QLayoutItem::layout()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
If this item is a QSpacerItem, it is returned as a QSpacerItem;
|
||||
otherwise 0 is returned. This function provides type-safe casting.
|
||||
otherwise null is returned. This function provides type-safe casting.
|
||||
*/
|
||||
QSpacerItem * QLayoutItem::spacerItem()
|
||||
QSpacerItem* QLayoutItem::spacerItem()
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QLayout * QLayout::layout()
|
||||
QLayout* QLayout::layout()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
@ -316,15 +316,15 @@ QSpacerItem * QSpacerItem::spacerItem()
|
|||
If this item is a QWidget, it is returned as a QWidget; otherwise
|
||||
0 is returned. This function provides type-safe casting.
|
||||
*/
|
||||
QWidget * QLayoutItem::widget()
|
||||
QWidget* QLayoutItem::widget()
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the widget managed by this item.
|
||||
*/
|
||||
QWidget *QWidgetItem::widget()
|
||||
QWidget* QWidgetItem::widget()
|
||||
{
|
||||
return wid;
|
||||
}
|
||||
|
@ -354,7 +354,6 @@ int QLayoutItem::minimumHeightForWidth(int w) const
|
|||
return heightForWidth(w);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Returns the preferred height for this layout item, given the width
|
||||
\a w.
|
||||
|
@ -572,8 +571,9 @@ QSize QSpacerItem::minimumSize() const
|
|||
*/
|
||||
QSize QWidgetItem::minimumSize() const
|
||||
{
|
||||
if (isEmpty())
|
||||
if (isEmpty()) {
|
||||
return QSize(0, 0);
|
||||
}
|
||||
return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)
|
||||
? toLayoutItemSize(wid->d_func(), qSmartMinSize(this))
|
||||
: qSmartMinSize(this);
|
||||
|
@ -595,11 +595,10 @@ QSize QWidgetItem::maximumSize() const
|
|||
{
|
||||
if (isEmpty()) {
|
||||
return QSize(0, 0);
|
||||
} else {
|
||||
return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)
|
||||
? toLayoutItemSize(wid->d_func(), qSmartMaxSize(this, align))
|
||||
: qSmartMaxSize(this, align);
|
||||
}
|
||||
return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)
|
||||
? toLayoutItemSize(wid->d_func(), qSmartMaxSize(this, align))
|
||||
: qSmartMaxSize(this, align);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -615,19 +614,21 @@ QSize QSpacerItem::sizeHint() const
|
|||
*/
|
||||
QSize QWidgetItem::sizeHint() const
|
||||
{
|
||||
QSize s(0, 0);
|
||||
if (!isEmpty()) {
|
||||
s = wid->sizeHint().expandedTo(wid->minimumSizeHint());
|
||||
s = s.boundedTo(wid->maximumSize())
|
||||
.expandedTo(wid->minimumSize());
|
||||
s = !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)
|
||||
? toLayoutItemSize(wid->d_func(), s)
|
||||
: s;
|
||||
if (isEmpty()) {
|
||||
return QSize(0, 0);
|
||||
}
|
||||
QSize s = wid->sizeHint().expandedTo(wid->minimumSizeHint());
|
||||
s = s.boundedTo(wid->maximumSize())
|
||||
.expandedTo(wid->minimumSize());
|
||||
s = !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)
|
||||
? toLayoutItemSize(wid->d_func(), s)
|
||||
: s;
|
||||
|
||||
if (wid->sizePolicy().horizontalPolicy() == QSizePolicy::Ignored)
|
||||
s.setWidth(0);
|
||||
if (wid->sizePolicy().verticalPolicy() == QSizePolicy::Ignored)
|
||||
s.setHeight(0);
|
||||
if (wid->sizePolicy().horizontalPolicy() == QSizePolicy::Ignored) {
|
||||
s.setWidth(0);
|
||||
}
|
||||
if (wid->sizePolicy().verticalPolicy() == QSizePolicy::Ignored) {
|
||||
s.setHeight(0);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
@ -655,157 +656,4 @@ QSizePolicy::ControlTypes QWidgetItem::controlTypes() const
|
|||
return wid->sizePolicy().controlType();
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QWidgetItemV2
|
||||
\internal
|
||||
*/
|
||||
|
||||
inline bool QWidgetItemV2::useSizeCache() const
|
||||
{
|
||||
return wid->d_func()->widgetItem == this;
|
||||
}
|
||||
|
||||
void QWidgetItemV2::updateCacheIfNecessary() const
|
||||
{
|
||||
if (q_cachedMinimumSize.width() != Dirty)
|
||||
return;
|
||||
|
||||
const QSize sizeHint(wid->sizeHint());
|
||||
const QSize minimumSizeHint(wid->minimumSizeHint());
|
||||
const QSize minimumSize(wid->minimumSize());
|
||||
const QSize maximumSize(wid->maximumSize());
|
||||
const QSizePolicy sizePolicy(wid->sizePolicy());
|
||||
const QSize expandedSizeHint(sizeHint.expandedTo(minimumSizeHint));
|
||||
|
||||
const QSize smartMinSize(qSmartMinSize(sizeHint, minimumSizeHint, minimumSize, maximumSize, sizePolicy));
|
||||
const QSize smartMaxSize(qSmartMaxSize(expandedSizeHint, minimumSize, maximumSize, sizePolicy, align));
|
||||
|
||||
const bool useLayoutItemRect = !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
|
||||
q_cachedMinimumSize = useLayoutItemRect
|
||||
? toLayoutItemSize(wid->d_func(), smartMinSize)
|
||||
: smartMinSize;
|
||||
|
||||
q_cachedSizeHint = expandedSizeHint;
|
||||
q_cachedSizeHint = q_cachedSizeHint.boundedTo(maximumSize)
|
||||
.expandedTo(minimumSize);
|
||||
q_cachedSizeHint = useLayoutItemRect
|
||||
? toLayoutItemSize(wid->d_func(), q_cachedSizeHint)
|
||||
: q_cachedSizeHint;
|
||||
|
||||
if (wid->sizePolicy().horizontalPolicy() == QSizePolicy::Ignored)
|
||||
q_cachedSizeHint.setWidth(0);
|
||||
if (wid->sizePolicy().verticalPolicy() == QSizePolicy::Ignored)
|
||||
q_cachedSizeHint.setHeight(0);
|
||||
|
||||
q_cachedMaximumSize = useLayoutItemRect
|
||||
? toLayoutItemSize(wid->d_func(), smartMaxSize)
|
||||
: smartMaxSize;
|
||||
}
|
||||
|
||||
QWidgetItemV2::QWidgetItemV2(QWidget *widget)
|
||||
: QWidgetItem(widget),
|
||||
q_cachedMinimumSize(Dirty, Dirty),
|
||||
q_cachedSizeHint(Dirty, Dirty),
|
||||
q_cachedMaximumSize(Dirty, Dirty),
|
||||
q_firstCachedHfw(0),
|
||||
q_hfwCacheSize(0),
|
||||
d(0)
|
||||
{
|
||||
QWidgetPrivate *wd = wid->d_func();
|
||||
if (!wd->widgetItem)
|
||||
wd->widgetItem = this;
|
||||
}
|
||||
|
||||
QWidgetItemV2::~QWidgetItemV2()
|
||||
{
|
||||
if (wid) {
|
||||
QWidgetPrivate *wd = wid->d_func();
|
||||
if (wd->widgetItem == this)
|
||||
wd->widgetItem = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QSize QWidgetItemV2::sizeHint() const
|
||||
{
|
||||
if (isEmpty())
|
||||
return QSize(0, 0);
|
||||
|
||||
if (useSizeCache()) {
|
||||
updateCacheIfNecessary();
|
||||
return q_cachedSizeHint;
|
||||
} else {
|
||||
return QWidgetItem::sizeHint();
|
||||
}
|
||||
}
|
||||
|
||||
QSize QWidgetItemV2::minimumSize() const
|
||||
{
|
||||
if (isEmpty())
|
||||
return QSize(0, 0);
|
||||
|
||||
if (useSizeCache()) {
|
||||
updateCacheIfNecessary();
|
||||
return q_cachedMinimumSize;
|
||||
} else {
|
||||
return QWidgetItem::minimumSize();
|
||||
}
|
||||
}
|
||||
|
||||
QSize QWidgetItemV2::maximumSize() const
|
||||
{
|
||||
if (isEmpty())
|
||||
return QSize(0, 0);
|
||||
|
||||
if (useSizeCache()) {
|
||||
updateCacheIfNecessary();
|
||||
return q_cachedMaximumSize;
|
||||
} else {
|
||||
return QWidgetItem::maximumSize();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
The height-for-width cache is organized as a circular buffer. The entries
|
||||
|
||||
q_hfwCachedHfws[q_firstCachedHfw],
|
||||
...,
|
||||
q_hfwCachedHfws[(q_firstCachedHfw + q_hfwCacheSize - 1) % HfwCacheMaxSize]
|
||||
|
||||
contain the last cached values. When the cache is full, the first entry to
|
||||
be erased is the entry before q_hfwCachedHfws[q_firstCachedHfw]. When
|
||||
values are looked up, we try to move q_firstCachedHfw to point to that new
|
||||
entry (unless the cache is not full, in which case it would leave the cache
|
||||
in a broken state), so that the most recently used entry is also the last
|
||||
to be erased.
|
||||
*/
|
||||
|
||||
int QWidgetItemV2::heightForWidth(int width) const
|
||||
{
|
||||
if (isEmpty())
|
||||
return -1;
|
||||
|
||||
for (int i = 0; i < q_hfwCacheSize; ++i) {
|
||||
int offset = q_firstCachedHfw + i;
|
||||
const QSize &size = q_cachedHfws[offset % HfwCacheMaxSize];
|
||||
if (size.width() == width) {
|
||||
if (q_hfwCacheSize == HfwCacheMaxSize)
|
||||
q_firstCachedHfw = offset;
|
||||
return size.height();
|
||||
}
|
||||
}
|
||||
|
||||
if (q_hfwCacheSize < HfwCacheMaxSize)
|
||||
++q_hfwCacheSize;
|
||||
q_firstCachedHfw = (q_firstCachedHfw + HfwCacheMaxSize - 1) % HfwCacheMaxSize;
|
||||
|
||||
int height = QWidgetItem::heightForWidth(width);
|
||||
q_cachedHfws[q_firstCachedHfw] = QSize(width, height);
|
||||
return height;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -121,41 +121,6 @@ protected:
|
|||
QWidget *wid;
|
||||
};
|
||||
|
||||
class Q_GUI_EXPORT QWidgetItemV2 : public QWidgetItem
|
||||
{
|
||||
public:
|
||||
explicit QWidgetItemV2(QWidget *widget);
|
||||
~QWidgetItemV2();
|
||||
|
||||
QSize sizeHint() const;
|
||||
QSize minimumSize() const;
|
||||
QSize maximumSize() const;
|
||||
int heightForWidth(int width) const;
|
||||
|
||||
private:
|
||||
enum { Dirty = -123, HfwCacheMaxSize = 3 };
|
||||
|
||||
inline bool useSizeCache() const;
|
||||
void updateCacheIfNecessary() const;
|
||||
inline void invalidateSizeCache() {
|
||||
q_cachedMinimumSize.setWidth(Dirty);
|
||||
q_hfwCacheSize = 0;
|
||||
}
|
||||
|
||||
mutable QSize q_cachedMinimumSize;
|
||||
mutable QSize q_cachedSizeHint;
|
||||
mutable QSize q_cachedMaximumSize;
|
||||
mutable QSize q_cachedHfws[HfwCacheMaxSize];
|
||||
mutable short q_firstCachedHfw;
|
||||
mutable short q_hfwCacheSize;
|
||||
void *d;
|
||||
|
||||
friend class QWidgetPrivate;
|
||||
|
||||
Q_DISABLE_COPY(QWidgetItemV2)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
#endif // QLAYOUTITEM_H
|
||||
|
|
|
@ -170,7 +170,6 @@ QWidgetPrivate::QWidgetPrivate()
|
|||
, layout(0)
|
||||
, needsFlush(0)
|
||||
, redirectDev(0)
|
||||
, widgetItem(0)
|
||||
, extraPaintEngine(0)
|
||||
, polished(0)
|
||||
, inheritedFontResolveMask(0)
|
||||
|
@ -214,9 +213,6 @@ QWidgetPrivate::QWidgetPrivate()
|
|||
QWidgetPrivate::~QWidgetPrivate()
|
||||
{
|
||||
|
||||
if (widgetItem)
|
||||
widgetItem->wid = 0;
|
||||
|
||||
if (extra)
|
||||
deleteExtra();
|
||||
}
|
||||
|
@ -1286,8 +1282,7 @@ void QWidgetPrivate::deleteExtra()
|
|||
delete extra->topextra;
|
||||
}
|
||||
delete extra;
|
||||
// extra->xic destroyed in QWidget::destroy()
|
||||
extra = 0;
|
||||
extra = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8020,8 +8015,6 @@ QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChil
|
|||
void QWidgetPrivate::updateGeometry_helper(bool forceUpdate)
|
||||
{
|
||||
Q_Q(QWidget);
|
||||
if (widgetItem)
|
||||
widgetItem->invalidateSizeCache();
|
||||
if (forceUpdate || !extra || extra->minw != extra->maxw || extra->minh != extra->maxh) {
|
||||
QWidget *parent;
|
||||
if (!q->isWindow() && !q->isHidden() && (parent = q->parentWidget())) {
|
||||
|
|
|
@ -579,7 +579,6 @@ private:
|
|||
friend class QETWidget;
|
||||
friend class QLayout;
|
||||
friend class QWidgetItem;
|
||||
friend class QWidgetItemV2;
|
||||
friend class QX11PaintEngine;
|
||||
friend class QShortcutPrivate;
|
||||
friend class QShortcutMap;
|
||||
|
|
|
@ -61,7 +61,6 @@ class QPaintEngine;
|
|||
class QPixmap;
|
||||
class QWidgetBackingStore;
|
||||
class QGraphicsProxyWidget;
|
||||
class QWidgetItemV2;
|
||||
class QStyle;
|
||||
|
||||
class Q_AUTOTEST_EXPORT QWidgetBackingStoreTracker
|
||||
|
@ -499,7 +498,6 @@ public:
|
|||
QLayout *layout;
|
||||
QRegion *needsFlush;
|
||||
QPaintDevice *redirectDev;
|
||||
QWidgetItemV2 *widgetItem;
|
||||
QPaintEngine *extraPaintEngine;
|
||||
mutable const QMetaObject *polished;
|
||||
// All widgets are added into the allWidgets set. Once
|
||||
|
|
|
@ -357,7 +357,7 @@ void QDockWidgetLayout::setWidgetForRole(Role r, QWidget *w)
|
|||
|
||||
if (w != 0) {
|
||||
addChildWidget(w);
|
||||
item_list[r] = new QWidgetItemV2(w);
|
||||
item_list[r] = new QWidgetItem(w);
|
||||
w->show();
|
||||
} else {
|
||||
item_list[r] = 0;
|
||||
|
|
|
@ -337,7 +337,7 @@ void QMainWindowLayoutState::setCentralWidget(QWidget *widget)
|
|||
deleteCentralWidgetItem();
|
||||
|
||||
if (widget != 0)
|
||||
item = new QWidgetItemV2(widget);
|
||||
item = new QWidgetItem(widget);
|
||||
|
||||
#ifndef QT_NO_DOCKWIDGET
|
||||
dockAreaLayout.centralWidgetItem = item;
|
||||
|
@ -1562,7 +1562,7 @@ void QMainWindowLayout::setStatusBar(QStatusBar *sb)
|
|||
if (sb)
|
||||
addChildWidget(sb);
|
||||
delete statusbar;
|
||||
statusbar = sb ? new QWidgetItemV2(sb) : 0;
|
||||
statusbar = sb ? new QWidgetItem(sb) : 0;
|
||||
invalidate();
|
||||
}
|
||||
#endif // QT_NO_STATUSBAR
|
||||
|
|
|
@ -279,7 +279,7 @@ void QToolBarAreaLayoutInfo::fitLayout()
|
|||
QLayoutItem *QToolBarAreaLayoutInfo::insertToolBar(QToolBar *before, QToolBar *toolBar)
|
||||
{
|
||||
toolBar->setOrientation(o);
|
||||
QLayoutItem *item = new QWidgetItemV2(toolBar);
|
||||
QLayoutItem *item = new QWidgetItem(toolBar);
|
||||
insertItem(before, item);
|
||||
return item;
|
||||
}
|
||||
|
@ -1340,7 +1340,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
|
|||
}
|
||||
|
||||
if (applyingLayout) {
|
||||
item.widgetItem = new QWidgetItemV2(toolBar);
|
||||
item.widgetItem = new QWidgetItem(toolBar);
|
||||
toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
|
||||
toolBar->setVisible(shown & 1);
|
||||
toolBar->d_func()->setWindowState(floating, true, rect);
|
||||
|
|
|
@ -548,7 +548,6 @@ static const struct ClassTblData {
|
|||
{ QLatin1String("QWidget"), QLatin1String("QtGui/qwidget.h") },
|
||||
{ QLatin1String("QWidgetAction"), QLatin1String("QtGui/qwidgetaction.h") },
|
||||
{ QLatin1String("QWidgetItem"), QLatin1String("QtGui/qlayoutitem.h") },
|
||||
{ QLatin1String("QWidgetItemV2"), QLatin1String("QtGui/qlayoutitem.h") },
|
||||
{ QLatin1String("QWindowStateChangeEvent"), QLatin1String("QtGui/qevent.h") },
|
||||
{ QLatin1String("QWindowsStyle"), QLatin1String("QtGui/qwindowsstyle.h") },
|
||||
{ QLatin1String("QWizard"), QLatin1String("QtGui/qwizard.h") },
|
||||
|
|
Loading…
Add table
Reference in a new issue