check queue WIP
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#ifdef BUILD_OFD_LOCAL_QR_SCAN
|
||||
# include <adjustpicturedialog.h>
|
||||
#include <checkqueuetablemodel.h>
|
||||
#endif
|
||||
|
||||
#include <outputdialog.h>
|
||||
@@ -32,14 +33,15 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
ui->setupUi(this);
|
||||
ui->stop_server_button->hide();
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
|
||||
ui->checks_scroll_area->setLayout(layout);
|
||||
ui->scrollAreaWidgetContents->setLayout(layout);
|
||||
ui->checks_to_parse_label->hide();
|
||||
ui->checks_scroll_area->hide();
|
||||
ui->checkQueueTable->hide();
|
||||
|
||||
connect(this, &MainWindow::deleteCheckFromList, this, &MainWindow::deleteCheckFromListHandler);
|
||||
model = new CheckQueueTableModel(&checks, this);
|
||||
ui->checkQueueTable->setModel(model);
|
||||
|
||||
// ui->
|
||||
// connect(this, &MainWindow::deleteCheckFromList, this, &MainWindow::deleteCheckFromListHandler);
|
||||
|
||||
#ifdef BUILD_OFD_BINARYEYE_SCAN
|
||||
QObject::connect(this, &MainWindow::httpErrorOccured, this, &MainWindow::notifyHttpServerFailure);
|
||||
@@ -195,42 +197,43 @@ void MainWindow::on_parse_email_button_clicked() {
|
||||
#endif // ifdef BUILD_EMAIL_MODE
|
||||
|
||||
void MainWindow::on_parse_button_clicked() {
|
||||
// if (checks.empty()) {
|
||||
// QMessageBox infoDialog;
|
||||
// infoDialog.setText(tr("Please, add check(s) to parse"));
|
||||
// infoDialog.setIcon(QMessageBox::Warning);
|
||||
// infoDialog.setWindowTitle(tr("No checks to parse"));
|
||||
// infoDialog.exec();
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (checks.empty()) {
|
||||
QMessageBox infoDialog;
|
||||
infoDialog.setText(tr("Please, add check(s) to parse"));
|
||||
infoDialog.setIcon(QMessageBox::Warning);
|
||||
infoDialog.setWindowTitle(tr("No checks to parse"));
|
||||
infoDialog.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
OutputDialog d = OutputDialog(this, &checks);
|
||||
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();
|
||||
// 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);
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
// 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();
|
||||
@@ -240,14 +243,15 @@ void MainWindow::on_add_new_check_button_clicked() {
|
||||
|
||||
checks.push_back(*new_check);
|
||||
|
||||
CheckListViewWidget *check_list_widget = new CheckListViewWidget(this, *new_check);
|
||||
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(check_list_widget);
|
||||
unsigned int newRowIndex = checks.size();
|
||||
model->insertRow(newRowIndex, 1);
|
||||
model->setData(model->index(newRowIndex, 0), QVariant::fromValue(new_check->get_date()));
|
||||
model->setData(model->index(newRowIndex, 1), QVariant::fromValue(new_check->get_total()));
|
||||
|
||||
delete new_check;
|
||||
|
||||
if (checks.size() == 1) {
|
||||
ui->checks_scroll_area->show();
|
||||
if (checks.size() > 0) {
|
||||
ui->checkQueueTable->show();
|
||||
ui->checks_to_parse_label->show();
|
||||
}
|
||||
}
|
||||
@@ -272,7 +276,8 @@ Check *MainWindow::parse_new_check() {
|
||||
ui->operation_type_combo_box->currentIndex() + 1,
|
||||
// In the request to ofd.ru, total is in a format with 2 last digits represent decimal part of a number.
|
||||
ui->total_spin_box->text().toDouble() * 100,
|
||||
solved_captcha);
|
||||
solved_captcha
|
||||
);
|
||||
|
||||
(*check) = parseOfdRuAnswer(check_content);
|
||||
check->set_date(ui->purchase_datetime_edit->dateTime().toString(Qt::ISODate).toStdString());
|
||||
|
||||
Reference in New Issue
Block a user