History

first cut at moving entity scripts into ScriptEngine

Brad Hefta-Gaub committed 11 years ago

Commit 18fbf891 parent 56118e46 files · +283 −316Browse files

Showing the changes to libraries/script-engine/src/ScriptCache.h (1 of 6 files). Show all

Unified · Split

libraries/script-engine/src/ScriptCache.h+12−2
@@ -20,23 +20,33 @@ public: · 19 unmodified lines
20 virtual void errorInLoadingScript(const QUrl& url) = 0;20 virtual void errorInLoadingScript(const QUrl& url) = 0;
21};21};
22 22
23using contentAvailableCallback = std::function<void(const QString& scriptOrURL, const QString& contents, bool isURL, bool contentAvailable)>;
24
23/// Interface for loading scripts25/// Interface for loading scripts
24class ScriptCache : public QObject, public Dependency {26class ScriptCache : public QObject, public Dependency {
25 Q_OBJECT27 Q_OBJECT
26 SINGLETON_DEPENDENCY28 SINGLETON_DEPENDENCY
27 29
28public:30public:
31 void getScriptContents(const QString& scriptOrURL, contentAvailableCallback contentAvailable, bool forceDownload = false);
32
33
29 QString getScript(const QUrl& unnormalizedURL, ScriptUser* scriptUser, bool& isPending, bool redownload = false);34 QString getScript(const QUrl& unnormalizedURL, ScriptUser* scriptUser, bool& isPending, bool redownload = false);
30 void deleteScript(const QUrl& unnormalizedURL);35 void deleteScript(const QUrl& unnormalizedURL);
36
37 // FIXME - how do we remove a script from the bad script list in the case of a redownload?
31 void addScriptToBadScriptList(const QUrl& url) { _badScripts.insert(url); }38 void addScriptToBadScriptList(const QUrl& url) { _badScripts.insert(url); }
32 bool isInBadScriptList(const QUrl& url) { return _badScripts.contains(url); }39 bool isInBadScriptList(const QUrl& url) { return _badScripts.contains(url); }
33 40
34private slots:41private slots:
35 void scriptDownloaded();42 void scriptDownloaded(); // old version
36 43 void scriptContentAvailable(); // new version
44
37private:45private:
38 ScriptCache(QObject* parent = NULL);46 ScriptCache(QObject* parent = NULL);
39 47
48 QMultiMap<QUrl, contentAvailableCallback> _contentCallbacks;
49
40 QHash<QUrl, QString> _scriptCache;50 QHash<QUrl, QString> _scriptCache;
41 QMultiMap<QUrl, ScriptUser*> _scriptUsers;51 QMultiMap<QUrl, ScriptUser*> _scriptUsers;
42 QSet<QUrl> _badScripts;52 QSet<QUrl> _badScripts;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t