示例#1
0
std::string Strings::getValue(const char* name) const
{
	std::string nameStr(name);
	int i = indexOfName(nameStr.c_str());
	if (i >= 0)
		return getString(i).substr(nameStr.length() + 1);
	else
		return "";
}
示例#2
0
void Strings::setValue(const char* name, const char* value)
{
	std::string nameStr(name);
	std::string valueStr(value);

	int i = indexOfName(nameStr.c_str());
	if (valueStr.empty())
	{
		if (i >= 0) del(i);
	}
	else
	{
		if (i < 0)
			i = add("");
		setString(i, (nameStr + getNameValueSeparator() + valueStr).c_str());
	}
}
void SampleView::updateSampleChemSymbol(QString chemSymbol){


    // Grab model index of currently selected sample.
    QModelIndex currentIndex = sampleListView_->selectionModel()->currentIndex();
    // In order to keep the sample name constant as the user updates the chemical symbol, grab the index of the name value
    // of the currently selected sample and store it as a string. Sample name is index-0 of model.
    QModelIndex indexOfName(currentIndex.model()->index(currentIndex.row(), 0, currentIndex.parent()));
    QString currentNameValue_ = (indexOfName.data(Qt::DisplayRole).toString());
    // The updated sample title.
    QStandardItem *item = new QStandardItem(currentNameValue_ + " - " + chemSymbol);
    // Set the model at the selected index row. Recall column 4 (index 3) is the sample title.
    sampleModel_->setItem(currentIndex.row(), 3, item);
    // Ensure proper mapping from edit widgets to model. Behaviour is buggy without it.
    modelToWidgetMapper_->submit();
    // Once a single character has changed the focus is lost on the sampleListView and any additional changes to the edit will not be
    // noticed by the sampleListView and cause program to crash. This returns focus, and more imporantly the index selection, back to the sampleListView.
    sampleListView_->selectionModel()->setCurrentIndex(currentIndex, QItemSelectionModel::Select);

}
示例#4
0
	{
		mOrderedImages = NULL;
		setMergeDirty();
	}

	void AtlasMerge::setMergeDirty()
	{
		mMergeDirty = true;
		mBlockBelongs.drop();
	}

	void AtlasMerge::setImage(c_str name, grab(Image) img)
	{
		assert(img->getWidth() > 0 && img->getHeight() > 0);
		String sName(name);
		int index = indexOfName(sName);
		if (index < 0){
			AtlasImageData *data = new AtlasImageData(sName, img);
			mImages.append(data);
			setImageDirty();
		}
	}

	void AtlasMerge::removeImage(c_str name)
	{
		String sName(name);
		int index = indexOfName(sName);
		if (index >= 0){
			mImages.remove(index);
			setOrderDirty();
		}