mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
get rid of QWidgetItemV2
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
d4a0fe76ef
commit
16e996daae
16 changed files with 30 additions and 218 deletions
|
@ -833,7 +833,6 @@ classlist = {
|
|||
"QWidget",
|
||||
"QWidgetAction",
|
||||
"QWidgetData",
|
||||
"QWidgetItemV2",
|
||||
"QWidgetMapper",
|
||||
"QWidgetSet",
|
||||
"QWindowsStyle",
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace qdesigner_internal {
|
|||
|
||||
// ------------------ QDesignerWidgetItem
|
||||
QDesignerWidgetItem::QDesignerWidgetItem(const QLayout *containingLayout, QWidget *w, Qt::Orientations o) :
|
||||
QWidgetItemV2(w),
|
||||
QWidgetItem(w),
|
||||
m_orientations(o),
|
||||
m_nonLaidOutMinSize(w->minimumSizeHint()),
|
||||
m_nonLaidOutSizeHint(w->sizeHint()),
|
||||
|
@ -146,7 +146,7 @@ void QDesignerWidgetItem::expand(QSize *s) const
|
|||
QSize QDesignerWidgetItem::minimumSize() const
|
||||
{
|
||||
// Just track the size in case we are laid-out or stretched.
|
||||
const QSize baseMinSize = QWidgetItemV2::minimumSize();
|
||||
const QSize baseMinSize = QWidgetItem::minimumSize();
|
||||
QWidget * w = constWidget();
|
||||
if (w->layout() || subjectToStretch(containingLayout(), w)) {
|
||||
m_nonLaidOutMinSize = baseMinSize;
|
||||
|
@ -162,7 +162,7 @@ QSize QDesignerWidgetItem::minimumSize() const
|
|||
QSize QDesignerWidgetItem::sizeHint() const
|
||||
{
|
||||
// Just track the size in case we are laid-out or stretched.
|
||||
const QSize baseSizeHint = QWidgetItemV2::sizeHint();
|
||||
const QSize baseSizeHint = QWidgetItem::sizeHint();
|
||||
QWidget * w = constWidget();
|
||||
if (w->layout() || subjectToStretch(containingLayout(), w)) {
|
||||
m_nonLaidOutSizeHint = baseSizeHint;
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace qdesigner_internal {
|
|||
// and destroyed slots as Designer will for example re-create grid layouts to
|
||||
// shrink them.
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT QDesignerWidgetItem : public QObject, public QWidgetItemV2 {
|
||||
class QDESIGNER_SHARED_EXPORT QDesignerWidgetItem : public QObject, public QWidgetItem {
|
||||
Q_DISABLE_COPY(QDesignerWidgetItem)
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -326,7 +326,6 @@ set(GUI_PUBLIC_HEADERS
|
|||
QMessageBox
|
||||
QWidgetAction
|
||||
QWidgetData
|
||||
QWidgetItemV2
|
||||
QWidgetMapper
|
||||
QWidgetSet
|
||||
QWindowsStyle
|
||||
|
|
|
@ -189,7 +189,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)
|
||||
|
@ -521,6 +521,19 @@ bool QLayout::isEmpty() const
|
|||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QSizePolicy::ControlTypes QLayout::controlTypes() const
|
||||
{
|
||||
if (count() == 0)
|
||||
return QSizePolicy::DefaultType;
|
||||
QSizePolicy::ControlTypes types;
|
||||
for (int i = count() - 1; i >= 0; --i)
|
||||
types |= itemAt(i)->controlTypes();
|
||||
return types;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
|
|
|
@ -123,6 +123,7 @@ public:
|
|||
virtual int indexOf(QWidget *) const;
|
||||
virtual int count() const = 0;
|
||||
bool isEmpty() const;
|
||||
QSizePolicy::ControlTypes controlTypes() const;
|
||||
|
||||
int totalHeightForWidth(int w) const;
|
||||
QSize totalMinimumSize() const;
|
||||
|
|
|
@ -408,17 +408,6 @@ int QLayoutItem::heightForWidth(int /* w */) const
|
|||
*/
|
||||
QSizePolicy::ControlTypes QLayoutItem::controlTypes() const
|
||||
{
|
||||
// ### Qt 5: This function should probably be virtual instead
|
||||
if (const QWidget *widget = const_cast<QLayoutItem*>(this)->widget()) {
|
||||
return widget->sizePolicy().controlType();
|
||||
} else if (const QLayout *layout = const_cast<QLayoutItem*>(this)->layout()) {
|
||||
if (layout->count() == 0)
|
||||
return QSizePolicy::DefaultType;
|
||||
QSizePolicy::ControlTypes types;
|
||||
for (int i = layout->count() - 1; i >= 0; --i)
|
||||
types |= layout->itemAt(i)->controlTypes();
|
||||
return types;
|
||||
}
|
||||
return QSizePolicy::DefaultType;
|
||||
}
|
||||
|
||||
|
@ -682,153 +671,9 @@ bool QWidgetItem::isEmpty() const
|
|||
return wid->isHidden() || wid->isWindow();
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QWidgetItemV2
|
||||
\internal
|
||||
*/
|
||||
|
||||
inline bool QWidgetItemV2::useSizeCache() const
|
||||
QSizePolicy::ControlTypes QWidgetItem::controlTypes() 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;
|
||||
return wid->sizePolicy().controlType();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
|
||||
Qt::Alignment alignment() const { return align; }
|
||||
void setAlignment(Qt::Alignment a);
|
||||
QSizePolicy::ControlTypes controlTypes() const;
|
||||
virtual QSizePolicy::ControlTypes controlTypes() const;
|
||||
|
||||
protected:
|
||||
Qt::Alignment align;
|
||||
|
@ -136,44 +136,11 @@ public:
|
|||
bool hasHeightForWidth() const;
|
||||
int heightForWidth(int) const;
|
||||
|
||||
QSizePolicy::ControlTypes controlTypes() const;
|
||||
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
|
||||
|
||||
QT_END_HEADER
|
||||
|
|
|
@ -204,7 +204,6 @@ QWidgetPrivate::QWidgetPrivate(int version)
|
|||
, layout(0)
|
||||
, needsFlush(0)
|
||||
, redirectDev(0)
|
||||
, widgetItem(0)
|
||||
, extraPaintEngine(0)
|
||||
, polished(0)
|
||||
, graphicsEffect(0)
|
||||
|
@ -252,9 +251,6 @@ QWidgetPrivate::QWidgetPrivate(int version)
|
|||
QWidgetPrivate::~QWidgetPrivate()
|
||||
{
|
||||
|
||||
if (widgetItem)
|
||||
widgetItem->wid = 0;
|
||||
|
||||
if (extra)
|
||||
deleteExtra();
|
||||
|
||||
|
@ -8731,8 +8727,6 @@ QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChil
|
|||
void QWidgetPrivate::updateGeometry_helper(bool forceUpdate)
|
||||
{
|
||||
Q_Q(QWidget);
|
||||
if (widgetItem)
|
||||
widgetItem->invalidateSizeCache();
|
||||
QWidget *parent;
|
||||
if (forceUpdate || !extra || extra->minw != extra->maxw || extra->minh != extra->maxh) {
|
||||
if (!q->isWindow() && !q->isHidden() && (parent = q->parentWidget())) {
|
||||
|
|
|
@ -649,7 +649,6 @@ private:
|
|||
friend class QETWidget;
|
||||
friend class QLayout;
|
||||
friend class QWidgetItem;
|
||||
friend class QWidgetItemV2;
|
||||
friend class QX11PaintEngine;
|
||||
friend class QShortcutPrivate;
|
||||
friend class QShortcutMap;
|
||||
|
|
|
@ -81,12 +81,9 @@ class QPaintEngine;
|
|||
class QPixmap;
|
||||
class QWidgetBackingStore;
|
||||
class QGraphicsProxyWidget;
|
||||
class QWidgetItemV2;
|
||||
|
||||
class QStyle;
|
||||
|
||||
class QUnifiedToolbarSurface;
|
||||
|
||||
class Q_AUTOTEST_EXPORT QWidgetBackingStoreTracker
|
||||
{
|
||||
|
||||
|
@ -568,7 +565,6 @@ public:
|
|||
QLayout *layout;
|
||||
QRegion *needsFlush;
|
||||
QPaintDevice *redirectDev;
|
||||
QWidgetItemV2 *widgetItem;
|
||||
QPaintEngine *extraPaintEngine;
|
||||
mutable const QMetaObject *polished;
|
||||
QGraphicsEffect *graphicsEffect;
|
||||
|
|
|
@ -377,7 +377,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;
|
||||
|
|
|
@ -371,7 +371,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;
|
||||
|
@ -1619,7 +1619,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
|
||||
|
|
|
@ -299,7 +299,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;
|
||||
}
|
||||
|
@ -1362,7 +1362,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);
|
||||
|
|
|
@ -440,7 +440,6 @@ static const ClassInfoEntry qclass_lib_map[] = {
|
|||
{ "QLayoutItem", "QtGui/qlayoutitem.h"},
|
||||
{ "QSpacerItem", "QtGui/qlayoutitem.h"},
|
||||
{ "QWidgetItem", "QtGui/qlayoutitem.h"},
|
||||
{ "QWidgetItemV2", "QtGui/qlayoutitem.h"},
|
||||
{ "QPalette", "QtGui/qpalette.h"},
|
||||
{ "QShortcut", "QtGui/qshortcut.h"},
|
||||
{ "QSizePolicy", "QtGui/qsizepolicy.h"},
|
||||
|
@ -698,6 +697,6 @@ static const ClassInfoEntry qclass_lib_map[] = {
|
|||
{ "QFormBuilder", "QtUiTools/formbuilder.h"},
|
||||
{ "QUiLoader", "QtUiTools/quiloader.h"},
|
||||
};
|
||||
static const int qclass_lib_count = 692;
|
||||
static const int qclass_lib_count = 691;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -879,7 +879,7 @@ QLayoutItem *QAbstractFormBuilder::create(DomLayoutItem *ui_layoutItem, QLayout
|
|||
case DomLayoutItem::Widget: {
|
||||
if (QWidget *w = create(ui_layoutItem->elementWidget(), parentWidget)) {
|
||||
#ifdef QFORMINTERNAL_NAMESPACE // uilib
|
||||
QWidgetItem *item = new QWidgetItemV2(w);
|
||||
QWidgetItem *item = new QWidgetItem(w);
|
||||
#else // Within Designer: Use factory method that returns special items that refuse to shrink to 0,0
|
||||
QWidgetItem *item = QLayoutPrivate::createWidgetItem(layout, w);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue