| 1 |
2 |
EziDebug |
#include "updatedetectthread.h"
|
| 2 |
|
|
#include "QWaitCondition"
|
| 3 |
|
|
#include "ezidebugvlgfile.h"
|
| 4 |
|
|
#include <algorithm>
|
| 5 |
|
|
#include <QDebug>
|
| 6 |
|
|
#include <QTimer>
|
| 7 |
|
|
#include <algorithm>
|
| 8 |
|
|
|
| 9 |
|
|
|
| 10 |
|
|
|
| 11 |
|
|
UpdateDetectThread::UpdateDetectThread(EziDebugPrj *prj,QObject *parent):QThread(parent),m_pprj(prj)
|
| 12 |
|
|
{
|
| 13 |
|
|
|
| 14 |
|
|
}
|
| 15 |
|
|
|
| 16 |
|
|
//UpdateDetectThread::~UpdateDetectThread()
|
| 17 |
|
|
//{
|
| 18 |
|
|
// // 怎么搞 ?
|
| 19 |
|
|
//}
|
| 20 |
|
|
|
| 21 |
|
|
void UpdateDetectThread::run()
|
| 22 |
|
|
{
|
| 23 |
|
|
m_ptimer = new QTimer ;
|
| 24 |
|
|
connect(m_ptimer, SIGNAL(timeout()), this, SLOT(update()),Qt::DirectConnection);
|
| 25 |
|
|
|
| 26 |
|
|
//,Qt::DirectConnection
|
| 27 |
|
|
m_ptimer->start(1000*5);
|
| 28 |
|
|
qDebug() << "Start Timer!" << QThread::currentThreadId();
|
| 29 |
|
|
exec();
|
| 30 |
|
|
qDebug() << "Stop Timer!";
|
| 31 |
|
|
m_ptimer->stop();
|
| 32 |
|
|
delete m_ptimer ;
|
| 33 |
|
|
}
|
| 34 |
|
|
|
| 35 |
|
|
//void UpdateDetectThread::codeFileChanged()
|
| 36 |
|
|
//{
|
| 37 |
|
|
// return ;
|
| 38 |
|
|
//}
|
| 39 |
|
|
|
| 40 |
|
|
|
| 41 |
|
|
void UpdateDetectThread::update()
|
| 42 |
|
|
{
|
| 43 |
|
|
|
| 44 |
|
|
QStringList ifileList ;
|
| 45 |
|
|
bool eneedUpdatedFlag = 0 ;
|
| 46 |
|
|
|
| 47 |
|
|
|
| 48 |
|
|
qDebug() << "!!!!!!!!!!!!!Attention: New Thread!!!!!!!!!!!!" << QThread::currentThreadId();
|
| 49 |
|
|
|
| 50 |
|
|
/*这时候使用 全局唯一的 prj 对象指针时,要注意工程发生变化时 prj 也随着变化*/
|
| 51 |
|
|
if(EziDebugPrj::ToolQuartus == m_pprj->m_eusedTool)
|
| 52 |
|
|
{
|
| 53 |
|
|
m_pprj->parseQuartusPrjFile(ifileList);
|
| 54 |
|
|
}
|
| 55 |
|
|
else if(EziDebugPrj::ToolIse == m_pprj->m_eusedTool)
|
| 56 |
|
|
{
|
| 57 |
|
|
m_pprj->parseIsePrjFile(ifileList);
|
| 58 |
|
|
}
|
| 59 |
|
|
else
|
| 60 |
|
|
{
|
| 61 |
|
|
qDebug() << "EziDebug is not support this sortware project file parse!";
|
| 62 |
|
|
}
|
| 63 |
|
|
|
| 64 |
|
|
ifileList.sort();
|
| 65 |
|
|
|
| 66 |
|
|
m_pprj->m_iupdateAddedFileList.clear();
|
| 67 |
|
|
m_pprj->m_iupdateDeletedFileList.clear();
|
| 68 |
|
|
m_pprj->m_iupdateChangedFileList.clear();
|
| 69 |
|
|
|
| 70 |
|
|
m_pprj->compareFileList(ifileList , m_pprj->m_iupdateAddedFileList , m_pprj->m_iupdateDeletedFileList , m_pprj->m_iupdateChangedFileList);
|
| 71 |
|
|
|
| 72 |
|
|
|
| 73 |
|
|
if(!(m_pprj->m_iupdateDeletedFileList.isEmpty() \
|
| 74 |
|
|
&& m_pprj->m_iupdateAddedFileList.isEmpty() \
|
| 75 |
|
|
&& m_pprj->m_iupdateChangedFileList.isEmpty()))
|
| 76 |
|
|
|
| 77 |
|
|
{
|
| 78 |
|
|
eneedUpdatedFlag = true ;
|
| 79 |
|
|
}
|
| 80 |
|
|
|
| 81 |
|
|
|
| 82 |
|
|
#if 0
|
| 83 |
|
|
QStringList::Iterator ifirstBeginIterator = ifileList.begin() ;
|
| 84 |
|
|
QStringList::Iterator ifirstEndIterator = ifileList.end() ;
|
| 85 |
|
|
|
| 86 |
|
|
QStringList::Iterator iSecondBeginIterator = m_pprj->m_iCodefileNameList.begin() ;
|
| 87 |
|
|
QStringList::Iterator iSecondEndIterator = m_pprj->m_iCodefileNameList.end() ;
|
| 88 |
|
|
|
| 89 |
|
|
/*删除的file*/
|
| 90 |
|
|
qDebug() << "!!!!!!!!!!!!!Attention: New Thread First!!!!!!!!!!!!" ;
|
| 91 |
|
|
std::set_difference(ifirstBeginIterator,ifirstEndIterator,iSecondBeginIterator,iSecondEndIterator,ioutDelIterator);
|
| 92 |
|
|
|
| 93 |
|
|
m_pprj->m_iupdateDeletedFileList = QList<QString>::fromStdList(ideletedFileList);
|
| 94 |
|
|
m_pprj->m_iupdateDeletedFileList = m_pprj->m_iupdateDeletedFileList.filter(QRegExp(QObject::tr(".+"))) ;
|
| 95 |
|
|
|
| 96 |
|
|
|
| 97 |
|
|
// ioutDelIterator = ideletedFileList.begin() ;
|
| 98 |
|
|
// while(ioutDelIterator != ideletedFileList.end())
|
| 99 |
|
|
// {
|
| 100 |
|
|
// m_pprj->m_iupdateDeletedFileList << *ioutDelIterator ;
|
| 101 |
|
|
// ++ioutDelIterator ;
|
| 102 |
|
|
// }
|
| 103 |
|
|
|
| 104 |
|
|
|
| 105 |
|
|
|
| 106 |
|
|
//m_pprj->m_iupdateDeletedFileList = QList<QString>::fromStdList(ideletedFileList);
|
| 107 |
|
|
|
| 108 |
|
|
|
| 109 |
|
|
// m_pprj->m_iupdateDeletedFileList = QList::fromStdList(ideletedFileList) ;
|
| 110 |
|
|
|
| 111 |
|
|
|
| 112 |
|
|
qDebug() << "!!!!!!!!!!!!!Attention: New Thread Second!!!!!!!!!!!!" ;
|
| 113 |
|
|
|
| 114 |
|
|
|
| 115 |
|
|
//ioutBeginIterator = iaddedFileList.begin() ;
|
| 116 |
|
|
/*新增的file*/
|
| 117 |
|
|
std::set_difference(iSecondBeginIterator,iSecondEndIterator,ifirstBeginIterator,ifirstEndIterator,ioutAddIterator);
|
| 118 |
|
|
m_pprj->m_iupdateAddedFileList = QList<QString>::fromStdList(iaddedFileList);
|
| 119 |
|
|
m_pprj->m_iupdateAddedFileList = m_pprj->m_iupdateAddedFileList.filter(QRegExp(QObject::tr(".+"))) ;
|
| 120 |
|
|
if(!m_pprj->m_iupdateAddedFileList.isEmpty())
|
| 121 |
|
|
{
|
| 122 |
|
|
eneedUpdatedFlag = true ;
|
| 123 |
|
|
}
|
| 124 |
|
|
|
| 125 |
|
|
// ioutAddIterator = iaddedFileList.begin() ;
|
| 126 |
|
|
// while(ioutAddIterator != iaddedFileList.end())
|
| 127 |
|
|
// {
|
| 128 |
|
|
// m_pprj->m_iupdateAddedFileList << *ioutAddIterator ;
|
| 129 |
|
|
// ++ioutAddIterator ;
|
| 130 |
|
|
// }
|
| 131 |
|
|
|
| 132 |
|
|
|
| 133 |
|
|
//m_pprj->m_iupdateAddedFileList = QList<QString>::fromStdList(iaddedFileList);
|
| 134 |
|
|
|
| 135 |
|
|
|
| 136 |
|
|
/*共同的file*/
|
| 137 |
|
|
qDebug() << "!!!!!!!!!!!!!Attention: New Thread Third!!!!!!!!!!!!" ;
|
| 138 |
|
|
|
| 139 |
|
|
//ioutBeginIterator = iidenticalFileList.begin() ;
|
| 140 |
|
|
|
| 141 |
|
|
std::set_intersection(ifirstBeginIterator,ifirstEndIterator,iSecondBeginIterator,iSecondEndIterator,ioutIdenticalIterator);
|
| 142 |
|
|
|
| 143 |
|
|
ioutIdenticalIterator = iidenticalFileList.begin() ;
|
| 144 |
|
|
while(ioutIdenticalIterator != iidenticalFileList.end())
|
| 145 |
|
|
{
|
| 146 |
|
|
QFileInfo itempFileInfo(m_pprj->m_iprjPath.path(),*ioutIdenticalIterator);
|
| 147 |
|
|
QDateTime idateTime = itempFileInfo.lastModified() ;
|
| 148 |
|
|
if((*ioutIdenticalIterator).endsWith(".v"))
|
| 149 |
|
|
{
|
| 150 |
|
|
if(idateTime != m_pprj->m_ivlgFileMap.value(*ioutIdenticalIterator)->m_iUpdateTime)
|
| 151 |
|
|
{
|
| 152 |
|
|
m_pprj->m_iupdateChangedFileList.append(*ioutIdenticalIterator);
|
| 153 |
|
|
}
|
| 154 |
|
|
}
|
| 155 |
|
|
else if((*ioutIdenticalIterator).endsWith(".vhd"))
|
| 156 |
|
|
{
|
| 157 |
|
|
if(idateTime != m_pprj->m_ivlgFileMap.value(*ioutIdenticalIterator)->m_iUpdateTime)
|
| 158 |
|
|
{
|
| 159 |
|
|
m_pprj->m_iupdateChangedFileList.append(*ioutIdenticalIterator);
|
| 160 |
|
|
}
|
| 161 |
|
|
}
|
| 162 |
|
|
else
|
| 163 |
|
|
{
|
| 164 |
|
|
|
| 165 |
|
|
}
|
| 166 |
|
|
|
| 167 |
|
|
++ioutIdenticalIterator ;
|
| 168 |
|
|
}
|
| 169 |
|
|
|
| 170 |
|
|
|
| 171 |
|
|
//m_pprj->m_iupdateChangedFileList = QList<QString>::fromStdList(iidenticalFileList) ;
|
| 172 |
|
|
|
| 173 |
|
|
if(!m_pprj->m_iupdateChangedFileList.isEmpty())
|
| 174 |
|
|
{
|
| 175 |
|
|
eneedUpdatedFlag = true ;
|
| 176 |
|
|
}
|
| 177 |
|
|
#endif
|
| 178 |
|
|
|
| 179 |
|
|
if(eneedUpdatedFlag)
|
| 180 |
|
|
{
|
| 181 |
|
|
emit codeFileChanged();
|
| 182 |
|
|
}
|
| 183 |
|
|
}
|