Skip to content
Snippets Groups Projects
Commit 2dca70a6 authored by roangel's avatar roangel
Browse files

protected against errors. Need to put error labels

parent 590f03d6
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,12 @@
class CFLinker
{
public:
struct link {
int student_id;
int cf_zone_index;
std::string cf_name;
};
explicit CFLinker(Ui::MainGUIWindow* ui, std::vector<crazyFly*> *crazyflies_vector, std::vector<crazyFlyZone*> *crazyfly_zones);
~CFLinker();
......@@ -19,15 +25,10 @@ public:
void unlink();
private:
struct link {
int cf_zone_index;
std::string cf_name;
};
std::vector<struct link> links;
private:
// QTableWidget m_p_table;
Ui::MainGUIWindow* m_ui;
......
......@@ -45,6 +45,7 @@ void CFLinker::link()
m_ui->table_links->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
struct link tmp_link;
tmp_link.student_id = m_ui->spinBox_student_ids->value();
tmp_link.cf_zone_index = getCFZoneIndexFromName(m_ui->comboBoxCFZones->currentText());
tmp_link.cf_name = m_ui->comboBoxCFs->currentText().toStdString();
......@@ -58,6 +59,17 @@ void CFLinker::link()
links.push_back(tmp_link);
// TODO: remove options linked from available ones
int index = m_ui->comboBoxCFs->currentIndex();
// remove items
m_ui->comboBoxCFs->removeItem(index);
index = m_ui->comboBoxCFZones->currentIndex();
m_ui->comboBoxCFZones->removeItem(index);
// disable item
// m_ui->comboBoxCFs->setItemData(index, 0, Qt::UserRole - 1);
// enable item
// ui->comboBox->setItemData(index, 33, Qt::UserRole - 1);
}
void CFLinker::unlink()
......
......@@ -113,6 +113,7 @@ void MainGUIWindow::_init()
selectedItem->setFont(fnt);
}
}
ui->table_links->setSelectionBehavior(QAbstractItemView::SelectRows);
// scene
scene = new myGraphicsScene(ui->frame_drawing);
......@@ -549,6 +550,33 @@ void MainGUIWindow::on_refresh_student_ids_button_clicked()
void MainGUIWindow::on_link_button_clicked()
{
#ifdef CATKIN_MAKE
cf_linker->link();
bool error = false;
if(ui->comboBoxCFs->count() == 0)
{
// plot error message
error = true;
}
if(ui->comboBoxCFZones->count() == 0)
{
// plot error message
error = true;
}
for(int i = 0; i < cf_linker->links.size(); i++)
{
if(cf_linker->links[i].student_id == ui->spinBox_student_ids->value())
{
// value already linked, choose different one
// plot error message
error = true;
}
}
if(!error)
{
// remove error messages
cf_linker->link();
}
#endif
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment