최신 analyzer + 형태소 분석기 합쳐놓음
git-svn-id: svn://192.168.0.12/source@245 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -13,16 +13,10 @@ TARGET = MorphereAnalyzer
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
|
||||||
|
|
||||||
SOURCES += main.cpp\
|
SOURCES += \
|
||||||
mainwindow.cpp \
|
|
||||||
widget.cpp \
|
|
||||||
stable.cpp \
|
stable.cpp \
|
||||||
../Json/sjson.cpp \
|
../Json/sjson.cpp \
|
||||||
sanaly1.cpp \
|
|
||||||
sanaly2.cpp \
|
|
||||||
sanalyzer.cpp \
|
|
||||||
sdictionary.cpp \
|
sdictionary.cpp \
|
||||||
keywordthread.cpp \
|
|
||||||
tablealgorithm_interface.cpp \
|
tablealgorithm_interface.cpp \
|
||||||
yalgorithm.cpp \
|
yalgorithm.cpp \
|
||||||
ymorpherethread.cpp \
|
ymorpherethread.cpp \
|
||||||
@@ -36,16 +30,22 @@ SOURCES += main.cpp\
|
|||||||
ymtwodepthwidget.cpp \
|
ymtwodepthwidget.cpp \
|
||||||
ymuploadwidget.cpp \
|
ymuploadwidget.cpp \
|
||||||
ymplatformwidget.cpp \
|
ymplatformwidget.cpp \
|
||||||
ymtwodepthawidget.cpp
|
ymtwodepthawidget.cpp \
|
||||||
|
subwindow.cpp \
|
||||||
|
main.cpp \
|
||||||
|
mainwindow.cpp \
|
||||||
|
sbatchrun.cpp \
|
||||||
|
scolumn.cpp \
|
||||||
|
scountdlg.cpp \
|
||||||
|
sdatadlg.cpp \
|
||||||
|
sfilterdlg.cpp \
|
||||||
|
sfilterobject.cpp \
|
||||||
|
sloaddlg.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
HEADERS += mainwindow.h \
|
|
||||||
widget.h \
|
|
||||||
stable.h \
|
stable.h \
|
||||||
../Json/sjson.h \
|
../Json/sjson.h \
|
||||||
../common.h \
|
../common.h \
|
||||||
sanaly1.h \
|
|
||||||
sanaly2.h \
|
|
||||||
char_property.h \
|
char_property.h \
|
||||||
common.h \
|
common.h \
|
||||||
connector.h \
|
connector.h \
|
||||||
@@ -74,9 +74,7 @@ HEADERS += mainwindow.h \
|
|||||||
viterbi.h \
|
viterbi.h \
|
||||||
winmain.h \
|
winmain.h \
|
||||||
writer.h \
|
writer.h \
|
||||||
sanalyzer.h \
|
|
||||||
sdictionary.h \
|
sdictionary.h \
|
||||||
keywordthread.h \
|
|
||||||
dataalgorithm_interface.h \
|
dataalgorithm_interface.h \
|
||||||
tablealgorithm_interface.h \
|
tablealgorithm_interface.h \
|
||||||
yalgorithm.h \
|
yalgorithm.h \
|
||||||
@@ -91,7 +89,15 @@ HEADERS += mainwindow.h \
|
|||||||
ymtwodepthwidget.h \
|
ymtwodepthwidget.h \
|
||||||
ymuploadwidget.h \
|
ymuploadwidget.h \
|
||||||
ymplatformwidget.h \
|
ymplatformwidget.h \
|
||||||
ymtwodepthawidget.h
|
ymtwodepthawidget.h \
|
||||||
|
subwindow.h \
|
||||||
|
mainwindow.h \
|
||||||
|
sbatchrun.h \
|
||||||
|
scolumn.h \
|
||||||
|
scountdlg.h \
|
||||||
|
sdatadlg.h \
|
||||||
|
sfilterdlg.h \
|
||||||
|
sfilterobject.h \
|
||||||
|
sloaddlg.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui
|
FORMS += mainwindow.ui
|
||||||
|
|||||||
@@ -1,448 +0,0 @@
|
|||||||
#include "keywordthread.h"
|
|
||||||
#include "sanaly2.h"
|
|
||||||
#include <QFile>
|
|
||||||
KeywordThread::KeywordThread(QObject *parent) : QThread(parent), m_nThread(1), m_pWidget(NULL), m_nSource(0), m_bPeriod(false), m_nPeriod(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
KeywordThread::KeywordThread(int number)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
KeywordThread::KeywordThread(QMutex &_mutex, int _number, int &_nCount)
|
|
||||||
{
|
|
||||||
KeywordThread();
|
|
||||||
num = _number;
|
|
||||||
mutex = &_mutex;
|
|
||||||
nCount = &_nCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setThreadNumber(int _nThread)
|
|
||||||
{
|
|
||||||
m_nThread = _nThread;
|
|
||||||
}
|
|
||||||
|
|
||||||
int KeywordThread::getThreadNumber()
|
|
||||||
{
|
|
||||||
return m_nThread;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setWidget(QWidget *_pWidget)
|
|
||||||
{
|
|
||||||
m_pWidget = (Widget*)_pWidget;
|
|
||||||
m_pTabWidget = m_pWidget->GetTabWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget* KeywordThread::getWidget()
|
|
||||||
{
|
|
||||||
return m_pQWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setMorphereList(const QStringList morpherelist)
|
|
||||||
{
|
|
||||||
m_slMorphereList.append(morpherelist);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void KeywordThread::setMorphereList(const QString morphere)
|
|
||||||
{
|
|
||||||
m_slMorphereList.append(morphere);
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::resetMorphereList()
|
|
||||||
{
|
|
||||||
m_slMorphereList.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setParametersfromWidget(QWidget *_pWidget, int _nSource)
|
|
||||||
{
|
|
||||||
resetMorphereList();
|
|
||||||
if(_nSource == 0)
|
|
||||||
{
|
|
||||||
pWidget = (SAnaly2*)_pWidget;
|
|
||||||
setThreadNumber(pWidget->getThread());
|
|
||||||
setPeriod(pWidget->getPeriod());
|
|
||||||
m_bDateAll = pWidget->getDateAll();
|
|
||||||
m_nDateStart = pWidget->getDateStart();
|
|
||||||
m_nDateEnd = pWidget->getDateEnd();
|
|
||||||
setMorphereList(pWidget->getMorphereList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList KeywordThread::getMorphereList()
|
|
||||||
{
|
|
||||||
return m_slMorphereList;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setPeriod(const int _nPeriod)
|
|
||||||
{
|
|
||||||
m_nPeriod = _nPeriod;
|
|
||||||
}
|
|
||||||
|
|
||||||
int KeywordThread::getPeriod()
|
|
||||||
{
|
|
||||||
return m_nPeriod;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setDate(const QDateTime _dtStart, const QDateTime _dtEnd)
|
|
||||||
{
|
|
||||||
m_nDateStart = _dtStart.toString("yyyy-MM-dd").replace("-","").toInt();
|
|
||||||
m_nDateEnd = _dtEnd.toString("yyyy-MM-dd").replace("-","").toInt();
|
|
||||||
}
|
|
||||||
void KeywordThread::setDate(const QString _strStart, const QString _strEnd)
|
|
||||||
{
|
|
||||||
m_nDateStart = _strStart.toInt();
|
|
||||||
m_nDateEnd = _strEnd.toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int KeywordThread::getDateStart()
|
|
||||||
{
|
|
||||||
return m_nDateStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int KeywordThread::getDateEnd()
|
|
||||||
{
|
|
||||||
return m_nDateEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setTitleBody(const int _n)
|
|
||||||
{
|
|
||||||
m_nTitleBody = _n;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setPosDate(const int _nPos)
|
|
||||||
{
|
|
||||||
m_nPosDate = _nPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setPosBody(const int _nPos)
|
|
||||||
{
|
|
||||||
m_nPosBody = _nPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setPosTitle(const int _nPos)
|
|
||||||
{
|
|
||||||
m_nPosTitle = _nPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setPosPlatformTitle(const int _nPos)
|
|
||||||
{
|
|
||||||
m_nPosPlatformTitle = _nPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::run()
|
|
||||||
{
|
|
||||||
|
|
||||||
typedef mecab_t* (*mecab_new_fun)(int,char**);
|
|
||||||
typedef const char* (*mecab_sparse_tostr_fun)(mecab_t *mecab, const char *str);
|
|
||||||
typedef void (*mecab_destroy_fun)(mecab_t *mecab);
|
|
||||||
|
|
||||||
mecab_t *mecab;
|
|
||||||
mecab_new_fun mecab_new = (mecab_new_fun)QLibrary::resolve("libmecab.dll","mecab_new");
|
|
||||||
mecab_sparse_tostr_fun mecab_sparse_tostr = (mecab_sparse_tostr_fun)QLibrary::resolve("libmecab.dll","mecab_sparse_tostr");
|
|
||||||
|
|
||||||
QString userdict = pWidget->getUserDictList();
|
|
||||||
|
|
||||||
if(userdict.length() < 1)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
char *t[] = {"RRR","-d","dic"};
|
|
||||||
int int_t = 3;
|
|
||||||
*/
|
|
||||||
|
|
||||||
char a[] = "RRR";
|
|
||||||
char b[] = "-d";
|
|
||||||
char c[] = "dic";
|
|
||||||
char *t[3];
|
|
||||||
t[0] = a;
|
|
||||||
t[1] = b;
|
|
||||||
t[2] = c;
|
|
||||||
int int_t = 3;
|
|
||||||
|
|
||||||
mecab = mecab_new(int_t, t);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *cstr = new char[userdict.toStdString().length() + 1];
|
|
||||||
strcpy(cstr, userdict.toStdString().c_str());
|
|
||||||
/*
|
|
||||||
char **t = {"RRR","-d","dic","-u",cstr};
|
|
||||||
int int_t = 5;
|
|
||||||
*/
|
|
||||||
char a[] = "RRR";
|
|
||||||
char b[] = "-d";
|
|
||||||
char c[] = "dic";
|
|
||||||
char d[] = "-u";
|
|
||||||
|
|
||||||
char *t[5];
|
|
||||||
t[0] = a;
|
|
||||||
t[1] = b;
|
|
||||||
t[2] = c;
|
|
||||||
t[3] = d;
|
|
||||||
t[4] = cstr;
|
|
||||||
int int_t = 5;
|
|
||||||
|
|
||||||
mecab = mecab_new(int_t, t);
|
|
||||||
delete[] cstr;
|
|
||||||
}
|
|
||||||
mecab_destroy_fun mecab_destroy = (mecab_destroy_fun)QLibrary::resolve("libmecab.dll","mecab_destroy");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//qDebug() << num;
|
|
||||||
|
|
||||||
STable *pCurrent = (STable *)m_pTabWidget->currentWidget();
|
|
||||||
int nDate = 0;
|
|
||||||
while(true)
|
|
||||||
{
|
|
||||||
QString strTitle;
|
|
||||||
QString strBody;
|
|
||||||
QString strDate;
|
|
||||||
QString strData;
|
|
||||||
QString strPlatformTitle;
|
|
||||||
{
|
|
||||||
mutex->lock();
|
|
||||||
if(*nCount >= pCurrent->rowCount())
|
|
||||||
{
|
|
||||||
mutex->unlock();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
strTitle = pCurrent->item((*nCount),m_nPosTitle)->text();
|
|
||||||
strDate = pCurrent->item((*nCount),m_nPosDate)->text();
|
|
||||||
strPlatformTitle = pCurrent->item((*nCount),m_nPosPlatformTitle)->text();
|
|
||||||
strBody = pCurrent->item((*nCount)++,m_nPosBody)->text();
|
|
||||||
|
|
||||||
mutex->unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
switch(m_nTitleBody)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
strData = strTitle;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
strData = strBody;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
strData = strTitle + "\n" + strBody;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3:
|
|
||||||
strData = strPlatformTitle;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
strTitle.clear();
|
|
||||||
strBody.clear();
|
|
||||||
strPlatformTitle.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!strData.contains(m_strCKeyword, Qt::CaseInsensitive))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(strDate.length() < 11)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
strDate = strDate.left(11);
|
|
||||||
if(strDate.trimmed().length()<10)
|
|
||||||
{
|
|
||||||
nDate = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strDate = strDate.replace("-","").trimmed();
|
|
||||||
if(strDate.length() < 8)
|
|
||||||
{
|
|
||||||
nDate = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
nDate = strDate.toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!m_bDateAll)
|
|
||||||
{
|
|
||||||
if(nDate < m_nDateStart || m_nDateEnd < nDate)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SAnaly2::m_mapKey mapkey;
|
|
||||||
|
|
||||||
switch(m_nPeriod)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
mapkey.strDate = "ALL";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
mapkey.strDate = "D" + QString::number(nDate);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
QDate tempdate = QDate(nDate/10000, (nDate%10000)/100, nDate%100);
|
|
||||||
mapkey.strDate = "W" + QString::number(nDate/10000);
|
|
||||||
if(tempdate.weekNumber() < 10)
|
|
||||||
mapkey.strDate += "0";
|
|
||||||
mapkey.strDate += QString::number(tempdate.weekNumber());
|
|
||||||
*/
|
|
||||||
mapkey.strDate = getWeeksInMonth(nDate);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3:
|
|
||||||
{
|
|
||||||
mapkey.strDate = "M";
|
|
||||||
if((nDate/100) < 10)
|
|
||||||
mapkey.strDate += "0";
|
|
||||||
mapkey.strDate += QString::number(nDate/100);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString strAnalyzedLine = QString::fromStdString(mecab_sparse_tostr(mecab, strData.toStdString().c_str())) + "\n";
|
|
||||||
QStringList strListAll = strAnalyzedLine.split("\n",QString::SkipEmptyParts);
|
|
||||||
|
|
||||||
foreach(QString strLine, strListAll)
|
|
||||||
{
|
|
||||||
QStringList strListLine = strLine.split("\t");
|
|
||||||
if(strListLine.size() < 2)
|
|
||||||
continue;
|
|
||||||
QStringList strpumsa = strListLine.at(1).trimmed().split(",");
|
|
||||||
foreach(QString strMorphere, m_slMorphereList)
|
|
||||||
{
|
|
||||||
if(strpumsa.at(0).trimmed().contains(strMorphere,Qt::CaseInsensitive))
|
|
||||||
{
|
|
||||||
mapkey.strKeyword = strListLine.at(0);
|
|
||||||
mapkey.strMorphere = strMorphere;
|
|
||||||
QString strkey = mapkey.strDate + "~!@" + mapkey.strMorphere + "~!@" + mapkey.strKeyword;
|
|
||||||
if(pWidget->m_HashResult[num].contains(strkey))
|
|
||||||
{
|
|
||||||
(pWidget->m_HashResult[num])[strkey]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pWidget->m_HashResult[num].insert(strkey,1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//if(m_bDateAll)
|
|
||||||
|
|
||||||
//qDebug() << num << " : " << strData;
|
|
||||||
}
|
|
||||||
|
|
||||||
mecab_destroy(mecab);
|
|
||||||
/*
|
|
||||||
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
|
||||||
{
|
|
||||||
QString strData = pCurrent->item(nCount,m_nPosBody)->text();
|
|
||||||
qDebug() << strData;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(QHash<QString, int>::iterator iterPos = pWidget->m_HashResult[num].begin(); iterPos != pWidget->m_HashResult[num].end(); iterPos++)
|
|
||||||
{
|
|
||||||
qDebug() << num << " : " << iterPos.key() << " ===== " << iterPos.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(QString str, m_slMorphereList)
|
|
||||||
{
|
|
||||||
qDebug() << num << " : " << str;
|
|
||||||
}
|
|
||||||
qDebug() << num << " : " << m_bDateAll;
|
|
||||||
qDebug() << num << " : " << m_bPeriod;
|
|
||||||
qDebug() << num << " : " << m_nDateStart;
|
|
||||||
qDebug() << num << " : " << m_nDateEnd;
|
|
||||||
qDebug() << num << " : " << pWidget->m_HashResult[num].isEmpty();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
QString KeywordThread::getWeeksInMonth(unsigned int _nDate)
|
|
||||||
{
|
|
||||||
QDate qToday(_nDate/10000, (_nDate/100)%100, _nDate%100);
|
|
||||||
if(!qToday.isValid())
|
|
||||||
return "inVaildDate";
|
|
||||||
|
|
||||||
QDate qTodayFirstDay = QDate(qToday.year(), qToday.month(), 1);
|
|
||||||
QDate qTodayLastDay = QDate(qToday.year(), qToday.month(), qToday.daysInMonth());
|
|
||||||
|
|
||||||
int thisFirstDayofWeek = qTodayFirstDay.dayOfWeek();
|
|
||||||
int thisLastDayofWeek = qTodayLastDay.dayOfWeek();
|
|
||||||
int thisLastDay = qTodayLastDay.daysInMonth();
|
|
||||||
int week = 0;
|
|
||||||
int firstWeekDays = (WEEK - thisFirstDayofWeek) + 1;
|
|
||||||
QString strWeek = "W";
|
|
||||||
|
|
||||||
if(thisFirstDayofWeek < FRIDAY)
|
|
||||||
{
|
|
||||||
week = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
week = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if((firstWeekDays < qToday.day()) && (qToday.day() <= (thisLastDay - thisLastDayofWeek)))
|
|
||||||
{
|
|
||||||
week = week + ((qToday.day() - firstWeekDays + WEEK - 1)/WEEK);
|
|
||||||
}
|
|
||||||
else if((firstWeekDays >= qToday.day()))
|
|
||||||
{
|
|
||||||
if(thisFirstDayofWeek >= FRIDAY)
|
|
||||||
{
|
|
||||||
|
|
||||||
const int DAYS_IN_WEEK = 7;
|
|
||||||
qToday = qToday.addMonths(-1);
|
|
||||||
int DaysInMonth = qToday.daysInMonth();
|
|
||||||
QDate FirstDayOfMonth = qToday;
|
|
||||||
FirstDayOfMonth.setDate(qToday.year(), qToday.month(), 1);
|
|
||||||
|
|
||||||
int WeekCount = DaysInMonth / DAYS_IN_WEEK;
|
|
||||||
int DaysLeft = DaysInMonth % DAYS_IN_WEEK;
|
|
||||||
if (DaysLeft > 0) {
|
|
||||||
WeekCount++;
|
|
||||||
// Check if the remaining days are split on two weeks
|
|
||||||
if (FirstDayOfMonth.dayOfWeek() + DaysLeft - 1 > DAYS_IN_WEEK)
|
|
||||||
WeekCount++;
|
|
||||||
}
|
|
||||||
week = WeekCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(thisLastDayofWeek < THURSDAY)
|
|
||||||
{
|
|
||||||
week = 1;
|
|
||||||
qToday = qToday.addMonths(1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
week = week + ((qToday.day() - firstWeekDays + WEEK - 1)/WEEK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
strWeek += qToday.toString("yyyyMM");
|
|
||||||
strWeek += QString::number(week);
|
|
||||||
return strWeek;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setKeywordThread(QMutex &_mutex, int number, int &_nCount)
|
|
||||||
{
|
|
||||||
num = number;
|
|
||||||
mutex = &_mutex;
|
|
||||||
nCount = &_nCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeywordThread::setCenterKeyword(QString strCKeyword)
|
|
||||||
{
|
|
||||||
m_strCKeyword = strCKeyword;
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
#ifndef KEYWORDTHREAD
|
|
||||||
#define KEYWORDTHREAD
|
|
||||||
|
|
||||||
#include <QThread>
|
|
||||||
#include "widget.h"
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QMutex>
|
|
||||||
#include "mecab.h"
|
|
||||||
#include <QLibrary>
|
|
||||||
|
|
||||||
class SAnaly2;
|
|
||||||
class KeywordThread : public QThread
|
|
||||||
{
|
|
||||||
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
|
|
||||||
KeywordThread(QObject *parent = NULL);
|
|
||||||
KeywordThread(int number);
|
|
||||||
KeywordThread(QMutex &_mutex, int number, int &_nCount);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
enum {
|
|
||||||
MONDAY = 1,
|
|
||||||
TUESDAY,
|
|
||||||
WEDNESDAY,
|
|
||||||
THURSDAY,
|
|
||||||
FRIDAY,
|
|
||||||
SATURDAY,
|
|
||||||
SUNDAY
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
WEEK = 7
|
|
||||||
};
|
|
||||||
int num;
|
|
||||||
QWidget *m_pQWidget;
|
|
||||||
int m_nThread;
|
|
||||||
QStringList m_slMorphereList;
|
|
||||||
int m_nSource;
|
|
||||||
bool m_bPeriod;
|
|
||||||
bool m_bDateAll;
|
|
||||||
int m_nPeriod; // 0 none, 1 1day, 2 1week, 3 1month;
|
|
||||||
unsigned int m_nDateStart;
|
|
||||||
unsigned int m_nDateEnd;
|
|
||||||
int m_nTitleBody;
|
|
||||||
Widget *m_pWidget;
|
|
||||||
int m_nPosDate;
|
|
||||||
int m_nPosBody;
|
|
||||||
int m_nPosTitle;
|
|
||||||
int m_nPosPlatformTitle;
|
|
||||||
QMutex *mutex;
|
|
||||||
SAnaly2 *pWidget;
|
|
||||||
QTabWidget *m_pTabWidget;
|
|
||||||
int *nCount;
|
|
||||||
QString m_strCKeyword;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void run();
|
|
||||||
|
|
||||||
public:
|
|
||||||
void setThreadNumber(int _nThread = 1);
|
|
||||||
int getThreadNumber();
|
|
||||||
void setWidget(QWidget *_pWidget);
|
|
||||||
QWidget* getWidget();
|
|
||||||
void setMorphereList(const QStringList morpherelist);
|
|
||||||
void setMorphereList(const QString morphere);
|
|
||||||
QStringList getMorphereList();
|
|
||||||
void resetMorphereList();
|
|
||||||
void setParametersfromWidget(QWidget *_pWidget, int _nSource);
|
|
||||||
void setPeriod(const int _nPeriod);
|
|
||||||
int getPeriod();
|
|
||||||
void setDate(const QString _strStart, const QString _strEnd);
|
|
||||||
void setDate(const QDateTime _dtStart, const QDateTime _dtEnd);
|
|
||||||
void setDateStart(const QString _strStart);
|
|
||||||
void setDateStart(const QDateTime _dtStart);
|
|
||||||
void setDateEnd(const QString _strEnd);
|
|
||||||
void setDateEnd(const QDateTime _dtStart);
|
|
||||||
unsigned int getDateStart();
|
|
||||||
unsigned int getDateEnd();
|
|
||||||
void setTitleBody(const int _n);
|
|
||||||
void setSource(QWidget* _qwidget);
|
|
||||||
void setPosDate(const int _nPos);
|
|
||||||
void setPosBody(const int _nPos);
|
|
||||||
void setPosTitle(const int _nPos);
|
|
||||||
void setPosPlatformTitle(const int _nPos);
|
|
||||||
QString getWeeksInMonth(unsigned int _nDate);
|
|
||||||
void setKeywordThread(QMutex &_mutex, int number, int &_nCount);
|
|
||||||
void setCenterKeyword(QString strCKeyword);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // KEYWORDTHREAD
|
|
||||||
|
|
||||||
@@ -1,11 +1,44 @@
|
|||||||
#include "mainwindow.h"
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "scolumn.h"
|
||||||
|
#include "subwindow.h"
|
||||||
|
|
||||||
|
MainWindow *g_pMain;
|
||||||
|
|
||||||
|
MainWindow *GetMainWindow()
|
||||||
|
{
|
||||||
|
return g_pMain;
|
||||||
|
}
|
||||||
|
|
||||||
|
SColumn g_column;
|
||||||
|
SColumn GetColumn()
|
||||||
|
{
|
||||||
|
return g_column;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
if (g_column.reload())
|
||||||
|
{
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
g_pMain = &w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
|
||||||
|
SubWindow s;
|
||||||
|
s.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox msg;
|
||||||
|
msg.setText("Can not read column data...");
|
||||||
|
msg.exec();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,387 +1,231 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD$
|
|
||||||
** You may use this file under the terms of the BSD license as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in
|
|
||||||
** the documentation and/or other materials provided with the
|
|
||||||
** distribution.
|
|
||||||
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
|
||||||
** of its contributors may be used to endorse or promote products derived
|
|
||||||
** from this software without specific prior written permission.
|
|
||||||
**
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "widget.h"
|
#include <QTime>
|
||||||
#include "stable.h"
|
#include <QFile>
|
||||||
#include "sdictionary.h"
|
#include <QMessageBox>
|
||||||
#include "tablealgorithm_interface.h"
|
#include <QInputDialog>
|
||||||
#include "yalgorithm.h"
|
#include <QFileDialog>
|
||||||
#include "ymbasicwidget.h"
|
|
||||||
#include "ymonedepthwidget.h"
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||||
#include "ymnxnmatrixwidget.h"
|
|
||||||
#include <QSqlQuery>
|
|
||||||
#include <QSqlDatabase>
|
|
||||||
#include <QSqlError>
|
|
||||||
#include "ymtwodepthwidget.h"
|
|
||||||
#include "ymplatformwidget.h"
|
|
||||||
#include "ymtwodepthawidget.h"
|
|
||||||
#include <QShortcut>
|
|
||||||
#include <QKeySequence>
|
|
||||||
#include <QUrl>
|
|
||||||
//! [0]
|
|
||||||
MainWindow::MainWindow()
|
|
||||||
{
|
|
||||||
QWidget *widget = new QWidget;
|
|
||||||
setCentralWidget(widget);
|
|
||||||
p_qwDB = new Widget;
|
|
||||||
//p_qwFile = new QWidget;
|
|
||||||
//p_qwAnalyzed1 = new QWidget;
|
|
||||||
//p_qwText = new QWidget;
|
|
||||||
//p_qwAnalyzer1 = new SAnaly1;
|
|
||||||
//p_qwAnalyzer2 = new SAnaly2;
|
|
||||||
m_pYMBasicWidget = new YMBasicWidget;
|
|
||||||
m_pYMOneDepthWidget = new YMOneDepthWidget;
|
|
||||||
m_pYMTwoDepthWidget = new YMTwoDepthWidget;
|
|
||||||
m_pYMTwoDepthAWidget = new YMTwoDepthAWidget;
|
|
||||||
|
|
||||||
m_pYMNxNMatrixWidget = new YMNxNMatrixWidget;
|
|
||||||
m_pYMPlatformWidget = new YMPlatformWidget;
|
|
||||||
p_qwDict = new SDictionary;
|
|
||||||
|
|
||||||
//p_qwAnalyzer1->setWidget(p_qwDB);
|
|
||||||
//p_qwAnalyzer2->setWidget(p_qwDB);
|
|
||||||
m_ptwSource = new QTabWidget;
|
|
||||||
m_ptwSource->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
||||||
m_ptwSource->addTab(p_qwDB,"DB");
|
|
||||||
//m_ptwSource->addTab(p_qwFile,"File");
|
|
||||||
//m_ptwSource->addTab(p_qwText,"Text");
|
|
||||||
//m_ptwSource->addTab(p_qwAnalyzed1,"Analyzed1");
|
|
||||||
m_pTAInterface = new TableAlgorithmInterface;
|
|
||||||
m_pTAInterface->ReloadColumn();
|
|
||||||
m_pUploadWidget = new YMUploadWidget();
|
|
||||||
|
|
||||||
|
|
||||||
m_ptwResult = new QTabWidget;
|
|
||||||
m_ptwResult->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
||||||
//m_ptwResult->addTab(p_qwAnalyzer1, "Analysis1");
|
|
||||||
//m_ptwResult->addTab(p_qwAnalyzer2, "Analysis2");
|
|
||||||
m_ptwResult->addTab(m_pYMBasicWidget, "Basic");
|
|
||||||
m_ptwResult->addTab(m_pYMOneDepthWidget, "OneDepth");
|
|
||||||
m_ptwResult->addTab(m_pYMTwoDepthWidget, "TwoDepth");
|
|
||||||
m_ptwResult->addTab(m_pYMTwoDepthAWidget, "TwoDepthAdv");
|
|
||||||
m_ptwResult->addTab(m_pYMNxNMatrixWidget, "NxNMatrix");
|
|
||||||
m_ptwResult->addTab(m_pYMPlatformWidget, "Platform");
|
|
||||||
|
|
||||||
m_pYMBasicWidget->setTabWidget(m_ptwSource);
|
|
||||||
m_pYMOneDepthWidget->setTabWidget(m_ptwSource);
|
|
||||||
m_pYMTwoDepthWidget->setTabWidget(m_ptwSource);
|
|
||||||
m_pYMNxNMatrixWidget->setTabWidget(m_ptwSource);
|
|
||||||
m_pYMPlatformWidget->setTabWidget(m_ptwSource);
|
|
||||||
m_pYMTwoDepthAWidget->setTabWidget(m_ptwSource);
|
|
||||||
|
|
||||||
m_pUploadWidget->setResultTabWidget(m_ptwResult);
|
|
||||||
m_pUploadWidget->setSourceTabWidget(m_ptwSource);
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout;
|
|
||||||
|
|
||||||
layout->setMargin(5);
|
|
||||||
layout->addWidget(m_ptwSource);
|
|
||||||
layout->addWidget(m_ptwResult);
|
|
||||||
|
|
||||||
widget->setLayout(layout);
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
actD3View = new QAction(tr("D3View"), this);
|
|
||||||
actD3View->setShortcut(Qt::Key_0 | Qt::CTRL);
|
|
||||||
connect(actD3View, SIGNAL(triggered()), this, SLOT(slotD3View()));
|
|
||||||
this->addAction(actD3View);
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
createActions();
|
|
||||||
createMenus();
|
|
||||||
|
|
||||||
QString message = tr("A context menu is available by right-clicking");
|
|
||||||
statusBar()->showMessage(message);
|
|
||||||
//test = new QWebView(this);
|
|
||||||
|
|
||||||
setWindowTitle(tr("Morphere Analyzer"));
|
|
||||||
setMinimumSize(800, 600);
|
|
||||||
resize(800, 600);
|
|
||||||
}
|
|
||||||
void MainWindow::createActions()
|
|
||||||
{
|
|
||||||
//! [5]
|
|
||||||
//!
|
|
||||||
actDBNew = new QAction(tr("&New DB "), this);
|
|
||||||
actDBNew->setStatusTip(tr("Create a new DB"));
|
|
||||||
connect(actDBNew, SIGNAL(triggered()), this, SLOT(newDB()));
|
|
||||||
|
|
||||||
actDBCsvImport = new QAction(tr("DB - CSV Import"), this);
|
|
||||||
actDBCsvImport->setStatusTip(tr("Import DB as a csv file"));
|
|
||||||
connect(actDBCsvImport, SIGNAL(triggered()), this, SLOT(importDB()));
|
|
||||||
|
|
||||||
actDBCsvExport = new QAction(tr("DB - CSV Export"), this);
|
|
||||||
actDBCsvExport->setStatusTip(tr("Export DB as a csv file"));
|
|
||||||
connect(actDBCsvExport, SIGNAL(triggered()), this, SLOT(exportDB()));
|
|
||||||
|
|
||||||
actMorphereOriginalExport = new QAction(tr("Morphere - CSV Export(OtherType Result)"), this);
|
|
||||||
actMorphereOriginalExport->setStatusTip(tr("Export Morphere as a csv file"));
|
|
||||||
connect(actMorphereOriginalExport, SIGNAL(triggered()), this, SLOT(exportOriginalMorphere()));
|
|
||||||
|
|
||||||
actMorphereExport = new QAction(tr("Morphere - CSV Export"), this);
|
|
||||||
actMorphereExport->setStatusTip(tr("Export Morphere as a csv file"));
|
|
||||||
connect(actMorphereExport, SIGNAL(triggered()), this, SLOT(exportMorphere()));
|
|
||||||
|
|
||||||
actMorphereImport = new QAction(tr("Morphere - CSV Import"), this);
|
|
||||||
actMorphereImport->setStatusTip(tr("Import Morphere as a csv file"));
|
|
||||||
connect(actMorphereImport, SIGNAL(triggered()), this, SLOT(importMorphere()));
|
|
||||||
|
|
||||||
actExit = new QAction(tr("Exit"), this);
|
|
||||||
actExit->setStatusTip(tr("Exit the application"));
|
|
||||||
connect(actExit, SIGNAL(triggered()), this, SLOT(close()));
|
|
||||||
|
|
||||||
actAnalyze = new QAction(tr("Analyze"), this);
|
|
||||||
actAnalyze->setStatusTip(tr("Analyze"));
|
|
||||||
connect(actAnalyze, SIGNAL(triggered()), this, SLOT(slotAnalyze()));
|
|
||||||
|
|
||||||
actDictionary = new QAction(tr("Dictionary"), this);
|
|
||||||
actAnalyze->setStatusTip(tr("Execute Dictionary Widget"));
|
|
||||||
connect(actDictionary, SIGNAL(triggered()), this, SLOT(slotDictionary()));
|
|
||||||
|
|
||||||
actTestUpload = new QAction(tr("Test Upload"), this);
|
|
||||||
connect(actTestUpload, SIGNAL(triggered()), this, SLOT(slotTestUpload()));
|
|
||||||
actShowUpload = new QAction(tr("Show Upload"), this);
|
|
||||||
connect(actShowUpload, SIGNAL(triggered()), this, SLOT(slotShowUpload()));
|
|
||||||
actD3ViewTree = new QAction(tr("D3View Tree"), this);
|
|
||||||
connect(actD3ViewTree, SIGNAL(triggered()), this, SLOT(slotD3ViewTree()));
|
|
||||||
|
|
||||||
actD3ViewTreeFile = new QAction(tr("D3ViewTree From File"), this);
|
|
||||||
connect(actD3ViewTreeFile, SIGNAL(triggered()), this, SLOT(slotD3ViewTreeFile()));
|
|
||||||
|
|
||||||
actD3ViewFile = new QAction(tr("D3View From File"), this);
|
|
||||||
connect(actD3ViewFile, SIGNAL(triggered()), this, SLOT(slotD3ViewFile()));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::slotShowUpload()
|
|
||||||
{
|
|
||||||
m_pUploadWidget->show();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::slotD3View()
|
|
||||||
{
|
|
||||||
((YMorphereWidget*)(m_ptwResult->currentWidget()))->D3View();
|
|
||||||
//qDebug() << "hide the D3View";
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::slotD3ViewTree()
|
|
||||||
{
|
|
||||||
((YMorphereWidget*)(m_ptwResult->currentWidget()))->D3ViewTree();
|
|
||||||
//qDebug() << "hide the D3View";
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::slotD3ViewFile()
|
|
||||||
{
|
|
||||||
((YMorphereWidget*)(m_ptwResult->currentWidget()))->D3ViewFile();
|
|
||||||
//qDebug() << "hide the D3View";
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::slotD3ViewTreeFile()
|
|
||||||
{
|
|
||||||
((YMorphereWidget*)(m_ptwResult->currentWidget()))->D3ViewTreeFile();
|
|
||||||
//qDebug() << "hide the D3View";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::createMenus()
|
|
||||||
{
|
|
||||||
//! [9] //! [10]
|
|
||||||
menuFile = menuBar()->addMenu(tr("File"));
|
|
||||||
|
|
||||||
menuFile->addAction(actDBNew);
|
|
||||||
menuFile->addSeparator();
|
|
||||||
//! [9]
|
|
||||||
menuFile->addAction(actDBCsvImport);
|
|
||||||
//! [10]
|
|
||||||
menuFile->addAction(actDBCsvExport);
|
|
||||||
menuFile->addSeparator();
|
|
||||||
menuFile->addAction(actMorphereImport);
|
|
||||||
menuFile->addAction(actMorphereExport);
|
|
||||||
menuFile->addAction(actMorphereOriginalExport);
|
|
||||||
|
|
||||||
menuFile->addSeparator();
|
|
||||||
menuFile->addAction(actExit);
|
|
||||||
//! [11]
|
|
||||||
|
|
||||||
//! [11]
|
|
||||||
menuDictionary = menuBar()->addMenu(tr("Dictionary"));
|
|
||||||
menuDictionary->addAction(actDictionary);
|
|
||||||
|
|
||||||
menuAnalyze = menuBar()->addMenu(tr("Analyze"));
|
|
||||||
menuAnalyze->addAction(actAnalyze);
|
|
||||||
|
|
||||||
menuTestUpload = menuBar()->addMenu(tr("TestUpload"));
|
|
||||||
menuTestUpload->addAction(actTestUpload);
|
|
||||||
|
|
||||||
menuShowUpload = menuBar()->addMenu(tr("ShowUpload"));
|
|
||||||
menuShowUpload->addAction(actShowUpload);
|
|
||||||
|
|
||||||
menuD3View = menuBar()->addMenu(tr("D3View"));
|
|
||||||
menuD3View->addAction(actD3View);
|
|
||||||
menuD3View->addAction(actD3ViewFile);
|
|
||||||
menuD3View->addAction(actD3ViewTree);
|
|
||||||
menuD3View->addAction(actD3ViewTreeFile);
|
|
||||||
|
|
||||||
}
|
|
||||||
//! [12]
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::newDB()
|
|
||||||
{
|
|
||||||
p_qwDB->FileNew();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::importDB()
|
|
||||||
{
|
|
||||||
p_qwDB->FileImport();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::exportDB()
|
|
||||||
{
|
|
||||||
p_qwDB->FileExport();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::importMorphere()
|
|
||||||
{
|
|
||||||
// p_qwAnalyzer1->FileImport();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::exportMorphere()
|
|
||||||
{
|
|
||||||
((YMorphereWidget*)(m_ptwResult->currentWidget()))->SaveFile();
|
|
||||||
// p_qwAnalyzer1->FileExport();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::exportOriginalMorphere()
|
|
||||||
{
|
|
||||||
((YMorphereWidget*)(m_ptwResult->currentWidget()))->SaveFileSimple();
|
|
||||||
// p_qwAnalyzer1->RawFileExport();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::slotAnalyze()
|
|
||||||
{
|
{
|
||||||
|
if (initDb() == false)
|
||||||
|
{
|
||||||
QMessageBox msg;
|
QMessageBox msg;
|
||||||
msg.setText("Please choose...");
|
msg.setText("Can't open database...");
|
||||||
msg.setModal(true);
|
|
||||||
|
|
||||||
QPushButton *pbTitle = msg.addButton("Title",QMessageBox::ActionRole);
|
|
||||||
QPushButton *pbBody = msg.addButton("Body",QMessageBox::ActionRole);
|
|
||||||
QPushButton *pbAll = msg.addButton("ALL",QMessageBox::ActionRole);
|
|
||||||
QPushButton *pbPlatformTitle = msg.addButton("Platform Title",QMessageBox::ActionRole);
|
|
||||||
/*
|
|
||||||
int setbody;
|
|
||||||
msg.exec();
|
msg.exec();
|
||||||
if (msg.clickedButton() == pbTitle) { setbody = 0; }
|
return;
|
||||||
else if (msg.clickedButton() == pbBody) { setbody = 1; }
|
}
|
||||||
else if (msg.clickedButton() == pbAll) { setbody = 2; }
|
setMenu();
|
||||||
else if (msg.clickedButton() == pbPlatformTitle) { setbody = 3; }
|
setDialog();
|
||||||
*/
|
setCentralWidget(&m_progress);
|
||||||
|
}
|
||||||
|
|
||||||
QMessageBox msg2;
|
MainWindow::~MainWindow()
|
||||||
msg2.setWindowFlags(msg2.windowFlags() | Qt::WindowCloseButtonHint);
|
{
|
||||||
msg2.setText("Please wait...");
|
if (m_db.isOpen() == false) return;
|
||||||
msg2.setVisible(true);
|
QFile file("size.sts");
|
||||||
//qDebug() << p_qwDB->GetTabWidget()->currentIndex();
|
if (!file.open(QIODevice::WriteOnly))
|
||||||
m_pTAInterface->setSource(p_qwDB->GetTabWidget()->currentWidget());
|
return;
|
||||||
YAFactory::getInstance()->getYAlgorithm(((YMorphereWidget*)(m_ptwResult->currentWidget()))->convertToParam())->setDataAlgorithmInterface(m_pTAInterface);
|
int anData[(D_DIALOG_MAX+1)*4];
|
||||||
m_ptwResult->currentWidget();
|
for (int i = 0; i < D_DIALOG_MAX;i++)
|
||||||
//qDebug() << m_ptwResult->currentIndex();
|
{
|
||||||
|
anData[i*4+0] = m_pDialogs[i]->geometry().left();
|
||||||
|
anData[i*4+1] = m_pDialogs[i]->geometry().top();
|
||||||
|
anData[i*4+2] = m_pDialogs[i]->geometry().width();
|
||||||
|
anData[i*4+3] = m_pDialogs[i]->geometry().height();
|
||||||
|
}
|
||||||
|
anData[D_DIALOG_MAX*4+0] = geometry().left();
|
||||||
|
anData[D_DIALOG_MAX*4+1] = geometry().top();
|
||||||
|
anData[D_DIALOG_MAX*4+2] = geometry().width();
|
||||||
|
anData[D_DIALOG_MAX*4+3] = geometry().height();
|
||||||
|
file.write((char*)&anData,sizeof(int)*(D_DIALOG_MAX+1)*4);
|
||||||
|
file.close();
|
||||||
|
m_db.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MainWindow::initDb()
|
||||||
|
{
|
||||||
|
m_db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
|
m_db.setHostName("bigbird.iptime.org");
|
||||||
|
m_db.setUserName("admin");
|
||||||
|
m_db.setPassword("admin123");
|
||||||
|
m_db.setDatabaseName("concepters");
|
||||||
|
|
||||||
|
connect(&m_timerAlive, SIGNAL(timeout()), this, SLOT(Alive()));
|
||||||
|
m_timerAlive.start(60*60000);
|
||||||
|
return m_db.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::setMenu()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
QMenu *pFile = menuBar()->addMenu("File");
|
||||||
|
connect(pFile->addAction("New"), SIGNAL(triggered()), this, SLOT(FileNew()));
|
||||||
|
connect(pFile->addAction("CSV Import"), SIGNAL(triggered()), this, SLOT(FileImport()));
|
||||||
|
connect(pFile->addAction("CSV Export"), SIGNAL(triggered()), this, SLOT(FileExport()));
|
||||||
|
pFile->addSeparator();
|
||||||
|
connect(pFile->addAction("Exit"), SIGNAL(triggered()), this, SLOT(FileExit()));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QMenu *pFile = menuBar()->addMenu("Window");
|
||||||
|
connect(pFile->addAction("Load"), SIGNAL(triggered()), this, SLOT(WindowLoad()));
|
||||||
|
connect(pFile->addAction("Data"), SIGNAL(triggered()), this, SLOT(WindowData()));
|
||||||
|
connect(pFile->addAction("Filter Object"), SIGNAL(triggered()), this, SLOT(WindowFilterObject()));
|
||||||
|
connect(pFile->addAction("Filter"), SIGNAL(triggered()), this, SLOT(WindowFilter()));
|
||||||
|
connect(pFile->addAction("Count"), SIGNAL(triggered()), this, SLOT(WindowCount()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setDialog()
|
||||||
|
{
|
||||||
|
m_pBatchRunDlg = new SBatchRun;
|
||||||
|
m_pDataDlg = new SDataDlg;
|
||||||
|
m_ploadDlg = new SLoadDlg;
|
||||||
|
m_pCountDlg = new SCountDlg;
|
||||||
|
m_pFilterObjectDlg = new SFilterObject;
|
||||||
|
m_pFilterDlg = new SFilterDlg;
|
||||||
|
m_pDialogs[0] = m_pDataDlg;
|
||||||
|
m_pDialogs[1] = m_ploadDlg;
|
||||||
|
m_pDialogs[2] = m_pCountDlg;
|
||||||
|
m_pDialogs[3] = m_pFilterObjectDlg;
|
||||||
|
m_pDialogs[4] = m_pFilterDlg;
|
||||||
|
//m_pDialogs[5] = m_pBatchRunDlg;
|
||||||
|
QFile file("size.sts");
|
||||||
|
if (file.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
int anData[D_DIALOG_MAX*4] = {0,};
|
||||||
|
file.read((char*)&anData[0],D_DIALOG_MAX*4*sizeof(int));
|
||||||
|
for (int i = 0; i < D_DIALOG_MAX;i++)
|
||||||
|
{
|
||||||
|
if (anData[i*4+2] != 0)
|
||||||
|
m_pDialogs[i]->setGeometry(anData[i*4+0],anData[i*4+1],anData[i*4+2],anData[i*4+3]);
|
||||||
|
}
|
||||||
|
file.seek(D_DIALOG_MAX*4*sizeof(int));
|
||||||
|
if (file.read((char*)&anData[0],4*sizeof(int)) > 0 )
|
||||||
|
setGeometry(anData[0],anData[1],anData[2],anData[3]);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < D_DIALOG_MAX;i++)
|
||||||
|
m_pDialogs[i]->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::InsertLog(QString str)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
if(m_ptwResult->currentIndex() == 0)
|
QTime time = QTime::currentTime();
|
||||||
|
QString strOut = time.toString("[hh:mm:ss] ") + str;
|
||||||
|
m_pLog->addItem(strOut);
|
||||||
|
if (m_pLog->count() > 1024)
|
||||||
{
|
{
|
||||||
p_qwAnalyzer1->Exec(setbody);
|
m_pLog->removeItemWidget(m_pLog->item(0));
|
||||||
}
|
QListWidgetItem* item = m_pLog->takeItem(0);
|
||||||
else if(m_ptwResult->currentIndex() == 1)
|
delete item;
|
||||||
{
|
|
||||||
p_qwAnalyzer2->Exec(setbody);
|
|
||||||
}
|
|
||||||
else if(m_ptwResult->currentIndex() == 2)
|
|
||||||
{
|
|
||||||
m_pYMBasicWidget->Exec(setbody);
|
|
||||||
}
|
|
||||||
else if(m_ptwResult->currentIndex() == 3)
|
|
||||||
{
|
|
||||||
m_pYMOneDepthWidget->Exec(setbody);
|
|
||||||
}
|
|
||||||
else if(m_ptwResult->currentIndex() == 4)
|
|
||||||
{
|
|
||||||
m_pYMNxNMatrixWidget->Exec(setbody);
|
|
||||||
}
|
}
|
||||||
|
m_pLog->setCurrentRow( m_pLog->count() - 1 );
|
||||||
|
m_pLog->repaint();
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
if(m_ptwResult->currentIndex() == 0)
|
|
||||||
{
|
|
||||||
m_pYMBasicWidget->Exec(setbody);
|
|
||||||
}
|
|
||||||
else if(m_ptwResult->currentIndex() == 1)
|
|
||||||
{
|
|
||||||
m_pYMOneDepthWidget->Exec(setbody);
|
|
||||||
}
|
|
||||||
else if(m_ptwResult->currentIndex() == 2)
|
|
||||||
{
|
|
||||||
m_pYMNxNMatrixWidget->Exec(setbody);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
((YMorphereWidget*)(m_ptwResult->currentWidget()))->Exec();
|
|
||||||
|
|
||||||
msg2.setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::slotTestUpload()
|
|
||||||
|
void MainWindow::FileNew()
|
||||||
{
|
{
|
||||||
((YMorphereWidget*)(m_ptwResult->currentWidget()))->TestUpload();
|
bool ok;
|
||||||
|
QString text = QInputDialog::getText(this,"New Row Count","Count :", QLineEdit::Normal,"0", &ok);
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
STable *pTable = (STable *)m_pDataDlg->AddTable("<New>");
|
||||||
|
QVector <QStringList> column = GetColumn().data();
|
||||||
|
pTable->SetHeaderList(&column,SColumn::E_NAME);
|
||||||
|
pTable->setRowCount(text.toInt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::slotDictionary()
|
void MainWindow::FileImport()
|
||||||
{
|
{
|
||||||
p_qwDict->show();
|
QString strFilename = QFileDialog::getOpenFileName(0,"Import file",QDir::currentPath(),
|
||||||
p_qwDict->repaint();
|
"csv files (*.csv);;All files (*.*)",new QString("Text files (*.csv)"));
|
||||||
|
|
||||||
|
QFile file(strFilename);
|
||||||
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
|
||||||
|
|
||||||
|
QVector <QByteArray> vecByte;
|
||||||
|
bool bQuit = true;
|
||||||
|
while(bQuit)
|
||||||
|
{
|
||||||
|
QByteArray byte = file.readLine();
|
||||||
|
if (byte.isEmpty()) { bQuit = false; continue; }
|
||||||
|
vecByte.push_back(byte);
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
m_pDataDlg->Import(vecByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event)
|
void MainWindow::FileExport()
|
||||||
{
|
{
|
||||||
QApplication::quit();
|
QString strFilename = QFileDialog::getSaveFileName(0,"Exoprt file",QDir::currentPath(),"csv files (*.csv);;All files (*.*)",new QString("Text files (*.csv)"));
|
||||||
|
if (strFilename.toLower().right(4) != QString(".csv"))
|
||||||
|
strFilename += ".csv";
|
||||||
|
|
||||||
|
m_pDataDlg->Export(strFilename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::FileExit()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < D_DIALOG_MAX;i++)
|
||||||
|
m_pDialogs[i]->close();
|
||||||
|
m_graph.close();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::WindowLoad()
|
||||||
|
{
|
||||||
|
if (m_ploadDlg->isHidden())
|
||||||
|
m_ploadDlg->show();
|
||||||
|
else
|
||||||
|
m_ploadDlg->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::WindowFilterObject()
|
||||||
|
{
|
||||||
|
if(m_pFilterObjectDlg->isHidden())
|
||||||
|
m_pFilterObjectDlg->show();
|
||||||
|
else
|
||||||
|
m_pFilterObjectDlg->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::WindowCount()
|
||||||
|
{
|
||||||
|
if (m_pCountDlg->isHidden())
|
||||||
|
m_pCountDlg->show();
|
||||||
|
else
|
||||||
|
m_pCountDlg->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::WindowFilter()
|
||||||
|
{
|
||||||
|
if (m_pFilterDlg->isHidden())
|
||||||
|
m_pFilterDlg->show();
|
||||||
|
else
|
||||||
|
m_pFilterDlg->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::WindowData()
|
||||||
|
{
|
||||||
|
if (m_pDataDlg->isHidden())
|
||||||
|
m_pDataDlg->show();
|
||||||
|
else
|
||||||
|
m_pDataDlg->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::closeEvent(QCloseEvent * event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
FileExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::Alive()
|
||||||
|
{
|
||||||
|
QSqlQuery query;
|
||||||
|
query.exec("SELECT 1");
|
||||||
|
query.next();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,169 +1,67 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD$
|
|
||||||
** You may use this file under the terms of the BSD license as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in
|
|
||||||
** the documentation and/or other materials provided with the
|
|
||||||
** distribution.
|
|
||||||
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
|
||||||
** of its contributors may be used to endorse or promote products derived
|
|
||||||
** from this software without specific prior written permission.
|
|
||||||
**
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QTabWidget>
|
#include <QMenuBar>
|
||||||
#include "widget.h"
|
#include <QDebug>
|
||||||
#include "sanaly1.h"
|
#include <QSqlQuery>
|
||||||
#include "sanaly2.h"
|
#include <QSqlDatabase>
|
||||||
#include "ymorpherewidget.h"
|
#include <QSqlError>
|
||||||
#include <QList>
|
#include <QProgressBar>
|
||||||
#include "sdictionary.h"
|
#include <QSqlDatabase>
|
||||||
#include "tablealgorithm_interface.h"
|
#include <QTimer>
|
||||||
#include <QCloseEvent>
|
#include <QWebView>
|
||||||
#include "ymuploadwidget.h"
|
#include "sloaddlg.h"
|
||||||
|
#include "sdatadlg.h"
|
||||||
|
#include "scountdlg.h"
|
||||||
|
#include "sfilterobject.h"
|
||||||
|
#include "sfilterdlg.h"
|
||||||
|
#include "sbatchrun.h"
|
||||||
|
#include "scolumn.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
#define D_DIALOG_MAX 5
|
||||||
class QAction;
|
|
||||||
class QActionGroup;
|
|
||||||
class QLabel;
|
|
||||||
class QMenu;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
//! [0]
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow(QWidget *parent = 0);
|
||||||
protected:
|
~MainWindow();
|
||||||
//void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;
|
void InsertLog(QString str);
|
||||||
//! [0]
|
bool initDb();
|
||||||
|
|
||||||
//! [1]
|
|
||||||
private slots:
|
|
||||||
void newDB();
|
|
||||||
void importDB();
|
|
||||||
void exportDB();
|
|
||||||
void exportMorphere();
|
|
||||||
void importMorphere();
|
|
||||||
void slotAnalyze();
|
|
||||||
void slotDictionary();
|
|
||||||
void exportOriginalMorphere();
|
|
||||||
void slotTestUpload();
|
|
||||||
void slotD3View();
|
|
||||||
void slotShowUpload();
|
|
||||||
void slotD3ViewTree();
|
|
||||||
void slotD3ViewFile();
|
|
||||||
void slotD3ViewTreeFile();
|
|
||||||
protected:
|
|
||||||
void closeEvent(QCloseEvent *);
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
private:
|
private:
|
||||||
void createActions();
|
void setMenu();
|
||||||
void createMenus();
|
bool ReloadColumn();
|
||||||
//! [2]
|
void setDialog();
|
||||||
|
private slots:
|
||||||
//! [3]
|
void FileNew();
|
||||||
//!
|
void FileImport();
|
||||||
//!
|
void FileExport();
|
||||||
|
void FileExit();
|
||||||
QTabWidget *m_ptwSource;
|
void WindowLoad();
|
||||||
QTabWidget *m_ptwResult;
|
void WindowData();
|
||||||
QWidget *m_qwMain;
|
void WindowFilter();
|
||||||
|
void WindowCount();
|
||||||
Widget *p_qwDB;
|
void WindowFilterObject();
|
||||||
QWidget *p_qwFile;
|
void Alive();
|
||||||
QWidget *p_qwAnalyzed1;
|
public:
|
||||||
QWidget *p_qwText;
|
SLoadDlg *m_ploadDlg;
|
||||||
SDictionary *p_qwDict;
|
SDataDlg *m_pDataDlg;
|
||||||
YMUploadWidget* m_pUploadWidget;
|
SCountDlg *m_pCountDlg;
|
||||||
|
SFilterObject *m_pFilterObjectDlg;
|
||||||
|
SFilterDlg *m_pFilterDlg;
|
||||||
SAnaly1 *p_qwAnalyzer1;
|
SBatchRun *m_pBatchRunDlg;
|
||||||
SAnaly2 *p_qwAnalyzer2;
|
QWebView m_graph;
|
||||||
YMorphereWidget *m_pYMBasicWidget;
|
QSqlDatabase m_db;
|
||||||
YMorphereWidget *m_pYMOneDepthWidget;
|
QProgressBar m_progress;
|
||||||
YMorphereWidget *m_pYMNxNMatrixWidget;
|
private:
|
||||||
YMorphereWidget *m_pYMTwoDepthWidget;
|
QDialog *m_pDialogs[D_DIALOG_MAX];
|
||||||
YMorphereWidget *m_pYMTwoDepthAWidget;
|
QTimer m_timerAlive;
|
||||||
YMorphereWidget *m_pYMPlatformWidget;
|
protected:
|
||||||
|
void closeEvent(QCloseEvent * event);
|
||||||
QAction *actDBNew;
|
|
||||||
QAction *actDBCsvImport;
|
|
||||||
QAction *actDBCsvExport;
|
|
||||||
QAction *actMorphereExport;
|
|
||||||
QAction *actMorphereImport;
|
|
||||||
QAction *actMorphereOriginalExport;
|
|
||||||
|
|
||||||
QAction *actExit;
|
|
||||||
QAction *actAnalyze;
|
|
||||||
QAction *actDictionary;
|
|
||||||
|
|
||||||
QAction *actTestUpload;
|
|
||||||
|
|
||||||
QMenu *menuFile;
|
|
||||||
QMenu *menuAnalyze;
|
|
||||||
QMenu *menuDictionary;
|
|
||||||
QMenu *menuTestUpload;
|
|
||||||
QMenu *menuShowUpload;
|
|
||||||
QMenu *menuD3View;
|
|
||||||
|
|
||||||
|
|
||||||
QAction *actD3View;
|
|
||||||
QAction *actD3ViewTree;
|
|
||||||
|
|
||||||
QAction *actD3ViewFile;
|
|
||||||
QAction *actD3ViewTreeFile;
|
|
||||||
|
|
||||||
QAction *actShowUpload;
|
|
||||||
//AnalyzerThread m_pThread[16];
|
|
||||||
/*
|
|
||||||
QMutex mutex;
|
|
||||||
AnalyzerThread **m_pThread;
|
|
||||||
QList<STable*> m_lTable;
|
|
||||||
QList<QTabWidget*> m_lTabWidget;
|
|
||||||
*/
|
|
||||||
QTabWidget* m_ptwTable;
|
|
||||||
TableAlgorithmInterface* m_pTAInterface;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
//! [3]
|
|
||||||
|
|
||||||
#endif
|
MainWindow *GetMainWindow();
|
||||||
|
SColumn GetColumn();
|
||||||
|
|
||||||
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
850
MorphereAnalyzer/sbatchrun.cpp
Normal file
850
MorphereAnalyzer/sbatchrun.cpp
Normal file
@@ -0,0 +1,850 @@
|
|||||||
|
#include "sbatchrun.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QDateEdit>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QCalendarWidget>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFile>
|
||||||
|
#include "stable.h"
|
||||||
|
#include "scolumn.h"
|
||||||
|
#include "./../Json/sjson.h"
|
||||||
|
#define D_NOT_SELECT -1
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
|
void SBatchRun::showBatchRun(int nGroupID)
|
||||||
|
{
|
||||||
|
if(nGroupID == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RefreshFilter(nGroupID);
|
||||||
|
this->show();
|
||||||
|
this->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SBatchRun::SBatchRun()
|
||||||
|
{
|
||||||
|
setMainWidgets();
|
||||||
|
ReloadColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVBoxLayout* SBatchRun::setLoadWidgets()
|
||||||
|
{
|
||||||
|
QVBoxLayout *vLoad = new QVBoxLayout;
|
||||||
|
m_plwData = new QListWidget;
|
||||||
|
m_plwData->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
vLoad->addWidget(m_plwData);
|
||||||
|
|
||||||
|
QPushButton *ppbRefresh = new QPushButton("Refresh");
|
||||||
|
vLoad->addWidget(ppbRefresh);
|
||||||
|
connect(ppbRefresh, SIGNAL(released()),this, SLOT(Refresh()));
|
||||||
|
|
||||||
|
return vLoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVBoxLayout* SBatchRun::setDaysWidgets()
|
||||||
|
{
|
||||||
|
QVBoxLayout *vDays = new QVBoxLayout;
|
||||||
|
|
||||||
|
m_pgbFromTo = setFromToWidgets();
|
||||||
|
m_pgbCutDays = setCutDaysWidgets();
|
||||||
|
|
||||||
|
connect(m_pgbFromTo, SIGNAL(clicked(bool)), this, SLOT(clickedFromTo(bool)));
|
||||||
|
connect(m_pgbCutDays, SIGNAL(clicked(bool)), this, SLOT(clickedCutDays(bool)));
|
||||||
|
|
||||||
|
vDays->addWidget(m_pgbFromTo);
|
||||||
|
vDays->addWidget(m_pgbCutDays);
|
||||||
|
|
||||||
|
return vDays;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVBoxLayout* SBatchRun::setFilterWidgets()
|
||||||
|
{
|
||||||
|
m_pleFilter = new QLineEdit;
|
||||||
|
m_plwFilter = new QListWidget;
|
||||||
|
|
||||||
|
QVBoxLayout *vFilter = new QVBoxLayout;
|
||||||
|
vFilter->addWidget(m_pleFilter);
|
||||||
|
vFilter->addWidget(m_plwFilter);
|
||||||
|
|
||||||
|
return vFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QGroupBox* SBatchRun::setFromToWidgets()
|
||||||
|
{
|
||||||
|
m_pdeFrom = new QDateEdit(QDate::currentDate());
|
||||||
|
m_pdeTo = new QDateEdit(QDate::currentDate());
|
||||||
|
|
||||||
|
m_pdeFrom->setDateRange(QDate(2003, 5, 20),QDate::currentDate());
|
||||||
|
m_pdeTo->setDateRange(QDate(2003, 5, 20),QDate::currentDate().addYears(1));
|
||||||
|
|
||||||
|
QCalendarWidget *pCalender = new QCalendarWidget();
|
||||||
|
m_pdeFrom->setCalendarWidget(pCalender);
|
||||||
|
m_pdeFrom->setCalendarPopup(true);
|
||||||
|
|
||||||
|
m_pdeTo->setCalendarWidget(pCalender);
|
||||||
|
m_pdeTo->setCalendarPopup(true);
|
||||||
|
|
||||||
|
QHBoxLayout *hFromTo = new QHBoxLayout;
|
||||||
|
hFromTo->addWidget(new QLabel("From:"));
|
||||||
|
hFromTo->addWidget(m_pdeFrom);
|
||||||
|
hFromTo->addWidget(new QLabel("To:"));
|
||||||
|
hFromTo->addWidget(m_pdeTo);
|
||||||
|
|
||||||
|
QGroupBox* pgbFromTo = new QGroupBox("FromTo");
|
||||||
|
pgbFromTo->setLayout(hFromTo);
|
||||||
|
pgbFromTo->setCheckable(true);
|
||||||
|
pgbFromTo->setChecked(false);
|
||||||
|
|
||||||
|
return pgbFromTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGroupBox* SBatchRun::setCutDaysWidgets()
|
||||||
|
{
|
||||||
|
m_pleCutDays = new QLineEdit;
|
||||||
|
m_pleCutDays->setText("-31");
|
||||||
|
|
||||||
|
QHBoxLayout *hCutDays = new QHBoxLayout;
|
||||||
|
hCutDays->addWidget(new QLabel("CutDays:"));
|
||||||
|
hCutDays->addWidget(m_pleCutDays);
|
||||||
|
|
||||||
|
QGroupBox* pgbCutDays = new QGroupBox("CutDays");
|
||||||
|
pgbCutDays->setLayout(hCutDays);
|
||||||
|
pgbCutDays->setCheckable(true);
|
||||||
|
pgbCutDays->setChecked(true);
|
||||||
|
|
||||||
|
return pgbCutDays;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SBatchRun::setMainWidgets()
|
||||||
|
{
|
||||||
|
QHBoxLayout *hMain = new QHBoxLayout;
|
||||||
|
hMain->addLayout(setLoadWidgets());
|
||||||
|
hMain->addLayout(setDaysWidgets());
|
||||||
|
hMain->addLayout(setFilterWidgets());
|
||||||
|
QPushButton *ppbRun = new QPushButton;
|
||||||
|
ppbRun->setText("Run");
|
||||||
|
connect(ppbRun, SIGNAL(released()),this, SLOT(run()));
|
||||||
|
hMain->addWidget(ppbRun);
|
||||||
|
|
||||||
|
setLayout(hMain);
|
||||||
|
|
||||||
|
setWindowTitle("Batch Run");
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBatchRun::clickedCutDays(bool clicked)
|
||||||
|
{
|
||||||
|
m_pgbFromTo->setChecked(!clicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SBatchRun::clickedFromTo(bool clicked)
|
||||||
|
{
|
||||||
|
m_pgbCutDays->setChecked(!clicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBatchRun::Refresh()
|
||||||
|
{
|
||||||
|
m_plwData->clear();
|
||||||
|
QSqlQuery query("select id,name,count from datagroup");
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
QString str = query.value(1).toString();
|
||||||
|
str += " ( ";
|
||||||
|
str += query.value(0).toString();
|
||||||
|
str += " , ";
|
||||||
|
str += query.value(2).toString();
|
||||||
|
str += " )";
|
||||||
|
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwData);
|
||||||
|
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBatchRun::run()
|
||||||
|
{
|
||||||
|
if(!loadData())
|
||||||
|
{
|
||||||
|
Message("Check Data DB");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!execFilter())
|
||||||
|
{
|
||||||
|
Message("Filter Failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ViewResult();
|
||||||
|
clearData();
|
||||||
|
}
|
||||||
|
|
||||||
|
SBatchRun::~SBatchRun()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBatchRun::ViewResult()
|
||||||
|
{
|
||||||
|
QVector <QStringList> column = GetColumn().data();
|
||||||
|
/*
|
||||||
|
STable *pTable = (STable *)GetMainWindow()->m_pDataDlg->GetCurrentWidget();
|
||||||
|
if (pTable == NULL)
|
||||||
|
pTable = (STable *)GetMainWindow()->m_pDataDlg->AddTable("<Batch>");
|
||||||
|
*/
|
||||||
|
STable *pTable = (STable *)GetMainWindow()->m_pDataDlg->AddTable("<Batch>");
|
||||||
|
QMap<QString, bool> mapFilter;
|
||||||
|
|
||||||
|
for(int i = 0; i < E_ARTICLE_MAX; i++)
|
||||||
|
{
|
||||||
|
if(m_bDataFlag[i])
|
||||||
|
{
|
||||||
|
for(int j = 0; j < m_data[i].length(); j++)
|
||||||
|
{
|
||||||
|
mapFilter[m_data[i][j][m_anData[E_DATA_article_url]].trimmed()] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qDebug() << m_bDataFlag[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "MapFilter size :" << mapFilter.size();
|
||||||
|
|
||||||
|
if(!m_bDataFlag[E_ARTICLE_BODY] && !m_bDataFlag[E_ARTICLE_REPLY])
|
||||||
|
{
|
||||||
|
for(int i = 0; i < m_vecData[E_ARTICLE_BODY].size(); i++)
|
||||||
|
{
|
||||||
|
mapFilter[m_vecData[E_ARTICLE_BODY][i][m_anData[E_DATA_article_url]].trimmed()] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalRow = 0;
|
||||||
|
for(int i = 0; i < E_ARTICLE_MAX; i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < m_vecData[i].size(); j++)
|
||||||
|
{
|
||||||
|
if(mapFilter.value(m_vecData[i][j][m_anData[E_DATA_article_url]].trimmed()))
|
||||||
|
totalRow++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qDebug() << totalRow;
|
||||||
|
|
||||||
|
pTable->setArticleSelect(STable::E_ARTICLE_ALL);
|
||||||
|
pTable->clear();
|
||||||
|
pTable->SetHeaderList(&column,SColumn::E_NAME);
|
||||||
|
pTable->setRowCount(totalRow);
|
||||||
|
|
||||||
|
GetMainWindow()->m_progress.setRange(0, totalRow);
|
||||||
|
int nCount = 0;
|
||||||
|
for(int i = 0; i < E_ARTICLE_MAX; i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < m_vecData[i].length(); j++)
|
||||||
|
{
|
||||||
|
if(mapFilter.value(m_vecData[i][j][m_anData[E_DATA_article_url]].trimmed()))
|
||||||
|
{
|
||||||
|
for (int k = 0; k < pTable->columnCount() ; k++)
|
||||||
|
{
|
||||||
|
QString str = m_vecData[i][j][k].replace("\n"," ");
|
||||||
|
pTable->setItem(nCount,k,new QTableWidgetItem(" "+str.replace("\t"," ")+" "));
|
||||||
|
}
|
||||||
|
nCount++;
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pTable->repaint();
|
||||||
|
//Message(QString("RealBody : ") + QString::number(m_data[E_ARTICLE_BODY].size()) + QString("\nRealReply : ") + QString::number(m_data[E_ARTICLE_REPLY].size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SBatchRun::ViewRawResult()
|
||||||
|
{
|
||||||
|
// check data duplication
|
||||||
|
{
|
||||||
|
QMap<QString, int> mapUrls;
|
||||||
|
for(int i = 0; i < m_vecData[E_ARTICLE_BODY].size(); i++)
|
||||||
|
{
|
||||||
|
if(mapUrls.contains(m_vecData[E_ARTICLE_BODY][i][m_anData[E_DATA_article_url]].trimmed()))
|
||||||
|
{
|
||||||
|
mapUrls[m_vecData[E_ARTICLE_BODY][i][m_anData[E_DATA_article_url]].trimmed()] += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mapUrls[m_vecData[E_ARTICLE_BODY][i][m_anData[E_DATA_article_url]].trimmed()] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for(QMap<QString, int>::iterator iterPos = mapUrls.begin(); iterPos != mapUrls.end(); iterPos++)
|
||||||
|
{
|
||||||
|
if(iterPos.value() > 1)
|
||||||
|
qDebug() << iterPos.key() << " : " << iterPos.value() ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVector <QStringList> column = GetColumn().data();
|
||||||
|
/*
|
||||||
|
STable *pTable = (STable *)GetMainWindow()->m_pDataDlg->GetCurrentWidget();
|
||||||
|
if (pTable == NULL)
|
||||||
|
pTable = (STable *)GetMainWindow()->m_pDataDlg->AddTable("<Batch>");
|
||||||
|
*/
|
||||||
|
STable *pTable = (STable *)GetMainWindow()->m_pDataDlg->AddTable("<RawBatch>");
|
||||||
|
|
||||||
|
int totalRow = 0;
|
||||||
|
for(int i = 0; i < E_ARTICLE_MAX; i++)
|
||||||
|
{
|
||||||
|
totalRow += m_vecData[i].size();
|
||||||
|
}
|
||||||
|
qDebug() << totalRow;
|
||||||
|
|
||||||
|
pTable->setArticleSelect(STable::E_ARTICLE_ALL);
|
||||||
|
pTable->clear();
|
||||||
|
pTable->SetHeaderList(&column,SColumn::E_NAME);
|
||||||
|
pTable->setRowCount(totalRow);
|
||||||
|
|
||||||
|
GetMainWindow()->m_progress.setRange(0, totalRow);
|
||||||
|
int nCount = 0;
|
||||||
|
for(int i = 0; i < E_ARTICLE_MAX; i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < m_vecData[i].length(); j++)
|
||||||
|
{
|
||||||
|
for (int k = 0; k < pTable->columnCount() ; k++)
|
||||||
|
{
|
||||||
|
QString str = m_vecData[i][j][k].replace("\n"," ");
|
||||||
|
pTable->setItem(nCount,k,new QTableWidgetItem(" "+str.replace("\t"," ")+" "));
|
||||||
|
}
|
||||||
|
nCount++;
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pTable->repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SBatchRun::RefreshFilter(int _nGroup)
|
||||||
|
{
|
||||||
|
if (_nGroup == D_NOT_SELECT) return;
|
||||||
|
{
|
||||||
|
QSqlQuery query("select id,type,data from filter where filtergroup_id = " + QString::number(_nGroup));
|
||||||
|
m_plwFilter->clear();
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
QString str = GetMainWindow()->m_pFilterObjectDlg->JsonToString(query.value(1).toInt(),query.value(2).toString());
|
||||||
|
QListWidgetItem *pItem = new QListWidgetItem(str, m_plwFilter);
|
||||||
|
pItem->setData(Qt::UserRole, QVariant(QList<QVariant>() << query.value(1) << query.value(2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
m_pleFilter->clear();
|
||||||
|
QSqlQuery query("select id,name from filtergroup where id = " + QString::number(_nGroup));
|
||||||
|
while (query.next())
|
||||||
|
m_pleFilter->setText(query.value(1).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
bool SBatchRun::ReloadColumn()
|
||||||
|
{
|
||||||
|
QVector <QStringList> vecColumn;
|
||||||
|
QFile file("column.txt");
|
||||||
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text) == false) return false;
|
||||||
|
{
|
||||||
|
while (!file.atEnd())
|
||||||
|
{
|
||||||
|
QString str = QString(file.readLine());
|
||||||
|
if (str.at(0) == QChar('#')) continue;
|
||||||
|
if (str.trimmed().isEmpty()) continue;
|
||||||
|
vecColumn.push_back(str.split(","));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (vecColumn.size() <= 0) return false;
|
||||||
|
|
||||||
|
foreach(QStringList strList,vecColumn)
|
||||||
|
m_listDataBaseColumn.push_back(strList.at(E_COLUMN_DATABASE));
|
||||||
|
|
||||||
|
for(int i = 0; i < m_listDataBaseColumn.size(); i++)
|
||||||
|
{
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("platform_title")) m_anData[E_DATA_platform_title] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_form")) m_anData[E_DATA_article_form] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_parent")) m_anData[E_DATA_article_parent] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_id")) m_anData[E_DATA_article_id] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_nickname")) m_anData[E_DATA_article_nickname] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_title")) m_anData[E_DATA_article_title] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_data")) m_anData[E_DATA_article_data] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_url")) m_anData[E_DATA_article_url] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_hit")) m_anData[E_DATA_article_hit] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_date")) m_anData[E_DATA_article_date] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_order")) m_anData[E_DATA_article_order] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("platform_id")) m_anData[E_DATA_platform_id] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("platform_name")) m_anData[E_DATA_platform_name] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("platform_form")) m_anData[E_DATA_platform_form] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("reply_url")) m_anData[E_DATA_reply_url] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("keyword_id")) m_anData[E_DATA_keyword_id] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_profileurl")) m_anData[E_DATA_article_profileurl] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("article_profile")) m_anData[E_DATA_article_profile] = i;
|
||||||
|
if (m_listDataBaseColumn[i].trimmed() == QString("etc")) m_anData[E_DATA_etc] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_nUrlColumn = m_anData[E_DATA_article_url];
|
||||||
|
m_nDateColumn = m_anData[E_DATA_article_date];
|
||||||
|
m_nOrderColumn = m_anData[E_DATA_article_order];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool SBatchRun::ReloadColumn()
|
||||||
|
{
|
||||||
|
m_anData[E_DATA_platform_title] = GetColumn().getColumnIndex(QString("platform_title"));
|
||||||
|
m_anData[E_DATA_article_form] = GetColumn().getColumnIndex(QString("article_form"));
|
||||||
|
m_anData[E_DATA_article_parent] = GetColumn().getColumnIndex(QString("article_parent"));
|
||||||
|
m_anData[E_DATA_article_id] = GetColumn().getColumnIndex(QString("article_id"));
|
||||||
|
m_anData[E_DATA_article_nickname] = GetColumn().getColumnIndex(QString("article_nickname"));
|
||||||
|
m_anData[E_DATA_article_title] = GetColumn().getColumnIndex(QString("article_title"));
|
||||||
|
m_anData[E_DATA_article_data] = GetColumn().getColumnIndex(QString("article_data"));
|
||||||
|
m_anData[E_DATA_article_url] = GetColumn().getColumnIndex(QString("article_url"));
|
||||||
|
m_anData[E_DATA_article_hit] = GetColumn().getColumnIndex(QString("article_hit"));
|
||||||
|
m_anData[E_DATA_article_date] = GetColumn().getColumnIndex(QString("article_date"));
|
||||||
|
m_anData[E_DATA_article_order] = GetColumn().getColumnIndex(QString("article_order"));
|
||||||
|
m_anData[E_DATA_platform_id] = GetColumn().getColumnIndex(QString("platform_id"));
|
||||||
|
m_anData[E_DATA_platform_name] = GetColumn().getColumnIndex(QString("platform_name"));
|
||||||
|
m_anData[E_DATA_platform_form] = GetColumn().getColumnIndex(QString("platform_form"));
|
||||||
|
m_anData[E_DATA_reply_url] = GetColumn().getColumnIndex(QString("reply_url"));
|
||||||
|
m_anData[E_DATA_keyword_id] = GetColumn().getColumnIndex(QString("keyword_id"));
|
||||||
|
m_anData[E_DATA_article_profileurl] = GetColumn().getColumnIndex(QString("article_profileurl"));
|
||||||
|
m_anData[E_DATA_article_profile] = GetColumn().getColumnIndex(QString("article_profile"));
|
||||||
|
m_anData[E_DATA_etc] = GetColumn().getColumnIndex(QString("etc"));
|
||||||
|
|
||||||
|
m_nUrlColumn = m_anData[E_DATA_article_url];
|
||||||
|
m_nDateColumn = m_anData[E_DATA_article_date];
|
||||||
|
m_nOrderColumn = m_anData[E_DATA_article_order];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SBatchRun::loadData()
|
||||||
|
{
|
||||||
|
QList<QListWidgetItem*> items = m_plwData->selectedItems();
|
||||||
|
if(items.length() < 1 || items.length() > 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
clearData();
|
||||||
|
|
||||||
|
QString _strDataNum = QString::number(items[0]->data(Qt::UserRole).toInt());
|
||||||
|
int nCutDays = m_pleCutDays->text().toInt();
|
||||||
|
QDate dateFrom = m_pdeFrom->date();
|
||||||
|
QDate dateTo = m_pdeTo->date();
|
||||||
|
|
||||||
|
|
||||||
|
QString strSelect;
|
||||||
|
strSelect = "select ";
|
||||||
|
qDebug() << "GetColumn().data().size() : "<< GetColumn().data().size();
|
||||||
|
foreach (QStringList strListColumn, GetColumn().data())
|
||||||
|
{
|
||||||
|
qDebug() << strListColumn[E_COLUMN_DATABASE];
|
||||||
|
strSelect += "CONVERT(" + strListColumn[E_COLUMN_DATABASE] + " USING utf8),";
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
foreach (QString strColumn,m_listDataBaseColumn)
|
||||||
|
strSelect += "CONVERT(" + strColumn + " USING utf8),";
|
||||||
|
*/
|
||||||
|
strSelect = strSelect.left(strSelect.size() - 1);
|
||||||
|
strSelect += " from ";
|
||||||
|
strSelect += "data_" + _strDataNum;
|
||||||
|
|
||||||
|
QString astrWhere[E_ARTICLE_MAX] = {" where article_form = 'body'"," where article_form = 'reply'"};
|
||||||
|
astrWhere[E_ARTICLE_BODY] += " and date(article_date) >= ";
|
||||||
|
astrWhere[E_ARTICLE_REPLY] += " and date(article_date) >= ";
|
||||||
|
if(m_pgbCutDays->isChecked())
|
||||||
|
{
|
||||||
|
astrWhere[E_ARTICLE_BODY] += "date(subdate(now(), INTERVAL ";
|
||||||
|
astrWhere[E_ARTICLE_BODY] += QString::number(abs(nCutDays));
|
||||||
|
astrWhere[E_ARTICLE_BODY] += " DAY))";
|
||||||
|
astrWhere[E_ARTICLE_BODY] += " and date(article_date) <= date(now())";
|
||||||
|
|
||||||
|
astrWhere[E_ARTICLE_REPLY] += "date(subdate(now(), INTERVAL ";
|
||||||
|
astrWhere[E_ARTICLE_REPLY] += QString::number(abs(nCutDays));
|
||||||
|
astrWhere[E_ARTICLE_REPLY] += " DAY))";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
astrWhere[E_ARTICLE_BODY] += "date('" + dateFrom.toString("yyyy-MM-dd") + "') ";
|
||||||
|
astrWhere[E_ARTICLE_BODY] += " and date(article_date) <= date('" + dateTo.toString("yyyy-MM-dd") + "')";
|
||||||
|
|
||||||
|
astrWhere[E_ARTICLE_REPLY] += "date('" + dateFrom.toString("yyyy-MM-dd") + "') ";
|
||||||
|
}
|
||||||
|
astrWhere[E_ARTICLE_BODY] += " Order by article_date DESC";
|
||||||
|
|
||||||
|
QSqlQuery query;
|
||||||
|
QSet<QString> setUrl;
|
||||||
|
|
||||||
|
for (int i = 0; i < E_ARTICLE_MAX ; i++)
|
||||||
|
{
|
||||||
|
if(query.exec(QString(strSelect + astrWhere[i]).toUtf8()) == false)
|
||||||
|
{
|
||||||
|
qDebug() << query.lastQuery();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(query.next())
|
||||||
|
{
|
||||||
|
QStringList strList;
|
||||||
|
strList.clear();
|
||||||
|
for(int j = 0; j < GetColumn().data().size(); j++)
|
||||||
|
//strList << " " + query.value(j).toString() + " ";
|
||||||
|
strList.append(query.value(j).toString());
|
||||||
|
|
||||||
|
if(strList[m_anData[E_DATA_platform_form]].trimmed() == "post" || strList[m_anData[E_DATA_platform_form]].trimmed() == "story" || strList[m_anData[E_DATA_platform_form]].trimmed() == "channel")
|
||||||
|
strList[m_anData[E_DATA_platform_form]] = "sns";
|
||||||
|
|
||||||
|
if(strList[m_anData[E_DATA_platform_form]].trimmed() == "group")
|
||||||
|
strList[m_anData[E_DATA_platform_form]] = "community";
|
||||||
|
|
||||||
|
|
||||||
|
if(i == E_ARTICLE_BODY)
|
||||||
|
{
|
||||||
|
if (strList[m_anData[E_DATA_article_date]].trimmed().isEmpty()) continue;
|
||||||
|
if (strList[m_anData[E_DATA_article_id]].trimmed().isEmpty()) continue;
|
||||||
|
if (strList[m_anData[E_DATA_article_nickname]].trimmed().isEmpty()) continue;
|
||||||
|
if (strList[m_anData[E_DATA_platform_id]].trimmed().isEmpty()) continue;
|
||||||
|
if (strList[m_anData[E_DATA_platform_id]].trimmed().isEmpty()) continue;
|
||||||
|
if (strList[m_anData[E_DATA_article_date]].trimmed() == "0000-00-00 00:00:00")
|
||||||
|
strList[m_anData[E_DATA_article_date]] = "1990-01-01 00:00:00";
|
||||||
|
|
||||||
|
setUrl.insert(strList[m_anData[E_DATA_article_url]].trimmed());
|
||||||
|
m_vecData[i].append(strList);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(i == E_ARTICLE_REPLY)
|
||||||
|
{
|
||||||
|
if (strList[m_anData[E_DATA_article_id]].trimmed().isEmpty()) continue;
|
||||||
|
if (strList[m_anData[E_DATA_article_nickname]].trimmed().isEmpty()) continue;
|
||||||
|
if (strList[m_anData[E_DATA_article_date]].trimmed() == "0000-00-00 00:00:00")
|
||||||
|
strList[m_anData[E_DATA_article_date]] = "1990-01-01 00:00:00";
|
||||||
|
|
||||||
|
if(setUrl.contains(strList[m_anData[E_DATA_article_url]].trimmed()))
|
||||||
|
{
|
||||||
|
m_vecData[i].append(strList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
setUrl.clear();
|
||||||
|
for(int i = 0; i < E_ARTICLE_MAX; i++)
|
||||||
|
{
|
||||||
|
m_data[i] = m_vecData[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
//ViewRawResult();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBatchRun::Message(QString strMessage)
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText(strMessage);
|
||||||
|
msgBox.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SBatchRun::execFilter()
|
||||||
|
{
|
||||||
|
DataFilter();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SBatchRun::clearData()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < E_ARTICLE_MAX; i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < m_vecData[i].length(); j++)
|
||||||
|
{
|
||||||
|
m_vecData[i][j].clear();
|
||||||
|
}
|
||||||
|
for(int j = 0; j < m_data[i].length(); j++)
|
||||||
|
{
|
||||||
|
m_data[i][j].clear();
|
||||||
|
}
|
||||||
|
m_vecData[i].clear();
|
||||||
|
m_data[i].clear();
|
||||||
|
}
|
||||||
|
for(int i = 0; i < E_ARTICLE_MAX; i++)
|
||||||
|
{
|
||||||
|
m_bDataFlag[i] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SBatchRun::DataFilter()
|
||||||
|
{
|
||||||
|
qDebug() << m_plwFilter->count();
|
||||||
|
for(int i = 0; i < m_plwFilter->count(); i++)
|
||||||
|
{
|
||||||
|
QList<QVariant> filterInfo = m_plwFilter->item(i)->data(Qt::UserRole).toList();
|
||||||
|
// qDebug() << filterInfo[0].toInt();
|
||||||
|
// qDebug() << filterInfo[1].toString();
|
||||||
|
switch(filterInfo.at(0).toInt())
|
||||||
|
{
|
||||||
|
case E_FILTER_TYPE_DATE://Date
|
||||||
|
FilterDate(filterInfo.at(1).toString());
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_SEARCH:
|
||||||
|
FilterSerach(filterInfo.at(1).toString());
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_LENGTH:
|
||||||
|
FilterLength(filterInfo.at(1).toString());
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_REPLACE:
|
||||||
|
FilterReplace(filterInfo.at(1).toString());
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_COUNTER:
|
||||||
|
FilterCounter(filterInfo.at(1).toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SBatchRun::FilterDate(QString _strJson)
|
||||||
|
{
|
||||||
|
SJson json;
|
||||||
|
int nSelect = json.Get(_strJson,"Article").toInt() - 1;
|
||||||
|
if (nSelect < 0) return;
|
||||||
|
m_bDataFlag[nSelect] = true;
|
||||||
|
QVector <QStringList> copyData;
|
||||||
|
QDate dateStart = QDate::fromString(json.Get(_strJson,"Start"),"yyyy-MM-dd");
|
||||||
|
QDate dateEnd = QDate::fromString(json.Get(_strJson,"End"),"yyyy-MM-dd");
|
||||||
|
foreach(QStringList strList , m_data[nSelect])
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
QString strTime = strList.at(m_nDateColumn).trimmed();
|
||||||
|
if (strTime.size() >= 10)
|
||||||
|
{
|
||||||
|
QChar ch = strTime.at(4);
|
||||||
|
QString strFormat = QString("yyyy")+ch+QString("MM")+ch+QString("dd");
|
||||||
|
QDate date = QDate::fromString(strTime.left(10),strFormat);
|
||||||
|
if (dateStart <= date && dateEnd >= date)
|
||||||
|
bFlag = true;
|
||||||
|
}
|
||||||
|
if (bFlag)
|
||||||
|
copyData.push_back(strList);
|
||||||
|
}
|
||||||
|
m_data[nSelect].clear();
|
||||||
|
m_data[nSelect] = copyData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBatchRun::FilterLength(QString _strJson)
|
||||||
|
{
|
||||||
|
SJson json;
|
||||||
|
int nSelect = json.Get(_strJson,"Article").toInt() - 1;
|
||||||
|
if (nSelect < 0) return;
|
||||||
|
m_bDataFlag[nSelect] = true;
|
||||||
|
|
||||||
|
int nCatalog = json.GetNumber(_strJson,"Category");
|
||||||
|
int nComp = json.GetNumber(_strJson,"Comp");
|
||||||
|
int nFlag = json.GetNumber(_strJson,"InsDel");
|
||||||
|
int nLength = json.Get(_strJson,"String").toInt();
|
||||||
|
|
||||||
|
QVector <QStringList> copyData;
|
||||||
|
foreach(QStringList strList , m_data[nSelect])
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
int nCurrentLength = strList.at(nCatalog).trimmed().length();
|
||||||
|
switch(nComp)
|
||||||
|
{
|
||||||
|
case E_LENGTH_COMP_GREATER:
|
||||||
|
if (nCurrentLength > nLength)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
case E_LENGTH_COMP_LESS:
|
||||||
|
if (nCurrentLength < nLength)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
case E_LENGTH_COMP_EQUAL:
|
||||||
|
if (nCurrentLength == nLength)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nFlag == 1) bFlag = !bFlag;
|
||||||
|
if (bFlag)
|
||||||
|
copyData.push_back(strList);
|
||||||
|
}
|
||||||
|
m_data[nSelect].clear();
|
||||||
|
m_data[nSelect] = copyData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SBatchRun::FilterCounter(QString _strJson)
|
||||||
|
{
|
||||||
|
SJson json;
|
||||||
|
int nSelect = json.Get(_strJson,"Article").toInt() - 1;
|
||||||
|
if (nSelect < 0) return;
|
||||||
|
m_bDataFlag[nSelect] = true;
|
||||||
|
|
||||||
|
int nCatalog = json.GetNumber(_strJson,"Category");
|
||||||
|
int nComp = json.GetNumber(_strJson,"Comp");
|
||||||
|
int nFlag = json.GetNumber(_strJson,"InsDel");
|
||||||
|
int nCounter = json.Get(_strJson,"String").toInt();
|
||||||
|
|
||||||
|
QMap <QString, int> mapData, mapDataresult;
|
||||||
|
foreach(QStringList strList , m_data[nSelect])
|
||||||
|
{
|
||||||
|
QString str = strList.at(nCatalog).trimmed();
|
||||||
|
if(mapData.contains(str))
|
||||||
|
mapData[str]++;
|
||||||
|
else
|
||||||
|
mapData.insert(str, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(QMap <QString, int>::iterator iterPos = mapData.begin(); iterPos != mapData.end(); iterPos++)
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
switch(nComp)
|
||||||
|
{
|
||||||
|
case E_LENGTH_COMP_GREATER:
|
||||||
|
if (iterPos.value() > nCounter)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
case E_LENGTH_COMP_LESS:
|
||||||
|
if (iterPos.value() < nCounter)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
case E_LENGTH_COMP_EQUAL:
|
||||||
|
if (iterPos.value() == nCounter)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nFlag == 1) bFlag = !bFlag;
|
||||||
|
if (bFlag)
|
||||||
|
mapDataresult.insert(iterPos.key(), iterPos.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
mapData.clear();
|
||||||
|
|
||||||
|
QVector <QStringList> copyData;
|
||||||
|
foreach(QStringList strList , m_data[nSelect])
|
||||||
|
{
|
||||||
|
QString str = strList.at(nCatalog).trimmed();
|
||||||
|
if(mapDataresult.contains(str))
|
||||||
|
copyData.push_back(strList);
|
||||||
|
}
|
||||||
|
m_data[nSelect].clear();
|
||||||
|
m_data[nSelect] = copyData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBatchRun::FilterReplace(QString _strJson)
|
||||||
|
{
|
||||||
|
SJson json;
|
||||||
|
int nSelect = json.Get(_strJson,"Article").toInt() - 1;
|
||||||
|
if (nSelect < 0) return;
|
||||||
|
m_bDataFlag[nSelect] = true;
|
||||||
|
|
||||||
|
int nCatalog = json.GetNumber(_strJson,"Category");
|
||||||
|
QString strFind = json.Get(_strJson,"String_Find");
|
||||||
|
QString strReplace = json.Get(_strJson,"String_Replace");
|
||||||
|
|
||||||
|
bool bFlag = false;
|
||||||
|
QStringList strListKeyword;
|
||||||
|
if (json.GetNumber(_strJson,"Find") == E_REPLACE_SPACE)
|
||||||
|
{
|
||||||
|
bFlag = true;
|
||||||
|
strListKeyword = strFind.split(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0 ; i < m_data[nSelect].size(); i++)
|
||||||
|
{
|
||||||
|
if (bFlag)
|
||||||
|
{
|
||||||
|
foreach(QString str,strListKeyword)
|
||||||
|
{
|
||||||
|
m_data[nSelect][i][nCatalog] = m_data[nSelect][i][nCatalog].replace(str,strReplace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_data[nSelect][i][nCatalog] = m_data[nSelect][i][nCatalog].replace(strFind,strReplace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBatchRun::FilterSerach(QString _strJson)
|
||||||
|
{
|
||||||
|
SJson json;
|
||||||
|
int nSelect = json.Get(_strJson,"Article").toInt() - 1;
|
||||||
|
if (nSelect < 0) return;
|
||||||
|
m_bDataFlag[nSelect] = true;
|
||||||
|
{
|
||||||
|
SKeyword stKeyword;
|
||||||
|
stKeyword.m_nCatalog = json.GetNumber(_strJson,"Category");
|
||||||
|
stKeyword.m_nKeyword = json.GetNumber(_strJson,"Keyword");
|
||||||
|
stKeyword.m_strListKeyword = json.Get(_strJson,"String").split(" ");
|
||||||
|
if (json.GetNumber(_strJson,"Method") == 1)
|
||||||
|
{
|
||||||
|
for (int i = 0 ; i < stKeyword.m_strListKeyword.size(); i++ )
|
||||||
|
stKeyword.m_strListKeyword[i] = " " + stKeyword.m_strListKeyword[i] + " ";
|
||||||
|
}
|
||||||
|
m_vecKeyword.push_back(stKeyword);
|
||||||
|
}
|
||||||
|
if (json.GetBool(_strJson,"Last")) //
|
||||||
|
{
|
||||||
|
QVector <QStringList> copyData;
|
||||||
|
|
||||||
|
foreach(QStringList strList , m_data[nSelect])
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
foreach(SKeyword stKeyword,m_vecKeyword)
|
||||||
|
{
|
||||||
|
QString strData = strList.at(stKeyword.m_nCatalog);
|
||||||
|
switch(stKeyword.m_nKeyword)
|
||||||
|
{
|
||||||
|
case E_SEARCH_KEYWORD_OR:
|
||||||
|
{
|
||||||
|
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||||
|
if (strData.contains(strKey)){bFlag = true;break;}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case E_SEARCH_KEYWORD_AND:
|
||||||
|
{
|
||||||
|
int nKeyCount = 0;
|
||||||
|
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||||
|
if (strData.contains(strKey)) nKeyCount++;
|
||||||
|
if (nKeyCount == stKeyword.m_strListKeyword.size())
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case E_SEARCH_KEYWORD_CELL_DELETE_OR:
|
||||||
|
{
|
||||||
|
bFlag = true;
|
||||||
|
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||||
|
if (strData.contains(strKey)){bFlag = false;break;}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case E_SEARCH_KEYWORD_CELL_DELETE_AND:
|
||||||
|
{
|
||||||
|
bFlag = true;
|
||||||
|
int nCount = 0;
|
||||||
|
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||||
|
if (strData.contains(strKey)){nCount++;}
|
||||||
|
if (nCount == stKeyword.m_strListKeyword.size())
|
||||||
|
bFlag = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bFlag) copyData.push_back(strList);
|
||||||
|
}
|
||||||
|
m_data[nSelect].clear();
|
||||||
|
m_data[nSelect] = copyData;
|
||||||
|
m_vecKeyword.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
117
MorphereAnalyzer/sbatchrun.h
Normal file
117
MorphereAnalyzer/sbatchrun.h
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
#ifndef SBATCHRUN
|
||||||
|
#define SBATCHRUN
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include "scolumn.h"
|
||||||
|
#include "./../common.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
class QGroupBox;
|
||||||
|
class QListWidget;
|
||||||
|
class QLineEdit;
|
||||||
|
class QDateEdit;
|
||||||
|
class QVBoxLayout;
|
||||||
|
|
||||||
|
class SBatchRun : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum E_COLUMN
|
||||||
|
{
|
||||||
|
E_COLUMN_DATABASE=0,
|
||||||
|
E_COLUMN_NAME,
|
||||||
|
E_COLUMN_DATE,
|
||||||
|
E_COLUMN_COUNT,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum E_ARTICLE
|
||||||
|
{
|
||||||
|
E_ARTICLE_BODY = 0,
|
||||||
|
E_ARTICLE_REPLY,
|
||||||
|
E_ARTICLE_MAX,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum E_DATA
|
||||||
|
{
|
||||||
|
E_DATA_platform_title = 0,
|
||||||
|
E_DATA_article_form,
|
||||||
|
E_DATA_article_parent,
|
||||||
|
E_DATA_article_id,
|
||||||
|
E_DATA_article_nickname,
|
||||||
|
E_DATA_article_title,
|
||||||
|
E_DATA_article_data,
|
||||||
|
E_DATA_article_url,
|
||||||
|
E_DATA_article_hit,
|
||||||
|
E_DATA_article_date,
|
||||||
|
E_DATA_article_order,
|
||||||
|
E_DATA_platform_id,
|
||||||
|
E_DATA_platform_name,
|
||||||
|
E_DATA_platform_form,
|
||||||
|
E_DATA_reply_url,
|
||||||
|
E_DATA_keyword_id,
|
||||||
|
E_DATA_article_profileurl,
|
||||||
|
E_DATA_article_profile,
|
||||||
|
E_DATA_etc,
|
||||||
|
E_DATA_MAX,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void clickedFromTo(bool clicked);
|
||||||
|
void clickedCutDays(bool clicked);
|
||||||
|
void run();
|
||||||
|
void Refresh();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setMainWidgets();
|
||||||
|
QVBoxLayout* setLoadWidgets();
|
||||||
|
QVBoxLayout* setDaysWidgets();
|
||||||
|
QVBoxLayout* setFilterWidgets();
|
||||||
|
QGroupBox* setCutDaysWidgets();
|
||||||
|
QGroupBox* setFromToWidgets();
|
||||||
|
void RefreshFilter(int nGroupID);
|
||||||
|
void ViewResult();
|
||||||
|
void ViewRawResult();
|
||||||
|
bool execFilter();
|
||||||
|
bool loadData();
|
||||||
|
void clearData();
|
||||||
|
void Message(QString strMessage);
|
||||||
|
|
||||||
|
// functions from FilterProcess
|
||||||
|
bool ReloadColumn();
|
||||||
|
void DataFilter();
|
||||||
|
void FilterDate(QString strJson);
|
||||||
|
void FilterSerach(QString strJson);
|
||||||
|
void FilterLength(QString strJson);
|
||||||
|
void FilterReplace(QString strJson);
|
||||||
|
void FilterCounter(QString _strJson);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
SBatchRun();
|
||||||
|
~SBatchRun();
|
||||||
|
void showBatchRun(int nGroupID);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<QStringList> m_vecData[E_ARTICLE_MAX];
|
||||||
|
QVector<QStringList> m_data[E_ARTICLE_MAX];
|
||||||
|
QListWidget *m_plwData, *m_plwFilter;
|
||||||
|
QGroupBox *m_pgbCutDays, *m_pgbFromTo;
|
||||||
|
QLineEdit *m_pleCutDays, *m_pleFilter;
|
||||||
|
QDateEdit *m_pdeFrom, *m_pdeTo;
|
||||||
|
|
||||||
|
QVector <SKeyword> m_vecKeyword;
|
||||||
|
|
||||||
|
//variables from FilterProcess
|
||||||
|
QStringList m_listDataBaseColumn;
|
||||||
|
int m_nUrlColumn, m_nDateColumn, m_nOrderColumn;
|
||||||
|
int m_anData[E_DATA_MAX];
|
||||||
|
bool m_bDataFlag[E_DATA_MAX];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // SBATCHRUN
|
||||||
|
|
||||||
57
MorphereAnalyzer/scolumn.cpp
Normal file
57
MorphereAnalyzer/scolumn.cpp
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#include "scolumn.h"
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
SColumn::SColumn() : m_bUse(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SColumn::~SColumn()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int SColumn::getColumnIndex(QString _str)
|
||||||
|
{
|
||||||
|
int nIndex = 0;
|
||||||
|
foreach(QStringList strList,m_vecColumn)
|
||||||
|
{
|
||||||
|
if (strList.at(E_DATABASE).trimmed() == _str.trimmed())
|
||||||
|
return nIndex;
|
||||||
|
if (strList.at(E_NAME).trimmed() == _str.trimmed())
|
||||||
|
return nIndex;
|
||||||
|
nIndex++;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SColumn::reload()
|
||||||
|
{
|
||||||
|
m_bUse = false;
|
||||||
|
m_vecColumn.clear();
|
||||||
|
QFile file("column.txt");
|
||||||
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text) == false) return m_bUse;
|
||||||
|
{
|
||||||
|
while (!file.atEnd())
|
||||||
|
{
|
||||||
|
QString str = QString(file.readLine());
|
||||||
|
if (str.at(0) == QChar('#')) continue;
|
||||||
|
if (str.trimmed().isEmpty()) continue;
|
||||||
|
m_vecColumn.push_back(str.split(","));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_vecColumn.size() <= 0) return m_bUse;
|
||||||
|
|
||||||
|
m_nDateColumn = -1;
|
||||||
|
foreach(QStringList strList,m_vecColumn)
|
||||||
|
{
|
||||||
|
if (strList.at(E_DATE).trimmed() == QString("o"))
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
m_nDateColumn++;
|
||||||
|
}
|
||||||
|
m_nDateColumn++;
|
||||||
|
m_bUse = true;
|
||||||
|
return m_bUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
32
MorphereAnalyzer/scolumn.h
Normal file
32
MorphereAnalyzer/scolumn.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef SCOLUMN_H
|
||||||
|
#define SCOLUMN_H
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
class SColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum E_COLUMN
|
||||||
|
{
|
||||||
|
E_DATABASE=0,
|
||||||
|
E_NAME,
|
||||||
|
E_DATE,
|
||||||
|
E_COUNT,
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
SColumn();
|
||||||
|
~SColumn();
|
||||||
|
bool reload();
|
||||||
|
bool isUse(){return m_bUse;}
|
||||||
|
bool isDateColumn(int _nColumn) {return (_nColumn == m_nDateColumn);}
|
||||||
|
QVector <QStringList> data() { return m_vecColumn; }
|
||||||
|
int getDateColumn() { return m_nDateColumn;}
|
||||||
|
int getColumnIndex(QString _str);
|
||||||
|
private:
|
||||||
|
QVector <QStringList> m_vecColumn;
|
||||||
|
bool m_bUse;
|
||||||
|
int m_nDateColumn;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCOLUMN_H
|
||||||
386
MorphereAnalyzer/scountdlg.cpp
Normal file
386
MorphereAnalyzer/scountdlg.cpp
Normal file
@@ -0,0 +1,386 @@
|
|||||||
|
#include "scountdlg.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
const int C_COMBO_MAX = 2;
|
||||||
|
|
||||||
|
SCountDlg::SCountDlg()
|
||||||
|
{
|
||||||
|
setWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
SCountDlg::~SCountDlg()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCountDlg::setWidgets()
|
||||||
|
{
|
||||||
|
setWindowTitle("Count");
|
||||||
|
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||||
|
{
|
||||||
|
QHBoxLayout *hlayout = new QHBoxLayout;
|
||||||
|
m_pCombo = new QComboBox[C_COMBO_MAX];
|
||||||
|
for (int i = 0; i < C_COMBO_MAX ; i++)
|
||||||
|
hlayout->addWidget(&m_pCombo[i]);
|
||||||
|
|
||||||
|
QPushButton *ppbRun = new QPushButton("Run");
|
||||||
|
connect(ppbRun, SIGNAL(released()),this, SLOT(run()));
|
||||||
|
hlayout->addWidget(ppbRun);
|
||||||
|
QPushButton *ppbGraph = new QPushButton("Graph");
|
||||||
|
connect(ppbGraph, SIGNAL(released()),this, SLOT(graph()));
|
||||||
|
hlayout->addWidget(ppbGraph);
|
||||||
|
QPushButton *ppbSave = new QPushButton("Save");
|
||||||
|
connect(ppbSave, SIGNAL(released()),this, SLOT(save()));
|
||||||
|
hlayout->addWidget(ppbSave);
|
||||||
|
|
||||||
|
vlayout->addLayout(hlayout);
|
||||||
|
}
|
||||||
|
m_pTable = new STable;
|
||||||
|
m_pTable->SetHeaderList(QStringList() << "Item" << "Count");
|
||||||
|
vlayout->addWidget(m_pTable);
|
||||||
|
|
||||||
|
setLayout(vlayout);
|
||||||
|
|
||||||
|
for (int i = 0; i < C_COMBO_MAX ; i++)
|
||||||
|
{
|
||||||
|
m_pCombo[i].clear();
|
||||||
|
foreach(QStringList strList,GetColumn().data())
|
||||||
|
m_pCombo[i].addItem(strList.at(SColumn::E_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < C_COMBO_MAX ; i++)
|
||||||
|
{
|
||||||
|
m_pCombo[i].addItem("[--------]");
|
||||||
|
m_pCombo[i].setCurrentIndex(GetColumn().data().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCountDlg::choose_1()
|
||||||
|
{
|
||||||
|
int nCatalog = D_NOT_SELECT;
|
||||||
|
for (int i = 0; i < C_COMBO_MAX ; i++)
|
||||||
|
{
|
||||||
|
if (m_pCombo[i].currentIndex() != GetColumn().data().size())
|
||||||
|
{
|
||||||
|
nCatalog = m_pCombo[i].currentIndex();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nCatalog == D_NOT_SELECT) return;
|
||||||
|
m_pTable->SetHeaderList(QStringList() << GetColumn().data().at(nCatalog).at(SColumn::E_NAME) << "Count");
|
||||||
|
QTableWidget *pCurrent = (QTableWidget *)GetMainWindow()->m_pDataDlg->GetCurrentWidget();
|
||||||
|
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount());
|
||||||
|
if (GetColumn().isDateColumn(nCatalog))
|
||||||
|
{
|
||||||
|
QMap <QDate,int> mapCount;
|
||||||
|
QDate dateStart(2055,12,31),dateEnd(1900,1,1);
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||||
|
{
|
||||||
|
//if(pCurrent->item(nCount,nCatalog)->text().trimmed().isEmpty()) continue;
|
||||||
|
QDateTime date;
|
||||||
|
QDate day = date.fromString(pCurrent->item(nCount,nCatalog)->text().trimmed(),"yyyy-MM-dd hh:mm:ss").date();
|
||||||
|
if (day.year() < 1901) continue;
|
||||||
|
if (day < dateStart) dateStart=day;
|
||||||
|
if (day > dateEnd) dateEnd=day;
|
||||||
|
if (mapCount.contains(day))
|
||||||
|
mapCount[day]++;
|
||||||
|
else
|
||||||
|
mapCount.insert(day,1);
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
int nCount = 0;
|
||||||
|
m_pTable->setRowCount(dateStart.daysTo(dateEnd));
|
||||||
|
for (QDate now = dateStart; now < dateEnd ; now=now.addDays(1) )
|
||||||
|
{
|
||||||
|
int nCol = 0;
|
||||||
|
QString str = now.toString("yyyy-MM-dd").trimmed();
|
||||||
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(str));
|
||||||
|
if (mapCount.contains(now))
|
||||||
|
m_pTable->setItem(nCount,nCol,new STableNumberItem(QString::number(mapCount[now])));
|
||||||
|
else
|
||||||
|
m_pTable->setItem(nCount,nCol,new STableNumberItem(QString::number(0)));
|
||||||
|
nCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMap <QString,int> mapCount;
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount() ; nCount++ )
|
||||||
|
{
|
||||||
|
QString str = pCurrent->item(nCount,nCatalog)->text().trimmed();
|
||||||
|
if(str.isEmpty()) continue;
|
||||||
|
if (mapCount.contains(str))
|
||||||
|
mapCount[str]++;
|
||||||
|
else
|
||||||
|
mapCount.insert(str,1);
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
m_pTable->setRowCount(mapCount.size());
|
||||||
|
int nCount = 0;
|
||||||
|
for (QMap<QString,int> ::iterator i = mapCount.begin(); i != mapCount.end(); ++i)
|
||||||
|
{
|
||||||
|
int nCol = 0;
|
||||||
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(i.key()));
|
||||||
|
m_pTable->setItem(nCount,nCol++,new STableNumberItem(QString::number(i.value())));
|
||||||
|
nCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCountDlg::choose_2()
|
||||||
|
{
|
||||||
|
QTableWidget *pCurrent = (QTableWidget *)GetMainWindow()->m_pDataDlg->GetCurrentWidget();
|
||||||
|
int anCatalog[C_COMBO_MAX];
|
||||||
|
|
||||||
|
for (int i = 0; i < C_COMBO_MAX ; i++)
|
||||||
|
anCatalog[i] = m_pCombo[i].currentIndex();
|
||||||
|
|
||||||
|
QMap <QString,QMap<QString,int> > mapCount;
|
||||||
|
QSet <QString> setList;
|
||||||
|
QDate dateStart(2055,12,31),dateEnd(1900,1,1);
|
||||||
|
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount());
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||||
|
{
|
||||||
|
QString astr[C_COMBO_MAX];
|
||||||
|
bool bFlag=true;
|
||||||
|
for (int i = 0; i < C_COMBO_MAX ; i++)
|
||||||
|
{
|
||||||
|
if (GetColumn().isDateColumn(anCatalog[i]))
|
||||||
|
{
|
||||||
|
QDateTime date;
|
||||||
|
QDate day = date.fromString(pCurrent->item(nCount,anCatalog[i])->text().trimmed(),"yyyy-MM-dd hh:mm:ss").date();
|
||||||
|
astr[i] = day.toString("yyyy-MM-dd").trimmed();
|
||||||
|
if(astr[i].isEmpty()) continue;
|
||||||
|
if (day.year() == 0) continue;
|
||||||
|
if (day < dateStart) dateStart=day;
|
||||||
|
if (day > dateEnd) dateEnd=day;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
astr[i] = pCurrent->item(nCount,anCatalog[i])->text().trimmed();
|
||||||
|
if (astr[i].isEmpty()) bFlag = false;
|
||||||
|
}
|
||||||
|
if (bFlag == false) continue;
|
||||||
|
if (mapCount.contains(astr[0]) == false)
|
||||||
|
{
|
||||||
|
QMap <QString,int> mapSec;
|
||||||
|
mapCount.insert(astr[0],mapSec);
|
||||||
|
}
|
||||||
|
if (mapCount[astr[0]].contains(astr[1]) == false)
|
||||||
|
mapCount[astr[0]].insert(astr[1],0);
|
||||||
|
if (setList.contains(astr[1]) == false)
|
||||||
|
setList.insert(astr[1]);
|
||||||
|
mapCount[astr[0]][astr[1]]++;
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
m_pTable->clear();
|
||||||
|
QStringList strList;
|
||||||
|
strList.push_back(m_pCombo[0].currentText());
|
||||||
|
for (QSet<QString>::iterator i = setList.begin(); i != setList.end(); ++i)
|
||||||
|
strList.push_back(*i);
|
||||||
|
m_pTable->SetHeaderList(strList);
|
||||||
|
int nCount = 0;
|
||||||
|
m_dTotal = 0.0;
|
||||||
|
if (GetColumn().isDateColumn(anCatalog[0]))
|
||||||
|
{
|
||||||
|
//qDebug() << dateStart.daysTo(dateEnd);
|
||||||
|
m_pTable->setRowCount(dateStart.daysTo(dateEnd));
|
||||||
|
for (QDate now = dateStart; now < dateEnd ; now=now.addDays(1) )
|
||||||
|
{
|
||||||
|
int nCol = 0;
|
||||||
|
QString str = now.toString("yyyy-MM-dd").trimmed();
|
||||||
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(str));
|
||||||
|
if (mapCount.contains(str))
|
||||||
|
{
|
||||||
|
for (QSet<QString>::iterator j = setList.begin(); j != setList.end(); ++j)
|
||||||
|
{
|
||||||
|
if (mapCount[str].contains(*j))
|
||||||
|
m_pTable->setItem(nCount,nCol++,new STableNumberItem(QString::number(mapCount[str].value(*j))));
|
||||||
|
else
|
||||||
|
m_pTable->setItem(nCount,nCol++,new STableNumberItem(QString::number(0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (;nCol < strList.size();nCol++)
|
||||||
|
m_pTable->setItem(nCount,nCol,new STableNumberItem(QString::number(0)));
|
||||||
|
}
|
||||||
|
nCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pTable->setRowCount(mapCount.size());
|
||||||
|
for (QMap<QString,QMap<QString,int> >::iterator i = mapCount.begin(); i != mapCount.end(); ++i)
|
||||||
|
{
|
||||||
|
int nCol = 0;
|
||||||
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(i.key()));
|
||||||
|
for (QSet<QString>::iterator j = setList.begin(); j != setList.end(); ++j)
|
||||||
|
{
|
||||||
|
if (i->contains(*j))
|
||||||
|
m_pTable->setItem(nCount,nCol++,new STableNumberItem(QString::number(i->value(*j))));
|
||||||
|
else
|
||||||
|
m_pTable->setItem(nCount,nCol++,new STableNumberItem(QString::number(0)));
|
||||||
|
}
|
||||||
|
nCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_strGraph = "<html>\r\n<meta charset=\"utf8\">\r\n<style>\r\nbody {\r\n font: 10px sans-serif;\r\n}\r\n\r\n.axis path,\r\n.axis line {\r\n fill: none;"
|
||||||
|
"\r\n stroke: #000;\r\n shape-rendering: crispEdges;\r\n}\r\n\r\n.x.axis path {\r\n display: none;\r\n}\r\n\r\n.line {\r\n fill: none;\r\n stroke: steelblue;"
|
||||||
|
"\r\n stroke-width: 1.5px;\r\n}\r\n\r\n</style>\r\n<body>\r\n<script src=\"http://d3js.org/d3.v3.min.js\"></script>\r\n<script>\r\n"
|
||||||
|
"\r\nvar margin = {top: 20, right: 80, bottom: 30, left: 50},\r\n width = 960 - margin.left - margin.right,\r\n height = 500 - margin.top - margin.bottom;"
|
||||||
|
"\r\n\r\nvar parseDate = d3.time.format(\"%Y-%m-%d\").parse;\r\n\r\nvar x = d3.time.scale()\r\n .range([0, width]);\r\n\r\nvar y = d3.scale.linear()\r\n .range([height, 0]);"
|
||||||
|
"\r\n\r\nvar color = d3.scale.category10();\r\n\r\nvar xAxis = d3.svg.axis()\r\n .scale(x)\r\n .orient(\"bottom\");\r\n\r\nvar yAxis = d3.svg.axis()\r\n .scale(y)"
|
||||||
|
"\r\n .orient(\"left\");"
|
||||||
|
"\r\n"
|
||||||
|
"\r\nvar line = d3.svg.line()"
|
||||||
|
"\r\n .interpolate(\"basis\")"
|
||||||
|
"\r\n .x(function(d) { return x(d.date); })"
|
||||||
|
"\r\n .y(function(d) { return y(d.temperature); });"
|
||||||
|
"\r\n"
|
||||||
|
"\r\nvar svg = d3.select(\"body\").append(\"svg\")"
|
||||||
|
"\r\n .attr(\"width\", width + margin.left + margin.right)"
|
||||||
|
"\r\n .attr(\"height\", height + margin.top + margin.bottom)"
|
||||||
|
"\r\n .append(\"g\")"
|
||||||
|
"\r\n .attr(\"transform\", \"translate(\" + margin.left + \",\" + margin.top + \")\");"
|
||||||
|
"\r\n"
|
||||||
|
"\r\nd3.tsv(\"file:///[!F*i!l*e!]\", function(error, data) {"
|
||||||
|
"\r\n if (error) throw error;"
|
||||||
|
"\r\n"
|
||||||
|
"\r\n color.domain(d3.keys(data[0]).filter(function(key) { return key !== \"date\"; }));"
|
||||||
|
"\r\n"
|
||||||
|
"\r\n data.forEach(function(d) {"
|
||||||
|
"\r\n d.date = parseDate(d.date);"
|
||||||
|
"\r\n });"
|
||||||
|
"\r\n"
|
||||||
|
"\r\n var cities = color.domain().map(function(name) {"
|
||||||
|
"\r\n return {"
|
||||||
|
"\r\n name: name,"
|
||||||
|
"\r\n values: data.map(function(d) {"
|
||||||
|
"\r\n return {date: d.date, temperature: +d[name]};"
|
||||||
|
"\r\n })"
|
||||||
|
"\r\n };"
|
||||||
|
"\r\n });"
|
||||||
|
"\r\n"
|
||||||
|
"\r\n x.domain(d3.extent(data, function(d) { return d.date; }));"
|
||||||
|
"\r\n"
|
||||||
|
"\r\n y.domain(["
|
||||||
|
"\r\n d3.min(cities, function(c) { return d3.min(c.values, function(v) { return v.temperature; }); }),"
|
||||||
|
"\r\n d3.max(cities, function(c) { return d3.max(c.values, function(v) { return v.temperature; }); })"
|
||||||
|
"\r\n ]);"
|
||||||
|
"\r\n"
|
||||||
|
"\r\n svg.append(\"g\")"
|
||||||
|
"\r\n .attr(\"class\", \"x axis\")"
|
||||||
|
"\r\n .attr(\"transform\", \"translate(0,\" + height + \")\")"
|
||||||
|
"\r\n .call(xAxis);"
|
||||||
|
"\r\n"
|
||||||
|
"\r\n svg.append(\"g\")"
|
||||||
|
"\r\n .attr(\"class\", \"y axis\")"
|
||||||
|
"\r\n .call(yAxis)"
|
||||||
|
"\r\n .append(\"text\")"
|
||||||
|
"\r\n .attr(\"transform\", \"rotate(-90)\")"
|
||||||
|
"\r\n .attr(\"y\", 6)"
|
||||||
|
"\r\n .attr(\"dy\", \".71em\")"
|
||||||
|
"\r\n .style(\"text-anchor\", \"end\")"
|
||||||
|
"\r\n .text(\"Count\");"
|
||||||
|
"\r\n"
|
||||||
|
"\r\n var city = svg.selectAll(\".city\")"
|
||||||
|
"\r\n .data(cities)"
|
||||||
|
"\r\n .enter().append(\"g\")"
|
||||||
|
"\r\n .attr(\"class\", \"city\");"
|
||||||
|
"\r\n"
|
||||||
|
"\r\n city.append(\"path\")"
|
||||||
|
"\r\n .attr(\"class\", \"line\")"
|
||||||
|
"\r\n .attr(\"d\", function(d) { return line(d.values); })"
|
||||||
|
"\r\n .style(\"stroke\", function(d) { return color(d.name); });"
|
||||||
|
"\r\n"
|
||||||
|
"\r\n city.append(\"text\")"
|
||||||
|
"\r\n .datum(function(d) { return {name: d.name, value: d.values[d.values.length - 1]}; })"
|
||||||
|
"\r\n .attr(\"transform\", function(d) { return \"translate(\" + x(d.value.date) + \",\" + y(d.value.temperature) + \")\"; })"
|
||||||
|
"\r\n .attr(\"x\", 3)"
|
||||||
|
"\r\n .attr(\"dy\", \".35em\")"
|
||||||
|
"\r\n .text(function(d) { return d.name; });"
|
||||||
|
"\r\n});"
|
||||||
|
"\r\n"
|
||||||
|
"\r\n</script>"
|
||||||
|
"\r\n";
|
||||||
|
QRegExp re("\\s{2,}");
|
||||||
|
m_strGraph = m_strGraph.replace(re,"");
|
||||||
|
m_strGraph = m_strGraph.replace("[!F*i!l*e!]",QApplication::applicationDirPath()+"/graph.tsv");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCountDlg::run()
|
||||||
|
{
|
||||||
|
int nNone=0;
|
||||||
|
for (int i = 0; i < C_COMBO_MAX ; i++)
|
||||||
|
{
|
||||||
|
if (m_pCombo[i].currentIndex() == GetColumn().data().size())
|
||||||
|
nNone++;
|
||||||
|
}
|
||||||
|
switch(nNone)
|
||||||
|
{
|
||||||
|
case 0:choose_2();break;
|
||||||
|
case 1:choose_1();break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCountDlg::graph()
|
||||||
|
{
|
||||||
|
QFile file(QApplication::applicationDirPath()+"/graph.tsv");
|
||||||
|
if (!file.open(QIODevice::WriteOnly)) return;
|
||||||
|
QTextStream out(&file);
|
||||||
|
out << QString("date\t").toUtf8();
|
||||||
|
for (int i = 1; i < m_pTable->columnCount();i++)
|
||||||
|
out << m_pTable->horizontalHeaderItem(i)->text().toUtf8() << QString("\t").toUtf8();
|
||||||
|
out << QString("\n").toUtf8();
|
||||||
|
GetMainWindow()->m_progress.setRange(0,m_pTable->rowCount());
|
||||||
|
for (int i = 0 ; i < m_pTable->rowCount() ; i++ )
|
||||||
|
{
|
||||||
|
for (int j = 0; j < m_pTable->columnCount();j++)
|
||||||
|
{
|
||||||
|
out << m_pTable->item(i,j)->text().trimmed().toUtf8() << QString("\t").toUtf8();
|
||||||
|
}
|
||||||
|
out << QString("\n").toUtf8();
|
||||||
|
GetMainWindow()->m_progress.setValue(i);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
GetMainWindow()->m_graph.setHtml(m_strGraph.toUtf8(),QUrl("file:///"));
|
||||||
|
GetMainWindow()->m_graph.settings()->setObjectCacheCapacities(0,0,0);
|
||||||
|
GetMainWindow()->m_graph.repaint();
|
||||||
|
GetMainWindow()->m_graph.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCountDlg::save()
|
||||||
|
{
|
||||||
|
QFile file(QFileDialog::getSaveFileName(this,tr("Save Csv"), "", tr("Csv Files (*.csv)")));
|
||||||
|
if (!file.open(QIODevice::WriteOnly)) return;
|
||||||
|
QTextStream out(&file);
|
||||||
|
for (int i = 0; i < m_pTable->columnCount();i++)
|
||||||
|
out << m_pTable->horizontalHeaderItem(i)->text().toUtf8() << QString(",").toUtf8();
|
||||||
|
out << QString("\r\n").toUtf8();
|
||||||
|
GetMainWindow()->m_progress.setRange(0,m_pTable->rowCount());
|
||||||
|
for (int i = 0 ; i < m_pTable->rowCount() ; i++ )
|
||||||
|
{
|
||||||
|
for (int j = 0; j < m_pTable->columnCount();j++)
|
||||||
|
{
|
||||||
|
out << m_pTable->item(i,j)->text().trimmed().toUtf8() << QString(",").toUtf8();
|
||||||
|
}
|
||||||
|
out << QString("\r\n").toUtf8();
|
||||||
|
GetMainWindow()->m_progress.setValue(i);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
29
MorphereAnalyzer/scountdlg.h
Normal file
29
MorphereAnalyzer/scountdlg.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#ifndef SCOUNTDLG_H
|
||||||
|
#define SCOUNTDLG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include "stable.h"
|
||||||
|
|
||||||
|
class SCountDlg : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SCountDlg();
|
||||||
|
~SCountDlg();
|
||||||
|
private slots:
|
||||||
|
void run();
|
||||||
|
void graph();
|
||||||
|
void save();
|
||||||
|
private:
|
||||||
|
QComboBox *m_pCombo;
|
||||||
|
STable *m_pTable;
|
||||||
|
QString m_strGraph;
|
||||||
|
double m_dTotal;
|
||||||
|
void setWidgets();
|
||||||
|
void choose_1();
|
||||||
|
void choose_2();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCOUNTDLG_H
|
||||||
483
MorphereAnalyzer/sdatadlg.cpp
Normal file
483
MorphereAnalyzer/sdatadlg.cpp
Normal file
@@ -0,0 +1,483 @@
|
|||||||
|
#include "sdatadlg.h"
|
||||||
|
#include "stable.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
#define D_NOT_SELECT -1
|
||||||
|
|
||||||
|
SDataDlg::SDataDlg()
|
||||||
|
{
|
||||||
|
setWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
SDataDlg::~SDataDlg()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::setWidgets()
|
||||||
|
{
|
||||||
|
setWindowTitle("Data");
|
||||||
|
m_ptab = new QTabWidget;
|
||||||
|
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||||
|
vlayout->addWidget(m_ptab);
|
||||||
|
setLayout(vlayout);
|
||||||
|
|
||||||
|
m_ptab->setTabsClosable(true);
|
||||||
|
connect(m_ptab,SIGNAL(tabCloseRequested(int)),this,SLOT(CloseTab(int)));
|
||||||
|
connect(m_ptab,SIGNAL(tabBarDoubleClicked(int)),this,SLOT(DoubleClickTab(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
QTableWidget *SDataDlg::AddTable(QString _str)
|
||||||
|
{
|
||||||
|
STable *pTable = new STable;
|
||||||
|
m_ptab->addTab(pTable,_str);
|
||||||
|
return (QTableWidget *)pTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::CloseTab(int index)
|
||||||
|
{
|
||||||
|
((STable*)(m_ptab->widget(index)))->clear();
|
||||||
|
m_ptab->removeTab(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::DoubleClickTab(int index)
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
if (index < 0) return;
|
||||||
|
QString text = QInputDialog::getText(this,"Tab name change","Name : ", QLineEdit::Normal,m_ptab->tabText(index), &ok);
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
m_ptab->setTabText(index,text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::DataReload(QString _strTableName,int _nSelect)
|
||||||
|
{
|
||||||
|
QString strSelect;
|
||||||
|
strSelect = "select ";
|
||||||
|
QVector <QStringList> column = GetColumn().data();
|
||||||
|
foreach(QStringList strlist,column)
|
||||||
|
strSelect += "CONVERT(" + strlist.at(SColumn::E_DATABASE) + " USING utf8),";
|
||||||
|
strSelect = strSelect.left(strSelect.size()-1);
|
||||||
|
strSelect += " from ";
|
||||||
|
strSelect += _strTableName;
|
||||||
|
|
||||||
|
if (_nSelect == STable::E_ARTICLE_BODY)
|
||||||
|
strSelect += " WHERE article_form = 'body'";
|
||||||
|
if (_nSelect == STable::E_ARTICLE_REPLY)
|
||||||
|
strSelect += " WHERE article_form = 'reply'";
|
||||||
|
|
||||||
|
QSqlQuery query(strSelect);
|
||||||
|
STable *pTable = (STable *)m_ptab->currentWidget();
|
||||||
|
if (pTable == NULL)
|
||||||
|
pTable = (STable*)AddTable("<first>");
|
||||||
|
pTable->setArticleSelect(_nSelect);
|
||||||
|
pTable->clear();
|
||||||
|
pTable->SetHeaderList(&column,SColumn::E_NAME);
|
||||||
|
pTable->setRowCount(query.size());
|
||||||
|
GetMainWindow()->m_progress.setRange(0,query.size());
|
||||||
|
int nCount = 0;
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
for (int i = 0; i < pTable->columnCount() ; i++)
|
||||||
|
{
|
||||||
|
QString str = query.value(i).toString().replace("\n"," ");
|
||||||
|
if((i == GetColumn().getColumnIndex("platform_form")) && (str.trimmed() == "post" || str.trimmed() == "channel" || str.trimmed() == "story"))
|
||||||
|
str = "sns";
|
||||||
|
if((i == GetColumn().getColumnIndex("platform_form")) && (str.trimmed() == "group"))
|
||||||
|
str = "community";
|
||||||
|
pTable->setItem(nCount,i,new QTableWidgetItem(" "+str.replace("\t"," ")+" "));
|
||||||
|
}
|
||||||
|
nCount++;
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::InsertCopyRow(int _nRow,QTableWidget *_pCurrent,QTableWidget *_pNew)
|
||||||
|
{
|
||||||
|
_pNew->setRowCount(_pNew->rowCount()+1);
|
||||||
|
for (int nCount = 0;nCount < _pCurrent->columnCount() ;nCount++ )
|
||||||
|
_pNew->setItem(_pNew->rowCount()-1,nCount,new QTableWidgetItem(*_pCurrent->item(_nRow,nCount)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::SearchDate(QDate _dtStart,QDate _dtEnd)
|
||||||
|
{
|
||||||
|
STable *pCurrent = (STable *)m_ptab->currentWidget();
|
||||||
|
if (pCurrent == NULL) return;
|
||||||
|
STable *pNew = new STable;
|
||||||
|
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
||||||
|
QVector <QStringList> column = GetColumn().data();
|
||||||
|
pNew->SetHeaderList(&column,SColumn::E_NAME);
|
||||||
|
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||||
|
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
QString strTime = pCurrent->item(nCount,GetColumn().getDateColumn())->text().trimmed();
|
||||||
|
if (strTime.size() >= 10)
|
||||||
|
{
|
||||||
|
QChar ch = strTime.at(4);
|
||||||
|
QString strFormat = QString("yyyy")+ch+QString("MM")+ch+QString("dd");
|
||||||
|
QDate date = QDate::fromString(strTime.left(10),strFormat);
|
||||||
|
if (_dtStart <= date && _dtEnd >= date)
|
||||||
|
bFlag = true;
|
||||||
|
}
|
||||||
|
if (bFlag)
|
||||||
|
InsertCopyRow(nCount,pCurrent,pNew);
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
m_ptab->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
||||||
|
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::SearchCounter(int _nCatalogIndex,int _nCompIndex,int _nInsDelIndex,int _nCounter)
|
||||||
|
{
|
||||||
|
STable *pCurrent = (STable *)m_ptab->currentWidget();
|
||||||
|
if (pCurrent == NULL) return;
|
||||||
|
QMap<QString, int> mapData,mapDataResult;
|
||||||
|
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||||
|
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
if (_nCatalogIndex == GetColumn().getDateColumn())
|
||||||
|
str = QDateTime::fromString(pCurrent->item(nCount,_nCatalogIndex)->text().trimmed(),"yyyy-MM-dd hh:mm:ss").date().toString("yyyy-MM-dd");
|
||||||
|
else
|
||||||
|
str = pCurrent->item(nCount,_nCatalogIndex)->text().trimmed();
|
||||||
|
|
||||||
|
if (str.isEmpty() == false)
|
||||||
|
{
|
||||||
|
if(mapData.contains(str))
|
||||||
|
mapData[str]++;
|
||||||
|
else
|
||||||
|
mapData.insert(str,1);
|
||||||
|
}
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(QMap <QString, int>::iterator iterPos = mapData.begin(); iterPos != mapData.end(); iterPos++)
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
switch(_nCompIndex)
|
||||||
|
{
|
||||||
|
case E_LENGTH_COMP_GREATER:
|
||||||
|
if (iterPos.value() > _nCounter)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
case E_LENGTH_COMP_LESS:
|
||||||
|
if (iterPos.value() < _nCounter)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
case E_LENGTH_COMP_EQUAL:
|
||||||
|
if (iterPos.value() == _nCounter)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (bFlag)
|
||||||
|
mapDataResult.insert(iterPos.key(), iterPos.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
STable *pNew = new STable;
|
||||||
|
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
||||||
|
QVector <QStringList> column = GetColumn().data();
|
||||||
|
pNew->SetHeaderList(&column,SColumn::E_NAME);
|
||||||
|
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||||
|
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
QString strCurrent = pCurrent->item(nCount,_nCatalogIndex)->text().trimmed();
|
||||||
|
if(mapDataResult.contains(strCurrent))
|
||||||
|
bFlag = true;
|
||||||
|
if (_nInsDelIndex == 1) bFlag = !bFlag;
|
||||||
|
if (bFlag) InsertCopyRow(nCount,pCurrent,pNew);
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
m_ptab->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
||||||
|
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::SearchLength(int _nCatalogIndex,int _nCompIndex,int _nInsDelIndex,int _nLength)
|
||||||
|
{
|
||||||
|
STable *pCurrent = (STable *)m_ptab->currentWidget();
|
||||||
|
if (pCurrent == NULL) return;
|
||||||
|
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||||
|
STable *pNew = new STable;
|
||||||
|
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
||||||
|
QVector <QStringList> column = GetColumn().data();
|
||||||
|
pNew->SetHeaderList(&column,SColumn::E_NAME);
|
||||||
|
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||||
|
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
int nCurrentLength = pCurrent->item(nCount,_nCatalogIndex)->text().trimmed().length();
|
||||||
|
switch(_nCompIndex)
|
||||||
|
{
|
||||||
|
case E_LENGTH_COMP_GREATER:
|
||||||
|
if (nCurrentLength > _nLength)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
case E_LENGTH_COMP_LESS:
|
||||||
|
if (nCurrentLength < _nLength)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
case E_LENGTH_COMP_EQUAL:
|
||||||
|
if (nCurrentLength == _nLength)
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (_nInsDelIndex == 1) bFlag = !bFlag;
|
||||||
|
if (bFlag) InsertCopyRow(nCount,pCurrent,pNew);
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
m_ptab->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
||||||
|
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::SearchReplace(int _nCatalogIndex,int _nReplaceFindIndex,int _nReplaceIndex,QString _strFind,QString _strReplace)
|
||||||
|
{
|
||||||
|
STable *pCurrent = (STable *)m_ptab->currentWidget();
|
||||||
|
if (pCurrent == NULL) return;
|
||||||
|
STable *pNew = new STable;
|
||||||
|
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
||||||
|
QVector <QStringList> column = GetColumn().data();
|
||||||
|
pNew->SetHeaderList(&column,SColumn::E_NAME);
|
||||||
|
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||||
|
//int nCatalog = m_pcbReplaceCatalog->currentIndex();
|
||||||
|
QStringList strListKeyword;
|
||||||
|
if (_nReplaceFindIndex == E_REPLACE_SPACE)
|
||||||
|
strListKeyword = _strFind.split(" ");
|
||||||
|
else
|
||||||
|
strListKeyword.push_back(_strFind);
|
||||||
|
|
||||||
|
pNew->setRowCount(pCurrent->rowCount());
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||||
|
{
|
||||||
|
for (int nColumnCount = 0;nColumnCount < pCurrent->columnCount() ;nColumnCount++ )
|
||||||
|
{
|
||||||
|
if (_nCatalogIndex == nColumnCount)
|
||||||
|
{
|
||||||
|
QString strOut = pCurrent->item(nCount,nColumnCount)->text();
|
||||||
|
switch(_nReplaceIndex)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
foreach(QString str,strListKeyword)
|
||||||
|
strOut = strOut.replace(str,_strReplace);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
QString strMiddle;
|
||||||
|
foreach(QString strLine,strOut.split("\n"))
|
||||||
|
{
|
||||||
|
foreach(QString strWord,strLine.split(" "))
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
foreach(QString str,strListKeyword)
|
||||||
|
{
|
||||||
|
if (strWord == str)
|
||||||
|
{
|
||||||
|
strMiddle += _strReplace + " ";
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bFlag == false)
|
||||||
|
strMiddle += strWord + " ";
|
||||||
|
}
|
||||||
|
strMiddle += "\n";
|
||||||
|
}
|
||||||
|
strOut = strMiddle;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
QString strMiddle;
|
||||||
|
foreach(QString strLine,strOut.split("\n"))
|
||||||
|
{
|
||||||
|
foreach(QString strWord,strLine.split(" "))
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
foreach(QString str,strListKeyword)
|
||||||
|
{
|
||||||
|
if (strWord.contains(str))
|
||||||
|
{
|
||||||
|
strMiddle += _strReplace + " ";
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bFlag == false)
|
||||||
|
strMiddle += strWord + " ";
|
||||||
|
}
|
||||||
|
strMiddle += "\n";
|
||||||
|
}
|
||||||
|
strOut = strMiddle;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pNew->setItem(nCount,nColumnCount,new QTableWidgetItem(strOut));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pNew->setItem(nCount,nColumnCount,new QTableWidgetItem(*pCurrent->item(nCount,nColumnCount)));
|
||||||
|
}
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
//m_ptwData->addTab(pNew,m_ptwData->tabText(m_ptwData->currentIndex())+" r");
|
||||||
|
m_ptab->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
||||||
|
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int SDataDlg::GetCurrentArticle()
|
||||||
|
{
|
||||||
|
if (m_ptab->count() == 0) return E_ARTICLE_NONE;
|
||||||
|
return ((STable *)m_ptab->currentWidget())->getArticleSelect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::SearchKeyword(QVector <SKeyword> _vecKeyword)
|
||||||
|
{
|
||||||
|
STable *pCurrent = (STable *)m_ptab->currentWidget();
|
||||||
|
if (pCurrent == NULL) return;
|
||||||
|
STable *pNew = new STable;
|
||||||
|
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
||||||
|
QVector <QStringList> column = GetColumn().data();
|
||||||
|
pNew->SetHeaderList(&column,SColumn::E_NAME);
|
||||||
|
|
||||||
|
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||||
|
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
foreach(SKeyword stKeyword,_vecKeyword)
|
||||||
|
{
|
||||||
|
QString strData = pCurrent->item(nCount,stKeyword.m_nCatalog)->text();
|
||||||
|
switch(stKeyword.m_nKeyword)
|
||||||
|
{
|
||||||
|
case E_SEARCH_KEYWORD_OR:
|
||||||
|
{
|
||||||
|
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||||
|
if (strData.contains(strKey)){bFlag = true;break;}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case E_SEARCH_KEYWORD_AND:
|
||||||
|
{
|
||||||
|
int nKeyCount = 0;
|
||||||
|
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||||
|
if (strData.contains(strKey)) nKeyCount++;
|
||||||
|
if (nKeyCount == stKeyword.m_strListKeyword.size())
|
||||||
|
bFlag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case E_SEARCH_KEYWORD_CELL_DELETE_OR:
|
||||||
|
{
|
||||||
|
bFlag = true;
|
||||||
|
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||||
|
if (strData.contains(strKey)){bFlag = false;break;}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case E_SEARCH_KEYWORD_CELL_DELETE_AND:
|
||||||
|
{
|
||||||
|
bFlag = true;
|
||||||
|
int nCount = 0;
|
||||||
|
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||||
|
if (strData.contains(strKey)){nCount++;}
|
||||||
|
if (nCount == stKeyword.m_strListKeyword.size())
|
||||||
|
bFlag = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bFlag) InsertCopyRow(nCount,pCurrent,pNew);
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
m_ptab->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
||||||
|
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::Import(QVector <QByteArray> _vecImport )
|
||||||
|
{
|
||||||
|
STable *pNew = new STable;
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("eucKR");
|
||||||
|
GetMainWindow()->m_progress.setRange(0,_vecImport.size());
|
||||||
|
QVector <QStringList> column = GetColumn().data();
|
||||||
|
int ncRow = 0;
|
||||||
|
bool bFirst = true;
|
||||||
|
pNew->setRowCount(_vecImport.size());
|
||||||
|
foreach (QByteArray byte,_vecImport)
|
||||||
|
{
|
||||||
|
QString strLine = codec->toUnicode(byte);
|
||||||
|
if (bFirst)
|
||||||
|
{
|
||||||
|
QStringList strings = strLine.split(",");
|
||||||
|
if (strings.at(0) == QString("#Head#"))
|
||||||
|
{
|
||||||
|
pNew->setColumnCount(strings.size()-1);
|
||||||
|
for (int i = 1; i < strings.size();i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < column.size(); j++)
|
||||||
|
{
|
||||||
|
if(column.at(j).at(SColumn::E_DATABASE).compare(strings.at(i)) == 0)
|
||||||
|
strings[i] = column.at(j).at(SColumn::E_NAME);
|
||||||
|
}
|
||||||
|
pNew->setHorizontalHeaderItem(i-1,new QTableWidgetItem(strings.at(i)));
|
||||||
|
}
|
||||||
|
bFirst = false;
|
||||||
|
pNew->setRowCount(_vecImport.size()-1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pNew->setColumnCount(strings.size());
|
||||||
|
}
|
||||||
|
bFirst = false;
|
||||||
|
strLine = strLine.replace("\"","");
|
||||||
|
QStringList strings = strLine.split(",");
|
||||||
|
int ncCol=0;
|
||||||
|
foreach(QString str,strings)
|
||||||
|
pNew->setItem(ncRow,ncCol++,new QTableWidgetItem(QString(" " + str + " ")));
|
||||||
|
GetMainWindow()->m_progress.setValue(ncRow++);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
m_ptab->addTab(pNew,"import");
|
||||||
|
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDataDlg::Export(QString _strFilename)
|
||||||
|
{
|
||||||
|
QFile file(_strFilename);
|
||||||
|
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
||||||
|
QTextStream out(&file);
|
||||||
|
QTableWidget *pCurrent = (QTableWidget *)m_ptab->currentWidget();
|
||||||
|
out << "#Head#,";
|
||||||
|
QVector <QStringList> column = GetColumn().data();
|
||||||
|
foreach(QStringList strList,column)
|
||||||
|
out << strList.at(SColumn::E_DATABASE) << ",";
|
||||||
|
out << endl;
|
||||||
|
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||||
|
{
|
||||||
|
for (int nColumnCount = 0;nColumnCount < pCurrent->columnCount() ;nColumnCount++ )
|
||||||
|
{
|
||||||
|
QString str = pCurrent->item(nCount,nColumnCount)->text();
|
||||||
|
str = str.replace(",",".");
|
||||||
|
str = str.replace("\n","");
|
||||||
|
out << "\"" << str << "\"" << ",";
|
||||||
|
}
|
||||||
|
out << "\"\"" << endl;
|
||||||
|
GetMainWindow()->m_progress.setValue(nCount);
|
||||||
|
GetMainWindow()->m_progress.repaint();
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
40
MorphereAnalyzer/sdatadlg.h
Normal file
40
MorphereAnalyzer/sdatadlg.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#ifndef SDATADLG_H
|
||||||
|
#define SDATADLG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QTableWidget>
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
|
||||||
|
class SDataDlg : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SDataDlg();
|
||||||
|
~SDataDlg();
|
||||||
|
void setWidgets();
|
||||||
|
QTableWidget *AddTable(QString _str);
|
||||||
|
void DataReload(QString _strTableName,int _nSelect);
|
||||||
|
QTableWidget *GetCurrentWidget() { return (QTableWidget *)m_ptab->currentWidget();}
|
||||||
|
int GetCurrentArticle();
|
||||||
|
void InsertCopyRow(int _nRow,QTableWidget *_pCurrent,QTableWidget *_pNew);
|
||||||
|
|
||||||
|
void SearchDate(QDate _dtStart,QDate _dtEnd);
|
||||||
|
void SearchCounter(int _nCatalogIndex,int _nCompIndex,int _nInsDelIndex,int _nCounter);
|
||||||
|
void SearchLength(int _nCatalogIndex,int _nCompIndex,int _nInsDelIndex,int _nLength);
|
||||||
|
void SearchReplace(int _nCatalogIndex,int _nReplaceFindIndex,int _nReplaceIndex,QString _strFind,QString _strReplace);
|
||||||
|
void SearchKeyword(QVector <SKeyword> _vecKeyword);
|
||||||
|
void Import(QVector <QByteArray> _vecImport);
|
||||||
|
void Export(QString _strFilename);
|
||||||
|
QTabWidget* GetCurrentTab() { return m_ptab; }
|
||||||
|
|
||||||
|
//void SearchCounter(int _nCatalogIndex,int _nCompIndex,int _nInsDelIndex,QString _strCounter);
|
||||||
|
private:
|
||||||
|
QTabWidget *m_ptab;
|
||||||
|
private slots:
|
||||||
|
void DoubleClickTab(int index);
|
||||||
|
void CloseTab(int index);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SDATADLG_H
|
||||||
236
MorphereAnalyzer/sfilterdlg.cpp
Normal file
236
MorphereAnalyzer/sfilterdlg.cpp
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
#include "sfilterdlg.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QSqlQuery>
|
||||||
|
|
||||||
|
#include "./../common.h"
|
||||||
|
|
||||||
|
SFilterDlg::SFilterDlg()
|
||||||
|
{
|
||||||
|
setWindowTitle("Filter");
|
||||||
|
setWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
SFilterDlg::~SFilterDlg()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterDlg::setWidgets()
|
||||||
|
{
|
||||||
|
QHBoxLayout *hMainlayout = new QHBoxLayout();
|
||||||
|
{
|
||||||
|
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||||
|
m_plwFilterGroup = new QListWidget;
|
||||||
|
m_pleFilterGroup = new QLineEdit;
|
||||||
|
vlayout->addWidget(m_plwFilterGroup);
|
||||||
|
vlayout->addWidget(m_pleFilterGroup);
|
||||||
|
connect(m_plwFilterGroup,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(GroupItemChanged(QListWidgetItem *, QListWidgetItem *)));
|
||||||
|
{
|
||||||
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||||
|
QPushButton *pbInsert = new QPushButton("Insert");
|
||||||
|
connect(pbInsert, SIGNAL(released()),this, SLOT(Group_Insert()));
|
||||||
|
QPushButton *pbDelete = new QPushButton("Delete");
|
||||||
|
connect(pbDelete, SIGNAL(released()),this, SLOT(Group_Delete()));
|
||||||
|
QPushButton *pbModify = new QPushButton("Modfiy");
|
||||||
|
connect(pbModify, SIGNAL(released()),this, SLOT(Group_Modify()));
|
||||||
|
QPushButton *pbCopy_Paste = new QPushButton("Copy&Paste");
|
||||||
|
connect(pbCopy_Paste, SIGNAL(released()),this, SLOT(Group_CopyPaste()));
|
||||||
|
QPushButton *pbRefresh = new QPushButton("Refresh");
|
||||||
|
connect(pbRefresh, SIGNAL(released()),this, SLOT(Group_Refresh()));
|
||||||
|
QPushButton *pbRun = new QPushButton("Run");
|
||||||
|
connect(pbRun, SIGNAL(released()), this, SLOT(Group_Run()));
|
||||||
|
|
||||||
|
hlayout->addWidget(pbInsert);
|
||||||
|
hlayout->addWidget(pbDelete);
|
||||||
|
hlayout->addWidget(pbModify);
|
||||||
|
hlayout->addWidget(pbCopy_Paste);
|
||||||
|
hlayout->addWidget(pbRefresh);
|
||||||
|
hlayout->addWidget(pbRun);
|
||||||
|
vlayout->addLayout(hlayout);
|
||||||
|
}
|
||||||
|
hMainlayout->addLayout(vlayout,1);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||||
|
m_plwFilter = new QListWidget;
|
||||||
|
vlayout->addWidget(m_plwFilter);
|
||||||
|
connect(m_plwFilter,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(ItemChanged(QListWidgetItem*,QListWidgetItem*)));
|
||||||
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||||
|
QPushButton *pbUp = new QPushButton("Up");
|
||||||
|
QPushButton *pbDown = new QPushButton("Down");
|
||||||
|
QPushButton *pbDelete = new QPushButton("Delete");
|
||||||
|
hlayout->addWidget(pbUp);
|
||||||
|
hlayout->addWidget(pbDown);
|
||||||
|
hlayout->addWidget(pbDelete);
|
||||||
|
vlayout->addLayout(hlayout);
|
||||||
|
connect(pbUp, SIGNAL(released()),this, SLOT(Up()));
|
||||||
|
connect(pbDown, SIGNAL(released()),this, SLOT(Down()));
|
||||||
|
connect(pbDelete, SIGNAL(released()),this, SLOT(Delete()));
|
||||||
|
hMainlayout->addLayout(vlayout,3);
|
||||||
|
}
|
||||||
|
setLayout(hMainlayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterDlg::Group_Insert()
|
||||||
|
{
|
||||||
|
QSqlQuery query;
|
||||||
|
QString strQuery = QString("insert into filtergroup set "
|
||||||
|
"name = '" + m_pleFilterGroup->text() + "'");
|
||||||
|
query.exec(strQuery.toUtf8());
|
||||||
|
Group_Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterDlg::Group_Delete()
|
||||||
|
{
|
||||||
|
QSqlQuery query;
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||||
|
{
|
||||||
|
QString strQuery = QString("delete from filtergroup where id = " + item->data(Qt::UserRole).toString());
|
||||||
|
query.exec(strQuery.toUtf8());
|
||||||
|
strQuery = QString("delete from filter where filtergroup_id = " + item->data(Qt::UserRole).toString());
|
||||||
|
query.exec(strQuery.toUtf8());
|
||||||
|
RefreshFilter(item->data(Qt::UserRole).toInt());
|
||||||
|
}
|
||||||
|
Group_Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterDlg::Group_Modify()
|
||||||
|
{
|
||||||
|
QSqlQuery query;
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||||
|
{
|
||||||
|
QString strQuery = QString("update filtergroup set name = '" + m_pleFilterGroup->text() + "' where id = " + item->data(Qt::UserRole).toString());
|
||||||
|
query.exec(strQuery.toUtf8());
|
||||||
|
}
|
||||||
|
Group_Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterDlg::Group_CopyPaste()
|
||||||
|
{
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||||
|
{
|
||||||
|
QSqlQuery query;
|
||||||
|
QString strQuery = QString("insert into filtergroup set "
|
||||||
|
"name = '" + item->text() + "-'");
|
||||||
|
query.exec(strQuery.toUtf8());
|
||||||
|
query.exec("select max(id) from filtergroup");
|
||||||
|
if (query.next())
|
||||||
|
{
|
||||||
|
strQuery = QString("insert into filter (type,data,filtergroup_id) select type,data,");
|
||||||
|
strQuery += query.value(0).toString();
|
||||||
|
strQuery += " from filter where filtergroup_id = " + item->data(Qt::UserRole).toString();
|
||||||
|
query.exec(strQuery.toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Group_Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterDlg::Group_Refresh()
|
||||||
|
{
|
||||||
|
m_plwFilterGroup->clear();
|
||||||
|
QSqlQuery query("select id,name from filtergroup");
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
QListWidgetItem *pItem = new QListWidgetItem(query.value(1).toString(),m_plwFilterGroup);
|
||||||
|
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterDlg::RefreshFilter(int _nGroup)
|
||||||
|
{
|
||||||
|
if (_nGroup == D_NOT_SELECT) return;
|
||||||
|
QSqlQuery query("select id,type,data from filter where filtergroup_id = " + QString::number(_nGroup));
|
||||||
|
m_plwFilter->clear();
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
QString str = GetMainWindow()->m_pFilterObjectDlg->JsonToString(query.value(1).toInt(),query.value(2).toString());
|
||||||
|
QListWidgetItem *pItem = new QListWidgetItem(str, m_plwFilter);
|
||||||
|
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SFilterDlg::GroupItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev)
|
||||||
|
{
|
||||||
|
Q_UNUSED(_pPrev);
|
||||||
|
if (_pCurrent == 0) return;
|
||||||
|
RefreshFilter(_pCurrent->data(Qt::UserRole).toInt());
|
||||||
|
m_pleFilterGroup->setText(_pCurrent->text());
|
||||||
|
m_pleFilterGroup->repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterDlg::ItemChanged(QListWidgetItem*_pCurrent, QListWidgetItem *_pPrev)
|
||||||
|
{
|
||||||
|
Q_UNUSED(_pPrev);
|
||||||
|
if (_pCurrent == 0) return;
|
||||||
|
QSqlQuery query("select id,type,data from filter where id = " + _pCurrent->data(Qt::UserRole).toString());
|
||||||
|
if (!query.next()) return;
|
||||||
|
GetMainWindow()->m_pFilterObjectDlg->JsonToWidget(query.value(1).toInt(),query.value(2).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SFilterDlg::Up()
|
||||||
|
{
|
||||||
|
int nSelect = m_plwFilter->currentRow();
|
||||||
|
if (nSelect <= 0) return;
|
||||||
|
QString strID1 = m_plwFilter->item(nSelect)->data(Qt::UserRole).toString();
|
||||||
|
QString strID2 = m_plwFilter->item(nSelect-1)->data(Qt::UserRole).toString();
|
||||||
|
QString strQuery = "UPDATE filter t1 INNER JOIN filter t2 ON (t1.id, t2.id) IN ((" + strID1 + ","+ strID2 +"),("+ strID2 + "," + strID1 + ")) SET t1.type = t2.type,t1.filtergroup_id = t2.filtergroup_id,t1.data = t2.data";
|
||||||
|
QSqlQuery query;
|
||||||
|
query.exec(strQuery.toUtf8());
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||||
|
RefreshFilter(item->data(Qt::UserRole).toInt());
|
||||||
|
m_plwFilter->setCurrentRow(nSelect-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterDlg::Down()
|
||||||
|
{
|
||||||
|
int nSelect = m_plwFilter->currentRow();
|
||||||
|
if (nSelect < 0) return;
|
||||||
|
if (nSelect >= (m_plwFilter->count() - 1)) return;
|
||||||
|
QString strID1 = m_plwFilter->item(nSelect)->data(Qt::UserRole).toString();
|
||||||
|
QString strID2 = m_plwFilter->item(nSelect+1)->data(Qt::UserRole).toString();
|
||||||
|
QString strQuery = "UPDATE filter t1 INNER JOIN filter t2 ON (t1.id, t2.id) IN ((" + strID1 + ","+ strID2 +"),("+ strID2 + "," + strID1 + ")) SET t1.type = t2.type,t1.filtergroup_id = t2.filtergroup_id,t1.data = t2.data";
|
||||||
|
QSqlQuery query;
|
||||||
|
query.exec(strQuery.toUtf8());
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||||
|
RefreshFilter(item->data(Qt::UserRole).toInt());
|
||||||
|
m_plwFilter->setCurrentRow(nSelect+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterDlg::Delete()
|
||||||
|
{
|
||||||
|
QSqlQuery query;
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilter->selectedItems())
|
||||||
|
{
|
||||||
|
QString strQuery = QString("delete from filter where id = '" + item->data(Qt::UserRole).toString() + "'");
|
||||||
|
query.exec(strQuery.toUtf8());
|
||||||
|
}
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||||
|
RefreshFilter(item->data(Qt::UserRole).toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
int SFilterDlg::GetSelectGroupID()
|
||||||
|
{
|
||||||
|
int nCurrentFilterGroupID = D_NOT_SELECT;
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||||
|
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
|
||||||
|
return nCurrentFilterGroupID;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SFilterDlg::GetSelectFilterID()
|
||||||
|
{
|
||||||
|
int nCurrentFilterID = D_NOT_SELECT;
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilter->selectedItems())
|
||||||
|
nCurrentFilterID = item->data(Qt::UserRole).toInt();
|
||||||
|
return nCurrentFilterID;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterDlg::Group_Run()
|
||||||
|
{
|
||||||
|
GetMainWindow()->m_pBatchRunDlg->showBatchRun(GetSelectGroupID());
|
||||||
|
}
|
||||||
40
MorphereAnalyzer/sfilterdlg.h
Normal file
40
MorphereAnalyzer/sfilterdlg.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#ifndef SFILTERDLG_H
|
||||||
|
#define SFILTERDLG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
|
||||||
|
class SFilterDlg : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SFilterDlg();
|
||||||
|
~SFilterDlg();
|
||||||
|
|
||||||
|
int GetSelectGroupID();
|
||||||
|
int GetSelectFilterID();
|
||||||
|
void RefreshFilter(int _nGroup);
|
||||||
|
private :
|
||||||
|
void setWidgets();
|
||||||
|
private :
|
||||||
|
QListWidget *m_plwFilterGroup;
|
||||||
|
QListWidget *m_plwFilter;
|
||||||
|
QLineEdit *m_pleFilterGroup;
|
||||||
|
private slots:
|
||||||
|
void Group_Insert();
|
||||||
|
void Group_Delete();
|
||||||
|
void Group_Modify();
|
||||||
|
void Group_CopyPaste();
|
||||||
|
void Group_Refresh();
|
||||||
|
void Group_Run();
|
||||||
|
void GroupItemChanged(QListWidgetItem *, QListWidgetItem *);
|
||||||
|
void ItemChanged(QListWidgetItem*,QListWidgetItem*);
|
||||||
|
|
||||||
|
void Up();
|
||||||
|
void Down();
|
||||||
|
void Delete();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SFILTERDLG_H
|
||||||
609
MorphereAnalyzer/sfilterobject.cpp
Normal file
609
MorphereAnalyzer/sfilterobject.cpp
Normal file
@@ -0,0 +1,609 @@
|
|||||||
|
#include "sfilterobject.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "../Json/sjson.h"
|
||||||
|
#include "../common.h"
|
||||||
|
|
||||||
|
#include <QLayout>
|
||||||
|
#include <QCalendarWidget>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QGroupBox>
|
||||||
|
|
||||||
|
SFilterObject::SFilterObject()
|
||||||
|
{
|
||||||
|
setWindowTitle("Object");
|
||||||
|
setWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
SFilterObject::~SFilterObject()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::setWidgets()
|
||||||
|
{
|
||||||
|
m_tab.setParent(this);
|
||||||
|
m_tab.addTab(setDateWidgets(),"Date");
|
||||||
|
m_tab.addTab(setSearchWidgets(),"Search");
|
||||||
|
m_tab.addTab(setLengthWidgets(),"Length");
|
||||||
|
m_tab.addTab(setReplaceWidgets(),"Replace");
|
||||||
|
m_tab.addTab(setCounterWidgets(),"Counter");
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *SFilterObject::setDateWidgets()
|
||||||
|
{
|
||||||
|
m_pdeStart = new QDateEdit(QDate::currentDate());
|
||||||
|
m_pdeEnd = new QDateEdit(QDate::currentDate());
|
||||||
|
|
||||||
|
m_pdeStart->setDateRange(QDate(2003, 5, 20),QDate::currentDate());
|
||||||
|
m_pdeEnd->setDateRange(QDate(2003, 5, 20),QDate::currentDate().addYears(1));
|
||||||
|
|
||||||
|
QCalendarWidget *pcw = new QCalendarWidget();
|
||||||
|
m_pdeStart->setCalendarWidget(pcw);
|
||||||
|
m_pdeStart->setCalendarPopup(true);
|
||||||
|
|
||||||
|
m_pdeEnd->setCalendarWidget(pcw);
|
||||||
|
m_pdeEnd->setCalendarPopup(true);
|
||||||
|
|
||||||
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||||
|
hlayout->addWidget(new QLabel("Start:"));
|
||||||
|
hlayout->addWidget(m_pdeStart);
|
||||||
|
hlayout->addWidget(new QLabel("End:"));
|
||||||
|
hlayout->addWidget(m_pdeEnd);
|
||||||
|
|
||||||
|
{
|
||||||
|
QPushButton *pbInsert = new QPushButton("Insert");
|
||||||
|
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchDate()));
|
||||||
|
QPushButton *pbModify = new QPushButton("Modify");
|
||||||
|
connect(pbModify , SIGNAL(released()),this, SLOT(SearchDateUpdate()));
|
||||||
|
|
||||||
|
hlayout->addWidget(pbInsert);
|
||||||
|
hlayout->addWidget(pbModify);
|
||||||
|
}
|
||||||
|
|
||||||
|
hlayout->setAlignment(Qt::AlignLeft|Qt::AlignTop);
|
||||||
|
QWidget *pWidget = new QWidget;
|
||||||
|
pWidget->setLayout(hlayout);
|
||||||
|
return pWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *SFilterObject::setSearchWidgets()
|
||||||
|
{
|
||||||
|
m_pcbCatalog = new QComboBox;
|
||||||
|
m_pcbKeyword = new QComboBox;
|
||||||
|
m_pcbMethod = new QComboBox;
|
||||||
|
m_pleString = new QLineEdit;
|
||||||
|
m_pchbLast = new QCheckBox;
|
||||||
|
|
||||||
|
m_pcbKeyword->addItem(QString("Or"));// or
|
||||||
|
m_pcbKeyword->addItem(QString("And"));// and
|
||||||
|
m_pcbKeyword->addItem(QString("Cell Delete Or"));
|
||||||
|
m_pcbKeyword->addItem(QString("Cell Delete And"));
|
||||||
|
//m_pcbKeyword->addItem(QString("Word Delete"));
|
||||||
|
|
||||||
|
m_pcbMethod->addItem(QString("Sentence"));
|
||||||
|
m_pcbMethod->addItem(QString("Space"));
|
||||||
|
|
||||||
|
m_pchbLast->setText("Last");
|
||||||
|
|
||||||
|
foreach(QStringList strList,GetColumn().data())
|
||||||
|
m_pcbCatalog->addItem(strList.at(SColumn::E_NAME));
|
||||||
|
|
||||||
|
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||||
|
{
|
||||||
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||||
|
hlayout->addWidget(new QLabel("Item:"));
|
||||||
|
hlayout->addWidget(m_pcbCatalog);
|
||||||
|
hlayout->addWidget(new QLabel("Method:"));
|
||||||
|
hlayout->addWidget(m_pcbMethod);
|
||||||
|
hlayout->addWidget(new QLabel("keyword:"));
|
||||||
|
hlayout->addWidget(m_pcbKeyword);
|
||||||
|
hlayout->addWidget(m_pchbLast);
|
||||||
|
vlayout->addLayout(hlayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||||
|
hlayout->addWidget(new QLabel("Search:"));
|
||||||
|
hlayout->addWidget(m_pleString);
|
||||||
|
vlayout->addLayout(hlayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||||
|
hlayout->addLayout(vlayout);
|
||||||
|
|
||||||
|
{
|
||||||
|
QVBoxLayout *vsublayout = new QVBoxLayout();
|
||||||
|
QPushButton *pbInsert = new QPushButton("Insert");
|
||||||
|
vsublayout->addWidget(pbInsert);
|
||||||
|
connect(pbInsert, SIGNAL(released()),this, SLOT(SearchKeyword()));
|
||||||
|
|
||||||
|
QPushButton *pbModify = new QPushButton("Modify");
|
||||||
|
connect(pbModify , SIGNAL(released()),this, SLOT(SearchKeywordUpdate()));
|
||||||
|
vsublayout->addWidget(pbModify);
|
||||||
|
hlayout->addLayout(vsublayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *pWidget = new QWidget;
|
||||||
|
pWidget->setLayout(hlayout);
|
||||||
|
return pWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *SFilterObject::setLengthWidgets()
|
||||||
|
{
|
||||||
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||||
|
m_pcbLengthCatalog = new QComboBox;
|
||||||
|
m_pcbLengthComp = new QComboBox;
|
||||||
|
m_pcbLengthInsDel = new QComboBox;
|
||||||
|
m_pleLength = new QLineEdit;
|
||||||
|
|
||||||
|
foreach(QStringList strList,GetColumn().data())
|
||||||
|
m_pcbLengthCatalog->addItem(strList.at(SColumn::E_NAME));
|
||||||
|
|
||||||
|
m_pcbLengthComp->addItem(">",QVariant(E_LENGTH_COMP_GREATER));
|
||||||
|
m_pcbLengthComp->addItem("<",QVariant(E_LENGTH_COMP_LESS));
|
||||||
|
m_pcbLengthComp->addItem("=",QVariant(E_LENGTH_COMP_EQUAL));
|
||||||
|
|
||||||
|
m_pcbLengthInsDel->addItem("Add",QVariant(0));
|
||||||
|
m_pcbLengthInsDel->addItem("Del",QVariant(1));
|
||||||
|
|
||||||
|
hlayout->addWidget(new QLabel("Item:"));
|
||||||
|
hlayout->addWidget(m_pcbLengthCatalog);
|
||||||
|
hlayout->addWidget(m_pcbLengthComp);
|
||||||
|
hlayout->addWidget(new QLabel("Length:"));
|
||||||
|
hlayout->addWidget(m_pleLength);
|
||||||
|
hlayout->addWidget(m_pcbLengthInsDel);
|
||||||
|
{
|
||||||
|
QVBoxLayout *vsublayout = new QVBoxLayout();
|
||||||
|
QPushButton *pbInsert = new QPushButton("Insert");
|
||||||
|
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchLength()));
|
||||||
|
QPushButton *pbModify = new QPushButton("Modify");
|
||||||
|
connect(pbModify , SIGNAL(released()),this, SLOT(SearchLengthUpdate()));
|
||||||
|
vsublayout->addWidget(pbInsert);
|
||||||
|
vsublayout->addWidget(pbModify);
|
||||||
|
hlayout->addLayout(vsublayout);
|
||||||
|
}
|
||||||
|
QWidget *pWidget = new QWidget;
|
||||||
|
pWidget->setLayout(hlayout);
|
||||||
|
return pWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *SFilterObject::setCounterWidgets()
|
||||||
|
{
|
||||||
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||||
|
m_pcbCounterCatalog = new QComboBox;
|
||||||
|
m_pcbCounterComp = new QComboBox;
|
||||||
|
m_pcbCounterInsDel = new QComboBox;
|
||||||
|
m_pcbCounterCntApl = new QComboBox;
|
||||||
|
m_pleCounter = new QLineEdit;
|
||||||
|
|
||||||
|
foreach(QStringList strList,GetColumn().data())
|
||||||
|
m_pcbCounterCatalog->addItem(strList.at(SColumn::E_NAME));
|
||||||
|
|
||||||
|
m_pcbCounterComp->addItem(">",QVariant(E_LENGTH_COMP_GREATER));
|
||||||
|
m_pcbCounterComp->addItem("<",QVariant(E_LENGTH_COMP_LESS));
|
||||||
|
m_pcbCounterComp->addItem("=",QVariant(E_LENGTH_COMP_EQUAL));
|
||||||
|
|
||||||
|
m_pcbCounterInsDel->addItem("Add",QVariant(0));
|
||||||
|
m_pcbCounterInsDel->addItem("Del",QVariant(1));
|
||||||
|
|
||||||
|
m_pcbCounterCntApl->addItem("Count",QVariant(0));
|
||||||
|
m_pcbCounterCntApl->addItem("Apply",QVariant(1));
|
||||||
|
|
||||||
|
hlayout->addWidget(new QLabel("Item:"));
|
||||||
|
hlayout->addWidget(m_pcbCounterCatalog);
|
||||||
|
hlayout->addWidget(m_pcbCounterComp);
|
||||||
|
//hlayout->addWidget(m_pcbCounterCntApl);
|
||||||
|
hlayout->addWidget(new QLabel("Count:"));
|
||||||
|
hlayout->addWidget(m_pleCounter);
|
||||||
|
hlayout->addWidget(m_pcbCounterInsDel);
|
||||||
|
{
|
||||||
|
QVBoxLayout *vsublayout = new QVBoxLayout();
|
||||||
|
QPushButton *pbInsert = new QPushButton("Insert");
|
||||||
|
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchCounter()));
|
||||||
|
QPushButton *pbModify = new QPushButton("Modify");
|
||||||
|
connect(pbModify , SIGNAL(released()),this, SLOT(SearchCounterUpdate()));
|
||||||
|
vsublayout->addWidget(pbInsert);
|
||||||
|
vsublayout->addWidget(pbModify);
|
||||||
|
hlayout->addLayout(vsublayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *pWidget = new QWidget;
|
||||||
|
pWidget->setLayout(hlayout);
|
||||||
|
return pWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *SFilterObject::setReplaceWidgets()
|
||||||
|
{
|
||||||
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||||
|
m_pcbReplaceCatalog = new QComboBox;
|
||||||
|
m_pcbReplaceFind = new QComboBox;
|
||||||
|
m_pcbReplace = new QComboBox;
|
||||||
|
m_pleReplaceFind = new QLineEdit;
|
||||||
|
m_pleReplace = new QLineEdit;
|
||||||
|
|
||||||
|
foreach(QStringList strList,GetColumn().data())
|
||||||
|
m_pcbReplaceCatalog->addItem(strList.at(SColumn::E_NAME));
|
||||||
|
|
||||||
|
m_pcbReplaceFind->addItem("Sentence",QVariant(E_REPLACE_SENTENCE));
|
||||||
|
m_pcbReplaceFind->addItem("Space",QVariant(E_REPLACE_SPACE));
|
||||||
|
|
||||||
|
m_pcbReplace->addItem("0",QVariant(0));
|
||||||
|
m_pcbReplace->addItem("1",QVariant(1));
|
||||||
|
m_pcbReplace->addItem("2",QVariant(2));
|
||||||
|
|
||||||
|
hlayout->addWidget(m_pcbReplaceCatalog);
|
||||||
|
hlayout->addWidget(new QLabel("Find:"));
|
||||||
|
hlayout->addWidget(m_pcbReplaceFind);
|
||||||
|
hlayout->addWidget(m_pleReplaceFind);
|
||||||
|
hlayout->addWidget(new QLabel("Replace:"));
|
||||||
|
hlayout->addWidget(m_pcbReplace);
|
||||||
|
hlayout->addWidget(m_pleReplace);
|
||||||
|
{
|
||||||
|
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||||
|
QPushButton *pbInsert = new QPushButton("Insert");
|
||||||
|
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchReplace()));
|
||||||
|
vlayout->addWidget(pbInsert);
|
||||||
|
QPushButton *pbModify = new QPushButton("Modify");
|
||||||
|
connect(pbModify , SIGNAL(released()),this, SLOT(SearchReplaceUpdate()));
|
||||||
|
vlayout->addWidget(pbModify);
|
||||||
|
hlayout->addLayout(vlayout);
|
||||||
|
}
|
||||||
|
QWidget *pWidget = new QWidget;
|
||||||
|
pWidget->setLayout(hlayout);
|
||||||
|
return pWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SFilterObject::JsonToString(int _nSelect,QString _strJson)
|
||||||
|
{
|
||||||
|
SJson json;
|
||||||
|
QString str = STable::GetArticleType(json.Get(_strJson,"Article").toInt());
|
||||||
|
switch(_nSelect)
|
||||||
|
{
|
||||||
|
case E_FILTER_TYPE_DATE:
|
||||||
|
str += "<Date> Start : ";
|
||||||
|
str += json.Get(_strJson,"Start");
|
||||||
|
str += " End : ";
|
||||||
|
str += json.Get(_strJson,"End");
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_SEARCH:
|
||||||
|
str += "<Search> ";
|
||||||
|
str += m_pcbCatalog->itemText(json.GetNumber(_strJson,"Category")) + " , ";
|
||||||
|
str += m_pcbMethod->itemText(json.GetNumber(_strJson,"Method")) + " , ";
|
||||||
|
str += m_pcbKeyword->itemText(json.GetNumber(_strJson,"Keyword")) + " , ";
|
||||||
|
str += (json.GetBool(_strJson,"Last")) ? "Last : o , " : "Last : x , ";
|
||||||
|
str += json.Get(_strJson,"String");
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_LENGTH:
|
||||||
|
str += "<Length> ";
|
||||||
|
str += m_pcbLengthCatalog->itemText(json.GetNumber(_strJson,"Category")) + " ";
|
||||||
|
str += m_pcbLengthComp->itemText(json.GetNumber(_strJson,"Comp")) + " ";
|
||||||
|
str += json.Get(_strJson,"String") + " , ";
|
||||||
|
str += m_pcbLengthInsDel->itemText(json.GetNumber(_strJson,"InsDel"));
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_REPLACE:
|
||||||
|
str += "<Replace> ";
|
||||||
|
str += m_pcbReplaceCatalog->itemText(json.GetNumber(_strJson,"Category")) + " , ";
|
||||||
|
str += m_pcbReplaceFind->itemText(json.GetNumber(_strJson,"Find")) + " ";
|
||||||
|
str += json.Get(_strJson,"String_Find") + " --> ";
|
||||||
|
str += json.Get(_strJson,"String_Replace");
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_COUNTER:
|
||||||
|
str += "<Counter> ";
|
||||||
|
str += m_pcbCounterCatalog->itemText(json.GetNumber(_strJson,"Category")) + " ";
|
||||||
|
str += m_pcbCounterComp->itemText(json.GetNumber(_strJson,"Comp")) + " ";
|
||||||
|
str += json.Get(_strJson,"String") + " , ";
|
||||||
|
str += m_pcbCounterInsDel->itemText(json.GetNumber(_strJson,"InsDel"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::JsonToWidget(int _nSelect,QString _strJson)
|
||||||
|
{
|
||||||
|
if (m_tab.isTabEnabled(_nSelect))
|
||||||
|
m_tab.setCurrentIndex(_nSelect);
|
||||||
|
SJson json;
|
||||||
|
switch(_nSelect)
|
||||||
|
{
|
||||||
|
case E_FILTER_TYPE_DATE:
|
||||||
|
m_pdeStart->setDate(QDate::fromString(json.Get(_strJson,"Start"),"yyyy-MM-dd"));
|
||||||
|
m_pdeEnd->setDate(QDate::fromString(json.Get(_strJson,"End"),"yyyy-MM-dd"));
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_SEARCH:
|
||||||
|
m_pcbCatalog->setCurrentIndex(json.GetNumber(_strJson,"Category"));
|
||||||
|
m_pcbMethod->setCurrentIndex(json.GetNumber(_strJson,"Method"));
|
||||||
|
m_pcbKeyword->setCurrentIndex(json.GetNumber(_strJson,"Keyword"));
|
||||||
|
m_pleString->setText(json.Get(_strJson,"String"));
|
||||||
|
m_pchbLast->setChecked(json.GetBool(_strJson,"Last"));
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_LENGTH:
|
||||||
|
m_pcbLengthCatalog->setCurrentIndex(json.GetNumber(_strJson,"Category"));
|
||||||
|
m_pcbLengthComp->setCurrentIndex(json.GetNumber(_strJson,"Comp"));
|
||||||
|
m_pcbLengthInsDel->setCurrentIndex(json.GetNumber(_strJson,"InsDel"));
|
||||||
|
m_pleLength->setText(json.Get(_strJson,"String"));
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_REPLACE:
|
||||||
|
m_pcbReplaceCatalog->setCurrentIndex(json.GetNumber(_strJson,"Category"));
|
||||||
|
m_pcbReplaceFind->setCurrentIndex(json.GetNumber(_strJson,"Find"));
|
||||||
|
m_pleReplaceFind->setText(json.Get(_strJson,"String_Find"));
|
||||||
|
m_pleReplace->setText(json.Get(_strJson,"String_Replace"));
|
||||||
|
break;
|
||||||
|
case E_FILTER_TYPE_COUNTER:
|
||||||
|
m_pcbCounterCatalog->setCurrentIndex(json.GetNumber(_strJson,"Category"));
|
||||||
|
m_pcbCounterComp->setCurrentIndex(json.GetNumber(_strJson,"Comp"));
|
||||||
|
m_pcbCounterInsDel->setCurrentIndex(json.GetNumber(_strJson,"InsDel"));
|
||||||
|
m_pleCounter->setText(json.Get(_strJson,"String"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::SearchDate()
|
||||||
|
{
|
||||||
|
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||||
|
DataBaseTimeFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),m_pdeStart->date(),m_pdeEnd->date(),nSelect,E_DATABASE_COMMAND_INSERT);
|
||||||
|
GetMainWindow()->m_pDataDlg->SearchDate(m_pdeStart->date(),m_pdeEnd->date());
|
||||||
|
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::SearchCounter()
|
||||||
|
{
|
||||||
|
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||||
|
DataBaseCounterFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||||
|
m_pcbCounterCatalog->currentIndex(),
|
||||||
|
m_pcbCounterComp->currentIndex(),
|
||||||
|
m_pcbCounterInsDel->currentIndex(),
|
||||||
|
m_pleCounter->text(),
|
||||||
|
nSelect, E_DATABASE_COMMAND_INSERT);
|
||||||
|
GetMainWindow()->m_pDataDlg->SearchCounter(m_pcbCounterCatalog->currentIndex(),
|
||||||
|
m_pcbCounterComp->currentIndex(),
|
||||||
|
m_pcbCounterInsDel->currentIndex(),
|
||||||
|
m_pleCounter->text().toInt());
|
||||||
|
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::SearchLength()
|
||||||
|
{
|
||||||
|
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||||
|
DataBaseLengthFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||||
|
m_pcbLengthCatalog->currentIndex(),
|
||||||
|
m_pcbLengthComp->currentIndex(),
|
||||||
|
m_pcbLengthInsDel->currentIndex(),m_pleLength->text(),
|
||||||
|
nSelect,E_DATABASE_COMMAND_INSERT);
|
||||||
|
GetMainWindow()->m_pDataDlg->SearchLength(m_pcbLengthCatalog->currentIndex(),
|
||||||
|
m_pcbLengthComp->currentIndex(),
|
||||||
|
m_pcbLengthInsDel->currentIndex(),
|
||||||
|
m_pleLength->text().toInt());
|
||||||
|
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::SearchReplace()
|
||||||
|
{
|
||||||
|
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||||
|
DataBaseReplaceFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||||
|
m_pcbReplaceCatalog->currentIndex(),
|
||||||
|
m_pcbReplaceFind->currentData().toInt(),
|
||||||
|
m_pleReplaceFind->text(),
|
||||||
|
m_pleReplace->text(),
|
||||||
|
nSelect,E_DATABASE_COMMAND_INSERT);
|
||||||
|
|
||||||
|
GetMainWindow()->m_pDataDlg->SearchReplace(m_pcbReplaceCatalog->currentIndex(),
|
||||||
|
m_pcbReplaceFind->currentIndex(),
|
||||||
|
m_pcbReplace->currentIndex(),
|
||||||
|
m_pleReplaceFind->text(),
|
||||||
|
m_pleReplace->text());
|
||||||
|
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::SearchKeyword()
|
||||||
|
{
|
||||||
|
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||||
|
{
|
||||||
|
SKeyword stKeyword;
|
||||||
|
stKeyword.m_nCatalog = m_pcbCatalog->currentIndex();
|
||||||
|
stKeyword.m_nKeyword = m_pcbKeyword->currentIndex();
|
||||||
|
QString strKey = m_pleString->text().replace("\r\n"," ");
|
||||||
|
strKey = strKey.replace("\n"," ");
|
||||||
|
strKey = strKey.replace("\t"," ");
|
||||||
|
|
||||||
|
QString strTemp;
|
||||||
|
foreach(QString str, strKey.split(" "))
|
||||||
|
{
|
||||||
|
if (str.trimmed().isEmpty() == false)
|
||||||
|
strTemp += str.trimmed() + " ";
|
||||||
|
}
|
||||||
|
strTemp = strTemp.trimmed();
|
||||||
|
m_pleString->setText(strTemp);
|
||||||
|
strKey = strTemp;
|
||||||
|
|
||||||
|
DataBaseSearchFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||||
|
m_pcbCatalog->currentIndex(),
|
||||||
|
m_pcbMethod->currentIndex(),
|
||||||
|
m_pcbKeyword->currentIndex(),
|
||||||
|
m_pchbLast->isChecked(),
|
||||||
|
strKey,
|
||||||
|
nSelect,E_DATABASE_COMMAND_INSERT);
|
||||||
|
|
||||||
|
stKeyword.m_strListKeyword = strKey.split(" ");
|
||||||
|
if (m_pcbMethod->currentIndex() == E_SEARCH_METHOD_SPACE)
|
||||||
|
{
|
||||||
|
for (int i = 0 ; i < stKeyword.m_strListKeyword.size(); i++ )
|
||||||
|
{
|
||||||
|
stKeyword.m_strListKeyword[i] = " " + stKeyword.m_strListKeyword[i] + " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_vecKeyword.push_back(stKeyword);
|
||||||
|
if (m_pchbLast->isChecked())
|
||||||
|
{
|
||||||
|
GetMainWindow()->m_pDataDlg->SearchKeyword(m_vecKeyword);
|
||||||
|
m_vecKeyword.clear();
|
||||||
|
unlockTabs();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lockTabs(1);
|
||||||
|
}
|
||||||
|
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::SearchDateUpdate()
|
||||||
|
{
|
||||||
|
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||||
|
DataBaseTimeFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||||
|
m_pdeStart->date(),m_pdeEnd->date(),
|
||||||
|
nSelect,E_DATABASE_COMMAND_UPDATE,
|
||||||
|
GetMainWindow()->m_pFilterDlg->GetSelectFilterID());
|
||||||
|
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::SearchCounterUpdate()
|
||||||
|
{
|
||||||
|
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||||
|
DataBaseCounterFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||||
|
m_pcbCounterCatalog->currentIndex(),
|
||||||
|
m_pcbCounterComp->currentIndex(),
|
||||||
|
m_pcbCounterInsDel->currentIndex(),
|
||||||
|
m_pleCounter->text(),
|
||||||
|
nSelect, E_DATABASE_COMMAND_UPDATE,
|
||||||
|
GetMainWindow()->m_pFilterDlg->GetSelectFilterID());
|
||||||
|
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::SearchLengthUpdate()
|
||||||
|
{
|
||||||
|
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||||
|
DataBaseLengthFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||||
|
m_pcbLengthCatalog->currentIndex(),
|
||||||
|
m_pcbLengthComp->currentIndex(),
|
||||||
|
m_pcbLengthInsDel->currentIndex(),
|
||||||
|
m_pleLength->text(),
|
||||||
|
nSelect,E_DATABASE_COMMAND_UPDATE,
|
||||||
|
GetMainWindow()->m_pFilterDlg->GetSelectFilterID());
|
||||||
|
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::SearchReplaceUpdate()
|
||||||
|
{
|
||||||
|
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||||
|
DataBaseReplaceFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||||
|
m_pcbReplaceCatalog->currentIndex(),
|
||||||
|
m_pcbReplaceFind->currentData().toInt(),
|
||||||
|
m_pleReplaceFind->text(),
|
||||||
|
m_pleReplace->text(),
|
||||||
|
nSelect,E_DATABASE_COMMAND_UPDATE,
|
||||||
|
GetMainWindow()->m_pFilterDlg->GetSelectFilterID());
|
||||||
|
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::SearchKeywordUpdate()
|
||||||
|
{
|
||||||
|
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||||
|
QString strKey = m_pleString->text().replace("\r\n"," ").replace("\n"," ").replace("\t"," ");
|
||||||
|
DataBaseSearchFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||||
|
m_pcbCatalog->currentIndex(),
|
||||||
|
m_pcbMethod->currentIndex(),
|
||||||
|
m_pcbKeyword->currentIndex(),
|
||||||
|
m_pchbLast->isChecked(),strKey,
|
||||||
|
nSelect,E_DATABASE_COMMAND_UPDATE,GetMainWindow()->m_pFilterDlg->GetSelectFilterID());
|
||||||
|
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::lockTabs(int _nExcept)
|
||||||
|
{
|
||||||
|
for (int i=0; i<m_tab.count(); i++)
|
||||||
|
{
|
||||||
|
if (i!=_nExcept)
|
||||||
|
m_tab.setTabEnabled(i, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::unlockTabs()
|
||||||
|
{
|
||||||
|
for (int i=0; i<m_tab.count(); i++)
|
||||||
|
m_tab.setTabEnabled(i, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::DataBaseFilter(int _nType,QString _strJson,int _nGroup,int _nCommand,int _nFilterID)
|
||||||
|
{
|
||||||
|
QString sql;
|
||||||
|
if (_nGroup == D_NOT_SELECT) return;
|
||||||
|
switch(_nCommand)
|
||||||
|
{
|
||||||
|
case E_DATABASE_COMMAND_INSERT:
|
||||||
|
sql = "INSERT INTO filter SET ";
|
||||||
|
break;
|
||||||
|
case E_DATABASE_COMMAND_UPDATE:
|
||||||
|
sql = "UPDATE filter SET ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sql += QString("type=") + QString::number(_nType) + ",";
|
||||||
|
sql += QString("data='") + _strJson + "',";
|
||||||
|
sql += QString("filtergroup_id=" ) + QString::number(_nGroup);
|
||||||
|
if (_nCommand == E_DATABASE_COMMAND_UPDATE)
|
||||||
|
{
|
||||||
|
if (_nFilterID == D_NOT_SELECT) return;
|
||||||
|
sql += QString(" where id=") + QString::number(_nFilterID);
|
||||||
|
}
|
||||||
|
QSqlQuery query;
|
||||||
|
if(query.exec(sql.toUtf8()) == false) { qDebug() << query.lastError().text();}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::DataBaseTimeFilter(int _nArticle ,QDate _dateStart ,QDate _dateEnd ,int _nGroup,int _nCommand,int _nFilterID )
|
||||||
|
{
|
||||||
|
QString strJson;
|
||||||
|
SJson json;
|
||||||
|
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
||||||
|
strJson = json.Set(strJson,"Start",_dateStart.toString("yyyy-MM-dd"));
|
||||||
|
strJson = json.Set(strJson,"End",_dateEnd.toString("yyyy-MM-dd"));
|
||||||
|
DataBaseFilter(E_FILTER_TYPE_DATE,json.Sql(strJson),_nGroup,_nCommand,_nFilterID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::DataBaseSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _nKeyword ,bool _bLast, QString _str,int _nGroup,int _nCommand,int _nFilterID)
|
||||||
|
{
|
||||||
|
QString strJson;
|
||||||
|
SJson json;
|
||||||
|
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
||||||
|
strJson = json.Set(strJson,"Category",_nCategory);
|
||||||
|
strJson = json.Set(strJson,"Method",_nMethod);
|
||||||
|
strJson = json.Set(strJson,"Keyword",_nKeyword);
|
||||||
|
strJson = json.Set(strJson,"Last",_bLast);
|
||||||
|
strJson = json.Set(strJson,"String",_str);
|
||||||
|
DataBaseFilter(E_FILTER_TYPE_SEARCH,json.Sql(strJson),_nGroup,_nCommand,_nFilterID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::DataBaseLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,int _nFilterID)
|
||||||
|
{
|
||||||
|
QString strJson;
|
||||||
|
SJson json;
|
||||||
|
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
||||||
|
strJson = json.Set(strJson,"Category",_nCategory);
|
||||||
|
strJson = json.Set(strJson,"Comp",_nComp);
|
||||||
|
strJson = json.Set(strJson,"InsDel",_nInsDel);
|
||||||
|
strJson = json.Set(strJson,"String",_str);
|
||||||
|
DataBaseFilter(E_FILTER_TYPE_LENGTH,json.Sql(strJson),_nGroup,_nCommand,_nFilterID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SFilterObject::DataBaseCounterFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,int _nFilterID)
|
||||||
|
{
|
||||||
|
QString strJson;
|
||||||
|
SJson json;
|
||||||
|
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
||||||
|
strJson = json.Set(strJson,"Category",_nCategory);
|
||||||
|
strJson = json.Set(strJson,"Comp",_nComp);
|
||||||
|
strJson = json.Set(strJson,"InsDel",_nInsDel);
|
||||||
|
strJson = json.Set(strJson,"String",_str);
|
||||||
|
DataBaseFilter(E_FILTER_TYPE_COUNTER,json.Sql(strJson),_nGroup,_nCommand,_nFilterID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFilterObject::DataBaseReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup,int _nCommand,int _nFilterID)
|
||||||
|
{
|
||||||
|
QString strJson;
|
||||||
|
SJson json;
|
||||||
|
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
||||||
|
strJson = json.Set(strJson,"Category",_nCategory);
|
||||||
|
strJson = json.Set(strJson,"Find",_nFind);
|
||||||
|
strJson = json.Set(strJson,"String_Find",_strFind);
|
||||||
|
strJson = json.Set(strJson,"String_Replace",_strReplace);
|
||||||
|
DataBaseFilter(E_FILTER_TYPE_REPLACE,json.Sql(strJson),_nGroup,_nCommand,_nFilterID);
|
||||||
|
}
|
||||||
86
MorphereAnalyzer/sfilterobject.h
Normal file
86
MorphereAnalyzer/sfilterobject.h
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
#ifndef SFILTEROBJECT_H
|
||||||
|
#define SFILTEROBJECT_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QDateEdit>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
|
#include "./../common.h"
|
||||||
|
|
||||||
|
class SFilterObject : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SFilterObject();
|
||||||
|
~SFilterObject();
|
||||||
|
void setWidgets();
|
||||||
|
QWidget *setDateWidgets();
|
||||||
|
QWidget *setSearchWidgets();
|
||||||
|
QWidget *setReplaceWidgets();
|
||||||
|
QWidget *setLengthWidgets();
|
||||||
|
QWidget *setCounterWidgets();
|
||||||
|
|
||||||
|
void lockTabs(int _nExcept);
|
||||||
|
void unlockTabs();
|
||||||
|
|
||||||
|
void JsonToWidget(int _nSelect,QString _strJson);
|
||||||
|
QString JsonToString(int _nSelect,QString _strJson);
|
||||||
|
|
||||||
|
void DataBaseFilter(int _nType,QString _strJson,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||||
|
void DataBaseTimeFilter(int _nArticle ,QDate _dateStart ,QDate _dateEnd ,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||||
|
void DataBaseSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _nKeyword ,bool _nLast , QString _str,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||||
|
void DataBaseLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||||
|
void DataBaseCounterFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||||
|
void DataBaseReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||||
|
private:
|
||||||
|
enum E_DATABASE_COMMAND
|
||||||
|
{
|
||||||
|
E_DATABASE_COMMAND_INSERT = 0,
|
||||||
|
E_DATABASE_COMMAND_UPDATE,
|
||||||
|
};
|
||||||
|
QTabWidget m_tab;
|
||||||
|
|
||||||
|
QDateEdit *m_pdeStart;
|
||||||
|
QDateEdit *m_pdeEnd;
|
||||||
|
|
||||||
|
QComboBox *m_pcbCatalog;
|
||||||
|
QComboBox *m_pcbKeyword;
|
||||||
|
QComboBox *m_pcbMethod;
|
||||||
|
QCheckBox *m_pchbLast;
|
||||||
|
QLineEdit *m_pleString;
|
||||||
|
|
||||||
|
QComboBox *m_pcbLengthCatalog;
|
||||||
|
QComboBox *m_pcbLengthComp;
|
||||||
|
QComboBox *m_pcbLengthInsDel;
|
||||||
|
QLineEdit *m_pleLength;
|
||||||
|
|
||||||
|
QComboBox *m_pcbCounterCatalog;
|
||||||
|
QComboBox *m_pcbCounterComp;
|
||||||
|
QComboBox *m_pcbCounterInsDel;
|
||||||
|
QComboBox *m_pcbCounterCntApl;
|
||||||
|
QLineEdit *m_pleCounter;
|
||||||
|
|
||||||
|
QComboBox *m_pcbReplaceCatalog;
|
||||||
|
QComboBox *m_pcbReplaceFind;
|
||||||
|
QComboBox *m_pcbReplace;
|
||||||
|
QLineEdit *m_pleReplaceFind;
|
||||||
|
QLineEdit *m_pleReplace;
|
||||||
|
|
||||||
|
QVector <SKeyword> m_vecKeyword;
|
||||||
|
private slots:
|
||||||
|
void SearchDate();
|
||||||
|
void SearchDateUpdate();
|
||||||
|
void SearchCounter();
|
||||||
|
void SearchCounterUpdate();
|
||||||
|
void SearchLength();
|
||||||
|
void SearchLengthUpdate();
|
||||||
|
void SearchReplace();
|
||||||
|
void SearchReplaceUpdate();
|
||||||
|
void SearchKeyword();
|
||||||
|
void SearchKeywordUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SFILTEROBJECT_H
|
||||||
63
MorphereAnalyzer/sloaddlg.cpp
Normal file
63
MorphereAnalyzer/sloaddlg.cpp
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#include "sloaddlg.h"
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "stable.h"
|
||||||
|
|
||||||
|
SLoadDlg::SLoadDlg()
|
||||||
|
{
|
||||||
|
setWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
SLoadDlg::~SLoadDlg()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SLoadDlg::setWidgets()
|
||||||
|
{
|
||||||
|
setWindowTitle("Load");
|
||||||
|
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||||
|
m_plwData = new QListWidget;
|
||||||
|
vlayout->addWidget(m_plwData);
|
||||||
|
m_plwData->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
QPushButton *ppbRefresh = new QPushButton("Refresh");
|
||||||
|
vlayout->addWidget(ppbRefresh);
|
||||||
|
connect(ppbRefresh, SIGNAL(released()),this, SLOT(Refresh()));
|
||||||
|
setLayout(vlayout);
|
||||||
|
connect(m_plwData,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(ItemChanged(QListWidgetItem*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SLoadDlg::Refresh()
|
||||||
|
{
|
||||||
|
m_plwData->clear();
|
||||||
|
QSqlQuery query("select id,name,count from datagroup");
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
QString str = query.value(1).toString();
|
||||||
|
str += " ( ";
|
||||||
|
str += query.value(0).toString();
|
||||||
|
str += " , ";
|
||||||
|
str += query.value(2).toString();
|
||||||
|
str += " )";
|
||||||
|
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwData);
|
||||||
|
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||||
|
}
|
||||||
|
GetMainWindow()->InsertLog("Start");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SLoadDlg::ItemChanged( QListWidgetItem *item)
|
||||||
|
{
|
||||||
|
QMessageBox msg;
|
||||||
|
msg.setText("Please choose...");
|
||||||
|
msg.setModal(true);
|
||||||
|
QPushButton *pbAll = msg.addButton("All",QMessageBox::ActionRole);
|
||||||
|
QPushButton *pbBody = msg.addButton("Body",QMessageBox::ActionRole);
|
||||||
|
QPushButton *pbReply = msg.addButton("Reply",QMessageBox::ActionRole);
|
||||||
|
msg.exec();
|
||||||
|
if (msg.clickedButton() == pbAll) GetMainWindow()->m_pDataDlg->DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_ALL);
|
||||||
|
else if (msg.clickedButton() == pbBody) GetMainWindow()->m_pDataDlg->DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_BODY);
|
||||||
|
else if (msg.clickedButton() == pbReply) GetMainWindow()->m_pDataDlg->DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_REPLY);
|
||||||
|
}
|
||||||
22
MorphereAnalyzer/sloaddlg.h
Normal file
22
MorphereAnalyzer/sloaddlg.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef SLOADDLG_H
|
||||||
|
#define SLOADDLG_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
|
class SLoadDlg : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SLoadDlg();
|
||||||
|
~SLoadDlg();
|
||||||
|
private:
|
||||||
|
void setWidgets();
|
||||||
|
QListWidget *m_plwData;
|
||||||
|
private slots:
|
||||||
|
void Refresh();
|
||||||
|
void ItemChanged( QListWidgetItem *item);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SLOADDLG_H
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDebug>
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
@@ -26,6 +25,15 @@ void STable::SetHeaderList(QVector <QStringList>* _pvecHead,int _nColumn)
|
|||||||
setHorizontalHeaderItem(i++,new QTableWidgetItem(strList.at(_nColumn)));
|
setHorizontalHeaderItem(i++,new QTableWidgetItem(strList.at(_nColumn)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void STable::SetHeaderList(QStringList _Head)
|
||||||
|
{
|
||||||
|
setColumnCount(_Head.size());
|
||||||
|
int i = 0;
|
||||||
|
foreach(QString str,_Head )
|
||||||
|
setHorizontalHeaderItem(i++,new QTableWidgetItem(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void STable::keyPressEvent(QKeyEvent* event)
|
void STable::keyPressEvent(QKeyEvent* event)
|
||||||
{
|
{
|
||||||
// If Ctrl-C typed
|
// If Ctrl-C typed
|
||||||
|
|||||||
@@ -3,6 +3,25 @@
|
|||||||
|
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QTableWidgetItem>
|
||||||
|
|
||||||
|
class STableNumberItem : public QTableWidgetItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
STableNumberItem(QString txt):QTableWidgetItem(txt)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
bool operator <(const QTableWidgetItem &other) const
|
||||||
|
{
|
||||||
|
return text().toDouble() < other.text().toDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator >(const QTableWidgetItem &other) const
|
||||||
|
{
|
||||||
|
return text().toDouble() > other.text().toDouble();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class STable : public QTableWidget
|
class STable : public QTableWidget
|
||||||
{
|
{
|
||||||
@@ -18,6 +37,7 @@ public:
|
|||||||
explicit STable(QWidget *parent = 0);
|
explicit STable(QWidget *parent = 0);
|
||||||
void keyPressEvent(QKeyEvent* event);
|
void keyPressEvent(QKeyEvent* event);
|
||||||
void SetHeaderList(QVector <QStringList> *_vecColumn,int _nColumn);
|
void SetHeaderList(QVector <QStringList> *_vecColumn,int _nColumn);
|
||||||
|
void SetHeaderList(QStringList _Head);
|
||||||
void setArticleSelect(int _nArticle);
|
void setArticleSelect(int _nArticle);
|
||||||
int getArticleSelect(){return m_nArticle;}
|
int getArticleSelect(){return m_nArticle;}
|
||||||
void Copy();
|
void Copy();
|
||||||
|
|||||||
388
MorphereAnalyzer/subwindow.cpp
Normal file
388
MorphereAnalyzer/subwindow.cpp
Normal file
@@ -0,0 +1,388 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the examples of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** You may use this file under the terms of the BSD license as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
||||||
|
** of its contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <QtWidgets>
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "subwindow.h"
|
||||||
|
//#include "widget.h"
|
||||||
|
#include "stable.h"
|
||||||
|
#include "sdictionary.h"
|
||||||
|
#include "tablealgorithm_interface.h"
|
||||||
|
#include "yalgorithm.h"
|
||||||
|
#include "ymbasicwidget.h"
|
||||||
|
#include "ymonedepthwidget.h"
|
||||||
|
#include "ymnxnmatrixwidget.h"
|
||||||
|
#include <QSqlQuery>
|
||||||
|
#include <QSqlDatabase>
|
||||||
|
#include <QSqlError>
|
||||||
|
#include "ymtwodepthwidget.h"
|
||||||
|
#include "ymplatformwidget.h"
|
||||||
|
#include "ymtwodepthawidget.h"
|
||||||
|
#include <QShortcut>
|
||||||
|
#include <QKeySequence>
|
||||||
|
#include <QUrl>
|
||||||
|
//! [0]
|
||||||
|
SubWindow::SubWindow()
|
||||||
|
{
|
||||||
|
QWidget *widget = new QWidget;
|
||||||
|
setCentralWidget(widget);
|
||||||
|
//p_qwDB = new Widget;
|
||||||
|
//p_qwFile = new QWidget;
|
||||||
|
//p_qwAnalyzed1 = new QWidget;
|
||||||
|
//p_qwText = new QWidget;
|
||||||
|
//p_qwAnalyzer1 = new SAnaly1;
|
||||||
|
//p_qwAnalyzer2 = new SAnaly2;
|
||||||
|
m_pYMBasicWidget = new YMBasicWidget;
|
||||||
|
m_pYMOneDepthWidget = new YMOneDepthWidget;
|
||||||
|
m_pYMTwoDepthWidget = new YMTwoDepthWidget;
|
||||||
|
m_pYMTwoDepthAWidget = new YMTwoDepthAWidget;
|
||||||
|
|
||||||
|
m_pYMNxNMatrixWidget = new YMNxNMatrixWidget;
|
||||||
|
m_pYMPlatformWidget = new YMPlatformWidget;
|
||||||
|
p_qwDict = new SDictionary;
|
||||||
|
|
||||||
|
//p_qwAnalyzer1->setWidget(p_qwDB);
|
||||||
|
//p_qwAnalyzer2->setWidget(p_qwDB);
|
||||||
|
m_ptwSource = new QTabWidget;
|
||||||
|
m_ptwSource->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
//m_ptwSource->addTab(p_qwDB,"DB");
|
||||||
|
//m_ptwSource->addTab(p_qwFile,"File");
|
||||||
|
//m_ptwSource->addTab(p_qwText,"Text");
|
||||||
|
//m_ptwSource->addTab(p_qwAnalyzed1,"Analyzed1");
|
||||||
|
m_pTAInterface = new TableAlgorithmInterface;
|
||||||
|
m_pTAInterface->ReloadColumn();
|
||||||
|
m_pUploadWidget = new YMUploadWidget();
|
||||||
|
|
||||||
|
|
||||||
|
m_ptwResult = new QTabWidget;
|
||||||
|
m_ptwResult->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
//m_ptwResult->addTab(p_qwAnalyzer1, "Analysis1");
|
||||||
|
//m_ptwResult->addTab(p_qwAnalyzer2, "Analysis2");
|
||||||
|
m_ptwResult->addTab(m_pYMBasicWidget, "Basic");
|
||||||
|
m_ptwResult->addTab(m_pYMOneDepthWidget, "OneDepth");
|
||||||
|
m_ptwResult->addTab(m_pYMTwoDepthWidget, "TwoDepth");
|
||||||
|
m_ptwResult->addTab(m_pYMTwoDepthAWidget, "TwoDepthAdv");
|
||||||
|
m_ptwResult->addTab(m_pYMNxNMatrixWidget, "NxNMatrix");
|
||||||
|
m_ptwResult->addTab(m_pYMPlatformWidget, "Platform");
|
||||||
|
|
||||||
|
|
||||||
|
m_pYMBasicWidget->setTabWidget(GetMainWindow()->m_pDataDlg->GetCurrentTab());
|
||||||
|
m_pYMOneDepthWidget->setTabWidget(GetMainWindow()->m_pDataDlg->GetCurrentTab());
|
||||||
|
m_pYMTwoDepthWidget->setTabWidget(GetMainWindow()->m_pDataDlg->GetCurrentTab());
|
||||||
|
m_pYMNxNMatrixWidget->setTabWidget(GetMainWindow()->m_pDataDlg->GetCurrentTab());
|
||||||
|
m_pYMPlatformWidget->setTabWidget(GetMainWindow()->m_pDataDlg->GetCurrentTab());
|
||||||
|
m_pYMTwoDepthAWidget->setTabWidget(GetMainWindow()->m_pDataDlg->GetCurrentTab());
|
||||||
|
|
||||||
|
m_pUploadWidget->setResultTabWidget(m_ptwResult);
|
||||||
|
m_pUploadWidget->setSourceTabWidget(GetMainWindow()->m_pDataDlg->GetCurrentTab());
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
|
|
||||||
|
layout->setMargin(5);
|
||||||
|
//layout->addWidget(m_ptwSource);
|
||||||
|
layout->addWidget(m_ptwResult);
|
||||||
|
|
||||||
|
widget->setLayout(layout);
|
||||||
|
//! [1]
|
||||||
|
|
||||||
|
actD3View = new QAction(tr("D3View"), this);
|
||||||
|
actD3View->setShortcut(Qt::Key_0 | Qt::CTRL);
|
||||||
|
connect(actD3View, SIGNAL(triggered()), this, SLOT(slotD3View()));
|
||||||
|
this->addAction(actD3View);
|
||||||
|
|
||||||
|
//! [2]
|
||||||
|
createActions();
|
||||||
|
createMenus();
|
||||||
|
|
||||||
|
QString message = tr("A context menu is available by right-clicking");
|
||||||
|
statusBar()->showMessage(message);
|
||||||
|
//test = new QWebView(this);
|
||||||
|
setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
|
||||||
|
setWindowTitle(tr("Morphere Analyzer"));
|
||||||
|
setMinimumSize(800, 600);
|
||||||
|
resize(800, 600);
|
||||||
|
}
|
||||||
|
void SubWindow::createActions()
|
||||||
|
{
|
||||||
|
//! [5]
|
||||||
|
//!
|
||||||
|
actDBNew = new QAction(tr("&New DB "), this);
|
||||||
|
actDBNew->setStatusTip(tr("Create a new DB"));
|
||||||
|
connect(actDBNew, SIGNAL(triggered()), this, SLOT(newDB()));
|
||||||
|
|
||||||
|
actDBCsvImport = new QAction(tr("DB - CSV Import"), this);
|
||||||
|
actDBCsvImport->setStatusTip(tr("Import DB as a csv file"));
|
||||||
|
connect(actDBCsvImport, SIGNAL(triggered()), this, SLOT(importDB()));
|
||||||
|
|
||||||
|
actDBCsvExport = new QAction(tr("DB - CSV Export"), this);
|
||||||
|
actDBCsvExport->setStatusTip(tr("Export DB as a csv file"));
|
||||||
|
connect(actDBCsvExport, SIGNAL(triggered()), this, SLOT(exportDB()));
|
||||||
|
|
||||||
|
actMorphereOriginalExport = new QAction(tr("Morphere - CSV Export(OtherType Result)"), this);
|
||||||
|
actMorphereOriginalExport->setStatusTip(tr("Export Morphere as a csv file"));
|
||||||
|
connect(actMorphereOriginalExport, SIGNAL(triggered()), this, SLOT(exportOriginalMorphere()));
|
||||||
|
|
||||||
|
actMorphereExport = new QAction(tr("Morphere - CSV Export"), this);
|
||||||
|
actMorphereExport->setStatusTip(tr("Export Morphere as a csv file"));
|
||||||
|
connect(actMorphereExport, SIGNAL(triggered()), this, SLOT(exportMorphere()));
|
||||||
|
|
||||||
|
actMorphereImport = new QAction(tr("Morphere - CSV Import"), this);
|
||||||
|
actMorphereImport->setStatusTip(tr("Import Morphere as a csv file"));
|
||||||
|
connect(actMorphereImport, SIGNAL(triggered()), this, SLOT(importMorphere()));
|
||||||
|
|
||||||
|
actExit = new QAction(tr("Exit"), this);
|
||||||
|
actExit->setStatusTip(tr("Exit the application"));
|
||||||
|
connect(actExit, SIGNAL(triggered()), this, SLOT(close()));
|
||||||
|
|
||||||
|
actAnalyze = new QAction(tr("Analyze"), this);
|
||||||
|
actAnalyze->setStatusTip(tr("Analyze"));
|
||||||
|
connect(actAnalyze, SIGNAL(triggered()), this, SLOT(slotAnalyze()));
|
||||||
|
|
||||||
|
actDictionary = new QAction(tr("Dictionary"), this);
|
||||||
|
actAnalyze->setStatusTip(tr("Execute Dictionary Widget"));
|
||||||
|
connect(actDictionary, SIGNAL(triggered()), this, SLOT(slotDictionary()));
|
||||||
|
|
||||||
|
actTestUpload = new QAction(tr("Test Upload"), this);
|
||||||
|
connect(actTestUpload, SIGNAL(triggered()), this, SLOT(slotTestUpload()));
|
||||||
|
actShowUpload = new QAction(tr("Show Upload"), this);
|
||||||
|
connect(actShowUpload, SIGNAL(triggered()), this, SLOT(slotShowUpload()));
|
||||||
|
actD3ViewTree = new QAction(tr("D3View Tree"), this);
|
||||||
|
connect(actD3ViewTree, SIGNAL(triggered()), this, SLOT(slotD3ViewTree()));
|
||||||
|
|
||||||
|
actD3ViewTreeFile = new QAction(tr("D3ViewTree From File"), this);
|
||||||
|
connect(actD3ViewTreeFile, SIGNAL(triggered()), this, SLOT(slotD3ViewTreeFile()));
|
||||||
|
|
||||||
|
actD3ViewFile = new QAction(tr("D3View From File"), this);
|
||||||
|
connect(actD3ViewFile, SIGNAL(triggered()), this, SLOT(slotD3ViewFile()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::slotShowUpload()
|
||||||
|
{
|
||||||
|
m_pUploadWidget->show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::slotD3View()
|
||||||
|
{
|
||||||
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->D3View();
|
||||||
|
//qDebug() << "hide the D3View";
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::slotD3ViewTree()
|
||||||
|
{
|
||||||
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->D3ViewTree();
|
||||||
|
//qDebug() << "hide the D3View";
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::slotD3ViewFile()
|
||||||
|
{
|
||||||
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->D3ViewFile();
|
||||||
|
//qDebug() << "hide the D3View";
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::slotD3ViewTreeFile()
|
||||||
|
{
|
||||||
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->D3ViewTreeFile();
|
||||||
|
//qDebug() << "hide the D3View";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SubWindow::createMenus()
|
||||||
|
{
|
||||||
|
//! [9] //! [10]
|
||||||
|
menuFile = menuBar()->addMenu(tr("File"));
|
||||||
|
|
||||||
|
menuFile->addAction(actDBNew);
|
||||||
|
menuFile->addSeparator();
|
||||||
|
//! [9]
|
||||||
|
menuFile->addAction(actDBCsvImport);
|
||||||
|
//! [10]
|
||||||
|
menuFile->addAction(actDBCsvExport);
|
||||||
|
menuFile->addSeparator();
|
||||||
|
menuFile->addAction(actMorphereImport);
|
||||||
|
menuFile->addAction(actMorphereExport);
|
||||||
|
menuFile->addAction(actMorphereOriginalExport);
|
||||||
|
|
||||||
|
menuFile->addSeparator();
|
||||||
|
menuFile->addAction(actExit);
|
||||||
|
//! [11]
|
||||||
|
|
||||||
|
//! [11]
|
||||||
|
menuDictionary = menuBar()->addMenu(tr("Dictionary"));
|
||||||
|
menuDictionary->addAction(actDictionary);
|
||||||
|
|
||||||
|
menuAnalyze = menuBar()->addMenu(tr("Analyze"));
|
||||||
|
menuAnalyze->addAction(actAnalyze);
|
||||||
|
|
||||||
|
menuTestUpload = menuBar()->addMenu(tr("TestUpload"));
|
||||||
|
menuTestUpload->addAction(actTestUpload);
|
||||||
|
|
||||||
|
menuShowUpload = menuBar()->addMenu(tr("ShowUpload"));
|
||||||
|
menuShowUpload->addAction(actShowUpload);
|
||||||
|
|
||||||
|
menuD3View = menuBar()->addMenu(tr("D3View"));
|
||||||
|
menuD3View->addAction(actD3View);
|
||||||
|
menuD3View->addAction(actD3ViewFile);
|
||||||
|
menuD3View->addAction(actD3ViewTree);
|
||||||
|
menuD3View->addAction(actD3ViewTreeFile);
|
||||||
|
|
||||||
|
}
|
||||||
|
//! [12]
|
||||||
|
|
||||||
|
|
||||||
|
void SubWindow::newDB()
|
||||||
|
{
|
||||||
|
//p_qwDB->FileNew();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::importDB()
|
||||||
|
{
|
||||||
|
//p_qwDB->FileImport();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::exportDB()
|
||||||
|
{
|
||||||
|
//p_qwDB->FileExport();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::importMorphere()
|
||||||
|
{
|
||||||
|
// p_qwAnalyzer1->FileImport();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::exportMorphere()
|
||||||
|
{
|
||||||
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->SaveFile();
|
||||||
|
// p_qwAnalyzer1->FileExport();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::exportOriginalMorphere()
|
||||||
|
{
|
||||||
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->SaveFileSimple();
|
||||||
|
// p_qwAnalyzer1->RawFileExport();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::slotAnalyze()
|
||||||
|
{
|
||||||
|
QMessageBox msg;
|
||||||
|
msg.setText("Please choose...");
|
||||||
|
msg.setModal(true);
|
||||||
|
|
||||||
|
QPushButton *pbTitle = msg.addButton("Title",QMessageBox::ActionRole);
|
||||||
|
QPushButton *pbBody = msg.addButton("Body",QMessageBox::ActionRole);
|
||||||
|
QPushButton *pbAll = msg.addButton("ALL",QMessageBox::ActionRole);
|
||||||
|
QPushButton *pbPlatformTitle = msg.addButton("Platform Title",QMessageBox::ActionRole);
|
||||||
|
/*
|
||||||
|
int setbody;
|
||||||
|
msg.exec();
|
||||||
|
if (msg.clickedButton() == pbTitle) { setbody = 0; }
|
||||||
|
else if (msg.clickedButton() == pbBody) { setbody = 1; }
|
||||||
|
else if (msg.clickedButton() == pbAll) { setbody = 2; }
|
||||||
|
else if (msg.clickedButton() == pbPlatformTitle) { setbody = 3; }
|
||||||
|
*/
|
||||||
|
|
||||||
|
QMessageBox msg2;
|
||||||
|
msg2.setWindowFlags(msg2.windowFlags() | Qt::WindowCloseButtonHint);
|
||||||
|
msg2.setText("Please wait...");
|
||||||
|
msg2.setVisible(true);
|
||||||
|
//qDebug() << p_qwDB->GetTabWidget()->currentIndex();
|
||||||
|
m_pTAInterface->setSource(GetMainWindow()->m_pDataDlg->GetCurrentWidget());
|
||||||
|
YAFactory::getInstance()->getYAlgorithm(((YMorphereWidget*)(m_ptwResult->currentWidget()))->convertToParam())->setDataAlgorithmInterface(m_pTAInterface);
|
||||||
|
m_ptwResult->currentWidget();
|
||||||
|
//qDebug() << m_ptwResult->currentIndex();
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(m_ptwResult->currentIndex() == 0)
|
||||||
|
{
|
||||||
|
p_qwAnalyzer1->Exec(setbody);
|
||||||
|
}
|
||||||
|
else if(m_ptwResult->currentIndex() == 1)
|
||||||
|
{
|
||||||
|
p_qwAnalyzer2->Exec(setbody);
|
||||||
|
}
|
||||||
|
else if(m_ptwResult->currentIndex() == 2)
|
||||||
|
{
|
||||||
|
m_pYMBasicWidget->Exec(setbody);
|
||||||
|
}
|
||||||
|
else if(m_ptwResult->currentIndex() == 3)
|
||||||
|
{
|
||||||
|
m_pYMOneDepthWidget->Exec(setbody);
|
||||||
|
}
|
||||||
|
else if(m_ptwResult->currentIndex() == 4)
|
||||||
|
{
|
||||||
|
m_pYMNxNMatrixWidget->Exec(setbody);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
if(m_ptwResult->currentIndex() == 0)
|
||||||
|
{
|
||||||
|
m_pYMBasicWidget->Exec(setbody);
|
||||||
|
}
|
||||||
|
else if(m_ptwResult->currentIndex() == 1)
|
||||||
|
{
|
||||||
|
m_pYMOneDepthWidget->Exec(setbody);
|
||||||
|
}
|
||||||
|
else if(m_ptwResult->currentIndex() == 2)
|
||||||
|
{
|
||||||
|
m_pYMNxNMatrixWidget->Exec(setbody);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->Exec();
|
||||||
|
|
||||||
|
msg2.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::slotTestUpload()
|
||||||
|
{
|
||||||
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->TestUpload();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::slotDictionary()
|
||||||
|
{
|
||||||
|
p_qwDict->show();
|
||||||
|
p_qwDict->repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubWindow::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
QApplication::quit();
|
||||||
|
}
|
||||||
169
MorphereAnalyzer/subwindow.h
Normal file
169
MorphereAnalyzer/subwindow.h
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the examples of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** You may use this file under the terms of the BSD license as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
||||||
|
** of its contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SUBWINDOW_H
|
||||||
|
#define SUBWINDOW_H
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QTabWidget>
|
||||||
|
//#include "widget.h"
|
||||||
|
//#include "sanaly1.h"
|
||||||
|
//#include "sanaly2.h"
|
||||||
|
#include "ymorpherewidget.h"
|
||||||
|
#include <QList>
|
||||||
|
#include "sdictionary.h"
|
||||||
|
#include "tablealgorithm_interface.h"
|
||||||
|
#include <QCloseEvent>
|
||||||
|
#include "ymuploadwidget.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QAction;
|
||||||
|
class QActionGroup;
|
||||||
|
class QLabel;
|
||||||
|
class QMenu;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
//! [0]
|
||||||
|
class SubWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SubWindow();
|
||||||
|
protected:
|
||||||
|
//void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
//! [0]
|
||||||
|
|
||||||
|
//! [1]
|
||||||
|
private slots:
|
||||||
|
void newDB();
|
||||||
|
void importDB();
|
||||||
|
void exportDB();
|
||||||
|
void exportMorphere();
|
||||||
|
void importMorphere();
|
||||||
|
void slotAnalyze();
|
||||||
|
void slotDictionary();
|
||||||
|
void exportOriginalMorphere();
|
||||||
|
void slotTestUpload();
|
||||||
|
void slotD3View();
|
||||||
|
void slotShowUpload();
|
||||||
|
void slotD3ViewTree();
|
||||||
|
void slotD3ViewFile();
|
||||||
|
void slotD3ViewTreeFile();
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *);
|
||||||
|
|
||||||
|
|
||||||
|
//! [1]
|
||||||
|
|
||||||
|
//! [2]
|
||||||
|
private:
|
||||||
|
void createActions();
|
||||||
|
void createMenus();
|
||||||
|
//! [2]
|
||||||
|
|
||||||
|
//! [3]
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
|
||||||
|
QTabWidget *m_ptwSource;
|
||||||
|
QTabWidget *m_ptwResult;
|
||||||
|
QWidget *m_qwMain;
|
||||||
|
|
||||||
|
//Widget *p_qwDB;
|
||||||
|
QWidget *p_qwFile;
|
||||||
|
QWidget *p_qwAnalyzed1;
|
||||||
|
QWidget *p_qwText;
|
||||||
|
SDictionary *p_qwDict;
|
||||||
|
YMUploadWidget* m_pUploadWidget;
|
||||||
|
|
||||||
|
|
||||||
|
//SAnaly1 *p_qwAnalyzer1;
|
||||||
|
//SAnaly2 *p_qwAnalyzer2;
|
||||||
|
YMorphereWidget *m_pYMBasicWidget;
|
||||||
|
YMorphereWidget *m_pYMOneDepthWidget;
|
||||||
|
YMorphereWidget *m_pYMNxNMatrixWidget;
|
||||||
|
YMorphereWidget *m_pYMTwoDepthWidget;
|
||||||
|
YMorphereWidget *m_pYMTwoDepthAWidget;
|
||||||
|
YMorphereWidget *m_pYMPlatformWidget;
|
||||||
|
|
||||||
|
QAction *actDBNew;
|
||||||
|
QAction *actDBCsvImport;
|
||||||
|
QAction *actDBCsvExport;
|
||||||
|
QAction *actMorphereExport;
|
||||||
|
QAction *actMorphereImport;
|
||||||
|
QAction *actMorphereOriginalExport;
|
||||||
|
|
||||||
|
QAction *actExit;
|
||||||
|
QAction *actAnalyze;
|
||||||
|
QAction *actDictionary;
|
||||||
|
|
||||||
|
QAction *actTestUpload;
|
||||||
|
|
||||||
|
QMenu *menuFile;
|
||||||
|
QMenu *menuAnalyze;
|
||||||
|
QMenu *menuDictionary;
|
||||||
|
QMenu *menuTestUpload;
|
||||||
|
QMenu *menuShowUpload;
|
||||||
|
QMenu *menuD3View;
|
||||||
|
|
||||||
|
|
||||||
|
QAction *actD3View;
|
||||||
|
QAction *actD3ViewTree;
|
||||||
|
|
||||||
|
QAction *actD3ViewFile;
|
||||||
|
QAction *actD3ViewTreeFile;
|
||||||
|
|
||||||
|
QAction *actShowUpload;
|
||||||
|
//AnalyzerThread m_pThread[16];
|
||||||
|
/*
|
||||||
|
QMutex mutex;
|
||||||
|
AnalyzerThread **m_pThread;
|
||||||
|
QList<STable*> m_lTable;
|
||||||
|
QList<QTabWidget*> m_lTabWidget;
|
||||||
|
*/
|
||||||
|
QTabWidget* m_ptwTable;
|
||||||
|
TableAlgorithmInterface* m_pTAInterface;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
//! [3]
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1569,7 +1569,7 @@ void Widget::FileImport()
|
|||||||
|
|
||||||
for(int i = 0; i < m_vecColumn.size(); i++)
|
for(int i = 0; i < m_vecColumn.size(); i++)
|
||||||
{
|
{
|
||||||
strlistHeader << m_vecColumn.at(i).at(E_COLUMN_DATABASE);
|
strlistHeader << m_vecColumn.at(i).at(E_COLUMN_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1600,7 +1600,7 @@ void Widget::FileImport()
|
|||||||
{
|
{
|
||||||
if (strlistHeader.contains(strings.at(i)))
|
if (strlistHeader.contains(strings.at(i)))
|
||||||
{
|
{
|
||||||
if (m_vecColumn.at(j).at(E_COLUMN_DATABASE) == strings.at(i).trimmed())
|
if (m_vecColumn.at(j).at(E_COLUMN_NAME) == strings.at(i).trimmed())
|
||||||
{
|
{
|
||||||
wgHeader << j;
|
wgHeader << j;
|
||||||
}
|
}
|
||||||
@@ -1663,7 +1663,7 @@ void Widget::FileExport()
|
|||||||
out << "#Head#,";
|
out << "#Head#,";
|
||||||
|
|
||||||
foreach(QStringList strList,m_vecColumn)
|
foreach(QStringList strList,m_vecColumn)
|
||||||
out << strList.at(E_COLUMN_DATABASE) << ",";
|
out << strList.at(E_COLUMN_NAME) << ",";
|
||||||
out << endl;
|
out << endl;
|
||||||
|
|
||||||
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
||||||
|
|||||||
@@ -990,7 +990,7 @@ QMap<QString, QString> YMBasicWidget::convertToParam()
|
|||||||
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mapParam.insert("Article",QString::number(((STable*)(((Widget*)(m_pTabWidget->currentWidget()))->GetTabWidget()->currentWidget()))->getArticleSelect()));
|
mapParam.insert("Article",QString::number(((STable *)m_pTabWidget->currentWidget())->getArticleSelect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1071,7 +1071,7 @@ QMap<QString, QString> YMNxNMatrixWidget::convertToParam()
|
|||||||
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mapParam.insert("Article",QString::number(((STable*)(((Widget*)(m_pTabWidget->currentWidget()))->GetTabWidget()->currentWidget()))->getArticleSelect()));
|
mapParam.insert("Article",QString::number(((STable *)m_pTabWidget->currentWidget())->getArticleSelect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapParam;
|
return mapParam;
|
||||||
|
|||||||
@@ -2110,7 +2110,7 @@ void YMOneDepthWidget::TestUpload()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
QSqlDatabase dbWeb = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase dbWeb = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
dbWeb.setHostName("db.big-bird.co.kr");
|
dbWeb.setHostName("db.big-bird.co.kr");
|
||||||
dbWeb.setUserName("concepters");
|
dbWeb.setUserName("concepters");
|
||||||
@@ -2141,7 +2141,7 @@ void YMOneDepthWidget::TestUpload()
|
|||||||
|
|
||||||
|
|
||||||
dbWeb.close();
|
dbWeb.close();
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2218,7 +2218,7 @@ QMap<QString, QString> YMOneDepthWidget::convertToParam()
|
|||||||
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mapParam.insert("Article",QString::number(((STable*)(((Widget*)(m_pTabWidget->currentWidget()))->GetTabWidget()->currentWidget()))->getArticleSelect()));
|
mapParam.insert("Article",QString::number(((STable *)m_pTabWidget->currentWidget())->getArticleSelect()));
|
||||||
}
|
}
|
||||||
return mapParam;
|
return mapParam;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3145,7 +3145,7 @@ QMap<QString, QString> YMPlatformWidget::convertToParam()
|
|||||||
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mapParam.insert("Article",QString::number(((STable*)(((Widget*)(m_pTabWidget->currentWidget()))->GetTabWidget()->currentWidget()))->getArticleSelect()));
|
mapParam.insert("Article",QString::number(((STable *)m_pTabWidget->currentWidget())->getArticleSelect()));
|
||||||
}
|
}
|
||||||
return mapParam;
|
return mapParam;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2682,7 +2682,7 @@ QMap<QString, QString> YMTwoDepthAWidget::convertToParam()
|
|||||||
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mapParam.insert("Article",QString::number(((STable*)(((Widget*)(m_pTabWidget->currentWidget()))->GetTabWidget()->currentWidget()))->getArticleSelect()));
|
mapParam.insert("Article",QString::number(((STable *)m_pTabWidget->currentWidget())->getArticleSelect()));
|
||||||
}
|
}
|
||||||
return mapParam;
|
return mapParam;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2554,7 +2554,7 @@ QMap<QString, QString> YMTwoDepthWidget::convertToParam()
|
|||||||
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mapParam.insert("Article",QString::number(((STable*)(((Widget*)(m_pTabWidget->currentWidget()))->GetTabWidget()->currentWidget()))->getArticleSelect()));
|
mapParam.insert("Article",QString::number(((STable *)m_pTabWidget->currentWidget())->getArticleSelect()));
|
||||||
}
|
}
|
||||||
return mapParam;
|
return mapParam;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ QGroupBox *YMUploadWidget::setUploadWidgets()
|
|||||||
|
|
||||||
void YMUploadWidget::MorphereGroupInsert()
|
void YMUploadWidget::MorphereGroupInsert()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
db.setHostName("bigbird.iptime.org");
|
db.setHostName("bigbird.iptime.org");
|
||||||
@@ -107,17 +108,22 @@ void YMUploadWidget::MorphereGroupInsert()
|
|||||||
qDebug() << db.lastError().text();
|
qDebug() << db.lastError().text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
QString strQuery = QString("insert into morpheregroup set "
|
QString strQuery = QString("insert into morpheregroup set "
|
||||||
"name = '" + m_pleMorphereGroup->text() + "'");
|
"name = '" + m_pleMorphereGroup->text() + "'");
|
||||||
|
QSqlQuery query(strQuery);
|
||||||
|
|
||||||
|
/*
|
||||||
db.exec(strQuery.toUtf8());
|
db.exec(strQuery.toUtf8());
|
||||||
db.close();
|
db.close();
|
||||||
|
*/
|
||||||
|
query.exec();
|
||||||
MorphereGroupRefresh();
|
MorphereGroupRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YMUploadWidget::MorphereGroupDelete()
|
void YMUploadWidget::MorphereGroupDelete()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
db.setHostName("bigbird.iptime.org");
|
db.setHostName("bigbird.iptime.org");
|
||||||
db.setUserName("admin");
|
db.setUserName("admin");
|
||||||
@@ -130,6 +136,8 @@ void YMUploadWidget::MorphereGroupDelete()
|
|||||||
qDebug() << db.lastError().text();
|
qDebug() << db.lastError().text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||||
{
|
{
|
||||||
QString strQuery = QString("delete from morpheregroup where id = " + item->data(Qt::UserRole).toString());
|
QString strQuery = QString("delete from morpheregroup where id = " + item->data(Qt::UserRole).toString());
|
||||||
@@ -139,12 +147,22 @@ void YMUploadWidget::MorphereGroupDelete()
|
|||||||
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
||||||
}
|
}
|
||||||
db.close();
|
db.close();
|
||||||
|
*/
|
||||||
|
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||||
|
{
|
||||||
|
QString strQuery = QString("delete from morpheregroup where id = " + item->data(Qt::UserRole).toString());
|
||||||
|
QSqlQuery query;
|
||||||
|
query.exec(strQuery);
|
||||||
|
strQuery = QString("delete from morphere where morpheregroup_id = " + item->data(Qt::UserRole).toString());
|
||||||
|
query.exec(strQuery);
|
||||||
|
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
||||||
|
}
|
||||||
MorphereGroupRefresh();
|
MorphereGroupRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YMUploadWidget::MorphereGroupModify()
|
void YMUploadWidget::MorphereGroupModify()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
db.setHostName("bigbird.iptime.org");
|
db.setHostName("bigbird.iptime.org");
|
||||||
db.setUserName("admin");
|
db.setUserName("admin");
|
||||||
@@ -156,6 +174,7 @@ void YMUploadWidget::MorphereGroupModify()
|
|||||||
qDebug() << db.lastError().text();
|
qDebug() << db.lastError().text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||||
{
|
{
|
||||||
QString strQuery = QString("update morpheregroup set name = '" + m_pleMorphereGroup->text() + "' where id = " + item->data(Qt::UserRole).toString());
|
QString strQuery = QString("update morpheregroup set name = '" + m_pleMorphereGroup->text() + "' where id = " + item->data(Qt::UserRole).toString());
|
||||||
@@ -163,12 +182,19 @@ void YMUploadWidget::MorphereGroupModify()
|
|||||||
db.exec(strQuery.toUtf8());
|
db.exec(strQuery.toUtf8());
|
||||||
}
|
}
|
||||||
db.close();
|
db.close();
|
||||||
|
*/
|
||||||
|
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||||
|
{
|
||||||
|
QString strQuery = QString("update morpheregroup set name = '" + m_pleMorphereGroup->text() + "' where id = " + item->data(Qt::UserRole).toString());
|
||||||
|
QSqlQuery query;
|
||||||
|
query.exec(strQuery);
|
||||||
|
}
|
||||||
MorphereGroupRefresh();
|
MorphereGroupRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YMUploadWidget::MorphereGroupCopyPaste()
|
void YMUploadWidget::MorphereGroupCopyPaste()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
db.setHostName("bigbird.iptime.org");
|
db.setHostName("bigbird.iptime.org");
|
||||||
db.setUserName("admin");
|
db.setUserName("admin");
|
||||||
@@ -181,6 +207,7 @@ void YMUploadWidget::MorphereGroupCopyPaste()
|
|||||||
qDebug() << db.lastError().text();
|
qDebug() << db.lastError().text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
@@ -197,14 +224,14 @@ void YMUploadWidget::MorphereGroupCopyPaste()
|
|||||||
query.exec(strQuery.toUtf8());
|
query.exec(strQuery.toUtf8());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.close();
|
// db.close();
|
||||||
MorphereGroupRefresh();
|
MorphereGroupRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void YMUploadWidget::MorphereGroupRefresh()
|
void YMUploadWidget::MorphereGroupRefresh()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
db.setHostName("bigbird.iptime.org");
|
db.setHostName("bigbird.iptime.org");
|
||||||
db.setUserName("admin");
|
db.setUserName("admin");
|
||||||
@@ -217,6 +244,7 @@ void YMUploadWidget::MorphereGroupRefresh()
|
|||||||
qDebug() << db.lastError().text();
|
qDebug() << db.lastError().text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
m_plwMorphereGroup->clear();
|
m_plwMorphereGroup->clear();
|
||||||
QSqlQuery query("select id,name from morpheregroup");
|
QSqlQuery query("select id,name from morpheregroup");
|
||||||
while (query.next())
|
while (query.next())
|
||||||
@@ -224,13 +252,13 @@ void YMUploadWidget::MorphereGroupRefresh()
|
|||||||
QListWidgetItem *pItem = new QListWidgetItem(query.value(1).toString(),m_plwMorphereGroup);
|
QListWidgetItem *pItem = new QListWidgetItem(query.value(1).toString(),m_plwMorphereGroup);
|
||||||
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||||
}
|
}
|
||||||
db.close();
|
//db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void YMUploadWidget::RefreshMorphere(int _nGroup)
|
void YMUploadWidget::RefreshMorphere(int _nGroup)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
db.setHostName("bigbird.iptime.org");
|
db.setHostName("bigbird.iptime.org");
|
||||||
db.setUserName("admin");
|
db.setUserName("admin");
|
||||||
@@ -243,6 +271,7 @@ void YMUploadWidget::RefreshMorphere(int _nGroup)
|
|||||||
qDebug() << db.lastError().text();
|
qDebug() << db.lastError().text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
QSqlQuery query("select id,type,data from morphere where morpheregroup_id = " + QString::number(_nGroup));
|
QSqlQuery query("select id,type,data from morphere where morpheregroup_id = " + QString::number(_nGroup));
|
||||||
|
|
||||||
SJson json;
|
SJson json;
|
||||||
@@ -266,7 +295,7 @@ void YMUploadWidget::RefreshMorphere(int _nGroup)
|
|||||||
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwMorphere);
|
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwMorphere);
|
||||||
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||||
}
|
}
|
||||||
db.close();
|
//db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -283,7 +312,7 @@ void YMUploadWidget::currentGroupItemChanged(QListWidgetItem *_pCurrent, QListWi
|
|||||||
|
|
||||||
void YMUploadWidget::MorphereDelete()
|
void YMUploadWidget::MorphereDelete()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
db.setHostName("bigbird.iptime.org");
|
db.setHostName("bigbird.iptime.org");
|
||||||
db.setUserName("admin");
|
db.setUserName("admin");
|
||||||
@@ -296,12 +325,15 @@ void YMUploadWidget::MorphereDelete()
|
|||||||
qDebug() << db.lastError().text();
|
qDebug() << db.lastError().text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
foreach (QListWidgetItem *item,m_plwMorphere->selectedItems())
|
foreach (QListWidgetItem *item,m_plwMorphere->selectedItems())
|
||||||
{
|
{
|
||||||
QString strQuery = QString("delete from morphere where id = '" + item->data(Qt::UserRole).toString() + "'");
|
QString strQuery = QString("delete from morphere where id = '" + item->data(Qt::UserRole).toString() + "'");
|
||||||
db.exec(strQuery.toUtf8());
|
QSqlQuery query;
|
||||||
|
query.exec(strQuery);
|
||||||
|
//db.exec(strQuery.toUtf8());
|
||||||
}
|
}
|
||||||
db.close();
|
//db.close();
|
||||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||||
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
||||||
}
|
}
|
||||||
@@ -323,7 +355,7 @@ void YMUploadWidget::MorphereUp()
|
|||||||
{
|
{
|
||||||
int nSelect = m_plwMorphere->currentRow();
|
int nSelect = m_plwMorphere->currentRow();
|
||||||
if (nSelect <= 0) return;
|
if (nSelect <= 0) return;
|
||||||
|
/*
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
db.setHostName("bigbird.iptime.org");
|
db.setHostName("bigbird.iptime.org");
|
||||||
db.setUserName("admin");
|
db.setUserName("admin");
|
||||||
@@ -336,12 +368,14 @@ void YMUploadWidget::MorphereUp()
|
|||||||
qDebug() << db.lastError().text();
|
qDebug() << db.lastError().text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
QString strID1 = m_plwMorphere->item(nSelect)->data(Qt::UserRole).toString();
|
QString strID1 = m_plwMorphere->item(nSelect)->data(Qt::UserRole).toString();
|
||||||
QString strID2 = m_plwMorphere->item(nSelect-1)->data(Qt::UserRole).toString();
|
QString strID2 = m_plwMorphere->item(nSelect-1)->data(Qt::UserRole).toString();
|
||||||
QString strQuery = "UPDATE morphere t1 INNER JOIN Morphere t2 ON (t1.id, t2.id) IN ((" + strID1 + ","+ strID2 +"),("+ strID2 + "," + strID1 + ")) SET t1.type = t2.type,t1.morpheregroup_id = t2.morpheregroup_id,t1.data = t2.data";
|
QString strQuery = "UPDATE morphere t1 INNER JOIN Morphere t2 ON (t1.id, t2.id) IN ((" + strID1 + ","+ strID2 +"),("+ strID2 + "," + strID1 + ")) SET t1.type = t2.type,t1.morpheregroup_id = t2.morpheregroup_id,t1.data = t2.data";
|
||||||
db.exec(strQuery.toUtf8());
|
QSqlQuery query;
|
||||||
db.close();
|
query.exec(strQuery);
|
||||||
|
//db.exec(strQuery.toUtf8());
|
||||||
|
//db.close();
|
||||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||||
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
||||||
|
|
||||||
@@ -354,7 +388,7 @@ void YMUploadWidget::MorphereDown()
|
|||||||
if (nSelect < 0) return;
|
if (nSelect < 0) return;
|
||||||
if (nSelect >= (m_plwMorphere->count() - 1)) return;
|
if (nSelect >= (m_plwMorphere->count() - 1)) return;
|
||||||
qDebug() << nSelect;
|
qDebug() << nSelect;
|
||||||
|
/*
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
db.setHostName("bigbird.iptime.org");
|
db.setHostName("bigbird.iptime.org");
|
||||||
db.setUserName("admin");
|
db.setUserName("admin");
|
||||||
@@ -367,11 +401,14 @@ void YMUploadWidget::MorphereDown()
|
|||||||
qDebug() << db.lastError().text();
|
qDebug() << db.lastError().text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
QString strID1 = m_plwMorphere->item(nSelect)->data(Qt::UserRole).toString();
|
QString strID1 = m_plwMorphere->item(nSelect)->data(Qt::UserRole).toString();
|
||||||
QString strID2 = m_plwMorphere->item(nSelect+1)->data(Qt::UserRole).toString();
|
QString strID2 = m_plwMorphere->item(nSelect+1)->data(Qt::UserRole).toString();
|
||||||
QString strQuery = "UPDATE morphere t1 INNER JOIN morphere t2 ON (t1.id, t2.id) IN ((" + strID1 + ","+ strID2 +"),("+ strID2 + "," + strID1 + ")) SET t1.type = t2.type,t1.morpheregroup_id = t2.morpheregroup_id,t1.data = t2.data";
|
QString strQuery = "UPDATE morphere t1 INNER JOIN morphere t2 ON (t1.id, t2.id) IN ((" + strID1 + ","+ strID2 +"),("+ strID2 + "," + strID1 + ")) SET t1.type = t2.type,t1.morpheregroup_id = t2.morpheregroup_id,t1.data = t2.data";
|
||||||
db.exec(strQuery.toUtf8());
|
QSqlQuery query;
|
||||||
db.close();
|
query.exec(strQuery.toUtf8());
|
||||||
|
//db.exec(strQuery.toUtf8());
|
||||||
|
//db.close();
|
||||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||||
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
||||||
|
|
||||||
@@ -394,7 +431,7 @@ void YMUploadWidget::DataBaseMorphereMorphere(int _nArticle,QMap<QString, QStrin
|
|||||||
|
|
||||||
void YMUploadWidget::DataBaseMorphere(int _nType, QString _strJson,int _nGroup,int _nCommand,QString _strFilterId)
|
void YMUploadWidget::DataBaseMorphere(int _nType, QString _strJson,int _nGroup,int _nCommand,QString _strFilterId)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
db.setHostName("bigbird.iptime.org");
|
db.setHostName("bigbird.iptime.org");
|
||||||
db.setUserName("admin");
|
db.setUserName("admin");
|
||||||
@@ -408,7 +445,7 @@ void YMUploadWidget::DataBaseMorphere(int _nType, QString _strJson,int _nGroup,i
|
|||||||
qDebug() << db.lastError().text();
|
qDebug() << db.lastError().text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
QString sql;
|
QString sql;
|
||||||
switch(_nCommand)
|
switch(_nCommand)
|
||||||
{
|
{
|
||||||
@@ -430,7 +467,7 @@ void YMUploadWidget::DataBaseMorphere(int _nType, QString _strJson,int _nGroup,i
|
|||||||
qDebug() << sql;
|
qDebug() << sql;
|
||||||
qDebug() << query.lastError().text();
|
qDebug() << query.lastError().text();
|
||||||
}
|
}
|
||||||
db.close();
|
// db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -438,7 +475,7 @@ void YMUploadWidget::currentMorphereItemChanged(QListWidgetItem *_pCurrent, QLis
|
|||||||
{
|
{
|
||||||
Q_UNUSED(_pPrev);
|
Q_UNUSED(_pPrev);
|
||||||
if (_pCurrent == 0) return;
|
if (_pCurrent == 0) return;
|
||||||
|
/*
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||||
db.setHostName("bigbird.iptime.org");
|
db.setHostName("bigbird.iptime.org");
|
||||||
db.setUserName("admin");
|
db.setUserName("admin");
|
||||||
@@ -452,6 +489,7 @@ void YMUploadWidget::currentMorphereItemChanged(QListWidgetItem *_pCurrent, QLis
|
|||||||
qDebug() << db.lastError().text();
|
qDebug() << db.lastError().text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
QSqlQuery query("select id,type,data from morphere where id = " + _pCurrent->data(Qt::UserRole).toString());
|
QSqlQuery query("select id,type,data from morphere where id = " + _pCurrent->data(Qt::UserRole).toString());
|
||||||
if (!query.next()) return;
|
if (!query.next()) return;
|
||||||
SJson json;
|
SJson json;
|
||||||
|
|||||||
Reference in New Issue
Block a user