完成‘折线图’数据面板的创建及时间坐标的实时同步
This commit is contained in:
parent
8860553d6e
commit
ef2a086495
|
|
@ -102,6 +102,7 @@ set(UTIL_FILES
|
|||
)
|
||||
|
||||
set(DATAPANEL_FILES
|
||||
dataPanel/dpGlobals.h
|
||||
dataPanel/dpBaseWidget.h
|
||||
dataPanel/dpBaseWidget.cpp
|
||||
dataPanel/dpLineChart.h
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@ public:
|
|||
~dpBaseWidget();
|
||||
|
||||
virtual void setTimeRange(TimeUnit) {}
|
||||
virtual void viewHistoricalData(QDateTime) {}
|
||||
virtual void setDateTime(const QDateTime&) {}
|
||||
virtual void viewHistoricalData(const QDateTime&) {}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef DP_GLOBALS_H
|
||||
#define DP_GLOBALS_H
|
||||
|
||||
enum DataPanelType
|
||||
{
|
||||
lineChart = 0, //折线图
|
||||
curveChart, //曲线图
|
||||
barChart, //柱状图
|
||||
dotChart, //点图
|
||||
pieChart, //饼图
|
||||
heatMap, //热力图
|
||||
dial, //仪表图
|
||||
table, //数据表
|
||||
map //地图
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -9,6 +9,8 @@ dpLineChart::dpLineChart(QWidget* parent)
|
|||
m_pCustomPlot = new QCustomPlot(this);
|
||||
initQCP();
|
||||
|
||||
m_timeRange = 60 * 1000;
|
||||
|
||||
QBoxLayout* mainLayout = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||
mainLayout->setContentsMargins(0, 1, 0, 0);
|
||||
mainLayout->addWidget(m_pCustomPlot);
|
||||
|
|
@ -22,49 +24,133 @@ dpLineChart::~dpLineChart()
|
|||
|
||||
void dpLineChart::initQCP()
|
||||
{
|
||||
m_pCustomPlot->axisRect()->setupFullAxesBox();
|
||||
//m_pCustomPlot->axisRect()->setupFullAxesBox();
|
||||
m_pCustomPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
|
||||
m_pCustomPlot->axisRect()->setRangeDrag(Qt::Horizontal); //只允许x轴方向的拖拽
|
||||
double zoomFactor = m_pCustomPlot->axisRect()->rangeZoomFactor(Qt::Horizontal);
|
||||
m_pCustomPlot->axisRect()->setRangeZoomFactor(zoomFactor, 1); //只做x轴的缩放
|
||||
m_pCustomPlot->xAxis->setSubTicks(false);
|
||||
m_pCustomPlot->xAxis2->setTicks(false);
|
||||
m_pCustomPlot->xAxis2->setSubTicks(false);
|
||||
m_pCustomPlot->yAxis->setSubTicks(false);
|
||||
m_pCustomPlot->yAxis2->setTicks(false);
|
||||
m_pCustomPlot->yAxis2->setSubTicks(false);
|
||||
connect(m_pCustomPlot->xAxis, SIGNAL(rangeChanged(const QCPRange&)), this, SLOT(onSignal_rangeChanged_xAxis(const QCPRange&)));
|
||||
//背景颜色
|
||||
m_pCustomPlot->setBackground(QBrush(Qt::transparent));
|
||||
//坐标轴颜色
|
||||
QColor axisColor(100, 100, 100);
|
||||
QColor axisColor(87, 100, 120);
|
||||
m_pCustomPlot->xAxis->setBasePen(axisColor);
|
||||
m_pCustomPlot->xAxis->setTickPen(axisColor);
|
||||
m_pCustomPlot->xAxis2->setBasePen(axisColor);
|
||||
m_pCustomPlot->xAxis2->setTickPen(axisColor);
|
||||
m_pCustomPlot->yAxis->setBasePen(axisColor);
|
||||
m_pCustomPlot->yAxis->setTickPen(axisColor);
|
||||
m_pCustomPlot->yAxis2->setBasePen(axisColor);
|
||||
m_pCustomPlot->yAxis2->setTickPen(axisColor);
|
||||
//坐标刻度颜色
|
||||
QColor tickColor(100, 100, 100);
|
||||
QColor tickColor(87, 100, 120);
|
||||
m_pCustomPlot->xAxis->setTickPen(QPen(tickColor));
|
||||
m_pCustomPlot->yAxis->setTickPen(QPen(tickColor));
|
||||
//坐标刻度Label颜色
|
||||
QColor tickLabelColor(250, 250, 250);
|
||||
m_pCustomPlot->xAxis->setTickLabelColor(tickLabelColor);
|
||||
m_pCustomPlot->xAxis->setTickLabelFont(QFont(QString::fromWCharArray(L"黑体"), 10));
|
||||
m_pCustomPlot->xAxis->setTickLabelFont(QFont(QString::fromWCharArray(L"黑体"), 12));
|
||||
m_pCustomPlot->yAxis->setTickLabelColor(tickLabelColor);
|
||||
m_pCustomPlot->yAxis->setTickLabelFont(QFont(QString::fromWCharArray(L"黑体"), 10));
|
||||
m_pCustomPlot->yAxis->setTickLabelFont(QFont(QString::fromWCharArray(L"黑体"), 12));
|
||||
//网格线颜色
|
||||
QColor gridColor(100, 100, 100);
|
||||
QColor gridColor(87, 100, 120);
|
||||
m_pCustomPlot->xAxis->grid()->setPen(QPen(gridColor, 1, Qt::DotLine));
|
||||
m_pCustomPlot->xAxis->grid()->setZeroLinePen(QPen(gridColor, 1, Qt::DotLine));
|
||||
//m_pCustomPlot->xAxis2->grid()->setPen(QPen(gridColor, 1, Qt::DotLine));
|
||||
m_pCustomPlot->yAxis->grid()->setPen(QPen(gridColor, 1, Qt::DotLine));
|
||||
m_pCustomPlot->yAxis->grid()->setZeroLinePen(QPen(gridColor, 1, Qt::DotLine));
|
||||
//m_pCustomPlot->yAxis2->grid()->setPen(QPen(gridColor, 1, Qt::DotLine));
|
||||
//x轴用时间格式
|
||||
QSharedPointer<QCPAxisTickerDateTime> timeTicker(new QCPAxisTickerDateTime);
|
||||
timeTicker->setDateTimeFormat("hh:mm:ss:zzz\nyyyy/MM/dd");
|
||||
//qDebug() << timeTicker->dateTimeFormat();
|
||||
m_pCustomPlot->xAxis->setTicker(timeTicker);
|
||||
//qDebug() << m_pCustomPlot->xAxis->range();
|
||||
}
|
||||
|
||||
void dpLineChart::setTimeRange(TimeUnit unit)
|
||||
{
|
||||
|
||||
switch(unit)
|
||||
{
|
||||
case TU_Year:
|
||||
m_timeRange = m_curDateTime.date().daysInYear() * 24 * 60 * 60 * (qint64)1000;
|
||||
break;
|
||||
case TU_Month:
|
||||
m_timeRange = m_curDateTime.date().daysInMonth() * 24 * 60 * 60 * (qint64)1000;
|
||||
break;
|
||||
case TU_Day:
|
||||
m_timeRange = 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
case TU_Hour:
|
||||
m_timeRange = 60 * 60 *1000;
|
||||
break;
|
||||
case TU_Minute_30:
|
||||
m_timeRange = 30 * 60 *1000;
|
||||
break;
|
||||
case TU_Minute_20:
|
||||
m_timeRange = 20 * 60 *1000;
|
||||
break;
|
||||
case TU_Minute_15:
|
||||
m_timeRange = 15 * 60 *1000;
|
||||
break;
|
||||
case TU_Minute_10:
|
||||
m_timeRange = 10 * 60 *1000;
|
||||
break;
|
||||
case TU_Minute_5:
|
||||
m_timeRange = 5 * 60 *1000;
|
||||
break;
|
||||
case TU_Minute_3:
|
||||
m_timeRange = 3 * 60 *1000;
|
||||
break;
|
||||
case TU_Minute_1:
|
||||
m_timeRange = 60 * 1000;
|
||||
break;
|
||||
case TU_Second_30:
|
||||
m_timeRange = 30 * 1000;
|
||||
break;
|
||||
case TU_Second_10:
|
||||
m_timeRange = 10 * 1000;
|
||||
break;
|
||||
case TU_Second_1:
|
||||
m_timeRange = 1 * 1000;
|
||||
break;
|
||||
case TU_MSecond_500:
|
||||
m_timeRange = 500;
|
||||
break;
|
||||
case TU_MSecond_100:
|
||||
m_timeRange = 100;
|
||||
break;
|
||||
case TU_MSecond_50:
|
||||
m_timeRange = 50;
|
||||
break;
|
||||
case TU_MSecond_10:
|
||||
m_timeRange = 10;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dpLineChart::viewHistoricalData(QDateTime dateTime)
|
||||
void dpLineChart::setDateTime(const QDateTime& dateTime)
|
||||
{
|
||||
qint64 timeValue = dateTime.toMSecsSinceEpoch() / 1000.0;
|
||||
//qint64 timeValue = QCPAxisTickerDateTime::dateTimeToKey(dateTime);
|
||||
m_pCustomPlot->xAxis->setRange(timeValue, m_timeRange / 1000.0, Qt::AlignRight);
|
||||
m_pCustomPlot->replot();
|
||||
m_curDateTime = dateTime;
|
||||
}
|
||||
|
||||
void dpLineChart::viewHistoricalData(const QDateTime& dateTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void dpLineChart::onSignal_rangeChanged_xAxis(const QCPRange& range)
|
||||
{
|
||||
// qDebug() << "m_timeRange: " << m_timeRange;
|
||||
// qDebug() << "range size: " << range.size();
|
||||
if(m_timeRange != range.size() * 1000)
|
||||
m_timeRange = range.size() * 1000;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "dpBaseWidget.h"
|
||||
|
||||
class QCustomPlot;
|
||||
class QCPRange;
|
||||
|
||||
class dpLineChart : public dpBaseWidget
|
||||
{
|
||||
|
|
@ -23,12 +24,18 @@ public:
|
|||
~dpLineChart();
|
||||
|
||||
void setTimeRange(TimeUnit);
|
||||
void viewHistoricalData(QDateTime);
|
||||
void setDateTime(const QDateTime&);
|
||||
void viewHistoricalData(const QDateTime&);
|
||||
|
||||
public slots:
|
||||
void onSignal_rangeChanged_xAxis(const QCPRange&);
|
||||
|
||||
private:
|
||||
void initQCP();
|
||||
|
||||
QCustomPlot* m_pCustomPlot;
|
||||
qint64 m_timeRange;
|
||||
QDateTime m_curDateTime;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "qboxlayout.h"
|
||||
#include <QObject>
|
||||
#include "global.h"
|
||||
#include "dataPanel/dpGlobals.h"
|
||||
|
||||
class DashboardFrame;
|
||||
class CustomTab;
|
||||
|
|
@ -24,10 +26,12 @@ public:
|
|||
CustomTab* tab();
|
||||
QWidget* displayArea();
|
||||
void setActive(bool);
|
||||
void addPanel(const QString&);
|
||||
void addPanel(DataPanelType);
|
||||
void removePanel(const QString&);
|
||||
void resizePanel(double, double);
|
||||
void deleteSubWidgets();
|
||||
void setDateTime(const QDateTime&);
|
||||
void setTimeRange(TimeUnit);
|
||||
|
||||
public slots:
|
||||
void contextMenu_tab(const QPoint&);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include "global.h"
|
||||
#include "dataPanel/dpGlobals.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
|
|
@ -80,7 +81,7 @@ public slots:
|
|||
void onSignal_removeDashboard();
|
||||
void onSignal_dashboardNaming(const QString&, const QString&);
|
||||
void onSignal_dashboardTabMoved(int, int); //拖动tab引发了位置变化
|
||||
void onSignal_panelSelectResult(const QString&);
|
||||
void onSignal_panelSelectResult(DataPanelType);
|
||||
|
||||
void onSignal_timeRangeChanged(TimeUnit);
|
||||
void onSignal_viewRealTimeData();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
#define DATAPANEL_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "global.h"
|
||||
#include "dataPanel/dpGlobals.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
|
|
@ -35,7 +37,7 @@ class DataPanel : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DataPanel(QWidget *parent = nullptr);
|
||||
DataPanel(QWidget *parent = nullptr, DataPanelType type = lineChart);
|
||||
~DataPanel();
|
||||
|
||||
/**
|
||||
|
|
@ -61,6 +63,8 @@ public:
|
|||
void setDisplayAreaSize(const QSize&);
|
||||
void resizeByRatio(double, double); //通过缩放比例做resize,在所属dasboard的resizeEvent中调用
|
||||
void resizeByNewSize(const QSize&); //通过新的尺寸(所在区域)做resize,当所属dashboard被激活(显示)时调用
|
||||
void setDateTime(const QDateTime&);
|
||||
void setTimeRange(TimeUnit);
|
||||
|
||||
protected:
|
||||
bool event(QEvent*);
|
||||
|
|
@ -87,6 +91,7 @@ signals:
|
|||
private:
|
||||
void setupScrollArea();
|
||||
void autoSetGeometry(); //在缩放和移动时以其它panel和parent的border为依据自动调整
|
||||
void createDataWidget(DataPanelType);
|
||||
|
||||
bool m_bMouseEnter;
|
||||
bool m_bConfigurationComplete;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public:
|
|||
DateTimeWidget(QWidget *parent = nullptr);
|
||||
~DateTimeWidget();
|
||||
|
||||
void setDateTime(QDateTime);
|
||||
void setDateTime(const QDateTime&);
|
||||
void setState(DateTimeWidgetState);
|
||||
void setRange(TimeUnit);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define PANELSELECTIONDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "dataPanel/dpGlobals.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
|
|
@ -21,7 +22,7 @@ protected:
|
|||
//void showEvent(QShowEvent*);
|
||||
|
||||
signals:
|
||||
void panelType(const QString&);
|
||||
void panelType(DataPanelType);
|
||||
void sgl_hide();
|
||||
|
||||
public slots:
|
||||
|
|
@ -29,6 +30,8 @@ public slots:
|
|||
void onBtnClicked_cancle();
|
||||
|
||||
private:
|
||||
void initList();
|
||||
|
||||
Ui::panelSelectionDialog* ui;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <QMenu>
|
||||
#include <QVBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QDateTime>
|
||||
|
||||
#define tabButtonHeight 41
|
||||
Dashboard::Dashboard(const QString& strName, QObject *parent)
|
||||
|
|
@ -134,9 +135,9 @@ void Dashboard::setActive(bool bActive)
|
|||
m_pTab->setActive(bActive);
|
||||
}
|
||||
|
||||
void Dashboard::addPanel(const QString& strType)
|
||||
void Dashboard::addPanel(DataPanelType type)
|
||||
{
|
||||
DataPanel* panel = new DataPanel(m_pDisplayArea);
|
||||
DataPanel* panel = new DataPanel(m_pDisplayArea, type);
|
||||
connect(panel, SIGNAL(sgl_remove(const QString&)), this, SLOT(onSignal_removePanel(const QString&)));
|
||||
QString strDefaultName = "dataPanel-" + QString::number(m_nPanenlNameNumber);
|
||||
m_nPanenlNameNumber++;
|
||||
|
|
@ -178,6 +179,18 @@ void Dashboard::resizePanel(double ratioX, double ratioY)
|
|||
m_dataPanels.at(n)->resizeByRatio(ratioX, ratioY);
|
||||
}
|
||||
|
||||
void Dashboard::setDateTime(const QDateTime& dateTime)
|
||||
{
|
||||
for(int n = 0; n < m_dataPanels.count(); n++)
|
||||
m_dataPanels.at(n)->setDateTime(dateTime);
|
||||
}
|
||||
|
||||
void Dashboard::setTimeRange(TimeUnit unit)
|
||||
{
|
||||
for(int n = 0; n < m_dataPanels.count(); n++)
|
||||
m_dataPanels.at(n)->setTimeRange(unit);
|
||||
}
|
||||
|
||||
void Dashboard::contextMenu_tab(const QPoint& pos)
|
||||
{
|
||||
QPoint originPoint = m_pTab->mapToGlobal(QPoint(0, 0));
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ void DashboardFrame::onBtnClicked_addDataPanel()
|
|||
m_pPanelSelectionDialog = new PanelSelectionDialog(this);
|
||||
m_pPanelSelectionDialog->installEventFilter(this);
|
||||
connect(m_pPanelSelectionDialog, SIGNAL(sgl_hide()), this, SLOT(onSignal_subDialogClose()));
|
||||
connect(m_pPanelSelectionDialog, SIGNAL(panelType(const QString&)), this, SLOT(onSignal_panelSelectResult(const QString&)));
|
||||
connect(m_pPanelSelectionDialog, SIGNAL(panelType(DataPanelType)), this, SLOT(onSignal_panelSelectResult(DataPanelType)));
|
||||
}
|
||||
|
||||
showTransparentMask();
|
||||
|
|
@ -557,6 +557,8 @@ void DashboardFrame::onTimeout_realTime()
|
|||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
m_pDateTimeWidget->setDateTime(curDateTime);
|
||||
m_pTimeLineWidget->setDateTime(curDateTime);
|
||||
if(m_curActiveDashboard)
|
||||
m_curActiveDashboard->setDateTime(curDateTime);
|
||||
}
|
||||
|
||||
void DashboardFrame::onSignal_subDialogClose()
|
||||
|
|
@ -627,11 +629,11 @@ void DashboardFrame::onSignal_renameDashboard()
|
|||
m_pDashboardNamingDialog->raise();
|
||||
}
|
||||
|
||||
void DashboardFrame::onSignal_panelSelectResult(const QString& strType)
|
||||
void DashboardFrame::onSignal_panelSelectResult(DataPanelType type)
|
||||
{
|
||||
//m_pPanelSelectionDialog->hide();
|
||||
hideTransparentMask();
|
||||
m_curActiveDashboard->addPanel(strType);
|
||||
m_curActiveDashboard->addPanel(type);
|
||||
}
|
||||
|
||||
void DashboardFrame::onSignal_timeRangeChanged(TimeUnit unit)
|
||||
|
|
@ -645,6 +647,9 @@ void DashboardFrame::onSignal_timeRangeChanged(TimeUnit unit)
|
|||
{
|
||||
m_pDateTimeWidget->setRange(unit);
|
||||
}
|
||||
|
||||
if(m_curActiveDashboard)
|
||||
m_curActiveDashboard->setTimeRange(unit);
|
||||
}
|
||||
|
||||
void DashboardFrame::onSignal_viewRealTimeData()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include "customBorderContainer.h"
|
||||
#include "customMenu.h"
|
||||
|
||||
#include "dataPanel/dpLineChart.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QBoxLayout>
|
||||
#include <QScrollArea>
|
||||
|
|
@ -25,7 +27,7 @@ PanelToolWidget::~PanelToolWidget()
|
|||
}
|
||||
|
||||
|
||||
DataPanel::DataPanel(QWidget *parent)
|
||||
DataPanel::DataPanel(QWidget *parent, DataPanelType type)
|
||||
: QDialog(parent)
|
||||
{
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::SubWindow);
|
||||
|
|
@ -40,14 +42,14 @@ DataPanel::DataPanel(QWidget *parent)
|
|||
centralWidget->setObjectName("centralWidget");
|
||||
centralWidget->setStyleSheet("QWidget #centralWidget{\n"
|
||||
" border:2px solid rgb(76,88,105);\n"
|
||||
" background-color:rgba(36,43,50,250);\n"
|
||||
" background-color:rgba(24,32,38,250);\n"
|
||||
"}\n");
|
||||
QBoxLayout* centralLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
|
||||
centralLayout->setContentsMargins(0, 0, 0, 0);
|
||||
centralLayout->addWidget(centralWidget);
|
||||
setLayout(centralLayout);
|
||||
m_pLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
|
||||
m_pLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_pLayout = new QBoxLayout(QBoxLayout::TopToBottom, centralWidget);
|
||||
m_pLayout->setContentsMargins(10, 5, 10, 10);
|
||||
m_pLayout->setSpacing(0);
|
||||
centralWidget->setLayout(m_pLayout);
|
||||
|
||||
|
|
@ -70,6 +72,8 @@ DataPanel::DataPanel(QWidget *parent)
|
|||
m_pToolMenu->addAction(QString::fromWCharArray(L"移除面板"), this, SLOT(onAction_remove()));
|
||||
//m_pToolMenu->addAction(QString::fromWCharArray(L"放置最前"), this, SLOT(onAction_moveToFront()));
|
||||
m_pToolMenu->addAction(QString::fromWCharArray(L"放置最后"), this, SLOT(onAction_moveToBack()));
|
||||
|
||||
createDataWidget(type);
|
||||
}
|
||||
|
||||
DataPanel::~DataPanel()
|
||||
|
|
@ -181,6 +185,21 @@ void DataPanel::autoSetGeometry()
|
|||
|
||||
}
|
||||
|
||||
void DataPanel::createDataWidget(DataPanelType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case lineChart:
|
||||
{
|
||||
dpLineChart* lineChart = new dpLineChart(this);
|
||||
setWiget(lineChart);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DataPanel::setWiget(QWidget* pWidget, eInsertMode InsertMode)
|
||||
{
|
||||
if(m_pContentWidget)
|
||||
|
|
@ -303,6 +322,20 @@ void DataPanel::resizeByNewSize(const QSize& newSize)
|
|||
resizeByRatio(ratioX, ratioY);
|
||||
}
|
||||
|
||||
void DataPanel::setDateTime(const QDateTime& dateTime)
|
||||
{
|
||||
dpBaseWidget* baseWidget = qobject_cast<dpBaseWidget*>(m_pContentWidget);
|
||||
if(baseWidget)
|
||||
baseWidget->setDateTime(dateTime);
|
||||
}
|
||||
|
||||
void DataPanel::setTimeRange(TimeUnit unit)
|
||||
{
|
||||
dpBaseWidget* baseWidget = qobject_cast<dpBaseWidget*>(m_pContentWidget);
|
||||
if(baseWidget)
|
||||
baseWidget->setTimeRange(unit);
|
||||
}
|
||||
|
||||
void DataPanel::onToolBtnClicked_setting()
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ void DateTimeWidget::setState(DateTimeWidgetState state)
|
|||
}
|
||||
}
|
||||
|
||||
void DateTimeWidget::setDateTime(QDateTime dateTime)
|
||||
void DateTimeWidget::setDateTime(const QDateTime& dateTime)
|
||||
{
|
||||
QString strTime = dateTime.time().toString("HH:mm:ss");
|
||||
ui->label_time->setText(strTime);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include "panelSelectionDialog.h"
|
||||
#include "ui_panelSelectionDialog.h"
|
||||
|
||||
#define panelTye 1
|
||||
|
||||
PanelSelectionDialog::PanelSelectionDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::panelSelectionDialog)
|
||||
|
|
@ -8,8 +10,8 @@ PanelSelectionDialog::PanelSelectionDialog(QWidget *parent)
|
|||
ui->setupUi(this);
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
if(ui->listWidget->count() > 0)
|
||||
ui->listWidget->setCurrentRow(0);
|
||||
|
||||
initList();
|
||||
|
||||
connect(ui->btnConfirm, SIGNAL(clicked()), this, SLOT(onBtnClicked_confirm()));
|
||||
connect(ui->btnCancle, SIGNAL(clicked()), this, SLOT(onBtnClicked_cancle()));
|
||||
|
|
@ -20,6 +22,41 @@ PanelSelectionDialog::~PanelSelectionDialog()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void PanelSelectionDialog::initList()
|
||||
{
|
||||
ui->listWidget->clear();
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem(QString::fromWCharArray(L"折线图"));
|
||||
item->setData(Qt::UserRole + panelTye, lineChart);
|
||||
ui->listWidget->addItem(item);
|
||||
item = new QListWidgetItem(QString::fromWCharArray(L"曲线图"));
|
||||
item->setData(Qt::UserRole + panelTye, curveChart);
|
||||
ui->listWidget->addItem(item);
|
||||
item = new QListWidgetItem(QString::fromWCharArray(L"柱状图"));
|
||||
item->setData(Qt::UserRole + panelTye, barChart);
|
||||
ui->listWidget->addItem(item);
|
||||
item = new QListWidgetItem(QString::fromWCharArray(L"点状图"));
|
||||
item->setData(Qt::UserRole + panelTye, dotChart);
|
||||
ui->listWidget->addItem(item);
|
||||
item = new QListWidgetItem(QString::fromWCharArray(L"饼状图"));
|
||||
item->setData(Qt::UserRole + panelTye, pieChart);
|
||||
ui->listWidget->addItem(item);
|
||||
item = new QListWidgetItem(QString::fromWCharArray(L"热力图"));
|
||||
item->setData(Qt::UserRole + panelTye, heatMap);
|
||||
ui->listWidget->addItem(item);
|
||||
item = new QListWidgetItem(QString::fromWCharArray(L"仪表盘"));
|
||||
item->setData(Qt::UserRole + panelTye, dial);
|
||||
ui->listWidget->addItem(item);
|
||||
item = new QListWidgetItem(QString::fromWCharArray(L"数据表"));
|
||||
item->setData(Qt::UserRole + panelTye, table);
|
||||
ui->listWidget->addItem(item);
|
||||
item = new QListWidgetItem(QString::fromWCharArray(L"地图"));
|
||||
item->setData(Qt::UserRole + panelTye, map);
|
||||
ui->listWidget->addItem(item);
|
||||
|
||||
ui->listWidget->setCurrentRow(0);
|
||||
}
|
||||
|
||||
// void PanelSelectionDialog::showEvent(QShowEvent* event)
|
||||
// {
|
||||
// Q_UNUSED(event);
|
||||
|
|
@ -32,10 +69,10 @@ void PanelSelectionDialog::onBtnClicked_confirm()
|
|||
QListWidgetItem* item = ui->listWidget->currentItem();
|
||||
if(item)
|
||||
{
|
||||
QString strType = item->text();
|
||||
DataPanelType type = (DataPanelType)item->data(Qt::UserRole + panelTye).toInt();
|
||||
ui->listWidget->setCurrentRow(0);
|
||||
hide();
|
||||
emit panelType(strType);
|
||||
emit panelType(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>427</width>
|
||||
<height>344</height>
|
||||
<height>365</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -94,7 +94,7 @@ border-right:0px;</string>
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>330</x>
|
||||
<y>300</y>
|
||||
<y>320</y>
|
||||
<width>71</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
|
|
@ -128,7 +128,7 @@ background-color:rgb(24,32,38);
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>300</y>
|
||||
<y>320</y>
|
||||
<width>71</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
|
|
@ -164,7 +164,7 @@ background-color:rgb(67,160,249);
|
|||
<x>40</x>
|
||||
<y>70</y>
|
||||
<width>341</width>
|
||||
<height>211</height>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
|
|
@ -175,6 +175,11 @@ background-color:rgb(67,160,249);
|
|||
<string>折线图</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>曲线图</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>柱状图</string>
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ void TimeLineItem::setState(DateTimeWidgetState state)
|
|||
d_ptr->m_curState = state;
|
||||
}
|
||||
|
||||
void TimeLineItem::setTime(QDateTime time)
|
||||
void TimeLineItem::setTime(const QDateTime& time)
|
||||
{
|
||||
if(time > QDateTime::currentDateTime())
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public:
|
|||
void setScaleSize(int);
|
||||
void setState(DateTimeWidgetState);
|
||||
|
||||
void setTime(QDateTime);
|
||||
void setTime(const QDateTime&);
|
||||
QDateTime time();
|
||||
|
||||
qint64 getOffsetTimeValue(int); //获取时间的偏移值(相对当前时间,在鼠标移动拖拽时调用,通过拖拽时同步更改当前时间继而重绘时间轴从而模拟出拖拽效果)
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ void TimeLineWidget::setTimeScaleUnit(TimeUnit unit)
|
|||
d_ptr->m_timeLineItem->setTimeUnit(unit);
|
||||
}
|
||||
|
||||
void TimeLineWidget::setDateTime(QDateTime dateTime)
|
||||
void TimeLineWidget::setDateTime(const QDateTime& dateTime)
|
||||
{
|
||||
d_ptr->m_timeLineItem->setTime(dateTime);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public:
|
|||
void setTimeScaleSize(int); //设置时间刻度大小(像素)
|
||||
void setTimeScaleUnit(TimeUnit); //设置时间刻度单位
|
||||
|
||||
void setDateTime(QDateTime);
|
||||
void setDateTime(const QDateTime&);
|
||||
void setDisplayState(DateTimeWidgetState);
|
||||
|
||||
void syncTimeUnit();
|
||||
|
|
|
|||
Loading…
Reference in New Issue