void MainScreen::handleSend() { m_cancelled = false; m_mainPage->setProperty("workInProgress", true); m_worker = new QThread(this); connect(m_worker, SIGNAL(started()), this, SLOT(doSend())); connect(m_worker, SIGNAL(finished()), this, SLOT(workDone())); connect(m_worker, SIGNAL(terminated()), this, SLOT(workDone())); m_worker->start(); }
void MainScreen::cancelWork() { m_cancelled = true; if(m_worker) { m_worker->exit(); } else { workDone(); } }
void toEventQuery::start() { if ( Worker || Started || WorkDone ) throw tr("toEventQuery::start - can not restart already stared query"); Worker = new toEventQueryWorker(this, Connection, CancelCondition, SQL, Param); Worker->moveToThread(Thread); Thread->Slave = Worker; // Connect to Worker's API connect(Worker, SIGNAL(headers(toQColumnDescriptionList &, int)), // BG -> main this, SLOT(slotDesc(toQColumnDescriptionList &, int))); connect(Worker, SIGNAL(data(const ValuesList &)), // BG -> main this, SLOT(slotData(const ValuesList &))); connect(Worker, SIGNAL(error(const toConnection::exception &)), // BG -> main this, SLOT(slotError(const toConnection::exception &))); connect(Worker, SIGNAL(workDone()), // BG -> main this, SLOT(slotFinished())); connect(Worker, SIGNAL(rowsProcessed(unsigned long)), // BG -> main this, SLOT(slotRowsProcessed(unsigned long))); connect(this, SIGNAL(dataRequested()), Worker, SLOT(slotRead())); // main -> BG connect(this, SIGNAL(consumed()), Worker, SLOT(slotRead())); // main -> BG // Connect to QThread's API // error handling connect(Worker, SIGNAL(error(toConnection::exception const &)) // BG -> main , this, SLOT(slotError(toConnection::exception const &))); // initization connect(Thread, SIGNAL(started()), Worker, SLOT(init())); // main -> BG connect(Worker, SIGNAL(started()), this, SLOT(slotStarted()));// BG -> main // finish connect(Worker, SIGNAL(finished()), Thread, SLOT(quit())); // BG -> BG?? (quit event loop) connect(Worker, SIGNAL(finished()), Worker, SLOT(deleteLater())); // BG -> BG connect(Thread, SIGNAL(finished()), Thread, SLOT(deleteLater())); // BG -> main connect(Thread, SIGNAL(destroyed()), this, SLOT(slotThreadEnd())); // main -> main connect(this, SIGNAL(stopRequested()), Worker, SLOT(slotStop())); // main -> BG TLOG(7, toDecorator, __HERE__) << "toEventQuery start" << std::endl; // finally start the thread Thread->start(); }
void FileCopyWorker::doWork(const QList<FileCopyInfo> files) { QString fullDestination; int count = 0; for (auto param : files) { if (m_abort) { m_abort = false; break; } if (param.ext == "jpg") { fullDestination = addUniqueSuffix( m_photoPath.absoluteFilePath(param.name)); } else { fullDestination = addUniqueSuffix( m_videoPath.absoluteFilePath(param.name)); } if (QFile(param.path).copy(fullDestination)) { ++count; emit fileDone(param.index, count); } QCoreApplication::processEvents(); } emit workDone(count); }
void ElementManager::reset() { // We disconnect from Interpreter disconnect(Interpreter::getInstance(), SIGNAL(workDone()), this, SLOT(commit())); }
VSPTree::VSPTree( QString appPath, QString argument) : m_applicationPath( appPath ), m_settings( appPath + "/VSPTree.ini", QSettings::IniFormat ) { QDir dir(PATH32); QDir dir2(PATH64); if ( dir.exists() ) { m_profilerpath = PATH32; } else if ( dir2.exists() ) { m_profilerpath = PATH64; } else { QMessageBox::critical(NULL,"Standalone Debugger not installed", "C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Team Tools\\Performance Tools\\ does not exist"); } QStringList env = QProcess::systemEnvironment(); env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), QString("PATH=\\1;") + m_profilerpath); m_process.setEnvironment(env); if ( m_settings.contains("m_lastExe") ) { m_lastExe = m_settings.value("m_lastExe").toString(); } if ( m_settings.contains("m_lastVSP") ) { m_lastVSP = m_settings.value("m_lastVSP").toString(); } if ( m_settings.contains("m_lastArguments") ) { m_lastArguments = m_settings.value("m_lastArguments").toString(); } m_editorPath = ""; if ( m_settings.contains("m_editorPath") ) { m_editorPath = m_settings.value("m_editorPath").toString(); } m_editorArguments = "<filename> -n<linenum>"; if ( m_settings.contains("m_editorArguments") ) { m_editorArguments = m_settings.value("m_editorArguments").toString(); } m_log = new QTextEdit(); m_log->setReadOnly(true); connect (&m_process, SIGNAL(readyReadStandardOutput()),this, SLOT(StdOutLog())); connect (&m_process, SIGNAL(readyReadStandardError()),this, SLOT(StdErrorLog())); menubar = this->menuBar(); QMenu* fileMenu = menubar->addMenu("File"); QAction* openAct = fileMenu->addAction("Open VSP"); connect(openAct, SIGNAL(triggered()), this, SLOT(LoadVSPClicked())); QAction* exitAct = fileMenu->addAction("Exit"); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); QMenu* profilerMenu = menubar->addMenu("Profiler"); QAction* startProfilingAct = profilerMenu->addAction("Start Profiler Service"); connect(startProfilingAct, SIGNAL(triggered()), this, SLOT(StartProfiling())); QAction* ProfileAct = profilerMenu->addAction("Profile Application"); connect(ProfileAct, SIGNAL(triggered()), this, SLOT(Profile())); QAction* stopProfilingAct = profilerMenu->addAction("Stop Profiler Service"); connect(stopProfilingAct, SIGNAL(triggered()), this, SLOT(StopProfiling())); QMenu* OptionsMenu = menubar->addMenu("Options"); QAction* setTextEditor = OptionsMenu->addAction("Set Text Editor"); connect(setTextEditor, SIGNAL(triggered()), this, SLOT(setTextEditor())); m_tabWidget = new QTabWidget(); m_callTreeWidget = new QTreeWidget(); m_flatCallTreeWidget = new QTreeWidget(); m_functionSummaryTreeWidget = new QTreeWidget(); m_tabWidget->addTab(m_callTreeWidget,"CallTree"); m_tabWidget->addTab(m_flatCallTreeWidget,"CallTreeFlat"); m_tabWidget->addTab(m_functionSummaryTreeWidget,"FunctionSummary"); m_tabWidget->addTab(m_log,"Log"); m_callTreeMenu = new QMenu(); QAction* openFileAct = m_callTreeMenu->addAction("Open File"); connect(openFileAct, SIGNAL(triggered()), this, SLOT(openFile())); QAction* expandAllAct = m_callTreeMenu->addAction("Expand All"); connect(expandAllAct, SIGNAL(triggered()), m_callTreeWidget, SLOT(expandAll())); QAction* collapseAllAct = m_callTreeMenu->addAction("Collapse All"); connect(collapseAllAct, SIGNAL(triggered()), m_callTreeWidget, SLOT(collapseAll())); m_flatCallTreeMenu = new QMenu(); m_flatCallTreeMenu->addAction(openFileAct); QAction* FindInTreeAct = m_flatCallTreeMenu->addAction("Find In Tree"); connect(FindInTreeAct, SIGNAL(triggered()), this, SLOT(FindInTree())); //threads connect( &m_thread, SIGNAL( output( QString ) ), this, SLOT( Log( QString ) ) ); connect( &m_thread, SIGNAL( finished() ), this, SLOT( workDone() ) ); this->setCentralWidget(m_tabWidget); this->setWindowTitle(VERSION); this->resize(640,480); this->show(); if ( !argument.isEmpty() ) { LoadVSP(argument); } }
void WindowManagerImpl::doWork(std::function<void()> f) { f(); emit workDone(); }