[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/marble/src/lib/geodata/scene
From:       Torsten Rahn <tackat () kde ! org>
Date:       2008-04-04 20:35:37
Message-ID: 1207341337.616269.19018.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 793695 by rahn:

- Bugfix



 M  +46 -0     GeoSceneLayer.cpp  
 M  +21 -1     GeoSceneLayer.h  


--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneLayer.cpp #793694:793695
@@ -34,6 +34,52 @@
     /* NOOP */
 }
 
+void GeoSceneLayer::addDataset( GeoSceneAbstractDataset* dataset )
+{
+    // Remove any dataset that has the same name
+    QVector<GeoSceneAbstractDataset*>::iterator it = m_datasets.begin();
+    while (it != m_datasets.end()) {
+        GeoSceneAbstractDataset* currentAbstractDataset = *it;
+        if ( currentAbstractDataset->name() == dataset->name() ) {
+            delete currentAbstractDataset;
+            it = m_datasets.erase(it);
+        }
+        else {
+            ++it;
+        }
+     }
+
+    if ( dataset ) {
+        m_datasets.append( dataset );
+    }
+}
+
+GeoSceneAbstractDataset* GeoSceneLayer::dataset( const QString& name )
+{
+    GeoSceneAbstractDataset* dataset = 0;
+
+    QVector<GeoSceneAbstractDataset*>::const_iterator it = m_datasets.begin();
+    for (it = m_datasets.begin(); it != m_datasets.end(); ++it) {
+        if ( (*it)->name() == name )
+            dataset = *it;
+    }
+
+    if ( dataset ) {
+        Q_ASSERT(dataset->name() == name);
+        return dataset;
+    }
+
+//    dataset = new GeoSceneAbstractDataset( name );
+    addDataset( dataset );
+
+    return dataset;
+}
+
+QVector<GeoSceneAbstractDataset*> GeoSceneLayer::datasets() const
+{
+    return m_datasets;
+}
+
 QString GeoSceneLayer::name() const
 {
     return m_name;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneLayer.h #793694:793695
@@ -29,6 +29,14 @@
 
 
 /**
+ * @short Contents used inside a layer.
+ */
+class GeoSceneAbstractDataset {
+ public:
+    virtual QString name() const;
+};
+
+/**
  * @short Layer of a GeoScene document.
  */
 
@@ -37,6 +45,14 @@
     GeoSceneLayer( const QString& name );
     ~GeoSceneLayer();
 
+    /**
+     * @brief  Add a section to the legend
+     * @param  section  the new section
+     */
+    void addDataset( GeoSceneAbstractDataset* );
+    GeoSceneAbstractDataset* dataset( const QString& );
+    QVector<GeoSceneAbstractDataset*> datasets() const;
+
     QString name() const;
 
     QString plugin() const;
@@ -46,10 +62,14 @@
     void setType( const QString& type );
 
  protected:
+    /// The vector holding all the data in the layer.
+    /// (We want to preserve the order and don't care 
+    /// much about speed here), so we don't use a hash
+    QVector<GeoSceneAbstractDataset*> m_datasets;
+
     QString m_name;
     QString m_plugin;
     QString m_type;
 };
 
-
 #endif // GEOSCENELAYER_H
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic