コード例 #1
0
void ComposerTextEdit::slotPasteAsQuotation()
{
    QString text = qApp->clipboard()->text();
    if (text.isEmpty())
        return;

    QStringList lines = text.split(QLatin1Char('\n'));
    for (QStringList::iterator it = lines.begin(); it != lines.end(); ++it) {
        it->remove(QLatin1Char('\r'));
        if (it->startsWith(QLatin1Char('>'))) {
            *it = QLatin1Char('>') + *it;
        } else {
            *it = QLatin1String("> ") + *it;
        }
    }
    text = lines.join(QStringLiteral("\n"));
    if (!text.endsWith(QLatin1Char('\n'))) {
        text += QLatin1Char('\n');
    }

    QTextCursor cursor = textCursor();
    cursor.beginEditBlock();
    cursor.insertBlock();
    cursor.insertText(text);
    cursor.endEditBlock();
    setTextCursor(cursor);
}
コード例 #2
0
void synaxErrorJudger::getAttributeInfo(vector<string> &attributeNameList,
	vector<pair<int, size_t>> &dataTypeInfo, set<string> &uniqueAttribute)
{
	int begin = sqlExp.indexOf('(') + 1;
	int end = sqlExp.lastIndexOf(',') - 1;
	QStringList attrList = sqlExp.mid(begin, end - begin + 1).split(',');
	QStringList::iterator it;
	for (it = attrList.begin(); it != attrList.end(); ++it) {
		if (it->trimmed() == "") {
			throw QString("Synax Error: Create statement's format is incorrect.");
		}
		string attributeName = it->section(' ', 0, 0, QString::SectionSkipEmpty).trimmed().toStdString();
		attributeNameList.push_back(attributeName);
		if (it->indexOf("unique") != -1) {
			uniqueAttribute.insert(attributeName);
			it->remove(it->indexOf("unique"), sizeof("unique") - 1);
		}
		it->remove(it->indexOf(attributeName.c_str()), attributeName.size());
		*it = it->trimmed();
		if (*it == "int") {
			dataTypeInfo.push_back(pair<int, size_t>(_INT, sizeof(int)));
		}
		else if (*it == "char") {
			dataTypeInfo.push_back(pair<int, size_t>(_CHAR, sizeof(char)));
		}
		else if (*it == "float") {
			dataTypeInfo.push_back(pair<int, size_t>(_FLOAT, sizeof(float)));
		}
		else { //一定是char(n,因为通过了前面正则表达式的匹配
			it->remove("char").remove('(').remove(')'); //去除括号
			int length = it->trimmed().toInt();
			if (length < 1 || length > 255) {
				throw QString("Synax Error: The length of string is overflow.");
			}
			dataTypeInfo.push_back(pair<int, size_t>(_STRING, sizeof(char) * length));
		}
	}
}
コード例 #3
0
bool synaxErrorJudger::isAlldataTypeValid(QStringList &data,  vector<pair<int, size_t>> &dataTypeInfo)
{
	QStringList::iterator it;
	for (it = data.begin(); it != data.end(); ++it) {
		*it = it->trimmed();
		if (*it == "") {
			return false;
		}
		bool ok;
		if (it->indexOf('\'') != -1) { //引号'应该是字符或字符串
			it->remove(0, 1).remove(QRegExp("'$"));
			size_t len = it->size();
			if (len < 1 || len > 255) {
				return false;
			}
			else if (len == 1) {
				dataTypeInfo.push_back(pair<int, size_t>(_CHAR, sizeof(char)));
			}
			else {
				dataTypeInfo.push_back(pair<int, size_t>(_STRING, len * sizeof(char)));
			}
		}
		else if (it->indexOf('.') != -1) { //有小数点且不是字符串,应该是float
			it->toFloat(&ok);
			if (!ok) {
				return false;
			}
			else {
				dataTypeInfo.push_back(pair<int, size_t>(_FLOAT, sizeof(float)));
			}
		}
		else { //剩下的应该是int类型
			it->toInt(&ok);
			if (!ok) {
				return false;
			}
			else {
				dataTypeInfo.push_back(pair<int, size_t>(_INT, sizeof(int)));
			}
		}
	}
	return true;
}
コード例 #4
0
ファイル: xboardengine.cpp プロジェクト: eliaskousk/cutechess
EngineOption* XboardEngine::parseOption(const QString& line)
{
	int start = line.indexOf('-');
	if (start < 2)
		return 0;

	QString name(line.left(start - 1));

	start++;
	int end = line.indexOf(' ', start);
	if (end == -1)
		end = line.length();
	QString type(line.mid(start, end - start));

	if (type == "button" || type == "save")
		return new EngineButtonOption(name);
	if (type == "check")
	{
		bool value = line.mid(end + 1) == "1";
		return new EngineCheckOption(name, value, value);
	}
	if (type == "string" || type == "file" || type == "path")
	{
		QString value(line.mid(end + 1));
		EngineTextOption::EditorType editorType;

		if (type == "file")
			editorType = EngineTextOption::FileDialog;
		else if (type == "path")
			editorType = EngineTextOption::FolderDialog;
		else
			editorType = EngineTextOption::LineEdit;

		return new EngineTextOption(name, value, value, QString(), editorType);
	}
	if (type == "spin" || type == "slider")
	{
		QStringList params(line.mid(end + 1).split(' ', QString::SkipEmptyParts));
		if (params.size() != 3)
			return 0;

		bool ok = false;
		int value = params.at(0).toInt(&ok);
		if (!ok)
			return 0;

		int min = params.at(1).toInt(&ok);
		if (!ok || min > value)
			return 0;

		int max = params.at(2).toInt(&ok);
		if (!ok || max < value)
			return 0;

		return new EngineSpinOption(name, value, value, min, max);
	}
	if (type == "combo")
	{
		QStringList choices = line.mid(end + 1).split(" /// ", QString::SkipEmptyParts);
		if (choices.isEmpty())
			return 0;

		QString value;
		QStringList::iterator it;
		for (it = choices.begin(); it != choices.end(); ++it)
		{
			if (it->startsWith('*'))
			{
				it->remove(0, 1);
				value = *it;
			}
		}
		if (value.isEmpty())
			value = choices.first();

		return new EngineComboOption(name, value, value, choices);
	}

	return 0;
}
コード例 #5
0
bool LeScienze500::ExecQuery()
{
    QueryDB db ;
    QueryData query_data ;

    if ( ui->Select_ParoleChiave->isChecked() )
        db.p_chiave = true ;

    if ( ui->Select_RicercaTesto->isChecked() )
        db.testo = true ;

    if ( ui->Select_RicercaCategoria->isChecked() )
        db.categorie = true ;

    if ( ui->Select_Anno->isChecked() )
        db.anno = true ;

    if ( ui->Select_ListaAutori->isChecked() )
        db.autori_l = true ;

    if ( ui->Select_Rubriche->isChecked() )
        db.rubriche = true ;

    if ( ui->AND_Button->isChecked() )
        db.global_and = true ;
    else
        db.global_and = false ;

    if ( this->menu_AND->isChecked() )
        db.setLogicalTestoEsteso( true );
    else if ( this->menu_OR->isChecked() )
        db.setLogicalTestoEsteso( false );

    if ( this->menu_AND_titolo->isChecked() )
        db.setLogicalTitolo( true );
    else if ( this->menu_OR_titolo->isChecked() )
        db.setLogicalTitolo( false );

    if ( ui->actionCerca_solo_nei_favoriti->isChecked() )
        db.fvorites_only = true ;
    else
        db.fvorites_only = false ;

    if ( db.p_chiave )
    {
        QString testo = ui->ParoleChiave->text() ;
        testo = testo.replace( "*" , "%" ) ;
        QStringList parole_c = testo.split( " " , QString::SkipEmptyParts ) ;
        db.setParoleChiave( parole_c );

        QString testo_b = ui->ParoleChiaveAbstract->text() ;
        testo_b = testo_b.replace( "*" , "%" ) ;
        QStringList parole_c_a = testo_b.split(" " , QString::SkipEmptyParts ) ;
        db.setParoleChiaveAbstract( parole_c_a );;

        // Nuovo in sviluppo
        query_data.setParoleChiaveTitolo( ui->ParoleChiave->text() );
        query_data.setParoleChiaveAbstract( ui->ParoleChiaveAbstract->text() );
    }

    if ( db.rubriche )
    {
        QStringList lista_rubriche ;
        lista_rubriche = ReadSelectedItems( ui->ListaRubriche ) ;
        db.setListaRubriche( lista_rubriche );

        query_data.setRubriche( lista_rubriche );
    }

    if ( db.categorie )
    {
        QStringList lista_categorie ;
        lista_categorie = ReadSelectedItems( ui->ListaCategorie ) ;
        db.setListaCategorie( lista_categorie ) ;

        query_data.setCategorie( lista_categorie );
    }

    if( db.autori_l )
    {
        QStringList lista_autori ;
        lista_autori = ReadSelectedItems( ui->ListaAutori ) ;
        db.setListaAutori( lista_autori ); ;
    }

    if( db.anno )
    {
        QStringList lista_anni ;
        lista_anni = ReadSelectedItems( ui->ListaAnni ) ;
        db.setListaAnni( lista_anni );
    }

    if ( db.testo )
    {
        QStringList lista_frasi ;
        QString frasi = ui->ParoleChiaveTesto->text() ;
        //qDebug() << "frase: " << frasi ;

        QString word_char = "\\w\\.:;,\\+-/\\*'`" ;
        //QString word_char = "\\w" ;
        QString S_regx = QString( "(\"[%1\\s]+\"|\\s[%1]+\\s|[%1]+\\s|^[%1]+\\s|\\s[%1]+$|[%1]+$|^[%1]+$)" ).arg(word_char) ;
        //QString S_regx = QString( "(\\s[%1]+\\s)" ).arg(word_char) ;

        QRegExp regx( S_regx )  ;

        if ( !regx.isValid() )
        {
            qDebug() << "Regex Error: " << regx.errorString() ;
        }

        qDebug() << S_regx ;

        int pos = 0;
        while ( pos >= 0 )
        {
            pos = regx.indexIn( frasi, pos ) ;
            if ( pos > -1 )
            {
                lista_frasi += regx.cap(1) ;
                pos  += regx.matchedLength() ;
            }
        }

        for (QStringList::iterator it = lista_frasi.begin(); it < lista_frasi.end(); it++ )
        {
            it->remove( QRegExp("(\"|^\\s|\\s$)") ) ;
            qDebug() << "parola: " << *it ;
        }

        db.setFrasiTestoEsteso( lista_frasi ) ;
    }

    QueryResult  q_result ;

    db.execMainQuery( q_result ) ;

    fillResultTable( q_result ) ;

    return true ;
}
コード例 #6
0
void synaxErrorJudger::generateCondition()
{
	int begin = sqlExp.indexOf("where") + 5;
	int end = sqlExp.indexOf(QRegExp(";$")) - 1;
	QStringList conditions = sqlExp.mid(begin, end - begin + 1).split("and");
	QStringList::iterator it;
	pair<int, size_t> dataType;
	int logicType;
	string rightSide, leftSide;
	for (it = conditions.begin(); it != conditions.end(); ++it) {	
		*it = it->trimmed();
		if (*it == "") {
			throw QString("Synax Error: Conditions' format is incorrect.");
		}
		int begin = 0;
		int end = it->indexOf(QRegExp("[=><]"))-1;
		rightSide = it->mid(begin, end - begin + 1).trimmed().toStdString();
		begin = end + 1;
		end = it->indexOf(QRegExp("[=><]"), begin + 1);
		if (end - begin > 1 || end == -1) { //如果下一个"=",">","<"号出现在较远处
			end = begin; //说明这个逻辑关系是"=",">","<"而非">=", "<=", "<>" 
		}
		logicType = condition::getLogicTypeFromStr(it->mid(begin, end - begin + 1).toStdString());
		if (logicType == _ERROR) {
			throw QString("Synax Error: The logic arithemtic is invalid.");
		}
		bool ok;
		*it = it->mid(end + 1).trimmed();
		if (it->indexOf(QRegExp("^'")) != -1) { //引号'应该是字符或字符串
			it->remove(0, 1).remove(QRegExp("'$"));
			size_t len = it->size();
			pair<int, size_t> dType;
			Api::cManager.getAttributeDataType(*tblName, rightSide, dType);
			if (len < 1 || len > 255 || len > dType.second) {
				throw QString("Synax Error: The length of string is overflow.");
			}
			else if (len == 1) {
				dataType = pair<int, size_t>(_CHAR, sizeof(char));
			}
			else {
				dataType = pair<int, size_t>(_STRING, dType.second * sizeof(char));
			}
		}
		else if (it->indexOf('.') != -1) { //有小数点且不是字符串,应该是float
			it->toFloat(&ok);
			if (!ok) {
				;
			}
			else {
				dataType = pair<int, size_t>(_FLOAT, sizeof(float));
			}
		}
		else { //剩下的应该是int类型
			it->toInt(&ok);
			if (!ok) {
				;
			}
			else {
				dataType = pair<int, size_t>(_INT, sizeof(int));
			}
		}
		leftSide = it->toStdString();
		if (cond == 0) {
			cond = new vector<condition>;
		}
		cond->push_back(condition(rightSide, logicType, dataType, leftSide));
	}
}
コード例 #7
0
ファイル: gettextexport.cpp プロジェクト: ShermanHuang/kdesdk
ConversionStatus GettextExportPlugin::save(QIODevice* device,
                                           const GettextStorage* catalog)
{
    QTextStream stream(device);

    //if ( m_wrapWidth == -1 ) m_wrapWidth=80;

#if 0
//legacy
    if (useOldEncoding && catalog->fileCodec())
    {
        stream.setCodec(catalog->fileCodec());
    }
    else

    {
        /*         switch(_saveSettings.encoding)
                 {
                    case ProjectSettingsBase::UTF8:
                       stream.setCodec(QTextCodec::codecForName("utf-8"));
                       break;
                    case ProjectSettingsBase::UTF16:
                       stream.setCodec(QTextCodec::codecForName("utf-16"));
                       break;
                    default:
        	       stream.setCodec(QTextCodec::codecForLocale());
                       break;
                 }*/
#endif
    //NOTE i had a look and even ja team uses utf-8 now
    stream.setCodec(QTextCodec::codecForName("utf-8"));


    // only save header if it is not empty
    const QString& headerComment( catalog->m_header.comment() );
    // ### why is this useful to have a header with an empty msgstr?
    if ( !headerComment.isEmpty() || !catalog->m_header.msgstrPlural().isEmpty() )
    {
        // write header
        writeComment( stream, headerComment );

        const QString& headerMsgid (catalog->m_header.msgid());

        // Gettext PO files should have an empty msgid as header
        if ( !headerMsgid.isEmpty() )
        {
            // ### perhaps it is grave enough for a user message
            kWarning() << "Non-empty msgid for the header, assuming empty msgid!" << endl << headerMsgid << "---";
        }

        // ### FIXME: if it is the header, then the msgid should be empty! (Even if KBabel has made something out of a non-header first entry!)
        stream << "msgid \"\"\n";

        writeKeyword( stream, "msgstr", catalog->m_header.msgstr(), false );
    }


    const QVector<CatalogItem>& catalogEntries=catalog->m_entries;
    int limit=catalog->numberOfEntries();
    QStringList list;
    for (int counter = 0; counter < limit; counter++)
    {
        stream << '\n';

        // write entry
        writeComment( stream, catalogEntries.at(counter).comment() );

        const QString& msgctxt = catalogEntries.at(counter).msgctxt();
        if (! msgctxt.isEmpty() )
            writeKeyword( stream, "msgctxt", msgctxt );

        writeKeyword( stream, "msgid", catalogEntries.at(counter).msgid(), true, catalogEntries.at(counter).prependEmptyForMsgid() );
        if ( catalogEntries.at(counter).isPlural() )
            writeKeyword( stream, "msgid_plural", catalogEntries.at(counter).msgid(1), true, catalogEntries.at(counter).prependEmptyForMsgid() );

        if (!catalogEntries.at(counter).isPlural())
            writeKeyword( stream, "msgstr", catalogEntries.at(counter).msgstr(), true, catalogEntries.at(counter).prependEmptyForMsgstr() );
        else
        {
            kDebug() << "Saving gettext plural form";
            //TODO check len of the actual stringlist??
            const int forms = catalog->numberOfPluralForms();
            for ( int i = 0; i < forms; ++i )
            {
                QString keyword = "msgstr[" % QString::number( i ) % ']';
                writeKeyword( stream, keyword, catalogEntries.at(counter).msgstr(i), true, catalogEntries.at(counter).prependEmptyForMsgstr() );
            }
        }
    }

#if 0
//legacy
    if ( _saveSettings.saveObsolete )
#endif
    {
        QList<QString>::const_iterator oit;
        const QStringList& _obsolete=catalog->m_catalogExtraData;
        oit=_obsolete.constBegin();
        if (oit!=_obsolete.constEnd())
        {
            stream << "\n" << (*oit);
            while((++oit)!=_obsolete.constEnd())
                stream << "\n\n" << (*oit);
        }
    }

    int i=m_trailingNewLines+1;
    while (--i>=0)
        stream << '\n';

    return OK;
}

void GettextExportPlugin::writeComment( QTextStream& stream, const QString& comment ) const
{
    if( !comment.isEmpty() )
    {
        // We must check that each comment line really starts with a #, to avoid syntax errors
        int pos = 0;
        for(;;)
        {
            const int newpos = comment.indexOf( '\n', pos, Qt::CaseInsensitive );
            if ( newpos == pos )
            {
                ++pos;
                stream << '\n';
                continue;
            }
            const QString& span ((newpos==-1 ) ? comment.mid(pos) : comment.mid(pos, newpos-pos) );

            const int len = span.length();
            QString spaces; // Stored leading spaces
            for ( int i = 0 ; i < len ; ++i )
            {
                const QChar& ch = span[ i ];
                if ( ch == '#' )
                {
                    stream << spaces << span.mid( i );
                    break;
                }
                else if ( ch == ' ' || ch == '\t' )
                {
                    // We have a leading white space character, so store it temporary
                    spaces += ch;
                }
                else
                {
                    // Not leading white space and not a # character. so consider that the # character was missing at first position.
                    stream << "# " << spaces << span.mid( i );
                    break;
                }
            }
            stream << '\n';

            if ( newpos == -1 )
                break;
            else
                pos = newpos + 1;
        }
    }
}

void GettextExportPlugin::writeKeyword( QTextStream& stream, const QString& keyword, QString text, bool containsHtml, bool startedWithEmptyLine ) const
{
    if ( text.isEmpty() )
    {
        // Whatever the wrapping mode, an empty line is an empty line
        stream << keyword << " \"\"\n";
        return;
    }

    //TODO remove this for KDE 4.4
    //NOTE not?
    int pos=0;
    while ((pos=text.indexOf("\\\"",pos))!=-1)
    {
        if (pos==0 || text.at(pos-1)!='\\')
            text.replace(pos,2,'"');
        else
            pos++;
    }
    text.replace('"',"\\\"");
#if 0
    if ( m_wrapWidth == -1 )
    {
        // Traditional KBabel wrapping
        QStringList list = text.split( '\n', QString::SkipEmptyParts );

        if ( text.startsWith( '\n' ) )
            list.prepend( QString() );

        if(list.isEmpty())
            list.append( QString() );

        if( list.count() > 1 )
            list.prepend( QString() );

        stream << keyword << ' ';

        QStringList::const_iterator it;
        for( it = list.constBegin(); it != list.constEnd(); ++it )
            stream << '\"' << (*it) << "\"\n";
        return;
    }
#endif

    if ( m_wrapWidth == 0 ) // Unknown special wrapping, so assume "no wrap" instead
    {
        // No wrapping (like Gettext's --no.wrap or -w0 )
        // we need to remove the \n characters, as they are extra characters
        QString realText( text );
        realText.remove( '\n' );
        stream << keyword << " \"" << realText << "\"\n";
        return;
    }
    else if ( m_wrapWidth < 0 )
    {
        // No change in wrapping
        QStringList list = text.split( '\n');
        if (list.count()>1 || startedWithEmptyLine /* || keyword.length()+3+text.length()>=80*/)
            list.prepend(QString());

        stream << keyword << " ";
        QStringList::const_iterator it;
        for( it = list.constBegin(); it != list.constEnd(); ++it )
            stream << "\"" << (*it) << "\"\n";

        return;
    }

    // lazy wrapping
    QStringList list = text.split( '\n', QString::SkipEmptyParts );

    if ( text.startsWith( '\n' ) )
        list.prepend( QString() );

    if(list.isEmpty())
        list.append( QString() );

    static QRegExp breakStopReForHtml("[ >.%]", Qt::CaseSensitive, QRegExp::Wildcard);
    QRegExp breakStopRe=containsHtml?breakStopReForHtml:QRegExp("[ .%]", Qt::CaseSensitive, QRegExp::Wildcard);

    int max=m_wrapWidth-2;
    bool prependedEmptyLine=false;
    QStringList::iterator itm;
    for( itm = list.begin(); itm != list.end(); ++itm )
    {
        if (list.count()==1 && keyword.length()+1+itm->length()>=max)
        {
            prependedEmptyLine=true;
            itm=list.insert(itm,QString());
        }

        if (itm->length()>max)
        {
            int pos = itm->lastIndexOf(breakStopRe,max-1);
            if (pos>0)
            {
                int pos2 = itm->indexOf('<',pos);
                if (pos2>0&&pos2<max-1)
                    pos=itm->indexOf('<',pos);
                ++pos;
            }
            else
                pos=max;
            //itm=list.insert(itm,itm->left(pos));
            QString t=*itm;
            itm=list.insert(itm,t);
            itm++;
            if (itm != list.end())
            {
                (*itm)=itm->remove(0,pos);
                itm--;
                if (itm != list.end())
                    itm->truncate(pos);
            }
        }
    }

    if( !prependedEmptyLine && list.count() > 1 )
        list.prepend( QString() );

    stream << keyword << " ";

    QStringList::const_iterator it;
    for( it = list.constBegin(); it != list.constEnd(); ++it )
        stream << "\"" << (*it) << "\"\n";
}
コード例 #8
0
void
ExportGroupTemplateDialog::onOkClicked()
{
    QString dirPath = _imp->fileEdit->text();

    if ( !dirPath.isEmpty() && ( dirPath[dirPath.size() - 1] == QLatin1Char('/') ) ) {
        dirPath.remove(dirPath.size() - 1, 1);
    }
    QDir d(dirPath);

    if ( !d.exists() ) {
        Dialogs::errorDialog( tr("Error").toStdString(), tr("You must specify a directory to save the script").toStdString() );

        return;
    }
    QString pluginLabel = _imp->labelEdit->text();
    if ( pluginLabel.isEmpty() ) {
        Dialogs::errorDialog( tr("Error").toStdString(), tr("You must specify a label to name the script").toStdString() );

        return;
    } else {
        pluginLabel = QString::fromUtf8( NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly( pluginLabel.toStdString() ).c_str() );
    }

    QString pluginID = _imp->idEdit->text();
    if ( pluginID.isEmpty() ) {
        Dialogs::errorDialog( tr("Error").toStdString(), tr("You must specify a unique ID to identify the script").toStdString() );

        return;
    }

    QString iconPath = _imp->iconPath->text();
    QString grouping = _imp->groupingEdit->text();
    QString description = _imp->descriptionEdit->getText();
    QString filePath = d.absolutePath() + QLatin1Char('/') + pluginLabel + QString::fromUtf8(".py");
    QStringList filters;
    filters.push_back( QString( pluginLabel + QString::fromUtf8(".py") ) );
    if ( !d.entryList(filters, QDir::Files | QDir::NoDotAndDotDot).isEmpty() ) {
        StandardButtonEnum rep = Dialogs::questionDialog(tr("Existing plug-in").toStdString(),
                                                         tr("A group plug-in with the same name already exists "
                                                            "would you like to "
                                                            "override it?").toStdString(), false);
        if  (rep == eStandardButtonNo) {
            return;
        }
    }

    bool foundInPath = false;
    QStringList groupSearchPath = appPTR->getAllNonOFXPluginsPaths();
    for (QStringList::iterator it = groupSearchPath.begin(); it != groupSearchPath.end(); ++it) {
        if ( !it->isEmpty() && ( it->at(it->size() - 1) == QLatin1Char('/') ) ) {
            it->remove(it->size() - 1, 1);
        }
        if (*it == dirPath) {
            foundInPath = true;
        }
    }

    if (!foundInPath) {
        QString message = dirPath + tr(" does not exist in the group plug-in search path, would you like to add it?");
        StandardButtonEnum rep = Dialogs::questionDialog(tr("Plug-in path").toStdString(),
                                                         message.toStdString(), false);

        if  (rep == eStandardButtonYes) {
            appPTR->getCurrentSettings()->appendPythonGroupsPath( dirPath.toStdString() );
        }
    }

    QFile file(filePath);
    if ( !file.open(QIODevice::ReadWrite | QIODevice::Truncate) ) {
        Dialogs::errorDialog( tr("Error").toStdString(), QString(tr("Cannot open ") + filePath).toStdString() );

        return;
    }

    QTextStream ts(&file);
    QString content;
    _imp->group->exportGroupToPython(pluginID, pluginLabel, description, iconPath, grouping, content);
    ts << content;

    accept();
} // ExportGroupTemplateDialog::onOkClicked