Skip to content

Commit

Permalink
最新代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Edeseses committed Jul 13, 2017
1 parent 22fb4c7 commit 631b774
Show file tree
Hide file tree
Showing 24 changed files with 810 additions and 755 deletions.
14 changes: 12 additions & 2 deletions Hq.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ SOURCES += main.cpp\
dbservices.cpp \
qeastmoneychinashareexchange.cpp \
qindexframe.cpp \
qindexwidget.cpp
qindexwidget.cpp \
qeastmonystockcodesthread.cpp \
qeastmoneyblocksharethread.cpp \
qeastmoneyblockmangagerthread.cpp \
qeastmoneysharefhspthread.cpp \
qhttpget.cpp

HEADERS += dialog.h \
stockdata.h \
Expand Down Expand Up @@ -70,7 +75,12 @@ HEADERS += dialog.h \
hqdatadefines.h \
qeastmoneychinashareexchange.h \
qindexframe.h \
qindexwidget.h
qindexwidget.h \
qeastmonystockcodesthread.h \
qeastmoneyblocksharethread.h \
qeastmoneyblockmangagerthread.h \
qeastmoneysharefhspthread.h \
qhttpget.h

FORMS += dialog.ui \
qexchangedatemangagedialog.ui \
Expand Down
2 changes: 1 addition & 1 deletion Hq.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.3.0, 2017-05-22T13:13:22. -->
<!-- Written by QtCreator 3.3.0, 2017-07-13T17:50:35. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
137 changes: 72 additions & 65 deletions dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <QDesktopWidget>
#include <QResizeEvent>
#include "qindexwidget.h"
#include "qeastmonystockcodesthread.h"

#define STK_ZXG_SEC "0520"
#define STK_HSJJ_SEC "4521"
Expand All @@ -38,7 +39,7 @@ class HqTableWidgetItem : public QTableWidgetItem
};

Dialog::Dialog(QWidget *parent) :
QDialog(parent),mBlockThread(NULL)/*,mStockThread(NULL)*/,mSearchThread(NULL),mDisplayCol(0),
QDialog(parent),mBlockMgr(NULL)/*,mStockThread(NULL)*/,mSearchThread(NULL),mDisplayCol(0),mMergeThread(0),
ui(new Ui::MainDialog)
{
ui->setupUi(this);
Expand Down Expand Up @@ -106,7 +107,6 @@ Dialog::Dialog(QWidget *parent) :
ui->closeBtn->setIcon(style()->standardPixmap(QStyle::SP_TitleBarCloseButton));
ui->minBtn->setIcon(style()->standardIcon(QStyle::SP_TitleBarMinButton));
//ui->srchBtn->setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
#if 1
//系统托盘
QIcon appIcon = QIcon(":/icon/image/Baidu_96px.png");
if(appIcon.isNull())
Expand All @@ -131,24 +131,28 @@ Dialog::Dialog(QWidget *parent) :
mIndexThread->setStkList(indexlist);
mIndexThread->start();

//更新所有的代码
QEastMonyStockCodesThread * codes = new QEastMonyStockCodesThread();
connect(codes, SIGNAL(signalSendCodesList(QStringList)), this, SLOT(slotUpdateStockCodesList(QStringList)));
connect(codes, SIGNAL(finished()), codes, SLOT(deleteLater()));
codes->start();
#if 0

//行情初始化
// mStockThread = new QSinaStkInfoThread;
// connect(mStockThread, SIGNAL(sendStkDataList(StockDataList)), this, SLOT(updateHqTable(StockDataList)));
// mStockThread->start();
mBlockThread = new QEastMoneyBlockThread;
connect(mBlockThread, SIGNAL(sendBlockDataList(BlockDataList)), this, SLOT(updateBlockTable(BlockDataList)));
connect(mBlockThread, SIGNAL(updateBlockCodesFinished()), this, SLOT(displayBlockRealtimeInfo()));
mBlockThread->start();
//行情中心初始化开始
mMergeThread = new QSinaStkResultMergeThread();
connect(mMergeThread, SIGNAL(sendStkDataList(StockDataList)), this, SLOT(updateHqTable(StockDataList)));
mMergeThread->setMktType(MKT_ALL);
mMergeThread->start();
//板块行情初始化
mBlockMgr = new QEastMoneyBlockMangagerThread();
mBlockMgr->setCurBlockType(2);
connect(mBlockMgr, SIGNAL(signalBlockDataListUpdated(BlockDataList)), this, SLOT(updateBlockTable(BlockDataList)));
mBlockMgr->start();
mSearchThread = new QSinaSearchThread;
connect(mSearchThread, SIGNAL(sendSearchResult(QStringList)), this, SLOT(displayBlockDetailInfoInTable(QStringList)));
mSearchThread->start();
mMergeThread = new QSinaStkResultMergeThread;
connect(mMergeThread, SIGNAL(sendStkDataList(StockDataList)), this, SLOT(updateHqTable(StockDataList)));
mMergeThread->setMktType(MKT_ZXG);
connect(mBlockThread, SIGNAL(sendStkinfoUpdateProgress(int,int)), this, SLOT(slotUpdate(int,int)));
connect(mBlockThread, SIGNAL(signalUpdateMsg(QString)), this, SLOT(slotUpdateMsg(QString)));
// mMergeThread->start();
// connect(mBlockThread, SIGNAL(sendStkinfoUpdateProgress(int,int)), this, SLOT(slotUpdate(int,int)));
// connect(mBlockThread, SIGNAL(signalUpdateMsg(QString)), this, SLOT(slotUpdateMsg(QString)));

//读取自选
mFavStkList = Profiles::instance()->value(STK_ZXG_SEC, STK_ZXG_NAME).toStringList();
Expand All @@ -157,8 +161,6 @@ Dialog::Dialog(QWidget *parent) :
mMergeThread->setActive(true);
mMergeThread->setMktType(MKT_ZXG);

#endif
// on_zxgBtn_clicked();
mCurBlockType = BLOCK_INDUSTORY;

//创建快捷事件
Expand All @@ -174,8 +176,7 @@ Dialog::Dialog(QWidget *parent) :
mInit = false;

iniHqCenterAction();
//((QHBoxLayout*) ui->btnframe->layout())->setStretch(0, /*ui->blocktbl->columnCount()*/2);
//((QHBoxLayout*) ui->btnframe->layout())->setStretch(1, /*ui->hqtbl->columnCount()*/3);
#endif
}

void Dialog::setDlgShow(QSystemTrayIcon::ActivationReason val)
Expand Down Expand Up @@ -232,38 +233,33 @@ void Dialog::displayBlockRealtimeInfo()
{
ui->updatelbl->clear();
// MktCapFile::instance()->setValue("Update", "time", QDateTime::currentDateTime().toTime_t());
if(mMergeThread)
{
mMergeThread->start();
mMergeThread->setActive(true);
}
if(mBlockThread)
{
mBlockThread->SetUpdateBlockCodes(false);
if(mBlockThread->isFinished())
{
mBlockThread->start();
}
}
// if(mMergeThread)
// {
// mMergeThread->start();
// mMergeThread->setActive(true);
// }
// if(mBlockThread)
// {
// mBlockThread->SetUpdateBlockCodes(false);
// if(mBlockThread->isFinished())
// {
// mBlockThread->start();
// }
// }
}

Dialog::~Dialog()
{
//unHook();
qDebug()<<"close dialog now";
// if(mStockThread) mStockThread->deleteLater();
if(mBlockThread) mBlockThread->deleteLater();
// qDebug()<<"close dialog now";
//// if(mStockThread) mStockThread->deleteLater();
// if(mBlockThread) mBlockThread->deleteLater();
delete ui;
}

void Dialog::setSortType(int index)
{
if(index < 2 || index > 13) return;
// if(mStockThread && mStockThread->isActive())
// {
// mStockThread->setOptType((STK_DISPLAY_TYPE)(index-2));
// }

if(mMergeThread && mMergeThread->isActive())
{
mMergeThread->setSortType((STK_DISPLAY_TYPE)(index-2));
Expand All @@ -275,28 +271,27 @@ void Dialog::setBlockSort(int val)
{
qDebug("click val = %d, total = %d", val, ui->blocktbl->rowCount() -1);
if(val != 1) return;
if(mBlockThread) mBlockThread->reverseSortRule();
if(mBlockMgr) mBlockMgr->reverseSortRule();
}

void Dialog::setBlockName()
{
if(!mBlockThread) return;
QAction *act = (QAction*)sender();
if(act == NULL) return;
int index = act->data().toInt();
mCurBlockType = index;
mBlockThread->setOptType((BLOCK_OPT_TYPE)index);
if(mBlockMgr) mBlockMgr->setCurBlockType(mCurBlockType);
qDebug()<<"act name:"<<act->text();

}

void Dialog::on_zxgBtn_clicked()
{
if(mMergeThread) /*mMergeThread->setActive(false);*/
{
mMergeThread->setSelfCodesList(mFavStkList);
mMergeThread->setMktType(MKT_ZXG);
}
// if(mMergeThread) /*mMergeThread->setActive(false);*/
// {
// mMergeThread->setSelfCodesList(mFavStkList);
// mMergeThread->setMktType(MKT_ZXG);
// }
// if(mStockThread)
// {
// mStockThread->setActive(true);
Expand Down Expand Up @@ -575,25 +570,16 @@ void Dialog::updateHqTable(const StockDataList& pDataList)
void Dialog::updateBlockTable(const BlockDataList& pDataList)
{
qDebug()<<"input:"<<pDataList.length();
if(pDataList.length() == 0) return;
// if(pDataList.length() == 0) return;

//ui->blocktbl->clearContents();
int totalrow = pDataList.length();
// //ui->blocktbl->clearContents();
// int totalrow = pDataList.length();
ui->blocktbl->setRowCount(pDataList.count());

int i=0;
foreach (BlockData data, pDataList) {
mBlockNameMap[data.code] = data.name;
mBlockStkList[data.code] = data.stklist;
if((data.code.left(1) == "1" && mCurBlockType != BLOCK_DISTRICT)||
(data.code.left(1) == "2" && mCurBlockType != BLOCK_INDUSTORY) ||
(data.code.left(1) == "3" && mCurBlockType != BLOCK_CONCEPT))
{
mBlockMap[data.code] = data.changePer;
ui->blocktbl->setRowCount(--totalrow );
continue;
}
// mBlockMap[data.code] = data.changePer;;
// if(i > totalrow-1) continue;
int k =0;
ui->blocktbl->setRowHeight(i, 20);
ui->blocktbl->setItem(i, k++, new HqTableWidgetItem(data.name));
Expand Down Expand Up @@ -625,7 +611,6 @@ void Dialog::updateBlockTable(const BlockDataList& pDataList)

void Dialog::on_blocktbl_itemDoubleClicked(QTableWidgetItem *item)
{
qDebug()<<"double block";
if(item == NULL) return;
QTableWidgetItem *wkItem = item;
if(wkItem->column() != 0){
Expand Down Expand Up @@ -740,7 +725,7 @@ void Dialog::editFavorite()
{
mFavStkList.append(code);
}
if(mMergeThread && mMergeThread->getMktType() == MKT_ZXG) mMergeThread->setSelfCodesList(mFavStkList);
//if(mMergeThread && mMergeThread->getMktType() == MKT_ZXG) mMergeThread->setSelfCodesList(mFavStkList);
Profiles::instance()->setValue(STK_ZXG_SEC, STK_ZXG_NAME, mFavStkList);
qDebug()<<"fav:"<<mFavStkList;
}
Expand Down Expand Up @@ -800,7 +785,7 @@ void Dialog::on_hqtbl_itemDoubleClicked(QTableWidgetItem *item)
{
mFavStkList.append(code);
}
if(mMergeThread && mMergeThread->getMktType() == MKT_ZXG) mMergeThread->setSelfCodesList(mFavStkList);
// if(mMergeThread && mMergeThread->getMktType() == MKT_ZXG) mMergeThread->setSelfCodesList(mFavStkList);
Profiles::instance()->setValue(STK_ZXG_SEC, STK_ZXG_NAME, mFavStkList);
qDebug()<<"fav:"<<mFavStkList;
}
Expand Down Expand Up @@ -979,3 +964,25 @@ void Dialog::on_blocktbl_itemClicked(QTableWidgetItem *item)
{
item->tableWidget()->horizontalHeader()->setHighlightSections(false);
}

void Dialog::slotUpdateStockCodesList(const QStringList &list)
{
//开始更新历史信息,龙虎榜信息,沪港通信息

//开启线程,更新股票的相关信息
if(mMergeThread)mMergeThread->setStkList(list);

// mMergeThread = new QSinaStkResultMergeThread;
// connect(mMergeThread, SIGNAL(sendStkDataList(StockDataList)), this, SLOT(updateHqTable(StockDataList)));
// mMergeThread->setMktType(MKT_ZXG);
// connect(mBlockThread, SIGNAL(sendStkinfoUpdateProgress(int,int)), this, SLOT(slotUpdate(int,int)));
// connect(mBlockThread, SIGNAL(signalUpdateMsg(QString)), this, SLOT(slotUpdateMsg(QString)));
//// mMergeThread->start();

// //读取自选
// mFavStkList = Profiles::instance()->value(STK_ZXG_SEC, STK_ZXG_NAME).toStringList();
// mHSFoundsList = Profiles::instance()->value(STK_HSJJ_SEC, STK_ZXG_NAME).toStringList();
// mMergeThread->setSelfCodesList(mFavStkList);
// mMergeThread->setActive(true);
// mMergeThread->setMktType(MKT_ZXG);
}
5 changes: 3 additions & 2 deletions dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <QDialog>
#include <QSystemTrayIcon>
#include <QTableWidget>
#include "qeastmoneyblockthread.h"
#include "qeastmoneyblockmangagerthread.h"
#include "qsinastkinfothread.h"
#include "qsinasearchthread.h"
#include "qsinastkresultmergethread.h"
Expand Down Expand Up @@ -77,6 +77,7 @@ public slots:
void slotDisplayBlock();
void slotDisplayStockFull();
void slotDisplayStockMini();
void slotUpdateStockCodesList(const QStringList& list);

private slots:
void on_zxgBtn_clicked();
Expand Down Expand Up @@ -119,7 +120,7 @@ private slots:
Ui::MainDialog *ui;
QSystemTrayIcon *systemIcon;
QSinaStkInfoThread *mIndexThread;
QEastMoneyBlockThread *mBlockThread;
QEastMoneyBlockMangagerThread *mBlockMgr;
QSinaStkResultMergeThread *mMergeThread;
QSinaSearchThread *mSearchThread;
QMap<QString, double> mStockMap;
Expand Down
50 changes: 50 additions & 0 deletions qeastmoneyblockmangagerthread.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "qeastmoneyblockmangagerthread.h"
#include <QDebug>

QEastMoneyBlockMangagerThread::QEastMoneyBlockMangagerThread(QObject *parent) : QThread(parent)
{
mCurBlockType = 2;
//this->moveToThread(&mWorkThread);
//connect(this, SIGNAL(signalReceiveBlockDataList(int,BlockDataList)), this,SLOT(slotReceiveBlockDataList(int,BlockDataList)), Qt::QueuedConnection);
}

QEastMoneyBlockMangagerThread::~QEastMoneyBlockMangagerThread()
{

}

void QEastMoneyBlockMangagerThread::run()
{
//创建板块线程,开始更新板块信息
for(int i= 1; i<=3; i++)
{
QEastMoneyBlockThread *hy = new QEastMoneyBlockThread(i);
connect(hy, SIGNAL(sendBlockDataList(int,BlockDataList)), this, SLOT(slotReceiveBlockDataList(int,BlockDataList)));
mWorkThreadList.append(hy);
emit hy->start();
}
while (1) {
emit signalBlockDataListUpdated(mBlockDataMapList[mCurBlockType]);
sleep(3);
}

}

void QEastMoneyBlockMangagerThread::setCurBlockType(int type)
{
mCurBlockType = type;
}

void QEastMoneyBlockMangagerThread::slotReceiveBlockDataList(int type, const BlockDataList &list)
{
qDebug()<<__FUNCTION__<<__LINE__;
mBlockDataMapList[type] = list;
}

void QEastMoneyBlockMangagerThread::reverseSortRule()
{
foreach (QEastMoneyBlockThread *t, mWorkThreadList) {
t->reverseSortRule();
}
}

Loading

0 comments on commit 631b774

Please sign in to comment.