Example #1
0
void MainWindow::slotDirectoryChanged(const QString &dir)
{
	QStringList files, subdirs;
	Common::foreachDir(dir, files, subdirs);

	foreach (const QString &file, files) {
		if (!watcher_->files().contains(file)) {
			slotFileChanged(file);
		}
	}

	foreach (const QString &subdir, subdirs) {
		if (!watcher_->directories().contains(subdir)) {
			slotFileChanged(subdir);
		}
	}

	QStringList dstFiles, dstSubdis;
	Common::foreachDir(oppositeSide(dir), dstFiles, dstSubdis);
	foreach (const QString &file, dstFiles) {
		if (!isOppositeSideExist(file, false)) {
			Common::deleteFile(file);
		}
	}


	foreach (const QString &subdir, dstSubdis) {
		if (!isOppositeSideExist(subdir, false)) {
			Common::deleteDir(subdir);
		}
	}
}
Example #2
0
void MainWindow::start(bool isTrue)
{
	if (isTrue) {
		isStart_ = true;
		pbStart_->setText(tr("Stop"));
		connect(watcher_, SIGNAL(fileChanged(QString)), this, SLOT(slotFileChanged(QString)));
		connect(watcher_, SIGNAL(directoryChanged(QString)), this, SLOT(slotDirectoryChanged(QString)));
		Common::asyncCopy(leFrom_->text(), leTo_->text());
	} else {
		isStart_ = false;
		pbStart_->setText(tr("Start"));
		disconnect(watcher_, SIGNAL(fileChanged(QString)), this, SLOT(slotFileChanged(QString)));
		disconnect(watcher_, SIGNAL(directoryChanged(QString)), this, SLOT(slotDirectoryChanged(QString)));
	}
}
Example #3
0
void CQExperimentData::slotFileDelete()
{
  // Get info from current selection
  size_t index = mpBoxFile->currentRow();

  if (index == C_INVALID_INDEX) return;

  std::string FileName = mFileMap[TO_UTF8(mpBoxFile->item((int) index)->text())];

  // change selection
  if (mpBoxFile->count() > 1)
    {
      if (mpBoxFile->count() > (int)index + 1)
        mpBoxFile->setCurrentRow((int)(index + 1));
      else
        mpBoxFile->setCurrentRow((int)(index - 1));
    }
  else
    slotFileChanged(NULL, NULL);

  // remove file
  mFileMap.erase(TO_UTF8(mpBoxFile->item((int) index)->text()));

  QListWidgetItem * pItem = mpBoxFile->takeItem((int) index);
  pdelete(pItem);

  // delete all experiments in current file.
  size_t i = mpExperimentSetCopy->getExperimentCount() - 1;

  for (; i != C_INVALID_INDEX; i--)
    if (mpExperimentSetCopy->getExperiment(i)->getFileName() == FileName)
      mpExperimentSetCopy->removeExperiment(i);
}
Example #4
0
//////////////////////////////////////////////////////////////////////////
/// Add a FileSystemWatcher to the directory
/// 
/// Creates a FileSystemWatcher, connects all the signals, adds it to the
/// list of watchers and starts it.
//////////////////////////////////////////////////////////////////////////
void SyncSystem::slotStartNodeWatching(const QString& dir)
{
  QString watchDir = joinPath(m_CurrentSourcePath, dir);
  qDebug() << "[SyncSystem.Debug] slotStartNodeWatching in dir " << watchDir;

  FileSystemWatcher* watcher = new FileSystemWatcher();
  connect(watcher, SIGNAL(fileAdded(QString)), SLOT(slotFileAdded(QString)));
  connect(watcher, SIGNAL(fileDeleted(QString)), SLOT(slotFileDeleted(QString)));
  connect(watcher, SIGNAL(fileChanged(QString)), SLOT(slotFileChanged(QString)));
  connect(watcher, SIGNAL(fileRenamed(QString,QString)), SLOT(slotFileRenamed(QString,QString)));
  connect(watcher, SIGNAL(filewatchError(QString)), SLOT(slotFilewatchError(QString)));
  connect(watcher, SIGNAL(filewatchLostSync(QString)), SLOT(slotLostSync()));
  m_FileSystemWatchers.append(watcher);
  watcher->setWatchDir(watchDir);
  watcher->setRelativeDir(dir);
  watcher->start();
}
Example #5
0
void DImgPreviewItem::DImgPreviewItemPrivate::init(DImgPreviewItem* const q)
{
    previewThread = new PreviewLoadThread;
    preloadThread = new PreviewLoadThread;
    preloadThread->setPriority(QThread::LowPriority);

    QObject::connect(previewThread, SIGNAL(signalImageLoaded(LoadingDescription,DImg)),
                     q, SLOT(slotGotImagePreview(LoadingDescription,DImg)));

    QObject::connect(preloadThread, SIGNAL(signalImageLoaded(LoadingDescription,DImg)),
                     q, SLOT(preloadNext()));

    // get preview size from screen size, but limit from VGA to WQXGA
    previewSize = qBound(640,
                         qMax(QApplication::desktop()->availableGeometry(-1).height(),
                              QApplication::desktop()->availableGeometry(-1).width()),
                         2560);

    LoadingCacheInterface::connectToSignalFileChanged(q, SLOT(slotFileChanged(QString)));

    QObject::connect(IccSettings::instance(), SIGNAL(settingsChanged(ICCSettingsContainer,ICCSettingsContainer)),
                     q, SLOT(iccSettingsChanged(ICCSettingsContainer,ICCSettingsContainer)));
}
Example #6
0
bool CQExperimentData::load(CExperimentSet * pExperimentSet, CCopasiDataModel * pDataModel)
{
  mpDataModel = pDataModel;

#ifdef COPASI_CROSSVALIDATION
  mCrossValidation = (dynamic_cast< CCrossValidationSet * >(pExperimentSet) != NULL);
#endif // COPASI_CROSSVALIDATION

  if (mCrossValidation)
    {
      setWindowTitle("Validation Data");
      mpLblWeight->show();
      mpEditWeight->show();
      mpLblThreshold->show();
      mpEditThreshold->show();
      mpLineCrossValidation->show();

#ifdef COPASI_CROSSVALIDATION
      mpEditWeight->setText(QString::number(static_cast< CCrossValidationSet * >(pExperimentSet)->getWeight()));
      mpEditThreshold->setText(QString::number(static_cast< CCrossValidationSet * >(pExperimentSet)->getThreshold()));
#endif // COPASI_CROSSVALIDATION
    }
  else
    {
      mpLblWeight->hide();
      mpEditWeight->hide();
      mpLblThreshold->hide();
      mpEditThreshold->hide();
      mpLineCrossValidation->hide();
    }

  if (!pExperimentSet) return false;

  mpExperiment = NULL;
  mShown =  -1;

  mpExperimentSet = pExperimentSet;

  pdelete(mpExperimentSetCopy);

  mpExperimentSetCopy = new CExperimentSet(*pExperimentSet);

#ifdef COPASI_CROSSVALIDATION

  if (mCrossValidation)
    mpExperimentSetCopy = elevate< CCrossValidationSet, CExperimentSet >(mpExperimentSetCopy);

#endif // COPASI_CROSSVALIDATION

  pdelete(mpFileInfo);
  mpFileInfo = new CExperimentFileInfo(*mpExperimentSetCopy);

  // Build the key map so that we are able to update the correct experiments
  // on OK.
  mKeyMap.clear();
  size_t i, imax = mpExperimentSet->getExperimentCount();

  for (i = 0; i < imax; i++)
    mKeyMap[mpExperimentSet->getExperiment(i)->CCopasiParameter::getKey()] =
      mpExperimentSetCopy->getExperiment(i)->CCopasiParameter::getKey();

  // fill file list box
  mpBoxFile->clear();

  std::vector< std::string > FileNames = mpExperimentSetCopy->getFileNames();
  std::vector< std::string >::const_iterator it = FileNames.begin();
  std::vector< std::string >::const_iterator end = FileNames.end();

  std::string FileName;
  i = 0;

  mFileMap.clear();

  for (; it != end; ++it)
    {
      FileName = CDirEntry::fileName(*it);

      while (mFileMap.find(FileName) != mFileMap.end())
        FileName = StringPrint("%s_%d", CDirEntry::fileName(*it).c_str(), i++);

      mFileMap[FileName] = *it;
      mpBoxFile->addItem(FROM_UTF8(FileName));
    }

  if (mpBoxFile->count())
    mpBoxFile->setCurrentRow(0); // This triggers the rest of the update :)
  else
    slotFileChanged(NULL, NULL);

  return true;
}