Theme Editor: Renderer now allows multiple viewports to share an identifier
authorbieber <bieber@a1c6a512-1295-4272-9138-f99709370657>
Thu, 24 Jun 2010 18:55:04 +0000 (24 18:55 +0000)
committerbieber <bieber@a1c6a512-1295-4272-9138-f99709370657>
Thu, 24 Jun 2010 18:55:04 +0000 (24 18:55 +0000)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27112 a1c6a512-1295-4272-9138-f99709370657

utils/themeeditor/graphics/rbscreen.cpp
utils/themeeditor/graphics/rbscreen.h

index a090c2f..d37050b 100644 (file)
@@ -70,8 +70,11 @@ RBScreen::~RBScreen()
 
     QMap<int, RBFont*>::iterator i;
     for(i = fonts.begin(); i != fonts.end(); i++)
-        if(*i)
-            delete (*i);
+        delete (*i);
+
+    QMap<QString, QList<RBViewport*>*>::iterator it;
+    for(it = namedViewports.begin(); it != namedViewports.end(); it++)
+        delete (*it);
 }
 
 QPainterPath RBScreen::shape() const
@@ -99,13 +102,30 @@ void RBScreen::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
     }
 }
 
+void RBScreen::loadViewport(QString name, RBViewport *view)
+{
+    QList<RBViewport*>* list;
+    if(namedViewports.value(name, 0) == 0)
+    {
+        list = new QList<RBViewport*>;
+        list->append(view);
+        namedViewports.insert(name, list);
+    }
+    else
+    {
+        list = namedViewports.value(name, 0);
+        list->append(view);
+    }
+}
+
 void RBScreen::showViewport(QString name)
 {
     if(namedViewports.value(name, 0) == 0)
         return;
 
-    namedViewports.value(name)->show();
-    update();
+    QList<RBViewport*>* list = namedViewports.value(name, 0);
+    for(int i = 0; i < list->count(); i++)
+        list->at(i)->show();
 }
 
 void RBScreen::loadFont(int id, RBFont* font)
@@ -143,11 +163,14 @@ void RBScreen::makeCustomUI(QString id)
 {
     if(namedViewports.value(id, 0) != 0)
     {
-        QMap<QString, RBViewport*>::iterator i;
+        QMap<QString, QList<RBViewport*>*>::iterator i;
         for(i = namedViewports.begin(); i != namedViewports.end(); i++)
-            (*i)->clearCustomUI();
-        namedViewports.value(id)->makeCustomUI();
-        namedViewports.value(id)->show();
+            for(int j = 0; j < (*i)->count(); j++)
+                (*i)->at(j)->clearCustomUI();
+        for(int i = 0; i < namedViewports.value(id)->count(); i++)
+            namedViewports.value(id)->at(i)->makeCustomUI();
+        for(int i = 0; i < namedViewports.value(id)->count(); i++)
+            namedViewports.value(id)->at(i)->show();
     }
 }
 
index 95a110a..f35aef6 100644 (file)
@@ -46,10 +46,7 @@ public:
     int getWidth() const{ return width; }
     int getHeight() const{ return height; }
 
-    void loadViewport(QString name, RBViewport* view)
-    {
-        namedViewports.insert(name, view);
-    }
+    void loadViewport(QString name, RBViewport* view);
     void showViewport(QString name);
 
     void loadImage(QString name, RBImage* image)
@@ -78,7 +75,7 @@ private:
 
     ProjectModel* project;
 
-    QMap<QString, RBViewport*> namedViewports;
+    QMap<QString, QList<RBViewport*>*> namedViewports;
     QMap<QString, RBImage*> images;
     QMap<QString, QString>* settings;
     QMap<int, RBFont*> fonts;