From bfa7c66c8ea05968ee4288ee78a732bafcea0dc2 Mon Sep 17 00:00:00 2001 From: poocka Date: Thu, 12 Sep 2019 18:07:12 +0300 Subject: [PATCH] Client_Server Communication Bug --- .gitignore | 5 +- .../Win32-QT-gui-application_2019.vcxproj | 10 ++-- lib/App/3dGUI/main-qt.cpp | 24 ++++---- lib/components/object/objectEventReport.cpp | 59 ++++++++++++++++++- lib/components/object/objectEventReport.h | 38 +++++++----- lib/data/media/video/videoAVLIBSource.cpp | 8 +-- lib/data/net/clientPort.cpp | 21 ++++--- lib/data/storage/storageProvider.cpp | 9 +-- lib/data/storage/storageProvider.h | 1 + lib/gui/controls/EventViewWidget.cpp | 2 +- lib/gui/controls/ReportsManagerWindow.cpp | 37 +++++++++++- lib/gui/controls/ReportsManagerWindow.h | 10 +++- 12 files changed, 164 insertions(+), 60 deletions(-) diff --git a/.gitignore b/.gitignore index 8ae1a7a5..173cd308 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ *.suo *.bak *~ +/Projects/QT-Gui-App/data/* /Projects/QT-Gui-App/swscale-4.dll /Projects/QT-Gui-App/swresample-2.dll /Projects/QT-Gui-App/ssleay32.dll @@ -74,9 +75,9 @@ /Projects/QT-Gui-App/platforms /Projects/QT-Gui-App/Release /Projects/QT-Gui-App/Debug -/Projects/QT-Gui-App/data/storage/2019/07/28 +/Projects/QT-Gui-App/data/storage /Projects/QT-Gui-App/.vs/Win32-QT-gui-application/v16 /.vs -/Projects/QT-Gui-App/data/storage/2019/07/29 /Projects/QT-Gui-App/Win32-QT-gui-application_2019.exe /Release +/Debug diff --git a/Projects/QT-Gui-App/Win32-QT-gui-application_2019.vcxproj b/Projects/QT-Gui-App/Win32-QT-gui-application_2019.vcxproj index ef619426..07a58733 100644 --- a/Projects/QT-Gui-App/Win32-QT-gui-application_2019.vcxproj +++ b/Projects/QT-Gui-App/Win32-QT-gui-application_2019.vcxproj @@ -35,12 +35,12 @@ - D:\W32LIBS\include;C:\FruchtSystems\W32LIBS\include;C:\Qt\Qt5.5.1\5.5\msvc2013\include;C:\LIBS\pthreads\include;C:\LIBS\Qt\5.12.2\msvc2017\include;$(IncludePath) - C:\FruchtSystems\W32LIBS\lib;C:\MDXSDK\Lib\x86;C:\Qt\Qt5.5.1\5.5\msvc2013\lib;C:\LIBS\pthreads\lib\x86;D:\C\MS_LIBS\DXSDK\Lib\x86;D:\W32LIBS\lib;C:\LIBS\Qt\5.12.2\msvc2017\lib;$(LibraryPath) + C:\LIBS\W32LIBS\include;C:\LIBS\Qt\5.12.2\msvc2017\include;$(IncludePath) + C:\LIBS\Qt\5.12.2\msvc2017\lib;C:\LIBS\MS_LIBS\DXSDK\Lib;C:\LIBS\MS_LIBS\DXSDK\Lib\x86;C:\LIBS\W32LIBS\lib;$(LibraryPath) - D:\W32LIBS\include;C:\FruchtSystems\W32LIBS\include;C:\Qt\Qt5.5.1\5.5\msvc2013\include;C:\LIBS\pthreads\include;C:\LIBS\Qt\5.12.2\msvc2017\include;$(IncludePath) - C:\FruchtSystems\W32LIBS\lib;C:\MDXSDK\Lib\x86;C:\Qt\Qt5.5.1\5.5\msvc2013\lib;C:\LIBS\pthreads\lib\x86;D:\C\MS_LIBS\DXSDK\Lib\x86;D:\W32LIBS\lib;C:\LIBS\Qt\5.12.2\msvc2017\lib;$(LibraryPath) + C:\LIBS\W32LIBS\include;C:\LIBS\Qt\5.12.2\msvc2017\include;$(IncludePath) + C:\LIBS\Qt\5.12.2\msvc2017\lib;C:\LIBS\MS_LIBS\DXSDK\Lib;C:\LIBS\MS_LIBS\DXSDK\Lib\x86;C:\LIBS\W32LIBS\lib;$(LibraryPath) @@ -57,7 +57,7 @@ C:\Qt\Qt5.5.1\5.5\msvc2010\lib;D:\W32LIBS\lib;C:\MS_LIBS\DXSDK\Lib\x86;%(AdditionalLibraryDirectories) - libcurl_a_debug.lib;Strmiids.lib;Quartz.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;opencv_calib3d249d.lib;opencv_contrib249d.lib;opencv_core249d.lib;opencv_features2d249d.lib;opencv_flann249d.lib;opencv_gpu249d.lib;opencv_highgui249d.lib;opencv_imgproc249d.lib;opencv_legacy249d.lib;opencv_ml249d.lib;opencv_nonfree249d.lib;opencv_objdetect249d.lib;opencv_ocl249d.lib;opencv_photo249d.lib;opencv_stitching249d.lib;opencv_superres249d.lib;opencv_ts249d.lib;opencv_video249d.lib;opencv_videostab249d.lib;postproc.lib;SDL2_image.lib;SDL2.lib;SDL2main.lib;SDL2_mixer.lib;SDL2_net.lib;SDL2test.lib;SDL2_ttf.lib;swresample.lib;swscale.lib;Ws2_32.lib;libeay32MTd.lib;ssleay32MTd.lib;d2d1.lib;d3d10.lib;d3d10_1.lib;d3d11.lib;d3d9.lib;d3dcompiler.lib;D3DCSX.lib;D3DCSXd.lib;d3dx10.lib;d3dx10d.lib;d3dx11.lib;d3dx11d.lib;d3dx9.lib;d3dx9d.lib;d3dxof.lib;dinput8.lib;dsetup.lib;dsound.lib;dwrite.lib;DxErr.lib;dxgi.lib;dxguid.lib;X3DAudio.lib;xapobase.lib;xapobased.lib;XAPOFX.lib;XInput.lib;%(AdditionalDependencies) + libcurl_a_debug.lib;Strmiids.lib;Quartz.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;opencv_calib3d249d.lib;opencv_contrib249d.lib;opencv_core249d.lib;opencv_features2d249d.lib;opencv_flann249d.lib;opencv_gpu249d.lib;opencv_highgui249d.lib;opencv_imgproc249d.lib;opencv_legacy249d.lib;opencv_ml249d.lib;opencv_nonfree249d.lib;opencv_objdetect249d.lib;opencv_ocl249d.lib;opencv_photo249d.lib;opencv_stitching249d.lib;opencv_superres249d.lib;opencv_ts249d.lib;opencv_video249d.lib;opencv_videostab249d.lib;postproc.lib;SDL2_image.lib;SDL2.lib;SDL2main.lib;SDL2_mixer.lib;SDL2_net.lib;SDL2test.lib;SDL2_ttf.lib;swresample.lib;swscale.lib;Ws2_32.lib;libeay32MT.lib;ssleay32MT.lib;d2d1.lib;d3d10.lib;d3d10_1.lib;d3d11.lib;d3d9.lib;d3dcompiler.lib;D3DCSX.lib;D3DCSXd.lib;d3dx11.lib;d3dx11d.lib;d3dx9.lib;d3dx9d.lib;d3dxof.lib;dinput8.lib;dsetup.lib;dsound.lib;dwrite.lib;DxErr.lib;dxgi.lib;dxguid.lib;X3DAudio.lib;xapobase.lib;xapobased.lib;XAPOFX.lib;XInput.lib;%(AdditionalDependencies) true Windows WinMainCRTStartup diff --git a/lib/App/3dGUI/main-qt.cpp b/lib/App/3dGUI/main-qt.cpp index 31ed22ad..bc9d8ff0 100644 --- a/lib/App/3dGUI/main-qt.cpp +++ b/lib/App/3dGUI/main-qt.cpp @@ -24,9 +24,9 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow){ - //Beep(512, 512); - //Beep(256, 256); - //Beep(128, 128); + Beep(512, 512); + Beep(256, 256); + Beep(128, 128); guiClass *GUI; systemAnchor *ANCH; @@ -108,24 +108,20 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, }; joysticObject::getInstance(); -#ifdef __linux__ - LOG_DEBUG("SS Enabled"); -#else - { - SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, timeoutLowPower, NULL, 0); - SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, timeoutPowerOff, NULL, 0); - SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, timeoutScreenSave, NULL, 0); - } - LOG_DEBUG("SS Enabled"); -#endif - delete GUI; delete window; delete LS; delete mpEventHeap; delete mpSettingsProvider; #ifdef __linux__ + LOG_DEBUG("SS Enabled"); #else + { + SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, timeoutLowPower, NULL, 0); + SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, timeoutPowerOff, NULL, 0); + SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, timeoutScreenSave, NULL, 0); + } + LOG_DEBUG("SS Enabled"); //lActiveFlag = 1; //SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, 0, 0); //lActiveFlag = 20; diff --git a/lib/components/object/objectEventReport.cpp b/lib/components/object/objectEventReport.cpp index 4daa7842..10eeddeb 100644 --- a/lib/components/object/objectEventReport.cpp +++ b/lib/components/object/objectEventReport.cpp @@ -18,6 +18,7 @@ objectEventReport* objectEventReport::getInstance() { // Constructor implementation objectEventReport::objectEventReport() : basicEventHandler(){ + m_pSettingsEngine = NULL; m_pStorageProvider = storageProvider::getInstance(); m_pStorageProvider->startNewSeries(); sprintf( m_pReportFileName, "%s", m_pStorageProvider->getNewFileName()); @@ -30,9 +31,10 @@ objectEventReport::~objectEventReport(){ void objectEventReport::dispatchEvent( basicEvent *Evt ){ if( Evt == NULL ) return; - if (Evt->m_eClass == EVT_CLASS_SENSOR || Evt->m_eClass == EVT_CLASS_SYSTEM){ + //if (Evt->m_eClass == EVT_CLASS_SENSOR || Evt->m_eClass == EVT_CLASS_SYSTEM){ + //Store all events addGenericEvent( Evt ); - }; + //}; }; bool objectEventReport::addGenericEvent( basicEvent *Evt ){ FILE *FD; @@ -75,6 +77,59 @@ bool objectEventReport::addGenericEvent( basicEvent *Evt ){ }; return true; }; + bool objectEventReport::addVideoRecord( CSTR fileName ){ return true; }; + +bool objectEventReport::addSnapshot(CSTR fileName) { + return true; +}; + +bool objectEventReport::loadReportList(struct tm* LTM){ + if (LTM == NULL) return false; + char RD_Path[MAX_PATH_LEN]; +#ifdef __linux__ + sprintf(RD_Path, "%s/%04d/%02d/%02d", m_pStorageProvider->getStorageBase(), LTM->tm_year + 1900, LTM->tm_mon + 1, LTM->tm_mday); +#else + sprintf(RD_Path, "%s/%04d/%02d/%02d/*", m_pStorageProvider->getStorageBase(), LTM->tm_year + 1900, LTM->tm_mon + 1, LTM->tm_mday); + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + LARGE_INTEGER filesize; + hFind = FindFirstFile(RD_Path, &ffd); + if (INVALID_HANDLE_VALUE == hFind) { + return false; + }; + //ToDo: Free Memory of list + m_vLoaddedReports.clear(); + do{ + if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){ + //_tprintf(TEXT(" %s \n"), ffd.cFileName); + if (strlen(ffd.cFileName) > 3) { // an item folder found + char* tPtr; + //tPtr = (char*)malloc(strlen(ffd.cFileName) + 1); + tPtr = (char*)malloc(64); + if (tPtr) { + //memset(tPtr, 0, strlen(ffd.cFileName) + 1); + //strncpy(tPtr, ffd.cFileName, strlen(ffd.cFileName)); + memset(tPtr, 0, 64); + sprintf(tPtr, "%c%c:%c%c:%c%c", *(ffd.cFileName), *(ffd.cFileName+1), *(ffd.cFileName+2), *(ffd.cFileName+3), *(ffd.cFileName+4), *(ffd.cFileName+5)); + m_vLoaddedReports.push_back(tPtr); + }; + }; + } else { + filesize.LowPart = ffd.nFileSizeLow; + filesize.HighPart = ffd.nFileSizeHigh; + //_tprintf(TEXT(" %s %ld bytes\n"), ffd.cFileName, filesize.QuadPart); + }; + } while (FindNextFile(hFind, &ffd) != 0); +#endif + return true; +}; + +Rere* objectEventReport::getLoaddedReports(void) { + if(m_vLoaddedReports.size()){ + return &m_vLoaddedReports; + }; + return NULL; +}; \ No newline at end of file diff --git a/lib/components/object/objectEventReport.h b/lib/components/object/objectEventReport.h index e442b655..69ebbd5c 100644 --- a/lib/components/object/objectEventReport.h +++ b/lib/components/object/objectEventReport.h @@ -2,31 +2,41 @@ #define __OBJECTEVENTREPORT_H_INCL__ #include +#include #include "../base/basicFunctionality.h" #include "../base/basicEventHandler.h" #include "../../data/storage/storageProvider.h" #include "../base/basicSettings.h" #include "../base/basicReportRecord.h" +#include "../base/basicCamera.h" /** * TODO: Add class description * * @author Gagua */ + +typedef std::vector Rere; + class objectEventReport : public basicEventHandler { -private: - storageProvider * m_pStorageProvider; - basicSettings * m_pSettingsEngine; - char m_pReportFileName[MAX_PATH]; - bool addVideoRecord( CSTR fileName ); - bool addGenericEvent( basicEvent *Evt ); -public: - static objectEventReport *getInstance(void); - virtual ~objectEventReport(void); - void dispatchEvent(basicEvent *Evt); -private: - static objectEventReport *_instance; -protected: - objectEventReport(void); + private: + storageProvider * m_pStorageProvider; + basicSettings * m_pSettingsEngine; + char m_pReportFileName[MAX_PATH]; + bool addVideoRecord( CSTR fileName ); + bool addSnapshot(CSTR fileName); + bool addGenericEvent( basicEvent *Evt ); + Rere m_vLoaddedReports; + public: + static objectEventReport *getInstance(void); + bool bindCamera( basicCamera * tPtr ); + virtual ~objectEventReport(void); + void dispatchEvent(basicEvent *Evt); + bool loadReportList(struct tm *LTM); + Rere * getLoaddedReports(void); + private: + static objectEventReport *_instance; + protected: + objectEventReport(void); }; diff --git a/lib/data/media/video/videoAVLIBSource.cpp b/lib/data/media/video/videoAVLIBSource.cpp index 0354fbb2..8118715e 100644 --- a/lib/data/media/video/videoAVLIBSource.cpp +++ b/lib/data/media/video/videoAVLIBSource.cpp @@ -301,7 +301,7 @@ bool videoAVLIBSource::_open(char *URI, bool ShowDeviceMenu, float framerate, in }; #if ( LIBAVCODEC_VERSION_MAJOR < 58 ) && ( LIBAVCODEC_VERSION_MINOR < 50 ) - LOG("YABABA-1!"); + //LOG("YABABA-1!"); for( unsigned int i=0; i < m_pVideoState->m_pFormatCtx->nb_streams; i++ ){ //if( m_pVideoState->m_pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ){ if( m_pVideoState->m_pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO ){ @@ -339,7 +339,7 @@ bool videoAVLIBSource::_open(char *URI, bool ShowDeviceMenu, float framerate, in //m_pVideoState->m_pFormatCtx->streams[m_pVideoState->m_iVideoStreamID]->codecpar->codec_id m_pVideoState->m_pVideoCodec = avcodec_find_decoder( m_pVideoState->m_pCodecCtx->codec_id ); #else - LOG("YABABA-2!"); + //LOG("YABABA-2!"); /* find the video stream information */ m_pVideoState->m_iVideoStreamID = av_find_best_stream(m_pVideoState->m_pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, &m_pVideoState->m_pVideoCodec, 0); @@ -446,10 +446,10 @@ bool videoAVLIBSource::_open(char *URI, bool ShowDeviceMenu, float framerate, in #endif m_pVideoState->m_bStatus = MS_ALOCATED; // All seems to be good -> allocating mem - LOG("YABABA!!!!"); + //LOG("YABABA!!!!"); if( m_bThreadStatus < TH_WORKING ) init(); - LOG("YABABA232!"); + //LOG("YABABA232!"); return true; }; return false; diff --git a/lib/data/net/clientPort.cpp b/lib/data/net/clientPort.cpp index 7d2e1a09..9b437086 100644 --- a/lib/data/net/clientPort.cpp +++ b/lib/data/net/clientPort.cpp @@ -82,7 +82,8 @@ bool clientPort::_connect(void){ WSADATA wsaData; iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); if (iResult != 0) { - printf("WSAStartup failed with error: %d\n", iResult); + sprintf(cBuffer, "WSAStartup failed with error: %d\n", iResult); + LOG_ERROR(cBuffer); return false; }; ZeroMemory( &hints, sizeof(hints) ); @@ -93,11 +94,11 @@ bool clientPort::_connect(void){ sprintf( cBuffer, "%d", m_nPort ); iResult = getaddrinfo( m_sHostName, cBuffer, &hints, &result ); if (iResult != 0) { - sprintf( cBuffer, "getaddrinfo for [%s:%d] failed with error: %d", m_sHostName, m_nPort, iResult ); - LOG(cBuffer); + sprintf(cBuffer, "getaddrinfo for [%s:%d] failed with error: %d", m_sHostName, m_nPort, iResult); + LOG_ERROR(cBuffer); WSACleanup(); return false; - } + }; // Attempt to connect to an address until one succeeds ptr = result; @@ -105,14 +106,16 @@ bool clientPort::_connect(void){ // Create a SOCKET for connecting to server m_nSocketFD = socket( ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol ); if( m_nSocketFD == INVALID_SOCKET ){ - sprintf( cBuffer, "socket failed with error: %ld", WSAGetLastError()); - LOG(cBuffer); + sprintf( cBuffer, "Socket Creation failed with error: %ld", WSAGetLastError()); + LOG_ERROR(cBuffer); WSACleanup(); return false; }; // Connect to server. iResult = connect( m_nSocketFD, ptr->ai_addr, (int)ptr->ai_addrlen ); if (iResult == SOCKET_ERROR) { + sprintf(cBuffer, "Socket Connection failed[%d] with error: %ld", iResult, WSAGetLastError()); + LOG_ERROR(cBuffer); closesocket(m_nSocketFD); m_nSocketFD = INVALID_SOCKET; ptr = ptr->ai_next; @@ -128,13 +131,13 @@ bool clientPort::_connect(void){ return false; }; #endif - //setConnectionStatus(CS_CONNECTED); + setConnectionStatus(CS_CONNECTED); return true; }; bool clientPort::connectTo(CSTR Host, int Port){ if( m_eConnectionStatus == CS_CONNECTED ){ - //setConnectionStatus(CS_DISCONNECTED); + setConnectionStatus(CS_DISCONNECTED); #ifdef __linux__ shutdown( m_nSocketFD, SHUT_RDWR ); close( m_nSocketFD ); @@ -308,7 +311,7 @@ bool clientPort::disconnect(void){ WSACleanup(); m_nSocketFD = INVALID_SOCKET; #endif - //setConnectionStatus(CS_DISCONNECTED); + setConnectionStatus(CS_DISCONNECTED); }; return true; }; diff --git a/lib/data/storage/storageProvider.cpp b/lib/data/storage/storageProvider.cpp index b51ef58c..f12811f6 100644 --- a/lib/data/storage/storageProvider.cpp +++ b/lib/data/storage/storageProvider.cpp @@ -23,14 +23,15 @@ storageProvider* storageProvider::getInstance(CSTR Base) { storageProvider::storageProvider(CSTR BasePath) :m_mCounterProtectorMutex(){ m_pLog = basicLogCollection::getInstance(); LOG("Start Storage"); - m_pCWD = (CSTR) malloc( 1024 ); - m_pBasePath = (CSTR) malloc( 1024 ); + m_pCWD = (CSTR) malloc(MAX_PATH_LEN); + m_pBasePath = (CSTR) malloc(MAX_PATH_LEN); m_pEntryFolder = (CSTR) malloc( 9 ); m_pSeriesBase = (CSTR) malloc( 33 ); m_nSeriesCounter = 0; if( m_pBasePath!= NULL ) { - - strncpy( m_pBasePath, BasePath, 1024 ); + _getcwd(m_pCWD, MAX_PATH_LEN ); + //strncpy( m_pBasePath, BasePath, 1024 ); + sprintf(m_pBasePath, "%s/%s", m_pCWD, BasePath); #ifdef DEBUG char Buffer[256]; sprintf(Buffer,"Base Path OK [%s]", m_pBasePath ); diff --git a/lib/data/storage/storageProvider.h b/lib/data/storage/storageProvider.h index 253e7c4c..e245e8f5 100644 --- a/lib/data/storage/storageProvider.h +++ b/lib/data/storage/storageProvider.h @@ -33,6 +33,7 @@ class storageProvider{ bool startNewSeries(void); bool startNewEntry(void); CSTR getNewFileName(void); + CSTR getStorageBase(void) { return m_pBasePath; }; protected: // Constructor - protected so users cannot call it. explicit storageProvider(CSTR BasePath); diff --git a/lib/gui/controls/EventViewWidget.cpp b/lib/gui/controls/EventViewWidget.cpp index 87974f33..304bd395 100644 --- a/lib/gui/controls/EventViewWidget.cpp +++ b/lib/gui/controls/EventViewWidget.cpp @@ -80,7 +80,7 @@ void EventViewerList::handleTimer( void ){ void EventViewerList::dispatchEvent(basicEvent *Evt){ //return; if (Evt == NULL) return; - if (Evt->m_eClass == EVT_CLASS_SENSOR || Evt->m_eClass == EVT_CLASS_SYSTEM){ + if (Evt->m_eClass == EVT_CLASS_SENSOR || Evt->m_eClass == EVT_CLASS_SYSTEM ){ m_oLinesProtector.lock(); EVListItem nLine; sprintf( nLine.msg, "%02d-%02d-%02d %02d:%02d:%02d %s", Evt->sTS.tm_year + 1900, Evt->sTS.tm_mon + 1, Evt->sTS.tm_mday, Evt->sTS.tm_hour, Evt->sTS.tm_min, Evt->sTS.tm_sec, Evt->m_pHumanReadableMsg); diff --git a/lib/gui/controls/ReportsManagerWindow.cpp b/lib/gui/controls/ReportsManagerWindow.cpp index 59040149..0a02b6ed 100644 --- a/lib/gui/controls/ReportsManagerWindow.cpp +++ b/lib/gui/controls/ReportsManagerWindow.cpp @@ -1,11 +1,44 @@ #include "ReportsManagerWindow.h" guiReportsManagerWindow::guiReportsManagerWindow(QDialog *parent) : QDialog(parent){ - m_pCalendarWidget = new QCalendarWidget(); + m_pCalendarWidget = new QCalendarWidget( this ); + m_pSystemReport = objectEventReport::getInstance(); m_pCalendarWidget->setGridVisible(true); - m_pListView = new QListView(); + connect(m_pCalendarWidget, &QCalendarWidget::selectionChanged, this, &guiReportsManagerWindow::selectReportDate); + m_pListView = new QListView( this ); + m_pListModel = new QStringListModel( m_pListView ); + m_pListView->setGeometry(200, 20, 300, 400); + m_pListView->setModel(m_pListModel); }; guiReportsManagerWindow::~guiReportsManagerWindow(){ +}; +void guiReportsManagerWindow::selectReportDate() { + QDate sd; + struct tm STM; + sd = m_pCalendarWidget->selectedDate(); + memset(&STM, 0, sizeof(struct tm)); + STM.tm_year = sd.year() - 1900; + STM.tm_mon = sd.month() - 1; + STM.tm_mday = sd.day(); + if (m_pSystemReport->loadReportList(&STM)) { + Rere* list; + list = m_pSystemReport->getLoaddedReports(); + if (list) { + QStringList lst; + m_pListModel->removeRows(0, m_pListModel->rowCount()); + for (Rere::iterator index = list->begin(); index < list->end(); index++) { + lst.append(QString(*index)); + }; + m_pListModel->setStringList(lst); + }; + } else { + QMessageBox msgBox; + msgBox.setText("No Data"); + msgBox.setInformativeText("We do not have reports to selected date."); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Discard | QMessageBox::Cancel ); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret = msgBox.exec(); + }; }; diff --git a/lib/gui/controls/ReportsManagerWindow.h b/lib/gui/controls/ReportsManagerWindow.h index 9c035548..92e3d3ff 100644 --- a/lib/gui/controls/ReportsManagerWindow.h +++ b/lib/gui/controls/ReportsManagerWindow.h @@ -3,15 +3,19 @@ #include #include "../guiClass.h" - +#include "../../components/object/objectEventReport.h" class guiReportsManagerWindow : public QDialog { private: - QCalendarWidget *m_pCalendarWidget; - QListView *m_pListView; + objectEventReport * m_pSystemReport; + QCalendarWidget * m_pCalendarWidget; + QListView * m_pListView; + QStringListModel * m_pListModel; public: explicit guiReportsManagerWindow(QDialog *parent = NULL); ~guiReportsManagerWindow(); + public slots: + void selectReportDate(); }; #endif \ No newline at end of file