コード例 #1
0
ファイル: chatbox.cpp プロジェクト: jesyspa/4DGo
void Chatbox::parseString(QString str) {
	if (str[0] != '!') {
		emit message(str);
		return;
	}
	str[0] = ' ';
	str = str.trimmed().toLower();
	QStringList list = str.split(QRegExp("\\s+"));
	QStringList::const_iterator it = list.begin();
	if (it->contains(rgxPos)) {
		emit playStone(Position(*it));
	} else if (*it == "pass" || *it == "p") {
		emit pass();
	} else if (*it == "undo" || *it == "u") {
		emit undo();
	} else if (*it == "kill" || *it == "k") {
		if (++it == list.end() || !it->contains(rgxPos))
			display("Expected position as second argument.");
		else
			emit kill(Position(*it));
	} else if (*it == "exit" || *it == "e") {
		emit exit();
	} else if (*it == "connect" || *it == "c") {
		if (++it != list.end()) {
			emit setHost(*it);
			if (++it != list.end()) {
				emit setPort(it->toInt());
			}
		}
		emit cl_connect();
	} else if (*it == "disconnect" || *it == "dc") {
		emit cl_disconnect();
	} else if (*it == "yes" || *it == "y") {
		emit confirm(true);
	} else if (*it == "no" || *it == "n") {
		emit confirm(false);
	} else if (*it == "save" || *it == "s") {
		if (++it == list.end())
			display("Expected filename as second argument.");
		else
			emit writeLogToDisk(*it);
	} else if (*it == "help" || *it == "h" ) {
		display("4DGo -- A four-dimensional goban for online play.");
		display("All commands start with a '!'. Any input that does not is treated as a chat message. All comands are case-insensitive.");
		display("  Commands:");
		display("!connect [hostname] [port]: connect to the game server. By default, localhost:15493 will be used.");
		display("!disconnect: break connection to server and clear the goban.");
		display("!A4d4: on slice A4 (top-left), on intersection d4 (top-right).");
		display("!pass: end your turn without playing a stone.");
		display("!undo: request that your last move be undone.");
		display("!yes: allow the action your opponent requested (usually an undo or kill).");
		display("!yes: refuse to allow the action your opponent requested (usually an undo or kill).");
		display("!kill: request a certain group to be immediately taken off the board. Useful in endgame, to not need to play out all captures.");
		display("!save filename: save the current history to file filename.");
		display("!exit: disconnect and close the window.");
	} else {
		tbCBox_->append(QString("Unknown command: ")+*it);
	}
}
コード例 #2
0
void QgsCoordinateTransformContext::readSettings()
{
  d.detach();
  d->mLock.lockForWrite();

  d->mSourceDestDatumTransforms.clear();
#if 0
  d->mSourceDatumTransforms.clear();
  d->mDestDatumTransforms.clear();
#endif

  QgsSettings settings;
  settings.beginGroup( QStringLiteral( "/Projections" ) );
  QStringList projectionKeys = settings.allKeys();

  //collect src and dest entries that belong together
  QMap< QPair< QString, QString >, QPair< int, int > > transforms;
  QStringList::const_iterator pkeyIt = projectionKeys.constBegin();
  for ( ; pkeyIt != projectionKeys.constEnd(); ++pkeyIt )
  {
    if ( pkeyIt->contains( QLatin1String( "srcTransform" ) ) || pkeyIt->contains( QLatin1String( "destTransform" ) ) )
    {
      QStringList split = pkeyIt->split( '/' );
      QString srcAuthId, destAuthId;
      if ( ! split.isEmpty() )
      {
        srcAuthId = split.at( 0 );
      }
      if ( split.size() > 1 )
      {
        destAuthId = split.at( 1 ).split( '_' ).at( 0 );
      }

      QString proj = settings.value( *pkeyIt ).toString();
      Q_NOWARN_DEPRECATED_PUSH
      int datumId = QgsDatumTransform::projStringToDatumTransformId( proj );
      Q_NOWARN_DEPRECATED_POP
      if ( pkeyIt->contains( QLatin1String( "srcTransform" ) ) )
      {
        transforms[ qMakePair( srcAuthId, destAuthId )].first = datumId;
      }
      else if ( pkeyIt->contains( QLatin1String( "destTransform" ) ) )
      {
        transforms[ qMakePair( srcAuthId, destAuthId )].second = datumId;
      }
    }
  }
コード例 #3
0
ファイル: cliparser.cpp プロジェクト: ginggs/quassel2go
bool CliParser::init(const QStringList &args) {
    argsRaw = args;
    QStringList::const_iterator currentArg;
    for (currentArg = argsRaw.constBegin(); currentArg != argsRaw.constEnd(); ++currentArg) {
        if(currentArg->startsWith("--")) {
            // long
            QString name;
            if(currentArg->contains("=")) {
                // option
                QStringList tmp = currentArg->mid(2).split("=");
                name = tmp.at(0);
                QString value;
                // this is needed to allow --option=""
                if(tmp.at(1).isNull()) value = QString("");
                else value = tmp.at(1);
                if(!addLongArg(CliParserArg::CliArgOption, name, value)) return false;
            }
            else {
                // switch
                name = currentArg->mid(2);
                if(!addLongArg(CliParserArg::CliArgSwitch, name)) return false;
            }
        }
        else if(currentArg->startsWith("-")) {
            // short
            char name;
            QStringList::const_iterator nextArg = currentArg+1;
            // if next arg is a short/long option/switch the current arg is one too
            if(nextArg == argsRaw.constEnd() || nextArg->startsWith("-")) {
                // switch
                for (int i = 0; i < currentArg->mid(1).toAscii().size(); i++) {
                    name = currentArg->mid(1).toAscii().at(i);
                    if(!addShortArg(CliParserArg::CliArgSwitch, name)) return false;
                }
            }
            // if next arg is is no option/switch it's an argument to a shortoption
            else {
                // option
                // short options are not freely mixable with other shortargs
                if(currentArg->mid(1).toAscii().size() > 1) {
                    qWarning() << "Warning: Shortoptions may not be combined with other shortoptions or switches";
                    return false;
                }
                QString value;
                bool skipNext = false;
                if(nextArg != argsRaw.constEnd()) {
                    value = nextArg->toLocal8Bit();
                    skipNext = true;
                }
                else value = currentArg->toLocal8Bit();
                name = currentArg->mid(1).toAscii().at(0);
                // we took one argument as argument to an option so skip it next time
                if(skipNext) currentArg++;
                if(!addShortArg(CliParserArg::CliArgOption, name, value)) return false;
            }
        }
        else {
            // we don't support plain arguments without -/--
            if(currentArg->toLatin1() != argsRaw.at(0)) return false;
        }
    }
    return true;
}