• 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
RenderPluginModel.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 2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
9 //
10 
11 #include "RenderPluginModel.h"
12 
13 #include "DialogConfigurationInterface.h"
14 #include "RenderPlugin.h"
15 
16 namespace Marble
17 {
18 
19 class RenderPluginModel::Private
20 {
21 public:
22  Private();
23 
24  static bool renderPluginGuiStringLessThan( RenderPlugin* one, RenderPlugin* two )
25  {
26  // Sort by gui string ignoring keyboard accelerators
27  return one->guiString().remove( QLatin1Char( '&' ) ) < two->guiString().remove( QLatin1Char( '&' ) );
28  }
29 
30  QList<RenderPlugin *> m_renderPlugins;
31 };
32 
33 RenderPluginModel::Private::Private() :
34  m_renderPlugins()
35 {
36 }
37 
38 RenderPluginModel::RenderPluginModel( QObject *parent ) :
39  QStandardItemModel( parent ),
40  d( new Private )
41 {
42 }
43 
44 RenderPluginModel::~RenderPluginModel()
45 {
46  // our model doesn't own the items, so take them away
47  while ( invisibleRootItem()->hasChildren() ) {
48  invisibleRootItem()->takeRow( 0 );
49  }
50 
51  delete d;
52 }
53 
54 void RenderPluginModel::setRenderPlugins( const QList<RenderPlugin *> &renderPlugins )
55 {
56  // our model doesn't own the items, so take them away
57  while ( invisibleRootItem()->hasChildren() ) {
58  invisibleRootItem()->takeRow( 0 );
59  }
60 
61  d->m_renderPlugins = renderPlugins;
62  qSort( d->m_renderPlugins.begin(), d->m_renderPlugins.end(), Private::renderPluginGuiStringLessThan );
63 
64  QStandardItem *parentItem = invisibleRootItem();
65  foreach ( RenderPlugin *plugin, d->m_renderPlugins ) {
66  parentItem->appendRow( plugin->item() );
67  }
68 }
69 
70 QList<PluginAuthor> RenderPluginModel::pluginAuthors( const QModelIndex &index ) const
71 {
72  if ( !index.isValid() )
73  return QList<PluginAuthor>();
74 
75  if ( index.row() < 0 || index.row() >= d->m_renderPlugins.count() )
76  return QList<PluginAuthor>();
77 
78  return d->m_renderPlugins.at( index.row() )->pluginAuthors();
79 }
80 
81 DialogConfigurationInterface *RenderPluginModel::pluginDialogConfigurationInterface( const QModelIndex &index )
82 {
83  if ( !index.isValid() )
84  return 0;
85 
86  if ( index.row() < 0 || index.row() >= d->m_renderPlugins.count() )
87  return 0;
88 
89  RenderPlugin *plugin = d->m_renderPlugins.at( index.row() );
90  return qobject_cast<DialogConfigurationInterface *>( plugin );
91 }
92 
93 void RenderPluginModel::retrievePluginState()
94 {
95  foreach ( RenderPlugin *plugin, d->m_renderPlugins ) {
96  plugin->retrieveItemState();
97  }
98 }
99 
100 void RenderPluginModel::applyPluginState()
101 {
102  foreach ( RenderPlugin *plugin, d->m_renderPlugins ) {
103  plugin->applyItemState();
104  }
105 }
106 
107 }
108 
109 #include "RenderPluginModel.moc"
RenderPluginModel.h
Marble::DialogConfigurationInterface
This interface allows a plugin to provide a QWidget-based configuration dialog which is accessible wi...
Definition: DialogConfigurationInterface.h:31
Marble::RenderPluginModel::~RenderPluginModel
~RenderPluginModel()
Definition: RenderPluginModel.cpp:44
QObject
Marble::RenderPluginModel::Private
friend class Private
Definition: RenderPluginModel.h:82
Marble::RenderPluginModel::RenderPluginModel
RenderPluginModel(QObject *parent=0)
Definition: RenderPluginModel.cpp:38
Marble::RenderPluginModel::setRenderPlugins
void setRenderPlugins(const QList< RenderPlugin * > &renderPlugins)
Set the RenderPlugins the model should manage.
Definition: RenderPluginModel.cpp:54
DialogConfigurationInterface.h
Marble::RenderPluginModel::retrievePluginState
void retrievePluginState()
Retrieve the current plugin state for the user interface.
Definition: RenderPluginModel.cpp:93
Marble::RenderPluginModel::pluginAuthors
QList< PluginAuthor > pluginAuthors(const QModelIndex &index) const
Definition: RenderPluginModel.cpp:70
RenderPlugin.h
Marble::RenderPluginModel::applyPluginState
void applyPluginState()
Apply the plugin state from the user interface.
Definition: RenderPluginModel.cpp:100
Marble::RenderPluginModel::pluginDialogConfigurationInterface
DialogConfigurationInterface * pluginDialogConfigurationInterface(const QModelIndex &index)
Definition: RenderPluginModel.cpp:81
Marble::RenderPlugin
The abstract class that creates a renderable item.
Definition: RenderPlugin.h:43
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