forked from bnufree/Hq
-
Notifications
You must be signed in to change notification settings - Fork 1
/
qdatamgrwidget.cpp
107 lines (97 loc) · 3.39 KB
/
qdatamgrwidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "qdatamgrwidget.h"
#include "ui_qdatamgrwidget.h"
#include "basic_info/qsharehsgttop10work.h"
#include <QThreadPool>
#include <QMessageBox>
#include "dbservices/dbservices.h"
#include "dbservices/qactivedate.h"
QDataMgrWidget::QDataMgrWidget(QWidget *parent) :
QWidget(parent),
mDataType(DATA_NONE),
ui(new Ui::QDataMgrWidget)
{
ui->setupUi(this);
//connect(ui->mCurDayText, SIGNAL(windowIconTextChanged(QString))
ui->mCurDayText->setText(QActiveDateTime::latestActiveDay().toString(DATE_FORMAT));
connect(ui->mPreDayBtn, SIGNAL(clicked()), this, SLOT(slotDayChanged()));
connect(ui->mNextDayBtn, SIGNAL(clicked()), this, SLOT(slotDayChanged()));
ui->mNextDayBtn->setVisible(false);
connect(DATA_SERVICE, SIGNAL(signalSendShareHsgtTop10List(ShareHsgtList)),
this, SLOT(slotUpdateShareHsgtTop10List(ShareHsgtList)));
connect(ui->mDataTableWidget, SIGNAL(signalDisplayMutualBundHistory(QString)),
this, SLOT(slotDisplayMutualBundHistory(QString)));
//updateData();
}
QDataMgrWidget::~QDataMgrWidget()
{
delete ui;
}
void QDataMgrWidget::slotDayChanged()
{
QAndroidButton *btn = qobject_cast<QAndroidButton*> (sender());
qDebug()<<"btn:"<<btn;
if(!btn) return;
QDate curDate = QDate::fromString(ui->mCurDayText->text(), DATE_FORMAT);
qDebug()<<"curDate:"<<curDate;
if(btn == ui->mPreDayBtn)
{
curDate = QActiveDateTime(curDate).preActiveDay();
} else
{
if(curDate != QActiveDateTime::latestActiveDay())
{
curDate = QActiveDateTime(curDate).nextActiveDay();
}
}
if(curDate == QActiveDateTime::latestActiveDay())
{
ui->mNextDayBtn->setVisible(false);
} else
{
ui->mNextDayBtn->setVisible(true);
}
qDebug()<<"new date:"<<curDate;
ui->mCurDayText->setText(curDate.toString(DATE_FORMAT));
updateData();
}
void QDataMgrWidget::setDislayDataType(int type)
{
ui->mCurDayText->setText(QDate::currentDate().toString("yyyy-MM-dd"));
updateData();
}
void QDataMgrWidget::setDataType(int type)
{
if(type != mDataType)
{
ui->mCurDayText->setText(QActiveDateTime::latestActiveDay().toString(DATE_FORMAT));
ui->mNextDayBtn->setVisible(false);
}
ui->mCurDayText->setText(TradeDateMgr::instance()->currentTradeDay().toString(DATE_FORMAT));
mDataType = type;
}
void QDataMgrWidget::updateData()
{
if(mDataType == DATA_MUTUAL_MARKET)
{
ui->mDataTableWidget->setDataList(ShareHsgtList());
emit DATA_SERVICE->signalQueryShareHsgtTop10List("", QDate::fromString(ui->mCurDayText->text(), DATE_FORMAT));
// QShareHsgtTop10Work *job = new QShareHsgtTop10Work(ui->mCurDayText->text());
// connect(job, SIGNAL(signalChinaAShareTop10Updated(ShareDataList,QString)), this, SLOT(slotUpdateShareHsgtTop10List(ShareDataList,QString)));
// QThreadPool::globalInstance()->start(job);
} else if(mDataType == DATA_LHB)
{
}
}
void QDataMgrWidget::slotUpdateShareHsgtTop10List(const ShareHsgtList &list)
{
if(list.length() == 0)
{
QMessageBox::warning(0, QStringLiteral(""), QStringLiteral("数据未找到."));
}
ui->mDataTableWidget->setDataList(list);
}
void QDataMgrWidget::slotDisplayMutualBundHistory(const QString &code)
{
ui->mDataTableWidget->setDataList(ShareHsgtList());
emit DATA_SERVICE->signalQueryShareHsgtTop10List(code, QDate());
}