X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Fscriptlist.cpp;fp=src%2Fbase%2Fscriptlist.cpp;h=0000000000000000000000000000000000000000;hb=9f6ad3fe0b9cb30115a5d38e8af3aebed0d70c08;hp=4fc8d640d32895e141d3ee35ec959ef8b0b0558c;hpb=43c13b052d069ba435277d93867380d00c04931f;p=architektonas diff --git a/src/base/scriptlist.cpp b/src/base/scriptlist.cpp deleted file mode 100644 index 4fc8d64..0000000 --- a/src/base/scriptlist.cpp +++ /dev/null @@ -1,190 +0,0 @@ -// scriptlist.cpp -// -// Part of the Architektonas Project -// Originally part of QCad Community Edition by Andrew Mustun -// Extensively rewritten and refactored by James L. Hammons -// Portions copyright (C) 2001-2003 RibbonSoft -// Copyright (C) 2010 Underground Software -// See the README and GPLv2 files for licensing and warranty information -// -// JLH = James L. Hammons -// -// Who When What -// --- ---------- ----------------------------------------------------------- -// JLH 06/02/2010 Added this text. :-) -// - -#include "scriptlist.h" - -#include "system.h" - -ScriptList * ScriptList::uniqueInstance = NULL; - -/** - * Default constructor. - */ -ScriptList::ScriptList(): scriptIterator(scripts) -{ -//Should be dealt with... -//#warning "!!! Need to deal with setAutoDelete() Qt3->Qt4 !!!" -// scripts.setAutoDelete(true); - //init(); - //scriptListListeners.setAutoDelete(false); - //activeScript = NULL; -} - -/*virtual*/ ScriptList::~ScriptList() -{ - while (!scripts.isEmpty()) - delete scripts.takeFirst(); -} - -/** - * @return Instance to the unique script list. - */ -/*static*/ ScriptList * ScriptList::instance() -{ - if (uniqueInstance == NULL) - uniqueInstance = new ScriptList(); - - return uniqueInstance; -} - -/** - * Initializes the script list by creating Script - * objects, one for each script that could be found. - */ -void ScriptList::init() -{ - DEBUG->print("ScriptList::initScripts"); - - scripts.clear(); - QStringList list = SYSTEM->getScriptList(); - Script * script; - - for(QStringList::Iterator it=list.begin(); it!=list.end(); ++it) - { - DEBUG->print("script: %s:", (*it).toLatin1().data()); - - QFileInfo fi(*it); - script = new Script(fi.baseName(), fi.absoluteFilePath()); - scripts.append(script); - - DEBUG->print("base: %s", fi.baseName().toLatin1().data()); - DEBUG->print("path: %s", fi.absoluteFilePath().toLatin1().data()); - } - - //Script* f = new Script("normal"); - //scripts.append(f); -} - -/** - * Removes all scripts in the scriptlist. - */ -void ScriptList::clearScripts() -{ - scripts.clear(); -} - -int ScriptList::countScripts() -{ - return scripts.count(); -} - -/** - * Removes a script from the list. - * Listeners are notified after the script was removed from - * the list but before it gets deleted. - */ -void ScriptList::removeScript(Script * script) -{ - DEBUG->print("ScriptList::removeScript()"); - - // here the script is removed from the list but not deleted -// scripts.remove(script); - // We have to delete it since AutoDelete does not exist in QList - int i = scripts.indexOf(script); - - if (i != -1) - delete scripts.takeAt(i); - - //for (uint i=0; iscriptRemoved(script); - //} - - // activate an other script if necessary: - //if (activeScript==script) { - // activateScript(scripts.first()); - //} - - // now it's save to delete the script - //delete script; -} - -/** - * @return Pointer to the script with the given name or - * \p NULL if no such script was found. The script will be loaded into - * memory if it's not already. - */ -Script * ScriptList::requestScript(const QString & name) -{ - DEBUG->print("ScriptList::requestScript %s", name.toLatin1().data()); - - QString name2 = name.toLower(); - Script * foundScript = NULL; - - DEBUG->print("name2: %s", name2.toLatin1().data()); - - // Search our list of available scripts: -// for(Script * s=scripts.first(); s!=NULL; s=scripts.next()) - for(int i=0; igetName() == name2) - { - foundScript = s; - break; - } - } - - // Script not found: - return foundScript; -} - -//! @return First script of the list. -Script * ScriptList::firstScript() -{ -// return scripts.first(); - scriptIterator.toFront(); - return scriptIterator.next(); -} - -/** @return Next script from the list after - * calling firstScript() or nextScript(). - */ -Script * ScriptList::nextScript() -{ -// return scripts.next(); - return scriptIterator.next(); -} - -/** - * @return Pointer to the script with the given name or - * \p NULL if no such script was found. - */ -//Script* ScriptList::loadScript(const QString& name) { -//} - -/** - * Tests the script list and its ability to load scripts. - */ -bool ScriptList::test() -{ - //ScriptList* l = ScriptList::instance(); - - //std::cout << "ScriptList: " << *l << std::endl; - - return true; -}