• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
RenderPlugin.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2008 Torsten Rahn <rahn@kde.org>
9 // Copyright 2008 Inge Wallin <inge@lysator.liu.se>
10 // Copyright 2011,2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
11 // Copyright 2012 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
12 //
13 
14 // Self
15 #include "RenderPlugin.h"
16 
17 // Marble
18 #include "DialogConfigurationInterface.h"
19 #include "MarbleModel.h"
20 #include "MarbleDebug.h"
21 #include "RenderPluginModel.h"
22 
23 // Qt
24 #include <QAction>
25 #include <QStandardItem>
26 
27 
28 namespace Marble
29 {
30 
31 class RenderPlugin::Private
32 {
33  public:
34  Private( const MarbleModel *marbleModel )
35  : m_marbleModel( marbleModel ),
36  m_action(0),
37  m_item(),
38  m_enabled(true),
39  m_visible(true),
40  m_userCheckable(true)
41  {
42  }
43 
44  ~Private()
45  {
46  }
47 
48  // const: RenderPlugins should only read the model, not modify it
49  const MarbleModel *const m_marbleModel;
50 
51  QAction m_action;
52  QStandardItem m_item;
53 
54  bool m_enabled;
55  bool m_visible;
56  bool m_userCheckable;
57 };
58 
59 
60 RenderPlugin::RenderPlugin( const MarbleModel *marbleModel )
61  : d( new Private( marbleModel ) )
62 {
63  connect( &d->m_action, SIGNAL( toggled( bool ) ),
64  this, SLOT( setVisible( bool ) ) );
65  connect( this, SIGNAL( visibilityChanged( bool, const QString & ) ),
66  &d->m_action, SLOT( setChecked( bool ) ) );
67  connect( this, SIGNAL( enabledChanged( bool ) ),
68  &d->m_action, SLOT( setVisible( bool ) ) );
69  connect( this, SIGNAL( enabledChanged( bool ) ),
70  SIGNAL( actionGroupsChanged() ) );
71 
72  connect( this, SIGNAL(visibilityChanged(bool,QString)),
73  this, SIGNAL(repaintNeeded()) );
74  connect( this, SIGNAL(settingsChanged(QString)),
75  this, SIGNAL(repaintNeeded()) );
76 }
77 
78 RenderPlugin::~RenderPlugin()
79 {
80  delete d;
81 }
82 
83 const MarbleModel* RenderPlugin::marbleModel() const
84 {
85  return d->m_marbleModel;
86 }
87 
88 QAction* RenderPlugin::action() const
89 {
90  d->m_action.setCheckable( true );
91  d->m_action.setChecked( visible() );
92  d->m_action.setIcon( icon() );
93  d->m_action.setText( guiString() );
94  d->m_action.setToolTip( description() );
95  return &d->m_action;
96 }
97 
98 const QList<QActionGroup*>* RenderPlugin::actionGroups() const
99 {
100  return 0;
101 }
102 
103 const QList<QActionGroup*>* RenderPlugin::toolbarActionGroups() const
104 {
105  return 0;
106 }
107 
108 QStandardItem* RenderPlugin::item()
109 {
110  d->m_item.setIcon( icon() );
111  d->m_item.setText( name() );
112  d->m_item.setEditable( false );
113  d->m_item.setCheckable( true );
114  d->m_item.setCheckState( enabled() ? Qt::Checked : Qt::Unchecked );
115  d->m_item.setToolTip( description() );
116  d->m_item.setFlags( d->m_item.flags() & ~Qt::ItemIsSelectable );
117 
118  // Custom data
119  d->m_item.setData( nameId(), RenderPluginModel::NameId );
120  d->m_item.setData( (bool) qobject_cast<DialogConfigurationInterface *>( this ), RenderPluginModel::ConfigurationDialogAvailable );
121  d->m_item.setData( backendTypes(), RenderPluginModel::BackendTypes );
122  d->m_item.setData( version(), RenderPluginModel::Version );
123  d->m_item.setData( aboutDataText(), RenderPluginModel::AboutDataText );
124  d->m_item.setData( copyrightYears(), RenderPluginModel::CopyrightYears );
125 
126  return &d->m_item;
127 }
128 
129 void RenderPlugin::applyItemState()
130 {
131  setEnabled( d->m_item.checkState() == Qt::Checked );
132 }
133 
134 void RenderPlugin::retrieveItemState()
135 {
136  d->m_item.setCheckState( enabled() ? Qt::Checked : Qt::Unchecked );
137 }
138 
139 void RenderPlugin::setEnabled( bool enabled )
140 {
141  if ( enabled == d->m_enabled )
142  return;
143 
144  d->m_enabled = enabled;
145 
146  d->m_item.setCheckState( enabled ? Qt::Checked : Qt::Unchecked );
147 
148  emit enabledChanged( enabled );
149 }
150 
151 void RenderPlugin::setVisible( bool visible )
152 {
153  if ( visible == d->m_visible )
154  return;
155 
156  d->m_visible = visible;
157 
158  emit visibilityChanged( visible, nameId() );
159 }
160 
161 void RenderPlugin::setUserCheckable( bool checkable )
162 {
163  if ( checkable != d->m_userCheckable ) {
164  d->m_action.setEnabled( checkable );
165  d->m_userCheckable = checkable;
166  emit userCheckableChanged( checkable );
167  }
168 }
169 
170 bool RenderPlugin::enabled() const
171 {
172  return d->m_enabled;
173 }
174 
175 bool RenderPlugin::visible() const
176 {
177  return d->m_visible;
178 }
179 
180 bool RenderPlugin::isUserCheckable() const
181 {
182  return d->m_userCheckable;
183 }
184 
185 QHash<QString,QVariant> RenderPlugin::settings() const
186 {
187  QHash<QString,QVariant> result;
188 
189  result.insert( "enabled", enabled() );
190  result.insert( "visible", visible() );
191 
192  return result;
193 }
194 
195 void RenderPlugin::setSettings( const QHash<QString,QVariant> &settings )
196 {
197  setEnabled( settings.value( "enabled", enabled() ).toBool() );
198  setVisible( settings.value( "visible", visible() ).toBool() );
199 }
200 
201 RenderPlugin::RenderType RenderPlugin::renderType() const
202 {
203  return UnknownRenderType;
204 }
205 
206 RenderState RenderPlugin::renderState() const
207 {
208  return RenderState( name() );
209 }
210 
211 QString RenderPlugin::runtimeTrace() const
212 {
213  return name();
214 }
215 
216 bool RenderPlugin::eventFilter( QObject *, QEvent * )
217 {
218  return false;
219 }
220 
221 void RenderPlugin::restoreDefaultSettings()
222 {
223  setSettings( QHash<QString,QVariant>() );
224 }
225 
226 QStringList RenderPlugin::settingKeys() const
227 {
228  return settings().keys();
229 }
230 
231 bool RenderPlugin::setSetting( const QString & key, const QVariant & value )
232 {
233  QHash< QString, QVariant> settings = this->settings();
234  if( settings.contains( key ) && settings.value( key ).type() == value.type() )
235  {
236  settings [ key ] = value;
237  setSettings( settings );
238  return true;
239  } else {
240  return false;
241  }
242 }
243 
244 QVariant RenderPlugin::setting( const QString & name ) const
245 {
246  return settings().value( name, QVariant() );
247 }
248 
249 } // namespace Marble
250 
251 #include "RenderPlugin.moc"
Marble::PluginInterface::aboutDataText
virtual QString aboutDataText() const
Returns about text (credits) for external data the plugin uses.
Definition: PluginInterface.cpp:20
Marble::RenderPlugin::visible
bool visible() const
is visible
QEvent
Marble::RenderPluginModel::AboutDataText
Definition: RenderPluginModel.h:46
QHash::insert
iterator insert(const Key &key, const T &value)
RenderPluginModel.h
Marble::RenderPlugin::setSetting
bool setSetting(const QString &key, const QVariant &value)
Change setting key's values.
Definition: RenderPlugin.cpp:231
Marble::RenderPlugin::repaintNeeded
void repaintNeeded(QRegion dirtyRegion=QRegion())
This signal is emitted if an update of the view is needed.
Marble::RenderPlugin::setting
QVariant setting(const QString &key) const
Getting setting value from the settings.
Definition: RenderPlugin.cpp:244
Marble::RenderPlugin::renderState
RenderState renderState() const
Definition: RenderPlugin.cpp:206
Marble::RenderPlugin::eventFilter
bool eventFilter(QObject *, QEvent *)
Definition: RenderPlugin.cpp:216
MarbleModel.h
This file contains the headers for MarbleModel.
Marble::RenderPluginModel::NameId
Definition: RenderPluginModel.h:42
Marble::RenderPluginModel::Version
Definition: RenderPluginModel.h:45
Marble::RenderPlugin::restoreDefaultSettings
void restoreDefaultSettings()
Passes an empty set of settings to the plugin.
Definition: RenderPlugin.cpp:221
Marble::RenderPlugin::UnknownRenderType
Definition: RenderPlugin.h:60
Marble::RenderPlugin::action
QAction * action() const
Plugin's menu action.
Definition: RenderPlugin.cpp:88
Marble::RenderPluginModel::ConfigurationDialogAvailable
Definition: RenderPluginModel.h:43
MarbleDebug.h
Marble::RenderPluginInterface::backendTypes
virtual QStringList backendTypes() const =0
Returns the name(s) of the backend that the plugin can render This method should return the name of t...
Marble::PluginInterface::description
virtual QString description() const =0
Returns a user description of the plugin.
Marble::RenderPlugin::actionGroupsChanged
void actionGroupsChanged()
This signal is emitted if the actions that the plugin supports change in any way. ...
QObject::name
const char * name() const
Marble::RenderPlugin::userCheckableChanged
void userCheckableChanged(bool isUserCheckable)
This signal is emitted if the user checkable property is changed with.
Marble::RenderPlugin::toolbarActionGroups
virtual const QList< QActionGroup * > * toolbarActionGroups() const
Getting all actions which should be placed in the toolbar.
Definition: RenderPlugin.cpp:103
QHash< QString, QVariant >
QObject
Marble::RenderPlugin::settingsChanged
void settingsChanged(QString nameId)
This signal is emitted if the settings of the RenderPlugin changed.
Marble::RenderPlugin::visibilityChanged
void visibilityChanged(bool visible, const QString &nameId)
This signal is emitted if the visibility is changed with.
DialogConfigurationInterface.h
Marble::RenderPlugin::setVisible
void setVisible(bool visible)
settting visible
Definition: RenderPlugin.cpp:151
QString
QList< QActionGroup * >
Marble::RenderPlugin::runtimeTrace
virtual QString runtimeTrace() const
Returns a debug line for perfo/tracing issues.
Definition: RenderPlugin.cpp:211
Marble::RenderState
Definition: RenderState.h:22
Marble::PluginInterface::nameId
virtual QString nameId() const =0
Returns the unique name of the plugin.
QStringList
QHash::keys
QList< Key > keys() const
Marble::RenderPlugin::settingKeys
QStringList settingKeys() const
Full list of the settings keys.
Definition: RenderPlugin.cpp:226
Marble::PluginInterface::version
virtual QString version() const =0
QHash::value
const T value(const Key &key) const
Marble::PluginInterface::copyrightYears
virtual QString copyrightYears() const =0
Marble::RenderPlugin::RenderPlugin
RenderPlugin(const MarbleModel *marbleModel)
Definition: RenderPlugin.cpp:60
Marble::RenderPlugin::actionGroups
virtual const QList< QActionGroup * > * actionGroups() const
Getting all actions.
Definition: RenderPlugin.cpp:98
Marble::RenderPlugin::setUserCheckable
void setUserCheckable(bool isUserCheckable)
settting user checkable
Definition: RenderPlugin.cpp:161
Marble::MarbleModel
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition: MarbleModel.h:97
Marble::PluginInterface::icon
virtual QIcon icon() const =0
Returns an icon for the plugin.
Marble::RenderPlugin::enabledChanged
void enabledChanged(bool enable)
This signal is emitted if the enabled property is changed with.
Marble::RenderPlugin::setEnabled
void setEnabled(bool enabled)
settting enabled
Definition: RenderPlugin.cpp:139
Marble::RenderPlugin::isUserCheckable
bool isUserCheckable() const
is user checkable
Definition: RenderPlugin.cpp:180
RenderPlugin.h
QAction
Marble::RenderPluginModel::BackendTypes
Definition: RenderPluginModel.h:44
QHash::contains
bool contains(const Key &key) const
Marble::RenderPlugin::enabled
bool enabled() const
is enabled
QStandardItem
Marble::RenderPlugin::~RenderPlugin
virtual ~RenderPlugin()
Definition: RenderPlugin.cpp:78
QVariant::type
Type type() const
Marble::RenderPlugin::marbleModel
const MarbleModel * marbleModel() const
Access to the MarbleModel.
Definition: RenderPlugin.cpp:83
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Marble::RenderPlugin::settings
virtual QHash< QString, QVariant > settings() const
Settings of the plugin.
Definition: RenderPlugin.cpp:185
Marble::RenderPlugin::guiString
virtual QString guiString() const =0
String that should be displayed in GUI.
Marble::RenderPlugin::RenderType
RenderType
A Type of plugin.
Definition: RenderPlugin.h:59
Marble::RenderPlugin::renderType
virtual RenderType renderType() const
Render type of the plugin.
Definition: RenderPlugin.cpp:201
Marble::RenderPlugin::setSettings
virtual void setSettings(const QHash< QString, QVariant > &settings)
Set the settings of the plugin.
Definition: RenderPlugin.cpp:195
Marble::RenderPluginModel::CopyrightYears
Definition: RenderPluginModel.h:47
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:41 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal