mainwindow-common.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #ifndef MAINWINDOWCOMMON_H
  2. #define MAINWINDOWCOMMON_H
  3. #include <QMainWindow>
  4. #include <QTableWidgetSelectionRange>
  5. #include <QMutex>
  6. #include <QSystemTrayIcon>
  7. #include "redmineitemtree.h"
  8. #include "roles.h"
  9. #include "memberships.h"
  10. #include "enumerations.h"
  11. #include "logtimewindow.h"
  12. #include "showtimewindow.h"
  13. #include "common.h"
  14. class MainWindowCommon : public QMainWindow
  15. {
  16. Q_OBJECT
  17. public:
  18. explicit MainWindowCommon ( QWidget *parent = 0 );
  19. ~MainWindowCommon();
  20. QList<QJsonObject> issues_get_byProjectId ( int project_id );
  21. /*
  22. * TODO: the next public stuff (but not slots) should be moved to
  23. * the protected section:
  24. */
  25. RedmineItemTree projects;
  26. RedmineItemTree issues;
  27. enum EIcon {
  28. GOOD = 0,
  29. BAD
  30. };
  31. typedef EIcon EStatus;
  32. EStatus status ()
  33. {
  34. return this->_status;
  35. }
  36. EStatus status ( EStatus newstatus )
  37. {
  38. return this->_status = newstatus;
  39. }
  40. EStatus statusWorsenTo ( EStatus newstatus )
  41. {
  42. return this->_status = qMax ( this->_status, newstatus );
  43. }
  44. void setIcon ( EIcon index );
  45. protected:
  46. static const int SORT_DEPTH = 3;
  47. enum ESortColumn {
  48. SORT_UNDEFINED = 0,
  49. SORT_NAME_ASC,
  50. SORT_NAME_DESC,
  51. SORT_ASSIGNEE_ASC,
  52. SORT_ASSIGNEE_DESC,
  53. SORT_DUE_TO_ASC,
  54. SORT_DUE_TO_DESC,
  55. SORT_STATUS_POS_ASC,
  56. SORT_STATUS_POS_DESC,
  57. SORT_UPDATED_ON_ASC,
  58. SORT_UPDATED_ON_DESC,
  59. SORT_STATUS_ISCLOSED_ASC,
  60. SORT_TIMEENTRY_FROM_ASC,
  61. };
  62. typedef bool ( *sortfunct_t ) ( const QJsonObject &issue_a, const QJsonObject &issue_b );
  63. // TODO: deduplicate sortLogicalIndex+sortOrder and sortColumn
  64. int sortLogicalIndex = -1;
  65. Qt::SortOrder sortOrder;
  66. enum ESortColumn sortColumn[SORT_DEPTH];
  67. QMap <enum ESortColumn, sortfunct_t> sortFunctMap;
  68. /*
  69. * TODO: the next protected stuff (but not slots) should be moved to
  70. * the private section:
  71. */
  72. QHash<int, QList<QJsonObject>> issues_byProjectId;
  73. Roles roles;
  74. Memberships memberships;
  75. Enumerations enumerations;
  76. QComboBox iconComboBox;
  77. QSystemTrayIcon *trayIcon;
  78. QMenu *trayIconMenu;
  79. void createIconComboBox();
  80. void createTrayIcon();
  81. void showOnTop();
  82. //virtual void createTrayActions();
  83. protected slots:
  84. int updateEnumerations();
  85. int updateMemberships();
  86. int updateProjects();
  87. int updateIssues();
  88. int updateRoles();
  89. void openLogTimeWindow();
  90. void on_closeLogTimeWindow();
  91. void openShowTimeWindow();
  92. void on_closeShowTimeWindow();
  93. signals:
  94. protected slots:
  95. void toggleShowHide();
  96. public slots:
  97. private:
  98. /* projects */
  99. virtual void projects_display();
  100. virtual void issues_display();
  101. void get_enumerations_callback ( QNetworkReply *reply, QJsonDocument *json, void *arg );
  102. void get_memberships_callback ( QNetworkReply *reply, QJsonDocument *json, void *arg );
  103. void get_projects_callback ( QNetworkReply *reply, QJsonDocument *json, void *arg );
  104. void get_issues_callback ( QNetworkReply *reply, QJsonDocument *json, void *arg );
  105. void get_roles_callback ( QNetworkReply *reply, QJsonDocument *json, void *arg );
  106. QMutex updateProjectsMutex;
  107. QMutex updateIssuesMutex;
  108. EStatus _status;
  109. LogTimeWindow *logTimeWindow;
  110. ShowTimeWindow *showTimeWindow;
  111. };
  112. #endif // MAINWINDOWCOMMON_H