ProjectListWidget.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #ifndef PROJECTLISTWIDGET_H
  2. #define PROJECTLISTWIDGET_H
  3. #include <QWidget>
  4. class ProjectInfo;
  5. class PushButton;
  6. class ToolButton;
  7. class LineEdit;
  8. class TreeWidget;
  9. class QVBoxLayout;
  10. class QHBoxLayout;
  11. class QGridLayout;
  12. class QLabel;
  13. class QListWidget;
  14. class QListWidgetItem;
  15. class ProjectListItemWidget : public QWidget
  16. {
  17. Q_OBJECT
  18. public:
  19. explicit ProjectListItemWidget(QWidget *parent = nullptr);
  20. void setProj(ProjectInfo *info);
  21. ProjectInfo *proj() const;
  22. signals:
  23. void sigInfo();
  24. void sigOpen();
  25. void sigDelete();
  26. void sigExport();
  27. private:
  28. void initWidgets();
  29. void initLayout();
  30. void connectSignalsAndSlots();
  31. private:
  32. ProjectInfo *m_proj = nullptr;
  33. QLabel *m_name = nullptr;
  34. QLabel *m_time = nullptr;
  35. QLabel *m_taskLabel = nullptr;
  36. QLabel *m_task = nullptr;
  37. QLabel *m_typeLabel = nullptr;
  38. QLabel *m_type = nullptr;
  39. PushButton *m_info = nullptr;
  40. PushButton *m_open = nullptr;
  41. PushButton *m_delete = nullptr;
  42. PushButton *m_export = nullptr;
  43. QVBoxLayout *m_layout = nullptr;
  44. QHBoxLayout *m_nameLayout = nullptr;
  45. QHBoxLayout *m_taskLayout = nullptr;
  46. QHBoxLayout *m_typeLayout = nullptr;
  47. QHBoxLayout *m_buttonLayout = nullptr;
  48. };
  49. /// 工程列表
  50. class ProjectListWidget : public QWidget
  51. {
  52. Q_OBJECT
  53. public:
  54. explicit ProjectListWidget(QWidget *parent = nullptr);
  55. void setProjects(QList<ProjectInfo *> list);
  56. void showLast() const;
  57. void addProject(ProjectInfo *proj);
  58. void removeProject(ProjectInfo *proj);
  59. ProjectListItemWidget *widgetOfItem(QListWidgetItem *item) const;
  60. QListWidgetItem *itemOfWidget(ProjectListItemWidget *widget) const;
  61. signals:
  62. void sigInfo(ProjectInfo *project);
  63. void sigOpen(ProjectInfo *project);
  64. void sigDelete(ProjectInfo *project);
  65. void sigExport(ProjectInfo *project);
  66. private:
  67. void initWidgets();
  68. void initLayout();
  69. void connectSiganlsAndSlots();
  70. private slots:
  71. void slotItemDoubleClicked(QListWidgetItem *item);
  72. void slotItemClicked(QListWidgetItem *item);
  73. void slotCurrentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
  74. void slotCurrentRowChanged(int currentRow);
  75. void slotItemSelectionChanged();
  76. void slotInfo();
  77. void slotOpen();
  78. void slotDelete();
  79. void slotExport();
  80. signals:
  81. private:
  82. QVBoxLayout *m_vBoxLayout = nullptr;
  83. QListWidget *m_listWidget = nullptr;
  84. QList<ProjectInfo *> m_projList;
  85. };
  86. #endif // PROJECTLISTWIDGET_H