~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kchart/kdchart/examples/Polar/Parameters/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <QtGui>
2
 
#include <KDChartChart>
3
 
#include <KDChartPolarDiagram>
4
 
#include <KDChartDataValueAttributes>
5
 
 
6
 
using namespace KDChart;
7
 
 
8
 
class ChartWidget : public QWidget {
9
 
    Q_OBJECT
10
 
public:
11
 
    explicit ChartWidget(QWidget* parent=0)
12
 
        : QWidget(parent)
13
 
    {
14
 
 
15
 
        // initialize the ItemModel and fill in some data
16
 
        m_model.insertRows( 0, 10 );
17
 
        m_model.insertColumns(  0,  5 );
18
 
        int value = 0;
19
 
        for ( int column = 0; column < m_model.columnCount(); ++column ) {
20
 
            for ( int row = 0; row < m_model.rowCount(); ++row ) {
21
 
                QModelIndex index = m_model.index( row, column );
22
 
                m_model.setData( index, QVariant( value++  ) );
23
 
            }
24
 
        }
25
 
        // We need a Polar plane for the Polar type
26
 
        PolarCoordinatePlane* polarPlane = new PolarCoordinatePlane( &m_chart );
27
 
        // replace the default Cartesian plane with
28
 
        // our Polar plane
29
 
        m_chart.replaceCoordinatePlane( polarPlane );
30
 
 
31
 
        // assign the model to our polar diagram
32
 
        PolarDiagram* diagram = new PolarDiagram;
33
 
        diagram->setModel(&m_model);
34
 
 
35
 
        // Configure some Polar specifical attributes
36
 
 
37
 
        // Display data values
38
 
        // not implemented yet - disable for now
39
 
        const QFont font(QFont( "Comic", 10 ));
40
 
        const int colCount = diagram->model()->columnCount();
41
 
        for ( int iColumn = 0; iColumn<colCount; ++iColumn ) {
42
 
            DataValueAttributes dva( diagram->dataValueAttributes( iColumn ) );
43
 
            TextAttributes ta( dva.textAttributes() );
44
 
            ta.setRotation( 0 );
45
 
            ta.setFont( font );
46
 
            ta .setPen( QPen( Qt::gray  ) );
47
 
            ta.setVisible( true );
48
 
            dva.setTextAttributes( ta );
49
 
            dva.setVisible( true );
50
 
            diagram->setDataValueAttributes( iColumn, dva);
51
 
        }
52
 
 
53
 
 
54
 
        // Assign our diagram to the Chart
55
 
        m_chart.coordinatePlane()->replaceDiagram(diagram);
56
 
 
57
 
        QVBoxLayout* l = new QVBoxLayout(this);
58
 
        l->addWidget(&m_chart);
59
 
        m_chart.setGlobalLeadingTop( 5 );
60
 
        m_chart.setGlobalLeadingBottom( 5 );
61
 
        setLayout(l);
62
 
    }
63
 
 
64
 
private:
65
 
    Chart m_chart;
66
 
    QStandardItemModel m_model;
67
 
};
68
 
 
69
 
int main( int argc, char** argv ) {
70
 
    QApplication app( argc, argv );
71
 
 
72
 
    ChartWidget w;
73
 
    w.show();
74
 
 
75
 
    return app.exec();
76
 
}
77
 
 
78
 
#include "main.moc"