You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "ReportsManagerDialog.h"
  2. guiReportsManagerDialog::guiReportsManagerDialog(QWidget *parent) : QDialog(parent){
  3. m_pCalendarWidget = new QCalendarWidget( this );
  4. m_pSystemReport = objectEventReport::getInstance();
  5. m_pCalendarWidget->setGridVisible(true);
  6. connect(m_pCalendarWidget, &QCalendarWidget::selectionChanged, this, &guiReportsManagerWindow::selectReportDate);
  7. m_pListView = new QListView( this );
  8. m_pListModel = new QStringListModel( m_pListView );
  9. m_pListView->setGeometry(200, 20, 300, 400);
  10. m_pListView->setModel(m_pListModel);
  11. };
  12. guiReportsManagerDialog::~guiReportsManagerDialog(){
  13. };
  14. void guiReportsManagerDialog::selectReportDate() {
  15. QDate sd;
  16. struct tm STM;
  17. sd = m_pCalendarWidget->selectedDate();
  18. memset(&STM, 0, sizeof(struct tm));
  19. STM.tm_year = sd.year() - 1900;
  20. STM.tm_mon = sd.month() - 1;
  21. STM.tm_mday = sd.day();
  22. if (m_pSystemReport->loadReportList(&STM)) {
  23. Rere* list;
  24. list = m_pSystemReport->getLoaddedReports();
  25. if (list) {
  26. QStringList lst;
  27. m_pListModel->removeRows(0, m_pListModel->rowCount());
  28. for (Rere::iterator index = list->begin(); index < list->end(); index++) {
  29. lst.append(QString(*index));
  30. };
  31. m_pListModel->setStringList(lst);
  32. };
  33. } else {
  34. QMessageBox msgBox;
  35. msgBox.setText("No Data");
  36. msgBox.setInformativeText("We do not have reports to selected date.");
  37. msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Discard | QMessageBox::Cancel );
  38. msgBox.setDefaultButton(QMessageBox::Ok);
  39. int ret = msgBox.exec();
  40. };
  41. };