Example #1
0
//----------------------------------------------------------------------------------------
OfsTreeWidget::OfsTreeWidget(QWidget *parent, unsigned int capabilities, QStringList initialSelection) : QTreeWidget(parent), mCapabilities(capabilities) 
{
    mSelectedItems = initialSelection;
    mRecycleBinParent = NULL;

    setColumnCount(1);
    setHeaderHidden(true);
    setSelectionMode(QAbstractItemView::ExtendedSelection);
    setSelectionBehavior(QAbstractItemView::SelectItems);
    setContextMenuPolicy(Qt::CustomContextMenu);
    setDragDropOverwriteMode(false);
    setAutoScroll(true);
    
    if(capabilities & CAP_ALLOW_DROPS)
        setDragDropMode(QAbstractItemView::DragDrop);

    mUnknownFileIcon = mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::File);

    mFile = Ogitors::OgitorsRoot::getSingletonPtr()->GetProjectFile();
    mFile->addTrigger(this, OFS::_OfsBase::CLBK_CREATE, &triggerCallback);
    mFile->addTrigger(this, OFS::_OfsBase::CLBK_DELETE, &triggerCallback);

    refreshWidget();

    mAddFilesThread = new AddFilesThread();
    mExtractorThread = new ExtractorThread();
    connect(mAddFilesThread, SIGNAL(finished()), this, SLOT(threadFinished()));
    connect(mExtractorThread, SIGNAL(finished()), this, SLOT(threadFinished()));
}
AREXPORT void *ArFunctorASyncTask::runThread(void *arg)
{
  threadStarted();
  void *ret = myFunc->invokeR(arg);
  threadFinished();
  return ret;
}
Example #3
0
void ThreadCleaner::stopAll()
{
    DBUG << "Remaining threads:" << threads.count();
    for (Thread *thread: threads) {
        DBUG << "Cleanup" << thread->objectName();
        disconnect(thread, SIGNAL(finished()), this, SLOT(threadFinished()));
    }

    for (Thread *thread: threads) {
        thread->stop();
    }

    QList<Thread *> stillRunning;
    for (Thread *thread: threads) {
        if (thread->wait(250)) {
            delete thread;
        } else {
            stillRunning.append(thread);
            DBUG << "Failed to close" << thread->objectName();
        }
    }

    // Terminate any still running threads...
    signal(SIGSEGV, segvHandler); // Ignore SEGV in case a thread throws an error...
    for (Thread *thread: stillRunning) {
        thread->terminate();
    }
}
void LiveStreamThread::start(const QUrl &url)
{
    QMutexLocker locker(&m_workerMutex);

    qDebug() << Q_FUNC_INFO << LoggableUrl(url);

    if (!m_worker)
    {
        Q_ASSERT(!m_thread);
        m_thread = new QThread();

        LiveStreamWorker *worker = new LiveStreamWorker();
        worker->moveToThread(m_thread.data());

        m_worker = worker;
        m_worker.data()->setUrl(url);

        connect(m_thread.data(), SIGNAL(started()), m_worker.data(), SLOT(run()));
        connect(m_thread.data(), SIGNAL(finished()), this, SLOT(threadFinished()));
        connect(m_worker.data(), SIGNAL(fatalError(QString)), this, SIGNAL(fatalError(QString)));

        m_thread.data()->start();
    }
    else
        m_worker.data()->metaObject()->invokeMethod(m_worker.data(), "run");

    m_isRunning = true;
}
	void DataCheckerJob::start()
	{
		registerWithTracker();
		DataChecker* dc = 0;
		const TorrentStats & stats = torrent()->getStats();
		if (stats.multi_file_torrent)
			dc = new MultiDataChecker(from, to);
		else
			dc = new SingleDataChecker(from, to);
		
		connect(dc,SIGNAL(progress(quint32,quint32)),
				this,SLOT(progress(quint32,quint32)),Qt::QueuedConnection);
		connect(dc,SIGNAL(status(quint32,quint32,quint32,quint32)),
				this,SLOT(status(quint32,quint32,quint32,quint32)),Qt::QueuedConnection);
		
		TorrentControl* tor = torrent();
		dcheck_thread = new DataCheckerThread(
				dc,tor->downloadedChunksBitSet(),
				stats.output_path,tor->getTorrent(),
				tor->getTorDir() + "dnd" + bt::DirSeparator());
				
		connect(dcheck_thread,SIGNAL(finished()),this,SLOT(threadFinished()),Qt::QueuedConnection);
		
		torrent()->beforeDataCheck();
		
		setTotalAmount(Bytes,to - from + 1);
		data_checker_slot.add(this);
		if (!started)
			infoMessage(this,i18n("Waiting for other data checks to finish"));
	}
Example #6
0
void DataModelGUI::exportCombineFinished()
{

  disconnect(mpThread, SIGNAL(finished()), this, SLOT(exportSBMLFinished()));

  threadFinished();
}
void
GenericSchedulerThread::onWatcherTaskFinishedEmitted()
{
    if (!_imp->blockingOperationWatcher) {
        return;
    }
    _imp->blockingOperationWatcher.reset();
    Q_EMIT threadFinished();
}
Example #8
0
void DataModelGUI::exportSBMLFinished()
{
  if (mSuccess)
    CCopasiRootContainer::getConfiguration()->getRecentSBMLFiles().addFile(mFileName);

  disconnect(mpThread, SIGNAL(finished()), this, SLOT(exportSBMLFinished()));

  threadFinished();
}
void UpdaterDialog::initUpdate(void)
{
	//Clean up files from previous attempt
	if(!m_binaries.isEmpty())
	{
		cleanFiles();
	}

	//Check binary files
	QString wgetBin, gpgvBin;
	if(!checkBinaries(wgetBin, gpgvBin))
	{
		ui->buttonCancel->setEnabled(true);
		const QString message = QString("%1<br><br><nobr><a href=\"%2\">%3</a></nobr><br>").arg(tr("At least one file required by the web-update tool is missing or corrupted.<br>Please re-install this application and then try again!"), QString::fromLatin1(m_updateUrl), QString::fromLatin1(m_updateUrl).replace("-", "&minus;"));
		if(QMessageBox::critical(this, tr("File Error"), message, tr("Download Latest Version"), tr("Discard")) == 0)
		{
			QDesktopServices::openUrl(QUrl(QString::fromLatin1(m_updateUrl)));
		}
		close(); return;
	}

	//Make sure user does have admin access
	if(!MUtils::OS::user_is_admin())
	{
		qWarning("User is not in the \"admin\" group, cannot update!");
		QString message;
		message += QString("<nobr>%1</nobr><br>").arg(tr("Sorry, but only users in the \"Administrators\" group can install updates."));
		message += QString("<nobr>%1</nobr>").arg(tr("Please start application from an administrator account and try again!"));
		if(QMessageBox::critical(this, this->windowTitle(), message, tr("Discard"), tr("Ignore")) != 1)
		{
			ui->buttonCancel->setEnabled(true);
			close(); return;
		}
	}
	
	//Create and setup thread
	if(!m_thread)
	{
		m_thread.reset(new MUtils::UpdateChecker(m_binaries.value("wget.exe"), m_binaries.value("gpgv.exe"), m_binaries.value("gpgv.gpg"), "Simple x264 Launcher", x264_version_build(), false));
		connect(m_thread.data(), SIGNAL(statusChanged(int)), this, SLOT(threadStatusChanged(int)));
		connect(m_thread.data(), SIGNAL(finished()), this, SLOT(threadFinished()));
		connect(m_thread.data(), SIGNAL(terminated()), this, SLOT(threadFinished()));
		connect(m_thread.data(), SIGNAL(messageLogged(QString)), this, SLOT(threadMessageLogged(QString)));
	}
 virtual void* runThread(void* arg)
 {
   threadStarted();
   while(Aria::getRunning() && getRunning())
   {
     ArSystemStatus::invalidate();
     ArUtil::sleep(myRefreshFrequency);
   }
   threadFinished();
   return NULL;
 }
Example #11
0
void DataModelGUI::importCombineFinished()
{
  if (mSuccess)
    {

      mpOutputHandlerPlot->setOutputDefinitionVector(mpDataModel->getPlotDefinitionList());
      linkDataModelToGUI();
    }

  disconnect(mpThread, SIGNAL(finished()), this, SLOT(importCombineFinished()));

  threadFinished();
}
RepositoryProfile::RepositoryProfile ( QObject *parent )
    : QObject ( parent ), curProfileName ( QApplication::translate ( "RepositoryProfile", "new profile" ) ),
    curUrl ( "ftp://" ),
    curDownloadDir ( QDir::current() ),
    curArchitectures ( RPM::i586 ),
    repositoryType ( YUM ),
    status ( UNKNOWN )
{
  clearStats();

  lister = new RDPackageListerThread ( this );
  connect ( lister, SIGNAL ( finished() ), this, SLOT ( threadFinished() ) );
}
Example #13
0
void DatabaseQuery::runQuery() {
    DatabaseQueryRequest *request = takeRequest();
    if (request) {
        QThread *thread = new QThread();
        connect(thread, SIGNAL(finished()), SLOT(threadFinished()));
        thread->start();
        request->moveToThread(thread);
        connect( request, SIGNAL(requestCompleted()), SLOT(finishQuery()) );
        connect( request, SIGNAL(resultsReady(DataStore)), SLOT(addResult(DataStore)) );
        connect( request, SIGNAL(errorMessageBox(QString,QString)), SIGNAL(errorMessageBox(QString,QString)) );
        QMetaObject::invokeMethod(request, "start", Qt::QueuedConnection);
    }
}
void UpdateDialog::showEvent(QShowEvent *event)
{
    QDialog::showEvent(event);

    if(m_firstShow)
    {
        if(!m_thread)
        {
            m_thread = new UpdateCheckThread(m_binaryWGet, m_binaryGnuPG, m_binaryKeys, m_betaUpdates);
            connect(m_thread, SIGNAL(statusChanged(int)), this, SLOT(threadStatusChanged(int)));
            connect(m_thread, SIGNAL(progressChanged(int)), this, SLOT(threadProgressChanged(int)));
            connect(m_thread, SIGNAL(messageLogged(QString)), this, SLOT(threadMessageLogged(QString)));
            connect(m_thread, SIGNAL(finished()), this, SLOT(threadFinished()));
            connect(m_thread, SIGNAL(terminated()), this, SLOT(threadFinished()));
        }

        threadStatusChanged(m_thread->getUpdateStatus());
        ui->labelVersionInstalled->setText(QString("%1 %2 (%3)").arg(tr("Build"), QString::number(lamexp_version_build()), lamexp_version_date().toString(Qt::ISODate)));
        ui->labelVersionLatest->setText(QString("(%1)").arg(tr("Unknown")));

        ui->installButton->setEnabled(false);
        ui->closeButton->setEnabled(false);
        ui->retryButton->setEnabled(false);
        ui->logButton->setEnabled(false);
        ui->retryButton->hide();
        ui->logButton->hide();
        ui->infoLabel->hide();
        ui->hintLabel->hide();
        ui->hintIcon->hide();
        ui->frameAnimation->hide();

        ui->progressBar->setMaximum(m_thread->getMaximumProgress());
        ui->progressBar->setValue(0);

        m_updaterProcess = NULL;

        QTimer::singleShot(0, this, SLOT(updateInit()));
        m_firstShow = false;
    }
Example #15
0
void FileTransferServer::addNewClient()
{
  QTcpSocket *client;
  if(m_server->hasPendingConnections()) {
    client = m_server->nextPendingConnection();
    m_socket = new ServerClient(client, m_file, m_sender);
    m_state = CONNECTED;
    connect(&m_serverThread, SIGNAL(finished()), this, SLOT(threadFinished()));
    m_socket->sendInit();
    if (m_sender == true)
      m_socket->sendFile();
    connect(m_socket, SIGNAL(disconnected()), this, SLOT(disconnectSlot()));
  }
}
Example #16
0
void DataModelGUI::loadModelFinished()
{
  if (mSuccess)
    {
      CCopasiRootContainer::getConfiguration()->getRecentFiles().addFile(mFileName);

      mOutputHandlerPlot.setOutputDefinitionVector((*CCopasiRootContainer::getDatamodelList())[0]->getPlotDefinitionList());
      linkDataModelToGUI();
    }

  disconnect(mpThread, SIGNAL(finished()), this, SLOT(loadModelFinished()));

  threadFinished();
}
Example #17
0
void DataModelGUI::addModelFinished()
{
  if (mSuccess)
    {
      //notify(ListViews::MODEL, ListViews::CHANGE, "");

      CCopasiRootContainer::getConfiguration()->getRecentFiles().addFile(mFileName);
      //linkDataModelToGUI();
    }

  disconnect(mpThread, SIGNAL(finished()), this, SLOT(addModelFinished()));

  threadFinished();
}
Example #18
0
void DataModelGUI::importSEDMLFinished()
{
  if (mSuccess)
    {
      CCopasiRootContainer::getConfiguration()->getRecentSEDMLFiles().addFile(mFileName);

      mpOutputHandlerPlot->setOutputDefinitionVector(mpDataModel->getPlotDefinitionList());
      linkDataModelToGUI();
    }

  disconnect(mpThread, SIGNAL(finished()), this, SLOT(importSEDMLFinished()));

  threadFinished();
}
Example #19
0
void DataModelGUI::importSBMLFinished()
{
  if (mSuccess)
    {
#ifdef CELLDESIGNER_IMPORT
      this->importCellDesigner();
#endif // CELLDESIGNER_IMPORT
      CCopasiRootContainer::getConfiguration()->getRecentSBMLFiles().addFile(mFileName);

      mOutputHandlerPlot.setOutputDefinitionVector((*CCopasiRootContainer::getDatamodelList())[0]->getPlotDefinitionList());
      linkDataModelToGUI();
    }

  disconnect(mpThread, SIGNAL(finished()), this, SLOT(importSBMLFinished()));

  threadFinished();
}
void EvernoteSync::startSyncThreaded()
{
    m_storageManager->log("EvernoteSync::startSyncThreaded()");
    EvernoteSyncThread *enSyncThread = new EvernoteSyncThread(m_evernoteAccess, this);
    connect(enSyncThread, SIGNAL(finished()), SLOT(threadFinished()));
    connect(enSyncThread, SIGNAL(syncFinished(bool,QString)), SIGNAL(syncFinished(bool,QString)));
    connect(enSyncThread, SIGNAL(loginError(QString)), SIGNAL(loginError(QString)));
    connect(enSyncThread, SIGNAL(firstChunkDone()), SIGNAL(firstChunkDone()));
    connect(enSyncThread, SIGNAL(syncProgressChanged(int)), SLOT(updateSyncProgress(int)));
    connect(enSyncThread, SIGNAL(syncStatusMessage(QString)), SLOT(updateSyncStatusMessage(QString)));
    connect(enSyncThread, SIGNAL(fullSyncDoneChanged()), SIGNAL(fullSyncDoneChanged()));
    connect(enSyncThread, SIGNAL(authTokenInvalid()), SIGNAL(authTokenInvalid()));
    connect(enSyncThread, SIGNAL(rateLimitReached(int)), SLOT(rateLimitReached(int)));
    updateSyncStatusMessage("Starting sync");
    enSyncThread->start(QThread::LowPriority);
    emit syncStarted();
}
Example #21
0
void MarkdownHighlighter::parse()
{
	if (workerThread && workerThread->isRunning()) {
		parsePending = true;
		return;
	}

	QString content = document->toPlainText();
	QByteArray ba = content.toUtf8();
	char *content_cstring = strdup((char *)ba.data());

	workerThread.reset(new WorkerThread());
	workerThread->content = content_cstring;
	connect(workerThread.get(), SIGNAL(finished()), this, SLOT(threadFinished()));
	parsePending = false;
	workerThread->start();
}
Example #22
0
void DataModelGUI::importSBMLFromStringFinished()
{
  mSBMLImportString = "";

  if (mSuccess)
    {
      // can't run this in a separate thread because it uses GUI routines
      // TODO maybe put the main part of this routine in a separate thread after
      // TODO asking the user
      this->importCellDesigner();
      mpOutputHandlerPlot->setOutputDefinitionVector(mpDataModel->getPlotDefinitionList());
      linkDataModelToGUI();
    }

  disconnect(mpThread, SIGNAL(finished()), this, SLOT(importSBMLFromStringFinished()));

  threadFinished();
}
Example #23
0
void ProxyChecker::threadFinished()
{
	ProxyCheckThread *thread = dynamic_cast<ProxyCheckThread *>(sender());
	if (!thread->getResult())
		CheckedList.removeAll(thread->getProxy());

	int index = thread->getIndex();
	thread->deleteLater();

	if (ProxyListIndex < ProxyList.count())
	{
		ProxyCheckThread *thread = new ProxyCheckThread(ProxyList.at(ProxyListIndex), index);
		connect(thread, SIGNAL(finished()), this, SLOT(threadFinished()));
		(*ThreadsList)[index] = thread;
		thread->start();
	}
	threadsFinishedNumber++;
}
void HGMarkdownHighlighter::parse()
{
    if (workerThread != NULL && workerThread->isRunning()) {
        parsePending = true;
        return;
    }

    QString content = document->toPlainText();
    QByteArray ba = content.toLatin1();
    char *content_cstring = strdup((char *)ba.data());

    if (workerThread != NULL)
        delete workerThread;
    workerThread = new WorkerThread();
    workerThread->content = content_cstring;
    connect(workerThread, SIGNAL(finished()), this, SLOT(threadFinished()));
    parsePending = false;
    workerThread->start();
}
void QGeoTiledMappingManagerEngine::setTileFetcher(QGeoTileFetcher *fetcher)
{
    Q_D(QGeoTiledMappingManagerEngine);

    d->fetcher_ = fetcher;
    d->fetcher_->init();

    d->thread_ = new QThread;

    qRegisterMetaType<QGeoTileSpec>();

    connect(d->fetcher_,
            SIGNAL(tileFinished(QGeoTileSpec,QByteArray,QString)),
            this,
            SLOT(engineTileFinished(QGeoTileSpec,QByteArray,QString)),
            Qt::QueuedConnection);
    connect(d->fetcher_,
            SIGNAL(tileError(QGeoTileSpec,QString)),
            this,
            SLOT(engineTileError(QGeoTileSpec,QString)),
            Qt::QueuedConnection);

    d->fetcher_->moveToThread(d_ptr->thread_);

    connect(d->thread_,
            SIGNAL(started()),
            d->fetcher_,
            SLOT(threadStarted()));

    connect(d->thread_,
            SIGNAL(finished()),
            d->fetcher_,
            SLOT(threadFinished()));

    connect(d->fetcher_,
            SIGNAL(destroyed()),
            d->thread_,
            SLOT(deleteLater()));

    engineInitialized();

    QTimer::singleShot(0, d->thread_, SLOT(start()));
}
Example #26
0
void DataModelGUI::importSBMLFromStringFinished()
{
  mSBMLImportString = "";

  if (mSuccess)
    {
      // can't run this in a separate thread because it uses GUI routines
      // TODO maybe put the main part of this routine in a separate thread after
      // TODO asking the user
#ifdef CELLDESIGNER_IMPORT
      this->importCellDesigner();
#endif // CELLDESIGNER_IMPORT
      mOutputHandlerPlot.setOutputDefinitionVector((*CCopasiRootContainer::getDatamodelList())[0]->getPlotDefinitionList());
      linkDataModelToGUI();
    }

  disconnect(mpThread, SIGNAL(finished()), this, SLOT(importSBMLFromStringFinished()));

  threadFinished();
}
Example #27
0
SDLEvents::SDLEvents() {
    // Initialize the GameController database with the most recent file
    // from https://github.com/gabomdq/SDL_GameControllerDB
    // TODO: Instead of storing the file as a ressource, have it in some
    // directory so the user can modify it if needed..
    Q_INIT_RESOURCE( assets ); // needed to access resources before app.exec()
    QFile f( ":/assets/gamecontrollerdb.txt" );
    f.open( QIODevice::ReadOnly );
    SDL_SetHint( SDL_HINT_GAMECONTROLLERCONFIG, f.readAll().constData() );

    event_list = new SDL_Event[10]();

    this->moveToThread( &thread );
    polltimer.moveToThread( &thread );
    connect( &thread, SIGNAL( started() ), SLOT( threadStarted() ) );
    connect( &thread, SIGNAL( finished() ), SLOT( threadFinished() ) );
    thread.setObjectName( "phoenix-SDLEvents" );

    thread.start( QThread::HighPriority );
}
Example #28
0
/**
 * Exports the current model to docbook in the given directory
 * @param destDir the directory where the docbook file and the figures will
 * be written
 * @todo better handling of error conditions
 * @return true if saving is successful and false otherwise.
 */
void DocbookGenerator::generateDocbookForProjectInto(const KUrl& destDir)
{
    m_destDir = destDir;
    umlDoc->writeToStatusBar(i18n("Exporting all views..."));

    QStringList errors = UMLViewImageExporterModel().exportAllViews(
        UMLViewImageExporterModel::mimeTypeToImageType("image/png"), destDir, false);
    if (!errors.empty()) {
        KMessageBox::errorList(UMLApp::app(), i18n("Some errors happened when exporting the images:"), errors);
        return;
    }

    umlDoc->writeToStatusBar(i18n("Generating Docbook..."));

    docbookGeneratorJob = new DocbookGeneratorJob( this );
    connect(docbookGeneratorJob, SIGNAL(docbookGenerated(QString)), this, SLOT(slotDocbookGenerationFinished(QString)));
    connect(docbookGeneratorJob, SIGNAL(finished()), this, SLOT(threadFinished()));
    uDebug()<<"Threading";
    docbookGeneratorJob->start();
}
Example #29
0
/*---------------------------------------------------------------------------
* Daten wurden aktualisiert : Thread erstellen und starten
*---------------------------------------------------------------------------*/
void DtaStatsFrame::dataUpdated()
{
   textEdit->clear();

   // Zeitspanne der Eingabefelder aktualisieren
   this->updateTimeRangeEdit();

   if(!data->isEmpty())
   {
      textEdit->insertPlainText(tr("Bitte warten! Daten werden ausgewertet."));

      // Thread starten
      this->thread = new DtaStatsThread();
      this->thread->setData(data);
      this->thread->setDateTimeRange( dteStart->dateTime().toTime_t(),
                                      dteEnd->dateTime().toTime_t());
      connect( thread, SIGNAL(finished()), this, SLOT(threadFinished()));
      this->thread->start();
   }
}
AREXPORT void *
ArRecurrentTask::runThread(void *ptr) 
{
  threadStarted();
#ifndef WIN32
  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL);
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL);
#endif
  while (myRunning)
    {
      bool doit;

      while (myRunning)
	{
	  lock();
	  doit = go_req;
	  unlock();
	  if (doit)
	    break;
//	  yield();		// don't hog resources
#ifndef WIN32
	  usleep(10000);
#else
	  Sleep(10);
#endif
	}
      if (!myRunning)
	break;
      lock();
      go_req = false;
      running = true;		// we've been requested to go
      unlock();
      task();			// do what we've got to do...
      lock();
      running = false;		// say we're done
      unlock();
    }

  threadFinished();
  return NULL;
}