Beispiel #1
0
/// Apply the cell value to the property, and notify the
/// item object.
void ctPropertyEditor::ApplyCellValueToProperty(int row, int col)
{
    static bool s_Applying = false;

    if (s_Applying)
        return;

    s_Applying = true;
    if (col == 1 && m_item)
    {
        ctProperty* prop = m_item->GetProperties().GetNth(row);

        wxString value = m_attributeEditorGrid->GetCellValue(row, col);
        if (prop->GetEditorType() == wxT("multiline"))
            value = ctConvertToMultilineText(value);

        wxVariant variant = prop->GetVariant();

        if (prop->GetVariant().GetType() == _T("bool"))
        {
            if (value == _T("1"))
                variant = true;
            else
                variant = false;
        }
        else if (prop->GetVariant().GetType() == _T("long"))
        {
            long l;
            value.ToLong(& l);
            variant = l;
        }
        else if (prop->GetVariant().GetType() == _T("double"))
        {
            double d;
            value.ToDouble(& d);
            variant = d;
        }
        else
        {
            variant = value;
        }

        ApplyPropertyValue(m_item, prop, variant);

        if (prop->GetName() == _T("description"))
            UpdateDescription(row);
    }
    s_Applying = false;
}
void ChangeFontPropertyCommand::Rollback()
{
	// The previous values are stored in Command Data.
	QString propertyName = GetPropertyName();
    for (COMMANDDATAVECTITER iter = this->commandData.begin(); iter != commandData.end(); iter ++)
    {
		Font* previousValue = (*iter).GetTreeNodePropertyValue();
		bool propertySetOK = ApplyPropertyValue(iter, previousValue);
		// Always restore control rect for align property while rollback
//		RestoreControlRect(iter);
        
        //TODO: revert changes
        

        if (propertySetOK)
        {			
            CommandsController::Instance()->EmitChangePropertySucceeded(propertyName);
        }
        else
        {
			CommandsController::Instance()->EmitChangePropertyFailed(propertyName);
        }
    }
}