videocollection/tsrc/stubs/src/testobjectstore.cpp
changeset 24 7d93ee07fb27
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/tsrc/stubs/src/testobjectstore.cpp	Thu May 27 12:53:14 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+#include "testobjectstore.h"
+
+TestObjectStore::TestObjectStore()
+{
+    
+}
+
+TestObjectStore::~TestObjectStore()
+{
+    while(!mObjects.isEmpty())
+    {
+        QObject *obj = mObjects.takeFirst();
+        delete obj;
+    }
+}
+
+TestObjectStore &TestObjectStore::instance()
+{
+    static TestObjectStore _store;
+    return _store;
+}
+
+void TestObjectStore::addObject(QObject *object)
+{
+    if(connect(object, SIGNAL(destroyed(QObject *)), this, SLOT(objectDestroyed(QObject *))))
+    {
+        mObjects.append(object);
+    }
+}
+
+void TestObjectStore::objectDestroyed(QObject *obj)
+{
+    if(obj)
+    {
+        disconnect(obj, SIGNAL(destroyed(QObject *)), this, SLOT(objectDestroyed(QObject *)));
+        mObjects.removeOne(obj);
+    }
+}