Ejemplo n.º 1
0
void KviWindow::preprocessMessage(QString & szMessage)
{
    // FIXME: slow

    if(!m_pConsole)
        return;
    if(!m_pConsole->connection())
        return;

    static QString szNonStandardLinkPrefix = QString::fromAscii("\r![");

    if(szMessage.contains(szNonStandardLinkPrefix))
        return; // contains a non standard link that may contain spaces, do not break it.

    // FIXME: This STILL breaks $fmtlink() in certain configurations

    QStringList strings = szMessage.split(" ");
    for(QStringList::Iterator it = strings.begin(); it != strings.end(); ++it )
    {
        if(it->contains('\r'))
            continue;
        QString szTmp(*it);
        szTmp = KviControlCodes::stripControlBytes(szTmp).trimmed();
        if(szTmp.length() < 1)
            continue;
        if(m_pConsole->connection()->serverInfo()->supportedChannelTypes().contains(szTmp[0]))
        {
            if((*it) == szTmp)
                *it = QString("\r!c\r%1\r").arg(*it);
            else
                *it = QString("\r!c%1\r%2\r").arg(szTmp,*it);
        }
    }
    szMessage = strings.join(" ");
}
Ejemplo n.º 2
0
void QIMPenInput::loadProfiles()
{
    profileList.clear();
    profile = 0;
    delete shortcutCharSet;
    shortcutCharSet = new QIMPenCharSet();
    shortcutCharSet->setTitle( tr("Shortcut") );
    QString path = QPEApplication::qpeDir() + "etc/qimpen";
    QDir dir( path, "*.conf" );
    QStringList list = dir.entryList();
    QStringList::Iterator it;
    for ( it = list.begin(); it != list.end(); ++it ) {
	QIMPenProfile *p = new QIMPenProfile( path + "/" + *it );
	profileList.append( p );
	if ( p->shortcut() ) {
	    QIMPenCharIterator it( p->shortcut()->characters() );
	    for ( ; it.current(); ++it ) {
		shortcutCharSet->addChar( new QIMPenChar(*it.current()) );
	    }
	}
    }

    Config config( "handwriting" );
    config.setGroup( "Settings" );
    QString prof = config.readEntry( "Profile", "Default" );
    selectProfile( prof );
}
Ejemplo n.º 3
0
void Process::restart()
{
    bool changed = false;
    if (mPath.compare(getTaskDefinition().getFirst()) != 0)
        changed = true;

    if (getTaskDefinition().getSecondList().size() != mArguments.size())
        changed = true;

    if (!changed)
    {
        int index = 0;
        for (QStringList::Iterator it = mArguments.begin(); it != mArguments.end(); it++)
        {
            if (it->compare(getTaskDefinition().getSecondList().at(index)) != 0)
            {
                changed = true;
                break;
            }
            index++;
        }
    }

    if (changed)
    {
        LOG_WARNING() << "Task definition for the process " << getTaskDefinition().getName() << " changed since the last execution. Restarting with the previous "
                      << "path and arguments. To use the new Values, stop and run the Simulation.";
    }

    restartProcess();
}
Ejemplo n.º 4
0
SvgStyles SvgStyleParser::collectStyles(const KoXmlElement &e)
{
    SvgStyles styleMap;

    // collect individual presentation style attributes which have the priority 0
    foreach(const QString &command, d->styleAttributes) {
        const QString attribute = e.attribute(command);
        if (!attribute.isEmpty())
            styleMap[command] = attribute;
    }
    foreach(const QString & command, d->fontAttributes) {
        const QString attribute = e.attribute(command);
        if (!attribute.isEmpty())
            styleMap[command] = attribute;
    }

    // match css style rules to element
    QStringList cssStyles = d->context.matchingStyles(e);

    // collect all css style attributes
    foreach(const QString &style, cssStyles) {
        QStringList substyles = style.split(';', QString::SkipEmptyParts);
        if (!substyles.count())
            continue;
        for (QStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) {
            QStringList substyle = it->split(':');
            if (substyle.count() != 2)
                continue;
            QString command = substyle[0].trimmed();
            QString params  = substyle[1].trimmed();
            // only use style and font attributes
            if (d->styleAttributes.contains(command) || d->fontAttributes.contains(command))
                styleMap[command] = params;
        }
    }
Ejemplo n.º 5
0
void Qt5Files::buttonClicked() {
	QString filter;
	if (!m_extensions.size()) {
		filter = tr("All Files (*.*)");
	} else {
		filter = tr("Valid Files (");
		for (unsigned int i=0; i<m_extensions.size(); ++i) {
			if (i) filter += " ";
			filter += "*."+QString::fromStdString(m_extensions[i]);
		}
		filter += tr(")");
	}
	QStringList files = QFileDialog::getOpenFileNames(nullptr, "Open Files...", filter, tr("All Files (*.*)"), nullptr, 0);
	QStringList::Iterator it = files.begin();
	m_value.clear();
	QString text;
	while (it != files.end()) {
		m_value.push_back(fs::path(it->toStdString()));
		if (it != files.begin()) text += ", ";
		text += *it;
		++it;
	}
	m_lineEdit->setText(text);
	notify(m_value);
}
Ejemplo n.º 6
0
void CPU::parse(QByteArray input)
{
    qDebug() << "opCodes:" << opCodes;
    QString in = input;
    QStringList string;
    if(input.isEmpty()) return;
        //throw Exception("Файл пуст!");
    string = in.split('\n'); // делим построчно файл
    for(QStringList::Iterator i = string.begin(); i < string.end(); i++)
        this->parseCommand(i->split(" ", QString::SkipEmptyParts)); // парсим каждую строку поотдельности
    qDebug() << data;
}
Ejemplo n.º 7
0
void SvgStyleParser::parseColorStops(QGradient *gradient, const KoXmlElement &e)
{
    QGradientStops stops;
    QColor c;

    for (KoXmlNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) {
        KoXmlElement stop = n.toElement();
        if (stop.tagName() == "stop") {
            float offset;
            QString temp = stop.attribute("offset");
            if (temp.contains('%')) {
                temp = temp.left(temp.length() - 1);
                offset = temp.toFloat() / 100.0;
            } else
                offset = temp.toFloat();

            QString stopColorStr = stop.attribute("stop-color");
            if (!stopColorStr.isEmpty()) {
                if (stopColorStr == "inherit") {
                    stopColorStr = inheritedAttribute("stop-color", stop);
                }
                parseColor(c, stopColorStr);
            }
            else {
                // try style attr
                QString style = stop.attribute("style").simplified();
                QStringList substyles = style.split(';', QString::SkipEmptyParts);
                for (QStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) {
                    QStringList substyle = it->split(':');
                    QString command = substyle[0].trimmed();
                    QString params  = substyle[1].trimmed();
                    if (command == "stop-color")
                        parseColor(c, params);
                    if (command == "stop-opacity")
                        c.setAlphaF(params.toDouble());
                }

            }
            QString opacityStr = stop.attribute("stop-opacity");
            if (!opacityStr.isEmpty()) {
                if (opacityStr == "inherit") {
                    opacityStr = inheritedAttribute("stop-opacity", stop);
                }
                c.setAlphaF(opacityStr.toDouble());
            }
            stops.append(QPair<qreal, QColor>(offset, c));
        }
    }
    if (stops.count())
        gradient->setStops(stops);
}
Ejemplo n.º 8
0
void MainWindow::LoadImages() {
    images_.clear();

    QStringList files = QFileDialog::getOpenFileNames(
                            this, tr("Load Images"), "~/Pictures",
                            tr("Images (*.png, *.jpeg, *.jpg, *.tiff, *.bmp, *"));

    QStringList files_copy = files;
    for (QStringList::Iterator i = files_copy.begin(); i != files_copy.end(); ++i) {
        // Load files and add to ThumbnailView.
        QImage* img = new QImage(*i);
        std::cout << i->toStdString() << " " << img->width() << " " << img->height() << "\n";
        images_.push_back(shared_ptr<QImage>(img));
        thumb_->addImage(img, *i);
    }
}
Ejemplo n.º 9
0
void KFFWin_Flightplan::setCurrentList( QStringList & list )
{
	QTreeWidgetItem* item = 0;
	QStringList::Iterator it;
	int i = 0, j;

	ui_widget.treewidget_navaids->clear();

	for ( it = list.begin() ; it != list.end() ; ( it++, i++ ) )
	{
		item = new QTreeWidgetItem( ui_widget.treewidget_navaids );

		for ( j = 0 ; j < ui_widget.treewidget_navaids->columnCount() ; j++ )
		{
			item->setText( j, it->section( "|", j, j ) );
		}

		ui_widget.treewidget_navaids->insertTopLevelItem( i, item );
	}
}
Ejemplo n.º 10
0
// -----------------------------------------------------------------------
bool ParseMasks(const char *Masks_, QSet<QString> &Patterns_, TExcludePatterns &ExcludePatterns_)
{
QStringList MasksList = QString::fromLocal8Bit(Masks_).split(';', QString::SkipEmptyParts);
for(QStringList::Iterator it = MasksList.begin(); it != MasksList.end(); ++it) {
	*it = it->trimmed();
	if(it->isEmpty()) return false;
	}
//
for(QStringList::Iterator it = MasksList.begin(); it != MasksList.end(); ++it) {
	if(Patterns_.contains(*it)) continue;
	//
	ExcludePatterns_.push_back(QRegExp(*it, 
		#ifdef Q_OS_WIN
			Qt::CaseInsensitive, QRegExp::Wildcard));
		#else
			Qt::CaseSensitive, QRegExp::WildcardUnix));
		#endif
	Patterns_.insert(*it);
	}
return true;
}
Ejemplo n.º 11
0
/**
 * Funtion returns image pointer to Image located 
 * in cache folder where shoul be downloaded cover 
 * with name from parameter.
 * @param name
 * @return 
 */
QImage* CoverDownloader::getImage(QString name) {
    QDir d = QDir::current();

    std::cout << "Current dir cover.. " << d.absolutePath().toStdString() << std::endl;
    if (d.cd("cache")) {
        QImage * img = new QImage();
        QStringList filters;
        filters << name + ".*";
        QStringList files = d.entryList(filters, QDir::Readable | QDir::Files | QDir::NoSymLinks);
        for (QStringList::Iterator it = files.begin(); it != files.end(); ++it) {
            std::cout << it->toStdString() << std::endl;
            if (img->load("cache/" + *it)) {
                break;
            }
        }
        if (!img->isNull()) {
            return img;
        }
        SAFE_DELETE(img);
    }
    return NULL;
}
Ejemplo n.º 12
0
QVector< QVector<int> > NormFilterDialog::getMatrixFromLineEdit(QTextEdit *edit) const
{	// 文字列から行列を得る
	QVector< QVector<int> > result;
	QTextCursor cr = edit->textCursor();
	cr.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
	for (QTextBlock block = cr.block(); block.isValid(); block = block.next()) {	// 行の走査
		const QString line = block.text();
		const QRegExp regExpSpTab(tr("[ \\t]+"));
		QStringList tokens = line.split(regExpSpTab);	// スペースでトークン分割
		if (!tokens.isEmpty() && tokens.first().isEmpty()) { tokens.removeFirst(); }
		if (!tokens.isEmpty() && tokens.last().isEmpty()) { tokens.removeLast(); }
		if (tokens.isEmpty()) { continue; }

		const QRegExp regExpInt(tr("^-?\\d+$"));
		QVector<int> row;
		for (QStringList::Iterator it = tokens.begin(); it != tokens.end(); ++it) {
			if (!regExpInt.exactMatch(*it)) { result.clear(); return result; }
			row.append(it->toInt());
		}
		result.append(row);
	}
	return result;
}
Ejemplo n.º 13
0
void ReduxWidget::open() {

    QStringList files = QFileDialog::getOpenFileNames( this, tr( "Open File" ), "", tr( "Log Files (*_lg*)" ) );

    int sz = PATH_MAX + 1; // N.B. It is possible to construct a path longer than PATH_MAX on most systems,
    // so this is really not fool-proof...
    char* buf = new char[sz];

    QStringList::Iterator it = files.begin();
    while( it != files.end() ) {
        memset( buf, 0, sz * sizeof( char ) );
        if( ( ! it->isEmpty() ) && realpath( it->toStdString().c_str(), buf ) ) {
            dumpMsg( QString( "Opening LogFile : " ) + *it );
            /*LogFile* tmpLog = new LogFile ( buf );
            bool skip = false;
            for ( unsigned int i=0; i<myLogs.size(); ++i)
            if ( !(*(myLogs[i]) != *tmpLog) )
               skip = true;
             cout << *tmpLog << endl;
                 if ( ! skip ) myLogs.push_back( tmpLog );
                 else delete tmpLog;
                 //myLog.load();
                 */
        }
        ++it;
    }
    delete[] buf;

    //emit setsChanged();
    //logTree->reset();

    //emit jobsChanged();
    //jobTree->reset();
    //for (int i=0; i<myJobs.size(); ++i) cout << *myJobs[i];
    //cout << myNet;
    //cout << dumpXML(true) << endl;
}
Ejemplo n.º 14
0
bool QOptions::parse(int argc, const char *const*argv)
{
    if (mOptionGroupMap.isEmpty())
		return false;

    if (argc==1)
		return true;

	bool result = true;
    QStringList args;
    for (int i=1;i<argc;++i) {
        args.append(QString::fromLocal8Bit(argv[i]));
	}

	QStringList::Iterator it = args.begin();
    QList<QOption>::Iterator it_list;
    mOptions = mOptionGroupMap.keys();

    while (it != args.end()) {
        if (it->startsWith("--")) {
            int e = it->indexOf('=');
            for (it_list = mOptions.begin(); it_list != mOptions.end(); ++it_list) {
                if (it_list->longName() == it->mid(2,e-2)) {
                    if (it_list->type()==QOption::NoToken) {
                        it_list->setValue(true);
                        //qDebug("%d %s", __LINE__, qPrintable(it_list->value().toString()));
						it = args.erase(it);
						break;
					}
					if (e>0) { //
                        it_list->setValue(it->mid(e+1));
                        //qDebug("%d %s", __LINE__, qPrintable(it_list->value().toString()));
					} else {
						it = args.erase(it);
                        if (it == args.end())
                            break;
                        it_list->setValue(*it);
                        //qDebug("%d %s", __LINE__, qPrintable(it_list->value().toString()));
					}
					it = args.erase(it);
					break;
				}
			}
            if (it_list == mOptions.end()) {
                qWarning() << "unknow option: " << *it;
                result = false;
				++it;
            }
			//handle unknow option
        } else if (it->startsWith('-')) {
            for (it_list = mOptions.begin(); it_list != mOptions.end(); ++it_list) {
                QString sname = it_list->shortName();
				int sname_len = sname.length(); //usally is 1
                //TODO: startsWith(-height,-h) Not endsWith, -oabco
                if (it->midRef(1).compare(sname) == 0) {
                    if (it_list->type() == QOption::NoToken) {
                        it_list->setValue(true);
						it = args.erase(it);
						break;
					}
                    if (it->length() == sname_len+1) {//-o abco
						it = args.erase(it);
                        if (it == args.end())
                            break;
                        it_list->setValue(*it);
                        //qDebug("%d %s", __LINE__, qPrintable(it_list->value().toString()));
                    } else {
                        it_list->setValue(it->mid(sname_len+1));
                        //qDebug("%d %s", __LINE__, qPrintable(it_list->value().toString()));
                    }
					it = args.erase(it);
					break;
				}
			}
            if (it_list==mOptions.end()) {
                qWarning() << "unknow option: " << *it;
                result = false;
				++it;
            }
			//handle unknow option
        } else {
            qWarning() << "unknow option: " << *it;
            ++it;
        }
	}
    if (!result) {
        print();
    }
	return result;
}
Ejemplo n.º 15
0
void KFFOpt_scenery::searchData( QFile* file )
{
	QDomDocument doc;
	QDomElement root;
	QDomNode parent;
	QDomNode child;
	QDomElement e_parent;
	QDomElement e_child;
	KFFScenarioData scenario;
	QString name;
	QStringList list;
	QStringList::Iterator it;

	if ( doc.setContent( file ) )
	{
		root = doc.documentElement();
		parent = root.firstChild();
		e_parent = parent.toElement();
		if ( !e_parent.isNull() )
		{
			if ( e_parent.tagName() == "description" )
			{
				list = e_parent.text().split("\n");
				for (it = list.begin() ; it != list.end() ; it++ )
				{
					*it = it->simplified();
				}
				scenario.description = list.join("\n");
				parent = parent.nextSibling();
				
			}
		}
		
		parent = parent.firstChild();
		
		name = file->fileName().section( '/', -1, -1 ).remove( ".xml" );

		while ( !parent.isNull() )
		{
			e_parent = parent.toElement();

			if ( !e_parent.isNull() )
			{
				if ( e_parent.tagName() == "entry" )
				{
					child = parent.firstChild();

					while ( !child.isNull() )
					{
						e_child = child.toElement();

						if ( !e_child.isNull() )
						{
							if ( e_child.tagName() == "type" )
							{
								scenario.type = e_child.text();
							}
						}

						child = child.nextSibling();
					}
				}

				if ( e_parent.tagName() == "description" )
				{
					list = e_parent.text().split("\n");
					for (it = list.begin() ; it != list.end() ; it++ )
					{
						*it = it->simplified();
					}
					scenario.description = list.join("\n");
				}
			}

			parent = parent.nextSibling();

		}

		if ( !m_scenarii.contains( name ) )
		{
			m_scenarii[name] = scenario;
		}

	}
	else
	{
		qDebug() << file->fileName() << "is not a valide xml file" ;
	}
}
Ejemplo n.º 16
0
ConversionStatus GettextImportPlugin::readEntryRaw(QTextStream& stream)
{
   //kDebug() << " START";
   enum {Begin,Comment,Msgctxt,Msgid,Msgstr} part=Begin;

   _trailingNewLines=0;
   bool error=false;
   bool recoverableError=false;
   bool seenMsgctxt=false;
   _msgstr.clear();
   _msgstr.append(QString());
   _msgid.clear();
   _msgid.append(QString());
   _msgctxt.clear();
   _comment.clear();
   _gettextPluralForm=false;
   _obsolete=false;

   QStringList::Iterator msgstrIt=_msgstr.begin();
   QString line;

   while( !stream.atEnd() )
   {
       _errorLine++;
       //line=stream.readLine();
       if (!_bufferedLine.isEmpty())
       {
            line=_bufferedLine;
            _bufferedLine.clear();
       }
       else
           line=stream.readLine();

       kDebug() << "Parsing line: " << line;

       static const QString lesslessless="<<<<<<<";
       static const QString isisis="=======";
       static const QString moremoremore=">>>>>>>";
       if (KDE_ISUNLIKELY( line.startsWith( lesslessless ) || line.startsWith( isisis ) || line.startsWith( moremoremore ) ))
       {
          // We have found a CVS/SVN conflict marker. Abort.
          // (It cannot be any useful data of the PO file, as otherwise the line would start with at least a quote)
          kError() << "CVS/SVN conflict marker found! Aborting!" << endl << line << endl;
          return PARSE_ERROR;
       }

       // remove whitespaces from beginning and end of line
       line = line.trimmed();

       // remember wrapping state to save file nicely
       int len=line.length();
       if (len)
       {
          _trailingNewLines=0;
         if (_maxLineLength<len && line.at(0)!='#')
           _maxLineLength=len;
       }
       else
          ++_trailingNewLines;


       if(part==Begin)
       {
           // ignore trailing newlines
           if(!len)
              continue;

           if(line.startsWith(_obsoleteStart))
           {
               _obsolete=true;
               part=Comment;
               _comment=line;
           }
           else if(line.startsWith('#'))
           {
               part=Comment;
               _comment=line;
           }
           else if( line.startsWith(_msgctxtStart) && line.contains( _rxMsgCtxt ) )
           {
               part=Msgctxt;

               // remove quotes at beginning and the end of the lines
               line.remove(QRegExp("^msgctxt\\s*\""));
               line.remove(_rxMsgLineRemEndQuote);
               _msgctxt=line;
               seenMsgctxt=true;
           }
           else if( line.contains( _rxMsgId ) )
           {
               part=Msgid;

               // remove quotes at beginning and the end of the lines
               line.remove(_rxMsgIdRemQuotes);
               line.remove(_rxMsgLineRemEndQuote);

               (*(_msgid).begin())=line;

           }
           // one of the quotation marks is missing
           else if(KDE_ISUNLIKELY( /*_testBorked&&*/ line.contains( _rxMsgIdBorked ) ))
           {
               part=Msgid;

               // remove quotes at beginning and the end of the lines
               line.remove(QRegExp("^msgid\\s*\"?"));
               line.remove(_rxMsgLineRemEndQuote);

               (*(_msgid).begin())=line;

               if(!line.isEmpty())
                  recoverableError=true;
           }
           else
           {
               kDebug() << "no comment, msgctxt or msgid found after a comment: " << line;
               error=true;
               break;
           }
       }
       else if(part==Comment)
       {
            if(!len && _obsolete ) return OK;
            if(!len) continue;
            else if(line.startsWith(_obsoleteStart))
            {
               _comment+=('\n'+line);
               _obsolete=true;
            }
            else if(line.startsWith('#'))
            {
               _comment+=('\n'+line);
            }
            else if( line.startsWith(_msgctxtStart) &&line.contains( _rxMsgCtxt ) )
            {
               part=Msgctxt;

               // remove quotes at beginning and the end of the lines
               line.remove(QRegExp("^msgctxt\\s*\""));
               line.remove(_rxMsgLineRemEndQuote);
               _msgctxt=line;
               seenMsgctxt=true;
            }
            else if( line.contains( _rxMsgId ) )
            {
               part=Msgid;

               // remove quotes at beginning and the end of the lines
               line.remove(_rxMsgIdRemQuotes);
               line.remove(_rxMsgLineRemEndQuote);

               (*(_msgid).begin())=line;
            }
            // one of the quotation marks is missing
            else if(KDE_ISUNLIKELY( /*_testBorked&&*/line.contains( _rxMsgIdBorked ) ))
            {
               part=Msgid;

               // remove quotes at beginning and the end of the lines
               line.remove(QRegExp("^msgid\\s*\"?"));
               line.remove(_rxMsgLineRemEndQuote);

               (*(_msgid).begin())=line;

               if(!line.isEmpty())
                     recoverableError=true;
            }
            else
            {
               kDebug() << "no comment or msgid found after a comment while parsing: " << _comment;
               error=true;
               break;
            }
        }
        else if(part==Msgctxt)
        {
            if(!len)
               continue;
            else if( line.contains( _rxMsgLine ) )
            {
               // remove quotes at beginning and the end of the lines
               line.remove(_rxMsgLineRemStartQuote);
               line.remove(_rxMsgLineRemEndQuote);

               // add Msgctxt line to item
               if(_msgctxt.isEmpty())
                  _msgctxt=line;
               else
                  _msgctxt+=('\n'+line);
            }
            else if( line.contains( _rxMsgId ) )
            {
               part=Msgid;

               // remove quotes at beginning and the end of the lines
               line.remove(_rxMsgIdRemQuotes);
               line.remove(_rxMsgLineRemEndQuote);

               _msgidMultiline=line.isEmpty();
               (*(_msgid).begin())=line;
            }
            // one of the quotation marks is missing
            else if(KDE_ISUNLIKELY(/*_testBorked&&*/ line.contains ( _rxMsgIdBorked ) ))
            {
               part=Msgid;

               // remove quotes at beginning and the end of the lines
               line.remove(QRegExp("^msgid\\s*\"?"));
               line.remove(_rxMsgLineRemEndQuote);

               (*(_msgid).begin())=line;

               if(!line.isEmpty())
                     recoverableError=true;
            }
            else
            {
               kDebug() << "no msgid found after a msgctxt while parsing: " << _msgctxt;
               error=true;
               break;
            }
        }
        else if(part==Msgid)
        {
            if(!len)
               continue;
            else if( line.contains( _rxMsgLine ) )
            {
               // remove quotes at beginning and the end of the lines
               line.remove(_rxMsgLineRemStartQuote);
               line.remove(_rxMsgLineRemEndQuote);

               QStringList::Iterator it;
               if(_gettextPluralForm)
               {
                   it=_msgid.end();
                   --it;
               }
               else
                   it = _msgid.begin();

               // add Msgid line to item
               if(it->isEmpty())
                  (*it)=line;
               else
                  (*it)+=('\n'+line);
            }
            else if( line.contains( _rxMsgIdPlural) )
            {
               part=Msgid;
               _gettextPluralForm = true;

               // remove quotes at beginning and the end of the lines
               line.remove(QRegExp("^msgid_plural\\s*\""));
               line.remove(_rxMsgLineRemEndQuote);

               _msgid.append(line);
            }
            // one of the quotation marks is missing
            else if(KDE_ISUNLIKELY(/*_testBorked&&*/ line.contains( _rxMsgIdPluralBorked ) ))
            {
               part=Msgid;
               _gettextPluralForm = true;

               // remove quotes at beginning and the end of the lines
               line.remove(QRegExp("^msgid_plural\\s*\"?"));
               line.remove(_rxMsgLineRemEndQuote);

               _msgid.append(line);

               if(!line.isEmpty())
                  recoverableError=true;
            }
            else if( !_gettextPluralForm && ( line.contains( _rxMsgStr ) ) )
            {
               part=Msgstr;

               // remove quotes at beginning and the end of the lines
               line.remove(_rxMsgStrRemQuotes);
               line.remove(_rxMsgLineRemEndQuote);

               _msgstrMultiline=line.isEmpty();
               (*msgstrIt)=line;
            }
            else if( !_gettextPluralForm && ( line.contains( _rxMsgStrOther )) )
            {
               part=Msgstr;

               // remove quotes at beginning and the end of the lines
               line.remove(_rxMsgStrRemQuotes);
               line.remove(_rxMsgLineRemEndQuote);

               (*msgstrIt)=line;

               if(!line.isEmpty())
                  recoverableError=true;
            }
            else if( _gettextPluralForm && ( line.contains( _rxMsgStrPluralStart ) ) )
            {
               part=Msgstr;

               // remove quotes at beginning and the end of the lines
               line.remove(QRegExp("^msgstr\\[0\\]\\s*\"?"));
               line.remove(_rxMsgLineRemEndQuote);

               (*msgstrIt)=line;
            }
            else if(KDE_ISUNLIKELY( /*_testBorked&&*/ _gettextPluralForm &&  line.contains( _rxMsgStrPluralStartBorked ) ))
            {
               part=Msgstr;

               // remove quotes at beginning and the end of the lines
               line.remove(QRegExp("^msgstr\\[0\\]\\s*\"?"));
               line.remove(_rxMsgLineRemEndQuote);

               (*msgstrIt)=line;

               if(!line.isEmpty())
                  recoverableError=true;
            }
            else if ( line.startsWith( '#' ) )
            {
               // ### TODO: could this be considered recoverable?
               kDebug() << "comment found after a msgid while parsing: " << _msgid.first();
               error=true;
               break;
            }
            else if ( line.startsWith( "msgid" ) )
            {
               kDebug() << "Another msgid found after a msgid while parsing: " << _msgid.first();
               error=true;
               break;
            }
            // a line of the msgid with a missing quotation mark
            else if(KDE_ISUNLIKELY( /*_testBorked&&*/line.contains( _rxMsgLineBorked ) ))
            {
               recoverableError=true;

               // remove quotes at beginning and the end of the lines
               line.remove(_rxMsgLineRemStartQuote);
               line.remove(_rxMsgLineRemEndQuote);

               QStringList::Iterator it;
               if( _gettextPluralForm )
               {
                   it=_msgid.end();
                   --it;
               }
               else
                   it = _msgid.begin();

               // add Msgid line to item
               if(it->isEmpty())
                  (*it)=line;
               else
                  (*it)+=('\n'+line);
            }
            else
            {
               kDebug() << "no msgstr found after a msgid while parsing: " << _msgid.first();
               error=true;
               break;
            }
        }
        else if(part==Msgstr)
        {
            if(!len)
               break;
            // another line of the msgstr
            else if( line.contains( _rxMsgLine ) )
            {
               // remove quotes at beginning and the end of the lines
               line.remove(_rxMsgLineRemStartQuote);
               line.remove(_rxMsgLineRemEndQuote);

               if(!(*msgstrIt).isEmpty())
                  (*msgstrIt)+='\n';
               (*msgstrIt)+=line;
            }
            else if( _gettextPluralForm && ( line.contains( _rxMsgStrPlural ) ) )
            {
               // remove quotes at beginning and the end of the lines
               line.remove(QRegExp("^msgstr\\[[0-9]+\\]\\s*\"?"));
               line.remove(_rxMsgLineRemEndQuote);

               _msgstr.append(line);
               msgstrIt=_msgstr.end();
               --msgstrIt;
            }
            else if ( line.startsWith( '#' ) || line.startsWith( "msgid" ) )
            {
               _errorLine--;
               _bufferedLine=line;
               break;
            }
            else if(KDE_ISUNLIKELY(/*_testBorked&&*/ _gettextPluralForm && ( line.contains( _rxMsgStrPluralBorked ) ) ))
            {
               // remove quotes at beginning and the end of the lines
               line.remove(QRegExp("^msgstr\\[[0-9]\\]\\s*\"?"));
               line.remove(_rxMsgLineRemEndQuote);

               _msgstr.append(line);
               msgstrIt=_msgstr.end();
               --msgstrIt;

               if(!line.isEmpty())
                  recoverableError=true;
            }
            else if(line.startsWith("msgstr"))
            {
               kDebug() << "Another msgstr found after a msgstr while parsing: " << line << _msgstr.last();
               error=true;
               break;
            }
            // another line of the msgstr with a missing quotation mark
            else if(KDE_ISUNLIKELY( /*_testBorked&&*/line.contains( _rxMsgLineBorked ) ))
            {
               recoverableError=true;

               // remove quotes at beginning and the end of the lines
               line.remove(_rxMsgLineRemStartQuote);
               line.remove(_rxMsgLineRemEndQuote);

               if(!(*msgstrIt).isEmpty())
                  (*msgstrIt)+='\n';
               (*msgstrIt)+=line;
            }
            else
            {
               kDebug() << "no msgid or comment found after a msgstr while parsing: " << _msgstr.last();
               error=true;
               break;
            }
        }
    }

/*
   if(_gettextPluralForm)
   {
       kDebug() << "gettext plural form:\n"
                 << "msgid:\n" << _msgid.first() << "\n"
                 << "msgid_plural:\n" << _msgid.last() << "\n" << endl;
       int counter=0;
       for(QStringList::Iterator it = _msgstr.begin(); it != _msgstr.end(); ++it)
       {
           kDebug() << "msgstr[" << counter << "]:\n" 
                     << (*it) << endl;
           counter++;
       }
   }
  */

    //kDebug() << " NEAR RETURN";
    if(KDE_ISUNLIKELY(error))
        return PARSE_ERROR;
    else if(KDE_ISUNLIKELY(recoverableError))
        return RECOVERED_PARSE_ERROR;
    else
        return OK;
}
Ejemplo n.º 17
0
void QgsGrassModule::run()
{
  QgsDebugMsg( "called." );

  if ( mProcess.state() == QProcess::Running )
  {
    mProcess.kill();
    mRunButton->setText( tr( "Run" ) );
  }
  else
  {
    //QString command;
    QStringList arguments;

    //mProcess.clearArguments();
    //mProcess.addArgument( mXName );
    //command = mXName;

    // Check if options are ready
    QStringList readyErrors = mOptions->ready();
    if ( readyErrors.size() > 0 )
    {
      QString err;
      for ( int i = 0; i < readyErrors.size(); i++ )
      {
        err.append( readyErrors.at( i ) + "<br>" );
      }
      QMessageBox::warning( 0, tr( "Warning" ), err );
      return;
    }

    // Check/set region
    struct Cell_head tempWindow;
    bool resetRegion = false;
    QgsCoordinateReferenceSystem crs;
    if ( mOptions->requestsRegion() ) // direct always
    {
      if ( !mOptions->inputRegion( &tempWindow, crs, false ) )
      {
        QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot get input region" ) );
        return;
      }
      resetRegion = true;
    }
    else if ( mOptions->usesRegion() )
    {
      QStringList outsideRegion = mOptions->checkRegion();
      if ( outsideRegion.size() > 0 )
      {
        QMessageBox questionBox( QMessageBox::Question, tr( "Warning" ),
                                 tr( "Input %1 outside current region!" ).arg( outsideRegion.join( QStringLiteral( "," ) ) ),
                                 QMessageBox::Ok | QMessageBox::Cancel );
        QPushButton *resetButton = nullptr;
        if ( QgsGrass::versionMajor() > 6 || ( QgsGrass::versionMajor() == 6 && QgsGrass::versionMinor() >= 1 ) )
        {
          resetButton = questionBox.addButton( tr( "Use Input Region" ), QMessageBox::DestructiveRole );
        }
        questionBox.exec();
        QAbstractButton *clicked = questionBox.clickedButton();
        if ( clicked == questionBox.button( QMessageBox::Cancel ) )
          return;
        if ( clicked == resetButton )
          resetRegion = true;

        if ( resetRegion )
        {
          if ( !mOptions->inputRegion( &tempWindow, crs, true ) )
          {
            QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot get input region" ) );
            return;
          }
        }
      }
    }

    // In direct mode user is warned by select file dialog
    if ( !mDirect )
    {
      // Check if output exists
      QStringList outputExists = mOptions->checkOutput();
      if ( outputExists.size() > 0 )
      {
        QMessageBox::StandardButton ret = QMessageBox::question( 0, QStringLiteral( "Warning" ),
                                          tr( "Output %1 exists! Overwrite?" ).arg( outputExists.join( QStringLiteral( "," ) ) ),
                                          QMessageBox::Ok | QMessageBox::Cancel );

        if ( ret == QMessageBox::Cancel )
          return;

        arguments.append( QStringLiteral( "--o" ) );
      }
    }

    // Remember output maps
    mOutputVector = mOptions->output( QgsGrassModuleOption::Vector );
    QgsDebugMsg( QString( "mOutputVector.size() = %1" ).arg( mOutputVector.size() ) );
    mOutputRaster = mOptions->output( QgsGrassModuleOption::Raster );
    QgsDebugMsg( QString( "mOutputRaster.size() = %1" ).arg( mOutputRaster.size() ) );
    mSuccess = false;
    mViewButton->setEnabled( false );

    QStringList list = mOptions->arguments();
    list << arguments;

    QStringList argumentsHtml;
    for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
    {
      QgsDebugMsg( "option: " + ( *it ) );
      //command.append ( " " + *it );
      arguments.append( *it );
      //mProcess.addArgument( *it );

      // Quote options with special characters so that user
      // can copy-paste-run the command
      if ( it->contains( QRegExp( "[ <>\\$|;&]" ) ) )
      {
        argumentsHtml.append( "\"" + *it + "\"" );
      }
      else
      {
        argumentsHtml.append( *it );
      }
    }

    /* WARNING - TODO: there was a bug in GRASS 6.0.0 / 6.1.CVS (< 2005-04-29):
     * db_start_driver set GISRC_MODE_MEMORY eviroment variable to 1 if
     * G_get_gisrc_mode() == G_GISRC_MODE_MEMORY but the variable wasn't unset
     * if  G_get_gisrc_mode() == G_GISRC_MODE_FILE. Because QGIS GRASS provider starts drivers in
     * G_GISRC_MODE_MEMORY mode, the variable remains set in variable when a module is run
     * -> unset GISRC_MODE_MEMORY. Remove later once 6.1.x / 6.0.1 is widespread.
    *   */
    putenv( ( char * ) "GISRC_MODE_MEMORY" ); // unset

    mOutputTextBrowser->clear();

    QProcessEnvironment environment = processEnvironment( mDirect );
    environment.insert( QStringLiteral( "GRASS_HTML_BROWSER" ), QgsGrassUtils::htmlBrowserPath() );

    // Warning: it is not useful to write requested region to WIND file and
    //          reset then to original because it is reset before
    //          the region is read by a module even if waitForStarted() is used
    //          -> necessary to pass region as environment variable
    //             but the feature is available in GRASS 6.1 only since 23.3.2006
    if ( resetRegion )
    {
      QString reg = QgsGrass::regionString( &tempWindow );
      QgsDebugMsg( "reg: " + reg );
      environment.insert( QStringLiteral( "GRASS_REGION" ), reg );
    }

    if ( mDirect )
    {
      QStringList variables;
      setDirectLibraryPath( environment );
#ifdef Q_OS_WIN
      variables << "PATH";
#elif defined(Q_OS_MAC)
      variables << "DYLD_LIBRARY_PATH";
#else
      variables << QStringLiteral( "LD_LIBRARY_PATH" );
#endif
      environment.insert( QStringLiteral( "QGIS_PREFIX_PATH" ), QgsApplication::prefixPath() );
      if ( crs.isValid() ) // it should always be valid
      {
        environment.insert( QStringLiteral( "QGIS_GRASS_CRS" ), crs.toProj4() );
      }
      // Suppress debug output
      environment.insert( QStringLiteral( "QGIS_DEBUG" ), QStringLiteral( "-1" ) );

      // Print some important variables
      variables << QStringLiteral( "QGIS_PREFIX_PATH" ) << QStringLiteral( "QGIS_GRASS_CRS" ) << QStringLiteral( "GRASS_REGION" );
      Q_FOREACH ( const QString &v, variables )
      {
        mOutputTextBrowser->append( v + "=" + environment.value( v ) + "<BR>" );
      }
    }

    QString commandHtml = mXName + " " + argumentsHtml.join( QStringLiteral( " " ) );

    QgsDebugMsg( "command: " + commandHtml );
    commandHtml.replace( QLatin1String( "&" ), QLatin1String( "&amp;" ) );
    commandHtml.replace( QLatin1String( "<" ), QLatin1String( "&lt;" ) );
    commandHtml.replace( QLatin1String( ">" ), QLatin1String( "&gt;" ) );
    mOutputTextBrowser->append( "<B>" +  commandHtml + "</B>" );

    // I was not able to get scripts working on Windows
    // via QProcess and sh.exe (MinGW). g.parser runs wellQProcessEnvironment::systemE
    // and it sets parameters correctly as environment variables
    // but it fails (without error) to re-run the script with
    // execlp(). And I could not figure out why it fails.
    // Because of this problem we simulate here what g.parser
    // normally does and that way we can avoid it.

    QStringList execArguments = QgsGrassModule::execArguments( mXName );

    if ( execArguments.size() == 0 )
    {
      QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot find module %1" ).arg( mXName ) );
      return;
    }

#ifdef Q_OS_WIN
    // we already know it exists from execArguments()
    QString exe = QgsGrass::findModule( mXName );
    QFileInfo fi( exe );
    if ( !fi.isExecutable() )
    {
      QStringList usedFlagNames;

      // Set environment variables
      for ( int i = 0; i < arguments.size(); i++ )
      {
        QString arg = arguments.at( i );
        //QString env;
        if ( arg.at( 0 ) == '-' ) //flag
        {
          //env = "GIS_FLAG_" + QString( arg.at( 1 ).toUpper() ) + "=1";
          environment.insert( "GIS_FLAG_" + QString( arg.at( 1 ).toUpper() ), "1" );
          usedFlagNames.append( arg.at( 1 ) );
        }
        else // option
        {
          QStringList opt = arg.split( "=" );
          //env = "GIS_OPT_" + opt.takeFirst().toUpper();
          //env += "=" + opt.join( "=" ); // rejoin rest
          environment.insert( "GIS_OPT_" + opt.takeFirst().toUpper(), opt.join( "=" ) );
        }
        //environment.append( env );
      }

      // Set remaining flags
      QStringList allFlagNames = mOptions->flagNames();
      for ( int i = 0; i < allFlagNames.size(); i++ )
      {
        bool used = false;
        for ( int j = 0; j < usedFlagNames.size(); j++ )
        {
          if ( usedFlagNames.at( j ) == allFlagNames.at( i ) )
          {
            used = true;
            break;
          }
        }
        if ( used )
          continue;
        //QString env = "GIS_FLAG_"
        //              + QString( allFlagNames.at( i ).toUpper() )
        //              + "=0";
        //QgsDebugMsg( "set: " + env );
        //environment.append( env );
        environment.insert( "GIS_FLAG_" + QString( allFlagNames.at( i ).toUpper() ), "0" );
      }

      arguments.clear();
      arguments.append( "@ARGS_PARSED@" );
    }
#endif

    QString cmd = execArguments.takeFirst();
    execArguments += arguments;

    // Freeze output vector on Windows
    mOptions->freezeOutput();

    mProcess.setProcessEnvironment( environment );
    mProcess.start( cmd, execArguments );
    emit moduleStarted();

    mProcess.waitForStarted();
    if ( mProcess.state() != QProcess::Running )
    {
      QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot start module: %1" ).arg( mProcess.errorString() ) );
      return;
    }

    mTabWidget->setCurrentIndex( 1 );
    mRunButton->setText( tr( "Stop" ) );
  }
Ejemplo n.º 18
0
void MigrateDialog::process()
{
    unsigned size = 0;
    for (list<QCheckBox*>::iterator it = m_boxes.begin(); it != m_boxes.end(); ++it){
        if (!(*it)->isChecked())
            continue;
        QString path = user_file((*it)->text());
        path += '/';
        icqConf.close();
        clientsConf.close();
        contactsConf.close();
        icqConf.setFileName(path + "icq.conf");
        clientsConf.setFileName(path + "clients.conf");
        contactsConf.setFileName(path + "contacts.conf");
        lblStatus->setText(path + "icq.conf");
        if (!icqConf.open(QIODevice::ReadOnly)){
            error(i18n("Can't open %1") .arg(path + "icq.conf"));
            return;
        }
        if (!clientsConf.open(QIODevice::WriteOnly | QIODevice::Truncate)){
            error(i18n("Can't open %1") .arg(path + "clients.conf"));
            return;
        }
        if (!contactsConf.open(QIODevice::WriteOnly | QIODevice::Truncate)){
            error(i18n("Can't open %1") .arg(path + "contacts.conf"));
            return;
        }
        m_uin    = 0;
        m_passwd = "";
        m_state  = 0;
        m_grpId		= 0;
        m_contactId = 0;
        Buffer cfg;
        cfg.init(icqConf.size());
        icqConf.read(cfg.data(), icqConf.size());
        for (;;){
            QByteArray section = cfg.getSection();
            if (section.isEmpty())
                break;
            m_state = 3;
            if (section == "Group")
                m_state = 1;
            if (section == "User")
                m_state = 2;
            if (!m_bProcess)
                return;
            for (;;){
                QByteArray l = cfg.getLine();
                if (l.isEmpty())
                    break;
                QByteArray line = l;
                QByteArray name = getToken(line, '=');
                if (name == "UIN")
                    m_uin = line.toUInt();
                if (name == "EncryptPassword")
                    m_passwd = line;
                if (name == "Name")
                    m_name = line;
                if (name == "Alias")
                    m_name = line;
            }
            flush();
            barCnv->setValue(cfg.readPos());
            qApp->processEvents();
        }
        icqConf.close();
        clientsConf.close();
        contactsConf.close();
        m_state = 3;
        size += icqConf.size();
        if (!m_bProcess)
            return;
        barCnv->setValue(size);
        qApp->processEvents();
        QString h_path = path;
#ifdef WIN32
        h_path += "history\\";
#else
        h_path += "history/";
#endif
        QDir history(h_path);
        QStringList l = history.entryList(QStringList("*.history"), QDir::Files);
        for (QStringList::Iterator it = l.begin(); it != l.end(); ++it){
            hFrom.close();
            hTo.close();
            hFrom.setFileName(h_path + (*it));
            lblStatus->setText(h_path + (*it));
            hTo.setFileName(h_path + QString(m_owner) + '.' + it->left(it->indexOf('.')));
            if (!hFrom.open(QIODevice::ReadOnly)){
                error(i18n("Can't open %1") .arg(hFrom.fileName()));
                return;
            }
            if (!hTo.open(QIODevice::WriteOnly | QIODevice::Truncate)){
                error(i18n("Can't open %1") .arg(hTo.fileName()));
                return;
            }
            cfg.init(hFrom.size());
            hFrom.read(cfg.data(), hFrom.size());
            for (;;){
                QByteArray section = cfg.getSection();
                if (section.isEmpty())
                    break;
                m_state = 3;
                if (section == "Message")
                    m_state = 4;
                if (!m_bProcess)
                    return;
                for (;;){
                    QByteArray l = cfg.getLine();
                    if (l.isEmpty())
                        break;
                    QByteArray line = l;
                    QByteArray name = getToken(line, '=');
                    if (name == "Message")
                        m_message = line;
                    if (name == "Time")
                        m_time = line;
                    if (name == "Direction")
                        m_direction = line;
                    if (name == "Charset")
                        m_charset = line;
                }
                flush();
                barCnv->setValue(cfg.readPos());
                qApp->processEvents();
            }
            hFrom.close();
            hTo.close();
            m_state = 3;
            size += hFrom.size();
            if (!m_bProcess)
                return;
            barCnv->setValue(size);
            qApp->processEvents();
        }
        if (chkRemove->isChecked()){
            icqConf.remove();
            icqConf.setFileName(path + "sim.conf");
            icqConf.remove();
            for (QStringList::Iterator it = l.begin(); it != l.end(); ++it){
                hFrom.setFileName(h_path + (*it));
                hFrom.remove();
            }
        }
    }
    m_bProcess = false;
    accept();
}
Ejemplo n.º 19
0
void pdp::Toolbar::OpenFile()
{
	//std::cout << "hi from " << __FUNCSIG__ << std::endl;

	mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New();
	QStringList fileNames;
	
	if(AT_HOME == 1)
	{
		fileNames = QFileDialog::getOpenFileNames(NULL, "Open", "C:\\DA\\Data\\", "*" );
	}
	else
	{
		fileNames = QFileDialog::getOpenFileNames(NULL, "Open", "E:\\Media Informatics\\thesis\\Hendrik_PhanAnh_pdp\\PA_Hendrik\\PA_Hendrik\\pdp\\Hendrik_pdp\\data", "*" );
		
	}

	if(!(fileNames.isEmpty()))
	{
		for(QStringList::Iterator fileName = fileNames.begin(); fileName != fileNames.end(); fileName++)
		{
			if(QFile::exists(fileName->toLocal8Bit().data()))
			{
				nodeReader->SetFileName(fileName->toLocal8Bit().data());
				try
				{
					nodeReader->Update();
				}
				catch (itk::ExceptionObject &ex)
				{
					std::cout << ex << std::endl;
				}
				catch (std::exception &ex1)
				{
					ex1.what();
				}

				// Adding file/image to the DataNode
				mitk::DataNode::Pointer node;
				node = nodeReader->GetOutput(0);
				
				// Add unique id
				int newId = m_ThreeDEditing->GetUniqueId();
				node->SetIntProperty("UniqueID", newId);
				node->SetBoolProperty("ModifiedThusConvert", mitk::BoolProperty::New(false));

				// Surface visualisation
				//node->SetFloatProperty("material.wireframeLineWidth", 8.0);
				node->ReplaceProperty("line width", mitk::IntProperty::New(3));

				m_ThreeDEditing->GetLungDataset()->getDataStore()->Add(node);
				m_ThreeDEditing->SetUpMitkView();
			}
			else
			{
				std::cout << "Selected file does not exist!\n";
			}
		}
	}
	else
	{
		std::cout << "No file given to the program!\n";
	}

	// Segmentations should be in the front, the reference image in the back
	SetImagesToBottom();

	//std::cout << "ciao from " << __FUNCSIG__ << std::endl;
}
Ejemplo n.º 20
0
void QmitkCommonExtPlugin::handleIPCMessage(const QByteArray& msg)
{
  QDataStream ds(msg);
  QString msgType;
  ds >> msgType;

  // we only handle messages containing command line arguments
  if (msgType != "$cmdLineArgs") return;

  // activate the current workbench window
  berry::IWorkbenchWindow::Pointer window =
      berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow();

  QMainWindow* mainWindow =
   static_cast<QMainWindow*> (window->GetShell()->GetControl());

  mainWindow->setWindowState(mainWindow->windowState() & ~Qt::WindowMinimized);
  mainWindow->raise();
  mainWindow->activateWindow();

  // Get the preferences for the instantiation behavior
  berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService();
  berry::IPreferences::Pointer prefs = prefService->GetSystemPreferences()->Node("/General");
  bool newInstanceAlways = prefs->GetBool("newInstance.always", false);
  bool newInstanceScene = prefs->GetBool("newInstance.scene", true);

  QStringList args;
  ds >> args;

  QStringList fileArgs;
  QStringList sceneArgs;

  Poco::Util::OptionSet os;
  berry::Platform::GetOptionSet(os);
  Poco::Util::OptionProcessor processor(os);
#if !defined(POCO_OS_FAMILY_UNIX)
  processor.setUnixStyle(false);
#endif
  args.pop_front();
  QStringList::Iterator it = args.begin();
  while (it != args.end())
  {
    std::string name;
    std::string value;
    if (processor.process(it->toStdString(), name, value))
    {
      ++it;
    }
    else
    {
      if (it->endsWith(".mitk"))
      {
        sceneArgs << *it;
      }
      else
      {
        fileArgs << *it;
      }
      it = args.erase(it);
    }
  }

  if (newInstanceAlways)
  {
    if (newInstanceScene)
    {
      startNewInstance(args, fileArgs);

      foreach(QString sceneFile, sceneArgs)
      {
        startNewInstance(args, QStringList(sceneFile));
      }
    }
    else
    {