summaryrefslogtreecommitdiffstats
path: root/examples/sql/drilldown/informationwindow.cpp
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2013-05-22 10:52:56 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-22 13:48:53 +0200
commite724fd4710cfd395b7d0a8cf160e79ec5ae9d685 (patch)
tree8279c866fb910a79416bbcfd762c36aafd5ce736 /examples/sql/drilldown/informationwindow.cpp
parentf9b3b02360f5b2352cfe26494fb07c7f2f3b7832 (diff)
Doc: Updated content for Drill Down example
QtWidgets/Drill Down example uses images and information about Nokia's old office locations as content. This change updates the example to use concepts related to Qt instead. In addition, - Documentation, screenshot updated accordingly - Corrected aspect ratio when scaling image items in the scene - Added a gray background with a slight gradient - Removed Symbian-specific code remnant Task-number: QTBUG-31075 Change-Id: Id8abfbf7f4033f74172477570f8f28390854101c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Diffstat (limited to 'examples/sql/drilldown/informationwindow.cpp')
-rw-r--r--examples/sql/drilldown/informationwindow.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/examples/sql/drilldown/informationwindow.cpp b/examples/sql/drilldown/informationwindow.cpp
index 08c125e58a..d3930c6f0b 100644
--- a/examples/sql/drilldown/informationwindow.cpp
+++ b/examples/sql/drilldown/informationwindow.cpp
@@ -41,38 +41,35 @@
#include "informationwindow.h"
//! [0]
-InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *offices,
+InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *items,
QWidget *parent)
: QDialog(parent)
{
//! [0] //! [1]
- QLabel *locationLabel = new QLabel(tr("Location: "));
- QLabel *countryLabel = new QLabel(tr("Country: "));
+ QLabel *itemLabel = new QLabel(tr("Item: "));
QLabel *descriptionLabel = new QLabel(tr("Description: "));
QLabel *imageFileLabel = new QLabel(tr("Image file: "));
createButtons();
- locationText = new QLabel;
- countryText = new QLabel;
+ itemText = new QLabel;
descriptionEditor = new QTextEdit;
//! [1]
//! [2]
imageFileEditor = new QComboBox;
- imageFileEditor->setModel(offices->relationModel(1));
- imageFileEditor->setModelColumn(offices->relationModel(1)->fieldIndex("file"));
+ imageFileEditor->setModel(items->relationModel(1));
+ imageFileEditor->setModelColumn(items->relationModel(1)->fieldIndex("file"));
//! [2]
//! [3]
mapper = new QDataWidgetMapper(this);
- mapper->setModel(offices);
+ mapper->setModel(items);
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
mapper->setItemDelegate(new QSqlRelationalDelegate(mapper));
mapper->addMapping(imageFileEditor, 1);
- mapper->addMapping(locationText, 2, "text");
- mapper->addMapping(countryText, 3, "text");
- mapper->addMapping(descriptionEditor, 4);
+ mapper->addMapping(itemText, 2, "text");
+ mapper->addMapping(descriptionEditor, 3);
mapper->setCurrentIndex(id);
//! [3]
@@ -83,8 +80,7 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *offices,
this, SLOT(enableButtons()));
QFormLayout *formLayout = new QFormLayout;
- formLayout->addRow(locationLabel, locationText);
- formLayout->addRow(countryLabel, countryText);
+ formLayout->addRow(itemLabel, itemText);
formLayout->addRow(imageFileLabel, imageFileEditor);
formLayout->addRow(descriptionLabel, descriptionEditor);
@@ -93,23 +89,19 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *offices,
layout->addWidget(buttonBox);
setLayout(layout);
- locationId = id;
+ itemId = id;
displayedImage = imageFileEditor->currentText();
- // Commented the following line. Now the window will look like dialog and the Qt will place the QDialogBox buttons to menu area in Symbian.
- // Too bad that the revert button is missing, Should the Qt place the buttons under Option menu in the menu area?!
- // If the Qt::Window flag was used, the background of window is white in symbian and the QLabels can't be regognized from the background.
-
- //setWindowFlags(Qt::Window);
+ setWindowFlags(Qt::Window);
enableButtons(false);
- setWindowTitle(tr("Office: %1").arg(locationText->text()));
+ setWindowTitle(itemText->text());
}
//! [4]
//! [5]
int InformationWindow::id()
{
- return locationId;
+ return itemId;
}
//! [5]
@@ -128,11 +120,11 @@ void InformationWindow::submit()
if (displayedImage != newImage) {
displayedImage = newImage;
- emit imageChanged(locationId, newImage);
+ emit imageChanged(itemId, newImage);
}
mapper->submit();
- mapper->setCurrentIndex(locationId);
+ mapper->setCurrentIndex(itemId);
enableButtons(false);
}