EngineListView::EngineListView( GLWidget *glWidget, QWidget *parent ) : QListView(parent), d(new EngineListViewPrivate) { d->glWidget = glWidget; EngineItemModel *m = new EngineItemModel(d->glWidget, this); if(model()) { delete model(); } // This should sort the engine names for user views // It should also update dynamically as people edit names // Somehow it doesn't work right from the start! QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(this); sortModel->setSourceModel(m); setModel(sortModel); sortModel->setSortCaseSensitivity(Qt::CaseInsensitive); sortModel->setSortLocaleAware(true); sortModel->setDynamicSortFilter(true); sortModel->sort(0, Qt::AscendingOrder); connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(selectEngine(QModelIndex))); // This might work for having the proxy model emit the signal, but let's keep it as-is connect(m, SIGNAL(dataChanged(QModelIndex, QModelIndex)), glWidget, SLOT(update())); // improves display performance setUniformItemSizes(true); setAlternatingRowColors(true); // looks better }
void EngineController::play() { qDebug() << "EngineController::play"; /* make moves in long algebraic notation "d2d4" or "f7f8q" */ if(engine->getBestmove().size() == 4 || engine->getBestmove().size() == 5) { game->move(engine->getBestmove()); /* Let other widgets know, that we made a move */ cout << "Made move" << endl; emit madeMove(); ui->playButton->setDisabled(true); /* Think on next move if radiobutton play and color checkbox are checked */ cout << "Think on next move" << endl; if(ui->radio_play->isChecked() || ui->radio_think->isChecked()) { if(game->getActiveColor() == 'b') selectEngine(1); else selectEngine(0); if((ui->checkBox_black->isChecked() && game->getActiveColor() == 'b') || (ui->checkBox_white->isChecked() && game->getActiveColor() == 'w')) go(); } } }
EngineController::EngineController(QWidget *parent) : QWidget(parent), ui(new Ui::EngineController) { ui->setupUi(this); connect(ui->engineSelect, SIGNAL(activated(int)), this, SLOT(selectEngine(int))); /* Create Engines */ uci = new UCIEngine("/bin/stockfish"); chess = new ChessEngine("/home/alex/cpp/giraffe/giraffe"); engine = NULL; selectEngine(0); // set default engine connect(ui->goButton, SIGNAL(pressed()), this, SLOT(toggleGoStop())); goButtonPressed = false; /* Link QDials and QSpinBoxes */ connect(ui->spinBox_depth, SIGNAL(valueChanged(int)), ui->searchdepth, SLOT(setValue(int))); connect(ui->spinBox_movetime, SIGNAL(valueChanged(int)), ui->movetime, SLOT(setValue(int))); connect(ui->spinBox_nodes, SIGNAL(valueChanged(int)), ui->nodes, SLOT(setValue(int))); connect(ui->searchdepth, SIGNAL(valueChanged(int)), ui->spinBox_depth, SLOT(setValue(int))); connect(ui->movetime, SIGNAL(valueChanged(int)), ui->spinBox_movetime, SLOT(setValue(int))); connect(ui->nodes, SIGNAL(valueChanged(int)), ui->spinBox_nodes, SLOT(setValue(int))); connect(ui->playButton, SIGNAL(pressed()), this, SLOT(play())); connect(ui->radio_play, SIGNAL(pressed()), this, SLOT(turnOn())); connect(ui->radio_think, SIGNAL(pressed()), this, SLOT(turnOn())); connect(ui->radio_power, SIGNAL(pressed()), this, SLOT(turnOff())); ui->searchdepth->setMinimum(0); ui->searchdepth->setMaximum(25); ui->movetime->setMinimum(0); //ui->movetime->setMaximum(100000); ui->nodes->setMinimum(0); ui->nodes->setMaximum(500); ui->spinBox_depth->setMaximum(ui->searchdepth->maximum()); ui->spinBox_movetime->setMaximum(ui->movetime->maximum()); ui->spinBox_nodes->setMaximum(ui->nodes->maximum()); turnOff(); //ui->verticalLayout->addWidget(uci->output); //ui->verticalLayout->addWidget(chess->output); }