summaryrefslogtreecommitdiffstats
path: root/chalk/ui/kis_resourceserver.cc
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2021-05-23 20:48:35 +0900
committerMichele Calgaro <[email protected]>2021-05-29 15:16:28 +0900
commit8b78a8791bc539bcffe7159f9d9714d577cb3d7d (patch)
tree1328291f966f19a22d7b13657d3f01a588eb1083 /chalk/ui/kis_resourceserver.cc
parent95834e2bdc5e01ae1bd21ac0dfa4fa1d2417fae9 (diff)
downloadkoffice-8b78a8791bc539bcffe7159f9d9714d577cb3d7d.tar.gz
koffice-8b78a8791bc539bcffe7159f9d9714d577cb3d7d.zip
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'chalk/ui/kis_resourceserver.cc')
-rw-r--r--chalk/ui/kis_resourceserver.cc199
1 files changed, 0 insertions, 199 deletions
diff --git a/chalk/ui/kis_resourceserver.cc b/chalk/ui/kis_resourceserver.cc
deleted file mode 100644
index 3076bc00..00000000
--- a/chalk/ui/kis_resourceserver.cc
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * kis_resourceserver.cc - part of KImageShop
- *
- * Copyright (c) 1999 Matthias Elter <[email protected]>
- * Copyright (c) 2003 Patrick Julien <[email protected]>
- * Copyright (c) 2005 Sven Langkamp <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-#include <tqfileinfo.h>
-#include <tqstringlist.h>
-#include <tqthread.h>
-#include <tqdir.h>
-
-#include <kdebug.h>
-#include <tdeglobal.h>
-#include <kstandarddirs.h>
-#include <kinstance.h>
-
-#include "kis_resource.h"
-#include "kis_factory.h"
-#include "kis_generic_registry.h"
-#include "kis_resourceserver.h"
-#include "kis_brush.h"
-#include "kis_imagepipe_brush.h"
-#include "kis_gradient.h"
-#include "kis_pattern.h"
-#include "kis_palette.h"
-#include <kogradientmanager.h>
-
-KisResourceServerBase::KisResourceServerBase(TQString type)
- : m_type(type), m_loaded(false)
-{
-}
-
-KisResourceServerBase::~KisResourceServerBase()
-{
-}
-
-void KisResourceServerBase::loadResources(TQStringList filenames)
-{
- TQStringList uniqueFiles;
-
- while( !filenames.empty() )
- {
-
- TQString front = *filenames.begin();
- filenames.pop_front();
-
- TQString fname = TQFileInfo(front).fileName();
- //ebug() << "Loading " << fname << "\n";
- // XXX: Don't load resources with the same filename. Actually, we should look inside
- // the resource to find out whether they are really the same, but for now this
- // will prevent the same brush etc. showing up twice.
- if (uniqueFiles.empty() || uniqueFiles.find(fname) == uniqueFiles.end()) {
- uniqueFiles.append(fname);
- KisResource *resource;
- resource = createResource(front);
- if(resource->load() && resource->valid())
- {
- m_resources.append(resource);
- TQ_CHECK_PTR(resource);
- emit resourceAdded(resource);
- }
- else {
- delete resource;
- }
- }
- }
- m_loaded = true;
-}
-
-TQValueList<KisResource*> KisResourceServerBase::resources()
-{
- if(!m_loaded) {
- return TQValueList<KisResource*>();
- }
-
- return m_resources;
-}
-
-void KisResourceServerBase::addResource(KisResource* resource)
-{
- if (!resource->valid()) {
- kdWarning(41001) << "Tried to add an invalid resource!" << endl;
- return;
- }
-
- m_resources.append(resource);
- emit resourceAdded(resource);
-}
-
-
-class ResourceLoaderThread : public TQThread {
-
-public:
-
- ResourceLoaderThread(KisResourceServerBase * server, TQStringList files)
- : TQThread()
- , m_server(server)
- , m_fileNames( files )
- {
- }
-
-
- void run()
- {
- m_server->loadResources(m_fileNames);
- }
-
-private:
-
- KisResourceServerBase * m_server;
- TQStringList m_fileNames;
-
-};
-
-TQStringList getFileNames( TQString extensions, TQString type )
-{
- TQStringList extensionList = TQStringList::split(":", extensions);
- TQStringList fileNames;
-
- TQStringList::Iterator it;
- for ( it = extensionList.begin(); it != extensionList.end(); ++it ) {
- TQString s = (*it);
- fileNames += KisFactory::instance()->dirs()->findAllResources(type.ascii(), (*it));
- }
- return fileNames;
-}
-
-
-KisResourceServerRegistry *KisResourceServerRegistry::m_singleton = 0;
-
-KisResourceServerRegistry::KisResourceServerRegistry()
-{
-
- KisResourceServer<KisBrush>* brushServer = new KisResourceServer<KisBrush>("kis_brushes");
- ResourceLoaderThread t1 (brushServer, getFileNames( "*.gbr","kis_brushes" ));
- t1.start();
-
- KisResourceServer<KisImagePipeBrush>* imagePipeBrushServer = new KisResourceServer<KisImagePipeBrush>("kis_brushes");
- ResourceLoaderThread t2 (imagePipeBrushServer, getFileNames( "*.gih", "kis_brushes"));
- t2.start();
-
- KisResourceServer<KisPattern>* patternServer = new KisResourceServer<KisPattern>("kis_patterns");
- ResourceLoaderThread t3 (patternServer, getFileNames("*.pat", "kis_patterns"));
- t3.start();
-
- KisResourceServer<KisGradient>* gradientServer = new KisResourceServer<KisGradient>("kis_gradients");
- ResourceLoaderThread t4 (gradientServer, getFileNames(KoGradientManager::filters().join( ":" ), "kis_gradients"));
- t4.start();
-
-
- KisResourceServer<KisPalette>* paletteServer = new KisResourceServer<KisPalette>("kis_palettes");
- ResourceLoaderThread t5 (paletteServer, getFileNames("*.gpl:*.pal:*.act", "kis_palettes") );
- t5.start();
-
- t1.wait();
- t2.wait();
- t3.wait();
- t4.wait();
- t5.wait();
-
- add( KisID( "BrushServer", ""), brushServer );
- add( KisID( "ImagePipeBrushServer", ""), imagePipeBrushServer );
- add( KisID( "PatternServer", ""), patternServer );
- add( KisID( "GradientServer", ""), gradientServer );
- add( KisID( "PaletteServer", ""), paletteServer );
-
-}
-
-KisResourceServerRegistry::~KisResourceServerRegistry()
-{
-}
-
-KisResourceServerRegistry* KisResourceServerRegistry::instance()
-{
- if(KisResourceServerRegistry::m_singleton == 0)
- {
- KisResourceServerRegistry::m_singleton = new KisResourceServerRegistry();
- }
- return KisResourceServerRegistry::m_singleton;
-}
-
-
-#include "kis_resourceserver.moc"
-