HomeView.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include "HomeView.h"
  2. #include "CreateProjView.h"
  3. #include <Widgets/Button.h>
  4. #include <Widgets/LineEdit.h>
  5. #include <QBoxLayout>
  6. #include <QLabel>
  7. #include <QTableWidget>
  8. #include <QHeaderView>
  9. #include <QDebug>
  10. HomeView::HomeView(QWidget *parent) : QWidget(parent)
  11. {
  12. initialize();
  13. initLayout();
  14. connectSignalsAndSlots();
  15. // this->setStyleSheet("background-color: rgb(250, 250, 250);");
  16. }
  17. void HomeView::initialize()
  18. {
  19. m_vBoxLayout = new QVBoxLayout(this);
  20. m_titleLabel = new QLabel(this);
  21. m_titleLabel->setText("工程列表");
  22. QFont ft("Microsoft YaHei", 12);
  23. m_titleLabel->setFont(ft);
  24. m_hBoxLayout = new QHBoxLayout();
  25. m_searchLineEdit = new SearchLineEdit(this);
  26. m_searchLineEdit->setPlaceholderText("搜索工程");
  27. m_searchLineEdit->setMinimumWidth(300);
  28. m_createProjPushButton = new PushButton("新建工程", NEWFLICON(FluentIcon, ADD), this);
  29. m_projTableWidget = new QTableWidget(this);
  30. m_projTableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
  31. m_projTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
  32. m_projTableWidget->setSelectionMode(QAbstractItemView::NoSelection);
  33. m_projTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
  34. m_projTableWidget->verticalHeader()->setVisible(false);
  35. const QStringList headers = { "工程名", "工程类型", "专家信息", "评估状态" };
  36. m_projTableWidget->setColumnCount(headers.count());
  37. m_projTableWidget->setHorizontalHeaderLabels(headers);
  38. m_projTableWidget->setStyleSheet("border: 1px solid rgba(0, 0, 0, 0.073)");
  39. m_createProjView = new CreateProjView(this);
  40. }
  41. void HomeView::initLayout()
  42. {
  43. m_vBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
  44. m_vBoxLayout->setContentsMargins(15, 10, 10, 15);
  45. m_vBoxLayout->addLayout(m_hBoxLayout);
  46. m_hBoxLayout->addWidget(m_titleLabel);
  47. m_hBoxLayout->addSpacing(15);
  48. m_hBoxLayout->addWidget(m_searchLineEdit, 0, Qt::AlignLeft);
  49. m_hBoxLayout->addWidget(m_createProjPushButton, 1, Qt::AlignLeft);
  50. m_vBoxLayout->addSpacing(15);
  51. m_vBoxLayout->addWidget(m_projTableWidget);
  52. }
  53. void HomeView::connectSignalsAndSlots()
  54. {
  55. connect(m_createProjPushButton, &PushButton::clicked, this, &HomeView::slotCreateProjClicked);
  56. }
  57. void HomeView::slotCreateProjClicked()
  58. {
  59. if (m_createProjView->isVisible() == false) {
  60. m_createProjView->clearInputs();
  61. m_createProjView->show();
  62. }
  63. }