コード例 #1
0
WiFiSDCoopLib::WiFiSDCoopLib() {
	_init();
	setSSID("default");
	setPass("");
	_fileBuffer[0] = '\0';
	_fileBufferPos = 0;
}
コード例 #2
0
/// read preference table from sql
void preferences::readDB(){
    OpenDB();
    int count = 0;
    if(db2.open()){
    QSqlQuery query(db2);

     query = QString("SELECT * FROM pref");

     while (query.next()){
         QString QVal1 = query.value(1).toString();
         QString QVal2 = query.value(2).toString();
         QString QVal3 = query.value(3).toString();
         QString QVal4 = query.value(4).toString();
         QString QVal5 = query.value(5).toString();
         QString QVal6 = query.value(6).toString();
         QString QVal7 = query.value(7).toString();


         setUser(QVal1.toStdString());
         setPass(QVal2.toStdString());
         setServ(QVal3.toStdString());
         setPort(QVal4.toStdString());
         setTable(QVal5.toStdString());
         setSQL(QVal6.toStdString());
         setPlaylistDir(QVal7.toStdString());
     }
    db2.close();
    }

}
コード例 #3
0
/// read preference table from sql
void preferences::readDB(){

    if(QFile::exists(DBlocation.c_str())){
        db2 = QSqlDatabase::addDatabase("QSQLITE");
        db2.setDatabaseName(DBlocation.c_str());
        if(db2.open()){
            QSqlQuery query(db2);

            query = QString("SELECT * FROM pref");

            while (query.next()){
                QString QVal1 = query.value(1).toString();
                QString QVal2 = query.value(2).toString();
                QString QVal3 = query.value(3).toString();
                QString QVal4 = query.value(4).toString();
                QString QVal5 = query.value(5).toString();
                QString QVal6 = query.value(6).toString();


                setUser(QVal1.toStdString());
                setPass(QVal2.toStdString());
                setServ(QVal3.toStdString());
                setPort(QVal4.toStdString());
                setTable(QVal5.toStdString());
                setSQL(QVal6.toStdString());
            }
        }

        db2.removeDatabase("QSQLITE");
    }

}
コード例 #4
0
preferences& preferences::operator=(const preferences& src){

    if(this != &src)
    {
        setUser(src.USER);
        setPass(src.PASS);
        setServ(src.SERVER);
        setPort(src.PORT);
        setTable(src.TABLE);
        setSQL(src.DBlocation);
    }
    return *this;
}
コード例 #5
0
ファイル: gtpwrapper.cpp プロジェクト: epichub/neatzsche
void GTPWrapper::genmove(bool first)
{
  
  if(moves==1&&bsize==5&&!first&&board[24]==0&&board[25]==1) {//kens trick
    if(doMove("white B3")) {board[22]=1;board[23]=0;
      //      board.at(11) = 1;//cout << "setting white at b3.."<<endl;
      moves++; return;} 
    else{//cout << "could not white at b3.."<<endl; 
      setPass(first); return;}
  }
  // to make gnugo play through a 5x5 match..
  string r = (first) ? doCmd("genmove black") : doCmd("genmove white");
  //int s = first+1;
  //  cout << "r: " << r << endl;

  if(r.find("?")!=string::npos)
    return;
  if(r.find("PASS")!=string::npos){
    //    string s = (first) ? "black" : "white";
    //cout << ((first) ? "black" : "white") << " passed board: "<< endl << getLocalBoardAscii();
    setPass(first);
    return;
  }
  moves++;
//   r = r.substr(r.find(" ")+1,r.length());
//   r = r.substr(0,r.length());
//   int x = getCol(r[0]); int y = atoi(r.substr(1,r.length()).c_str()); y--; x++;
//   //   cout << "white moved to" << endl;   cout << "x:"<<x<<" y:"<<y<<"   r: " << r << " s:" << s << " first:" << first <<  endl; 
//   //  cout << "setting board at: " << ((bsize-x)*bsize)+y << " to " << s<<endl;
//   board.at(((bsize-x)*bsize)+y)  = s;
  updateFromGnuGo();
  //  int fanda;
  //  cin >> fanda;
  //  cout << "board at: " << ((x-bsize)*bsize)+y << ": " << board.at((x*bsize)+y) <<endl;
  //  cout << getBoardAscii() << endl;
}
コード例 #6
0
ファイル: qnapiconfig.cpp プロジェクト: Fisiu/qnapi
QString QNapiConfig::pass(const QString & engine)
{
    QString pass = settings->value(engine + "/pass", "").toString();

    if(pass.isEmpty() && (engine == "NapiProjekt"))
    {
        pass = settings->value("qnapi/pass", "").toString();

        if(!pass.isEmpty())
        {
            settings->remove("qnapi/pass");
            setPass("NapiProjekt", pass);
        }
    }

    return pass;
}
コード例 #7
0
ConnectionProperties::ConnectionProperties(Database *database, MainWin *mainwin)
{
    QPushButton *pBOK;
    QPushButton *pBCancel;
    QWidget *layoutWidget;
    QVBoxLayout *verticalLayout;

    setWindowFlags(Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_DeleteOnClose);
    resize(256, 288);
    setModal(true);
    setParent(mainwin);
    setWindowFlags(Qt::Window);
    setWindowModality(Qt::WindowModal);
    pBOK = new QPushButton(this);
    pBOK->setObjectName(QString::fromUtf8("pBOK"));
    pBOK->setAutoDefault(false);
    pBOK->setGeometry(QRect(30, 250, 75, 23));
    QFont font;
    font.setFamily(QString::fromUtf8("Verdana"));
    pBOK->setFont(font);
    pBCancel = new QPushButton(this);
    pBCancel->setObjectName(QString::fromUtf8("pBCancel"));
    pBCancel->setGeometry(QRect(140, 250, 75, 23));
    pBCancel->setFont(font);
    pBCancel->setAutoDefault(false);
    setDb(new QLineEdit(this));
    getDb()->setObjectName(QString::fromUtf8("lEDb"));
    getDb()->setGeometry(QRect(100, 90, 133, 20));
    getDb()->setFont(font);
    getDb()->setAutoFillBackground(true);
    getDb()->setInputMethodHints(Qt::ImhNone);
    setSrv(new QLineEdit(this));
    getSrv()->setObjectName(QString::fromUtf8("lESrv"));
    getSrv()->setGeometry(QRect(100, 47, 133, 20));
    getSrv()->setFont(font);
    setPort(new QLineEdit(this));
    getPort()->setObjectName(QString::fromUtf8("lEPort"));
    getPort()->setGeometry(QRect(100, 130, 133, 20));
    getPort()->setFont(font);
    getPort()->setInputMethodHints(Qt::ImhFormattedNumbersOnly);
    getPort()->setInputMask("00000");
    setUser(new QLineEdit(this));
    getUser()->setObjectName(QString::fromUtf8("lEUser"));
    getUser()->setGeometry(QRect(100, 171, 133, 20));
    getUser()->setFont(font);
    setPass(new QLineEdit(this));
    getPass()->setObjectName(QString::fromUtf8("lEPass"));
    getPass()->setGeometry(QRect(100, 213, 133, 20));
    getPass()->setEchoMode(QLineEdit::Password);
    getPass()->setFont(font);
    layoutWidget = new QWidget(this);
    layoutWidget->setObjectName(QString::fromUtf8("layoutWidget"));
    layoutWidget->setGeometry(QRect(20, 40, 71, 201));
    verticalLayout = new QVBoxLayout(layoutWidget);
    verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
    verticalLayout->setContentsMargins(0, 0, 0, 0);
    lSrv = new QLabel(layoutWidget);
    lSrv->setObjectName(QString::fromUtf8("lSrv"));
    lSrv->setFont(font);
    verticalLayout->addWidget(lSrv);
    lDb = new QLabel(layoutWidget);
    lDb->setObjectName(QString::fromUtf8("lDb"));
    lDb->setFont(font);
    verticalLayout->addWidget(lDb);
    lPort = new QLabel(layoutWidget);
    lPort->setObjectName(QString::fromUtf8("lPort"));
    lPort->setFont(font);
    verticalLayout->addWidget(lPort);
    lUser = new QLabel(layoutWidget);
    lUser->setObjectName(QString::fromUtf8("lUser"));
    lUser->setFont(font);
    verticalLayout->addWidget(lUser);
    lPass = new QLabel(layoutWidget);
    lPass->setObjectName(QString::fromUtf8("lPass"));
    lPass->setFont(font);
    verticalLayout->addWidget(lPass);
    lTitle = new QLabel(this);
    lTitle->setObjectName(QString::fromUtf8("lTitle"));
    lTitle->setGeometry(QRect(20, 10, 211, 21));
    lTitle->setAlignment(Qt::AlignHCenter);
    QFont font1;
    font1.setFamily(QString::fromUtf8("Verdana"));
    font1.setPointSize(14);
    lTitle->setFont(font1);
    QWidget::setTabOrder(getSrv(), getDb());
    QWidget::setTabOrder(getDb(), getPort());
    QWidget::setTabOrder(getPort(), getUser());
    QWidget::setTabOrder(getUser(), getPass());
    QWidget::setTabOrder(getPass(), pBOK);
    QWidget::setTabOrder(pBOK, pBCancel);
    QObject::connect(pBCancel, SIGNAL(clicked()), this, SLOT(close()));
    QObject::connect(pBOK, SIGNAL(clicked()), this, SLOT(okslot()));
    QObject::connect(this, SIGNAL(oksignal(QString,qint32,QString,QString,QString)),
                     mainwin, SLOT(newDatabase(QString,qint32,QString,QString,QString)));
    QObject::connect(getSrv(), SIGNAL(returnPressed()), getDb(), SLOT(setFocus()));
    QObject::connect(getDb(), SIGNAL(returnPressed()), getPort(), SLOT(setFocus()));
    QObject::connect(getPort(), SIGNAL(returnPressed()), getUser(), SLOT(setFocus()));
    QObject::connect(getUser(), SIGNAL(returnPressed()), getPass(), SLOT(setFocus()));
    QObject::connect(getPass(), SIGNAL(returnPressed()), pBOK, SLOT(setFocus()));
    setWindowTitle(QApplication::translate("Connection", "Connection", 0, QApplication::UnicodeUTF8));
    pBOK->setText(QApplication::translate("Connection", "OK", 0, QApplication::UnicodeUTF8));
    pBCancel->setText(QApplication::translate("Connection", "Cancel", 0, QApplication::UnicodeUTF8));
    if(!database->getDatabaseStatus()) {
        getSrv()->setText(database->getHost());
        getDb()->setText(database->getName());
        getPort()->setText(database->getPort());
        getUser()->setText(database->getUser());
        getPass()->setText(database->getPassword());
    }
    else {
        QSqlDatabase database_connection = QSqlDatabase::database(QString("base").append(QString::number(database->getId())));
        getSrv()->setText(database_connection.hostName());
        getDb()->setText(database->getName());
        getPort()->setText(QString::number(database_connection.port()));
        getUser()->setText(database_connection.userName());
        getPass()->setText(database_connection.password());
    }
    lTitle->setText(QApplication::translate("Connection", "Connection", 0, QApplication::UnicodeUTF8));
    lSrv->setText(QApplication::translate("Connection", "Server", 0, QApplication::UnicodeUTF8));
    lDb->setText(QApplication::translate("Connection", "Database", 0, QApplication::UnicodeUTF8));
    lPort->setText(QApplication::translate("Connection", "Port", 0, QApplication::UnicodeUTF8));
    lUser->setText(QApplication::translate("Connection", "Username", 0, QApplication::UnicodeUTF8));
    lPass->setText(QApplication::translate("Connection", "Password", 0, QApplication::UnicodeUTF8));
}
コード例 #8
0
ファイル: map_v2.cpp プロジェクト: tramboi/scummvm-test
void Map_v2::loadMapObjects(const char *avjFile) {
	uint8 wayPointsCount;
	uint16 var;
	int16 id;
	int16 mapWidth, mapHeight;
	int16 tmp;
	byte *variables;
	uint32 tmpPos;
	uint32 passPos;

	var = _vm->_game->_script->readVarIndex();
	variables = _vm->_inter->_variables->getAddressOff8(var);

	id = _vm->_game->_script->readInt16();

	if (((uint16) id) >= 65520) {
		switch ((uint16) id) {
			case 65530:
				for (int i = 0; i < _mapWidth * _mapHeight; i++)
					_passMap[i] -= READ_VARO_UINT8(var + i);
				break;
			case 65531:
				for (int i = 0; i < _mapWidth * _mapHeight; i++)
					_passMap[i] += READ_VARO_UINT8(var + i);
				break;
			case 65532:
				for (int i = 0; i < _mapWidth * _mapHeight; i++)
					WRITE_VARO_UINT8(var + i, 0x00);
				break;
			case 65533:
				warning("Map_v2::loadMapObjects(): ID == 65533");
				break;
			case 65534:
				_tilesWidth = READ_VARO_UINT8(var);
				_tilesHeight = READ_VARO_UINT8(var + 1);
				_mapWidth = READ_VARO_UINT8(var + 2);
				_mapHeight = READ_VARO_UINT8(var + 3);
				_mapUnknownBool = READ_VARO_UINT8(var + 4) ? true : false;
				break;
			case 65535:
				_passMap = (int8 *)_vm->_inter->_variables->getAddressOff8(var);
				break;
			default:
				warning("Map_v2::loadMapObjects(): ID == %d", (uint16) id);
				break;
		}
		return;
	}

	Resource *resource = _vm->_game->_resources->getResource(id);
	if (!resource)
		return;

	Common::SeekableReadStream &mapData = *resource->stream();

	_mapVersion = mapData.readByte();
	if (_mapVersion == 4) {
		_screenWidth = 640;
		_screenHeight = 400;
	} else if (_mapVersion == 3) {
		_passWidth = 65;
		_screenWidth = 640;
		_screenHeight = 200;
	} else {
		_passWidth = 40;
		_screenWidth = 320;
		_screenHeight = 200;
	}

	_wayPointCount = mapData.readByte();
	_tilesWidth = mapData.readSint16LE();
	_tilesHeight = mapData.readSint16LE();

	_bigTiles = !(_tilesHeight & 0xFF00);
	_tilesHeight &= 0xFF;

	if (_mapVersion == 4) {
		_screenWidth = mapData.readSint16LE();
		_screenHeight = mapData.readSint16LE();
	}

	_mapWidth = _screenWidth / _tilesWidth;
	_mapHeight = _screenHeight / _tilesHeight;

	passPos = mapData.pos();
	mapData.skip(_mapWidth * _mapHeight);

	if (resource->getData()[0] == 1)
		wayPointsCount = _wayPointCount = 40;
	else
		wayPointsCount = _wayPointCount == 0 ? 1 : _wayPointCount;

	delete[] _wayPoints;
	_wayPoints = new WayPoint[wayPointsCount];
	for (int i = 0; i < _wayPointCount; i++) {
		_wayPoints[i].x = mapData.readSByte();
		_wayPoints[i].y = mapData.readSByte();
		_wayPoints[i].notWalkable = mapData.readSByte();
	}

	if (_mapVersion == 4) {
		_mapWidth  = VAR(17);
		_passWidth = _mapWidth;
	}

	// In the original asm, this writes byte-wise into the variables-array
	tmpPos = mapData.pos();
	mapData.seek(passPos);
	if ((variables != 0) &&
	    (variables != _vm->_inter->_variables->getAddressOff8(0))) {

		_passMap = (int8 *)variables;
		mapHeight = _screenHeight / _tilesHeight;
		mapWidth = _screenWidth / _tilesWidth;

		for (int i = 0; i < mapHeight; i++) {
			for (int j = 0; j < mapWidth; j++)
				setPass(j, i, mapData.readSByte());
			_vm->_inter->_variables->getAddressOff8(var + i * _passWidth);
		}
	}
	mapData.seek(tmpPos);

	tmp = mapData.readSint16LE();
	mapData.skip(tmp * 14);
	tmp = mapData.readSint16LE();
	mapData.skip(tmp * 14 + 28);
	tmp = mapData.readSint16LE();
	mapData.skip(tmp * 14);

	_vm->_goblin->_gobsCount = tmp;
	for (int i = 0; i < _vm->_goblin->_gobsCount; i++)
		loadGoblinStates(mapData, i);

	_vm->_goblin->_soundSlotsCount = _vm->_game->_script->readInt16();
	for (int i = 0; i < _vm->_goblin->_soundSlotsCount; i++)
		_vm->_goblin->_soundSlots[i] = _vm->_inter->loadSound(1);

	delete resource;
}
コード例 #9
0
ファイル: WiFiLib.cpp プロジェクト: Naguissa/WiFiLib
WiFiLib::WiFiLib() {
	setSSID("default");
	setPass("");
}
コード例 #10
0
ファイル: knsettings.cpp プロジェクト: kragen/mod_pubsub
bool 
CKNSettings::OpenKey(bool bForReading)
{
    // If reg key is open, close it

    if(m_hKey)
        CloseKey();


    // Stores result of reg operations

    LONG result;


    // If the key is for reading, open it w/ read perms, otherwise open w/ 
    // write perms, either way store key in it's handle

    if(bForReading) 
    {
        result = RegOpenKeyEx(HKEY_CURRENT_USER,
                              m_lpKeyName,
                              0,
                              KEY_QUERY_VALUE,
                              &m_hKey);
    } 
    else 
    {
        result = RegOpenKeyEx(HKEY_CURRENT_USER,
                              m_lpKeyName,
                              0,
                              KEY_WRITE,
                              &m_hKey);
    }


    // If opening didn't succeed, create the key

    if(result != ERROR_SUCCESS) 
    {
        DWORD disp;

        result = RegCreateKeyEx(HKEY_CURRENT_USER,
                                m_lpKeyName,
                                0,
                                NULL,
                                REG_OPTION_NON_VOLATILE,
                                KEY_WRITE,
                                NULL,
                                &m_hKey,
                                &disp);

        // If creating didn't succed, set handle to null and return false

        if(result != ERROR_SUCCESS) 
        {
            m_hKey = NULL;
            return false;
        }


        // Otherwise set settings to default.

        string str = "";

        setServer(str);
        setPort(0);
        setPath(str);
        setUser(str);
        setPass(str);
    }

    return true;
}
コード例 #11
0
void TestPreferences::testPreferences()
{
	auto pref = SettingsObjectWrapper::instance();
	pref->load();

	auto cloud = pref->cloud_storage;
	cloud->setBackgroundSync(true);
	TEST(cloud->backgroundSync(), true);
	cloud->setBackgroundSync(false);
	TEST(cloud->backgroundSync(), false);

	cloud->setBaseUrl("test_one");
	TEST(cloud->baseUrl(), QStringLiteral("test_one"));
	cloud->setBaseUrl("test_two");
	TEST(cloud->baseUrl(), QStringLiteral("test_two"));

	cloud->setEmail("*****@*****.**");
	TEST(cloud->email(), QStringLiteral("*****@*****.**"));
	cloud->setEmail("*****@*****.**");
	TEST(cloud->email(), QStringLiteral("*****@*****.**"));

	cloud->setGitLocalOnly(true);
	TEST(cloud->gitLocalOnly(), true);
	cloud->setGitLocalOnly(false);
	TEST(cloud->gitLocalOnly(), false);

	// Why there's new password and password on the prefs?
	cloud->setNewPassword("ABCD");
	TEST(cloud->newPassword(), QStringLiteral("ABCD"));
	cloud->setNewPassword("ABCDE");
	TEST(cloud->newPassword(), QStringLiteral("ABCDE"));

	cloud->setPassword("ABCDE");
	TEST(cloud->password(), QStringLiteral("ABCDE"));
	cloud->setPassword("ABCABC");
	TEST(cloud->password(), QStringLiteral("ABCABC"));

	cloud->setSavePasswordLocal(true);
	TEST(cloud->savePasswordLocal(), true);
	cloud->setSavePasswordLocal(false);
	TEST(cloud->savePasswordLocal(), false);

	// Why this is short and not bool?
	cloud->setSaveUserIdLocal(1);
	TEST(cloud->saveUserIdLocal(), (short)1);
	cloud->setSaveUserIdLocal(0);
	TEST(cloud->saveUserIdLocal(), (short)0);

	cloud->setUserId("Tomaz");
	TEST(cloud->userId(), QStringLiteral("Tomaz"));
	cloud->setUserId("Zamot");
	TEST(cloud->userId(), QStringLiteral("Zamot"));

	cloud->setVerificationStatus(0);
	TEST(cloud->verificationStatus(), (short)0);
	cloud->setVerificationStatus(1);
	TEST(cloud->verificationStatus(), (short)1);

	auto tecDetails = pref->techDetails;
	tecDetails->setModp02(0.2);
	TEST(tecDetails->modp02(), 0.2);
	tecDetails->setModp02(1.0);
	TEST(tecDetails->modp02(), 1.0);

	tecDetails->setGflow(2);
	TEST(tecDetails->gflow(), 2);
	tecDetails->setGflow(3);
	TEST(tecDetails->gflow(), 3);

	tecDetails->setGfhigh(4);
	TEST(tecDetails->gfhigh(), 4);
	tecDetails->setGfhigh(5);
	TEST(tecDetails->gfhigh(), 5);

	tecDetails->setVpmbConservatism(5);
	TEST(tecDetails->vpmbConservatism(), (short)5);
	tecDetails->setVpmbConservatism(6);
	TEST(tecDetails->vpmbConservatism(), (short)6);

	tecDetails->setEad(true);
	TEST(tecDetails->ead(), true);
	tecDetails->setMod(true);
	TEST(tecDetails->mod(), true);
	tecDetails->setDCceiling(true);
	TEST(tecDetails->dcceiling(), true);
	tecDetails->setRedceiling(true);
	TEST(tecDetails->redceiling(), true);
	tecDetails->setCalcceiling(true);
	TEST(tecDetails->calcceiling(), true);
	tecDetails->setCalcceiling3m(true);
	TEST(tecDetails->calcceiling3m(), true);
	tecDetails->setCalcalltissues(true);
	TEST(tecDetails->calcalltissues(), true);
	tecDetails->setCalcndltts(true);
	TEST(tecDetails->calcndltts(), true);
	tecDetails->setBuehlmann(true);
	TEST(tecDetails->buehlmann(), true);
	tecDetails->setHRgraph(true);
	TEST(tecDetails->hrgraph(), true);
	tecDetails->setTankBar(true);
	TEST(tecDetails->tankBar(), true);
	tecDetails->setPercentageGraph(true);
	TEST(tecDetails->percentageGraph(), true);
	tecDetails->setRulerGraph(true);
	TEST(tecDetails->rulerGraph(), true);
	tecDetails->setShowCCRSetpoint(true);
	TEST(tecDetails->showCCRSetpoint(), true);
	tecDetails->setShowCCRSensors(true);
	TEST(tecDetails->showCCRSensors(), true);
	tecDetails->setZoomedPlot(true);
	TEST(tecDetails->zoomedPlot(), true);
	tecDetails->setShowSac(true);
	TEST(tecDetails->showSac(), true);
	tecDetails->setGfLowAtMaxDepth(true);
	TEST(tecDetails->gfLowAtMaxDepth(), true);
	tecDetails->setDisplayUnusedTanks(true);
	TEST(tecDetails->displayUnusedTanks(), true);
	tecDetails->setShowAverageDepth(true);
	TEST(tecDetails->showAverageDepth(), true);
	tecDetails->setShowPicturesInProfile(true);
	TEST(tecDetails->showPicturesInProfile(), true);

	tecDetails->setEad(false);
	TEST(tecDetails->ead(), false);
	tecDetails->setMod(false);
	TEST(tecDetails->mod(), false);
	tecDetails->setDCceiling(false);
	TEST(tecDetails->dcceiling(), false);
	tecDetails->setRedceiling(false);
	TEST(tecDetails->redceiling(), false);
	tecDetails->setCalcceiling(false);
	TEST(tecDetails->calcceiling(), false);
	tecDetails->setCalcceiling3m(false);
	TEST(tecDetails->calcceiling3m(), false);
	tecDetails->setCalcalltissues(false);
	TEST(tecDetails->calcalltissues(), false);
	tecDetails->setCalcndltts(false);
	TEST(tecDetails->calcndltts(), false);
	tecDetails->setBuehlmann(false);
	TEST(tecDetails->buehlmann(), false);
	tecDetails->setHRgraph(false);
	TEST(tecDetails->hrgraph(), false);
	tecDetails->setTankBar(false);
	TEST(tecDetails->tankBar(), false);
	tecDetails->setPercentageGraph(false);
	TEST(tecDetails->percentageGraph(), false);
	tecDetails->setRulerGraph(false);
	TEST(tecDetails->rulerGraph(), false);
	tecDetails->setShowCCRSetpoint(false);
	TEST(tecDetails->showCCRSetpoint(), false);
	tecDetails->setShowCCRSensors(false);
	TEST(tecDetails->showCCRSensors(), false);
	tecDetails->setZoomedPlot(false);
	TEST(tecDetails->zoomedPlot(), false);
	tecDetails->setShowSac(false);
	TEST(tecDetails->showSac(), false);
	tecDetails->setGfLowAtMaxDepth(false);
	TEST(tecDetails->gfLowAtMaxDepth(), false);
	tecDetails->setDisplayUnusedTanks(false);
	TEST(tecDetails->displayUnusedTanks(), false);
	tecDetails->setShowAverageDepth(false);
	TEST(tecDetails->showAverageDepth(), false);
	tecDetails->setShowPicturesInProfile(false);
	TEST(tecDetails->showPicturesInProfile(), false);

	auto pp = pref->pp_gas;
	pp->setShowPn2(false);
	pp->setShowPhe(false);
	pp->setShowPo2(false);
	pp->setPo2Threshold(1.0);
	pp->setPn2Threshold(2.0);
	pp->setPheThreshold(3.0);

	TEST(pp->showPn2(), (short) false);
	TEST(pp->showPhe(), (short) false);
	TEST(pp->showPo2(), (short) false);
	TEST(pp->pn2Threshold(), 2.0);
	TEST(pp->pheThreshold(), 3.0);
	TEST(pp->po2Threshold(), 1.0);

	pp->setShowPn2(true);
	pp->setShowPhe(true);
	pp->setShowPo2(true);
	pp->setPo2Threshold(4.0);
	pp->setPn2Threshold(5.0);
	pp->setPheThreshold(6.0);

	TEST(pp->showPn2(), (short) true);
	TEST(pp->showPhe(), (short) true);
	TEST(pp->showPo2(), (short) true);
	TEST(pp->pn2Threshold(), 5.0);
	TEST(pp->pheThreshold(), 6.0);
	TEST(pp->po2Threshold(), 4.0);

	auto fb = pref->facebook;
	fb->setAccessToken("rand-access-token");
	fb->setUserId("tomaz-user-id");
	fb->setAlbumId("album-id");

	TEST(fb->accessToken(),QStringLiteral("rand-access-token"));
	TEST(fb->userId(),     QStringLiteral("tomaz-user-id"));
	TEST(fb->albumId(),    QStringLiteral("album-id"));

	fb->setAccessToken("rand-access-token-2");
	fb->setUserId("tomaz-user-id-2");
	fb->setAlbumId("album-id-2");

	TEST(fb->accessToken(),QStringLiteral("rand-access-token-2"));
	TEST(fb->userId(),     QStringLiteral("tomaz-user-id-2"));
	TEST(fb->albumId(),    QStringLiteral("album-id-2"));

	auto geo = pref->geocoding;
	geo->setEnableGeocoding(true);
	geo->setParseDiveWithoutGps(true);
	geo->setTagExistingDives(true);

	TEST(geo->enableGeocoding(),true);
	TEST(geo->parseDiveWithoutGps(),true);
	TEST(geo->tagExistingDives(),true);

	geo->setFirstTaxonomyCategory(TC_NONE);
	geo->setSecondTaxonomyCategory(TC_OCEAN);
	geo->setThirdTaxonomyCategory(TC_COUNTRY);

	TEST(geo->firstTaxonomyCategory(), TC_NONE);
	TEST(geo->secondTaxonomyCategory(), TC_OCEAN);
	TEST(geo->thirdTaxonomyCategory(), TC_COUNTRY);

	geo->setEnableGeocoding(false);
	geo->setParseDiveWithoutGps(false);
	geo->setTagExistingDives(false);

	TEST(geo->enableGeocoding(),false);
	TEST(geo->parseDiveWithoutGps(),false);
	TEST(geo->tagExistingDives(),false);

	geo->setFirstTaxonomyCategory(TC_OCEAN);
	geo->setSecondTaxonomyCategory(TC_COUNTRY);
	geo->setThirdTaxonomyCategory(TC_NONE);

	TEST(geo->firstTaxonomyCategory(), TC_OCEAN);
	TEST(geo->secondTaxonomyCategory(), TC_COUNTRY);
	TEST(geo->thirdTaxonomyCategory(), TC_NONE);

	auto proxy = pref->proxy;
	proxy->setType(2);
	proxy->setPort(80);
	proxy->setAuth(true);
	proxy->setHost("localhost");
	proxy->setUser("unknown");
	proxy->setPass("secret");

	TEST(proxy->type(),2);
	TEST(proxy->port(),80);
	TEST(proxy->auth(),true);
	TEST(proxy->host(),QStringLiteral("localhost"));
	TEST(proxy->user(),QStringLiteral("unknown"));
	TEST(proxy->pass(),QStringLiteral("secret"));

	proxy->setType(3);
	proxy->setPort(8080);
	proxy->setAuth(false);
	proxy->setHost("127.0.0.1");
	proxy->setUser("unknown_1");
	proxy->setPass("secret_1");

	TEST(proxy->type(),3);
	TEST(proxy->port(),8080);
	TEST(proxy->auth(),false);
	TEST(proxy->host(),QStringLiteral("127.0.0.1"));
	TEST(proxy->user(),QStringLiteral("unknown_1"));
	TEST(proxy->pass(),QStringLiteral("secret_1"));

	auto planner = pref->planner_settings;
	planner->setLastStop(true);
	planner->setVerbatimPlan(true);
	planner->setDisplayRuntime(true);
	planner->setDisplayDuration(true);
	planner->setDisplayTransitions(true);
	planner->setDoo2breaks(true);
	planner->setDropStoneMode(true);
	planner->setSafetyStop(true);
	planner->setSwitchAtRequiredStop(true);

	planner->setAscrate75(1);
	planner->setAscrate50(2);
	planner->setAscratestops(3);
	planner->setAscratelast6m(4);
	planner->setDescrate(5);
	planner->setBottompo2(6);
	planner->setDecopo2(7);
	planner->setBestmixend(8);
	planner->setReserveGas(9);
	planner->setMinSwitchDuration(10);
	planner->setBottomSac(11);
	planner->setDecoSac(12);

	planner->setDecoMode(BUEHLMANN);

	TEST(planner->lastStop(),true);
	TEST(planner->verbatimPlan(),true);
	TEST(planner->displayRuntime(),true);
	TEST(planner->displayDuration(),true);
	TEST(planner->displayTransitions(),true);
	TEST(planner->doo2breaks(),true);
	TEST(planner->dropStoneMode(),true);
	TEST(planner->safetyStop(),true);
	TEST(planner->switchAtRequiredStop(),true);

	TEST(planner->ascrate75(),1);
	TEST(planner->ascrate50(),2);
	TEST(planner->ascratestops(),3);
	TEST(planner->ascratelast6m(),4);
	TEST(planner->descrate(),5);
	TEST(planner->bottompo2(),6);
	TEST(planner->decopo2(),7);
	TEST(planner->bestmixend(),8);
	TEST(planner->reserveGas(),9);
	TEST(planner->minSwitchDuration(),10);
	TEST(planner->bottomSac(),11);
	TEST(planner->decoSac(),12);

	TEST(planner->decoMode(),BUEHLMANN);

	planner->setLastStop(false);
	planner->setVerbatimPlan(false);
	planner->setDisplayRuntime(false);
	planner->setDisplayDuration(false);
	planner->setDisplayTransitions(false);
	planner->setDoo2breaks(false);
	planner->setDropStoneMode(false);
	planner->setSafetyStop(false);
	planner->setSwitchAtRequiredStop(false);

	planner->setAscrate75(11);
	planner->setAscrate50(12);
	planner->setAscratestops(13);
	planner->setAscratelast6m(14);
	planner->setDescrate(15);
	planner->setBottompo2(16);
	planner->setDecopo2(17);
	planner->setBestmixend(18);
	planner->setReserveGas(19);
	planner->setMinSwitchDuration(110);
	planner->setBottomSac(111);
	planner->setDecoSac(112);

	planner->setDecoMode(RECREATIONAL);

	TEST(planner->lastStop(),false);
	TEST(planner->verbatimPlan(),false);
	TEST(planner->displayRuntime(),false);
	TEST(planner->displayDuration(),false);
	TEST(planner->displayTransitions(),false);
	TEST(planner->doo2breaks(),false);
	TEST(planner->dropStoneMode(),false);
	TEST(planner->safetyStop(),false);
	TEST(planner->switchAtRequiredStop(),false);

	TEST(planner->ascrate75(),11);
	TEST(planner->ascrate50(),12);
	TEST(planner->ascratestops(),13);
	TEST(planner->ascratelast6m(),14);
	TEST(planner->descrate(),15);
	TEST(planner->bottompo2(),16);
	TEST(planner->decopo2(),17);
	TEST(planner->bestmixend(),18);
	TEST(planner->reserveGas(),19);
	TEST(planner->minSwitchDuration(),110);
	TEST(planner->bottomSac(),111);
	TEST(planner->decoSac(),112);

	TEST(planner->decoMode(),RECREATIONAL);

	auto units = pref->unit_settings;
	units->setLength(0);
	units->setPressure(0);
	units->setVolume(0);
	units->setTemperature(0);
	units->setWeight(0);
	units->setVerticalSpeedTime(0);
	units->setUnitSystem(QStringLiteral("metric"));
	units->setCoordinatesTraditional(false);

	TEST(units->length(),0);
	TEST(units->pressure(),0);
	TEST(units->volume(),0);
	TEST(units->temperature(),0);
	TEST(units->weight(),0);
	TEST(units->verticalSpeedTime(),0);
	TEST(units->unitSystem(),QStringLiteral("metric"));
	TEST(units->coordinatesTraditional(),false);

	units->setLength(1);
	units->setPressure(1);
	units->setVolume(1);
	units->setTemperature(1);
	units->setWeight(1);
	units->setVerticalSpeedTime(1);
	units->setUnitSystem(QStringLiteral("fake-metric-system"));
	units->setCoordinatesTraditional(true);

	TEST(units->length(),1);
	TEST(units->pressure(),1);
	TEST(units->volume(),1);
	TEST(units->temperature(),1);
	TEST(units->weight(),1);
	TEST(units->verticalSpeedTime(),1);
	TEST(units->unitSystem(),QStringLiteral("personalized"));
	TEST(units->coordinatesTraditional(),true);

	auto general = pref->general_settings;
	general->setDefaultFilename       ("filename");
	general->setDefaultCylinder       ("cylinder_2");
	//TODOl: Change this to a enum. 	// This is 'undefined', it will need to figure out later between no_file or use_deault file.
	general->setDefaultFileBehavior   (0);
	general->setDefaultSetPoint       (0);
	general->setO2Consumption         (0);
	general->setPscrRatio             (0);
	general->setUseDefaultFile        (true);

	TEST(general->defaultFilename(), QStringLiteral("filename"));
	TEST(general->defaultCylinder(), QStringLiteral("cylinder_2"));
	TEST(general->defaultFileBehavior(), (short) LOCAL_DEFAULT_FILE); // since we have a default file, here it returns
	TEST(general->defaultSetPoint(), 0);
	TEST(general->o2Consumption(), 0);
	TEST(general->pscrRatio(), 0);
	TEST(general->useDefaultFile(), true);

	general->setDefaultFilename       ("no_file_name");
	general->setDefaultCylinder       ("cylinder_1");
	//TODOl: Change this to a enum.
	general->setDefaultFileBehavior   (CLOUD_DEFAULT_FILE);

	general->setDefaultSetPoint       (1);
	general->setO2Consumption         (1);
	general->setPscrRatio             (1);
	general->setUseDefaultFile        (false);

	TEST(general->defaultFilename(), QStringLiteral("no_file_name"));
	TEST(general->defaultCylinder(), QStringLiteral("cylinder_1"));
	TEST(general->defaultFileBehavior(), (short) CLOUD_DEFAULT_FILE);
	TEST(general->defaultSetPoint(), 1);
	TEST(general->o2Consumption(), 1);
	TEST(general->pscrRatio(), 1);
	TEST(general->useDefaultFile(), false);

	auto display = pref->display_settings;
	display->setDivelistFont("comic");
	display->setFontSize(10.0);
	display->setDisplayInvalidDives(true);

	TEST(display->divelistFont(),QStringLiteral("comic"));
	TEST(display->fontSize(), 10.0);
	TEST(display->displayInvalidDives(),(short) true); //TODO: this is true / false.

	display->setDivelistFont("helvetica");
	display->setFontSize(14.0);
	display->setDisplayInvalidDives(false);

	TEST(display->divelistFont(),QStringLiteral("helvetica"));
	TEST(display->fontSize(), 14.0);
	TEST(display->displayInvalidDives(),(short) false);

	auto language = pref->language_settings;
	language->setLangLocale         ("en_US");
	language->setLanguage           ("en");
	language->setTimeFormat         ("hh:mm");
	language->setDateFormat         ("dd/mm/yy");
	language->setDateFormatShort    ("dd/mm");
	language->setTimeFormatOverride (false);
	language->setDateFormatOverride (false);
	language->setUseSystemLanguage  (false);

	TEST(language->langLocale(), QStringLiteral("en_US"));
	TEST(language->language(), QStringLiteral("en"));
	TEST(language->timeFormat(), QStringLiteral("hh:mm"));
	TEST(language->dateFormat(), QStringLiteral("dd/mm/yy"));
	TEST(language->dateFormatShort(), QStringLiteral("dd/mm"));
	TEST(language->timeFormatOverride(), false);
	TEST(language->dateFormatOverride(), false);
	TEST(language->useSystemLanguage(), false);

	language->setLangLocale         ("en_EN");
	language->setLanguage           ("br");
	language->setTimeFormat         ("mm:hh");
	language->setDateFormat         ("yy/mm/dd");
	language->setDateFormatShort    ("dd/yy");
	language->setTimeFormatOverride (true);
	language->setDateFormatOverride (true);
	language->setUseSystemLanguage  (true);

	TEST(language->langLocale(), QStringLiteral("en_EN"));
	TEST(language->language(), QStringLiteral("br"));
	TEST(language->timeFormat(), QStringLiteral("mm:hh"));
	TEST(language->dateFormat(), QStringLiteral("yy/mm/dd"));
	TEST(language->dateFormatShort(), QStringLiteral("dd/yy"));
	TEST(language->timeFormatOverride(),true);
	TEST(language->dateFormatOverride(),true);
	TEST(language->useSystemLanguage(), true);

	pref->animation_settings->setAnimationSpeed(20);
	TEST(pref->animation_settings->animationSpeed(), 20);
	pref->animation_settings->setAnimationSpeed(30);
	TEST(pref->animation_settings->animationSpeed(), 30);

	auto location = pref->location_settings;
	location->setTimeThreshold(10);
	location->setDistanceThreshold(20);

	TEST(location->timeThreshold(), 10);
	TEST(location->distanceThreshold(), 20);

	location->setTimeThreshold(30);
	location->setDistanceThreshold(40);

	TEST(location->timeThreshold(), 30);
	TEST(location->distanceThreshold(), 40);

	auto update = pref->update_manager_settings;
	QDate date = QDate::currentDate();

	update->setDontCheckForUpdates(true);
	update->setLastVersionUsed("tomaz-1");
	update->setNextCheck(date);

	TEST(update->dontCheckForUpdates(), true);
	TEST(update->lastVersionUsed(), QStringLiteral("tomaz-1"));
	TEST(update->nextCheck(), date);

	date.addDays(3);
	update->setDontCheckForUpdates(false);
	update->setLastVersionUsed("tomaz-2");
	update->setNextCheck(date);

	TEST(update->dontCheckForUpdates(), false);
	TEST(update->lastVersionUsed(), QStringLiteral("tomaz-2"));
	TEST(update->nextCheck(), date);

	auto dc = pref->dive_computer_settings;
	dc->setDevice("TomazComputer");
	TEST(dc->dc_device(), QStringLiteral("TomazComputer"));
	dc->setDevice("Deepwater");
	TEST(dc->dc_device(), QStringLiteral("Deepwater"));

	dc->setDownloadMode(0);
	TEST(dc->downloadMode(), 0);
	dc->setDownloadMode(1);
	TEST(dc->downloadMode(), 1);

	dc->setProduct("Thingy1");
	TEST(dc->dc_product(), QStringLiteral("Thingy1"));
	dc->setProduct("Thingy2");
	TEST(dc->dc_product(), QStringLiteral("Thingy2"));

	dc->setVendor("Sharewater");
	TEST(dc->dc_vendor(), QStringLiteral("Sharewater"));
	dc->setVendor("OSTS");
	TEST(dc->dc_vendor(), QStringLiteral("OSTS"));
}
コード例 #12
0
ファイル: gtpwrapper.cpp プロジェクト: epichub/neatzsche
//returns true for limit pass, pass or put, false for movement or 
// .. inp: a,b,c,d,e,f,g :
// a: forward, b: back, c: left, d: right,
// e: put, f: pass, g: pause
bool GTPWrapper::doThis(bool first, vector<double> inp)
{
  //  cout << "dothis inp: " << printvector(inp);
  //check for limits if within inc counter..
  if(first){
    if(fcount>=thinksteps){
      setPass(first);
      return true;
    }else 
      fcount++;
  }
  if(!first){
    if(scount>=thinksteps){
      setPass(first);
      return true;
    }else
      scount++;
  }

  //needs conflict resolution
  //first check for movement(default in kens code)
  //default in con  flicts; back & forward => forward, left & righ ->left
  bool forward,back,west,east;
  forward=back=west=east=false;
  bool moving = false;
  int *heading = getHeading(first);
  if(inp.at(0)>0.5){//forward..
    moving = true;
    if(*heading == 0)
      forward = true;
    else if(*heading == 1)
      east = true;
    else if(*heading == 2)
      back = true;
    else if(*heading == 3)
      west = true;
  }
  bool turned = false;
  if(inp.at(1)>0.5){//turn left
    turnleft(first);
    turned = true;
  }else if(inp.at(2)>0.5){//right..
    turnright(first);
    turned = true;
  }
  
  if(!moving&&!turned){
    int ind = 5;
    int n = 5;
//     if(headingsupport)
//       n++;
    double max=0.5;
    for(int i=3;i<n;i++){
      if(inp.at(i)>max){
	ind = i;
	max = inp.at(i);
      }
    }
    if(ind==5){//default
      //      cout << "doing nothing.." << endl;
      return false;
    }
    if(ind==3){
//       if(!justput)
      //cout << "putting " << getColoredCoord(first) << endl; 

//       if(justput)
// 	secondput = true;
//       justput = true;
//       if(justmoved && secondput)
// 	cout << "!!!! second put " << getColoredCoord(first) << endl;
      if(put(first)){//regardless of illegal move?? heh
	moves++;
// 	if(moves>4)
// 	cout<<"four moves!!!: " << endl << getLocalBoardAscii();
	unsetPass(first);
	unsetCount(first);
      }else{
	setPass(first);
	unsetCount(first);
      }
      return true;
    }else if(ind==4){
      //      cout << "passing" << endl;
      setPass(first);
      unsetCount(first);
      return true;
    }
//     else if(headingsupport&&ind==7){
//       //      cout << "turning around!!" << endl;
      
//       unsetPass(first);
//       return false;
//     }
  }else{
//     if(!justmoved)
    //cout << "fpass:"******" spass:"******" moving(fc:"<<fcount<<" sc:"<<scount<<")" << "forward: " << forward << " back: "<<back<<" west: "<<west<<"  east:" << east<< endl;
    unsetPass(first);
//     justmoved = true;
    //    unsetCount(first);
    if(forward)
      up(first);
    if(back)
      down(first);
    if(west)
      left(first);
    if(east)
      right(first);
    return false;
  }
  return true;
}
コード例 #13
0
void Map_v2::loadMapObjects(char *avjFile) {
	int i;
	int j;
	int k;
	uint8 wayPointsCount;
	int16 var;
	int16 id;
	int16 mapHeight;
	int16 mapWidth;
	int16 tmp;
	int16 numData;
	int16 statesCount;
	int16 state;
	char *variables;
	char *extData;
	uint32 dataPos1;
	uint32 dataPos2;
	int8 statesMask[102];
	Mult::Mult_GobState *statesPtr;

	var = _vm->_parse->parseVarIndex();
	variables = _vm->_global->_inter_variables + var;

	id = _vm->_inter->load16();

	if (id == -1) {
		_passMap = (int8 *)(_vm->_global->_inter_variables + var);
		return;
	}

	extData = _vm->_game->loadExtData(id, 0, 0);
	Common::MemoryReadStream mapData((byte *) extData, 4294967295U);

	if (mapData.readByte() == 3) {
		_screenWidth = 640;
		_passWidth = 65;
	} else {
		_screenWidth = 320;
		_passWidth = 40;
	}
	_wayPointsCount = mapData.readByte();
	_tilesWidth = mapData.readSint16LE();
	_tilesHeight = mapData.readSint16LE();

	_bigTiles = !(_tilesHeight & 0xFF00);
	_tilesHeight &= 0xFF;

	_mapWidth = _screenWidth / _tilesWidth;
	_mapHeight = 200 / _tilesHeight;

	dataPos2 = mapData.pos();
	mapData.seek(_mapWidth * _mapHeight, SEEK_CUR);

	if (*extData == 1)
		wayPointsCount = _wayPointsCount = 40;
	else
		wayPointsCount = _wayPointsCount == 0 ? 1 : _wayPointsCount;

	_wayPoints = new Point[wayPointsCount];
	for (i = 0; i < _wayPointsCount; i++) {
		_wayPoints[i].x = mapData.readSByte();
		_wayPoints[i].y = mapData.readSByte();
		_wayPoints[i].field_2 = mapData.readSByte();
	}

	// In the original asm, this writes byte-wise into the variables-array
	dataPos1 = mapData.pos();
	if (variables != _vm->_global->_inter_variables) {
		_passMap = (int8 *) variables;
		mapHeight = 200 / _tilesHeight;
		mapWidth = _screenWidth / _tilesWidth;
		for (i = 0; i < mapHeight; i++) {
			mapData.seek(dataPos2 + (mapWidth * i));
			for (j = 0; j < mapWidth; j++) {
				setPass(j, i, mapData.readSByte());
			}
		}
	}
	mapData.seek(dataPos1);

	tmp = mapData.readSint16LE();
	mapData.seek(tmp * 14, SEEK_CUR);
	tmp = mapData.readSint16LE();
	mapData.seek(tmp * 14 + 28, SEEK_CUR);
	tmp = mapData.readSint16LE();
	mapData.seek(tmp * 14, SEEK_CUR);

	_vm->_goblin->_gobsCount = tmp;
	for (i = 0; i < _vm->_goblin->_gobsCount; i++) {
		memset(statesMask, -1, 101);
		_vm->_mult->_objects[i].goblinStates = new Mult::Mult_GobState*[101];
		memset(_vm->_mult->_objects[i].goblinStates, 0, 101 * sizeof(Mult::Mult_GobState *));
		mapData.read(statesMask, 100);
		dataPos1 = mapData.pos();
		statesCount = 0;
		for (j = 0; j < 100; j++) {
			if (statesMask[j] != -1) {
				statesCount++;
				mapData.seek(4, SEEK_CUR);
				numData = mapData.readByte();
				statesCount += numData;
				mapData.seek(numData * 9, SEEK_CUR);
			}
		}
		statesPtr = new Mult::Mult_GobState[statesCount];
		_vm->_mult->_objects[i].goblinStates[0] = statesPtr;
		mapData.seek(dataPos1);
		for (j = 0; j < 100; j++) {
			state = statesMask[j];
			if (state != -1) {
				_vm->_mult->_objects[i].goblinStates[state] = statesPtr++;
				_vm->_mult->_objects[i].goblinStates[state][0].animation = mapData.readSint16LE();
				_vm->_mult->_objects[i].goblinStates[state][0].layer = mapData.readSint16LE();
				numData = mapData.readByte();
				_vm->_mult->_objects[i].goblinStates[state][0].dataCount = numData;
				for (k = 1; k <= numData; k++) {
					mapData.seek(1, SEEK_CUR);
					_vm->_mult->_objects[i].goblinStates[state][k].sndItem = mapData.readSByte();
					mapData.seek(1, SEEK_CUR);
					_vm->_mult->_objects[i].goblinStates[state][k].sndFrame = mapData.readByte();
					mapData.seek(1, SEEK_CUR);
					_vm->_mult->_objects[i].goblinStates[state][k].freq = mapData.readSint16LE();
					_vm->_mult->_objects[i].goblinStates[state][k].repCount = mapData.readSByte();
					_vm->_mult->_objects[i].goblinStates[state][k].speaker = mapData.readByte();
					statesPtr++;
				}
			}
		}
	}

	_vm->_goblin->_soundSlotsCount = _vm->_inter->load16();
	for (i = 0; i < _vm->_goblin->_soundSlotsCount; i++)
		_vm->_goblin->_soundSlots[i] = _vm->_inter->loadSound(1);
}
コード例 #14
0
ファイル: PlayerSetupDialog.cpp プロジェクト: dtbinh/dviz
void PlayerSetupDialog::setCurrentPlayer(PlayerConnection* con)
{
    if(con == m_con)
        return;

    m_stickyConnectionMessage = false;
    if(m_con)
    {
        disconnect(ui->playerName, 0, m_con, 0);
        disconnect(ui->playerHost, 0, m_con, 0);
        disconnect(ui->playerUser, 0, m_con, 0);
        disconnect(ui->playerPass, 0, m_con, 0);
        disconnect(m_con, 0, this, 0);
    }

    if(m_subviewModel)
    {
        delete m_subviewModel;
        m_subviewModel = 0;
    }

    m_con = con;

    if(!con)
    {
        ui->boxConnection->setEnabled(false);
        ui->boxOutput->setEnabled(false);
        ui->boxSubviewOpts->setEnabled(false);
        ui->boxSubviews->setEnabled(false);
        ui->boxKeystone->setEnabled(true);
        return;
    }

    if(con->isConnected())
        conConnected();
    else
        conDisconnected();

    // Set up the UI with values from the player before connecting slots so we dont needlessly update the object
    ui->playerName->setText(con->name());
    ui->playerHost->setText(con->host());
    ui->playerUser->setText(con->user());
    ui->playerPass->setText(con->pass());
    ui->autoconnectBox->setChecked(con->autoconnect());
    ui->optIgnoreAR->setChecked(con->aspectRatioMode() == Qt::IgnoreAspectRatio);

    QRect screen = con->screenRect();
    if(screen.isEmpty())
        con->setScreenRect(screen = QRect(0,0,1024,768));
    ui->outputX->setValue(screen.x());
    ui->outputY->setValue(screen.y());
    ui->outputWidth->setValue(screen.width());
    ui->outputHeight->setValue(screen.height());

    QRect view = con->viewportRect();
    if(view.isEmpty())
        con->setViewportRect(view = QRect(0,0,1000,750));
    ui->viewportX->setValue(view.x());
    ui->viewportY->setValue(view.y());
    ui->viewportWidth->setValue(view.width());
    ui->viewportHeight->setValue(view.height());

    connect(ui->playerName, SIGNAL(textChanged(QString)), con, SLOT(setName(QString)));
    connect(ui->playerHost, SIGNAL(textChanged(QString)), con, SLOT(setHost(QString)));
    connect(ui->playerUser, SIGNAL(textChanged(QString)), con, SLOT(setUser(QString)));
    connect(ui->playerPass, SIGNAL(textChanged(QString)), con, SLOT(setPass(QString)));

    connect(con, SIGNAL(connected()), this, SLOT(conConnected()));
    connect(con, SIGNAL(disconnected()), this, SLOT(conDisconnected()));
    connect(con, SIGNAL(loginSuccess()), this, SLOT(conLoginSuccess()));
    connect(con, SIGNAL(loginFailure()), this, SLOT(conLoginFailure()));
    connect(con, SIGNAL(playerError(QString)), this, SLOT(conPlayerError(QString)));
    connect(con, SIGNAL(pingResponseReceived(QString)), this, SLOT(conPingResponseReceived(QString)));
    connect(con, SIGNAL(testStarted()), this, SLOT(conTestStarted()));
    connect(con, SIGNAL(testEnded()), this, SLOT(conTestEnded()));
    connect(con, SIGNAL(testResults(bool)), this, SLOT(conTestResults(bool)));

    ui->boxConnection->setEnabled(true);
    ui->boxOutput->setEnabled(true);

    m_subviewModel = new PlayerSubviewsModel(con);

    ui->subviewListview->setModel(m_subviewModel);
    ui->subviewListview->setCurrentIndex(m_subviewModel->index(0,0));

    GLWidgetSubview *sub = !con->subviews().isEmpty() ? con->subviews().at(0) : 0;
    if(!sub)
        con->addSubview(sub = new GLWidgetSubview());
    if(sub->title().isEmpty())
        sub->setTitle("Default Subview");

    setCurrentSubview(sub);
}