ProjectListWidget.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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(int index, QWidget *parent = nullptr);
  20. void setInfo(ProjectInfo *info);
  21. int index() const;
  22. ProjectInfo *proj() const;
  23. signals:
  24. void sigInfo();
  25. void sigOpen();
  26. void sigDelete();
  27. private:
  28. void initWidgets();
  29. void initLayout();
  30. void connectSignalsAndSlots();
  31. private:
  32. int m_index = 0;
  33. ProjectInfo *m_proj = nullptr;
  34. QLabel *m_name = nullptr;
  35. QLabel *m_time = nullptr;
  36. QLabel *m_taskLabel = nullptr;
  37. QLabel *m_task = nullptr;
  38. QLabel *m_typeLabel = nullptr;
  39. QLabel *m_type = nullptr;
  40. PushButton *m_info = nullptr;
  41. PushButton *m_open = nullptr;
  42. PushButton *m_delete = 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 showProjects(QList<ProjectInfo *> list);
  56. ProjectListItemWidget *itemWidget(QListWidgetItem *item) const;
  57. signals:
  58. void sigInfo(ProjectInfo *project);
  59. void sigOpen(ProjectInfo *project);
  60. void sigDelete(ProjectInfo *project);
  61. private:
  62. void initWidgets();
  63. void initLayout();
  64. void connectSiganlsAndSlots();
  65. private slots:
  66. void slotItemDoubleClicked(QListWidgetItem *item);
  67. void slotItemClicked(QListWidgetItem *item);
  68. void slotCurrentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
  69. void slotCurrentRowChanged(int currentRow);
  70. void slotItemSelectionChanged();
  71. void slotInfo();
  72. void slotOpen();
  73. void slotDelete();
  74. signals:
  75. private:
  76. QVBoxLayout *m_vBoxLayout = nullptr;
  77. QListWidget *m_listWidget = nullptr;
  78. };
  79. #endif // PROJECTLISTWIDGET_H