Exemple #1
0
bool CWizIndexBase::CreateStyleEx(const WIZSTYLEDATA& data)
{
    qDebug() << "create style, name: " << data.strName;

    Q_ASSERT(data.strKbGUID == m_strKbGUID);

    CString strFormat = FormatInsertSQLFormat(TABLE_NAME_WIZ_STYLE, FIELD_LIST_WIZ_STYLE, PARAM_LIST_WIZ_STYLE);

    CString strSQL;
    strSQL.Format(strFormat,
        STR2SQL(data.strGUID).utf16(),
        STR2SQL(data.strName).utf16(),
        STR2SQL(data.strDescription).utf16(),
        COLOR2SQL(data.crTextColor).utf16(),
        COLOR2SQL(data.crBackColor).utf16(),
        data.bTextBold ? 1 : 0,
        data.nFlagIndex,
        TIME2SQL(data.tModified).utf16(),
        WizInt64ToStr(data.nVersion).utf16()
        );


    if (!ExecSQL(strSQL))
        return false;

    if (!m_bUpdating) {
        emit styleCreated(data);
    }

    return true;
}
IMessageStyle *SimpleMessageStyleEngine::styleForOptions(const IMessageStyleOptions &AOptions)
{
	if (!FStyles.contains(AOptions.styleId))
	{
		QString stylePath = FStylePaths.value(AOptions.styleId);
		if (!stylePath.isEmpty())
		{
			SimpleMessageStyle *style = new SimpleMessageStyle(stylePath, FNetworkAccessManager, this);
			if (style->isValid())
			{
				LOG_INFO(QString("Simple style created, id=%1").arg(style->styleId()));
				FStyles.insert(AOptions.styleId,style);
				connect(style,SIGNAL(widgetAdded(QWidget *)),SLOT(onStyleWidgetAdded(QWidget *)));
				connect(style,SIGNAL(widgetRemoved(QWidget *)),SLOT(onStyleWidgetRemoved(QWidget *)));
				emit styleCreated(style);
			}
			else
			{
				delete style;
				REPORT_ERROR(QString("Failed to create simple style id=%1: Invalid style").arg(AOptions.styleId));
			}
		}
		else
		{
			REPORT_ERROR(QString("Failed to create simple style id=%1: Style not found").arg(AOptions.styleId));
		}
	}
	return FStyles.value(AOptions.styleId);
}