void Priorities::slotInsertOrUpdateRecords(void) { QList<QVariant> list; QSqlQuery stored; if (m_rad == RecordActionDatabase::ardInsert){ list.append(dictionaryDialog->ui->lineEditItem->text()); list.append((int)dictionaryDialog->ui->checkBoxActual->isChecked()); list.append((int)(dictionaryDialog->ui->comboBoxIcon->currentIndex())); stored = execStored(currentDatabase(), "InsertPriorityType", storageHashTable(list)); stored.finish(); } else if (m_rad == RecordActionDatabase::ardUpdate){ unsigned i(0); unsigned m_code = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), i).data(Qt::DisplayRole).toUInt(); list.append(m_code); list.append(dictionaryDialog->ui->lineEditItem->text()); list.append((int)(dictionaryDialog->ui->checkBoxActual->isChecked())); list.append((int)(dictionaryDialog->ui->comboBoxIcon->currentIndex())); stored = execStored(currentDatabase(), "UpdatePriorityType", storageHashTable(list)); stored.finish(); } slotRefreshRecords(); clearEditDialog(dictionaryDialog); m_selectedItem = false; }
void CTaskType::slotDeleteRecords(void) { QList<QVariant> list; QSqlQuery stored; if (currentDatabase().isOpen()) { int code = modelSelectionTask->currentIndex().sibling(modelSelectionTask->currentIndex().row(), 0).data().toUInt(); if (!modelSelectionTask->selection().isEmpty()) { CMessage answer(this, "Удаление", "Подтверждаете удаление?"); QPushButton *_delete = answer.addButton(QString("Удалить"), QMessageBox::ActionRole); QPushButton *cancel = answer.addButton(QString("Отмена"), QMessageBox::ActionRole); answer.exec(); if (answer.clickedButton() == _delete){ list.append((int)code); stored.setForwardOnly(true); stored = execStored(currentDatabase(), "DeleteTaskType", storageHashTable(list)); stored.finish(); slotRefreshRecords(); // refresh } else if (answer.clickedButton() == cancel){ treeCppsst->clearSelection(); answer.reject(); } } else CCommunicate::showing(QString("Не удается выполнить, запись не выбрана")); } else CCommunicate::showing(QString("Не удается выполнить, база данных не доступна")); }
void CTaskType::slotActualRecords(const bool &actual) { actualRecords = !actual; slotRefreshRecords(); actualRecords ? ui->labelViewState->setText(QString(tr("Отображаются записи: <b><u>Актуальные</u></b>"))) : ui->labelViewState->setText(QString(tr("Отображаются записи: <b><u>Все</u></b>"))); }
bool CTaskType::eventFilter(QObject *object, QEvent *event) { if (object == qobject_cast<CTreeViewCppsst*>(treeCppsst)) { if (event->type() == QEvent::FocusIn){ for (QAction *action : getContextMenu()->actions()){ disconnect(action, SIGNAL(triggered()), 0, 0); } connect(getContextMenu()->actions().at(0), SIGNAL(triggered()), SLOT(slotCreateEditDialog())); connect(getContextMenu()->actions().at(2), SIGNAL(triggered()), SLOT(slotCopyRecords())); connect(getContextMenu()->actions().at(3), SIGNAL(triggered()), SLOT(slotDeleteRecords())); connect(getContextMenu()->actions().at(5), SIGNAL(triggered()), SLOT(slotRefreshRecords())); return false; } } return QWidget::eventFilter(object, event); }
void Priorities::slotDeleteRecords(void) { QList<QVariant> list; QSqlQuery stored; QString m_name; unsigned i(0); unsigned m_code = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), i).data(Qt::DisplayRole).toUInt(); if (m_selectionModel->currentIndex().column() != 1){ m_name = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), 1).data(Qt::DisplayRole).toString(); } else { m_name = m_selectionModel->currentIndex().data(Qt::DisplayRole).toString(); } if (m_selectionModel->isSelected(m_selectionModel->currentIndex())){ QMessageBox answer; answer.setText(QString(tr("Подтверждаете удаление <b>%1</b>?").arg(m_name))); answer.setWindowTitle(QString(tr("Удаление"))); answer.setIcon(QMessageBox::Question); QPushButton *m_delete = answer.addButton(QString(tr("Удалить")), QMessageBox::ActionRole); QPushButton *m_cancel = answer.addButton(QString(tr("Отмена")), QMessageBox::ActionRole); answer.exec(); if (answer.clickedButton() == m_delete){ list.append(m_code); stored = execStored(currentDatabase(), "DeletePriorityType", storageHashTable(list)); stored.finish(); slotRefreshRecords(); } else if (answer.clickedButton() == m_cancel){ treeView->clearSelection(); answer.reject(); } } else { Communicate::showing(QString("Не удается удалить,\n запись не выбрана"), 3000); } m_selectedItem = false; }
void CTaskType::slotInsertOrUpdateRecords(const QList<QString> ¶m) { QList<QVariant> list; QSqlQuery stored; int code = modelSelectionTask->currentIndex().sibling(modelSelectionTask->currentIndex().row(), 0).data().toUInt(); list.append(code); list.append(param.at(0)); list.append(QVariant(param.at(2)).toBool()); if (act == Action::Add) { list.removeAt(0); stored = execStored(currentDatabase(), "InsertTaskType", storageHashTable(list)); } else if (act == Action::Edit) { stored = execStored(currentDatabase(), "UpdateTaskType", storageHashTable(list)); } stored.finish(); slotRefreshRecords(); CDictionaryCore::clearEditDialog(cppsstDialog); }