summaryrefslogtreecommitdiffstats
path: root/examples/sql/drilldown
diff options
context:
space:
mode:
Diffstat (limited to 'examples/sql/drilldown')
-rw-r--r--examples/sql/drilldown/drilldown.qrc17
-rw-r--r--examples/sql/drilldown/imageitem.cpp2
-rw-r--r--examples/sql/drilldown/images/beijing.pngbin99093 -> 0 bytes
-rw-r--r--examples/sql/drilldown/images/berlin.pngbin81944 -> 0 bytes
-rw-r--r--examples/sql/drilldown/images/brisbane.pngbin57785 -> 0 bytes
-rw-r--r--examples/sql/drilldown/images/munich.pngbin59769 -> 0 bytes
-rw-r--r--examples/sql/drilldown/images/oslo.pngbin41781 -> 0 bytes
-rw-r--r--examples/sql/drilldown/images/qt-creator.pngbin0 -> 46906 bytes
-rw-r--r--examples/sql/drilldown/images/qt-logo.pngbin0 -> 45652 bytes
-rw-r--r--examples/sql/drilldown/images/qt-project.pngbin0 -> 37795 bytes
-rw-r--r--examples/sql/drilldown/images/qt-quick.pngbin0 -> 43238 bytes
-rw-r--r--examples/sql/drilldown/images/redwood.pngbin39050 -> 0 bytes
-rw-r--r--examples/sql/drilldown/informationwindow.cpp38
-rw-r--r--examples/sql/drilldown/informationwindow.h7
-rw-r--r--examples/sql/drilldown/logo.pngbin13378 -> 0 bytes
-rw-r--r--examples/sql/drilldown/main.cpp2
-rw-r--r--examples/sql/drilldown/view.cpp47
-rw-r--r--examples/sql/drilldown/view.h4
18 files changed, 53 insertions, 64 deletions
diff --git a/examples/sql/drilldown/drilldown.qrc b/examples/sql/drilldown/drilldown.qrc
index d2fb12295b..f24edbafe4 100644
--- a/examples/sql/drilldown/drilldown.qrc
+++ b/examples/sql/drilldown/drilldown.qrc
@@ -1,11 +1,8 @@
-<!DOCTYPE RCC><RCC version="1.0">
- <qresource>
- <file>images/oslo.png</file>
- <file>images/brisbane.png</file>
- <file>images/redwood.png</file>
- <file>images/berlin.png</file>
- <file>images/munich.png</file>
- <file>images/beijing.png</file>
- <file>logo.png</file>
- </qresource>
+<RCC>
+ <qresource prefix="/">
+ <file>images/qt-logo.png</file>
+ <file>images/qt-quick.png</file>
+ <file>images/qt-creator.png</file>
+ <file>images/qt-project.png</file>
+ </qresource>
</RCC>
diff --git a/examples/sql/drilldown/imageitem.cpp b/examples/sql/drilldown/imageitem.cpp
index 8ebd7fd890..f1e3872e1c 100644
--- a/examples/sql/drilldown/imageitem.cpp
+++ b/examples/sql/drilldown/imageitem.cpp
@@ -100,7 +100,7 @@ void ImageItem::setFrame(int frame)
void ImageItem::adjust()
{
QMatrix matrix;
- matrix.scale(150/ boundingRect().width(), 120/ boundingRect().height());
+ matrix.scale(120/ boundingRect().width(), 120/ boundingRect().height());
setMatrix(matrix);
}
//! [4]
diff --git a/examples/sql/drilldown/images/beijing.png b/examples/sql/drilldown/images/beijing.png
deleted file mode 100644
index 45df148506..0000000000
--- a/examples/sql/drilldown/images/beijing.png
+++ /dev/null
Binary files differ
diff --git a/examples/sql/drilldown/images/berlin.png b/examples/sql/drilldown/images/berlin.png
deleted file mode 100644
index ead62f0421..0000000000
--- a/examples/sql/drilldown/images/berlin.png
+++ /dev/null
Binary files differ
diff --git a/examples/sql/drilldown/images/brisbane.png b/examples/sql/drilldown/images/brisbane.png
deleted file mode 100644
index 04fff57f9c..0000000000
--- a/examples/sql/drilldown/images/brisbane.png
+++ /dev/null
Binary files differ
diff --git a/examples/sql/drilldown/images/munich.png b/examples/sql/drilldown/images/munich.png
deleted file mode 100644
index 741eb77b8d..0000000000
--- a/examples/sql/drilldown/images/munich.png
+++ /dev/null
Binary files differ
diff --git a/examples/sql/drilldown/images/oslo.png b/examples/sql/drilldown/images/oslo.png
deleted file mode 100644
index 02fa25e5a0..0000000000
--- a/examples/sql/drilldown/images/oslo.png
+++ /dev/null
Binary files differ
diff --git a/examples/sql/drilldown/images/qt-creator.png b/examples/sql/drilldown/images/qt-creator.png
new file mode 100644
index 0000000000..fa0f6ed7ce
--- /dev/null
+++ b/examples/sql/drilldown/images/qt-creator.png
Binary files differ
diff --git a/examples/sql/drilldown/images/qt-logo.png b/examples/sql/drilldown/images/qt-logo.png
new file mode 100644
index 0000000000..53bc39c38c
--- /dev/null
+++ b/examples/sql/drilldown/images/qt-logo.png
Binary files differ
diff --git a/examples/sql/drilldown/images/qt-project.png b/examples/sql/drilldown/images/qt-project.png
new file mode 100644
index 0000000000..c34d3f099d
--- /dev/null
+++ b/examples/sql/drilldown/images/qt-project.png
Binary files differ
diff --git a/examples/sql/drilldown/images/qt-quick.png b/examples/sql/drilldown/images/qt-quick.png
new file mode 100644
index 0000000000..f66127e8e7
--- /dev/null
+++ b/examples/sql/drilldown/images/qt-quick.png
Binary files differ
diff --git a/examples/sql/drilldown/images/redwood.png b/examples/sql/drilldown/images/redwood.png
deleted file mode 100644
index f39ac06578..0000000000
--- a/examples/sql/drilldown/images/redwood.png
+++ /dev/null
Binary files differ
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);
}
diff --git a/examples/sql/drilldown/informationwindow.h b/examples/sql/drilldown/informationwindow.h
index e1bb9bc958..f039e120ca 100644
--- a/examples/sql/drilldown/informationwindow.h
+++ b/examples/sql/drilldown/informationwindow.h
@@ -50,7 +50,7 @@ class InformationWindow : public QDialog
Q_OBJECT
public:
- InformationWindow(int id, QSqlRelationalTableModel *offices,
+ InformationWindow(int id, QSqlRelationalTableModel *items,
QWidget *parent = 0);
int id();
@@ -70,12 +70,11 @@ private slots:
private:
void createButtons();
- int locationId;
+ int itemId;
QString displayedImage;
QComboBox *imageFileEditor;
- QLabel *locationText;
- QLabel *countryText;
+ QLabel *itemText;
QTextEdit *descriptionEditor;
QPushButton *closeButton;
diff --git a/examples/sql/drilldown/logo.png b/examples/sql/drilldown/logo.png
deleted file mode 100644
index 4b1d235488..0000000000
--- a/examples/sql/drilldown/logo.png
+++ /dev/null
Binary files differ
diff --git a/examples/sql/drilldown/main.cpp b/examples/sql/drilldown/main.cpp
index 2ee32e446f..956cca9ef9 100644
--- a/examples/sql/drilldown/main.cpp
+++ b/examples/sql/drilldown/main.cpp
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
if (!createConnection())
return 1;
- View view("offices", "images");
+ View view("items", "images");
view.show();
#ifdef QT_KEYPAD_NAVIGATION
QApplication::setNavigationMode(Qt::NavigationModeCursorAuto);
diff --git a/examples/sql/drilldown/view.cpp b/examples/sql/drilldown/view.cpp
index d80a800e62..a64252cbd2 100644
--- a/examples/sql/drilldown/view.cpp
+++ b/examples/sql/drilldown/view.cpp
@@ -43,61 +43,62 @@
#include "view.h"
//! [0]
-View::View(const QString &offices, const QString &images, QWidget *parent)
+View::View(const QString &items, const QString &images, QWidget *parent)
: QGraphicsView(parent)
{
- officeTable = new QSqlRelationalTableModel(this);
- officeTable->setTable(offices);
- officeTable->setRelation(1, QSqlRelation(images, "locationid", "file"));
- officeTable->select();
+ itemTable = new QSqlRelationalTableModel(this);
+ itemTable->setTable(items);
+ itemTable->setRelation(1, QSqlRelation(images, "itemid", "file"));
+ itemTable->select();
//! [0]
//! [1]
scene = new QGraphicsScene(this);
- scene->setSceneRect(0, 0, 465, 615);
+ scene->setSceneRect(0, 0, 465, 365);
setScene(scene);
addItems();
- QGraphicsPixmapItem *logo = scene->addPixmap(QPixmap(":/logo.png"));
- logo->setPos(30, 515);
+ setMinimumSize(470, 370);
+ setMaximumSize(470, 370);
- setMinimumSize(470, 620);
- setMaximumSize(470, 620);
-
- setWindowTitle(tr("Offices World Wide"));
+ QLinearGradient gradient(QPointF(0, 0), QPointF(0, 370));
+ gradient.setColorAt(0, QColor("#868482"));
+ gradient.setColorAt(1, QColor("#5d5b59"));
+ setBackgroundBrush(gradient);
}
//! [1]
//! [3]
void View::addItems()
{
- int officeCount = officeTable->rowCount();
+ int itemCount = itemTable->rowCount();
int imageOffset = 150;
int leftMargin = 70;
int topMargin = 40;
- for (int i = 0; i < officeCount; i++) {
+ for (int i = 0; i < itemCount; i++) {
ImageItem *image;
QGraphicsTextItem *label;
- QSqlRecord record = officeTable->record(i);
+ QSqlRecord record = itemTable->record(i);
int id = record.value("id").toInt();
QString file = record.value("file").toString();
- QString location = record.value("location").toString();
+ QString item = record.value("itemtype").toString();
- int columnOffset = ((i / 3) * 37);
- int x = ((i / 3) * imageOffset) + leftMargin + columnOffset;
- int y = ((i % 3) * imageOffset) + topMargin;
+ int columnOffset = ((i % 2) * 37);
+ int x = ((i % 2) * imageOffset) + leftMargin + columnOffset;
+ int y = ((i / 2) * imageOffset) + topMargin;
image = new ImageItem(id, QPixmap(":/" + file));
image->setData(0, i);
image->setPos(x, y);
scene->addItem(image);
- label = scene->addText(location);
- QPointF labelOffset((150 - label->boundingRect().width()) / 2, 120.0);
+ label = scene->addText(item);
+ label->setDefaultTextColor(QColor("#d7d6d5"));
+ QPointF labelOffset((120 - label->boundingRect().width()) / 2, 120.0);
label->setPos(QPointF(x, y) + labelOffset);
}
}
@@ -118,7 +119,7 @@ void View::mouseReleaseEvent(QMouseEvent *event)
void View::showInformation(ImageItem *image)
{
int id = image->id();
- if (id < 0 || id >= officeTable->rowCount())
+ if (id < 0 || id >= itemTable->rowCount())
return;
InformationWindow *window = findWindow(id);
@@ -129,7 +130,7 @@ void View::showInformation(ImageItem *image)
window->show();
} else {
InformationWindow *window;
- window = new InformationWindow(id, officeTable, this);
+ window = new InformationWindow(id, itemTable, this);
connect(window, SIGNAL(imageChanged(int,QString)),
this, SLOT(updateImage(int,QString)));
diff --git a/examples/sql/drilldown/view.h b/examples/sql/drilldown/view.h
index 21193b1960..c9fc040bb1 100644
--- a/examples/sql/drilldown/view.h
+++ b/examples/sql/drilldown/view.h
@@ -53,7 +53,7 @@ class View : public QGraphicsView
Q_OBJECT
public:
- View(const QString &offices, const QString &images, QWidget *parent = 0);
+ View(const QString &items, const QString &images, QWidget *parent = 0);
protected:
void mouseReleaseEvent(QMouseEvent *event);
@@ -73,7 +73,7 @@ private:
QGraphicsScene *scene;
QList<InformationWindow *> informationWindows;
//! [2] //! [3]
- QSqlRelationalTableModel *officeTable;
+ QSqlRelationalTableModel *itemTable;
};
//! [3]