当前位置: 首页>>代码示例>>C++>>正文


C++ TypeSystem::setId方法代码示例

本文整理汇总了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();
    }
}
开发者ID:Indexu,项目名称:Verklegt_Namskeid,代码行数:53,代码来源:maintype.cpp

示例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();
    }
}
开发者ID:Indexu,项目名称:Verklegt_Namskeid,代码行数:77,代码来源:maintype.cpp


注:本文中的TypeSystem::setId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。