示例#1
0
AssetType *AssetType::load(
    const QString &location,
    Shift::Set *parent,
    Shift::Set *assetParent,
    ProjectInterface *ifc,
    CreateInterface *
    )
  {
  auto type = Application::load(location.toUtf8().data(), parent);
  if(!type)
    {
    return nullptr;
    }

  auto asset = type->castTo<AssetType>();
  if(!asset)
    {
    return nullptr;
    }

  asset->setPath(location.toUtf8().data(), ifc);
  asset->_assetParent.setPointed(assetParent);
  asset->setSaved();
  return asset;
  }
示例#2
0
void ProjectBase::save(bool saveAllOMCases)
{
    Save::saveProject(this,saveAllOMCases);

    setSaved(true);
    emit projectChanged();
}
示例#3
0
bool ProjectBase::load(QString loadPath)
{
    if(_saveLoadMutex.tryLock())
    {
        bool configOk = checkConfiguration();
        bool loaded = false;

        if(configOk)
            loaded = Load::loadProject(loadPath,this);

        if (loaded)
        {
            emit InfoSender::instance()->send( Info(ListInfo::PROJECTLOADSUCCESSFULL,filePath()));
            emit projectChanged();
        }
        else
        {
            emit InfoSender::instance()->send( Info(ListInfo::PROJECTLOADFAILED,filePath()));
            clear();
            emit projectChanged();
        }
        setSaved(true);
        emit projectChanged();
        _saveLoadMutex.unlock();
        return loaded;
    }
}
示例#4
0
bool ExternalDbAsset::save()
  {
  auto ass = cachedAsset();
  if (ass)
    {
    auto obj = ass->castTo<File>();
    if (obj)
      {
      obj->setSaved();
      }
    }

  return ExternalAssetType::save();
  }
示例#5
0
GMap::GMap(Biome *biome_)
{
    // Player

    // Coords
    setPlayerX(0);
    setPlayerY(0);

    // Map

    // Biome
    biome = biome_;

    // Saved
    setSaved(true);
}
示例#6
0
void updateInfoDialog(LPCTSTR filename, int song)
{
	int songs;
	int i;
	if (infoDialog == NULL)
		return;
	if (edited_info == NULL) {
		edited_info = ASAPInfo_New();
		if (astil == NULL)
			astil = ASTIL_New();
		if (edited_info == NULL || astil == NULL) {
			closeInfoDialog();
			return;
		}
	}
	else if (infoChanged())
		return;
	if (!loadModule(filename, saved_module, &saved_module_len)
	 || !ASAPInfo_Load(edited_info, filename, saved_module, saved_module_len)) {
		closeInfoDialog();
		return;
	}
	setSaved();
	can_save = isExt(filename, _T(".sap"));
	invalid_fields = 0;
	SendDlgItemMessage(infoDialog, IDC_FILENAME, WM_SETTEXT, 0, (LPARAM) filename);
	SendDlgItemMessage(infoDialog, IDC_AUTHOR, WM_SETTEXT, 0, (LPARAM) saved_author);
	SendDlgItemMessage(infoDialog, IDC_NAME, WM_SETTEXT, 0, (LPARAM) saved_title);
	SendDlgItemMessage(infoDialog, IDC_DATE, WM_SETTEXT, 0, (LPARAM) saved_date);
	SendDlgItemMessage(infoDialog, IDC_SONGNO, CB_RESETCONTENT, 0, 0);
	songs = ASAPInfo_GetSongs(edited_info);
	EnableWindow(GetDlgItem(infoDialog, IDC_SONGNO), songs > 1);
	for (i = 1; i <= songs; i++) {
		_TCHAR str[16];
		_stprintf(str, _T("%d"), i);
		SendDlgItemMessage(infoDialog, IDC_SONGNO, CB_ADDSTRING, 0, (LPARAM) str);
	}
	if (song < 0)
		song = ASAPInfo_GetDefaultSong(edited_info);
	SendDlgItemMessage(infoDialog, IDC_SONGNO, CB_SETCURSEL, song, 0);
	setEditedSong(song);
	EnableWindow(GetDlgItem(infoDialog, IDC_SAVE), FALSE);
	updateTech();
}
示例#7
0
static BOOL saveFile(LPCTSTR filename, BOOL tag)
{
	BOOL isSap = isExt(filename, _T(".sap"));
	if (isSap) {
		int song = ASAPInfo_GetSongs(edited_info);
		while (--song >= 0 && ASAPInfo_GetDuration(edited_info, song) < 0);
		while (--song >= 0) {
			if (ASAPInfo_GetDuration(edited_info, song) < 0) {
				MessageBox(infoDialog, _T("Cannot save file because time not set for all songs"), _T("Error"), MB_OK | MB_ICONERROR);
				return FALSE;
			}
		}
	}
	if (!doSaveFile(filename, tag)) {
		MessageBox(infoDialog, _T("Cannot save file"), _T("Error"), MB_OK | MB_ICONERROR);
		// FIXME: delete file
		return FALSE;
	}
	if (isSap)
		setSaved();
	return TRUE;
}
示例#8
0
bool Score::saveFile()
{
    QString suffix = info.suffix();
    if (info.exists() && !info.isWritable()) {
        MScore::lastError = tr("The following file is locked: \n%1 \n\nTry saving to a different location.").arg(info.filePath());
        return false;
    }

    // if file was already saved in this session
    // save but don't overwrite backup again

    if (saved()) {
        try {
            if (suffix == "mscx")
                saveFile(info);
            else
                saveCompressedFile(info, false);
        }
        catch (QString s) {
            MScore::lastError = s;
            return false;
        }
        undo()->setClean();
        info.refresh();
        update();
        return true;
    }
    //
    // step 1
    // save into temporary file to prevent partially overwriting
    // the original file in case of "disc full"
    //

    QString tempName = info.filePath() + QString(".temp");
    QFile temp(tempName);
    if (!temp.open(QIODevice::WriteOnly)) {
        MScore::lastError = tr("Open Temp File\n%1\nfailed: %2").arg(tempName).arg(QString(strerror(errno)));
        return false;
    }
    try {
        if (suffix == "mscx")
            saveFile(&temp, false);
        else
            saveCompressedFile(&temp, info, false);
    }
    catch (QString s) {
        MScore::lastError = s;
        return false;
    }
    if (temp.error() != QFile::NoError) {
        MScore::lastError = tr("MuseScore: Save File failed: %1").arg(temp.errorString());
        temp.close();
        return false;
    }
    temp.close();

    //
    // step 2
    // remove old backup file if exists
    //
    QDir dir(info.path());
    QString backupName = QString(".") + info.fileName() + QString(",");
    if (dir.exists(backupName)) {
        if (!dir.remove(backupName)) {
//                  if (!MScore::noGui)
//                        QMessageBox::critical(0, tr("MuseScore: Save File"),
//                           tr("Removing old backup file ") + backupName + tr(" failed"));
        }
    }

    //
    // step 3
    // rename old file into backup
    //
    QString name(info.filePath());
    if (dir.exists(name)) {
        if (!dir.rename(name, backupName)) {
//                  if (!MScore::noGui)
//                        QMessageBox::critical(0, tr("MuseScore: Save File"),
//                           tr("Renaming old file <")
//                            + name + tr("> to backup <") + backupName + tr("> failed"));
        }
    }
#ifdef Q_OS_WIN
    QFileInfo fileBackup(dir, backupName);
    QString backupNativePath = QDir::toNativeSeparators(fileBackup.absoluteFilePath());
    SetFileAttributes((LPCTSTR)backupNativePath.toLocal8Bit(), FILE_ATTRIBUTE_HIDDEN);
#endif
    //
    // step 4
    // rename temp name into file name
    //
    if (!QFile::rename(tempName, name)) {
        MScore::lastError = tr("Renaming temp. file <%1> to <%2> failed:\n%3").arg(tempName).arg(name).arg(QString(strerror(errno)));
        return false;
    }
    // make file readable by all
    QFile::setPermissions(name, QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser
                          | QFile::ReadGroup | QFile::ReadOther);

    undo()->setClean();
    setSaved(true);
    info.refresh();
    update();
    return true;
}
示例#9
0
/**
 * Selects dataset with given name.
 */
void BaseModel::selectDataset(QString name){
	selSet = name;
	setSaved(false);
}
示例#10
0
/**
 * Selects network with given name.
 */
void BaseModel::selectNetwork(QString name){
	selNet = name;
	setSaved(false);
}
示例#11
0
/**
 * Emits changed signal.
 */
void BaseModel::modelChanged(ChangeType type){
	emit changed(type);
	setSaved(false);
}
示例#12
0
/**
 * Sets model as unsaved when data is changed.
 */
void DatasetEditModel::dataChanged(){
	setSaved(false);
}
示例#13
0
bool SoundFile::openWrite(const char *filename_, int rate_, int channels_, int bits_, int windowSize_, int stepSize_)
{
    uninit();
    setSaved(false);

    //_offset = (windowSize_ / stepSize_) / 2;
    _offset = windowSize_ / 2;
    fprintf(stderr, "--------Recording------------\n");
    fprintf(stderr, "filename = %s\n", filename_);
    fprintf(stderr, "rate = %d\n", rate_);
    fprintf(stderr, "channels = %d\n", channels_);
    fprintf(stderr, "bits = %d\n", bits_);
    fprintf(stderr, "windowSize = %d\n", windowSize_);
    fprintf(stderr, "stepSize = %d\n", stepSize_);
    fprintf(stderr, "-----------------------------\n");

    setFramesPerChunk(stepSize_);

    setFilename(filename_);
    //setFilteredFilename((QString(filename)+QString("~")).ascii());
    setFilteredFilename(getNextTempFilename());

    stream = new WaveStream;
    filteredStream = new WaveStream;
    if(stream->open_write(filename, rate_, channels_, bits_)) {
        fprintf(stderr, "Error opening %s for writting\n", filename);
        delete stream;
        stream = NULL;
        delete filteredStream;
        filteredStream = NULL;
        QString s = QString("Error opening ") + QString(filename) + QString(" for writing.\nPossible cause: temp folder is read-only or disk is out of space.\nPlease select a writable Temp Folder");
        QMessageBox::warning(mainWindow, "Error", s, QMessageBox::Ok, QMessageBox::NoButton);
        mainWindow->menuPreferences();
        return false;
    }
    if(filteredStream->open_write(filteredFilename, rate_, channels_, bits_)) {
        fprintf(stderr, "Error opening %s for writting\n", filteredFilename);
        delete stream;
        stream = NULL;
        delete filteredStream;
        filteredStream = NULL;
        QString s = QString("Error opening ") + QString(filteredFilename) + QString(" for writing.\nPossible cause: temp folder is read-only or disk is out of space.\nPlease select a writable Temp Folder");
        QMessageBox::warning(mainWindow, "Error", s, QMessageBox::Ok, QMessageBox::NoButton);
        mainWindow->menuPreferences();
        return false;
    }
    //printf("in_channels = %d\n", gdata->in_channels);
    //printf("stream->channels=%d\n", stream->channels);

    channels.resize(stream->channels);
    fprintf(stderr, "channels = %d\n", numChannels());
    for(int j=0; j<numChannels(); j++) {
        channels(j) = new Channel(this, windowSize_);
        fprintf(stderr, "channel size = %d\n", channels(j)->size());
        //channels(j)->setParent(this);
        channels(j)->setColor(gdata->getNextColor());
        //channels(j)->setPitchMethod(gdata->pitch_method[0]);
    }
    myTransforms.init(windowSize_, 0, stream->freq, gdata->doingEqualLoudness());

    //setup the tempChunkBuffers
    tempWindowBuffer = new float*[numChannels()];
    tempWindowBufferDouble = new double*[numChannels()];
    tempWindowBufferFiltered = new float*[numChannels()];
    tempWindowBufferFilteredDouble = new double*[numChannels()];
    for(int c=0; c<numChannels(); c++) {
        tempWindowBuffer[c] = (new float[bufferSize()+16]) + 16; //array ranges from -16 to bufferSize()
        tempWindowBufferDouble[c] = (new double[bufferSize()+16]) + 16; //array ranges from -16 to bufferSize()
        tempWindowBufferFiltered[c] = (new float[bufferSize()+16]) + 16; //array ranges from -16 to bufferSize()
        tempWindowBufferFilteredDouble[c] = (new double[bufferSize()+16]) + 16; //array ranges from -16 to bufferSize()
    }

    _doingDetailedPitch = gdata->doingDetailedPitch();

    return true;
}
示例#14
0
bool SoundFile::openRead(const char *filename_)
{
    uninit();
    setSaved(true);

    setFilename(filename_);
    //setFilteredFilename((QString(filename)+QString("~")).ascii());
    setFilteredFilename(getNextTempFilename());
    fprintf(stderr, "Opening file: %s\n(FilteredFilename: %s)\n", filename, filteredFilename);
//#ifdef USE_SOX
//  stream = new SoxStream;
//#else
    if(str_case_cmp(getFileExtension(filename), "wav") == 0) {
        stream = new WaveStream;
        filteredStream = new WaveStream;
    }
//#ifdef USE_OGG
//  else if(str_case_cmp(getFileExtension(filename), "ogg") == 0) {
//	  stream = new OggStream;
//  }
//#endif
    else {
        fprintf(stderr, "Cannot open file of this type. %s\n", filename);
        return false;
    }
//#endif

    if(stream->open_read(filename)) {
        fprintf(stderr, "Error opening %s\n", filename);
        return false;
    }
    //if(filteredStream->open_read((QString(filename) + QString("~")).ascii())) {
    if(filteredStream->open_write(filteredFilename, stream->freq, stream->channels, stream->bits)) {
        fprintf(stderr, "Error opening %s\n", filteredFilename);
        delete stream;
        stream = NULL;
        QString s = QString("Error opening ") + QString(filteredFilename) + QString(" for writing.\nPossible cause: temp folder is read-only or disk is out of space.\nPlease select a writable Temp Folder");
        QMessageBox::warning(mainWindow, "Error", s, QMessageBox::Ok, QMessageBox::NoButton);
        mainWindow->menuPreferences();
        return false;
    }

    channels.resize(stream->channels);
    int windowSize_ = gdata->getAnalysisBufferSize(stream->freq);
    fprintf(stderr, "channels = %d\n", numChannels());

    int stepSize_ = gdata->getAnalysisStepSize(stream->freq);
    //_offset = (windowSize_ / stepSize_) / 2;
    _offset = windowSize_ / 2;
    setFramesPerChunk(stepSize_); // The user needs to be able to set this

    for(int j=0; j<numChannels(); j++) {
        channels(j) = new Channel(this, windowSize_);
        fprintf(stderr, "channel size = %d\n", channels(j)->size());
        //channels(j)->setParent(this);
        channels(j)->setColor(gdata->getNextColor());
        //channels(j)->setPitchMethod(gdata->pitch_method[0]);
    }
    myTransforms.init(windowSize_, 0, stream->freq, gdata->doingEqualLoudness());

    fprintf(stderr, "----------Opening------------\n");
    fprintf(stderr, "filename = %s\n", filename_);
    fprintf(stderr, "rate = %d\n", rate());
    fprintf(stderr, "channels = %d\n", numChannels());
    fprintf(stderr, "bits = %d\n", bits());
    fprintf(stderr, "windowSize = %d\n", windowSize_);
    fprintf(stderr, "stepSize = %d\n", stepSize_);
    fprintf(stderr, "-----------------------------\n");

    //setup the tempChunkBuffers
    tempWindowBuffer = new float *[numChannels()];
    tempWindowBufferDouble = new double *[numChannels()];
    tempWindowBufferFiltered = new float *[numChannels()];
    tempWindowBufferFilteredDouble = new double *[numChannels()];
    for(int c=0; c<numChannels(); c++) {
        tempWindowBuffer[c] = (new float[bufferSize()+16]) + 16; //array ranges from -16 to bufferSize()
        tempWindowBufferDouble[c] = (new double[bufferSize()+16]) + 16; //array ranges from -16 to bufferSize()
        tempWindowBufferFiltered[c] = (new float[bufferSize()+16]) + 16; //array ranges from -16 to bufferSize()
        tempWindowBufferFilteredDouble[c] = (new double[bufferSize()+16]) + 16; //array ranges from -16 to bufferSize()
    }

    _doingDetailedPitch = gdata->doingDetailedPitch();

    return true;
}
示例#15
0
void ValueContainer::setFloat(std::string const& id, float value, bool save)
{
    setFloat(id,value);
    setSaved(id,save);
}
示例#16
0
bool MasterScore::saveFile()
      {
      QString suffix = info.suffix();
      if (info.exists() && !info.isWritable()) {
            MScore::lastError = tr("The following file is locked: \n%1 \n\nTry saving to a different location.").arg(info.filePath());
            return false;
            }
      //
      // step 1
      // save into temporary file to prevent partially overwriting
      // the original file in case of "disc full"
      //

      QString tempName = info.filePath() + QString(".temp");
      QFile temp(tempName);
      if (!temp.open(QIODevice::WriteOnly)) {
            MScore::lastError = tr("Open Temp File\n%1\nfailed: %2").arg(tempName, strerror(errno));
            return false;
            }
      bool rv = suffix == "mscx" ? Score::saveFile(&temp, false) : Score::saveCompressedFile(&temp, info, false);
      if (!rv) {
            return false;
            }

      if (temp.error() != QFile::NoError) {
            MScore::lastError = tr("Save File failed: %1").arg(temp.errorString());
            return false;
            }
      temp.close();

      QString name(info.filePath());
      QString basename(info.fileName());
      QDir dir(info.path());
      if (!saved()) {
            // if file was already saved in this session
            // save but don't overwrite backup again

            //
            // step 2
            // remove old backup file if exists
            //
            QString backupName = QString(".") + info.fileName() + QString(",");
            if (dir.exists(backupName)) {
                  if (!dir.remove(backupName)) {
//                      if (!MScore::noGui)
//                            QMessageBox::critical(0, QObject::tr("Save File"),
//                               tr("Removing old backup file %1 failed").arg(backupName));
                        }
                  }

            //
            // step 3
            // rename old file into backup
            //
            if (dir.exists(basename)) {
                  if (!dir.rename(basename, backupName)) {
//                      if (!MScore::noGui)
//                            QMessageBox::critical(0, tr("Save File"),
//                               tr("Renaming old file <%1> to backup <%2> failed").arg(name, backupname);
                        }
                  }
#ifdef Q_OS_WIN
            QFileInfo fileBackup(dir, backupName);
            QString backupNativePath = QDir::toNativeSeparators(fileBackup.absoluteFilePath());
#if (defined (_MSCVER) || defined (_MSC_VER))
   #if (defined (UNICODE))
            SetFileAttributes((LPCTSTR)backupNativePath.unicode(), FILE_ATTRIBUTE_HIDDEN);
   #else
            // Use byte-based Windows function
            SetFileAttributes((LPCTSTR)backupNativePath.toLocal8Bit(), FILE_ATTRIBUTE_HIDDEN);
   #endif
#else
            SetFileAttributes((LPCTSTR)backupNativePath.toLocal8Bit(), FILE_ATTRIBUTE_HIDDEN);
#endif
#endif
            }
      else {
            // file has previously been saved - remove the old file
            if (dir.exists(basename)) {
                  if (!dir.remove(basename)) {
//                      if (!MScore::noGui)
//                            QMessageBox::critical(0, tr("Save File"),
//                               tr("Removing old file %1 failed").arg(name));
                        }
                  }
            }

      //
      // step 4
      // rename temp name into file name
      //
      if (!QFile::rename(tempName, name)) {
            MScore::lastError = tr("Renaming temp. file <%1> to <%2> failed:\n%3").arg(tempName, name, strerror(errno));
            return false;
            }
      // make file readable by all
      QFile::setPermissions(name, QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser
         | QFile::ReadGroup | QFile::ReadOther);

      undoStack()->setClean();
      setSaved(true);
      info.refresh();
      update();
      return true;
      }
示例#17
0
/**
 * Saves model to file.
 */
void DatasetEditModel::save(){
	reduceToMinSize();
	DatasetMdlParser& parser = DatasetMdlParser::get();
	setSaved(parser.save(this));
	viewMdl->emitLayoutChanged();
}