#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace QtCharts; using MapLabelPair = std::map, std::shared_ptr>>; class LabelPairH; class LabelPairV; class UiStyle { public: static std::string BTN; }; class QUI { public: static std::shared_ptr label(QWidget* parent, int x, int y, int w, int h, std::string text, std::string sty=""); static void label(QLabel& lab, QWidget* parent, int x, int y, int w, int h, std::string text, std::string sty = ""); static void labelImage(QLabel& lab, QWidget* parent, int x, int y, int w, int h, std::string img); static std::shared_ptr labelPair(QWidget* parent, int x, int y, int w, int h, int w1, std::string k, std::string v=""); static std::shared_ptr labelPairV(QWidget* parent, int x, int y, int w, int h, int h1, std::string k, std::string v = ""); static void button(QPushButton& btn, QWidget* parent, int x, int y, int w, int h, std::string text, std::string sty = ""); static QPushButton* button(QWidget* parent, int x, int y, int w, int h, std::string text, std::string sty = ""); //static std::shared_ptr combox(QWidget* parent, int x, int y, int w, int h, std::vector& items); static void combox(QComboBox& comb, QWidget* parent, int x, int y, int w, int h, std::vector items, std::string v=""); static void lineedit(QLineEdit& line, QWidget* parent, int x, int y, int w, int h); static void setBackground(QWidget* w, std::string name, QColor color=QColor(29, 54, 102), std::string border="border-radius:5px;"); }; class Panel : public QWidget { public: Panel(QWidget* parent, QRect rt, std::string title=""); void setBackground(QColor color, std::string border="border-radius:1px;border:1px solid gray;"); QLabel labBkg_; QLabel labIcon_; QLabel labTitle_; }; class ChartBarView : public QChartView { public: ChartBarView(QWidget* parent, QRect rt, int xfrag=5); void setTitle(std::string title); std::shared_ptr chart(); QBarSet& addItem(std::string name); void updateItem(int index, std::vector& vd); QBarSet* getBar(int index); void setBackground(QColor& color); void setAxisXTick(std::vector& vecTick); public: std::shared_ptr chart_; std::shared_ptr series_; // X轴 std::shared_ptr axisX_; // Y轴左侧 std::shared_ptr axisYLeft_; int xfrag_; QLabel labTitle_; }; class ChartLineView : QChartView { public: ChartLineView(QWidget* parent, QRect rt); void setAxisX(double min, double max, int tickCount, std::string fmt = "hh:mm"); void setAxisYLeft(double min, double max, double tickCount, std::string fmt = "%0.1f"); void addItem(std::string name); void updateItem(int index, std::vector>& vd); private: std::shared_ptr chart_; std::shared_ptr axisX; std::shared_ptr axisY; std::vector> vecSeries_; }; class ProgressView : public QWidget { public: ProgressView(QWidget* parent, int x, int y, int h, int w=3, int d=1, int n=50); void setVal(int v); int num_; QLabel labVal_; QLabel labBarBkg_; std::vector> vecBar_; }; class LabelPairV { public: LabelPairV(QWidget* parent, QRect rt, int w, std::string k, std::string v); void setVal(std::string v, std::string sty = ""); void setValStyle(std::string sty); void setKeyStyle(std::string sty); void setStyle(std::string styK, std::string styV = ""); QLabel labK_; QLabel labV_; }; class LabelPairH { public: LabelPairH(QWidget* parent, QRect rt, int w, std::string k, std::string v); void setVal(std::string v, std::string sty=""); void setValStyle(std::string sty); void setKeyStyle(std::string sty); void setStyle(std::string styK, std::string styV=""); QLabel labK_; QLabel labV_; }; class TableBase : public QObject { Q_OBJECT public: TableBase(QWidget* parent, int rowMax, int colMax); ~TableBase(); void setGeometry(int x, int y, int w, int h); void setHeaderH(std::vector vecHeader); void setHeaderWidth(std::vector vecWidth); void setOperate(std::vector vecOperate, std::function cb); void setRowData(int row, std::vector vd); void clear(); std::shared_ptr widget(); public: void onOperate(int row, std::string oper); private: std::vector vecOperate_; std::vector> vecWidgetOper_; std::function cbOper_ = nullptr; std::shared_ptr widget_; }; class PageCtrl : public QWidget { Q_OBJECT public: PageCtrl(QWidget* parent, QRect rt, int pageSize=10); void setPage(int pageId, int total); int pageSize_ = 0; int curPage_ = 0; QLabel labTotal_; QLabel labPage_; QPushButton btnPrev_; QPushButton btnNext_; QPushButton btnFirst_; QPushButton btnLast_; };