Crossfire Server, Trunk
ScriptFileManager.cpp
Go to the documentation of this file.
1 #include "ScriptFileManager.h"
2 #include "scripts/ScriptFile.h"
3 #include <QVariant>
4 
6  setProperty(tipProperty, tr("Display all Python scripts used in maps."));
7 }
8 
10 {
11  qDeleteAll(myScripts.values());
12 }
13 
15 {
16  QList<ScriptFile*> list;
17  foreach(ScriptFile* script, myScripts.values())
18  {
19  if (script->forMap(map))
20  {
21  list.append(script);
22  }
23  }
24  return list;
25 }
26 
28 {
29  if (!myScripts.contains(path))
30  {
31  myScripts.insert(path, new ScriptFile(this, path));
32  }
33  return myScripts[path];
34 }
35 
37 {
38  QHash<QString, ScriptFile*>::iterator script = myScripts.begin();
39  while (script != myScripts.end())
40  {
41  if ((*script)->removeMap(map))
42  {
43  ScriptFile* s = *script;
44  script = myScripts.erase(script);
45  delete s;
46  }
47  else
48  {
49  script++;
50  }
51  }
52 }
53 
54 QList<ScriptFile*> ScriptFileManager::scripts() const
55 {
56  return myScripts.values();
57 }
58 
59 void ScriptFileManager::addHook(const QString &file, HookInformation *hook) {
60  getFile(file)->addHook(hook);
61 }
ScriptFileManager.h
ScriptFileManager::myScripts
QHash< QString, ScriptFile * > myScripts
Definition: ScriptFileManager.h:45
guildoracle.list
list
Definition: guildoracle.py:87
python_event.path
path
Definition: python_event.py:11
mad_mage_user.file
file
Definition: mad_mage_user.py:15
ScriptFile::forMap
bool forMap(CREMapInformation *map) const
Definition: ScriptFile.cpp:18
AssetWrapper::tipProperty
static const char * tipProperty
Definition: AssetWrapper.h:16
CREMapInformation
Definition: CREMapInformation.h:16
disinfect.map
map
Definition: disinfect.py:4
ScriptFile.h
ScriptFileManager::scriptsForMap
QList< ScriptFile * > scriptsForMap(CREMapInformation *map)
Definition: ScriptFileManager.cpp:14
AssetWrapper
Definition: AssetWrapper.h:11
ScriptFileManager::removeMap
void removeMap(CREMapInformation *map)
Definition: ScriptFileManager.cpp:36
ScriptFileManager::ScriptFileManager
ScriptFileManager(AssetWrapper *parent)
Definition: ScriptFileManager.cpp:5
ScriptFileManager::scripts
QList< ScriptFile * > scripts() const
Definition: ScriptFileManager.cpp:54
ScriptFile
Definition: ScriptFile.h:31
ScriptFileManager::getFile
ScriptFile * getFile(const QString &path)
Definition: ScriptFileManager.cpp:27
ScriptFile::addHook
void addHook(HookInformation *hook)
Definition: ScriptFile.cpp:13
HookInformation
Definition: ScriptFile.h:10
ScriptFileManager::~ScriptFileManager
virtual ~ScriptFileManager()
Definition: ScriptFileManager.cpp:9
ScriptFileManager::addHook
void addHook(const QString &file, HookInformation *hook)
Definition: ScriptFileManager.cpp:59