QList<FakeJobResponse::Token> FakeJobResponse::tokenize(const QString& treeString)
{
  QStringList parts = treeString.split('-');

  QList<Token> tokens;
  const QStringList::const_iterator begin = parts.constBegin();
  const QStringList::const_iterator end = parts.constEnd();

  QStringList::const_iterator it = begin;
  ++it;
  for (; it != end; ++it)
  {
    Token token;
    if (it->trimmed().isEmpty())
    {
      token.type = Token::Branch;
    } else {
      token.type = Token::Leaf;
      token.content = it->trimmed();
    }
    tokens.append(token);
  }
  return tokens;
}
void RezkonvImporter::loadReferences( QStringList::const_iterator &text_it, Recipe &recipe )
{
    kDebug() << "Found source header" ;

    text_it++;
    while ( text_it != m_end_it && !text_it->trimmed().isEmpty() ) {
        QRegExp rx_line_begin( "^\\s*-{0,2}\\s*" );

        QRegExp rx_creation_date = QRegExp( "^\\s*-{0,2}\\s*Erfasst \\*RK\\*", Qt::CaseInsensitive );
        if ( ( *text_it ).contains( rx_creation_date ) )  // date followed by typist
        {
            QString date = *text_it;
            date.remove( rx_creation_date ).remove( QRegExp( " von\\s*$" ) );

            // Date is given as DD.MM.YY
            QString s = date.section( '.', 0, 0 );
            int day = s.toInt();

            s = date.section( '.', 1, 1 );
            int month = s.toInt();

            s = date.section( '.', 2, 2 );
            int year = s.toInt();
            year += 1900;
            if ( year < 1970 )
                year += 100; //we'll assume nothing has been created before 1970 (y2k issues :p)

            recipe.ctime = QDateTime(QDate(year,month,day));

#if 0
            //typist
            text_it++;
            QString typist = = *text_it;
            typist.remove( rx_line_begin );
#endif

        }
        else //everything else is an author
        {
            if ( ( *text_it ).contains( rx_line_begin ) ) {
示例#3
0
void ContactRegistry::fromFile(QString const& filename, bool dryRun) {
	if (!QFile::exists(filename)) {
		throw IllegalArgumentException() << QString("Could not open the specified contacts file as it does not exist: %1").arg(filename).toStdString();
	}
	QFile inputFile(filename);
	if (!inputFile.open(QFile::ReadOnly | QFile::Text)) {
		throw IllegalArgumentException() << QString("Could not open the specified contacts file for reading: %1").arg(filename).toStdString();
	}

	QRegExp commentRegExp("^\\s*#.*$", Qt::CaseInsensitive, QRegExp::RegExp2);
	QRegExp identityRegExp("^\\s*([A-Z0-9]{8})\\s*:\\s*([a-fA-F0-9]{64})\\s*(?::\\s*(.*)\\s*)?$", Qt::CaseInsensitive, QRegExp::RegExp2);
	QRegExp groupRegExp("^\\s*([a-fA-F0-9]{16})\\s*:\\s*([A-Z0-9]{8})\\s*:\\s*([A-Z0-9]{8}(?:\\s*,\\s*[A-Z0-9]{8})*)\\s*:\\s*(.*)\\s*$", Qt::CaseInsensitive, QRegExp::RegExp2);

	QTextStream in(&inputFile);
	in.setCodec("UTF-8"); // change the file codec to UTF-8.
	while (!in.atEnd()) {
		QString line = in.readLine().trimmed();
		if (line.isEmpty() || commentRegExp.exactMatch(line)) {
			continue;
		} else if (identityRegExp.exactMatch(line)) {
			if (!dryRun) {
				accessMutex.lock();

				ContactId const contactId(identityRegExp.cap(1));
				IdentityContact* iContact = new IdentityContact(contactId, PublicKey::fromHexString(identityRegExp.cap(2)));
				if (!identityRegExp.cap(3).trimmed().isEmpty()) {
					// Nickname given.
					iContact->setNickname(identityRegExp.cap(3).trimmed());
				}
				connectContact(iContact);
				identityToIdentityContactHashMap.insert(contactId, iContact);

				accessMutex.unlock();
			}
		} else if (groupRegExp.exactMatch(line)) {
			if (!dryRun) {
				accessMutex.lock();

				quint64 groupIdentity = IdentityHelper::groupIdByteArrayToUint64(QByteArray::fromHex(groupRegExp.cap(1).toLatin1()));
				quint64 groupOwner = IdentityHelper::identityStringToUint64(groupRegExp.cap(2));
				GroupContact* gContact = new GroupContact(GroupId(groupOwner, groupIdentity));
				if (!groupRegExp.cap(4).trimmed().isEmpty()) {
					gContact->setGroupName(groupRegExp.cap(4).trimmed());
				}

				QStringList ids = groupRegExp.cap(3).split(',', QString::SkipEmptyParts);
				if (ids.size() == 0) {
					throw IllegalArgumentException() << QString("Invalid or ill-formated line in contacts file \"%1\".\nProblematic line: %2").arg(filename).arg(line).toStdString();
				}

				QStringList::const_iterator it = ids.constBegin();
				QStringList::const_iterator end = ids.constEnd();
				for (; it != end; ++it) {
					QString trimmedId(it->trimmed());
					ContactId const memberId(trimmedId);
					gContact->addMember(memberId);
				}

				connectContact(gContact);
				identityToGroupContactHashMap.insert(GroupId(groupOwner, groupIdentity), gContact);

				accessMutex.unlock();
			}
		} else {
			throw IllegalArgumentException() << QString("Invalid or ill-formated line in contacts file \"%1\".\nProblematic line: %2").arg(filename).arg(line).toStdString();
		}
	}

	inputFile.close();
	if (!dryRun) {
		emit identitiesChanged();
	}
}
General_Menu::General_Menu(QWidget *parent):QDialog(parent)
{
	ui.setupUi(this);
	
	//Editor
	ui.use_external_editor->setCheckState(CHECK_FROM_STRING(get_config("external_editor")));
	ui.editor_lineEdit->setText(get_config("editor"));
	if(get_config("autoindent_statements")=="true")
	{
		ui.no_autoindent_radioButton->setChecked(false);
		ui.autoindent_radioButton->setChecked(false);
		ui.autoindent_statements_radioButton->setChecked(true);
	}
	else if(get_config("autoindent")!="false")
	{
		ui.no_autoindent_radioButton->setChecked(false);
		ui.autoindent_radioButton->setChecked(true);
		ui.autoindent_statements_radioButton->setChecked(false);
	}
	else
	{
		ui.no_autoindent_radioButton->setChecked(true);
		ui.autoindent_radioButton->setChecked(false);
		ui.autoindent_statements_radioButton->setChecked(false);
	}
	
	ui.syntaxHighlighting_checkBox->setCheckState(CHECK_FROM_STRING(get_config("syntaxHighlighting")));
	ui.bracketsMatch_checkBox->setCheckState(CHECK_FROM_STRING(get_config("bracketsMatch")));
	ui.autoCompletion_checkBox->setCheckState(CHECK_FROM_STRING(get_config("autoCompletion")));
	ui.simple_rcs_checkBox->setCheckState(CHECK_FROM_STRING(get_config("simple_rcs")));
	
	QString font_name=get_config("textEditFont");
	QString font_size=get_config("textEditFontSize");
	if(font_name.isEmpty())
	{
		font_name=text_edit_font.family();
	}
	if(font_size.isEmpty())
	{
		font_size=QString::number(text_edit_font.pointSize());
	}
	text_edit_font.setFamily(font_name);
	text_edit_font.setPointSize(font_size.toInt());
	ui.textEditFont_label->setText("Font: "+font_name+", "+font_size);
	connect(ui.textEditFont_pushButton,SIGNAL(clicked()),this,SLOT(textEditFont_pushButton_callback()));
	
	//Help path
	ui.help_path_lineEdit->setText(get_config("help_path"));
	ui.qtinfo_ok_checkBox->setCheckState(CHECK_FROM_STRING(get_config("qtinfo_ok")));
	
	//Terminal
	
	//Max. number of items in command line
	ui.lines_in_history_lineEdit->setText(get_config("lines_in_history"));
	
	if(!get_config("terminal_font").isEmpty()) config_font.fromString(get_config("terminal_font"));
	
	set_font_label();
	
	foreground_color.setNamedColor(get_config("terminal_foreground_color"));
	background_color.setNamedColor(get_config("terminal_background_color"));
	error_color.setNamedColor(get_config("terminal_error_color"));
	
	set_color_label();
	
	ui.max_line_num_lineEdit->setText(get_config("lines_in_terminal"));
	ui.max_col_in_terminal_lineEdit->setText(get_config("cols_in_terminal"));

	ui.show_ide_commands_checkBox->setCheckState(CHECK_FROM_STRING(get_config("show_ide_commands")));

	// Octave
	ui.octave_path_lineEdit->setText(get_config("octave_path"));
	ui.octaveArgs_lineEdit->setText(get_config("octave_arguments"));
	QStringList dirList = get_config("octave_folders").split(",", QString::SkipEmptyParts);
	QString aux;

	for(QStringList::const_iterator i = dirList.begin(); 
	    i != dirList.end(); i++)
	{
	  aux = i->trimmed();
	  if(aux.startsWith('"'))
	    aux = aux.mid(1, aux.length() - 2);
	  ui.octaveDir_list->addItem(aux);
	}
	
	ui.easy_plot_checkBox->setCheckState(CHECK_FROM_STRING(get_config("easy_plot_active")));
	ui.easy_plot_path_lineEdit->setText(get_config("easy_plot_path"));

	// Connect
	connect(ui.editor_select_button,SIGNAL(clicked()),this,SLOT(editor_select_button_callback()));
	connect(ui.help_path_select_pushButton,SIGNAL(clicked()),this,SLOT(help_path_select_pushButton_callback()));
	connect(ui.font_button,SIGNAL(clicked()),this,SLOT(font_button_callback()));
	connect(ui.foreground_button,SIGNAL(clicked()),this,SLOT(foreground_button_callback()));
	connect(ui.background_button,SIGNAL(clicked()),this,SLOT(background_button_callback()));
	connect(ui.error_button,SIGNAL(clicked()),this,SLOT(error_button_callback()));
	connect(ui.octaveDirRem_button, SIGNAL(clicked()),
		this, SLOT(octaveDirRem_button_callback()));
	connect(ui.octaveDirAdd_button, SIGNAL(clicked()),
		this, SLOT(octaveDirAdd_button_callback()));
	connect(ui.octave_path_pushButton,SIGNAL(clicked()),this,SLOT(octave_path_button_callback()));
	connect(ui.easy_plot_path_pushButton,SIGNAL(clicked()),this,SLOT(easy_plot_path_button_callback()));
}