ProjectListWidget.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 sigEdit();
  27. void sigDelete();
  28. private:
  29. void initWidgets();
  30. void initLayout();
  31. void connectSignalsAndSlots();
  32. private:
  33. int m_index = 0;
  34. ProjectInfo *m_proj = nullptr;
  35. QLabel *m_name = nullptr;
  36. QLabel *m_time = nullptr;
  37. QLabel *m_taskLabel = nullptr;
  38. QLabel *m_task = nullptr;
  39. QLabel *m_typeLabel = nullptr;
  40. QLabel *m_type = nullptr;
  41. PushButton *m_info = nullptr;
  42. PushButton *m_edit = nullptr;
  43. PushButton *m_open = nullptr;
  44. PushButton *m_delete = nullptr;
  45. QVBoxLayout *m_layout = nullptr;
  46. QHBoxLayout *m_nameLayout = nullptr;
  47. QHBoxLayout *m_taskLayout = nullptr;
  48. QHBoxLayout *m_typeLayout = nullptr;
  49. QHBoxLayout *m_buttonLayout = nullptr;
  50. };
  51. /// 工程列表
  52. class ProjectListWidget : public QWidget
  53. {
  54. Q_OBJECT
  55. public:
  56. explicit ProjectListWidget(QWidget *parent = nullptr);
  57. void showProjects(QList<ProjectInfo *> list);
  58. ProjectListItemWidget *itemWidget(QListWidgetItem *item) const;
  59. signals:
  60. void sigInfo(ProjectInfo *project);
  61. void sigOpen(ProjectInfo *project);
  62. void sigEdit(ProjectInfo *project);
  63. void sigDelete(ProjectInfo *project);
  64. private:
  65. void initWidgets();
  66. void initLayout();
  67. void connectSiganlsAndSlots();
  68. private slots:
  69. void slotItemDoubleClicked(QListWidgetItem *item);
  70. void slotItemClicked(QListWidgetItem *item);
  71. void slotCurrentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
  72. void slotCurrentRowChanged(int currentRow);
  73. void slotItemSelectionChanged();
  74. void slotInfo();
  75. void slotOpen();
  76. void slotEdit();
  77. void slotDelete();
  78. signals:
  79. private:
  80. QVBoxLayout *m_vBoxLayout = nullptr;
  81. QListWidget *m_listWidget = nullptr;
  82. };
  83. #endif // PROJECTLISTWIDGET_H