#ifndef THREADBINDER_H #define THREADBINDER_H #include #include "model/ultrasoundModule/UsModule.h" #include "model/csm/utils/MouseEventFilter.h" class ThreadBinder : public QObject { public: static void bind(UsModule* obj, bool eventFilter) { auto thread = new QThread(); obj->moveToThread(thread); if(eventFilter) { auto mousEv = new TrackballMouseEventFilter(); mousEv->moveToThread(thread); obj->installEventFilter(mousEv); } //TODO: say this to logger connect(obj, SIGNAL (error(QString)), this, SLOT //(errorString(QString))); connect(thread, SIGNAL(started()), obj, SLOT(threadStarted())); connect(obj, SIGNAL(finished()), thread, SLOT(quit())); connect(obj, SIGNAL(finished()), obj, SLOT(deleteLater())); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); thread->start(); } }; #endif //THREADBINDER_H