multi-check system
This commit is contained in:
@@ -33,11 +33,13 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
ui->stop_server_button->hide();
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
|
||||
ui->checks_scroll_area->setLayout(layout);
|
||||
ui->scrollAreaWidgetContents->setLayout(layout);
|
||||
QLabel a = QLabel("123");
|
||||
layout->addWidget(&a);
|
||||
// ui->checks_to_parse_label->hide();
|
||||
// ui->checks_scroll_area->hide();
|
||||
ui->checks_to_parse_label->hide();
|
||||
ui->checks_scroll_area->hide();
|
||||
|
||||
connect(this, &MainWindow::deleteCheckFromList, this, &MainWindow::deleteCheckFromListHandler);
|
||||
|
||||
#ifdef BUILD_OFD_BINARYEYE_SCAN
|
||||
QObject::connect(this, &MainWindow::httpErrorOccured, this, &MainWindow::notifyHttpServerFailure);
|
||||
@@ -97,7 +99,7 @@ void MainWindow::on_binary_eye_button_clicked() {
|
||||
infoDialog.setText(QString::fromStdString(connectionString));
|
||||
infoDialog.setIconPixmap(QPixmap(QString::fromStdString(get_path_relative_to_home(".local/share/checks_parser/binaryeye_connection.png"))).scaled(400, 400, Qt::KeepAspectRatio));
|
||||
infoDialog.setWindowTitle(tr("QR code for binaryeye to connect"));
|
||||
infoDialog.setButtonText(1, tr("I've scanned"));
|
||||
infoDialog.addButton(tr("I've scanned"), QMessageBox::ButtonRole::AcceptRole);
|
||||
infoDialog.exec();
|
||||
}
|
||||
|
||||
@@ -206,6 +208,30 @@ void MainWindow::on_parse_button_clicked() {
|
||||
d.exec();
|
||||
}
|
||||
|
||||
void MainWindow::deleteCheckFromListHandler(Check &check) {
|
||||
for (unsigned int i = 0; i < ui->scrollAreaWidgetContents->layout()->count(); i ++) {
|
||||
QLayoutItem *item = ui->scrollAreaWidgetContents->layout()->itemAt(i);
|
||||
QObject *child = item->widget();
|
||||
CheckListViewWidget *c = (CheckListViewWidget *)child;
|
||||
if (c->get_check() == check) {
|
||||
ui->scrollAreaWidgetContents->layout()->removeItem(item);
|
||||
delete item;
|
||||
delete child;
|
||||
ui->scrollAreaWidgetContents->layout()->update();
|
||||
ui->scrollAreaWidgetContents->update();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int position = std::find(checks.begin(), checks.end(), check) - checks.begin() - 1;
|
||||
checks.erase(checks.begin() + position);
|
||||
|
||||
if (ui->scrollAreaWidgetContents->layout()->count() == 0) {
|
||||
ui->checks_to_parse_label->hide();
|
||||
ui->checks_scroll_area->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_add_new_check_button_clicked() {
|
||||
Check *new_check = parse_new_check();
|
||||
if (new_check == nullptr) {
|
||||
@@ -214,10 +240,9 @@ void MainWindow::on_add_new_check_button_clicked() {
|
||||
|
||||
checks.push_back(*new_check);
|
||||
|
||||
CheckListViewWidget check_list_widget(this, *new_check);
|
||||
CheckListViewWidget *check_list_widget = new CheckListViewWidget(this, *new_check);
|
||||
|
||||
auto a = QLabel("123");
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(&a);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(check_list_widget);
|
||||
|
||||
delete new_check;
|
||||
|
||||
@@ -250,6 +275,11 @@ Check *MainWindow::parse_new_check() {
|
||||
solved_captcha);
|
||||
|
||||
(*check) = parseOfdRuAnswer(check_content);
|
||||
check->set_date(ui->purchase_datetime_edit->dateTime().toString(Qt::ISODate).toStdString());
|
||||
check->set_fn(ui->fn_line_edit->text().toStdString());
|
||||
check->set_fd(ui->fd_line_edit->text().toStdString());
|
||||
check->set_fi(ui->fi_line_edit->text().toStdString());
|
||||
check->set_operation_type(OperationType(ui->operation_type_combo_box->currentIndex() + 1));
|
||||
return check;
|
||||
} catch(OfdRequestException e) {
|
||||
if (!strcmp(e.what(), "Incorrect captcha")) {
|
||||
|
||||
Reference in New Issue
Block a user