|
CenGen - Генератор ценников
1.1
|
00001 #ifndef CENGEN_H 00002 #define CENGEN_H 00003 00004 #include <QMainWindow> 00005 #include <QPrinter> 00006 #include <QPrintDialog> 00007 #include <QTabWidget> 00008 #include <QScrollArea> 00009 #include <QVBoxLayout> 00010 #include <QFile> 00011 #include <QRectF> 00012 #include <QStringList> 00013 #include <QComboBox> 00014 #include <QCheckBox> 00015 #include <QProgressBar> 00016 #include <QGraphicsScene> 00017 #include <QGraphicsView> 00018 #include <QSettings> 00019 #include <QGroupBox> 00020 #include <QSpinBox> 00021 #include <QRadioButton> 00022 #include <QLineEdit> 00023 #include <QCalendarWidget> 00024 #include <QToolBar> 00025 #include <QStatusBar> 00026 #include <QMenuBar> 00027 #include <QAction> 00028 #include <QMap> 00029 #include <QApplication> 00030 #include <QClipboard> 00031 #include <QNetworkAccessManager> 00032 #include <QNetworkRequest> 00033 #include <QNetworkReply> 00034 #include "tinformer.h" 00035 #include "barcode.h" 00036 #include "cen_viewer.h" 00037 #include "bvalidator.h" 00038 #include "sql_validator.h" 00039 #include "tnvalidator.h" 00040 #include "dialog.h" 00041 #include "editor.h" 00042 #include "about.h" 00043 #include "mainTableWidget.h" 00044 #include "autozakaz.h" 00045 #include "sellFilterWidget.h" 00046 00047 QT_BEGIN_NAMESPACE 00048 class QPushButton; 00049 class QTableWidget; 00050 class QLabel; 00051 class QFile; 00052 class QScrollArea; 00053 class QVBoxLayout; 00054 class QSpinBox; 00055 class QPrinter; 00056 class QComboBox; 00057 class QGraphicsScene; 00058 class QTabWidget; 00059 class QValidator; 00060 class QStringList; 00061 class QToolBar; 00062 00063 class BarcodeValidator; 00064 class Tinformer; 00065 class Barcode; 00066 class Cennic; 00067 //class SellFilterWidget; 00068 QT_END_NAMESPACE 00069 00070 //namespace Ui { 00071 // class cengen; 00072 //} 00073 00074 class cengen : public QMainWindow, public ImageBox 00075 { 00076 Q_OBJECT 00077 public: 00078 cengen(QWidget *parent = 0); 00079 ~cengen(); 00080 void writeSettings(); 00081 void readSettings(); 00082 void make_actions(); 00083 void make_toolBar(); 00084 void make_mainMenu(); 00085 void make_search_tab(); 00086 void make_shablon_tab(); 00087 void make_preview_tab(); 00088 void make_source_tab(); 00089 void make_filter_tab(); 00090 void make_fieldList_tab(); 00091 void make_sellSettings_tab(); 00092 void make_ext_app_tab(); 00093 void make_status_bar(); 00094 void set_org_name(QString org, QString prog); 00095 void trigger_source_selection(bool state); 00096 bool load_source_settings_file(QString fileName); 00097 void load_filter_settings_file(QString fileName); 00098 void save_source_settings_file(QString fileName); 00099 void turn_filter_ON(); 00100 void open_tovar_list(QString fileName); 00101 void load_all_records(); 00102 void set_ext_shablon_name(QString fileName); 00103 00104 //порядок вкладок 00105 struct TabsOrder 00106 { 00107 static int const Search = 0; 00108 static int const Shablon = 1; 00109 static int const Preview = 2; 00110 static int const Source = 3; 00111 static int const fList = 4; 00112 static int const Filter = 5; 00113 static int const Sell = 6; 00114 static int const App = 7; 00115 }; 00116 00117 protected: 00118 void changeEvent(QEvent *e); 00119 00120 private: 00121 QString org_name, app_name; 00122 00123 TabsOrder order; 00124 00125 //статусбар 00126 QStatusBar* statusBar; 00127 QLabel *ui_statusLabel; 00128 QProgressBar *progressBar; 00129 00130 //виджеты вкладки поиска 00131 QWidget *tab1; 00132 QGridLayout *layTab1, 00133 *layBox1, *layBox5, *layBox6; 00134 QLineEdit* ui_lineEdit; 00135 MainTableWidget *tableWidget; 00136 00137 00138 //виджеты вкладки предварительного просмотра 00139 QWidget *tab3; 00140 QGridLayout *layTab3; 00141 QGraphicsScene* currentScene; 00142 QGraphicsView* view; //используется для отображения превью 00143 00144 00145 //виджеты вкладки выбора шаблона и параметров страницы 00146 QWidget *tab2; 00147 QBoxLayout *layTab2; 00148 QGroupBox *ui_groupBox_2; 00149 QGroupBox *ui_groupBox_3; 00150 QBoxLayout *layBoxT2B2; 00151 QPushButton *ui_selecctShablonButton; 00152 QLabel *ui_label; 00153 QPushButton *ui_show_editor_button; 00154 QLabel *label24; 00155 QComboBox *shablonBox; 00156 bool previewed; 00157 00158 00159 QGridLayout *layBoxT2B3; 00160 QComboBox *comboBox; 00161 QLineEdit *ui_lineH, *ui_lineW, *ui_lineH_2, *ui_lineW_2; 00162 QLabel *label2, *label3, *label4, *label5, *labelOrient, *labelZero; 00163 QLabel *totalCennicOnPage; 00164 QRadioButton *ui_radioButton_6; 00165 QRadioButton *ui_radioButton_7; 00166 00167 QLabel *zoomLabel; 00168 QSpinBox *zoomBox; 00169 00170 QLabel *otstupLabel1; 00171 QLineEdit *otstupTopLine; 00172 00173 //QLabel *label32; 00174 QCheckBox *expandBox; 00175 00176 00177 //виджеты вкладки источника данных 00178 QWidget *tab4; 00179 QGroupBox *ui_groupDBF, *ui_groupSQL, *ui_groupOpisateli; 00180 QGridLayout *layTab4; 00181 QGridLayout *laySQL, *layDBF, *layOpisateli; 00182 //поля для параметров MySQL-базы данных 00183 QLineEdit *ui_lineHost, *ui_lineName, *ui_lineUser, *ui_linePort, *ui_linePass; 00184 QLabel *label6, *label10, *label9, *label7, *label8, *label11; 00185 QPushButton *ui_connectMySQLButton; 00186 QComboBox *ui_mysql_table_selector_comboBox; 00187 00188 QLabel *label16, *labelDBFname; 00189 QPushButton *ui_selectSourceDBF_file_button; 00190 00191 //а эти для определения, где в таблице какое поле 00192 QComboBox *ui_comboTnomer, *ui_comboTname, *ui_comboTbarcode, *ui_comboTprice; 00193 QLabel *label12, *label13, *label14, *label15; 00194 QPushButton *saveSourceButton, *loadSourceButton; 00195 00196 00197 //виджеты вкладки фильтра 00198 QWidget *tab5; 00199 QBoxLayout *layTab5; 00200 QGroupBox* ui_filterBox; 00201 QGridLayout *laytab5g1; 00202 QPushButton *ui_filterFileSelectButton; 00203 QComboBox *ui_filterWhatBox, *ui_filterWhereBox, 00204 *ui_filterWhatToFoundBox, *ui_filterMethodBox; 00205 QLineEdit* ui_filterLineText; 00206 QLabel *label18, *label19, *label20, *label21, *label22, *label23, *label23a, *label18a; 00207 00208 QGroupBox *filBoxCheck; 00209 QGridLayout *filCheckLay; 00210 QLabel *label30, *label31; 00211 QComboBox *filterCheckOutBox, *filterCheckInBox; 00212 QPushButton *saveFilterSettings, *loadFilterSettings; 00213 QCheckBox *delete_filtered_box; 00214 00215 00216 00217 //виджеты вкладки выбора списка полей для основной таблицы 00218 QWidget *tab6; 00219 QGridLayout *layTab6; 00220 QGridLayout *layFields; 00221 QLabel *label25, *label26, *label27, *label28; 00222 QMap<QString, bool> fullFieldsList; //список вообще всех полей 00223 00224 00225 //виджеты вкладки для управления файлом продаж 00226 SellFilterWidget *sellFilter; 00227 00228 autozakaz_config acfg; 00229 00230 00231 //виджеты вкладки настроек внешней программы 00232 QWidget *tab8; 00233 QGridLayout *layTab8; 00234 QLineEdit *ext_prog_name_edit, *ext_conf_edit, *ext_shablon_name_edit; 00235 QPushButton *select_ext_app_button, *select_ext_conf_file, *select_ext_shablon_button; 00236 00237 00238 00239 QSettings m_settings; 00240 int mainTableWidth, mainTableHeith; 00241 00242 editor* shablon_editor; 00243 00244 //валидаторы для штрих-кода, номера и текста 00245 BarcodeValidator* ui_bvalidator; 00246 TNValidator* ui_nvalidator; 00247 SqlValidator* ui_svalidator; 00248 00249 00250 00251 //контролы SQL и DBF 00252 00253 QRadioButton *ui_radioButton_1, 00254 *ui_radioButton_2, 00255 *ui_radioButton_3, 00256 *ui_radioButton_5; 00257 QGroupBox *ui_groupBox, *ui_groupBox_6; 00258 //QTableWidget* tableWidget; 00259 int sizeDeltaX; //разница в ширине между основным окном и таблицей 00260 int sizeDeltaY; 00261 QLabel *ui_countLabel; 00262 QTabWidget* ui_tabWidget; 00263 //QFile file; //файл шаблона 00264 QString currShablonFileName; 00265 QStringList shablonList; //список шаблонов в текущей дирректории 00266 //QString shablonPath; 00267 QDomDocument domDoc; 00268 QDomElement shablonElement; 00269 QPushButton *ui_pushButton, *ui_maxButton; 00270 00271 QString method; //метод поиска товара - номер, штрихкод или название 00272 int db_source; //источник данных: MySQL(1) или DBF(0) 00273 00274 00275 Tinformer* my_informer; 00276 dbTranslator config, filterConfig; //что есть что в базе данных 00277 int config_index[4]; //индекс для комбобоксов 00278 SqlConfig* sql; 00279 DbfConfig* dbf; 00280 Barcode* my_barcode; 00281 bool file_is_ready; 00282 bool db_is_ready; 00283 bool describer_is_ready; 00284 00285 00286 //переменные для работы фильтра 00287 bool filter_is_on; 00288 DbfConfig filterDbf; 00289 Tinformer* filterInformer; 00290 00291 QString pageSize; //формат бумаги - А4, А5 00292 QString paperOrientation; // книжная или альбомная 00293 int Crows, Ccols; //количество строк и столбцов в шаблоне ценника 00294 float pageW, pageH; //ширина и высота бумаги выбранного формата (в мкм) 00295 float zoomedPageW, zoomedPageH; //размеры немасштабированного поля 00296 float otstupTop; //отступ от верхней границы листа 00297 float zoom; //масштаб предпросмотра 00298 QRectF rectCen; //размер одного ценника из шаблона 00299 QList<QRectF> pages; //области для постраничной печати 00300 QStringList opisateli; 00301 00302 00303 QSpinBox* ui_spinLimit; 00304 00305 //переменные для скачивания файлов обновлений 00306 QNetworkAccessManager *manager, *manager2; 00307 int update_counter, update_count; 00308 QString currentUpdatingFile; 00309 QString updatingPath; 00310 QMap<QNetworkReply*, QString> up_files; 00311 ListFoundedItemsDialog* update_dlg; 00312 00313 bool unfinishedHttp; 00314 00315 00316 QToolBar* ui_mainToolBar; 00317 QMenuBar* mainMenu; 00318 QMenu *menuFile, *menuEdit, *menuSell, *menuHelp; 00319 QMenu *cenMenu; 00320 QMenu *macroMenu; 00321 QMenu *selectFoundMethodMenu; 00322 00323 QAction* action_new; //новый файл 00324 QAction* action_exit; //выход 00325 QAction* action_save; //сохранить 00326 QAction* action_open; //загрузить список 00327 QAction* action_make; //сформировать ценники 00328 QAction* action_scale_up; 00329 QAction* action_scale_down; //масштаб - меньше и больше 00330 QAction* action_print; 00331 QAction* action_about; 00332 QAction* action_minus; 00333 QAction* apply_filter_on_current_list; 00334 QAction* interchange_prices_in_table; 00335 QAction* intellect_interchange_prices_in_table; 00336 QAction* action_verify_barcode; 00337 QAction* action_update_prices; 00338 QAction* action_update_prices_in_minus; 00339 QAction* action_update_names; 00340 QAction* action_search_by_tnomer_in_clipboard; 00341 QAction* action_load_tovar_list_from_clipboard; 00342 QAction* action_export_tovar_list_to_clipboard; 00343 QAction* action_on_off_filter; 00344 QAction* action_set_special_shablon_to_zero_price2; 00345 QAction* action_sell_filter; 00346 QAction* action_render_in_external_app; 00347 QAction* action_open_in_external_app; 00348 QAction* action_expand_list; 00349 QAction* action_select_method_barcode; 00350 QAction* action_select_method_tnomer; 00351 QAction* action_select_method_tname; 00352 QAction* action_get_sum_of_tovar; 00353 QAction* action_program_update; 00354 QAction* action_zakaz10; 00355 QAction* action_remove_zero_items; 00356 QAction* action_left_items_with_zero_price2; 00357 QAction* action_group_same_shablons; 00358 QAction* action_check_line_prices; 00359 QAction* action_start_macro; 00360 QAction* action_collaps_same_items; 00361 QAction* action_get_sold_items; 00362 00363 00364 private slots: 00365 void httpRequestFinished(QNetworkReply* rpl); 00366 void httpOneFileFinished(QNetworkReply* rpl); 00367 00368 void get_method_from_ui(); 00369 00370 void on_source_changed_toDBF(); 00371 void on_source_changed_toMySQL(); 00372 void on_opisateli_updated(); 00373 void on_mysql_table_selector_comboBox_activated(QString ); 00374 void on_connectMySQLButton_clicked(); 00375 void on_action_print_triggered(); 00376 void on_action_scaleDown_triggered(); 00377 void on_action_scaleUp_triggered(); 00378 void on_comboBox_activated(QString ); 00379 void on_tabWidget_currentChanged(int index); 00380 void on_selectShablonButton_clicked(); 00381 void on_action_make_triggered(); 00382 void on_apply_filter_on_current_list_triggered(); 00383 void on_interchange_prices_in_table_triggered(); 00384 void on_intellect_interchange_prices_in_table_triggered(); 00385 void on_action_search_by_tnomer_in_clipboard_triggered(); 00386 void on_action_load_tovar_list_in_clipboard_triggered(); 00387 void on_action_export_tovar_list_to_clipboard(); 00388 void on_action_verify_barcode(); 00389 void on_action_update_prices(); 00390 void update_prices(bool AskUserToSave = true); 00391 void on_action_update_prices_in_minus(); 00392 void on_action_update_names(); 00393 void on_action_set_special_shablon_to_zero_price2(); 00394 void on_action_sell_filter_triggered(); 00395 void on_action_render_in_external_app(); 00396 void on_action_open_in_external_app(); 00397 void on_action_expand_triggered(bool); 00398 void on_action_select_method_barcode(); 00399 void on_action_select_method_tnomer(); 00400 void on_action_select_method_tname(); 00401 void on_action_get_sum_of_tovar(); 00402 void on_action_program_update(); 00403 void on_action_zakaz10_triggered(); 00404 void on_action_remove_zero_items(); 00405 void on_action_left_itms_zero_price2(); 00406 void on_action_check_line_prices(); 00407 void on_action_start_macro(); 00408 void on_collaps_same_items(); 00409 QVector<Tovar> collaps_same_items(QVector<Tovar> inputList); 00410 void on_action_get_sold_items(); 00411 00412 void on_lineEdit_returnPressed(); 00413 void tovar_search(); 00414 void new_line_ready(); 00415 void update_values(); //обновить значеня шаблона в UI-форме 00416 QDomDocument read_file_shablon(QString str); //прочитать шаблон 00417 void describe_shablon(QDomDocument shablon); 00418 void generate_preview(); 00419 void update_ui_tb_fields(QStringList list); 00420 void update_ui_db_controls(); 00421 void update_ui_connection_established(); 00422 void on_saveSourceButton(); 00423 void on_loadSourceButton(); 00424 void on_saveFilterSettings(); 00425 void on_loadFilterSettings(); 00426 //void on_selectSellFileButtonClicked(); 00427 //void check_sell_file(); 00428 //void updateSellTab(); 00429 void select_ext_conf_button_clicked(); 00430 void select_ext_app_button_clicked(); 00431 void select_ext_shablon_button_clicked(); 00432 void on_data_changed(); 00433 00434 00435 QList<Tovar> show_found_items(QList<Tovar> inputList); 00436 QList<Tovar> apply_filter(QList<Tovar> inputList, bool startProgressBar = true); 00437 QRectF get_shablon_rect(const QDomNode& node); 00438 QString get_shablon_name(const QDomNode& node); 00439 bool read_opisateli_from_settings(); 00440 void set_opisateli_from_settings(); 00441 00442 void on_selectSourceDBF_file_button_clicked(); 00443 void on_spinLimit_valueChanged(int ); 00444 void on_maxButton_clicked(); 00445 00446 00447 void on_show_editor_button_clicked(); 00448 void on_action_save_triggered(); 00449 void on_action_open_triggered(); 00450 void on_action_new_triggered(); 00451 00452 QList<Tovar> convert_xml_into_tovar_list(QDomDocument doc); 00453 QDomDocument convert_tovar_list_into_xml(QList<Tovar> tovarList); 00454 QList<Tovar> minus(QList<Tovar> oldList, QList<Tovar> newList); 00455 QList<Tovar> expand(QList<Tovar> list); 00456 QList<Tovar> group(QList<Tovar> list); 00457 00458 void on_action_minus_triggered(); 00459 void on_filterBox_toggled(bool arg1); 00460 void on_filterFileSelectButton_clicked(); 00461 void on_filterFileName_changed(); 00462 void read_filter_settings(); 00463 00464 void on_radioButton_6_clicked(); 00465 void on_radioButton_7_clicked(); 00466 00467 void on_action_about_triggered(); 00468 00469 void on_shablon_name_changed(QString name); 00470 00471 void on_shablonList_combo_changed(int index); 00472 00473 void on_fieldListBox_checked(bool status); 00474 00475 void save_tovar_list_into_file(QString name, QList<Tovar> spisok, bool ask_for_fileName = true); 00476 00477 void ask_user_to_save_wrong_tovar_list(QList<Tovar> spisok); 00478 00479 bool save_tovar_list_into_dbf(QString fileName, QList<Tovar> spisok); 00480 00481 void debug_tovar(QList<Tovar> list); 00482 00483 void execute_macro_file(QString fileName); 00484 00485 }; 00486 00487 #endif // CENGEN_H