| 2751 | } |
| 2752 | |
| 2753 | void MainWindow::stateAdd(QString &name, QString &path) { |
| 2754 | const int row = ui->slotView->rowCount(); |
| 2755 | ui->slotView->setSortingEnabled(false); |
| 2756 | |
| 2757 | QToolButton *btnLoad = new QToolButton(); |
| 2758 | QToolButton *btnSave = new QToolButton(); |
| 2759 | QToolButton *btnEdit = new QToolButton(); |
| 2760 | QToolButton *btnRemove = new QToolButton(); |
| 2761 | |
| 2762 | btnLoad->setIcon(m_iconLoad); |
| 2763 | btnSave->setIcon(m_iconSave); |
| 2764 | btnEdit->setIcon(m_iconEdit); |
| 2765 | btnRemove->setIcon(m_iconRemove); |
| 2766 | |
| 2767 | connect(btnRemove, &QToolButton::clicked, this, &MainWindow::stateRemove); |
| 2768 | connect(btnLoad, &QToolButton::clicked, this, &MainWindow::stateLoad); |
| 2769 | connect(btnSave, &QToolButton::clicked, this, &MainWindow::stateSave); |
| 2770 | connect(btnEdit, &QToolButton::clicked, this, &MainWindow::stateEdit); |
| 2771 | |
| 2772 | QTableWidgetItem *itemName = new QTableWidgetItem(name); |
| 2773 | QTableWidgetItem *itemLoad = new QTableWidgetItem(); |
| 2774 | QTableWidgetItem *itemSave = new QTableWidgetItem(); |
| 2775 | QTableWidgetItem *itemEdit = new QTableWidgetItem(); |
| 2776 | QTableWidgetItem *itemRemove = new QTableWidgetItem(); |
| 2777 | |
| 2778 | itemEdit->setData(Qt::UserRole, path); |
| 2779 | stateToPath(itemEdit->data(Qt::UserRole).toString()); |
| 2780 | |
| 2781 | ui->slotView->setRowCount(row + 1); |
| 2782 | ui->slotView->setItem(row, SLOT_NAME_COL, itemName); |
| 2783 | ui->slotView->setItem(row, SLOT_LOAD_COL, itemLoad); |
| 2784 | ui->slotView->setItem(row, SLOT_SAVE_COL, itemSave); |
| 2785 | ui->slotView->setItem(row, SLOT_EDIT_COL, itemEdit); |
| 2786 | ui->slotView->setItem(row, SLOT_REMOVE_COL, itemRemove); |
| 2787 | |
| 2788 | ui->slotView->setCellWidget(row, SLOT_LOAD_COL, btnLoad); |
| 2789 | ui->slotView->setCellWidget(row, SLOT_SAVE_COL, btnSave); |
| 2790 | ui->slotView->setCellWidget(row, SLOT_EDIT_COL, btnEdit); |
| 2791 | ui->slotView->setCellWidget(row, SLOT_REMOVE_COL, btnRemove); |
| 2792 | |
| 2793 | ui->slotView->setCurrentCell(row, SLOT_NAME_COL); |
| 2794 | |
| 2795 | stateSaveInfo(); |
| 2796 | |
| 2797 | ui->slotView->setVisible(false); |
| 2798 | ui->slotView->resizeColumnsToContents(); |
| 2799 | ui->slotView->setVisible(true); |
| 2800 | ui->slotView->setSortingEnabled(true); |
| 2801 | } |
| 2802 | |
| 2803 | int MainWindow::stateGet(QObject *obj, int col) { |
| 2804 | int row; |