drop unused QGraphicsItem custom data feature

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-15 03:15:49 +03:00
parent 464d7b2eeb
commit 783b4e90e9
5 changed files with 16 additions and 69 deletions

View file

@ -236,15 +236,6 @@
function sceneEventFilter(). You can remove item event filters by calling
removeSceneEventFilter().
\section1 Custom Data
Sometimes it's useful to register custom data with an item, be it a custom
item, or a standard item. You can call setData() on any item to store data
in it using a key-value pair (the key being an integer, and the value is a
QVariant). To get custom data from an item, call data(). This
functionality is completely untouched by Qt itself; it is provided for the
user's convenience.
\sa QGraphicsScene, QGraphicsView, {Graphics View Framework}
*/
@ -5971,40 +5962,6 @@ bool QGraphicsItem::isUnderMouse() const
return false;
}
/*!
Returns this item's custom data for the key \a key as a QVariant.
Custom item data is useful for storing arbitrary properties in any
item. Example:
\snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 11
Qt does not use this feature for storing data; it is provided solely
for the convenience of the user.
\sa setData()
*/
QVariant QGraphicsItem::data(int key) const
{
Q_D(const QGraphicsItem);
return d->datastore.value(key);
}
/*!
Sets this item's custom data for the key \a key to \a value.
Custom item data is useful for storing arbitrary properties for any
item. Qt does not use this feature for storing data; it is provided solely
for the convenience of the user.
\sa data()
*/
void QGraphicsItem::setData(int key, const QVariant &value)
{
Q_D(QGraphicsItem);
d->datastore[key] = value;
}
/*!
\fn T qgraphicsitem_cast(QGraphicsItem *item)
\relates QGraphicsItem

View file

@ -363,10 +363,6 @@ public:
QGraphicsItem *commonAncestorItem(const QGraphicsItem *other) const;
bool isUnderMouse() const;
// Custom data
QVariant data(int key) const;
void setData(int key, const QVariant &value);
enum {
Type = 1,
UserType = 65536

View file

@ -431,8 +431,6 @@ public:
QGraphicsItem::GraphicsItemFlags flags;
uint ancestorFlags;
QMap<int, QVariant> datastore;
QGraphicsItem *q_ptr;
};

View file

@ -61,14 +61,12 @@ public:
static QGraphicsWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0),
const QSizeF &preferred = QSize(150.0, 100.0),
const QSizeF &maximum = QSizeF(200.0, 100.0),
const QString &name = QString())
const QSizeF &maximum = QSizeF(200.0, 100.0))
{
QGraphicsWidget *w = new RectWidget;
w->setMinimumSize(minimum);
w->setPreferredSize(preferred);
w->setMaximumSize(maximum);
w->setData(0, name);
return w;
}
@ -107,13 +105,13 @@ void tst_QGraphicsAnchorLayout::s60_hard_complex()
QSizeF pref(50, 10);
QSizeF max(100, 10);
QGraphicsWidget *a = createItem(min, pref, max, "a");
QGraphicsWidget *b = createItem(min, pref, max, "b");
QGraphicsWidget *c = createItem(min, pref, max, "c");
QGraphicsWidget *d = createItem(min, pref, max, "d");
QGraphicsWidget *e = createItem(min, pref, max, "e");
QGraphicsWidget *f = createItem(min, pref, max, "f");
QGraphicsWidget *g = createItem(min, pref, max, "g");
QGraphicsWidget *a = createItem(min, pref, max);
QGraphicsWidget *b = createItem(min, pref, max);
QGraphicsWidget *c = createItem(min, pref, max);
QGraphicsWidget *d = createItem(min, pref, max);
QGraphicsWidget *e = createItem(min, pref, max);
QGraphicsWidget *f = createItem(min, pref, max);
QGraphicsWidget *g = createItem(min, pref, max);
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
@ -185,10 +183,10 @@ static QGraphicsLayout* createLayouts(int whichLayout)
QSizeF pref(50, 10);
QSizeF max(100, 10);
QGraphicsWidget *a = createItem(min, pref, max, "a");
QGraphicsWidget *b = createItem(min, pref, max, "b");
QGraphicsWidget *c = createItem(min, pref, max, "c");
QGraphicsWidget *d = createItem(min, pref, max, "d");
QGraphicsWidget *a = createItem(min, pref, max);
QGraphicsWidget *b = createItem(min, pref, max);
QGraphicsWidget *c = createItem(min, pref, max);
QGraphicsWidget *d = createItem(min, pref, max);
QGraphicsLayout *l;
if (whichLayout == 0) {
@ -320,10 +318,10 @@ void tst_QGraphicsAnchorLayout::linearVsAnchorNested()
QSizeF pref(80, 80);
QSizeF max(150, 150);
QGraphicsWidget *a = createItem(min, pref, max, "a");
QGraphicsWidget *b = createItem(min, pref, max, "b");
QGraphicsWidget *c = createItem(min, pref, max, "c");
QGraphicsWidget *d = createItem(min, pref, max, "d");
QGraphicsWidget *a = createItem(min, pref, max);
QGraphicsWidget *b = createItem(min, pref, max);
QGraphicsWidget *c = createItem(min, pref, max);
QGraphicsWidget *d = createItem(min, pref, max);
QGraphicsLayout *layout;

View file

@ -83,7 +83,6 @@ void tst_QGraphicsLayout::invalidate()
RectWidget *window = new RectWidget(0, Qt::Window);
window->setGeometryCalls = &setGeometryCalls;
window->setData(0, QString(QLatin1Char('a')));
scene.addItem(window);
RectWidget *leaf = 0;
@ -93,7 +92,6 @@ void tst_QGraphicsLayout::invalidate()
QGraphicsLinearLayout *l = new QGraphicsLinearLayout(parent);
l->setContentsMargins(0,0,0,0);
RectWidget *child = new RectWidget;
child->setData(0, QString(QChar('a' + i)));
child->setGeometryCalls = &setGeometryCalls;
l->addItem(child);
parent = child;