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

marble

  • sources
  • kde-4.12
  • 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,QString)),
66  &d->m_action, SLOT(setChecked(bool)) );
67  connect( this, SIGNAL(enabledChanged(bool)),
68  &d->m_action, SLOT(setVisible(bool)) );
69 
70  connect( this, SIGNAL(visibilityChanged(bool,QString)),
71  this, SIGNAL(repaintNeeded()) );
72  connect( this, SIGNAL(settingsChanged(QString)),
73  this, SIGNAL(repaintNeeded()) );
74 }
75 
76 RenderPlugin::~RenderPlugin()
77 {
78  delete d;
79 }
80 
81 const MarbleModel* RenderPlugin::marbleModel() const
82 {
83  return d->m_marbleModel;
84 }
85 
86 QAction* RenderPlugin::action() const
87 {
88  d->m_action.setCheckable( true );
89  d->m_action.setChecked( visible() );
90  d->m_action.setIcon( icon() );
91  d->m_action.setText( guiString() );
92  d->m_action.setToolTip( description() );
93  return &d->m_action;
94 }
95 
96 const QList<QActionGroup*>* RenderPlugin::actionGroups() const
97 {
98  return 0;
99 }
100 
101 const QList<QActionGroup*>* RenderPlugin::toolbarActionGroups() const
102 {
103  return 0;
104 }
105 
106 QStandardItem* RenderPlugin::item()
107 {
108  d->m_item.setIcon( icon() );
109  d->m_item.setText( name() );
110  d->m_item.setEditable( false );
111  d->m_item.setCheckable( true );
112  d->m_item.setCheckState( enabled() ? Qt::Checked : Qt::Unchecked );
113  d->m_item.setToolTip( description() );
114  d->m_item.setFlags( d->m_item.flags() & ~Qt::ItemIsSelectable );
115 
116  // Custom data
117  d->m_item.setData( nameId(), RenderPluginModel::NameId );
118  d->m_item.setData( (bool) qobject_cast<DialogConfigurationInterface *>( this ), RenderPluginModel::ConfigurationDialogAvailable );
119  d->m_item.setData( backendTypes(), RenderPluginModel::BackendTypes );
120  d->m_item.setData( version(), RenderPluginModel::Version );
121  d->m_item.setData( aboutDataText(), RenderPluginModel::AboutDataText );
122  d->m_item.setData( copyrightYears(), RenderPluginModel::CopyrightYears );
123 
124  return &d->m_item;
125 }
126 
127 void RenderPlugin::applyItemState()
128 {
129  setEnabled( d->m_item.checkState() == Qt::Checked );
130 }
131 
132 void RenderPlugin::retrieveItemState()
133 {
134  d->m_item.setCheckState( enabled() ? Qt::Checked : Qt::Unchecked );
135 }
136 
137 void RenderPlugin::setEnabled( bool enabled )
138 {
139  if ( enabled == d->m_enabled )
140  return;
141 
142  d->m_enabled = enabled;
143 
144  d->m_item.setCheckState( enabled ? Qt::Checked : Qt::Unchecked );
145 
146  emit enabledChanged( enabled );
147 }
148 
149 void RenderPlugin::setVisible( bool visible )
150 {
151  if ( visible == d->m_visible )
152  return;
153 
154  d->m_visible = visible;
155 
156  emit visibilityChanged( visible, nameId() );
157 }
158 
159 void RenderPlugin::setUserCheckable( bool checkable )
160 {
161  if ( checkable != d->m_userCheckable ) {
162  d->m_action.setEnabled( checkable );
163  d->m_userCheckable = checkable;
164  emit userCheckableChanged( checkable );
165  }
166 }
167 
168 bool RenderPlugin::enabled() const
169 {
170  return d->m_enabled;
171 }
172 
173 bool RenderPlugin::visible() const
174 {
175  return d->m_visible;
176 }
177 
178 bool RenderPlugin::isUserCheckable() const
179 {
180  return d->m_userCheckable;
181 }
182 
183 QHash<QString,QVariant> RenderPlugin::settings() const
184 {
185  QHash<QString,QVariant> result;
186 
187  result.insert( "enabled", enabled() );
188  result.insert( "visible", visible() );
189 
190  return result;
191 }
192 
193 void RenderPlugin::setSettings( const QHash<QString,QVariant> &settings )
194 {
195  setEnabled( settings.value( "enabled", enabled() ).toBool() );
196  setVisible( settings.value( "visible", visible() ).toBool() );
197 }
198 
199 RenderPlugin::RenderType RenderPlugin::renderType() const
200 {
201  return UnknownRenderType;
202 }
203 
204 QString RenderPlugin::runtimeTrace() const
205 {
206  return name();
207 }
208 
209 bool RenderPlugin::eventFilter( QObject *, QEvent * )
210 {
211  return false;
212 }
213 
214 void RenderPlugin::restoreDefaultSettings()
215 {
216  setSettings( QHash<QString,QVariant>() );
217 }
218 
219 QStringList RenderPlugin::settingKeys()
220 {
221  return settings().keys();
222 }
223 
224 bool RenderPlugin::setSetting( const QString & key, const QVariant & value )
225 {
226  QHash< QString, QVariant> settings = this->settings();
227  if( settings.contains( key ) && settings.value( key ).type() == value.type() )
228  {
229  settings [ key ] = value;
230  setSettings( settings );
231  return true;
232  } else {
233  return false;
234  }
235 }
236 
237 QVariant RenderPlugin::setting( const QString & name )
238 {
239  return settings().value( name, QVariant() );
240 }
241 
242 } // namespace Marble
243 
244 #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
Marble::RenderPluginModel::AboutDataText
Definition: RenderPluginModel.h:46
RenderPluginModel.h
Marble::RenderPlugin::setSetting
bool setSetting(const QString &key, const QVariant &value)
Change setting key's values.
Definition: RenderPlugin.cpp:224
Marble::RenderPlugin::repaintNeeded
void repaintNeeded(QRegion dirtyRegion=QRegion())
This signal is emitted if an update of the view is needed.
Marble::RenderPlugin::eventFilter
bool eventFilter(QObject *, QEvent *)
Definition: RenderPlugin.cpp:209
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:214
Marble::RenderPlugin::UnknownRenderType
Definition: RenderPlugin.h:60
Marble::RenderPlugin::action
QAction * action() const
Plugin's menu action.
Definition: RenderPlugin.cpp:86
Marble::RenderPluginModel::ConfigurationDialogAvailable
Definition: RenderPluginModel.h:43
QObject
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::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:101
Marble::RenderPlugin::setting
QVariant setting(const QString &key)
Getting setting value from the settings.
Definition: RenderPlugin.cpp:237
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:149
Marble::RenderPlugin::runtimeTrace
virtual QString runtimeTrace() const
Returns a debug line for perfo/tracing issues.
Definition: RenderPlugin.cpp:204
Marble::PluginInterface::nameId
virtual QString nameId() const =0
Returns the unique name of the plugin.
Marble::PluginInterface::version
virtual QString version() const =0
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:96
Marble::RenderPlugin::setUserCheckable
void setUserCheckable(bool isUserCheckable)
settting user checkable
Definition: RenderPlugin.cpp:159
Marble::MarbleModel
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition: MarbleModel.h:96
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:137
Marble::RenderPlugin::isUserCheckable
bool isUserCheckable() const
is user checkable
Definition: RenderPlugin.cpp:178
RenderPlugin.h
Marble::RenderPluginModel::BackendTypes
Definition: RenderPluginModel.h:44
Marble::PluginInterface::name
virtual QString name() const =0
Returns the user-visible name of the plugin.
Marble::RenderPlugin::enabled
bool enabled() const
is enabled
Marble::RenderPlugin::~RenderPlugin
virtual ~RenderPlugin()
Definition: RenderPlugin.cpp:76
Marble::RenderPlugin::settingKeys
QStringList settingKeys()
Full list of the settings keys.
Definition: RenderPlugin.cpp:219
Marble::RenderPlugin::marbleModel
const MarbleModel * marbleModel() const
Access to the MarbleModel.
Definition: RenderPlugin.cpp:81
Marble::RenderPlugin::settings
virtual QHash< QString, QVariant > settings() const
Settings of the plugin.
Definition: RenderPlugin.cpp:183
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:199
Marble::RenderPlugin::setSettings
virtual void setSettings(const QHash< QString, QVariant > &settings)
Set the settings of the plugin.
Definition: RenderPlugin.cpp:193
Marble::RenderPluginModel::CopyrightYears
Definition: RenderPluginModel.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:52 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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