~ubuntu-branches/ubuntu/oneiric/qwt/oneiric-proposed

« back to all changes in this revision

Viewing changes to qwt/designer/qwtplugin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2009-07-01 16:08:21 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090701160821-gog44m4w7x2f4u6o
Tags: 5.2.0-1
* New upstream release.
* Add branch pull patch from svn r544.
* Bump Standards-Version to 3.8.2. No changes needed.
* Update installed manpages.
* Use qwt as base name for directory (drop version).
* Add missing warnings patch.
* Rewrite debian/rules: use dh.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 
2
 * Qwt Widget Library
 
3
 * Copyright (C) 1997   Josef Wilgen
 
4
 * Copyright (C) 2002   Uwe Rathmann
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the Qwt License, Version 1.0
 
8
 *****************************************************************************/
 
9
 
 
10
#if defined(_MSC_VER) /* MSVC Compiler */
 
11
#pragma warning ( disable : 4786 )
 
12
#endif
 
13
 
 
14
#include <qglobal.h>
 
15
#include <qvaluelist.h>
 
16
#include <qmime.h>
 
17
#include <qdragobject.h>
 
18
 
 
19
#include "qwtplugin.h"
 
20
#include "qwt_text_label.h"
 
21
 
 
22
#ifndef NO_QWT_PLOT
 
23
#include "qwt_plot.h"
 
24
#include "qwt_scale_widget.h"
 
25
#endif
 
26
 
 
27
#ifndef NO_QWT_WIDGETS
 
28
#include "qwt_counter.h"
 
29
#include "qwt_wheel.h"
 
30
#include "qwt_thermo.h"
 
31
#include "qwt_knob.h"
 
32
#include "qwt_slider.h"
 
33
#include "qwt_analog_clock.h"
 
34
#include "qwt_compass.h"
 
35
#endif
 
36
 
 
37
namespace
 
38
{
 
39
    struct Entry
 
40
    {
 
41
        Entry() {}
 
42
        Entry( QString _classname, QString _header, QString  _pixmap,
 
43
                QString _tooltip, QString _whatshis):       
 
44
                classname(_classname),
 
45
                header(_header),
 
46
                pixmap(_pixmap),
 
47
                tooltip(_tooltip),
 
48
                whatshis(_whatshis)
 
49
        {}
 
50
 
 
51
        QString classname;
 
52
        QString header;
 
53
        QString pixmap;
 
54
        QString tooltip;
 
55
        QString whatshis;
 
56
    };
 
57
 
 
58
    QValueList<Entry> vec;
 
59
 
 
60
    const Entry *entry(const QString& str)
 
61
    {
 
62
        for ( uint i = 0; i < vec.count(); i++ )
 
63
        {
 
64
            if (str == vec[i].classname)
 
65
                return &vec[i];
 
66
        }
 
67
        return NULL;
 
68
    }
 
69
}
 
70
 
 
71
QwtPlugin::QwtPlugin()
 
72
{
 
73
#ifndef NO_QWT_PLOT
 
74
    vec.append(Entry("QwtPlot", "qwt_plot.h",
 
75
        "qwtplot.png", "QwtPlot", "whatsthis"));
 
76
    vec.append(Entry("QwtScaleWidget", "qwt_scale_widget.h",
 
77
        "qwtscale.png", "QwtScaleWidget", "whatsthis"));
 
78
#endif
 
79
 
 
80
#ifndef NO_QWT_WIDGETS
 
81
    vec.append(Entry("QwtAnalogClock", "qwt_analog_clock.h", 
 
82
        "qwtanalogclock.png", "QwtAnalogClock", "whatsthis"));
 
83
    vec.append(Entry("QwtCompass", "qwt_compass.h",
 
84
        "qwtcompass.png", "QwtCompass", "whatsthis"));
 
85
    vec.append(Entry("QwtCounter", "qwt_counter.h", 
 
86
        "qwtcounter.png", "QwtCounter", "whatsthis"));
 
87
    vec.append(Entry("QwtDial", "qwt_dial.h", 
 
88
        "qwtdial.png", "QwtDial", "whatsthis"));
 
89
    vec.append(Entry("QwtKnob", "qwt_knob.h",
 
90
        "qwtknob.png", "QwtKnob", "whatsthis"));
 
91
    vec.append(Entry("QwtSlider", "qwt_slider.h",
 
92
        "qwtslider.png", "QwtSlider", "whatsthis"));
 
93
    vec.append(Entry("QwtThermo", "qwt_thermo.h",
 
94
        "qwtthermo.png", "QwtThermo", "whatsthis"));
 
95
    vec.append(Entry("QwtWheel", "qwt_wheel.h",
 
96
        "qwtwheel.png", "QwtWheel", "whatsthis"));
 
97
#endif
 
98
 
 
99
    vec.append(Entry("QwtTextLabel", "qwt_text_label.h", 
 
100
        "qwtwidget.png", "QwtTextLabel", "whatsthis"));
 
101
 
 
102
}
 
103
 
 
104
QWidget* QwtPlugin::create(const QString &key, 
 
105
    QWidget* parent, const char* name)
 
106
{
 
107
    QWidget *w = NULL;
 
108
 
 
109
#ifndef NO_QWT_PLOT
 
110
    if ( key == "QwtPlot" )
 
111
        w = new QwtPlot( parent );
 
112
    else if ( key == "QwtScaleWidget" )
 
113
        w = new QwtScaleWidget( QwtScaleDraw::LeftScale, parent);
 
114
#endif
 
115
 
 
116
#ifndef NO_QWT_WIDGETS
 
117
    if ( key == "QwtAnalogClock" )
 
118
        w = new QwtAnalogClock( parent);
 
119
    else if ( key == "QwtCounter" )
 
120
        w = new QwtCounter( parent);
 
121
    else if ( key == "QwtCompass" )
 
122
        w = new QwtCompass( parent);
 
123
    else if ( key == "QwtDial" )
 
124
        w = new QwtDial( parent);
 
125
    else if ( key == "QwtWheel" )
 
126
        w = new QwtWheel( parent);
 
127
    else if ( key == "QwtThermo" )
 
128
        w = new QwtThermo( parent);
 
129
    else if ( key == "QwtKnob" )
 
130
        w = new QwtKnob( parent);
 
131
    else if ( key == "QwtSlider" )
 
132
        w = new QwtSlider( parent);
 
133
#endif
 
134
 
 
135
    if ( key == "QwtTextLabel" )
 
136
        w = new QwtTextLabel( parent);
 
137
 
 
138
    if ( w )
 
139
        w->setName(name);
 
140
 
 
141
    return w;
 
142
}
 
143
 
 
144
QStringList QwtPlugin::keys() const
 
145
{
 
146
    QStringList list;
 
147
    
 
148
    for (unsigned i = 0; i < vec.count(); i++)
 
149
        list += vec[i].classname;
 
150
 
 
151
    return list;
 
152
}
 
153
 
 
154
QString QwtPlugin::group( const QString& feature ) const
 
155
{
 
156
    if (entry(feature) != NULL )
 
157
        return QString("Qwt"); 
 
158
    return QString::null;
 
159
}
 
160
 
 
161
QIconSet QwtPlugin::iconSet( const QString& pmap) const
 
162
{
 
163
    QString pixmapKey("qwtwidget.png");
 
164
    if (entry(pmap) != NULL )
 
165
        pixmapKey = entry(pmap)->pixmap;
 
166
 
 
167
    const QMimeSource *ms =
 
168
        QMimeSourceFactory::defaultFactory()->data(pixmapKey);
 
169
 
 
170
    QPixmap pixmap;
 
171
    QImageDrag::decode(ms, pixmap);
 
172
 
 
173
    return QIconSet(pixmap);
 
174
}
 
175
 
 
176
QString QwtPlugin::includeFile( const QString& feature ) const
 
177
{
 
178
    if (entry(feature) != NULL)
 
179
        return entry(feature)->header;        
 
180
    return QString::null;
 
181
}
 
182
 
 
183
QString QwtPlugin::toolTip( const QString& feature ) const
 
184
{
 
185
    if (entry(feature) != NULL )
 
186
        return entry(feature)->tooltip;       
 
187
    return QString::null;
 
188
}
 
189
 
 
190
QString QwtPlugin::whatsThis( const QString& feature ) const
 
191
{
 
192
    if (entry(feature) != NULL)
 
193
        return entry(feature)->whatshis;      
 
194
    return QString::null;
 
195
}
 
196
 
 
197
bool QwtPlugin::isContainer( const QString& ) const
 
198
{
 
199
    return false;
 
200
}
 
201
 
 
202
Q_EXPORT_PLUGIN( QwtPlugin )