summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMarek Rosa <marek.rosa@digia.com>2012-12-11 15:47:42 +0200
committerMarek Rosa <marek.rosa@digia.com>2012-12-11 15:47:42 +0200
commit78f544f7173ae96cc32823a91464387feeda19db (patch)
tree05bb796025d4c2d93c4410d6c93e3ab0f8feb651 /examples
parenta79e8167701d451da9ef8f0c183bc588c2886d07 (diff)
Removed old logaxis example
Diffstat (limited to 'examples')
-rw-r--r--examples/logaxis/customtablemodel.cpp110
-rw-r--r--examples/logaxis/customtablemodel.h51
-rw-r--r--examples/logaxis/logaxis.pro16
-rw-r--r--examples/logaxis/main.cpp30
-rw-r--r--examples/logaxis/tablewidget.cpp153
-rw-r--r--examples/logaxis/tablewidget.h55
6 files changed, 0 insertions, 415 deletions
diff --git a/examples/logaxis/customtablemodel.cpp b/examples/logaxis/customtablemodel.cpp
deleted file mode 100644
index 30d7bfc7..00000000
--- a/examples/logaxis/customtablemodel.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "customtablemodel.h"
-#include <QVector>
-#include <QTime>
-#include <QRect>
-#include <QColor>
-
-CustomTableModel::CustomTableModel(QObject *parent) :
- QAbstractTableModel(parent)
-{
- qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
-
- m_columnCount = 4;
- m_rowCount = 15;
-
- // m_data
- for (int i = 0; i < m_rowCount; i++) {
- QVector<qreal>* dataVec = new QVector<qreal>(m_columnCount);
- for (int k = 0; k < dataVec->size(); k++) {
- if (k % 2 == 0)
- dataVec->replace(k, i * 50 + qrand() % 20);
- else
- dataVec->replace(k, qrand() % 100);
- }
- m_data.append(dataVec);
- }
-}
-
-int CustomTableModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent)
- return m_data.count();
-}
-
-int CustomTableModel::columnCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent)
- return m_columnCount;
-}
-
-QVariant CustomTableModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- if (role != Qt::DisplayRole)
- return QVariant();
-
- if (orientation == Qt::Horizontal) {
- if (section % 2 == 0)
- return "x";
- else
- return "y";
- } else {
- return QString("%1").arg(section + 1);
- }
-}
-
-QVariant CustomTableModel::data(const QModelIndex &index, int role) const
-{
- if (role == Qt::DisplayRole) {
- return m_data[index.row()]->at(index.column());
- } else if (role == Qt::EditRole) {
- return m_data[index.row()]->at(index.column());
- } else if (role == Qt::BackgroundRole) {
- foreach (QRect rect, m_mapping) {
- if (rect.contains(index.column(), index.row()))
- return QColor(m_mapping.key(rect));
- }
- // cell not mapped return white color
- return QColor(Qt::white);
- }
- return QVariant();
-}
-
-bool CustomTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
-{
- if (index.isValid() && role == Qt::EditRole) {
- m_data[index.row()]->replace(index.column(), value.toDouble());
- emit dataChanged(index, index);
- return true;
- }
- return false;
-}
-
-Qt::ItemFlags CustomTableModel::flags(const QModelIndex &index) const
-{
- return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
-}
-
-void CustomTableModel::addMapping(QString color, QRect area)
-{
- m_mapping.insertMulti(color, area);
-}
diff --git a/examples/logaxis/customtablemodel.h b/examples/logaxis/customtablemodel.h
deleted file mode 100644
index 7b7e63f5..00000000
--- a/examples/logaxis/customtablemodel.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CUSTOMTABLEMODEL_H
-#define CUSTOMTABLEMODEL_H
-
-#include <QAbstractTableModel>
-#include <QHash>
-#include <QRect>
-
-class CustomTableModel : public QAbstractTableModel
-{
- Q_OBJECT
-public:
- explicit CustomTableModel(QObject *parent = 0);
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
- Qt::ItemFlags flags(const QModelIndex &index) const;
-
- void addMapping(QString color, QRect area);
- void clearMapping() { m_mapping.clear(); }
-
-private:
- QList<QVector<qreal> * > m_data;
- QHash<QString, QRect> m_mapping;
- int m_columnCount;
- int m_rowCount;
-};
-
-#endif // CUSTOMTABLEMODEL_H
diff --git a/examples/logaxis/logaxis.pro b/examples/logaxis/logaxis.pro
deleted file mode 100644
index 068f5a60..00000000
--- a/examples/logaxis/logaxis.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-!include( ../examples.pri ) {
- error( "Couldn't find the examples.pri file!" )
-}
-
-QT += core gui
-
-TARGET = logaxis
-TEMPLATE = app
-
-
-SOURCES += main.cpp\
- tablewidget.cpp \
- customtablemodel.cpp
-
-HEADERS += tablewidget.h \
- customtablemodel.h
diff --git a/examples/logaxis/main.cpp b/examples/logaxis/main.cpp
deleted file mode 100644
index 1b64c7be..00000000
--- a/examples/logaxis/main.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include "tablewidget.h"
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
- TableWidget w;
- w.show();
- return a.exec();
-}
diff --git a/examples/logaxis/tablewidget.cpp b/examples/logaxis/tablewidget.cpp
deleted file mode 100644
index 5dd98716..00000000
--- a/examples/logaxis/tablewidget.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "tablewidget.h"
-#include "customtablemodel.h"
-#include <QGridLayout>
-#include <QTableView>
-#include <QChart>
-#include <QChartView>
-#include <QLineSeries>
-#include <QVXYModelMapper>
-#include <QHeaderView>
-#include <QDoubleSpinBox>
-#include <QLogValueAxis>
-#include <QLineEdit>
-#include <QDateTimeAxis>
-
-QTCOMMERCIALCHART_USE_NAMESPACE
-
-TableWidget::TableWidget(QWidget *parent)
- : QWidget(parent),
- m_logBaseSpinBox(0),
- m_axis(0)
-{
- // create simple model for storing data
- // user's table data model
- //! [1]
- CustomTableModel *model = new CustomTableModel;
- //! [1]
-
- //! [2]
- // create table view and add model to it
- QTableView *tableView = new QTableView;
- tableView->setModel(model);
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
- tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
- tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
-#else
- tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
- tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
-#endif
- //! [2]
-
- //! [3]
- QChart *chart = new QChart;
- chart->setAnimationOptions(QChart::AllAnimations);
- //! [3]
-
- // series 1
- //! [4]
- QLineSeries *series = new QLineSeries;
- series->setName("Line 1");
- QVXYModelMapper *mapper = new QVXYModelMapper(this);
- mapper->setXColumn(0);
- mapper->setYColumn(1);
- mapper->setSeries(series);
- mapper->setModel(model);
- chart->addSeries(series);
- //! [4]
-
- //! [5]
- // for storing color hex from the series
- QString seriesColorHex = "#000000";
-
- // get the color of the series and use it for showing the mapped area
- seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper();
- model->addMapping(seriesColorHex, QRect(0, 0, 2, model->rowCount()));
- //! [5]
-
-
- // series 2
- //! [6]
- QLineSeries *series2 = new QLineSeries;
- series2->setName("Line 2");
-
- mapper = new QVXYModelMapper(this);
- mapper->setXColumn(2);
- mapper->setYColumn(3);
- mapper->setSeries(series2);
- mapper->setModel(model);
- chart->addSeries(series2);
- //! [6]
-
- //! [7]
- // get the color of the series and use it for showing the mapped area
- seriesColorHex = "#" + QString::number(series2->pen().color().rgb(), 16).right(6).toUpper();
- model->addMapping(seriesColorHex, QRect(2, 0, 2, model->rowCount()));
- //! [7]
-
- //! [8]
- chart->createDefaultAxes();
-
- m_axis = new QLogValueAxis;
- chart->addAxis(m_axis, Qt::AlignRight);
- chart->setAxisY(m_axis, series);
- chart->setAxisY(m_axis, series2);
-// series->attachAxis(m_axis);
-// series2->attachAxis(m_axis);
-
-
- QChartView *chartView = new QChartView(chart);
- chartView->setRenderHint(QPainter::Antialiasing);
- chartView->setMinimumSize(640, 480);
- //! [8]
-
- m_logBaseSpinBox = new QDoubleSpinBox;
- m_logBaseSpinBox->setRange(0.01, 100.0);
-
- connect(m_logBaseSpinBox, SIGNAL(valueChanged(double)), this, SLOT(logBaseChanged(double)));
-
- QLineEdit *format = new QLineEdit;
- connect(format, SIGNAL(textEdited(QString)), this, SLOT(formatChanged(QString)));
-
- //! [9]
- // create main layout
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->addWidget(tableView, 1, 0);
- mainLayout->addWidget(chartView, 1, 1);
- mainLayout->addWidget(m_logBaseSpinBox, 1, 2);
- mainLayout->addWidget(format, 1, 3);
- mainLayout->setColumnStretch(1, 1);
- mainLayout->setColumnStretch(0, 0);
- setLayout(mainLayout);
- //! [9]
-}
-
-void TableWidget::logBaseChanged(double base)
-{
- m_axis->setBase(base);
-}
-
-void TableWidget::formatChanged(const QString& format)
-{
- m_axis->setLabelFormat(format);
-// m_axis->setFormat(format);
-}
diff --git a/examples/logaxis/tablewidget.h b/examples/logaxis/tablewidget.h
deleted file mode 100644
index 77a428b1..00000000
--- a/examples/logaxis/tablewidget.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef TABLEWIDGET_H
-#define TABLEWIDGET_H
-
-#include <QWidget>
-#include <QChartGlobal>
-
-class QDoubleSpinBox;
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-class QChart;
-class QLogValueAxis;
-class QDateTimeAxis;
-QTCOMMERCIALCHART_END_NAMESPACE
-
-QTCOMMERCIALCHART_USE_NAMESPACE
-
-class TableWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- TableWidget(QWidget *parent = 0);
-
-public slots:
- void logBaseChanged(double base);
- void formatChanged(const QString& format);
-
-private:
- QDoubleSpinBox *m_logBaseSpinBox;
- QLogValueAxis *m_axis;
-// QDateTimeAxis *m_axis;
-
-};
-
-#endif // TABLEWIDGET_H