本文整理汇总了C++中TypeSystem::setId方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeSystem::setId方法的具体用法?C++ TypeSystem::setId怎么用?C++ TypeSystem::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeSystem
的用法示例。
在下文中一共展示了TypeSystem::setId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: editType
// === EDIT ===
// Edit type
void MainWindow::editType(){
QVector<int> ids = utilities::getSelectedTableViewIds(ui->typesTable);
// No rows or more than 1
if (ids.size() != 1) {
return;
}
// An empty person
TypeSystem ts;
// Set person ID to the ID of the row
ts.setId(ids[0]);
// Get the person info by ID
if(!servicesLayer.getTypeSystem(ts, 1, error)){
checkError();
return;
}
// Edit dialog
EditTypeSystemDialog editDialog;
// Forward person to edit dialog
editDialog.setName(ts.getName());
// Set the fields
editDialog.setFields();
// Set title
editDialog.setTitle("Edit Type");
// If saved
if (editDialog.exec()) {
ts.setName(editDialog.getName());
// If error, show error, else update table
if (!servicesLayer.editTypeSystem(ts, 1, error)) {
checkError();
return;
}
else{
checkTypeSearch();
displayMachinesTable();
displayConnectionsTable();
}
// Set status bar message
ui->statusBar->showMessage(ts.getName() + " edited", constants::STATUSBAR_MESSAGE_TIME);
// Disable Person edit and delete buttons
disableEditDeleteTypeButtons();
}
}
示例2: deleteType
// ==== DELETE ====
// Delete type
void MainWindow::deleteType(){
QVector<int> ids = utilities::getSelectedTableViewIds(ui->typesTable);
// No rows
if (ids.isEmpty()) {
return;
}
int numRows = ids.size();
QString deleteConfirmMessage = "";
QString statusBarMessage = "";
// Get all the machines that are about to be deleted
QVector<TypeSystem> typesToBeDeleted;
for(int i = 0; i < numRows;i++){
// An empty machine
TypeSystem ts;
// Set machine ID to the ID of the row
ts.setId(ids[i]);
// Get the machine info by ID
if(!servicesLayer.getTypeSystem(ts, 1, error)){
checkError();
return;
}
// Add to vector
typesToBeDeleted.push_back(ts);
}
// Single row
if(numRows == 1){
deleteConfirmMessage = "Are you sure you want to delete " + typesToBeDeleted[0].getName() + "?";
statusBarMessage = typesToBeDeleted[0].getName() + " deleted";
}
// Rows less than 11
else if(numRows > 1 && numRows < 11){
deleteConfirmMessage = "Are you sure you want to delete:\n";
// Loop over names
for(int i = 0; i < numRows;i++){
deleteConfirmMessage += typesToBeDeleted[i].getName() + "\n";
}
statusBarMessage = QString::number(numRows) + " entries deleted";
}
// More than 10
else{
deleteConfirmMessage = "Are you sure you want to delete these " + QString::number(numRows) + " entries?";
statusBarMessage = QString::number(numRows) + " entries deleted";
}
// Confirmation window
int ans = QMessageBox::question(this, "Confirmation", deleteConfirmMessage, QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
// Check answer
if (ans == QMessageBox::Yes) {
// Delete
if(!servicesLayer.deleteTypeSystem(typesToBeDeleted, 1, error)){
checkError();
return;
}
// Disable Person edit and delete buttons
disableEditDeleteTypeButtons();
// Status bar update
ui->statusBar->showMessage(statusBarMessage, constants::STATUSBAR_MESSAGE_TIME);
// Re-display
checkTypeSearch();
displayMachinesTable();
displayConnectionsTable();
}
}