Beispiel #1
0
 /*! @brief Add a character string representation of a floating-point value to the buffer.
  @param[in] aDouble The value to add.
  @returns The StringBuffer object so that cascading can be done. */
 inline StringBuffer &
 addDouble
     (const double   aDouble)
 {
     addString(ConvertDoubleToString(aDouble));
     return *this;
 } // addDouble
bool ParamComboBox :: AddOption (const SharedType *value_p, char *option_s, const SharedType *current_param_value_p)
{
	QVariant *v_p = 0;
	bool alloc_display_flag = false;
	bool success_flag = false;
	bool current_value_flag = false;

	switch (bpw_param_p -> pa_type)
		{
			case PT_STRING:
			case PT_KEYWORD:
			case PT_LARGE_STRING:
				{
					v_p = new QVariant (value_p -> st_string_value_s);

					if (current_param_value_p)
						{
							if (strcmp (value_p -> st_string_value_s, current_param_value_p -> st_string_value_s) == 0)
								{
									current_value_flag = true;
								}
						}

					if (!option_s)
						{
							option_s = value_p -> st_string_value_s;
						}
				}
				break;

			case PT_UNSIGNED_INT:
				v_p = new QVariant (value_p -> st_ulong_value);

				if (current_param_value_p)
					{
						if (value_p -> st_ulong_value == current_param_value_p -> st_ulong_value)
							{
								current_value_flag = true;
							}
					}

				if (!option_s)
					{
						option_s =	ConvertIntegerToString (value_p -> st_ulong_value);
						alloc_display_flag = (option_s != 0);
					}
				break;

		case PT_SIGNED_INT:
			v_p = new QVariant (value_p -> st_long_value);

			if (current_param_value_p)
				{
					if (value_p -> st_long_value == current_param_value_p -> st_long_value)
						{
							current_value_flag = true;
						}
				}

			if (!option_s)
				{
					option_s =	ConvertIntegerToString (value_p -> st_long_value);
					alloc_display_flag = (option_s != 0);
				}
			break;

		case PT_SIGNED_REAL:
		case PT_UNSIGNED_REAL:
			v_p = new QVariant (value_p -> st_data_value);

			if (current_param_value_p)
				{
					if (value_p -> st_data_value == current_param_value_p -> st_data_value)
						{
							current_value_flag = true;
						}
				}

			if (!option_s)
				{
					option_s =	ConvertDoubleToString (value_p -> st_data_value);
					alloc_display_flag = (option_s != 0);
				}
			break;

		default:
				break;
		}

	if (v_p && option_s)
		{
			QString display_str = QString (option_s);
			const int index = pcb_combo_box_p -> count ();
			pcb_combo_box_p -> insertItem (index, display_str, *v_p);

			if (current_value_flag)
				{
					pcb_combo_box_p -> setCurrentIndex (index);
				}

			success_flag = true;
		}

	if (alloc_display_flag)
		{
			FreeCopiedString (option_s);
		}

	if (v_p)
		{
			delete v_p;
		}

	return success_flag;
}