예제 #1
0
void Search( vector<Computer> & list, Computer p ) {        // Search for members in list based on template person p
    vector<Computer> SearchList;                      // Create search result vector

    for( unsigned int x = 0; x < list.size(); x++) {    // Search each entry of list
        bool add = true;                                    // We say the entry should be added by default then exclude it based on the template person
        if( p.getName() != "" )
            if( !list[x].getName().contains( p.getName(), Qt::CaseInsensitive ) )
                add = false;

        if( p.getType() != "" )
            if( !list[x].getType().contains( p.getType() , Qt::CaseInsensitive ) )
                add = false;

        if( p.getWasBuilt() != 2 )
            if( !(list[x].getWasBuilt() == p.getWasBuilt() ) )
                add = false;

        if( p.getYear() != "" )
            if( !(list[x].getYear() == p.getYear() ) )
                add = false;

        if(add)
            SearchList.push_back( list[x] );
    }
    displayComputer( SearchList );              // Display search results
}
예제 #2
0
vector<int> addRelation(vector<Person>& p, vector<Computer>& c) {
    QTextStream in(stdin);
    vector<int> relation;
    unsigned int x, y;
    QString value;

    displayPerson(p);
    do{
        cout <<"Select a person: ";
        cin.ignore();
        value = in.readLine();
        x = value.toInt();
        if( x > p.size() || x < 1 )
            cout << "Please choose a number from 1 to " << p.size() << endl;
        else
            relation.push_back(x);
    } while( x > p.size() || x < 1 );

    displayComputer(c);
    do{
        cout << "Select a computer to connect to the chosen person: ";
        value = in.readLine();
        y = value.toInt();
        if( y > c.size() || y < 1 )
            cout << "Please choose a number from 1 to " << c.size() << endl;
        else
            relation.push_back(y);
    } while( y > c.size() || y < 1 );

    return relation;
}
예제 #3
0
vector<int> removeRelation(vector<Person>& p, vector<Computer>& c) {
    QTextStream in(stdin);
    vector<int> relation;
    unsigned int x, y;
    QString value;

    displayPerson(p);
    do{
        cout <<"Select a person: ";
        value = in.readLine();
        x = value.toInt();
        if(x > p.size() || x < 1)
            cout << "Please choose a number from 1 to " << p.size() << endl;
        else
            relation.push_back(x - 1);
    } while(x > p.size() || x < 1);

    Person pers = p[x - 1];
    vector<Computer> comps;


    for(int i = 0; i < pers.getSize(); i++){
        for(unsigned int j = 0; j < c.size(); j++){
            if(pers.getComputer(i) == c[j].getId()){
                comps.push_back(c[j]);
            }
        }
    }

    displayComputer(comps);
    do{
        cout << "Select a connected computer to remove from chosen person: ";
        value = in.readLine();
        y = value.toInt();
        if(y > comps.size() || y < 1)
            cout << "Please choose a number from 1 to " << comps.size() << endl;
        else{
            Computer comp = comps[y - 1];
            int z = -1;
            while( c[z].getId() != comp.getId() ) {
                z++;
                if( c[z].getId() == comp.getId() )
                    relation.push_back(z);
            }
        }
    } while( y > c.size() || y < 1 );

    return relation;
}
예제 #4
0
void ViewComputerDialog::setup() {
    setTable();
    displayComputer();
    ui->scientist_table->setColumnWidth(0,35);
    ui->scientist_table->setColumnWidth(1,200);
}
예제 #5
0
void MainWindow::on_input_filter_computers_textChanged(const QString& arg1) {
    string userInput = ui->input_filter_computers->text().toStdString();
    vector<Computer> computers = compService.search(userInput, getCurrentComputerOrderBy(), getComputerOrderByAscending());
    displayComputer(computers);
}
예제 #6
0
void MainWindow::displayAllComputers() {
    vector<Computer> computers = compService.sort(getCurrentComputerOrderBy(), getComputerOrderByAscending());
    displayComputer(computers);
}
예제 #7
0
void ClickComputer::setSelectedComputer(computersWithPeople MSelectedComputer)
{
    selectedComputer = MSelectedComputer;
    displayComputer();
}
예제 #8
0
void editComputers::setSelectedComputer(const computersWithPeople &MSelectedComputer)
{
    selectedComputer = MSelectedComputer;
    displayComputer();
}