1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
// vim: expandtab
#if defined(_MSC_VER) /* MSVC Compiler */
#pragma warning ( disable : 4786 )
#endif
#include <qvaluelist.h>
#include <qmime.h>
#include <qdragobject.h>
#include "qwtplugin.h"
#include "qwt_counter.h"
#include "qwt_plot.h"
#include "qwt_wheel.h"
#include "qwt_thermo.h"
#include "qwt_knob.h"
#include "qwt_scale.h"
#include "qwt_slider.h"
#include "qwt_analog_clock.h"
#include "qwt_compass.h"
namespace
{
struct Entry
{
Entry() {}
Entry( QString _classname, QString _header, QString _pixmap,
QString _tooltip, QString _whatshis):
classname(_classname),
header(_header),
pixmap(_pixmap),
tooltip(_tooltip),
whatshis(_whatshis)
{}
QString classname;
QString header;
QString pixmap;
QString tooltip;
QString whatshis;
};
QValueList<Entry> vec;
const Entry *entry(const QString& str)
{
for ( uint i = 0; i < vec.count(); i++ )
{
if (str == vec[i].classname)
return &vec[i];
}
return NULL;
}
}
QwtPlugin::QwtPlugin()
{
vec.append(Entry("QwtPlot", "qwt_plot.h",
"qwtplot.png", "QwtPlot", "whatsthis"));
vec.append(Entry("QwtAnalogClock", "qwt_analog_clock.h",
"qwtanalogclock.png", "QwtAnalogClock", "whatsthis"));
vec.append(Entry("QwtCompass", "qwt_compass.h",
"qwtcompass.png", "QwtCompass", "whatsthis"));
vec.append(Entry("QwtCounter", "qwt_counter.h",
"qwtcounter.png", "QwtCounter", "whatsthis"));
vec.append(Entry("QwtDial", "qwt_dial.h",
"qwtdial.png", "QwtDial", "whatsthis"));
vec.append(Entry("QwtKnob", "qwt_knob.h",
"qwtknob.png", "QwtKnob", "whatsthis"));
vec.append(Entry("QwtPushButton", "qwt_push_button.h",
"qwtpushbutton.png", "QwtPushButton", "whatsthis"));
vec.append(Entry("QwtScale", "qwt_scale.h",
"qwtscale.png", "QwtScale", "whatsthis"));
vec.append(Entry("QwtSlider", "qwt_slider.h",
"qwtslider.png", "QwtSlider", "whatsthis"));
vec.append(Entry("QwtThermo", "qwt_thermo.h",
"qwtthermo.png", "QwtThermo", "whatsthis"));
vec.append(Entry("QwtWheel", "qwt_wheel.h",
"qwtwheel.png", "QwtWheel", "whatsthis"));
}
QWidget* QwtPlugin::create(const QString &key,
QWidget* parent, const char* name)
{
if ( key == "QwtPlot" )
return new QwtPlot( parent, name );
else if ( key == "QwtAnalogClock" )
return new QwtAnalogClock( parent, name);
else if ( key == "QwtCounter" )
return new QwtCounter( parent, name);
else if ( key == "QwtCompass" )
return new QwtCompass( parent, name );
else if ( key == "QwtDial" )
return new QwtDial( parent, name);
else if ( key == "QwtPushButton" )
return new QwtPushButton(
QString::fromLatin1("E=mc<sup>2</sup>"), parent, name );
else if ( key == "QwtWheel" )
return new QwtWheel( parent, name );
else if ( key == "QwtThermo" )
return new QwtThermo( parent, name );
else if ( key == "QwtKnob" )
return new QwtKnob( parent, name );
else if ( key == "QwtScale" )
return new QwtScale( QwtScale::Left, parent, name );
else if ( key == "QwtSlider" )
return new QwtSlider( parent, name );
return 0;
}
QStringList QwtPlugin::keys() const
{
QStringList list;
for (unsigned i = 0; i < vec.count(); i++)
list += vec[i].classname;
return list;
}
QString QwtPlugin::group( const QString& feature ) const
{
if (entry(feature) != NULL )
return QString("Qwt");
return QString::null;
}
QIconSet QwtPlugin::iconSet( const QString& pmap) const
{
QString pixmapKey("qwtwidget.png");
if (entry(pmap) != NULL )
pixmapKey = entry(pmap)->pixmap;
const QMimeSource *ms =
QMimeSourceFactory::defaultFactory()->data(pixmapKey);
QPixmap pixmap;
QImageDrag::decode(ms, pixmap);
return QIconSet(pixmap);
}
QString QwtPlugin::includeFile( const QString& feature ) const
{
if (entry(feature) != NULL)
return entry(feature)->header;
return QString::null;
}
QString QwtPlugin::toolTip( const QString& feature ) const
{
if (entry(feature) != NULL )
return entry(feature)->tooltip;
return QString::null;
}
QString QwtPlugin::whatsThis( const QString& feature ) const
{
if (entry(feature) != NULL)
return entry(feature)->whatshis;
return QString::null;
}
bool QwtPlugin::isContainer( const QString& ) const
{
return FALSE;
}
Q_EXPORT_PLUGIN( QwtPlugin )
// Local Variables:
// mode: C++
// c-file-style: "stroustrup"
// indent-tabs-mode: nil
// End:
|