filter와 같이 웹에 파라미터 업로드 하는 작업 구현

2depth 구현
파라미터 입력방식 변경


git-svn-id: svn://192.168.0.12/source@172 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
admin
2015-08-12 02:17:11 +00:00
parent ecd221e60a
commit d28d4ae562
20 changed files with 1807 additions and 382 deletions

View File

@@ -4,7 +4,7 @@
#
#-------------------------------------------------
QT += core gui sql
QT += core gui sql webkitwidgets network webkit
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
@@ -33,8 +33,8 @@ SOURCES += main.cpp\
ymnxnmatrixwidget.cpp \
ymfilter.cpp \
ymfilterchildren.cpp \
ymupload.cpp \
ymtwodepthwidget.cpp
ymtwodepthwidget.cpp \
ymuploadwidget.cpp
HEADERS += mainwindow.h \
@@ -86,8 +86,8 @@ HEADERS += mainwindow.h \
ymnxnmatrixwidget.h \
ymfilter.h \
ymfilterchildren.h \
ymupload.h \
ymtwodepthwidget.h
ymtwodepthwidget.h \
ymuploadwidget.h
FORMS += mainwindow.ui

View File

@@ -52,6 +52,9 @@
#include <QSqlDatabase>
#include <QSqlError>
#include "ymtwodepthwidget.h"
#include <QShortcut>
#include <QKeySequence>
#include <QUrl>
//! [0]
MainWindow::MainWindow()
{
@@ -66,13 +69,11 @@ MainWindow::MainWindow()
m_pYMBasicWidget = new YMBasicWidget;
m_pYMOneDepthWidget = new YMOneDepthWidget;
m_pYMTwoDepthWidget = new YMTwoDepthWidget;
m_pYMNxNMatrixWidget = new YMNxNMatrixWidget;
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");
@@ -81,6 +82,8 @@ MainWindow::MainWindow()
//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);
@@ -90,6 +93,16 @@ MainWindow::MainWindow()
m_ptwResult->addTab(m_pYMOneDepthWidget, "OneDepth");
m_ptwResult->addTab(m_pYMTwoDepthWidget, "TwoDepth");
m_ptwResult->addTab(m_pYMNxNMatrixWidget, "NxNMatrix");
m_pYMBasicWidget->setTabWidget(m_ptwSource);
m_pYMOneDepthWidget->setTabWidget(m_ptwSource);
m_pYMTwoDepthWidget->setTabWidget(m_ptwSource);
m_pYMNxNMatrixWidget->setTabWidget(m_ptwSource);
m_pUploadWidget->setResultTabWidget(m_ptwResult);
m_pUploadWidget->setSourceTabWidget(m_ptwSource);
QHBoxLayout *layout = new QHBoxLayout;
layout->setMargin(5);
@@ -105,7 +118,12 @@ MainWindow::MainWindow()
QString message = tr("A context menu is available by right-clicking");
statusBar()->showMessage(message);
//test = new QWebView(this);
actD3View = new QAction(tr("D3View"), this);
actD3View->setShortcut(Qt::Key_0 | Qt::CTRL);
connect(actD3View, SIGNAL(triggered()), this, SLOT(slotD3View()));
this->addAction(actD3View);
setWindowTitle(tr("Morphere Analyzer"));
setMinimumSize(800, 600);
@@ -153,9 +171,23 @@ void MainWindow::createActions()
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()));
}
void MainWindow::slotShowUpload()
{
m_pUploadWidget->show();
}
void MainWindow::slotD3View()
{
((YMorphereWidget*)(m_ptwResult->currentWidget()))->D3View();
//qDebug() << "hide the D3View";
}
void MainWindow::createMenus()
{
//! [9] //! [10]
@@ -186,6 +218,9 @@ void MainWindow::createMenus()
menuTestUpload = menuBar()->addMenu(tr("TestUpload"));
menuTestUpload->addAction(actTestUpload);
menuShowUpload = menuBar()->addMenu(tr("ShowUpload"));
menuShowUpload->addAction(actShowUpload);
}
//! [12]
@@ -232,15 +267,17 @@ void MainWindow::slotAnalyze()
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();
@@ -285,17 +322,14 @@ void MainWindow::slotAnalyze()
m_pYMNxNMatrixWidget->Exec(setbody);
}
*/
((YMorphereWidget*)(m_ptwResult->currentWidget()))->Exec(setbody);
((YMorphereWidget*)(m_ptwResult->currentWidget()))->Exec();
msg2.setVisible(false);
}
void MainWindow::slotTestUpload()
{
((YMorphereWidget*)(m_ptwResult->currentWidget()))->TestUpload();
}
void MainWindow::slotDictionary()
@@ -303,3 +337,9 @@ void MainWindow::slotDictionary()
p_qwDict->show();
p_qwDict->repaint();
}
void MainWindow::closeEvent(QCloseEvent *event)
{
QApplication::quit();
}

View File

@@ -50,7 +50,8 @@
#include <QList>
#include "sdictionary.h"
#include "tablealgorithm_interface.h"
#include <QCloseEvent>
#include "ymuploadwidget.h"
QT_BEGIN_NAMESPACE
class QAction;
@@ -81,8 +82,11 @@ private slots:
void slotDictionary();
void exportOriginalMorphere();
void slotTestUpload();
void slotD3View();
void slotShowUpload();
protected:
void closeEvent(QCloseEvent *);
//! [1]
@@ -106,6 +110,8 @@ private:
QWidget *p_qwAnalyzed1;
QWidget *p_qwText;
SDictionary *p_qwDict;
YMUploadWidget* m_pUploadWidget;
SAnaly1 *p_qwAnalyzer1;
SAnaly2 *p_qwAnalyzer2;
@@ -132,7 +138,10 @@ private:
QMenu *menuAnalyze;
QMenu *menuDictionary;
QMenu *menuTestUpload;
QMenu *menuShowUpload;
QAction *actD3View;
QAction *actShowUpload;
//AnalyzerThread m_pThread[16];
/*
QMutex mutex;
@@ -142,6 +151,9 @@ private:
*/
QTabWidget* m_ptwTable;
TableAlgorithmInterface* m_pTAInterface;
};
//! [3]

View File

@@ -1049,6 +1049,7 @@ void Widget::DataGroupItemChanged( 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);

View File

@@ -3,6 +3,7 @@
#include "mecab.h"
#include <QLibrary>
#include <QDate>
#include <QDateTime>
YMorphereThread* ThreadFactory::getThread(QMap<QString, QString> mapParam)
{
@@ -105,6 +106,7 @@ void YBasicMThread::run()
QString strDate;
QString strData;
QString strPlatformTitle;
QString strArticle;
{
mutex->lock();
if(!m_pDAInterface->hasNext())
@@ -116,9 +118,36 @@ void YBasicMThread::run()
strDate = m_pDAInterface->getArticleDate();
strPlatformTitle = m_pDAInterface->getPlatformTitle();
strBody = m_pDAInterface->getArticleData();
strArticle = m_pDAInterface->getArticleForm();
m_pDAInterface->next();
mutex->unlock();
}
//qDebug() << strArticle;
//qDebug() << m_nArticle;
bool bContinue = true;
{
switch(m_nArticle)
{
case 0:
break;
case 1:
{
if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) != 0)
bContinue = false;
break;
}
case 2:
{
if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) != 0)
bContinue = false;
break;
}
}
}
if(!bContinue)
continue;
{
switch(m_nTitleBody)
@@ -213,6 +242,8 @@ void YBasicMThread::run()
QString strAnalyzedLine = QString::fromStdString(mecab_sparse_tostr(mecab, strData.toStdString().c_str())) + "\n";
QStringList strListAll = strAnalyzedLine.split("\n",QString::SkipEmptyParts);
QMap<QString, int> mapResult;
foreach(QString strLine, strListAll)
{
QStringList strListLine = strLine.split("\t");
@@ -226,19 +257,40 @@ void YBasicMThread::run()
m_strKeyword = strListLine.at(0).toLower();
m_strMorphere = strMorphere;
QString strkey = m_strDate + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
if(m_mapResult.contains(strkey))
if(mapResult.contains(strkey))
{
(m_mapResult)[strkey]++;
(mapResult)[strkey]++;
}
else
{
m_mapResult.insert(strkey,1);
mapResult.insert(strkey,1);
}
}
}
}
if(!m_bDuplicate)
{
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
{
mapResult[iterPos.key()] = 1;
}
}
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
{
if(m_mapResult.contains(iterPos.key()))
{
m_mapResult[iterPos.key()] += iterPos.value();
}
else
{
m_mapResult.insert(iterPos.key(), iterPos.value());
}
}
//if(m_bDateAll)
//qDebug() << num << " : " << strData;
@@ -251,6 +303,7 @@ void YBasicMThread::run()
void YBasicMThread::parseParam()
{
userdict = m_mapParam.value("UserDict");
m_nArticle = m_mapParam.value("Article").toInt();
m_nTitleBody = m_mapParam.value("TitleBody").toInt();
m_nPeriod = m_mapParam.value("Period").toInt();
@@ -266,78 +319,61 @@ void YBasicMThread::parseParam()
m_bDateAll = false;
m_slMorphereList = m_mapParam.value("MorphereList").split(" ");
}
QString YBasicMThread::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;
}
if(m_mapParam.value("CountMethod") == "Duplicate")
m_bDuplicate = true;
else
m_bDuplicate = false;
m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed();
//qDebug() << m_strRecentPeriod;
if(m_strRecentPeriod == "None")
{
week = 0;
}
if((firstWeekDays < qToday.day()) && (qToday.day() <= (thisLastDay - thisLastDayofWeek)))
}
else if(m_strRecentPeriod == "Days")
{
week = week + ((qToday.day() - firstWeekDays + WEEK - 1)/WEEK);
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addDays(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
else if((firstWeekDays >= qToday.day()))
else if(m_strRecentPeriod == "Weeks")
{
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;
}
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addDays(-(nDate*7));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
else
else if(m_strRecentPeriod == "Months")
{
if(thisLastDayofWeek < THURSDAY)
{
week = 1;
qToday = qToday.addMonths(1);
}
else
{
week = week + ((qToday.day() - firstWeekDays + WEEK - 1)/WEEK);
}
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addMonths(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").replace("-","").trimmed().toInt();
m_bDateAll = false;
}
else if(m_strRecentPeriod == "Years")
{
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addYears(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
strWeek += qToday.toString("yyyyMM");
strWeek += QString::number(week);
return strWeek;
}
@@ -409,6 +445,7 @@ void YOneDepthMThread::run()
QString strDate;
QString strData;
QString strPlatformTitle;
QString strArticle;
{
mutex->lock();
if(!m_pDAInterface->hasNext())
@@ -420,10 +457,37 @@ void YOneDepthMThread::run()
strDate = m_pDAInterface->getArticleDate();
strPlatformTitle = m_pDAInterface->getPlatformTitle();
strBody = m_pDAInterface->getArticleData();
strArticle = m_pDAInterface->getArticleForm();
m_pDAInterface->next();
mutex->unlock();
}
bool bContinue = true;
{
switch(m_nArticle)
{
case 0:
break;
case 1:
{
if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) == 0)
bContinue = false;
break;
}
case 2:
{
if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) == 0)
bContinue = false;
break;
}
}
}
if(!bContinue)
continue;
{
switch(m_nTitleBody)
{
@@ -520,6 +584,7 @@ void YOneDepthMThread::run()
QString strAnalyzedLine = QString::fromStdString(mecab_sparse_tostr(mecab, strData.toStdString().c_str())) + "\n";
QStringList strListAll = strAnalyzedLine.split("\n",QString::SkipEmptyParts);
QMap<QString, int> mapResult;
foreach(QString strLine, strListAll)
{
@@ -534,19 +599,41 @@ void YOneDepthMThread::run()
m_strKeyword = strListLine.at(0).toLower();
m_strMorphere = strMorphere;
QString strkey = m_strDate + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
if(m_mapResult.contains(strkey))
if(mapResult.contains(strkey))
{
(m_mapResult)[strkey]++;
(mapResult)[strkey]++;
}
else
{
m_mapResult.insert(strkey,1);
mapResult.insert(strkey,1);
}
}
}
}
if(!m_bDuplicate)
{
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
{
mapResult[iterPos.key()] = 1;
}
}
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
{
if(m_mapResult.contains(iterPos.key()))
{
m_mapResult[iterPos.key()] += iterPos.value();
}
else
{
m_mapResult.insert(iterPos.key(), iterPos.value());
}
}
//if(m_bDateAll)
//qDebug() << num << " : " << strData;
@@ -561,6 +648,8 @@ void YOneDepthMThread::parseParam()
userdict = m_mapParam.value("UserDict");
m_nArticle = m_mapParam.value("Article").toInt();
m_nTitleBody = m_mapParam.value("TitleBody").toInt();
m_nPeriod = m_mapParam.value("Period").toInt();
@@ -577,81 +666,60 @@ void YOneDepthMThread::parseParam()
m_slMorphereList = m_mapParam.value("MorphereList").split(" ");
m_strCKeyword = m_mapParam.value("CenterKeyword").trimmed();
}
QString YOneDepthMThread::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;
}
if(m_mapParam.value("CountMethod") == "Duplicate")
m_bDuplicate = true;
else
m_bDuplicate = false;
m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed();
if(m_strRecentPeriod == "None")
{
week = 0;
}
if((firstWeekDays < qToday.day()) && (qToday.day() <= (thisLastDay - thisLastDayofWeek)))
}
else if(m_strRecentPeriod == "Days")
{
week = week + ((qToday.day() - firstWeekDays + WEEK - 1)/WEEK);
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addDays(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
else if((firstWeekDays >= qToday.day()))
else if(m_strRecentPeriod == "Weeks")
{
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;
}
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addDays(-(nDate*7));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
else
else if(m_strRecentPeriod == "Months")
{
if(thisLastDayofWeek < THURSDAY)
{
week = 1;
qToday = qToday.addMonths(1);
}
else
{
week = week + ((qToday.day() - firstWeekDays + WEEK - 1)/WEEK);
}
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addMonths(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
else if(m_strRecentPeriod == "Years")
{
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addYears(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
strWeek += qToday.toString("yyyyMM");
strWeek += QString::number(week);
return strWeek;
}
void YTwoDepthMThread::run()
{
typedef mecab_t* (*mecab_new_fun)(int,char**);
@@ -720,6 +788,7 @@ void YTwoDepthMThread::run()
QString strDate;
QString strData;
QString strPlatformTitle;
QString strArticle;
{
mutex->lock();
if(!m_pDAInterface->hasNext())
@@ -731,10 +800,36 @@ void YTwoDepthMThread::run()
strDate = m_pDAInterface->getArticleDate();
strPlatformTitle = m_pDAInterface->getPlatformTitle();
strBody = m_pDAInterface->getArticleData();
strArticle = m_pDAInterface->getArticleForm();
m_pDAInterface->next();
mutex->unlock();
}
bool bContinue = true;
{
switch(m_nArticle)
{
case 0:
break;
case 1:
{
if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) == 0)
bContinue = false;
break;
}
case 2:
{
if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) == 0)
bContinue = false;
break;
}
}
}
if(!bContinue)
continue;
{
switch(m_nTitleBody)
{
@@ -832,7 +927,7 @@ void YTwoDepthMThread::run()
QString strAnalyzedLine = QString::fromStdString(mecab_sparse_tostr(mecab, strData.toStdString().c_str())) + "\n";
QStringList strListAll = strAnalyzedLine.split("\n",QString::SkipEmptyParts);
QMap<QString, int> tempResult;
QMap<QString, int> mapResult;
foreach(QString strLine, strListAll)
{
@@ -847,24 +942,34 @@ void YTwoDepthMThread::run()
m_strKeyword = strListLine.at(0).toLower();
m_strMorphere = strMorphere;
QString strkey = m_strDate + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
if(tempResult.contains(strkey))
if(mapResult.contains(strkey))
{
(tempResult)[strkey]++;
(mapResult)[strkey]++;
}
else
{
tempResult.insert(strkey,1);
mapResult.insert(strkey,1);
}
}
}
}
if(!m_bDuplicate)
{
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
{
mapResult[iterPos.key()] = 1;
}
}
foreach(QString str, m_slOneDepthKeys)
{
if(tempResult.contains(str))
if(mapResult.contains(str))
{
for(QMap<QString, int>::iterator iterPos = tempResult.begin(); iterPos != tempResult.end(); iterPos++)
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
{
if(iterPos.key() == str)
continue;
@@ -891,6 +996,8 @@ void YTwoDepthMThread::parseParam()
{
userdict = m_mapParam.value("UserDict");
m_nArticle = m_mapParam.value("Article").toInt();
m_nTitleBody = m_mapParam.value("TitleBody").toInt();
m_nPeriod = m_mapParam.value("Period").toInt();
@@ -909,77 +1016,58 @@ void YTwoDepthMThread::parseParam()
m_strCKeyword = m_mapParam.value("CenterKeyword").trimmed();
m_slOneDepthKeys = m_mapParam.value("OneDepthKeys").split(" ");
}
QString YTwoDepthMThread::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;
}
if(m_mapParam.value("CountMethod") == "Duplicate")
m_bDuplicate = true;
else
{
week = 0;
}
m_bDuplicate = false;
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);
m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed();
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(m_strRecentPeriod == "None")
{
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;
}
else if(m_strRecentPeriod == "Days")
{
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addDays(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
else if(m_strRecentPeriod == "Weeks")
{
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addDays(-(nDate*7));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
else if(m_strRecentPeriod == "Months")
{
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addMonths(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
else if(m_strRecentPeriod == "Years")
{
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addYears(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
}
@@ -1020,6 +1108,7 @@ void YNNMatrixMThread::run()
QString strDate;
QString strData;
QString strPlatformTitle;
QString strArticle;
{
mutex->lock();
if(!m_pDAInterface->hasNext())
@@ -1031,10 +1120,35 @@ void YNNMatrixMThread::run()
strDate = m_pDAInterface->getArticleDate();
strPlatformTitle = m_pDAInterface->getPlatformTitle();
strBody = m_pDAInterface->getArticleData();
strArticle = m_pDAInterface->getArticleForm();
m_pDAInterface->next();
mutex->unlock();
}
bool bContinue = true;
{
switch(m_nArticle)
{
case 0:
break;
case 1:
{
if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) == 0)
bContinue = false;
break;
}
case 2:
{
if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) == 0)
bContinue = false;
break;
}
}
}
if(!bContinue)
continue;
{
switch(m_nTitleBody)
{
@@ -1175,6 +1289,8 @@ void YNNMatrixMThread::parseParam()
{
userdict = m_mapParam.value("UserDict");
m_nArticle = m_mapParam.value("Article").toInt();
m_nTitleBody = m_mapParam.value("TitleBody").toInt();
m_nPeriod = m_mapParam.value("Period").toInt();
@@ -1196,78 +1312,53 @@ void YNNMatrixMThread::parseParam()
else
m_bDuplicate = false;
m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed();
if(m_strRecentPeriod == "None")
{
}
else if(m_strRecentPeriod == "Days")
{
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addDays(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
else if(m_strRecentPeriod == "Weeks")
{
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addDays(-(nDate*7));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
else if(m_strRecentPeriod == "Months")
{
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addMonths(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
else if(m_strRecentPeriod == "Years")
{
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
QDateTime today = QDateTime::currentDateTime();
QDateTime startday = today.addYears(-(nDate));
startday = startday.addDays(1);
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
m_bDateAll = false;
}
}
QString YNNMatrixMThread::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;
}

View File

@@ -12,21 +12,7 @@ class YBasicMThread:public YMorphereThread
{
Q_OBJECT
private:
QString getWeeksInMonth(unsigned int _nDate);
enum {
MONDAY = 1,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY,
SUNDAY
};
enum
{
WEEK = 7
};
//QString getWeeksInMonth(unsigned int _nDate);
QString userdict;
@@ -36,9 +22,9 @@ private:
unsigned int m_nDateEnd;
bool m_bDateAll;
QStringList m_slMorphereList;
bool m_bDuplicate;
QString m_strRecentPeriod;
int m_nArticle;
protected:
void run();
@@ -52,21 +38,8 @@ class YOneDepthMThread:public YMorphereThread
Q_OBJECT
private:
QString getWeeksInMonth(unsigned int _nDate);
enum {
MONDAY = 1,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY,
SUNDAY
};
//QString getWeeksInMonth(unsigned int _nDate);
enum
{
WEEK = 7
};
QString userdict;
@@ -77,6 +50,9 @@ private:
bool m_bDateAll;
QStringList m_slMorphereList;
QString m_strCKeyword;
bool m_bDuplicate;
QString m_strRecentPeriod;
int m_nArticle;
protected:
void run();
public:
@@ -87,21 +63,8 @@ class YTwoDepthMThread:public YMorphereThread
{
Q_OBJECT
private:
QString getWeeksInMonth(unsigned int _nDate);
enum {
MONDAY = 1,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY,
SUNDAY
};
//QString getWeeksInMonth(unsigned int _nDate);
enum
{
WEEK = 7
};
QString userdict;
@@ -113,7 +76,9 @@ private:
QStringList m_slMorphereList;
QString m_strCKeyword;
QStringList m_slOneDepthKeys;
bool m_bDuplicate;
QString m_strRecentPeriod;
int m_nArticle;
protected:
void run();
@@ -145,21 +110,7 @@ class YNNMatrixMThread:public YMorphereThread
Q_OBJECT
private:
QString getWeeksInMonth(unsigned int _nDate);
enum {
MONDAY = 1,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY,
SUNDAY
};
enum
{
WEEK = 7
};
//QString getWeeksInMonth(unsigned int _nDate);
QString userdict;
@@ -170,6 +121,8 @@ private:
bool m_bDateAll;
QStringList m_strMKeyword;
bool m_bDuplicate;
QString m_strRecentPeriod;
int m_nArticle;
protected:
void run();

View File

@@ -37,18 +37,23 @@ YMBasicWidget::YMBasicWidget(QWidget *parent)
QGroupBox *gBox = setMorphereList();
QGroupBox *gDate = setDate();
QGroupBox *gData = setData();
QGroupBox *gFilter = setFilter();
QGroupBox *gOther = setOther();
QGroupBox *gSort = setSort();
QHBoxLayout *hboxlayout = new QHBoxLayout;
QGroupBox *gDictionary = setDictionary();
QGroupBox *gCountMethod = setCountMethod();
hboxlayout->addWidget(gBox,5);
vboxlayout->addWidget(gData,3);
vboxlayout->addWidget(gDate,3);
//vboxlayout->addWidget(gFilter,3);
vboxlayout->addWidget(gSort,2);
vboxlayout->addWidget(gOther,2);
vboxlayout->addWidget(gDictionary,2);
vboxlayout->addWidget(gCountMethod,2);
hboxlayout->addLayout(vboxlayout,5);
vMainLayout->addLayout(hboxlayout, 2);
@@ -121,6 +126,7 @@ QGroupBox *YMBasicWidget::setDate()
{
QHBoxLayout *hlayout = new QHBoxLayout;
QHBoxLayout *hlayout1 = new QHBoxLayout;
QHBoxLayout *hlayout2 = new QHBoxLayout;
QVBoxLayout *vlayout = new QVBoxLayout;
QGroupBox *groupBox = new QGroupBox(tr("Date"));
@@ -144,6 +150,13 @@ QGroupBox *YMBasicWidget::setDate()
m_pcbPeriod = new QComboBox;
m_pcbPeriod->addItems(QStringList() << "None" << "1 Day" << "1 Week" << "1 Month");
m_pleDates = new QLineEdit;
m_pleDates->setValidator(new QIntValidator(1, 100));
m_pcbDuring = new QComboBox;
m_pcbDuring->addItems(QStringList() << "None" << "Days" << "Weeks" << "Months" << "Years");
hlayout->addWidget(m_pcbDate);
hlayout->addWidget(new QLabel("Start:"));
hlayout->addWidget(m_pdeStart);
@@ -153,11 +166,14 @@ QGroupBox *YMBasicWidget::setDate()
hlayout1->addWidget(new QLabel("Period:"));
hlayout1->addWidget(m_pcbPeriod);
hlayout2->addWidget(new QLabel("Recent:"));
hlayout2->addWidget(m_pleDates);
hlayout2->addWidget(m_pcbDuring);
vlayout->addLayout(hlayout2);
vlayout->addLayout(hlayout);
vlayout->addLayout(hlayout1);
vlayout->addLayout(hlayout);
vlayout->addLayout(hlayout1);
groupBox->setCheckable(true);
groupBox->setLayout(vlayout);
@@ -165,6 +181,48 @@ QGroupBox *YMBasicWidget::setDate()
return groupBox;
}
QGroupBox *YMBasicWidget::setData()
{
QHBoxLayout *hlayout = new QHBoxLayout;
m_pcbData = new QComboBox;
m_pcbData->addItems(QStringList() << "Title" << "Body" << "Title+Body" << "PlatformTitle");
m_pcbData->setCurrentIndex(2);
hlayout->addWidget(new QLabel("Data: "));
hlayout->addWidget(m_pcbData);
QGroupBox *groupBox = new QGroupBox(tr("Data"));
groupBox->setCheckable(true);
groupBox->setLayout(hlayout);
groupBox->setChecked(true);
return groupBox;
}
QGroupBox *YMBasicWidget::setCountMethod()
{
QHBoxLayout *hlayout = new QHBoxLayout;
m_pcbCountMethod = new QComboBox;
m_pcbCountMethod->addItems(QStringList() << "Duplicate" << "NonDuplicate");
hlayout->addWidget(new QLabel("CountMethod: "));
hlayout->addWidget(m_pcbCountMethod);
QGroupBox *groupBox = new QGroupBox(tr("CountMethod"));
groupBox->setCheckable(true);
groupBox->setLayout(hlayout);
groupBox->setChecked(true);
return groupBox;
}
QGroupBox *YMBasicWidget::setFilter()
{
QHBoxLayout *hlayout = new QHBoxLayout;
@@ -457,6 +515,7 @@ void YMBasicWidget::SaveFile()
}
file.close();
*/
FileExport();
}
@@ -585,6 +644,13 @@ bool YMBasicWidget::setListMorphere(QStringList& MorphereEN, QStringList& Morphe
}
void YMBasicWidget::SaveFileSimple()
{
RawFileExport();
}
void YMBasicWidget::RawFileExport()
{
QString strFilename = QFileDialog::getSaveFileName(0,"Exoprt file",QDir::currentPath(),
@@ -800,6 +866,20 @@ QMap<QString, QString> YMBasicWidget::convertToParam()
{
mapParam.insert("Period", QString::number(getPeriod()));
}
{
mapParam.insert("CountMethod", m_pcbCountMethod->currentText().trimmed());
}
{
mapParam.insert("RecentDate", m_pleDates->text().trimmed());
mapParam.insert("RecentPeriod", m_pcbDuring->currentText().trimmed());
}
{
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
}
{
mapParam.insert("Article",QString::number(((STable*)(((Widget*)(m_pTabWidget->currentWidget()))->GetTabWidget()->currentWidget()))->getArticleSelect()));
}
return mapParam;
}

View File

@@ -39,6 +39,7 @@ public:
bool getDateAll();
QString getUserDictList();
void SaveFile();
void SaveFileSimple();
private:
// Data
@@ -47,6 +48,8 @@ private:
QCalendarWidget *m_pcw;
QDateEdit *m_pdeStart;
QDateEdit *m_pdeEnd;
QLineEdit *m_pleDates;
QComboBox *m_pcbDuring;
//QPushButton *m_ppbInsertCalc;
//QComboBox *m_pcbDateCatalog;
//
@@ -82,6 +85,9 @@ private:
QTabWidget* m_ptwTable;
QMap<QString, QMap<QString, QMap<int, QString> > > m_mapViewResult;
QComboBox *m_pcbCountMethod;
QComboBox* m_pcbData;
public:
@@ -97,10 +103,12 @@ public:
private:
QGroupBox *setMorphereList();
QGroupBox *setDate();
QGroupBox *setData();
QGroupBox *setFilter();
QGroupBox *setOther();
QGroupBox *setSort();
QGroupBox *setDictionary();
QGroupBox *setCountMethod();
void SortViewResult();

View File

@@ -34,8 +34,9 @@ YMNxNMatrixWidget::YMNxNMatrixWidget(QWidget *parent)
QVBoxLayout *vMainLayout = new QVBoxLayout;
vMainLayout->setAlignment(Qt::AlignVCenter);
QVBoxLayout *vboxlayout = new QVBoxLayout;
QGroupBox *gData = setData();
QGroupBox *gBox = setMorphereList();
QGroupBox *gDate = setDate();
QGroupBox *gFilter = setFilter();
QGroupBox *gOther = setOther();
@@ -45,12 +46,13 @@ YMNxNMatrixWidget::YMNxNMatrixWidget(QWidget *parent)
QGroupBox *gMatrixKeyword = setMatrixKeyword();
//hboxlayout->addWidget(gBox,5);
vboxlayout->addWidget(gData,3);
vboxlayout->addWidget(gDate,3);
//vboxlayout->addWidget(gFilter,3);
//vboxlayout->addWidget(gSort,2);
vboxlayout->addWidget(gOther,2);
vboxlayout->addWidget(gDictionary,2);
// vboxlayout->addWidget(gDictionary,2);
hboxlayout->addLayout(vboxlayout,5);
vMainLayout->addWidget(gMatrixKeyword, 1);
@@ -126,6 +128,7 @@ QGroupBox *YMNxNMatrixWidget::setDate()
{
QHBoxLayout *hlayout = new QHBoxLayout;
QHBoxLayout *hlayout1 = new QHBoxLayout;
QHBoxLayout *hlayout2 = new QHBoxLayout;
QVBoxLayout *vlayout = new QVBoxLayout;
QGroupBox *groupBox = new QGroupBox(tr("Date"));
@@ -149,6 +152,13 @@ QGroupBox *YMNxNMatrixWidget::setDate()
m_pcbPeriod = new QComboBox;
m_pcbPeriod->addItems(QStringList() << "None" << "1 Day" << "1 Week" << "1 Month");
m_pleDates = new QLineEdit;
m_pleDates->setValidator(new QIntValidator(1, 100));
m_pcbDuring = new QComboBox;
m_pcbDuring->addItems(QStringList() << "None" << "Days" << "Weeks" << "Months" << "Years");
hlayout->addWidget(m_pcbDate);
hlayout->addWidget(new QLabel("Start:"));
hlayout->addWidget(m_pdeStart);
@@ -158,11 +168,14 @@ QGroupBox *YMNxNMatrixWidget::setDate()
hlayout1->addWidget(new QLabel("Period:"));
hlayout1->addWidget(m_pcbPeriod);
hlayout2->addWidget(new QLabel("Recent:"));
hlayout2->addWidget(m_pleDates);
hlayout2->addWidget(m_pcbDuring);
vlayout->addLayout(hlayout2);
vlayout->addLayout(hlayout);
vlayout->addLayout(hlayout1);
vlayout->addLayout(hlayout);
vlayout->addLayout(hlayout1);
groupBox->setCheckable(true);
groupBox->setLayout(vlayout);
@@ -278,9 +291,6 @@ QGroupBox *YMNxNMatrixWidget::setMatrixKeyword()
m_pcbCountMethod->addItems(QStringList() << "Duplicate" << "NonDuplicate");
m_pcbThread->addItems(QStringList() << "1" << "2" << "4" << "8");
hlayout->addWidget(new QLabel("Matrix Keywords: "));
hlayout->addWidget(m_pleMKeyword);
hlayout->addWidget(new QLabel("CountMethod: "));
@@ -910,6 +920,27 @@ void YMNxNMatrixWidget::SaveFile()
}
QGroupBox *YMNxNMatrixWidget::setData()
{
QHBoxLayout *hlayout = new QHBoxLayout;
m_pcbData = new QComboBox;
m_pcbData->addItems(QStringList() << "Title" << "Body" << "Title+Body" << "PlatformTitle");
m_pcbData->setCurrentIndex(2);
hlayout->addWidget(new QLabel("Data: "));
hlayout->addWidget(m_pcbData);
QGroupBox *groupBox = new QGroupBox(tr("Data"));
groupBox->setCheckable(true);
groupBox->setLayout(hlayout);
groupBox->setChecked(true);
return groupBox;
}
QString YMNxNMatrixWidget::getMatrixKeyword()
@@ -956,7 +987,15 @@ QMap<QString, QString> YMNxNMatrixWidget::convertToParam()
mapParam.insert("CountMethod", m_pcbCountMethod->currentText().trimmed());
}
{
mapParam.insert("RecentDate", m_pleDates->text().trimmed());
mapParam.insert("RecentPeriod", m_pcbDuring->currentText().trimmed());
}
{
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
}
{
mapParam.insert("Article",QString::number(((STable*)(((Widget*)(m_pTabWidget->currentWidget()))->GetTabWidget()->currentWidget()))->getArticleSelect()));
}
return mapParam;
}

View File

@@ -50,6 +50,8 @@ private:
QCalendarWidget *m_pcw;
QDateEdit *m_pdeStart;
QDateEdit *m_pdeEnd;
QLineEdit *m_pleDates;
QComboBox *m_pcbDuring;
//QPushButton *m_ppbInsertCalc;
//QComboBox *m_pcbDateCatalog;
//
@@ -90,7 +92,7 @@ private:
QString m_strMKeyword;
QLineEdit *m_pleMKeyword;
QComboBox *m_pcbCountMethod;
QComboBox* m_pcbData;
@@ -113,7 +115,7 @@ private:
QGroupBox *setSort();
QGroupBox *setDictionary();
QGroupBox *setMatrixKeyword();
QGroupBox *setData();
void SortViewResult();
QTableWidget *AddTable(QString _str);

View File

@@ -41,6 +41,7 @@ YMOneDepthWidget::YMOneDepthWidget(QWidget *parent)
QGroupBox *gBox = setMorphereList();
QGroupBox *gDate = setDate();
QGroupBox *gData = setData();
QGroupBox *gFilter = setFilter();
QGroupBox *gOther = setOther();
QGroupBox *gSort = setSort();
@@ -50,7 +51,9 @@ YMOneDepthWidget::YMOneDepthWidget(QWidget *parent)
hboxlayout->addWidget(gBox,5);
vboxlayout->addWidget(gData,3);
vboxlayout->addWidget(gDate,3);
//vboxlayout->addWidget(gFilter,3);
vboxlayout->addWidget(gSort,2);
vboxlayout->addWidget(gOther,2);
@@ -70,6 +73,7 @@ YMOneDepthWidget::YMOneDepthWidget(QWidget *parent)
vMainLayout->addWidget(m_ptwData, 8);
setLayout(vMainLayout);
}
QGroupBox *YMOneDepthWidget::setMorphereList()
@@ -130,6 +134,7 @@ QGroupBox *YMOneDepthWidget::setDate()
{
QHBoxLayout *hlayout = new QHBoxLayout;
QHBoxLayout *hlayout1 = new QHBoxLayout;
QHBoxLayout *hlayout2 = new QHBoxLayout;
QVBoxLayout *vlayout = new QVBoxLayout;
QGroupBox *groupBox = new QGroupBox(tr("Date"));
@@ -153,6 +158,13 @@ QGroupBox *YMOneDepthWidget::setDate()
m_pcbPeriod = new QComboBox;
m_pcbPeriod->addItems(QStringList() << "None" << "1 Day" << "1 Week" << "1 Month");
m_pleDates = new QLineEdit;
m_pleDates->setValidator(new QIntValidator(1, 100));
m_pcbDuring = new QComboBox;
m_pcbDuring->addItems(QStringList() << "None" << "Days" << "Weeks" << "Months" << "Years");
hlayout->addWidget(m_pcbDate);
hlayout->addWidget(new QLabel("Start:"));
hlayout->addWidget(m_pdeStart);
@@ -162,11 +174,14 @@ QGroupBox *YMOneDepthWidget::setDate()
hlayout1->addWidget(new QLabel("Period:"));
hlayout1->addWidget(m_pcbPeriod);
hlayout2->addWidget(new QLabel("Recent:"));
hlayout2->addWidget(m_pleDates);
hlayout2->addWidget(m_pcbDuring);
vlayout->addLayout(hlayout2);
vlayout->addLayout(hlayout);
vlayout->addLayout(hlayout1);
vlayout->addLayout(hlayout);
vlayout->addLayout(hlayout1);
groupBox->setCheckable(true);
groupBox->setLayout(vlayout);
@@ -294,15 +309,42 @@ QGroupBox *YMOneDepthWidget::setDictionary()
}
QGroupBox *YMOneDepthWidget::setData()
{
QHBoxLayout *hlayout = new QHBoxLayout;
m_pcbData = new QComboBox;
m_pcbData->addItems(QStringList() << "Title" << "Body" << "Title+Body" << "PlatformTitle");
m_pcbData->setCurrentIndex(2);
hlayout->addWidget(new QLabel("Data: "));
hlayout->addWidget(m_pcbData);
QGroupBox *groupBox = new QGroupBox(tr("Data"));
groupBox->setCheckable(true);
groupBox->setLayout(hlayout);
groupBox->setChecked(true);
return groupBox;
}
QGroupBox *YMOneDepthWidget::setCenterKeyword()
{
QHBoxLayout *hlayout = new QHBoxLayout;
m_pleCKeyword = new QLineEdit;
m_pcbCountMethod = new QComboBox;
m_pcbCountMethod->addItems(QStringList() << "Duplicate" << "NonDuplicate");
hlayout->addWidget(new QLabel("Center Keyword: "));
hlayout->addWidget(m_pleCKeyword);
hlayout->addWidget(new QLabel("CountMethod: "));
hlayout->addWidget(m_pcbCountMethod);
QGroupBox *groupBox = new QGroupBox(tr("Center Keyword"));
@@ -572,6 +614,201 @@ void YMOneDepthWidget::MemClear()
m_mapViewResult.clear();
}
void YMOneDepthWidget::D3View()
{
QString strCKeyword = getCenterKeyword();
//qDebug() << "executed";
/*
QString strjson = "{\n\t\"name\":\" " + strCKeyword + "\",\n";
strjson += ("\t\"children\": [\n");
STable* pTable = (STable*)((QTabWidget*)(m_ptwTable->currentWidget()))->currentWidget();
int nCountIndex = pTable->columnCount() - 1;
int nKeywordIndex = pTable->columnCount() - 2;
for (int i = 0; i < pTable->rowCount(); i++)
{
QString strKeyword = pTable->item(i, nKeywordIndex)->text().trimmed();
int nCount = pTable->item(i, nCountIndex)->text().trimmed().toInt();
strjson += ("\t{\"name\": \"" + strKeyword + "\", \"size\": " + QString::number(nCount) + "},\n");
}
strjson = strjson.trimmed();
strjson = strjson.left(strjson.length() - 1);
strjson += "\n\t]\n}";
*/
QString strjson = "{\"name\":\" " + strCKeyword + "\",";
strjson += ("\"children\": [");
STable* pTable = (STable*)((QTabWidget*)(m_ptwTable->currentWidget()))->currentWidget();
int nCountIndex = pTable->columnCount() - 1;
int nKeywordIndex = pTable->columnCount() - 2;
for (int i = 0; i < pTable->rowCount(); i++)
{
QString strKeyword = pTable->item(i, nKeywordIndex)->text().trimmed();
int nCount = pTable->item(i, nCountIndex)->text().trimmed().toInt();
strjson += ("{\"name\": \"" + strKeyword + "\", \"size\": " + QString::number(nCount) + "},");
}
strjson = strjson.trimmed();
strjson = strjson.left(strjson.length() - 1);
strjson += "]}";
QString strHtml;
strHtml = "<html>"
"\n<meta charset=\"utf-8\">"
"\n<style>"
"\n"
"\n.node circle {"
"\n cursor: pointer;"
"\n stroke: #3182bd;"
"\n stroke-width: 1.5px;"
"\n}"
"\n"
"\n.node text {"
"\n font: 10px sans-serif;"
"\n pointer-events: none;"
"\n text-anchor: middle;"
"\n}"
"\n"
"\nline.link {"
"\n fill: none;"
"\n stroke: #9ecae1;"
"\n stroke-width: 1.5px;"
"\n}"
"\n"
"\n</style>"
"\n<body>"
"\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js\"></script>"
"\n<script>"
"\n"
"\nvar width = 1600,"
"\n height = 900,"
"\n root;"
"\n"
"\nvar force = d3.layout.force()"
"\n .linkDistance(80)"
"\n .charge(-120)"
"\n .gravity(.05)"
"\n .size([width, height])"
"\n .on(\"tick\", tick);"
"\n"
"\nvar svg = d3.select(\"body\").append(\"svg\")"
"\n .attr(\"width\", width)"
"\n .attr(\"height\", height);"
"\n"
"\nvar link = svg.selectAll(\".link\"),"
"\n node = svg.selectAll(\".node\");"
"\n"
//"\nd3.json(\"graph.json\", function(error, json) {"
//"\n if (error) throw error;"
"\n"
"\nvar jsonparam = '" + strjson + "';"
"\n root = JSON.parse(jsonparam);"
"\n update();"
//"\n});"
"\n"
"\nfunction update() {"
"\n var nodes = flatten(root),"
"\n links = d3.layout.tree().links(nodes);"
"\n"
"\n // Restart the force layout."
"\n force"
"\n .nodes(nodes)"
"\n .links(links)"
"\n .start();"
"\n"
"\n // Update links."
"\n link = link.data(links, function(d) { return d.target.id; });"
"\n"
"\n link.exit().remove();"
"\n"
"\n link.enter().insert(\"line\", \".node\")"
"\n .attr(\"class\", \"link\");"
"\n"
"\n // Update nodes."
"\n node = node.data(nodes, function(d) { return d.id; });"
"\n"
"\n node.exit().remove();"
"\n"
"\n var nodeEnter = node.enter().append(\"g\")"
"\n .attr(\"class\", \"node\")"
"\n .on(\"click\", click)"
"\n .call(force.drag);"
"\n"
"\n nodeEnter.append(\"circle\")"
"\n .attr(\"r\", function(d) { return Math.sqrt(d.size) / 10 || 4.5; });"
"\n"
"\n nodeEnter.append(\"text\")"
"\n .attr(\"dy\", \".35em\")"
"\n .text(function(d) { return d.name; });"
"\n"
"\n node.select(\"circle\")"
"\n .style(\"fill\", color);"
"\n}"
"\n"
"\nfunction tick() {"
"\n link.attr(\"x1\", function(d) { return d.source.x; })"
"\n .attr(\"y1\", function(d) { return d.source.y; })"
"\n .attr(\"x2\", function(d) { return d.target.x; })"
"\n .attr(\"y2\", function(d) { return d.target.y; });"
"\n"
"\n node.attr(\"transform\", function(d) { return \"translate(\" + d.x + \",\" + d.y + \")\"; });"
"\n}"
"\n"
"\nfunction color(d) {"
"\n return d._children ? \"#3182bd\" // collapsed package"
"\n : d.children ? \"#c6dbef\" // expanded package"
"\n : \"#fd8d3c\"; // leaf node"
"\n}"
"\n"
"\n// Toggle children on click."
"\nfunction click(d) {"
"\n if (d3.event.defaultPrevented) return; // ignore drag"
"\n if (d.children) {"
"\n d._children = d.children;"
"\n d.children = null;"
"\n } else {"
"\n d.children = d._children;"
"\n d._children = null;"
"\n }"
"\n update();"
"\n}"
"\n"
"\n// Returns a list of all nodes under the root."
"\nfunction flatten(root) {"
"\n var nodes = [], i = 0;"
"\n"
"\n function recurse(node) {"
"\n if (node.children) node.children.forEach(recurse);"
"\n if (!node.id) node.id = ++i;"
"\n nodes.push(node);"
"\n }"
"\n"
"\n recurse(root);"
"\n return nodes;"
"\n}"
"\n"
"\n</script>"
"\n";
/*
qDebug() << strHtml;
QFile file("c:/data/d3test.html");
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
QTextStream out(&file);
out << strHtml;
file.close();
*/
m_WVD3View.setHtml(strHtml);
m_WVD3View.settings()->setObjectCacheCapacities(0,0,0);
m_WVD3View.repaint();
m_WVD3View.show();
}
bool YMOneDepthWidget::setListMorphere(QStringList& MorphereEN, QStringList& MorphereKO)
{
@@ -1116,6 +1353,10 @@ QMap<QString, QString> YMOneDepthWidget::convertToParam()
mapParam.insert("CenterKeyword", getCenterKeyword());
}
{
mapParam.insert("CountMethod", m_pcbCountMethod->currentText().trimmed());
}
{
if(!m_pleFilterExtractor->text().trimmed().isEmpty())
mapParam.insert("Extractor", m_pleFilterExtractor->text().trimmed());
@@ -1137,5 +1378,15 @@ QMap<QString, QString> YMOneDepthWidget::convertToParam()
if(!m_pleFilterRankSeparated->text().trimmed().isEmpty())
mapParam.insert("RankFilterSeparated", m_pleFilterRankSeparated->text().trimmed());
}
{
mapParam.insert("RecentDate", m_pleDates->text().trimmed());
mapParam.insert("RecentPeriod", m_pcbDuring->currentText().trimmed());
}
{
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
}
{
mapParam.insert("Article",QString::number(((STable*)(((Widget*)(m_pTabWidget->currentWidget()))->GetTabWidget()->currentWidget()))->getArticleSelect()));
}
return mapParam;
}

View File

@@ -19,6 +19,7 @@
#include <QSqlDatabase>
#include <QListWidgetItem>
#include "stable.h"
class YMOneDepthWidget:public YMorphereWidget
{
Q_OBJECT
@@ -44,7 +45,7 @@ public:
void SaveFileSimple();
QMap<QString, int> getResult();
void TestUpload();
void D3View();
private:
// Data
QListWidget *m_plwData;
@@ -52,6 +53,8 @@ private:
QCalendarWidget *m_pcw;
QDateEdit *m_pdeStart;
QDateEdit *m_pdeEnd;
QLineEdit *m_pleDates;
QComboBox *m_pcbDuring;
//QPushButton *m_ppbInsertCalc;
//QComboBox *m_pcbDateCatalog;
//
@@ -95,8 +98,9 @@ private:
QString m_strCKeyword;
QLineEdit *m_pleCKeyword;
QComboBox *m_pcbCountMethod;
QWebViewChild m_WVD3View;
QComboBox* m_pcbData;
public:
struct m_mapKey
{
@@ -115,7 +119,7 @@ private:
QGroupBox *setSort();
QGroupBox *setDictionary();
QGroupBox *setCenterKeyword();
QGroupBox *setData();
void SortViewResult();
QTableWidget *AddTable(QString _str);

View File

@@ -1,5 +1,5 @@
#include "ymorpherethread.h"
#include <QDate>
void YMorphereThread::setParam(QMap<QString, QString> mapParam)
{
m_mapParam = mapParam;
@@ -41,3 +41,77 @@ void YMorphereThread::clearResult()
{
m_mapResult.clear();
}
QString YMorphereThread::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;
}

View File

@@ -14,6 +14,20 @@ protected:
QMap<QString, int> m_mapResult;
QMap<QString, int>* m_pmapResult;
QString m_strName;
enum {
MONDAY = 1,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY,
SUNDAY
};
enum
{
WEEK = 7
};
private:
@@ -29,6 +43,8 @@ public:
QMap<QString, int> getResult();
void clearResult();
void clearpResult();
QString getWeeksInMonth(unsigned int _nDate);
//virtual void setup() = 0;
};

View File

@@ -1,6 +1,7 @@
#include "ymorpherewidget.h"
#include "ymfilterchildren.h"
#include <QDebug>
YMorphereWidget::YMorphereWidget(QWidget *parent)
: QWidget(parent)
{
@@ -25,11 +26,17 @@ void YMorphereWidget::Exec()
clearResult();
clearViewResult();
clearView();
m_pYAlgorithm = YASingleton::getInstance();
m_pYAlgorithm = YAFactory::getInstance()->getYAlgorithm(convertToParam());
m_pYAlgorithm->init();
m_pYAlgorithm->setParam(convertToParam());
//qDebug() << "EXEC: "<< convertToParam().value("Article");
m_pYAlgorithm->Start();
m_mapResult = m_pYAlgorithm->getResult();
//qDebug() << m_mapResult.count();
ViewResult();
}
@@ -50,6 +57,11 @@ void YMorphereWidget::TestUpload()
}
void YMorphereWidget::D3View()
{
}
void YMorphereWidget::Exec(int nTitleBody)
{
@@ -67,3 +79,8 @@ void YMorphereWidget::Exec(int nTitleBody)
//qDebug() << m_mapResult.count();
ViewResult();
}
void YMorphereWidget::setTabWidget(QTabWidget *tabWidget)
{
m_pTabWidget = tabWidget;
}

View File

@@ -4,6 +4,22 @@
#include <QMap>
#include <QString>
#include "yalgorithm.h"
#include <QTabWidget>
#include "widget.h"
#include <QWebView>
class QWebViewChild:public QWebView
{
Q_OBJECT
protected:
void closeEvent(QCloseEvent *event)
{
this->setHtml(QString());
this->settings()->setObjectCacheCapacities(0,0,0);
this->repaint();
}
};
class YMorphereWidget : public QWidget
{
@@ -12,7 +28,7 @@ protected:
QMap <QString, int> m_mapResult;
YAlgorithm* m_pYAlgorithm;
QTabWidget* m_pTabWidget;
public:
YMorphereWidget(QWidget *parent = 0);
@@ -28,6 +44,8 @@ public:
virtual void SaveFile();
virtual void SaveFileSimple();
virtual void TestUpload();
virtual void D3View();
void setTabWidget(QTabWidget* tabWidget);
};
#endif // YMORPHEREWIDGET

View File

@@ -19,6 +19,8 @@
#include <QSqlQuery>
#include <QSqlError>
#include <QSet>
#define D_NOT_SELECT -1
#define SAFE_DELETE(x) if(x != NULL) { delete x; x = NULL; }
@@ -41,6 +43,7 @@ YMTwoDepthWidget::YMTwoDepthWidget(QWidget *parent)
QGroupBox *gBox = setMorphereList();
QGroupBox *gDate = setDate();
QGroupBox *gData = setData();
QGroupBox *gFilter = setFilter();
QGroupBox *gFilter2 = setFilter2();
QGroupBox *gOther = setOther();
@@ -50,7 +53,7 @@ YMTwoDepthWidget::YMTwoDepthWidget(QWidget *parent)
QGroupBox *gCenterKeyword = setCenterKeyword();
hboxlayout->addWidget(gBox,5);
vboxlayout->addWidget(gData,3);
vboxlayout->addWidget(gDate,3);
//vboxlayout->addWidget(gFilter,3);
vboxlayout->addWidget(gSort,2);
@@ -133,6 +136,7 @@ QGroupBox *YMTwoDepthWidget::setDate()
{
QHBoxLayout *hlayout = new QHBoxLayout;
QHBoxLayout *hlayout1 = new QHBoxLayout;
QHBoxLayout *hlayout2 = new QHBoxLayout;
QVBoxLayout *vlayout = new QVBoxLayout;
QGroupBox *groupBox = new QGroupBox(tr("Date"));
@@ -156,6 +160,13 @@ QGroupBox *YMTwoDepthWidget::setDate()
m_pcbPeriod = new QComboBox;
m_pcbPeriod->addItems(QStringList() << "None" << "1 Day" << "1 Week" << "1 Month");
m_pleDates = new QLineEdit;
m_pleDates->setValidator(new QIntValidator(1, 100));
m_pcbDuring = new QComboBox;
m_pcbDuring->addItems(QStringList() << "None" << "Days" << "Weeks" << "Months" << "Years");
hlayout->addWidget(m_pcbDate);
hlayout->addWidget(new QLabel("Start:"));
hlayout->addWidget(m_pdeStart);
@@ -165,11 +176,14 @@ QGroupBox *YMTwoDepthWidget::setDate()
hlayout1->addWidget(new QLabel("Period:"));
hlayout1->addWidget(m_pcbPeriod);
hlayout2->addWidget(new QLabel("Recent:"));
hlayout2->addWidget(m_pleDates);
hlayout2->addWidget(m_pcbDuring);
vlayout->addLayout(hlayout2);
vlayout->addLayout(hlayout);
vlayout->addLayout(hlayout1);
vlayout->addLayout(hlayout);
vlayout->addLayout(hlayout1);
groupBox->setCheckable(true);
groupBox->setLayout(vlayout);
@@ -350,14 +364,17 @@ QGroupBox *YMTwoDepthWidget::setCenterKeyword()
QHBoxLayout *hlayout = new QHBoxLayout;
m_pleCKeyword = new QLineEdit;
m_pcbCountMethod = new QComboBox;
m_pcbCountMethod->addItems(QStringList() << "Duplicate" << "NonDuplicate");
hlayout->addWidget(new QLabel("Center Keyword: "));
hlayout->addWidget(m_pleCKeyword);
hlayout->addWidget(new QLabel("CountMethod: "));
hlayout->addWidget(m_pcbCountMethod);
QGroupBox *groupBox = new QGroupBox(tr("Center Keyword"));
groupBox->setCheckable(true);
groupBox->setLayout(hlayout);
groupBox->setChecked(true);
return groupBox;
@@ -708,6 +725,26 @@ void YMTwoDepthWidget::clearViewResult()
}
QGroupBox *YMTwoDepthWidget::setData()
{
QHBoxLayout *hlayout = new QHBoxLayout;
m_pcbData = new QComboBox;
m_pcbData->addItems(QStringList() << "Title" << "Body" << "Title+Body" << "PlatformTitle");
m_pcbData->setCurrentIndex(2);
hlayout->addWidget(new QLabel("Data: "));
hlayout->addWidget(m_pcbData);
QGroupBox *groupBox = new QGroupBox(tr("Data"));
groupBox->setCheckable(true);
groupBox->setLayout(hlayout);
groupBox->setChecked(true);
return groupBox;
}
void YMTwoDepthWidget::clearView()
@@ -1134,6 +1171,225 @@ QMap<QString, int> YMTwoDepthWidget::getResult()
return m_mapResult;
}
void YMTwoDepthWidget::D3View()
{
QMap<QString, QMap<QString, int> > mapResult;
QString strCKeyword = getCenterKeyword();
//qDebug() << "executed";
{
STable* pTable = (STable*)((QTabWidget*)(m_ptwTable->currentWidget()))->currentWidget();
if(pTable->columnCount() < 4)
return;
int nCountIndex = pTable->columnCount() - 1;
int nTDKeywordIndex = pTable->columnCount() - 2;
int nODKeywordIndex = pTable->columnCount() - 4;
for (int i = 0; i < pTable->rowCount(); i++)
{
QString strODKeyword = pTable->item(i, nODKeywordIndex)->text().trimmed();
QString strTDKeyword = pTable->item(i, nTDKeywordIndex)->text().trimmed();
int nCount = pTable->item(i, nCountIndex)->text().trimmed().toInt();
if(mapResult.contains(strODKeyword))
{
mapResult[strODKeyword].insert(strTDKeyword, nCount);
}
else
{
QMap<QString, int> qLast;
qLast.insert(strTDKeyword, nCount);
mapResult.insert(strODKeyword, qLast);
}
}
}
QString strjson = "{\"name\":\" " + strCKeyword + "\",";
strjson += ("\"children\": [");
for(QMap<QString, QMap<QString, int > >::iterator iterPos1 = mapResult.begin(); iterPos1 != mapResult.end(); iterPos1++)
{
int sum = 0;
for(QMap<QString, int>::iterator iterPos2 = iterPos1.value().begin(); iterPos2 != iterPos1.value().end(); iterPos2++)
{
sum += iterPos2.value();
}
strjson += "{";
strjson += ("\"name\":\"" + iterPos1.key() + "\",\"size\":" + QString::number(sum) + ",");
strjson += "\"children\": [";
for(QMap<QString, int>::iterator iterPos2 = iterPos1.value().begin(); iterPos2 != iterPos1.value().end(); iterPos2++)
{
strjson += ("{\"name\": \"" + iterPos2.key() + "\", \"size\": " + QString::number(iterPos2.value()) + "},");
}
strjson = strjson.trimmed();
strjson = strjson.left(strjson.length() - 1);
strjson += "]},";
}
strjson = strjson.trimmed();
strjson = strjson.left(strjson.length() - 1);
strjson += "]}";
QString strHtml;
strHtml = "<html>"
"\n<meta charset=\"utf-8\">"
"\n<style>"
"\n"
"\n.node circle {"
"\n cursor: pointer;"
"\n stroke: #3182bd;"
"\n stroke-width: 1.5px;"
"\n}"
"\n"
"\n.node text {"
"\n font: 10px sans-serif;"
"\n pointer-events: none;"
"\n text-anchor: middle;"
"\n}"
"\n"
"\nline.link {"
"\n fill: none;"
"\n stroke: #9ecae1;"
"\n stroke-width: 1.5px;"
"\n}"
"\n"
"\n</style>"
"\n<body>"
"\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js\"></script>"
"\n<script>"
"\n"
"\nvar width = 1600,"
"\n height = 900,"
"\n root;"
"\n"
"\nvar force = d3.layout.force()"
"\n .linkDistance(80)"
"\n .charge(-120)"
"\n .gravity(.05)"
"\n .size([width, height])"
"\n .on(\"tick\", tick);"
"\n"
"\nvar svg = d3.select(\"body\").append(\"svg\")"
"\n .attr(\"width\", width)"
"\n .attr(\"height\", height);"
"\n"
"\nvar link = svg.selectAll(\".link\"),"
"\n node = svg.selectAll(\".node\");"
"\n"
//"\nd3.json(\"graph.json\", function(error, json) {"
//"\n if (error) throw error;"
"\n"
"\nvar jsonparam = '" + strjson + "';"
"\n root = JSON.parse(jsonparam);"
"\n update();"
//"\n});"
"\n"
"\nfunction update() {"
"\n var nodes = flatten(root),"
"\n links = d3.layout.tree().links(nodes);"
"\n"
"\n // Restart the force layout."
"\n force"
"\n .nodes(nodes)"
"\n .links(links)"
"\n .start();"
"\n"
"\n // Update links."
"\n link = link.data(links, function(d) { return d.target.id; });"
"\n"
"\n link.exit().remove();"
"\n"
"\n link.enter().insert(\"line\", \".node\")"
"\n .attr(\"class\", \"link\");"
"\n"
"\n // Update nodes."
"\n node = node.data(nodes, function(d) { return d.id; });"
"\n"
"\n node.exit().remove();"
"\n"
"\n var nodeEnter = node.enter().append(\"g\")"
"\n .attr(\"class\", \"node\")"
"\n .on(\"click\", click)"
"\n .call(force.drag);"
"\n"
"\n nodeEnter.append(\"circle\")"
"\n .attr(\"r\", function(d) { return Math.sqrt(d.size) / 10 || 4.5; });"
"\n"
"\n nodeEnter.append(\"text\")"
"\n .attr(\"dy\", \".35em\")"
"\n .text(function(d) { return d.name; });"
"\n"
"\n node.select(\"circle\")"
"\n .style(\"fill\", color);"
"\n}"
"\n"
"\nfunction tick() {"
"\n link.attr(\"x1\", function(d) { return d.source.x; })"
"\n .attr(\"y1\", function(d) { return d.source.y; })"
"\n .attr(\"x2\", function(d) { return d.target.x; })"
"\n .attr(\"y2\", function(d) { return d.target.y; });"
"\n"
"\n node.attr(\"transform\", function(d) { return \"translate(\" + d.x + \",\" + d.y + \")\"; });"
"\n}"
"\n"
"\nfunction color(d) {"
"\n return d._children ? \"#3182bd\" // collapsed package"
"\n : d.children ? \"#c6dbef\" // expanded package"
"\n : \"#fd8d3c\"; // leaf node"
"\n}"
"\n"
"\n// Toggle children on click."
"\nfunction click(d) {"
"\n if (d3.event.defaultPrevented) return; // ignore drag"
"\n if (d.children) {"
"\n d._children = d.children;"
"\n d.children = null;"
"\n } else {"
"\n d.children = d._children;"
"\n d._children = null;"
"\n }"
"\n update();"
"\n}"
"\n"
"\n// Returns a list of all nodes under the root."
"\nfunction flatten(root) {"
"\n var nodes = [], i = 0;"
"\n"
"\n function recurse(node) {"
"\n if (node.children) node.children.forEach(recurse);"
"\n if (!node.id) node.id = ++i;"
"\n nodes.push(node);"
"\n }"
"\n"
"\n recurse(root);"
"\n return nodes;"
"\n}"
"\n"
"\n</script>"
"\n";
qDebug() << strHtml;
QFile file("c:/data/d3test.html");
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
QTextStream out(&file);
out << strHtml;
file.close();
m_WVD3View.setHtml(strHtml);
m_WVD3View.settings()->setObjectCacheCapacities(0,0,0);
m_WVD3View.repaint();
m_WVD3View.show();
}
void YMTwoDepthWidget::TestUpload()
{
@@ -1283,6 +1539,9 @@ QMap<QString, QString> YMTwoDepthWidget::convertToParam()
{
mapParam.insert("CenterKeyword", getCenterKeyword());
}
{
mapParam.insert("CountMethod", m_pcbCountMethod->currentText().trimmed());
}
{
if(!m_pleFilterExtractor->text().trimmed().isEmpty())
@@ -1326,7 +1585,15 @@ QMap<QString, QString> YMTwoDepthWidget::convertToParam()
if(!m_pleFilterRankSeparated2->text().trimmed().isEmpty())
mapParam.insert("RankFilterSeparated2", m_pleFilterRankSeparated2->text().trimmed());
}
{
mapParam.insert("RecentDate", m_pleDates->text().trimmed());
mapParam.insert("RecentPeriod", m_pcbDuring->currentText().trimmed());
}
{
mapParam.insert("TitleBody", QString::number(m_pcbData->currentIndex()));
}
{
mapParam.insert("Article",QString::number(((STable*)(((Widget*)(m_pTabWidget->currentWidget()))->GetTabWidget()->currentWidget()))->getArticleSelect()));
}
return mapParam;
}

View File

@@ -19,6 +19,9 @@
#include <QSqlDatabase>
#include <QListWidgetItem>
#include "stable.h"
#include <QCloseEvent>
class YMTwoDepthWidget:public YMorphereWidget
{
Q_OBJECT
@@ -44,7 +47,7 @@ public:
void SaveFileSimple();
QMap<QString, int> getResult();
void TestUpload();
void D3View();
private:
// Data
QListWidget *m_plwData;
@@ -52,6 +55,8 @@ private:
QCalendarWidget *m_pcw;
QDateEdit *m_pdeStart;
QDateEdit *m_pdeEnd;
QLineEdit *m_pleDates;
QComboBox *m_pcbDuring;
//QPushButton *m_ppbInsertCalc;
//QComboBox *m_pcbDateCatalog;
//
@@ -103,7 +108,9 @@ private:
QString m_strCKeyword;
QLineEdit *m_pleCKeyword;
QComboBox *m_pcbCountMethod;
QWebViewChild m_WVD3View;
QComboBox* m_pcbData;
public:
struct m_mapKey
@@ -125,7 +132,7 @@ private:
QGroupBox *setSort();
QGroupBox *setDictionary();
QGroupBox *setCenterKeyword();
QGroupBox *setData();
void SortViewResult();
QTableWidget *AddTable(QString _str);

View File

@@ -0,0 +1,486 @@
#include "ymuploadwidget.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QSqlDatabase>
#include <QString>
#include <QSqlQuery>
#include <../Json/sjson.h>
#include "stable.h"
#include <QDebug>
#include <QSqlError>
#include "ymorpherewidget.h"
#include "stable.h"
#include "widget.h"
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
YMUploadWidget::YMUploadWidget(QWidget *parent):QWidget(parent)
{
m_pgbAnalysis = setUploadWidgets();
QVBoxLayout *vMainLayout = new QVBoxLayout;
vMainLayout->addWidget(m_pgbAnalysis);
AnalysisGroupRefresh();
setLayout(vMainLayout);
}
YMUploadWidget::~YMUploadWidget()
{
}
QGroupBox *YMUploadWidget::setUploadWidgets()
{
QHBoxLayout *hMainlayout = new QHBoxLayout();
{
QVBoxLayout *vlayout = new QVBoxLayout();
m_plwAnalysisGroup = new QListWidget;
m_pleAnalysisGroup = new QLineEdit;
vlayout->addWidget(m_plwAnalysisGroup);
vlayout->addWidget(m_pleAnalysisGroup);
{
QHBoxLayout *hlayout = new QHBoxLayout();
QPushButton *pbInsert = new QPushButton("Insert");
connect(pbInsert, SIGNAL(released()),this, SLOT(AnalysisGroupInsert()));
QPushButton *pbDelete = new QPushButton("Delete");
connect(pbDelete, SIGNAL(released()),this, SLOT(AnalysisGroupDelete()));
QPushButton *pbModify = new QPushButton("Modfiy");
connect(pbModify, SIGNAL(released()),this, SLOT(AnalysisGroupModify()));
QPushButton *pbCopy_Paste = new QPushButton("Copy&Paste");
connect(pbCopy_Paste, SIGNAL(released()),this, SLOT(AnalysisGroupCopyPaste()));
QPushButton *pbRefresh = new QPushButton("Refresh");
connect(pbRefresh, SIGNAL(released()),this, SLOT(AnalysisGroupRefresh()));
hlayout->addWidget(pbInsert);
hlayout->addWidget(pbDelete);
hlayout->addWidget(pbModify);
hlayout->addWidget(pbCopy_Paste);
hlayout->addWidget(pbRefresh);
vlayout->addLayout(hlayout);
}
hMainlayout->addLayout(vlayout);
}
{
QVBoxLayout *vlayout = new QVBoxLayout();
m_plwAnalysis = new QListWidget;
vlayout->addWidget(m_plwAnalysis);
connect(m_plwAnalysis,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(currentAnalysisItemChanged(QListWidgetItem*,QListWidgetItem*)));
QHBoxLayout *hlayout = new QHBoxLayout();
QPushButton *pbAdd = new QPushButton("Add");
QPushButton *pbUp = new QPushButton("Up");
QPushButton *pbDown = new QPushButton("Down");
QPushButton *pbDelete = new QPushButton("Delete");
hlayout->addWidget(pbAdd);
hlayout->addWidget(pbUp);
hlayout->addWidget(pbDown);
hlayout->addWidget(pbDelete);
vlayout->addLayout(hlayout);
connect(pbAdd, SIGNAL(released()),this, SLOT(AnalysisAdd()));
connect(pbUp, SIGNAL(released()),this, SLOT(AnalysisUp()));
connect(pbDown, SIGNAL(released()),this, SLOT(AnalysisDown()));
connect(pbDelete, SIGNAL(released()),this, SLOT(AnalysisDelete()));
hMainlayout->addLayout(vlayout);
}
m_pgbAnalysis = new QGroupBox(tr("Upload"));
m_pgbAnalysis->setCheckable(true);
m_pgbAnalysis->setChecked(false);
m_pgbAnalysis->setLayout(hMainlayout);
connect(m_plwAnalysisGroup,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(currentGroupItemChanged(QListWidgetItem *, QListWidgetItem *)));
return m_pgbAnalysis;
}
void YMUploadWidget::AnalysisGroupInsert()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
db.setUserName("admin");
db.setPassword("admin123");
db.setDatabaseName("concepters");
if (db.open() == false)
{
qDebug() << db.lastError().text();
return;
}
QString strQuery = QString("insert into analysisgroup set "
"name = '" + m_pleAnalysisGroup->text() + "'");
db.exec(strQuery.toUtf8());
db.close();
AnalysisGroupRefresh();
}
void YMUploadWidget::AnalysisGroupDelete()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
db.setUserName("admin");
db.setPassword("admin123");
db.setDatabaseName("concepters");
if (db.open() == false)
{
qDebug() << db.lastError().text();
return;
}
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
{
QString strQuery = QString("delete from analysisgroup where id = " + item->data(Qt::UserRole).toString());
db.exec(strQuery.toUtf8());
strQuery = QString("delete from analysis where analysisgroup_id = " + item->data(Qt::UserRole).toString());
db.exec(strQuery.toUtf8());
RefreshAnalysis(item->data(Qt::UserRole).toInt());
}
db.close();
AnalysisGroupRefresh();
}
void YMUploadWidget::AnalysisGroupModify()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
db.setUserName("admin");
db.setPassword("admin123");
db.setDatabaseName("concepters");
if (db.open() == false)
{
qDebug() << db.lastError().text();
return;
}
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
{
QString strQuery = QString("update analysisgroup set name = '" + m_pleAnalysisGroup->text() + "' where id = " + item->data(Qt::UserRole).toString());
qDebug() << strQuery;
db.exec(strQuery.toUtf8());
}
db.close();
AnalysisGroupRefresh();
}
void YMUploadWidget::AnalysisGroupCopyPaste()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
db.setUserName("admin");
db.setPassword("admin123");
db.setDatabaseName("concepters");
if (db.open() == false)
{
qDebug() << db.lastError().text();
return;
}
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
{
QSqlQuery query;
QString strQuery = QString("insert into analysisgroup set "
"name = '" + item->text() + "-'");
query.exec(strQuery.toUtf8());
query.exec("select max(id) from analysisgroup");
if (query.next())
{
strQuery = QString("insert into analysis (type,data,analysisgroup_id) select type,data,");
strQuery += query.value(0).toString();
strQuery += " from analysis where analysisgroup_id = " + item->data(Qt::UserRole).toString();
qDebug() << strQuery;
query.exec(strQuery.toUtf8());
}
}
db.close();
AnalysisGroupRefresh();
}
void YMUploadWidget::AnalysisGroupRefresh()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
db.setUserName("admin");
db.setPassword("admin123");
db.setDatabaseName("concepters");
if (db.open() == false)
{
qDebug() << db.lastError().text();
return;
}
m_plwAnalysisGroup->clear();
QSqlQuery query("select id,name from analysisgroup");
while (query.next())
{
QListWidgetItem *pItem = new QListWidgetItem(query.value(1).toString(),m_plwAnalysisGroup);
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
}
db.close();
}
void YMUploadWidget::RefreshAnalysis(int _nGroup)
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
db.setUserName("admin");
db.setPassword("admin123");
db.setDatabaseName("concepters");
if (db.open() == false)
{
qDebug() << db.lastError().text();
return;
}
QSqlQuery query("select id,type,data from analysis where analysisgroup_id = " + QString::number(_nGroup));
SJson json;
m_plwAnalysis->clear();
while (query.next())
{
QString str;
QString strJson = query.value(2).toString();
QJsonObject jsonObj = QJsonDocument::fromJson(strJson.toUtf8()).object();
str = STable::GetArticleType(json.Get(strJson,"Article").toInt());
for(QJsonObject::iterator iterPos = jsonObj.begin(); iterPos != jsonObj.end(); iterPos++)
{
str += (" " + iterPos.key() + " : " + iterPos.value().toString() + " ,");
}
str = str.left(str.length() - 1);
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwAnalysis);
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
}
db.close();
}
void YMUploadWidget::currentGroupItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev)
{
Q_UNUSED(_pPrev);
if (_pCurrent == 0) return;
RefreshAnalysis(_pCurrent->data(Qt::UserRole).toInt());
m_pleAnalysisGroup->setText(_pCurrent->text());
m_pleAnalysisGroup->repaint();
}
void YMUploadWidget::AnalysisDelete()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
db.setUserName("admin");
db.setPassword("admin123");
db.setDatabaseName("concepters");
if (db.open() == false)
{
qDebug() << db.lastError().text();
return;
}
foreach (QListWidgetItem *item,m_plwAnalysis->selectedItems())
{
QString strQuery = QString("delete from analysis where id = '" + item->data(Qt::UserRole).toString() + "'");
db.exec(strQuery.toUtf8());
}
db.close();
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
RefreshAnalysis(item->data(Qt::UserRole).toInt());
}
void YMUploadWidget::AnalysisAdd()
{
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
{
int nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
DataBaseMorphereAnalysis(((STable*)((Widget*)(m_ptwSource->currentWidget()))->GetTabWidget()->currentWidget())->getArticleSelect(), ((YMorphereWidget*)(m_ptwResult->currentWidget()))->convertToParam(), nCurrentFilterGroupID, E_DATABASE_COMMAND_INSERT);
}
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
RefreshAnalysis(item->data(Qt::UserRole).toInt());
}
void YMUploadWidget::AnalysisUp()
{
int nSelect = m_plwAnalysis->currentRow();
if (nSelect <= 0) return;
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
db.setUserName("admin");
db.setPassword("admin123");
db.setDatabaseName("concepters");
if (db.open() == false)
{
qDebug() << db.lastError().text();
return;
}
QString strID1 = m_plwAnalysis->item(nSelect)->data(Qt::UserRole).toString();
QString strID2 = m_plwAnalysis->item(nSelect-1)->data(Qt::UserRole).toString();
QString strQuery = "UPDATE analysis t1 INNER JOIN analysis t2 ON (t1.id, t2.id) IN ((" + strID1 + ","+ strID2 +"),("+ strID2 + "," + strID1 + ")) SET t1.type = t2.type,t1.analysisgroup_id = t2.analysisgroup_id,t1.data = t2.data";
db.exec(strQuery.toUtf8());
db.close();
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
RefreshAnalysis(item->data(Qt::UserRole).toInt());
m_plwAnalysis->setCurrentRow(nSelect-1);
}
void YMUploadWidget::AnalysisDown()
{
int nSelect = m_plwAnalysis->currentRow();
if (nSelect < 0) return;
if (nSelect >= (m_plwAnalysis->count() - 1)) return;
qDebug() << nSelect;
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
db.setUserName("admin");
db.setPassword("admin123");
db.setDatabaseName("concepters");
if (db.open() == false)
{
qDebug() << db.lastError().text();
return;
}
QString strID1 = m_plwAnalysis->item(nSelect)->data(Qt::UserRole).toString();
QString strID2 = m_plwAnalysis->item(nSelect+1)->data(Qt::UserRole).toString();
QString strQuery = "UPDATE analysis t1 INNER JOIN analysis t2 ON (t1.id, t2.id) IN ((" + strID1 + ","+ strID2 +"),("+ strID2 + "," + strID1 + ")) SET t1.type = t2.type,t1.analysisgroup_id = t2.analysisgroup_id,t1.data = t2.data";
db.exec(strQuery.toUtf8());
db.close();
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
RefreshAnalysis(item->data(Qt::UserRole).toInt());
m_plwAnalysis->setCurrentRow(nSelect+1);
}
void YMUploadWidget::DataBaseMorphereAnalysis(int _nArticle,QMap<QString, QString> mapParam ,int _nGroup,int _nCommand, QString _strFilterId)
{
QString strJson;
SJson json;
for(QMap<QString, QString>::iterator iterPos = mapParam.begin(); iterPos != mapParam.end(); iterPos++)
{
strJson = json.Set(strJson, iterPos.key(), iterPos.value());
}
DataBaseAnalysis(_nArticle, json.Sql(strJson),_nGroup,_nCommand,_strFilterId);
}
void YMUploadWidget::DataBaseAnalysis(int _nType, QString _strJson,int _nGroup,int _nCommand,QString _strFilterId)
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
db.setUserName("admin");
db.setPassword("admin123");
db.setDatabaseName("concepters");
if (db.open() == false)
{
qDebug() << db.lastError().text();
return;
}
QString sql;
switch(_nCommand)
{
case E_DATABASE_COMMAND_INSERT:
sql = "INSERT INTO analysis SET ";
sql += QString("type=") + QString::number(_nType) + ",";
break;
case E_DATABASE_COMMAND_UPDATE:
sql = "UPDATE filter SET ";
break;
}
sql += QString("data='") + _strJson + "',";
sql += QString("analysisgroup_id=" ) + QString::number(_nGroup);
if (_nCommand == E_DATABASE_COMMAND_UPDATE)
sql += QString(" where id=") + _strFilterId;
QSqlQuery query;
if (query.exec(sql.toUtf8()) == false)
{
qDebug() << sql;
qDebug() << query.lastError().text();
}
db.close();
}
void YMUploadWidget::currentAnalysisItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev)
{
Q_UNUSED(_pPrev);
if (_pCurrent == 0) return;
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
db.setUserName("admin");
db.setPassword("admin123");
db.setDatabaseName("concepters");
if (db.open() == false)
{
qDebug() << db.lastError().text();
return;
}
QSqlQuery query("select id,type,data from filter where id = " + _pCurrent->data(Qt::UserRole).toString());
if (!query.next()) return;
SJson json;
QString strJson = query.value(2).toString();
/*
switch(query.value(1).toInt())
{
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"));
m_pleString->setText("");
m_pleLength->setText("");
m_pleReplaceFind->setText("");
m_pleReplace->setText("");
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_pleLength->setText("");
m_pleReplaceFind->setText("");
m_pleReplace->setText("");
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"));
m_pleReplaceFind->setText("");
m_pleReplace->setText("");
m_pleString->setText("");
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"));
m_pleString->setText("");
m_pleLength->setText("");
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"));
m_pleReplaceFind->setText("");
m_pleReplace->setText("");
m_pleString->setText("");
break;
}
*/
}
void YMUploadWidget::setResultTabWidget(QTabWidget* tabWidget)
{
m_ptwResult = tabWidget;
}
void YMUploadWidget::setSourceTabWidget(QTabWidget* tabWidget)
{
m_ptwSource = tabWidget;
}

View File

@@ -0,0 +1,59 @@
#ifndef YMUPLOADWIDGET
#define YMUPLOADWIDGET
#include <QWidget>
#include <QGroupBox>
#include <QListWidget>
#include <QListWidgetItem>
#include <QLineEdit>
#include <QString>
#include <QMap>
#include <QTabWidget>
class YMUploadWidget:public QWidget
{
Q_OBJECT
enum E_DATABASE_COMMAND
{
E_DATABASE_COMMAND_INSERT = 0,
E_DATABASE_COMMAND_UPDATE,
};
public:
YMUploadWidget(QWidget *parent = 0);
~YMUploadWidget();
private:
QGroupBox *setUploadWidgets();
QListWidget* m_plwAnalysisGroup;
QLineEdit* m_pleAnalysisGroup;
QListWidget* m_plwAnalysis;
QGroupBox* m_pgbAnalysis;
QTabWidget* m_ptwResult;
QTabWidget* m_ptwSource;
public slots:
void AnalysisGroupInsert();
void AnalysisGroupDelete();
void AnalysisGroupModify();
void AnalysisGroupRefresh();
void AnalysisGroupCopyPaste();
void currentGroupItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0);
void AnalysisDelete();
void AnalysisUp();
void AnalysisDown();
void AnalysisAdd();
void currentAnalysisItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0);
void RefreshAnalysis(int _nGroup);
// void RefreshAnalysis(int _nGroup);
void DataBaseMorphereAnalysis(int _nArticle,QMap<QString, QString> mapParam ,int _nGroup,int _nCommand, QString _strFilterId = "");
void DataBaseAnalysis(int _nType, QString _strJson,int _nGroup,int _nCommand,QString _strFilterId);
void setResultTabWidget(QTabWidget* tabWidget);
void setSourceTabWidget(QTabWidget* tabWidget);
};
#endif // YMUPLOADWIDGET