check queue WIP

This commit is contained in:
leca 2025-05-19 01:05:56 +03:00
parent d10dfc07b6
commit a8549c838c
12 changed files with 457 additions and 273 deletions

View File

@ -165,6 +165,7 @@ else()
add_executable(checks-parser add_executable(checks-parser
${PROJECT_SOURCES} ${PROJECT_SOURCES}
${SOURCES} ${SOURCES}
widgets/checkqueuetablemodel.h widgets/checkqueuetablemodel.cpp
) )
endif() endif()

BIN
a.out Executable file

Binary file not shown.

View File

@ -53,6 +53,10 @@ void Check::set_operation_type(OperationType t) {
this->operation_type = t; this->operation_type = t;
} }
void Check::set_total(double total){
this->total = total;
}
double Check::get_total() { double Check::get_total() {
return total; return total;
} }

View File

@ -8,6 +8,7 @@
#ifdef BUILD_OFD_LOCAL_QR_SCAN #ifdef BUILD_OFD_LOCAL_QR_SCAN
# include <adjustpicturedialog.h> # include <adjustpicturedialog.h>
#include <checkqueuetablemodel.h>
#endif #endif
#include <outputdialog.h> #include <outputdialog.h>
@ -32,14 +33,15 @@ MainWindow::MainWindow(QWidget *parent)
ui->setupUi(this); ui->setupUi(this);
ui->stop_server_button->hide(); 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_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 #ifdef BUILD_OFD_BINARYEYE_SCAN
QObject::connect(this, &MainWindow::httpErrorOccured, this, &MainWindow::notifyHttpServerFailure); QObject::connect(this, &MainWindow::httpErrorOccured, this, &MainWindow::notifyHttpServerFailure);
@ -195,42 +197,43 @@ void MainWindow::on_parse_email_button_clicked() {
#endif // ifdef BUILD_EMAIL_MODE #endif // ifdef BUILD_EMAIL_MODE
void MainWindow::on_parse_button_clicked() { void MainWindow::on_parse_button_clicked() {
// if (checks.empty()) {
// QMessageBox infoDialog; if (checks.empty()) {
// infoDialog.setText(tr("Please, add check(s) to parse")); QMessageBox infoDialog;
// infoDialog.setIcon(QMessageBox::Warning); infoDialog.setText(tr("Please, add check(s) to parse"));
// infoDialog.setWindowTitle(tr("No checks to parse")); infoDialog.setIcon(QMessageBox::Warning);
// infoDialog.exec(); infoDialog.setWindowTitle(tr("No checks to parse"));
// return; infoDialog.exec();
// } return;
}
OutputDialog d = OutputDialog(this, &checks); OutputDialog d = OutputDialog(this, &checks);
d.exec(); d.exec();
} }
void MainWindow::deleteCheckFromListHandler(Check &check) { // void MainWindow::deleteCheckFromListHandler(Check &check) {
for (unsigned int i = 0; i < ui->scrollAreaWidgetContents->layout()->count(); i ++) { // for (unsigned int i = 0; i < ui->scrollAreaWidgetContents->layout()->count(); i ++) {
QLayoutItem *item = ui->scrollAreaWidgetContents->layout()->itemAt(i); // QLayoutItem *item = ui->scrollAreaWidgetContents->layout()->itemAt(i);
QObject *child = item->widget(); // QObject *child = item->widget();
CheckListViewWidget *c = (CheckListViewWidget *)child; // CheckListViewWidget *c = (CheckListViewWidget *)child;
if (c->get_check() == check) { // if (c->get_check() == check) {
ui->scrollAreaWidgetContents->layout()->removeItem(item); // ui->scrollAreaWidgetContents->layout()->removeItem(item);
delete item; // delete item;
delete child; // delete child;
ui->scrollAreaWidgetContents->layout()->update(); // ui->scrollAreaWidgetContents->layout()->update();
ui->scrollAreaWidgetContents->update(); // ui->scrollAreaWidgetContents->update();
} // }
} // }
int position = std::find(checks.begin(), checks.end(), check) - checks.begin() - 1; // int position = std::find(checks.begin(), checks.end(), check) - checks.begin() - 1;
checks.erase(checks.begin() + position); // checks.erase(checks.begin() + position);
if (ui->scrollAreaWidgetContents->layout()->count() == 0) { // if (ui->scrollAreaWidgetContents->layout()->count() == 0) {
ui->checks_to_parse_label->hide(); // ui->checks_to_parse_label->hide();
ui->checks_scroll_area->hide(); // ui->checks_scroll_area->hide();
} // }
} // }
void MainWindow::on_add_new_check_button_clicked() { void MainWindow::on_add_new_check_button_clicked() {
Check *new_check = parse_new_check(); Check *new_check = parse_new_check();
@ -240,14 +243,15 @@ void MainWindow::on_add_new_check_button_clicked() {
checks.push_back(*new_check); checks.push_back(*new_check);
CheckListViewWidget *check_list_widget = new CheckListViewWidget(this, *new_check); unsigned int newRowIndex = checks.size();
model->insertRow(newRowIndex, 1);
ui->scrollAreaWidgetContents->layout()->addWidget(check_list_widget); 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; delete new_check;
if (checks.size() == 1) { if (checks.size() > 0) {
ui->checks_scroll_area->show(); ui->checkQueueTable->show();
ui->checks_to_parse_label->show(); ui->checks_to_parse_label->show();
} }
} }
@ -272,7 +276,8 @@ Check *MainWindow::parse_new_check() {
ui->operation_type_combo_box->currentIndex() + 1, 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. // 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, ui->total_spin_box->text().toDouble() * 100,
solved_captcha); solved_captcha
);
(*check) = parseOfdRuAnswer(check_content); (*check) = parseOfdRuAnswer(check_content);
check->set_date(ui->purchase_datetime_edit->dateTime().toString(Qt::ISODate).toStdString()); check->set_date(ui->purchase_datetime_edit->dateTime().toString(Qt::ISODate).toStdString());

View File

@ -4,6 +4,7 @@
#include <QWidget> #include <QWidget>
#include <QEvent> #include <QEvent>
#include <thread> #include <thread>
#include <checkqueuetablemodel.h>
#include <http_server/http_server.h> #include <http_server/http_server.h>
@ -22,6 +23,7 @@ public:
~MainWindow(); ~MainWindow();
Check *parse_new_check(); Check *parse_new_check();
CheckQueueTableModel *model;
#ifdef BUILD_OFD_BINARYEYE_SCAN #ifdef BUILD_OFD_BINARYEYE_SCAN
void startHttpServer(); void startHttpServer();
@ -47,7 +49,7 @@ private slots:
void on_stop_server_button_clicked(); void on_stop_server_button_clicked();
void httpNewMessageHandler(QString message); void httpNewMessageHandler(QString message);
void deleteCheckFromListHandler(Check&); // void deleteCheckFromListHandler(Check&);
#endif #endif
#ifdef BUILD_EMAIL_MODE #ifdef BUILD_EMAIL_MODE
void on_parse_email_button_clicked(); void on_parse_email_button_clicked();

View File

@ -26,23 +26,26 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="1"> <item row="0" column="5">
<widget class="QLabel" name="or_label_1"> <widget class="QLabel" name="checks_to_parse_label">
<property name="text">
<string>Checks to parse</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="parse_email_button">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>or</string> <string>Parse an E-Mail</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="datetime_label">
<property name="text">
<string>Date and time of purchase</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -59,102 +62,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="2" colspan="3">
<widget class="QDoubleSpinBox" name="total_spin_box">
<property name="maximum">
<double>4294967296.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="checks_to_parse_label">
<property name="text">
<string>Checks to parse</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="fi_label">
<property name="text">
<string>FI (Fiscal Identifier)</string>
</property>
</widget>
</item>
<item row="9" column="4">
<widget class="QPushButton" name="parse_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Parse</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="settings_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Settings</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="fn_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FN (Fiscal Number)</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="total_label">
<property name="text">
<string>Total</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="binary_eye_button">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Use your phone as a QR code scanner</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="or_label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>or</string>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QPushButton" name="choose_image_button"> <widget class="QPushButton" name="choose_image_button">
<property name="sizePolicy"> <property name="sizePolicy">
@ -168,42 +75,36 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2" colspan="3"> <item row="6" column="0">
<widget class="QLineEdit" name="fn_line_edit"> <widget class="QLabel" name="datetime_label">
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <string>Date and time of purchase</string>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="2" colspan="3"> <item row="1" column="1">
<widget class="QDateTimeEdit" name="purchase_datetime_edit"/> <widget class="QLabel" name="or_label_1">
</item>
<item row="2" column="0" colspan="5">
<widget class="QLabel" name="info_label">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>or</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="4"> <item row="9" column="4">
<widget class="QPushButton" name="stop_server_button"> <widget class="QPushButton" name="parse_button">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Stop server</string> <string>Parse</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -231,15 +132,21 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="0" column="4">
<widget class="QLabel" name="operation_type_label"> <widget class="QPushButton" name="stop_server_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Operation type</string> <string>Stop server</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="4">
<widget class="QPushButton" name="parse_email_button"> <widget class="QPushButton" name="binary_eye_button">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -247,14 +154,144 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Parse an E-Mail</string> <string>Use your phone as a QR code scanner</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0" colspan="2"> <item row="4" column="2" colspan="3">
<widget class="QLineEdit" name="fd_line_edit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="fn_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FN (Fiscal Number)</string>
</property>
</widget>
</item>
<item row="5" column="2" colspan="3">
<widget class="QLineEdit" name="fi_line_edit"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="operation_type_label">
<property name="text">
<string>Operation type</string>
</property>
</widget>
</item>
<item row="8" column="2" colspan="3">
<widget class="QDoubleSpinBox" name="total_spin_box">
<property name="maximum">
<double>4294967296.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="5" rowspan="9">
<widget class="QTableView" name="checkQueueTable">
<property name="editTriggers">
<set>QAbstractItemView::EditTrigger::DoubleClicked|QAbstractItemView::EditTrigger::EditKeyPressed</set>
</property>
<property name="tabKeyNavigation">
<bool>false</bool>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDropMode::InternalMove</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::DropAction::TargetMoveAction</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SelectionMode::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="5">
<widget class="QLabel" name="info_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="fi_label">
<property name="text">
<string>FI (Fiscal Identifier)</string>
</property>
</widget>
</item>
<item row="6" column="2" colspan="3">
<widget class="QDateTimeEdit" name="purchase_datetime_edit"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="total_label">
<property name="text">
<string>Total</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="settings_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Settings</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="or_label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>or</string>
</property>
</widget>
</item>
<item row="3" column="2" colspan="3">
<widget class="QLineEdit" name="fn_line_edit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QPushButton" name="clear_button"> <widget class="QPushButton" name="clear_button">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -264,36 +301,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="2" colspan="3"> <item row="9" column="1" colspan="3">
<widget class="QLineEdit" name="fi_line_edit"/>
</item>
<item row="9" column="2" colspan="2">
<widget class="QPushButton" name="add_new_check_button"> <widget class="QPushButton" name="add_new_check_button">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Add new check</string> <string>Add new check</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="2" colspan="3">
<widget class="QLineEdit" name="fd_line_edit"/>
</item>
<item row="1" column="5" rowspan="9">
<widget class="QScrollArea" name="checks_scroll_area">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>273</width>
<height>404</height>
</rect>
</property>
</widget>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View File

@ -37,6 +37,9 @@
</item> </item>
<item row="3" column="0" colspan="3"> <item row="3" column="0" colspan="3">
<widget class="QListView" name="listView"> <widget class="QListView" name="listView">
<property name="editTriggers">
<set>QAbstractItemView::EditTrigger::DoubleClicked|QAbstractItemView::EditTrigger::EditKeyPressed</set>
</property>
<property name="dragEnabled"> <property name="dragEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>

13
test.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <iostream>
using namespace std;
int main () {
char lowerGender;
cin >> lowerGender;
if ((lowerGender != 'm' && lowerGender != 'f') && (lowerGender != 'м' && lowerGender != 'ж' )) {
cout << "хуйня" << std::endl;
cout << (int)lowerGender << endl;
} else {
cout << "норм" << endl;
}
}

View File

@ -70,7 +70,7 @@
<translation type="vanished">Store type</translation> <translation type="vanished">Store type</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="95"/> <location filename="../scenes/mainwindow.ui" line="107"/>
<source>Parse</source> <source>Parse</source>
<translation>Parse</translation> <translation>Parse</translation>
</message> </message>
@ -113,13 +113,13 @@
<translation type="vanished">0000000000000000</translation> <translation type="vanished">0000000000000000</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="121"/> <location filename="../scenes/mainwindow.ui" line="173"/>
<source>FN (Fiscal Number)</source> <source>FN (Fiscal Number)</source>
<translatorcomment>FN = Фискальный Номер</translatorcomment> <translatorcomment>FN = Фискальный Номер</translatorcomment>
<translation>FN (Fiscal Number)</translation> <translation>FN (Fiscal Number)</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="58"/> <location filename="../scenes/mainwindow.ui" line="61"/>
<source>FD (Fiscal Document)</source> <source>FD (Fiscal Document)</source>
<translatorcomment>FD = Фискальный Документ</translatorcomment> <translatorcomment>FD = Фискальный Документ</translatorcomment>
<translation>FD (Fiscal Document)</translation> <translation>FD (Fiscal Document)</translation>
@ -133,93 +133,93 @@
<translation type="obsolete">Back</translation> <translation type="obsolete">Back</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="206"/> <location filename="../scenes/mainwindow.ui" line="144"/>
<source>Stop server</source> <source>Stop server</source>
<translation>Stop server</translation> <translation>Stop server</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="167"/> <location filename="../scenes/mainwindow.ui" line="74"/>
<source>Choose image on your PC</source> <source>Choose image on your PC</source>
<translation>Choose image on your PC</translation> <translation>Choose image on your PC</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="38"/> <location filename="../scenes/mainwindow.ui" line="94"/>
<location filename="../scenes/mainwindow.ui" line="154"/> <location filename="../scenes/mainwindow.ui" line="277"/>
<source>or</source> <source>or</source>
<translation>or</translation> <translation>or</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="141"/> <location filename="../scenes/mainwindow.ui" line="157"/>
<source>Use your phone as a QR code scanner</source> <source>Use your phone as a QR code scanner</source>
<translation>Use your phone as a QR code scanner</translation> <translation>Use your phone as a QR code scanner</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="82"/> <location filename="../scenes/mainwindow.ui" line="241"/>
<source>FI (Fiscal Identifier)</source> <source>FI (Fiscal Identifier)</source>
<translatorcomment>FI = Фискальный Признак</translatorcomment> <translatorcomment>FI = Фискальный Признак</translatorcomment>
<translation>FI (Fiscal Identifier)</translation> <translation>FI (Fiscal Identifier)</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="273"/> <location filename="../scenes/mainwindow.ui" line="313"/>
<source>Add new check</source> <source>Add new check</source>
<translation>Add new check</translation> <translation>Add new check</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="263"/> <location filename="../scenes/mainwindow.ui" line="300"/>
<source>Clear</source> <source>Clear</source>
<translation>Clear</translation> <translation>Clear</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="45"/> <location filename="../scenes/mainwindow.ui" line="81"/>
<source>Date and time of purchase</source> <source>Date and time of purchase</source>
<translation>Date and time of purchase</translation> <translation>Date and time of purchase</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="237"/> <location filename="../scenes/mainwindow.ui" line="183"/>
<source>Operation type</source> <source>Operation type</source>
<translation>Operation type</translation> <translation>Operation type</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="250"/> <location filename="../scenes/mainwindow.ui" line="48"/>
<source>Parse an E-Mail</source> <source>Parse an E-Mail</source>
<translation>Parse an E-Mail</translation> <translation>Parse an E-Mail</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="214"/> <location filename="../scenes/mainwindow.ui" line="115"/>
<source>Funds income</source> <source>Funds income</source>
<translatorcomment>Приход средств</translatorcomment> <translatorcomment>Приход средств</translatorcomment>
<translation>Funds income</translation> <translation>Funds income</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="219"/> <location filename="../scenes/mainwindow.ui" line="120"/>
<source>Funds return</source> <source>Funds return</source>
<translatorcomment>Возврат средств</translatorcomment> <translatorcomment>Возврат средств</translatorcomment>
<translation>Funds return</translation> <translation>Funds return</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="224"/> <location filename="../scenes/mainwindow.ui" line="125"/>
<source>Funds spend</source> <source>Funds spend</source>
<translatorcomment>Расход средств</translatorcomment> <translatorcomment>Расход средств</translatorcomment>
<translation>Funds spend</translation> <translation>Funds spend</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="229"/> <location filename="../scenes/mainwindow.ui" line="130"/>
<source>Spends return</source> <source>Spends return</source>
<translatorcomment>Возврат расхода</translatorcomment> <translatorcomment>Возврат расхода</translatorcomment>
<translation>Spends return</translation> <translation>Spends return</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="72"/> <location filename="../scenes/mainwindow.ui" line="32"/>
<source>Checks to parse</source> <source>Checks to parse</source>
<translation>Checks to parse</translation> <translation>Checks to parse</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="108"/> <location filename="../scenes/mainwindow.ui" line="264"/>
<source>Settings</source> <source>Settings</source>
<translation>Settings</translation> <translation>Settings</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="128"/> <location filename="../scenes/mainwindow.ui" line="251"/>
<source>Total</source> <source>Total</source>
<translation>Total</translation> <translation>Total</translation>
</message> </message>
@ -228,75 +228,77 @@
<translation type="vanished">checks parser</translation> <translation type="vanished">checks parser</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="101"/> <location filename="../mainwindow.cpp" line="103"/>
<source>QR code for binaryeye to connect</source> <source>QR code for binaryeye to connect</source>
<translation>QR code for binaryeye to connect</translation> <translation>QR code for binaryeye to connect</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="102"/> <location filename="../mainwindow.cpp" line="104"/>
<source>I&apos;ve scanned</source> <source>I&apos;ve scanned</source>
<translation>I&apos;ve scanned</translation> <translation>I&apos;ve scanned</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="108"/> <location filename="../mainwindow.cpp" line="110"/>
<source>Could not start http server. 10 times in a row random port was occupied. Either you should run for a lottery ticket, or the problem is in the program. If the lottery ticket wasn&apos;t lucky, please, contact the developer.</source> <source>Could not start http server. 10 times in a row random port was occupied. Either you should run for a lottery ticket, or the problem is in the program. If the lottery ticket wasn&apos;t lucky, please, contact the developer.</source>
<translation>Could not start http server. 10 times in a row random port was occupied. Either you should run for a lottery ticket, or the problem is in the program. If the lottery ticket wasn&apos;t lucky, please, contact the developer.</translation> <translation>Could not start http server. 10 times in a row random port was occupied. Either you should run for a lottery ticket, or the problem is in the program. If the lottery ticket wasn&apos;t lucky, please, contact the developer.</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="110"/> <location filename="../mainwindow.cpp" line="112"/>
<source>Could not start http server.</source> <source>Could not start http server.</source>
<translation>Could not start http server.</translation> <translation>Could not start http server.</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="154"/> <location filename="../mainwindow.cpp" line="156"/>
<source>Selected image: </source> <source>Selected image: </source>
<translation>Selected image: </translation> <translation>Selected image: </translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="187"/> <location filename="../mainwindow.cpp" line="189"/>
<source>This feature is under development. Wait it to appear in next updates.</source> <source>This feature is under development. Wait it to appear in next updates.</source>
<translation>This feature is under development. Wait for it to appear in next updates.</translation> <translation>This feature is under development. Wait for it to appear in next updates.</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="189"/> <location filename="../mainwindow.cpp" line="191"/>
<source>Under development</source> <source>Under development</source>
<translation>Under development</translation> <translation>Under development</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="203"/>
<source>Please, add check(s) to parse</source> <source>Please, add check(s) to parse</source>
<translation type="vanished">Please, add check(s) to parse</translation> <translation>Please, add check(s) to parse</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="205"/>
<source>No checks to parse</source> <source>No checks to parse</source>
<translation type="vanished">No checks to parse</translation> <translation>No checks to parse</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="287"/> <location filename="../mainwindow.cpp" line="292"/>
<source>Captcha was not solved correctly!</source> <source>Captcha was not solved correctly!</source>
<translation>Captcha was not solved correctly!</translation> <translation>Captcha was not solved correctly!</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="289"/> <location filename="../mainwindow.cpp" line="294"/>
<source>Captcha is incorrect</source> <source>Captcha is incorrect</source>
<translation>Captcha is incorrect</translation> <translation>Captcha is incorrect</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="294"/> <location filename="../mainwindow.cpp" line="299"/>
<source>Internal server error. Please, try again later.</source> <source>Internal server error. Please, try again later.</source>
<translation>Internal server error. Please, try again later.</translation> <translation>Internal server error. Please, try again later.</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="296"/> <location filename="../mainwindow.cpp" line="301"/>
<source>Internal server error</source> <source>Internal server error</source>
<translation>Internal server error</translation> <translation>Internal server error</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="301"/> <location filename="../mainwindow.cpp" line="306"/>
<source>Check not found. Please, ensure correctness of entered data.</source> <source>Check not found. Please, ensure correctness of entered data.</source>
<translation>Check not found. Please, ensure correctness of entered data.</translation> <translation>Check not found. Please, ensure correctness of entered data.</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="303"/> <location filename="../mainwindow.cpp" line="308"/>
<source>Check was not found</source> <source>Check was not found</source>
<translation>Check was not found</translation> <translation>Check was not found</translation>
</message> </message>
@ -309,12 +311,12 @@
<translation type="vanished">Error in parsing</translation> <translation type="vanished">Error in parsing</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="147"/> <location filename="../mainwindow.cpp" line="149"/>
<source>Please, select a picture where QR code that contains info about check is present</source> <source>Please, select a picture where QR code that contains info about check is present</source>
<translation>Please, select a picture where QR code that contains info about check is present</translation> <translation>Please, select a picture where QR code that contains info about check is present</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="149"/> <location filename="../mainwindow.cpp" line="151"/>
<source>Picture was not selected</source> <source>Picture was not selected</source>
<translation>Picture was not selected</translation> <translation>Picture was not selected</translation>
</message> </message>
@ -532,7 +534,7 @@
<translation>Choose</translation> <translation>Choose</translation>
</message> </message>
<message> <message>
<location filename="../scenes/outputdialog.ui" line="73"/> <location filename="../scenes/outputdialog.ui" line="76"/>
<source>Print header</source> <source>Print header</source>
<translation>Print header</translation> <translation>Print header</translation>
</message> </message>

View File

@ -70,7 +70,7 @@
<translation type="vanished">Магазин</translation> <translation type="vanished">Магазин</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="95"/> <location filename="../scenes/mainwindow.ui" line="107"/>
<source>Parse</source> <source>Parse</source>
<translation>Парсить</translation> <translation>Парсить</translation>
</message> </message>
@ -113,13 +113,13 @@
<translation type="vanished">0000000000000000</translation> <translation type="vanished">0000000000000000</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="121"/> <location filename="../scenes/mainwindow.ui" line="173"/>
<source>FN (Fiscal Number)</source> <source>FN (Fiscal Number)</source>
<translatorcomment>Фискальный Норма</translatorcomment> <translatorcomment>Фискальный Норма</translatorcomment>
<translation>ФН</translation> <translation>ФН</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="58"/> <location filename="../scenes/mainwindow.ui" line="61"/>
<source>FD (Fiscal Document)</source> <source>FD (Fiscal Document)</source>
<translatorcomment>Фискальный Документ</translatorcomment> <translatorcomment>Фискальный Документ</translatorcomment>
<translation>ФД</translation> <translation>ФД</translation>
@ -133,89 +133,89 @@
<translation type="obsolete">Назад</translation> <translation type="obsolete">Назад</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="206"/> <location filename="../scenes/mainwindow.ui" line="144"/>
<source>Stop server</source> <source>Stop server</source>
<translation>Остановить сервер</translation> <translation>Остановить сервер</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="167"/> <location filename="../scenes/mainwindow.ui" line="74"/>
<source>Choose image on your PC</source> <source>Choose image on your PC</source>
<translation>Выбрать изображение на компьютере</translation> <translation>Выбрать изображение на компьютере</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="38"/> <location filename="../scenes/mainwindow.ui" line="94"/>
<location filename="../scenes/mainwindow.ui" line="154"/> <location filename="../scenes/mainwindow.ui" line="277"/>
<source>or</source> <source>or</source>
<translation>или</translation> <translation>или</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="141"/> <location filename="../scenes/mainwindow.ui" line="157"/>
<source>Use your phone as a QR code scanner</source> <source>Use your phone as a QR code scanner</source>
<translation>Использовать телефон как сканнер QR</translation> <translation>Использовать телефон как сканнер QR</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="82"/> <location filename="../scenes/mainwindow.ui" line="241"/>
<source>FI (Fiscal Identifier)</source> <source>FI (Fiscal Identifier)</source>
<translatorcomment>Фискальный Признак</translatorcomment> <translatorcomment>Фискальный Признак</translatorcomment>
<translation>ФП</translation> <translation>ФП</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="273"/> <location filename="../scenes/mainwindow.ui" line="313"/>
<source>Add new check</source> <source>Add new check</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="263"/> <location filename="../scenes/mainwindow.ui" line="300"/>
<source>Clear</source> <source>Clear</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="45"/> <location filename="../scenes/mainwindow.ui" line="81"/>
<source>Date and time of purchase</source> <source>Date and time of purchase</source>
<translation>Дата и время покупки</translation> <translation>Дата и время покупки</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="237"/> <location filename="../scenes/mainwindow.ui" line="183"/>
<source>Operation type</source> <source>Operation type</source>
<translation>Тип операции</translation> <translation>Тип операции</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="250"/> <location filename="../scenes/mainwindow.ui" line="48"/>
<source>Parse an E-Mail</source> <source>Parse an E-Mail</source>
<translation>Парсить E-Mail</translation> <translation>Парсить E-Mail</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="214"/> <location filename="../scenes/mainwindow.ui" line="115"/>
<source>Funds income</source> <source>Funds income</source>
<translation>Приход средств</translation> <translation>Приход средств</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="219"/> <location filename="../scenes/mainwindow.ui" line="120"/>
<source>Funds return</source> <source>Funds return</source>
<translation>Возврат средств</translation> <translation>Возврат средств</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="224"/> <location filename="../scenes/mainwindow.ui" line="125"/>
<source>Funds spend</source> <source>Funds spend</source>
<translation>Расход средств</translation> <translation>Расход средств</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="229"/> <location filename="../scenes/mainwindow.ui" line="130"/>
<source>Spends return</source> <source>Spends return</source>
<translation>Возврат расхода</translation> <translation>Возврат расхода</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="72"/> <location filename="../scenes/mainwindow.ui" line="32"/>
<source>Checks to parse</source> <source>Checks to parse</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="108"/> <location filename="../scenes/mainwindow.ui" line="264"/>
<source>Settings</source> <source>Settings</source>
<translation>Настройки</translation> <translation>Настройки</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="128"/> <location filename="../scenes/mainwindow.ui" line="251"/>
<source>Total</source> <source>Total</source>
<translation>Итого</translation> <translation>Итого</translation>
</message> </message>
@ -224,67 +224,77 @@
<translation type="vanished">Парсер чеков</translation> <translation type="vanished">Парсер чеков</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="101"/> <location filename="../mainwindow.cpp" line="103"/>
<source>QR code for binaryeye to connect</source> <source>QR code for binaryeye to connect</source>
<translation>QR код для подключения BinaryEye</translation> <translation>QR код для подключения BinaryEye</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="102"/> <location filename="../mainwindow.cpp" line="104"/>
<source>I&apos;ve scanned</source> <source>I&apos;ve scanned</source>
<translation>Просканировал</translation> <translation>Просканировал</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="108"/> <location filename="../mainwindow.cpp" line="110"/>
<source>Could not start http server. 10 times in a row random port was occupied. Either you should run for a lottery ticket, or the problem is in the program. If the lottery ticket wasn&apos;t lucky, please, contact the developer.</source> <source>Could not start http server. 10 times in a row random port was occupied. Either you should run for a lottery ticket, or the problem is in the program. If the lottery ticket wasn&apos;t lucky, please, contact the developer.</source>
<translation>Не смог поднять HTTP сервер. 10 раз подряд случайно выбранный порт был занят. Либо Вам следует бежать за лоттерейным билетом, или в программе баг. Если лотерейный билет не был выигрышным, пожалуйста, сообщите разработчику.</translation> <translation>Не смог поднять HTTP сервер. 10 раз подряд случайно выбранный порт был занят. Либо Вам следует бежать за лоттерейным билетом, или в программе баг. Если лотерейный билет не был выигрышным, пожалуйста, сообщите разработчику.</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="110"/> <location filename="../mainwindow.cpp" line="112"/>
<source>Could not start http server.</source> <source>Could not start http server.</source>
<translation>Не получилось запустить HTTP сервер.</translation> <translation>Не получилось запустить HTTP сервер.</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="154"/> <location filename="../mainwindow.cpp" line="156"/>
<source>Selected image: </source> <source>Selected image: </source>
<translation>Выбранное изображение: </translation> <translation>Выбранное изображение: </translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="187"/> <location filename="../mainwindow.cpp" line="189"/>
<source>This feature is under development. Wait it to appear in next updates.</source> <source>This feature is under development. Wait it to appear in next updates.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="189"/> <location filename="../mainwindow.cpp" line="191"/>
<source>Under development</source> <source>Under development</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="287"/> <location filename="../mainwindow.cpp" line="203"/>
<source>Please, add check(s) to parse</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="205"/>
<source>No checks to parse</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="292"/>
<source>Captcha was not solved correctly!</source> <source>Captcha was not solved correctly!</source>
<translation>Капча была решена неверно!</translation> <translation>Капча была решена неверно!</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="289"/> <location filename="../mainwindow.cpp" line="294"/>
<source>Captcha is incorrect</source> <source>Captcha is incorrect</source>
<translation>Капча введена неверно</translation> <translation>Капча введена неверно</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="294"/> <location filename="../mainwindow.cpp" line="299"/>
<source>Internal server error. Please, try again later.</source> <source>Internal server error. Please, try again later.</source>
<translation>Внутренняя ошибка сервера. Пожалуйста, попробуйте снова позже.</translation> <translation>Внутренняя ошибка сервера. Пожалуйста, попробуйте снова позже.</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="296"/> <location filename="../mainwindow.cpp" line="301"/>
<source>Internal server error</source> <source>Internal server error</source>
<translation>Внутренняя ошибка сервера</translation> <translation>Внутренняя ошибка сервера</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="301"/> <location filename="../mainwindow.cpp" line="306"/>
<source>Check not found. Please, ensure correctness of entered data.</source> <source>Check not found. Please, ensure correctness of entered data.</source>
<translation>Чек не найден. Пожалуйста, убедитесь в правильности введённых данных.</translation> <translation>Чек не найден. Пожалуйста, убедитесь в правильности введённых данных.</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="303"/> <location filename="../mainwindow.cpp" line="308"/>
<source>Check was not found</source> <source>Check was not found</source>
<translation>Чек не найден</translation> <translation>Чек не найден</translation>
</message> </message>
@ -297,12 +307,12 @@
<translation type="vanished">Ошибка в парсинге</translation> <translation type="vanished">Ошибка в парсинге</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="147"/> <location filename="../mainwindow.cpp" line="149"/>
<source>Please, select a picture where QR code that contains info about check is present</source> <source>Please, select a picture where QR code that contains info about check is present</source>
<translation>Пожалуйста, выберете изображение, содержащее QR код с информацией о чеке</translation> <translation>Пожалуйста, выберете изображение, содержащее QR код с информацией о чеке</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="149"/> <location filename="../mainwindow.cpp" line="151"/>
<source>Picture was not selected</source> <source>Picture was not selected</source>
<translation>Изображение не было выбрано</translation> <translation>Изображение не было выбрано</translation>
</message> </message>
@ -520,7 +530,7 @@
<translation>Выбрать</translation> <translation>Выбрать</translation>
</message> </message>
<message> <message>
<location filename="../scenes/outputdialog.ui" line="73"/> <location filename="../scenes/outputdialog.ui" line="76"/>
<source>Print header</source> <source>Print header</source>
<translation>Печатать заголовок</translation> <translation>Печатать заголовок</translation>
</message> </message>

View File

@ -0,0 +1,94 @@
#include "checkqueuetablemodel.h"
#include <iostream>
CheckQueueTableModel::CheckQueueTableModel(std::vector<Check> *checks, QObject *parent)
: checks(checks), QAbstractTableModel{parent}
{}
int CheckQueueTableModel::rowCount(const QModelIndex &parent) const { return checks->size(); }
int CheckQueueTableModel::columnCount(const QModelIndex &parent) const { return 3; }
QVariant CheckQueueTableModel::data(const QModelIndex &index, int role) const {
if (role != Qt::DisplayRole) return QVariant();
Check& c = (*checks).at(index.row());
switch (index.column()) {
case 0:
return QVariant::fromValue(QString::fromStdString(c.get_date()));
break;
case 1:
return QVariant::fromValue(c.get_total());
break;
case 2:
return QVariant::fromValue(QString("кнопка"));
break;
}
return QVariant();
}
bool CheckQueueTableModel::setData(const QModelIndex &index, const QVariant &value, int role) {
if (role == Qt::EditRole) {
if (!checkIndex(index))
return false;
unsigned int row = index.row();
switch (index.column()) {
case 0:
checks->at(row).set_date(value.value<std::string>());
break;
case 1:
checks->at(row).set_total(value.value<double>());
break;
case 2:
// delete Button
break;
}
//for presentation purposes only: build and emit a joined string
// QString result = "dick";
// for (int row = 0; row < checks->size(); row++) {
// for (int col= 0; col < 3; col++)
// result += m_gridData[row][col] + ' ';
// }
// emit editCompleted(result);
return true;
}
return false;
}
QVariant CheckQueueTableModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
switch (section) {
case 0:
return tr("Date&Time");
break;
case 1:
return tr("Total");
break;
case 2:
return tr("Delete button");
break;
}
}
return QVariant();
}
Qt::ItemFlags CheckQueueTableModel::flags(const QModelIndex &index) const {
Qt::ItemFlags defaultFlags = QAbstractTableModel::flags(index);
if (index.isValid())
return Qt::ItemIsDragEnabled | defaultFlags;
else
return Qt::ItemIsDropEnabled | defaultFlags;
// return Qt::ItemIsSelectable | QAbstractTableModel::flags(index);
}
bool CheckQueueTableModel::insertRow(int row, int count, const QModelIndex &parent) {
beginInsertRows(QModelIndex(), row, row+count-1);
for (int i = 0; i < count; ++i)
checks->emplace(checks->begin() + row, Check());
endInsertRows();
return true;
}

View File

@ -0,0 +1,30 @@
#ifndef CHECKQUEUETABLEMODEL_H
#define CHECKQUEUETABLEMODEL_H
#include <QAbstractTableModel>
#include <check/check.h>
class CheckQueueTableModel : public QAbstractTableModel
{
Q_OBJECT
public:
explicit CheckQueueTableModel(std::vector<Check> *checks, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool insertRow(int row, int count, const QModelIndex &parent = QModelIndex());
private:
std::vector<Check> *checks;
signals:
void editCompleted(const QString &);
};
#endif // CHECKQUEUETABLEMODEL_H