Пример #1
0
QgsAbstractGeometry *QgsMultiPolygon::boundary() const
{
  std::unique_ptr< QgsMultiLineString > multiLine( new QgsMultiLineString() );
  for ( int i = 0; i < mGeometries.size(); ++i )
  {
    if ( QgsPolygon *polygon = qgsgeometry_cast<QgsPolygon *>( mGeometries.at( i ) ) )
    {
      QgsAbstractGeometry *polygonBoundary = polygon->boundary();

      if ( QgsLineString *lineStringBoundary = qgsgeometry_cast< QgsLineString * >( polygonBoundary ) )
      {
        multiLine->addGeometry( lineStringBoundary );
      }
      else if ( QgsMultiLineString *multiLineStringBoundary = qgsgeometry_cast< QgsMultiLineString * >( polygonBoundary ) )
      {
        for ( int j = 0; j < multiLineStringBoundary->numGeometries(); ++j )
        {
          multiLine->addGeometry( multiLineStringBoundary->geometryN( j )->clone() );
        }
        delete multiLineStringBoundary;
      }
      else
      {
        delete polygonBoundary;
      }
    }
  }
  if ( multiLine->numGeometries() == 0 )
  {
    return nullptr;
  }
  return multiLine.release();
}
Пример #2
0
UString SieveParser::string()
{
    whitespace();
    if ( nextChar() == '"' )
        return quotedString();
    return multiLine();
}
Пример #3
0
    // Replace newline characters literal "\n"  for inline editing in mode ValidationMultiLine
    QString TextPropertyEditor::stringToEditorString(const QString &s, TextPropertyValidationMode  validationMode) {
        if (s.isEmpty() || !multiLine(validationMode))
            return s;

        QString rc(s);
        // protect backslashes
        rc.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
        // escape newlines
        rc.replace(NewLineChar, QString(EscapedNewLine));
        return rc;

    }
Пример #4
0
    void TextPropertyEditor::setTextPropertyValidationMode(TextPropertyValidationMode vm) {
        m_validationMode = vm;
        m_lineEdit->setWantNewLine(multiLine(m_validationMode));
        switch (m_validationMode) {
        case ValidationStyleSheet:
            m_lineEdit->setValidator(new  StyleSheetValidator(m_lineEdit));
            m_lineEdit->setCompleter(0);
            break;
        case ValidationMultiLine:
        case ValidationRichText:
            // Set a  validator that replaces newline characters by literal "\\n".
            // While it is not possible to actually type a newline  characters,
            // it can be pasted into the line edit.
            m_lineEdit->setValidator(new ReplacementValidator(m_lineEdit, NewLineChar, EscapedNewLine));
            m_lineEdit->setCompleter(0);
            break;
        case ValidationSingleLine:
            // Set a  validator that replaces newline characters by a blank.
            m_lineEdit->setValidator(new ReplacementValidator(m_lineEdit, NewLineChar, QString(QLatin1Char(' '))));
             m_lineEdit->setCompleter(0);
            break;
        case ValidationObjectName:
            setRegExpValidator(QLatin1String("[_a-zA-Z][_a-zA-Z0-9]{,1023}"));
             m_lineEdit->setCompleter(0);
             break;
        case ValidationObjectNameScope:
            setRegExpValidator(QLatin1String("[_a-zA-Z:][_a-zA-Z0-9:]{,1023}"));
            m_lineEdit->setCompleter(0);
            break;
        case ValidationURL: {
            static QStringList urlCompletions;
            if (urlCompletions.empty()) {
                urlCompletions.push_back(QLatin1String("about:blank"));
                urlCompletions.push_back(QLatin1String("http://"));
                urlCompletions.push_back(QLatin1String("http://www."));
                urlCompletions.push_back(QLatin1String("http://qt.nokia.com/"));
                urlCompletions.push_back(QLatin1String("file://"));
                urlCompletions.push_back(QLatin1String("ftp://"));
                urlCompletions.push_back(QLatin1String("data:"));
                urlCompletions.push_back(QLatin1String("data:text/html,"));
                urlCompletions.push_back(QLatin1String("qrc:/"));
            }
            QCompleter *completer = new QCompleter(urlCompletions, m_lineEdit);
            m_lineEdit->setCompleter(completer);
            m_lineEdit->setValidator(new UrlValidator(completer, m_lineEdit));
        }
            break;
        }

        setFocusProxy(m_lineEdit);
        setText(m_cachedText);
        markIntermediateState();
    }
Пример #5
0
    // Replace literal "\n"  by actual new lines for inline editing in mode ValidationMultiLine
    // Note: As the properties are updated while the user types, it is important
    // that trailing slashes ('bla\') are not deleted nor ignored, else this will
    // cause jumping of the  cursor
    QString  TextPropertyEditor::editorStringToString(const QString &s, TextPropertyValidationMode  validationMode) {
        if (s.isEmpty() || !multiLine(validationMode))
            return s;

        QString rc(s);
        for (int pos = 0; (pos = rc.indexOf(QLatin1Char('\\'),pos)) >= 0 ; ) {
            // found an escaped character. If not a newline or at end of string, leave as is, else insert '\n'
            const int nextpos = pos + 1;
            if (nextpos  >= rc.length())  // trailing '\\'
                 break;
            // Escaped NewLine
            if (rc.at(nextpos) ==  QChar(QLatin1Char('n')))
                 rc[nextpos] =  NewLineChar;
            // Remove escape, go past escaped
            rc.remove(pos,1);
            pos++;
        }
        return rc;
    }
Пример #6
0
void MainWindow::OpenFile(const QString& file){
	setStatusTip(UTF8("打开文件:")+file);
	bool test_ok = false;

	QFile fp(file);
	test_ok = fp.exists();
	if(!test_ok) throw AlertException(UTF8("打开失败"),UTF8("文件不存在:\n")+file);
	test_ok = fp.open(QFile::ReadOnly);
	if(!test_ok) throw AlertException(UTF8("打开失败"),UTF8("无法读取文件:\n")+file);

	QTextStream CurrentFile(&fp);
	//读取文件中的配置
	QString Line;
	QString OData;
	QTextStream ProjectData(&OData);
	bool switcher = false;
	while( !CurrentFile.atEnd() ){
		Line = CurrentFile.readLine();
		if( !switcher ){ //非 配置or导出 部分
			if(Line.startsWith(StartIndent) || Line.startsWith(AutoGenIndent)){
				switcher = true;
				continue;
			}
		}else{ //配置or导出 部分
			switcher = !(Line.startsWith(EndIndent) || Line.startsWith(AutoGenEndIndent));
			ProjectData<<Line<<endl;
		}
	}

	bool start = false;
	while(!ProjectData.atEnd()){
		QString Line = ProjectData.readLine();
		if( Line == "[GLOBAL]" ){
			start = true;
			continue;
		}
		if( Line == "[END]" ){
			start = false;
			continue;
		}
		if(!start) continue;

		Line = Line.trimmed();
		QString ID = Line.section(' ',0,0).toLower();
		ID.truncate(ID.length()-1);
		QString Value = multiLine( Line.section(' ',1) );

		CurrentSetting->setProperty(ID.toStdString().data(),Value);

	}

	if(!test_ok) throw AlertException(UTF8("打开失败"),UTF8("无法在文件中识别本程序的格式"));

	ProjectData.reset();
	wm->restart();

	//移动当前目录
	QString stuff_dir = file + STUFF_FOLDER;
	QDir stuff(stuff_dir);
	if( !stuff.exists() ){
		stuff.mkdir(stuff_dir);
	}
	stuff.setCurrent(stuff_dir);

	qDebug()<<"[OPEN FILE]Current dir is "<<QDir::currentPath();

	wm->SessionResume(OData);

	CurrentFilePath = file;
	this->setWindowTitle(file+QString(" - cssSprites"));
}