void DatabaseWidget::editDataInit() { FormDialog fDialog(this, FormDialog::SelectingRecord, "Numer wtryskiwacza:") ; fDialog.exec() ; if (fDialog.canceled) return ; const QString filePathName(QDir::currentPath() + "/DatabaseSx/" + fDialog.company + '/' + fDialog.type + '/' + fDialog.number + ".txt"); QFile file(filePathName); if (!file.exists() ) { QMessageBox::critical(this, "Błąd", "Nie udało się wczytać nastaw z bazy. Może nastawy do tego wtryskiwacza nie istnieją?") ; return ; } file.open(QFile::Text | QFile::ReadOnly) ; QTextStream str(&file) ; QStringList SL ; for (int i = 0 ; i < 40 ; i++) { SL.append(str.readLine() ) ; } file.close() ; str.flush() ; if(dataWidget) { stackedWidget->removeWidget(dataWidget); delete dataWidget; dataWidget = nullptr; } const QString title(fDialog.company + " - " + fDialog.type + " - " + fDialog.number); dataWidget =new DataWidget(stackedWidget, title, SL, filePathName); stackedWidget->addWidget(DATA_WIDGET, dataWidget); stackedWidget->slideInIdx(DATA_WIDGET); connect(dataWidget, SIGNAL(dialogClosed()), this, SLOT(editDataClosed())); }
void DatabaseWidget::deleteDataFromDatabase() { FormDialog fDialog(this, FormDialog::SelectingRecord, "Numer wtryskiwacza:") ; fDialog.exec() ; if (fDialog.canceled) return ; QFile file(QDir::currentPath() + "/DatabaseSx/" + fDialog.company + '/' + fDialog.type + '/' + fDialog.number + ".txt") ; if(file.remove()) QMessageBox::information(this, "Sukces", "Nastawy zostały pomyślnie usunięte z bazy danych.") ; else QMessageBox::critical(this, "Błąd", "Nie udało się usunąć nastaw z bazy. Może nastawy \ do tego wtryskiwacza nigdy nie istniały?") ; } void DatabaseWidget::showResult() { FormDialog dialog(this, FormDialog::SelectingRecord, "Nazwa rekordu:") ; dialog.exec() ; if (dialog.canceled) return ; QFile dbFile; QFile dbResFile; dbFile.setFileName(QDir::currentPath() + "/DatabaseSx/" + dialog.company + "/" + dialog.type + "/" + dialog.number + ".txt"); dbResFile.setFileName(QDir::currentPath() + "/DatabaseSx/" + dialog.company + "/" + dialog.type + "/Results/" + dialog.number + ".txt"); if(!dbFile.exists() || !dbResFile.exists()) { QMessageBox::warning(this, "Wynik" , "Wynik o podanej nazwie nie istnieje w bazie danych."); return; } QStringList dbFileSL ; {//read from file dbFile.open(QFile::Text | QFile::ReadOnly) ; QTextStream str(&dbFile) ; for (int i = 0 ; i < 40 ; i++) dbFileSL.append(str.readLine() ) ; dbFile.close() ; } QStringList dbResFileSL; {//read from file dbResFile.open(QFile::Text | QFile::ReadOnly) ; QTextStream str(&dbResFile) ; for (int i = 0 ; i < 100 ; i++) dbResFileSL.append(str.readLine() ) ; dbResFile.close() ; } if(showResultWiget) { stackedWidget->removeWidget(showResultWiget); delete showResultWiget; showResultWiget = nullptr; } const QString hwName = dialog.company + "-" + dialog.type + "-" + dialog.number; showResultWiget =new ResultWidget(stackedWidget, dbFileSL, dbResFileSL, hwName, SHOW_ONLY); stackedWidget->addWidget(SHOWRESULT_WIDGET, showResultWiget); stackedWidget->slideInIdx(SHOWRESULT_WIDGET); } void DatabaseWidget::editResultInit() { FormDialog dialog(this, FormDialog::SelectingRecord, "Nazwa rekordu:") ; dialog.exec() ; if (dialog.canceled) return ; QFile dbFile; QFile dbResFile; dbFile.setFileName(QDir::currentPath() + "/DatabaseSx/" + dialog.company + "/" + dialog.type + "/" + dialog.number + ".txt"); dbResFile.setFileName(QDir::currentPath() + "/DatabaseSx/" + dialog.company + "/" + dialog.type + "/Results/" + dialog.number + ".txt"); if(!dbFile.exists() || !dbResFile.exists()) { QMessageBox::warning(this, "Wynik" , "Wynik o podanej nazwie nie istnieje w bazie danych."); return; } QStringList dbFileSL ; {//read from file dbFile.open(QFile::Text | QFile::ReadOnly) ; QTextStream str(&dbFile) ; for (int i = 0 ; i < 40 ; i++) dbFileSL.append(str.readLine() ) ; dbFile.close() ; } QStringList dbResFileSL; {//read from file dbResFile.open(QFile::Text | QFile::ReadOnly) ; QTextStream str(&dbResFile) ; for (int i = 0 ; i < 100 ; i++) dbResFileSL.append(str.readLine() ) ; dbResFile.close() ; } if(showResultWiget) { stackedWidget->removeWidget(showResultWiget); delete showResultWiget; showResultWiget = nullptr; } const QString hwName = dialog.company + "-" + dialog.type + "-" + dialog.number; showResultWiget =new ResultWidget(stackedWidget, dbFileSL, dbResFileSL, hwName, EDIT); stackedWidget->addWidget(SHOWRESULT_WIDGET, showResultWiget); stackedWidget->slideInIdx(SHOWRESULT_WIDGET); connect(showResultWiget, SIGNAL(dialogClosed()), this, SLOT(editResultClosed())); }
LONG FAR PASCAL WndProc(HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam) { int NewX, NewY, i; switch (messg) { case WM_PAINT: PaintWindow(hWnd); break; case WM_MOUSEMOVE: MouseX = LOWORD(lParam) - 32; MouseY = HIWORD(lParam) - 45; Counter2 = 0; break; case WM_TIMER: switch (State) { case 0: State = 4; Pic = 0; Counter = 0; LastX = MouseX; LastY = MouseY; break; case 1: if ((LastX != MouseX) || (LastY != MouseY)) { if (MouseX > (LastX + SPEED)) { NewX = LastX + SPEED; Sec = 0; } else if (MouseX < (LastX - SPEED)) { NewX = LastX - SPEED; Sec = 8; } else { NewX = MouseX; } if (MouseY > (LastY + SPEED)) { NewY = LastY + SPEED; } else if (MouseY < (LastY - SPEED)) { NewY = LastY - SPEED; } else { NewY = MouseY; } DisplayPic(hWnd, NewX, NewY, Pic + Sec); Pic = ((Pic + 1) % 8); LastX = NewX; LastY = NewY; if (Counter != 500) { Counter ++; } else { Counter = 0; Counter2 = 0; Pic = 0; State = 6; } } else { State = 2; Counter = 0; } break; case 2: if ((LastX != MouseX) || (LastY != MouseY)) { State = 1; Pic = 0; Counter = 0; } else { if (Counter < 100) { Counter ++; if (Counter == 1) DisplayPic(hWnd, LastX, LastY, 16); } else { Pic = 0; State = 3; Counter = 0; } } break; case 3: if ((LastX != MouseX) || (LastY != MouseY)) { State = 5; Counter = 0; } else { if (Counter != 10) { Counter ++; } else if (Pic < 5) { Counter = 0; Pic ++; DisplayPic(hWnd, LastX, LastY, Pic + 16); } else { State = 4; Counter = 0; Pic = 0; } } break; case 4: if ((LastX != MouseX) || (LastY != MouseY)) { State = 5; Counter = 0; Pic = 5; } else { if (Counter == 20) { DisplayPic(hWnd, LastX, LastY, 22); } else if (Counter == 40) { DisplayPic(hWnd, LastX, LastY, 21); } else if (Counter == 100) { Counter = 0; }; Counter ++; } break; case 5: if (Counter == 10) { if (Pic > 0) { Pic --; DisplayPic(hWnd, LastX, LastY, 16 + Pic); } else { State = 1; Counter = 0; Pic = 0; } } else { Counter ++; } break; case 6: if (Counter == 3) { if (Pic > 8) { Pic = 4; Counter2 ++; } if (Counter2 < 4) { DisplayPic(hWnd, LastX, LastY, 23 + Pic); Pic ++; Counter = 0; } else { Counter2 = 0; Counter = 0; Pic = 0; State = 1; } } else { Counter ++; } break; }; break; case WM_COMMAND: switch (wParam) { case 101: if (TestParety(hWnd)) fDialog ("DIALOG_1", hWnd, (FARPROC)AboutDialogProc); break; case 102: ExitApp(hWnd); break; } break; case WM_SIZE: if (wParam == SIZE_MINIMIZED) { MouseX = - 10; MouseY = - 20; State = 1; Pic = 0; Counter = 0; } break; case WM_DESTROY: ExitApp(hWnd); break; default: return DefWindowProc(hWnd, messg, wParam, lParam); } return 0L; }