SQL/drilldown example: add new icons and misc cleanup

Cleanup the drilldown example:
 - use icons with the current style
 - remove unneeded QOverload<>
 - remove some empty lines which don't look good in the documentation
 - use Q_SLOTS/Q_SIGNALS instead slots/signals

Fixes: QTBUG-113696
Change-Id: I62476a8989c0abd1f424d1425cb05489491e2153
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Christian Ehrlicher 2023-11-10 21:13:05 +01:00
parent 1ffd12a8dc
commit fa045a3ce7
12 changed files with 17 additions and 21 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -46,8 +46,8 @@
\snippet drilldown/informationwindow.h 0
When we create an information window, we pass the associated
item ID, a parent, and a pointer to the database, to the
constructor. We will use the database pointer to populate our
item ID, a pointer to the model, and a parent to the
constructor. We will use the model pointer to populate our
window with data, while passing the parent parameter on to the
base class. The ID is stored for future reference.

View File

@ -54,7 +54,7 @@ void ImageItem::setFrame(int frame)
QPointF center = boundingRect().center();
setTransform(QTransform::fromTranslate(center.x(), center.y()), true);
setTransform(QTransform::fromScale(1 + frame / 330.0, 1 + frame / 330.0), true);
setTransform(QTransform::fromScale(1 + frame / 300.0, 1 + frame / 300.0), true);
setTransform(QTransform::fromTranslate(-center.x(), -center.y()), true);
}
//! [3]
@ -62,8 +62,8 @@ void ImageItem::setFrame(int frame)
//! [4]
void ImageItem::adjust()
{
setTransform(QTransform::fromScale(120 / boundingRect().width(),
120 / boundingRect().height()));
setTransform(QTransform::fromScale(120.0 / boundingRect().width(),
120.0 / boundingRect().height()));
}
//! [4]

View File

@ -11,7 +11,6 @@
class ImageItem : public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
public:
enum { Type = UserType + 1 };
@ -25,7 +24,7 @@ protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
private slots:
private Q_SLOTS:
void setFrame(int frame);
void updateItemPosition();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@ -37,8 +37,8 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *items,
//! [3]
//! [4]
connect(descriptionEditor, &QTextEdit::textChanged, this, [this]() { enableButtons(); });
connect(imageFileEditor, &QComboBox::currentIndexChanged, this, [this]() { enableButtons(); });
connect(descriptionEditor, &QTextEdit::textChanged, this, [this]() { enableButtons(true); });
connect(imageFileEditor, &QComboBox::currentIndexChanged, this, [this]() { enableButtons(true); });
QFormLayout *formLayout = new QFormLayout;
formLayout->addRow(itemLabel, itemText);

View File

@ -11,22 +11,20 @@
class InformationWindow : public QDialog
{
Q_OBJECT
public:
InformationWindow(int id, QSqlRelationalTableModel *items,
QWidget *parent = nullptr);
int id() const;
signals:
Q_SIGNALS:
void imageChanged(int id, const QString &fileName);
//! [0]
//! [1]
private slots:
private Q_SLOTS:
void revert();
void submit();
void enableButtons(bool enable = true);
void enableButtons(bool enable);
//! [1]
//! [2]

View File

@ -87,8 +87,8 @@ void View::showInformation(ImageItem *image)
if (!window) {
window = new InformationWindow(id, itemTable, this);
connect(window, QOverload<int,const QString &>::of(&InformationWindow::imageChanged),
this, QOverload<int,const QString &>::of(&View::updateImage));
connect(window, &InformationWindow::imageChanged,
this, &View::updateImage);
window->move(pos() + QPoint(20, 40));
window->show();

View File

@ -14,7 +14,6 @@ class InformationWindow;
class View : public QGraphicsView
{
Q_OBJECT
public:
View(const QString &items, const QString &images, QWidget *parent = nullptr);
@ -23,7 +22,7 @@ protected:
//! [0]
//! [1]
private slots:
private Q_SLOTS:
void updateImage(int id, const QString &fileName);
//! [1]