void RecentFilesManager::SetFileToRecent(const DAVA::String& file)
{
    DAVA::Vector<String> vectorToSave = GetRecentFiles();
    DAVA::FilePath filePath(file);
    DAVA::String stringToInsert = filePath.GetAbsolutePathname();
    //check present set to avoid duplicates
    vectorToSave.erase(std::remove(vectorToSave.begin(), vectorToSave.end(), stringToInsert), vectorToSave.end());
    
    vectorToSave.insert(vectorToSave.begin(), stringToInsert);

    uint32 recentFilesMaxCount = SettingsManager::GetValue(Settings::General_RecentFilesCount).AsInt32();

    DAVA::uint32 size = vectorToSave.size() > recentFilesMaxCount ? recentFilesMaxCount : vectorToSave.size();
    KeyedArchive* archive = new KeyedArchive();
    for (DAVA::uint32 i = 0; i < size; ++i)
    {
        archive->SetString(Format("%d",i), vectorToSave[i]);
    }
    SettingsManager::SetValue(Settings::Internal_RecentFiles, DAVA::VariantType(archive));
    SafeRelease( archive);
}
Example #2
0
QWidget* ActionItemEditDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
					  const QModelIndex &index) const
{	
	QWidget* editor = NULL;
	switch(index.column())
	{
		case COLUMN_ACTION_TYPE:
		{
			QComboBox* combo = new QComboBox(parent);
			combo->setFrame(false);
			for(int i = 1; i < ACTION_NAME_COUNT - 1; ++i) //do not add sound aciton
			{
				combo->addItem(ACTION_TYPE_NAME[i]);
			}
			
			editor = combo;
			
			break;
		}
			
		case COLUMN_ENTITY_NAME:
		{
			DAVA::Entity* parentEntity = targetComponent->GetEntity();
			DAVA::Vector<DAVA::Entity*> allChildren;
			parentEntity->GetChildNodes(allChildren);

			DAVA::Vector<DAVA::String> childrenNames;
			childrenNames.push_back(parentEntity->GetName());
			for(int i = 0; i < allChildren.size(); ++i)
			{
				childrenNames.push_back(allChildren[i]->GetName());
			}
			
			std::sort(childrenNames.begin(), childrenNames.end());
			childrenNames.erase(std::unique(childrenNames.begin(), childrenNames.end()), childrenNames.end());
			
			QComboBox* combo = new QComboBox(parent);
			combo->setFrame(false);
			for(int i = 0; i < childrenNames.size(); ++i)
			{
				combo->addItem(childrenNames[i].c_str());
			}
			
			editor = combo;
			
			break;
		}
			
		case COLUMN_DELAY:
		{
			QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent);
			spinBox->setMinimum(0.0f);
			spinBox->setMaximum(3600.f);
			spinBox->setSingleStep(0.01f);
			
			editor = spinBox;
			
			break;
		}
			
		case COLUMN_SWITCH_INDEX:
		{
			QSpinBox* spinBox = new QSpinBox(parent);
			spinBox->setMinimum(-1);
			spinBox->setMaximum(128);
			spinBox->setSingleStep(1);
			
			editor = spinBox;

			break;
		}
			
		case COLUMN_STOPAFTERNREPEATS_INDEX:
		{
			QSpinBox* spinBox = new QSpinBox(parent);
			spinBox->setMinimum(-1);
			spinBox->setMaximum(100000);
			spinBox->setSingleStep(1);
			
			editor = spinBox;
			
			break;
		}

		case COLUMN_STOPWHENEMPTY_INDEX:
		{
			QComboBox* combo = new QComboBox(parent);
			combo->setFrame(false);
			combo->addItem("Yes");
			combo->addItem("No");
			
			editor = combo;
			break;
		}
	}

	DVASSERT(editor);
	return editor;
}