summaryrefslogtreecommitdiff
path: root/src/drumkitloader.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-03-22 22:42:05 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2013-03-22 22:42:05 +0100
commit47e1f28f1fe9fecf969d63f059b8ec8c0184605e (patch)
tree47ac2c6a2256b75601fa7077c994cdbfbeadc62a /src/drumkitloader.cc
parent70cc80a11a44c73c3cf548c7cedf2a520a025fb6 (diff)
Added Engine->Messageing system. Implemented LoadStatus Message. Added ProgressBar widget. Made FileBrowser chdir to old value (needs further fixing). More printf->hugin ports.
Diffstat (limited to 'src/drumkitloader.cc')
-rw-r--r--src/drumkitloader.cc46
1 files changed, 35 insertions, 11 deletions
diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc
index 9f514d0..53af7db 100644
--- a/src/drumkitloader.cc
+++ b/src/drumkitloader.cc
@@ -29,9 +29,11 @@
#include <hugin.hpp>
#include "drumkitparser.h"
+#include "drumgizmo.h"
-DrumKitLoader::DrumKitLoader()
+DrumKitLoader::DrumKitLoader(DrumGizmo *dg)
{
+ drumgizmo = dg;
is_done = false;
quitit = false;
}
@@ -75,19 +77,41 @@ void DrumKitLoader::thread_main()
if(quitit) return;
- Instruments::iterator i = kit->instruments.begin();
- while(i != kit->instruments.end()) {
- Instrument *instr = *i;
+ unsigned int count = 0;
+ { // Count total number of files that need loading:
+ Instruments::iterator i = kit->instruments.begin();
+ while(i != kit->instruments.end()) {
+ Instrument *instr = *i;
- std::vector<AudioFile*>::iterator a = instr->audiofiles.begin();
- while(a != instr->audiofiles.end()) {
- // usleep(10000);
- AudioFile *af = *a;
- af->load();
- a++;
+ count += instr->audiofiles.size();
+ i++;
}
+ }
- i++;
+ { // Now actually load them:
+ unsigned int loaded = 0;
+ Instruments::iterator i = kit->instruments.begin();
+ while(i != kit->instruments.end()) {
+ Instrument *instr = *i;
+
+ std::vector<AudioFile*>::iterator a = instr->audiofiles.begin();
+ while(a != instr->audiofiles.end()) {
+ //usleep(5000);
+ AudioFile *af = *a;
+ af->load();
+ loaded++;
+
+ LoadStatus *ls = new LoadStatus();
+ ls->number_of_files = count;
+ ls->numer_of_files_loaded = loaded;
+ ls->current_file = af->filename;
+ drumgizmo->sendMessage(ls);
+
+ a++;
+ }
+
+ i++;
+ }
}
mutex.lock();