コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: uh-adapsys/accompany
void MainWindow::on_clearAPPushButton_clicked()
{
    if (QMessageBox::No == QMessageBox::question(this, tr("Action Possibility Creator"),
                                    tr("Do you really want to clear Action Possibility Thresholds?"),
                                    QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
            return;

    QSqlQuery Goalquery(db);

    Goalquery.clear();

    db.database().transaction();

      Goalquery.prepare("UPDATE ActionPossibilities SET likelihood = 0");
      if (!Goalquery.exec())
      {
          QMessageBox msgBox;
          msgBox.setIcon(QMessageBox::Critical);

          msgBox.setText("Cant update action possibilities table!");
          msgBox.exec();
          closeDownRequest = true;
          return;
      }

    db.database().commit();

    fillDisplayArea();
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: uh-adapsys/accompany
void MainWindow::on_APDeletePushButton_clicked()
{
    int ret = QMessageBox::warning(this, tr("Action Possibility Creator"),
                                   tr("Do you really want to delete this Action Possibility?"),
                                   QMessageBox::Cancel | QMessageBox::Yes);

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

    QSqlQuery query;
    query = "DELETE FROM ActionPossibilities Where apId = " + ui->tableWidget->item(deleteCandidate,0)->text();
    query.exec();
    fillDisplayArea();
}
コード例 #3
0
ファイル: mainwindow.cpp プロジェクト: ai-haibara/accompany
void MainWindow::on_comboBox_currentIndexChanged(QString seq)
{
    fillDisplayArea(seq);
}
コード例 #4
0
ファイル: mainwindow.cpp プロジェクト: ai-haibara/accompany
void MainWindow::setup()
{

    bool ok;
    QString host, user, pw, dBase;

    QFile file("../UHCore/Core/config.py");

    if (!file.exists())
    {
        qDebug()<<"No config.py found!!";
    }

    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        closeDownRequest = true;
        return;
    }

    QTextStream in(&file);
    while (!in.atEnd())
    {
        QString line = in.readLine();

        if (line.contains("mysql_log_user"))
        {
            user = line.section("'",3,3);
        }
        if (line.contains("mysql_log_password"))
        {
            pw = line.section("'",3,3);
        }
        if (line.contains("mysql_log_server"))
        {
            host = line.section("'",3,3);
        }
        if (line.contains("mysql_log_db"))
        {
            dBase = line.section("'",3,3);
        }
    }

    user = QInputDialog::getText ( this, "Accompany DB", "User:"******"Accompany DB", "Password:"******"Accompany DB", "Host:",QLineEdit::Normal,
                                   host, &ok);
    if (!ok)
    {
        closeDownRequest = true;
        return;
    };

    dBase = QInputDialog::getText ( this, "Accompany DB", "Database:",QLineEdit::Normal,
                                    dBase, &ok);
    if (!ok)
    {
        closeDownRequest = true;
        return;
    };


    ui->locnLabel->setText(lv + ":" + user + ":" + host + ":" + dBase);


    db = QSqlDatabase::addDatabase("QMYSQL");

    db.setHostName(host);
    db.setDatabaseName(dBase);
    db.setUserName(user);
    db.setPassword(pw);

    dbOpen = db.open();

    if (!dbOpen)
    {

        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);

        msgBox.setText("Database error - login problem - see console log!");
        msgBox.exec();

        qCritical("Cannot open database: %s (%s)",
                  db.lastError().text().toLatin1().data(),
                  qt_error_string().toLocal8Bit().data());

        closeDownRequest = true;

        return;
    }
    else
    {
        qDebug() << "Database Opened";
    }

    // get experimental location


    QSqlQuery query("SELECT ExperimentalLocationId  FROM SessionControl WHERE SessionId = 1 LIMIT 1");

    if (query.next())
    {
        experimentLocation = query.value(0).toInt();
    }
    else
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);

        msgBox.setText("Can find session control table!");
        msgBox.exec();
        closeDownRequest = true;
        return;
    }


    fillScenarioCombo();
    fillSequenceCombo();

    QString top;
    top = ui->comboBox->currentText();

    fillDisplayArea(top);

}
コード例 #5
0
ファイル: mainwindow.cpp プロジェクト: uh-adapsys/accompany
void MainWindow::on_APRefreshPushButton_clicked()
{
        fillDisplayArea();
}
コード例 #6
0
ファイル: mainwindow.cpp プロジェクト: uh-adapsys/accompany
void MainWindow::setup()
{

    bool ok;
    QString host, user, pw, dBase;

    QFile file("../UHCore/Core/config/database.yaml");

    if (!file.exists())
    {
       qDebug()<<"No database config found!!";
    }

    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        closeDownRequest = true;
        return;
    }

    QTextStream in(&file);
    while (!in.atEnd())
    {
       QString line = in.readLine();

       if (line.startsWith("mysql_log_user"))
       {
          user = line.section(":",1,1).trimmed();
       }
       if (line.startsWith("mysql_log_password"))
       {
           pw = line.section(":",1,1).trimmed();
       }
       if (line.startsWith("mysql_log_server"))
       {
          host = line.section(":",1,1).trimmed();
       }
       if (line.startsWith("mysql_log_db"))
       {
          dBase = line.section(":",1,1).trimmed();
       }
    }

    user = QInputDialog::getText ( this, "Accompany DB", "User:"******"Accompany DB", "Password:"******"Accompany DB", "Host:",QLineEdit::Normal,
                                     host, &ok);
    if (!ok)
    {
      closeDownRequest = true;
      return;
    };

    dBase = QInputDialog::getText ( this, "Accompany DB", "Database:",QLineEdit::Normal,
                                     dBase, &ok);
    if (!ok)
    {
      closeDownRequest = true;
      return;
    };

    ui->userLabel->setText(user + ":" + host);


    db = QSqlDatabase::addDatabase("QMYSQL");

    db.setHostName(host);
    db.setDatabaseName(dBase);
    db.setUserName(user);
    db.setPassword(pw);

    dbOpen = db.open();

    if (!dbOpen)
    {

        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);

        msgBox.setText("Database error - login problem - see console log!");
        msgBox.exec();

        qCritical("Cannot open database: %s (%s)",
                  db.lastError().text().toLatin1().data(),
                  qt_error_string().toLocal8Bit().data());

        closeDownRequest = true;

        return;
    }
    else
    {
        qDebug() << "Database Opened";
    }

    // get experimental location


    QSqlQuery query("SELECT ExperimentalLocationId,Sessionuser  FROM SessionControl WHERE SessionId = 1 LIMIT 1");

    if (query.next())
    {
       experimentLocation = query.value(0).toInt();
       experimentLocationString = query.value(0).toString();
       sessionUser = query.value(1).toString();
    }
    else
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);

        msgBox.setText("Cant find session control table!");
        msgBox.exec();
        closeDownRequest = true;
        return;
    }

    // get language

    query = "SELECT languageId FROM Users where userId = " + sessionUser + " LIMIT 1";

    if (query.next())
    {
       languageId = query.value(0).toString();
    }
    else
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);

        msgBox.setText("Cant find users table!");
        msgBox.exec();
        closeDownRequest = true;
        return;
    }

    fillAPTextCombo();
    fillAPPredicates();
    fillDisplayArea();

 }
コード例 #7
0
ファイル: mainwindow.cpp プロジェクト: uh-adapsys/accompany
void MainWindow::on_APCreatePushButton_clicked()
{
    QSqlQuery query;

    query.prepare("SELECT MAX(apId) FROM ActionPossibilities");

    if (!query.exec())
    {
        qDebug() << query.lastQuery();

        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);

        msgBox.setText("Can't select from ActionPossibilities table?");
        msgBox.exec();

        qCritical("Cannot add/update: %s (%s)",
                  db.lastError().text().toLatin1().data(),
                  qt_error_string().toLocal8Bit().data());
        return;
    }

    int sId;

    while(query.next())
    {
          sId = query.value(0).toInt() + 1;
    }

    query.prepare("INSERT INTO ActionPossibilities VALUES (:apId, :apText, 1, :locn, :apPhrase, null, 0,:pred,100,100)");


    query.bindValue(":apId",sId);
    query.bindValue(":apText",ui->APTextComboBox->currentText().section("::",1,1));
    query.bindValue(":apPhrase",ui->APPhraseComboBox->currentText().section("::",1,1));
    query.bindValue(":pred",ui->APPredComboBox->currentText().section("::",1,1));
    query.bindValue(":locn",experimentLocationString);

  //  qDebug() << sId;
  //  qDebug() << ui->APTextComboBox->currentText().section("::",1,1);
  //  qDebug() << ui->APPhraseComboBox->currentText().section("::",1,1);
  //  qDebug() << ui->APPredComboBox->currentText().section("::",1,1);

  //  qDebug()<<query.executedQuery();

    if (!query.exec())
    {

        qDebug() << query.lastQuery();

        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);

        msgBox.setText("Can't add to ActionPossibilities table - duplicate?");
        msgBox.exec();

        qCritical("Cannot add/update: %s (%s)",
                  db.lastError().text().toLatin1().data(),
                  qt_error_string().toLocal8Bit().data());

        qDebug()<<query.lastError();
        qDebug()<<query.executedQuery();

        return;
    }

    QString sIdStg;
    sIdStg.setNum(sId);
    QString msg;
    msg = "Action Possibility " + sIdStg + " Created!";
    const char* test = msg.toAscii().data();
    QMessageBox::question(this, tr("Action Possibility Creator"),
                          tr(test), QMessageBox::Ok,QMessageBox::Ok);

    fillDisplayArea();
}
コード例 #8
0
ファイル: mainwindow.cpp プロジェクト: ipa-rmb/accompany
void MainWindow::setup()
{

    bool ok;
    QString host, user, pw, dBase;

    user = QInputDialog::getText ( this, "Accompany DB", "User:"******"", &ok);
    if (!ok)
    {
       closeDownRequest = true;
       return;
    }


    pw = QInputDialog::getText ( this, "Accompany DB", "Password:"******"", &ok);
    if (!ok)
    {
       closeDownRequest = true;
       return;
    }


    host = QInputDialog::getText ( this, "Accompany DB", "Host:",QLineEdit::Normal,
                                   "", &ok);
    if (!ok)
    {
       closeDownRequest = true;
       return;
    };

    dBase = QInputDialog::getText ( this, "Accompany DB", "Database:",QLineEdit::Normal,
                                   "", &ok);
    if (!ok)
    {
       closeDownRequest = true;
       return;
    };

    ui->locnLabel->setText(lv);

    if (lv=="ZUYD")
    {
       if (host=="") host = "accompany1";
       if (user=="") user = "******";
       if (pw=="") pw = "accompany";

    }
    else
    {
        if (host=="") host = "localhost";
        if (user=="") user = "******";
        if (pw=="") pw = "waterloo";
    }

    if (dBase=="")  dBase = "Accompany";


    ui->userLabel->setText(user + ":" + host);


    db = QSqlDatabase::addDatabase("QMYSQL");

    db.setHostName(host);
    db.setDatabaseName(dBase);
    db.setUserName(user);
    db.setPassword(pw);

    dbOpen = db.open();

    if (!dbOpen)
    {

        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);

        msgBox.setText("Database error - login problem - see console log!");
        msgBox.exec();

        qCritical("Cannot open database: %s (%s)",
                  db.lastError().text().toLatin1().data(),
                  qt_error_string().toLocal8Bit().data());

        closeDownRequest = true;

        return;
    }
    else
    {
        qDebug() << "Database Opened";
    }

    // get experimental location


    QSqlQuery query("SELECT ExperimentalLocationId,Sessionuser  FROM SessionControl WHERE SessionId = 1 LIMIT 1");

    if (query.next())
    {
       experimentLocation = query.value(0).toInt();
       sessionUser = query.value(1).toString();
    }
    else
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);

        msgBox.setText("Cant find session control table!");
        msgBox.exec();
        closeDownRequest = true;
        return;
    }

    // get language

    query = "SELECT languageId FROM Users where userId = " + sessionUser + " LIMIT 1";

    if (query.next())
    {
       languageId = query.value(0).toString();
    }
    else
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);

        msgBox.setText("Cant find users table!");
        msgBox.exec();
        closeDownRequest = true;
        return;
    }

    fillAPTextCombo();
    fillAPPredicates();
    fillDisplayArea();

 }