git-svn-id: svn://192.168.0.12/source@202 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -4,15 +4,15 @@
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui sql network webenginewidgets
|
||||
QT += core gui sql network webkit webkitwidgets
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
DEFINES += NOMINMAX
|
||||
|
||||
TARGET = MorphereAnalyzer
|
||||
TEMPLATE = app
|
||||
|
||||
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
widget.cpp \
|
||||
@@ -35,7 +35,8 @@ SOURCES += main.cpp\
|
||||
ymfilterchildren.cpp \
|
||||
ymtwodepthwidget.cpp \
|
||||
ymuploadwidget.cpp \
|
||||
ymplatformwidget.cpp
|
||||
ymplatformwidget.cpp \
|
||||
ymtwodepthawidget.cpp
|
||||
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
@@ -89,7 +90,8 @@ HEADERS += mainwindow.h \
|
||||
ymfilterchildren.h \
|
||||
ymtwodepthwidget.h \
|
||||
ymuploadwidget.h \
|
||||
ymplatformwidget.h
|
||||
ymplatformwidget.h \
|
||||
ymtwodepthawidget.h
|
||||
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define KEYWORDTHREAD
|
||||
|
||||
#include <QThread>
|
||||
#include <QWidget>
|
||||
#include "widget.h"
|
||||
#include <QDebug>
|
||||
#include <QMutex>
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <QSqlError>
|
||||
#include "ymtwodepthwidget.h"
|
||||
#include "ymplatformwidget.h"
|
||||
#include "ymtwodepthawidget.h"
|
||||
#include <QShortcut>
|
||||
#include <QKeySequence>
|
||||
#include <QUrl>
|
||||
@@ -70,6 +71,8 @@ MainWindow::MainWindow()
|
||||
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;
|
||||
@@ -94,6 +97,7 @@ MainWindow::MainWindow()
|
||||
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");
|
||||
|
||||
@@ -102,6 +106,7 @@ MainWindow::MainWindow()
|
||||
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);
|
||||
@@ -177,6 +182,15 @@ void MainWindow::createActions()
|
||||
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()
|
||||
@@ -197,6 +211,18 @@ void MainWindow::slotD3ViewTree()
|
||||
//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()
|
||||
{
|
||||
@@ -233,7 +259,10 @@ void MainWindow::createMenus()
|
||||
|
||||
menuD3View = menuBar()->addMenu(tr("D3View"));
|
||||
menuD3View->addAction(actD3View);
|
||||
menuD3View->addAction(actD3ViewFile);
|
||||
menuD3View->addAction(actD3ViewTree);
|
||||
menuD3View->addAction(actD3ViewTreeFile);
|
||||
|
||||
}
|
||||
//! [12]
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTabWidget>
|
||||
#include "widget.h"
|
||||
@@ -85,6 +84,8 @@ private slots:
|
||||
void slotD3View();
|
||||
void slotShowUpload();
|
||||
void slotD3ViewTree();
|
||||
void slotD3ViewFile();
|
||||
void slotD3ViewTreeFile();
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *);
|
||||
|
||||
@@ -119,6 +120,7 @@ private:
|
||||
YMorphereWidget *m_pYMOneDepthWidget;
|
||||
YMorphereWidget *m_pYMNxNMatrixWidget;
|
||||
YMorphereWidget *m_pYMTwoDepthWidget;
|
||||
YMorphereWidget *m_pYMTwoDepthAWidget;
|
||||
YMorphereWidget *m_pYMPlatformWidget;
|
||||
|
||||
QAction *actDBNew;
|
||||
@@ -144,6 +146,10 @@ private:
|
||||
|
||||
QAction *actD3View;
|
||||
QAction *actD3ViewTree;
|
||||
|
||||
QAction *actD3ViewFile;
|
||||
QAction *actD3ViewTreeFile;
|
||||
|
||||
QAction *actShowUpload;
|
||||
//AnalyzerThread m_pThread[16];
|
||||
/*
|
||||
|
||||
@@ -336,6 +336,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
# ifdef DLL_EXPORT
|
||||
# define MECAB_DLL_EXTERN __declspec(dllexport)
|
||||
|
||||
@@ -83,6 +83,12 @@ YAlgorithm* YAFactory::getYAlgorithm(QMap<QString, QString> mapParam)
|
||||
m_mapAlgorithm.insert("platform", new YPlatformAlgorithm());
|
||||
Algorithm = m_mapAlgorithm.value("platform");
|
||||
}
|
||||
else if(mapParam.value("Algorithm").compare("twodeptha", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(!m_mapAlgorithm.contains("twodeptha"))
|
||||
m_mapAlgorithm.insert("twodeptha", new YTwoDepthAAlgorithm());
|
||||
Algorithm = m_mapAlgorithm.value("twodeptha");
|
||||
}
|
||||
else
|
||||
{
|
||||
Algorithm = NULL;
|
||||
@@ -512,8 +518,130 @@ void YPlatformAlgorithm::Start()
|
||||
}
|
||||
delete ymfilter;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void YTwoDepthAAlgorithm::Start()
|
||||
{
|
||||
if(m_mapParam.isEmpty())
|
||||
return;
|
||||
|
||||
bool okThread = false;
|
||||
int nThread = m_mapParam.value("Thread").trimmed().toInt(&okThread);
|
||||
|
||||
if(!okThread)
|
||||
setThreadNumber(1);
|
||||
else
|
||||
setThreadNumber(nThread);
|
||||
|
||||
QMap<QString, QString>mapParam = m_mapParam;
|
||||
|
||||
mapParam["Algorithm"] = "onedepth";
|
||||
|
||||
|
||||
m_pYMThread = new YMorphereThread*[getThreadNumber()];
|
||||
for(int i = 0; i < getThreadNumber(); i++)
|
||||
{
|
||||
m_pYMThread[i] = ThreadFactory::getThread(mapParam);
|
||||
m_pYMThread[i]->setDataAlgorithmInterface(m_pDAInterface);
|
||||
m_pYMThread[i]->setMutex(&mutex);
|
||||
m_pYMThread[i]->setParam(mapParam);
|
||||
}
|
||||
for(int i = 0;i < getThreadNumber(); i++)
|
||||
{
|
||||
m_pYMThread[i]->start();
|
||||
}
|
||||
for(int i = 0;i < getThreadNumber(); i++)
|
||||
{
|
||||
m_pYMThread[i]->wait();
|
||||
}
|
||||
|
||||
m_mapThreadResult = new QMap<QString, int>*[getThreadNumber()];
|
||||
for(int i = 0; i < getThreadNumber(); i++)
|
||||
{
|
||||
m_mapThreadResult[i] = new QMap<QString, int>();
|
||||
}
|
||||
for(int i = 0; i < getThreadNumber(); i++)
|
||||
{
|
||||
*m_mapThreadResult[i] = m_pYMThread[i]->getResult();
|
||||
m_pYMThread[i]->clearResult();
|
||||
}
|
||||
|
||||
for(int i = 0;i < getThreadNumber(); i++)
|
||||
{
|
||||
delete m_pYMThread[i];
|
||||
}
|
||||
delete[] m_pYMThread;
|
||||
|
||||
EmergeThreadResult();
|
||||
|
||||
YMFilter* ymfilter = YMFilterFactory::getFilter(mapParam);
|
||||
//qDebug() << "EXEC";
|
||||
if(ymfilter != NULL)
|
||||
{
|
||||
ymfilter->setParam(m_mapParam);
|
||||
m_mapTotalResult = ymfilter->Exec(m_mapTotalResult);
|
||||
}
|
||||
delete ymfilter;
|
||||
|
||||
|
||||
QList<QString> listKeys = m_mapTotalResult.keys();
|
||||
|
||||
QString strKeys;
|
||||
|
||||
for(int i = 0; i < listKeys.count(); i++)
|
||||
{
|
||||
strKeys += (listKeys.at(i).trimmed() + " ");
|
||||
}
|
||||
|
||||
strKeys = strKeys.trimmed();
|
||||
|
||||
m_mapTotalResult.clear();
|
||||
|
||||
m_mapParam.insert("OneDepthKeys", strKeys);
|
||||
m_pDAInterface->reset();
|
||||
m_pYMThread = new YMorphereThread*[getThreadNumber()];
|
||||
for(int i = 0; i < getThreadNumber(); i++)
|
||||
{
|
||||
m_pYMThread[i] = ThreadFactory::getThread(m_mapParam);
|
||||
m_pYMThread[i]->setDataAlgorithmInterface(m_pDAInterface);
|
||||
m_pYMThread[i]->setMutex(&mutex);
|
||||
m_pYMThread[i]->setParam(m_mapParam);
|
||||
}
|
||||
for(int i = 0;i < getThreadNumber(); i++)
|
||||
{
|
||||
m_pYMThread[i]->start();
|
||||
}
|
||||
for(int i = 0;i < getThreadNumber(); i++)
|
||||
{
|
||||
m_pYMThread[i]->wait();
|
||||
}
|
||||
|
||||
m_mapThreadResult = new QMap<QString, int>*[getThreadNumber()];
|
||||
for(int i = 0; i < getThreadNumber(); i++)
|
||||
{
|
||||
m_mapThreadResult[i] = new QMap<QString, int>();
|
||||
}
|
||||
for(int i = 0; i < getThreadNumber(); i++)
|
||||
{
|
||||
*m_mapThreadResult[i] = m_pYMThread[i]->getResult();
|
||||
m_pYMThread[i]->clearResult();
|
||||
}
|
||||
|
||||
for(int i = 0;i < getThreadNumber(); i++)
|
||||
{
|
||||
delete m_pYMThread[i];
|
||||
}
|
||||
delete[] m_pYMThread;
|
||||
|
||||
EmergeThreadResult();
|
||||
|
||||
ymfilter = YMFilterFactory::getFilter(m_mapParam);
|
||||
//qDebug() << "EXEC";
|
||||
if(ymfilter != NULL)
|
||||
{
|
||||
ymfilter->setParam(m_mapParam);
|
||||
m_mapTotalResult = ymfilter->Exec(m_mapTotalResult);
|
||||
}
|
||||
delete ymfilter;
|
||||
|
||||
}
|
||||
|
||||
@@ -68,6 +68,13 @@ public:
|
||||
void Start();
|
||||
};
|
||||
|
||||
class YTwoDepthAAlgorithm:public YAlgorithm
|
||||
{
|
||||
public:
|
||||
void Start();
|
||||
};
|
||||
|
||||
|
||||
class YPlatformAlgorithm:public YAlgorithm
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -19,6 +19,10 @@ YMorphereThread* ThreadFactory::getThread(QMap<QString, QString> mapParam)
|
||||
{
|
||||
return new YTwoDepthMThread();
|
||||
}
|
||||
else if(mapParam.value("Algorithm").trimmed().compare("twodeptha", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return new YTwoDepthAMThread();
|
||||
}
|
||||
else if(mapParam.value("Algorithm").trimmed().compare("platformone", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return new YPlatformOneMThread();
|
||||
@@ -2080,3 +2084,382 @@ void YPlatformMThread::run()
|
||||
}
|
||||
mecab_destroy(mecab);
|
||||
}
|
||||
|
||||
|
||||
void YTwoDepthAMThread::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");
|
||||
|
||||
parseParam();
|
||||
|
||||
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;
|
||||
|
||||
int nDate = 0;
|
||||
while(true)
|
||||
{
|
||||
QString strTitle;
|
||||
QString strBody;
|
||||
QString strDate;
|
||||
QString strData;
|
||||
QString strPlatformTitle;
|
||||
QString strArticle;
|
||||
{
|
||||
mutex->lock();
|
||||
if(!m_pDAInterface->hasNext())
|
||||
{
|
||||
mutex->unlock();
|
||||
break;
|
||||
}
|
||||
strTitle = m_pDAInterface->getArticleTitle();
|
||||
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)
|
||||
{
|
||||
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))
|
||||
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;
|
||||
}
|
||||
|
||||
QString m_strDate;
|
||||
QString m_strKeyword;
|
||||
QString m_strMorphere;
|
||||
|
||||
switch(m_nPeriod)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_strDate = "ALL";
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
m_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());
|
||||
*/
|
||||
m_strDate = getWeeksInMonth(nDate);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
m_strDate = "M";
|
||||
if((nDate/100) < 10)
|
||||
m_strDate += "0";
|
||||
m_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);
|
||||
|
||||
QMap<QString, int> mapResult;
|
||||
QMap<QString, int> mapCheck;
|
||||
|
||||
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_slMorphereListAll)
|
||||
{
|
||||
if(strpumsa.at(0).trimmed().contains(strMorphere,Qt::CaseInsensitive))
|
||||
{
|
||||
m_strKeyword = strListLine.at(0).toLower();
|
||||
m_strMorphere = strMorphere;
|
||||
QString strkey = m_strDate + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
|
||||
|
||||
if(m_slMorphereList.contains(strMorphere, Qt::CaseInsensitive))
|
||||
{
|
||||
if(mapCheck.contains(strkey))
|
||||
{
|
||||
(mapCheck)[strkey]++;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
mapCheck.insert(strkey,1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(m_slMorphereList2.contains(strMorphere, Qt::CaseInsensitive))
|
||||
{
|
||||
if(mapResult.contains(strkey))
|
||||
{
|
||||
(mapResult)[strkey]++;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
mapResult.insert(strkey,1);
|
||||
}
|
||||
}
|
||||
strkey.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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(mapCheck.contains(str))
|
||||
{
|
||||
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
|
||||
{
|
||||
if(iterPos.key() == str)
|
||||
continue;
|
||||
QString key = iterPos.key();
|
||||
QStringList slkey = key.split("~!@", QString::SkipEmptyParts);
|
||||
int nLength = slkey.length();
|
||||
QString strkey = str + "~!@" + slkey.at(nLength - 2) + "~!@" + slkey.at(nLength - 1);
|
||||
if(m_mapResult.contains(strkey))
|
||||
{
|
||||
m_mapResult[strkey] += iterPos.value();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mapResult.insert(strkey, iterPos.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mecab_destroy(mecab);
|
||||
}
|
||||
|
||||
void YTwoDepthAMThread::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();
|
||||
|
||||
m_nDateStart = m_mapParam.value("DateStart").toInt();
|
||||
m_nDateEnd = m_mapParam.value("DateEnd").toInt();
|
||||
|
||||
m_bDateAll = true;
|
||||
|
||||
if(m_mapParam.value("DateALL") == "true")
|
||||
m_bDateAll = true;
|
||||
else
|
||||
m_bDateAll = false;
|
||||
|
||||
m_slMorphereList = m_mapParam.value("MorphereList").split(" ");
|
||||
m_slMorphereList2 = m_mapParam.value("MorphereList2").split(" ");
|
||||
|
||||
|
||||
m_slMorphereListAll = m_slMorphereList + m_slMorphereList2;
|
||||
m_slMorphereListAll.removeDuplicates();
|
||||
|
||||
m_strCKeyword = m_mapParam.value("CenterKeyword").trimmed();
|
||||
|
||||
m_slOneDepthKeys = m_mapParam.value("OneDepthKeys").split(" ");
|
||||
if(m_mapParam.value("CountMethod") == "Duplicate")
|
||||
m_bDuplicate = true;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -171,6 +171,33 @@ public:
|
||||
void parseParam();
|
||||
};
|
||||
|
||||
class YTwoDepthAMThread:public YMorphereThread
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
//QString getWeeksInMonth(unsigned int _nDate);
|
||||
|
||||
QString userdict;
|
||||
int m_nTitleBody;
|
||||
int m_nPeriod;
|
||||
unsigned int m_nDateStart;
|
||||
unsigned int m_nDateEnd;
|
||||
bool m_bDateAll;
|
||||
QStringList m_slMorphereList;
|
||||
QStringList m_slMorphereList2;
|
||||
QStringList m_slMorphereListAll;
|
||||
QString m_strCKeyword;
|
||||
QStringList m_slOneDepthKeys;
|
||||
bool m_bDuplicate;
|
||||
QString m_strRecentPeriod;
|
||||
int m_nArticle;
|
||||
|
||||
protected:
|
||||
void run();
|
||||
public:
|
||||
void parseParam();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // YCHILDRENTHREAD_H
|
||||
|
||||
@@ -20,6 +20,8 @@ YMFilter* YMFilterFactory::getFilter(QMap<QString, QString> mapParam)
|
||||
return new YMOneDepthFilter();
|
||||
else if(mapParam.value("Algorithm").trimmed().compare("twodepth", Qt::CaseInsensitive) == 0)
|
||||
return new YMTwoDepthFilter();
|
||||
else if(mapParam.value("Algorithm").trimmed().compare("twodeptha", Qt::CaseInsensitive) == 0)
|
||||
return new YMTwoDepthFilter();
|
||||
else if(mapParam.value("Algorithm").trimmed().compare("platformone", Qt::CaseInsensitive) == 0)
|
||||
return new YMPlatformOneFilter();
|
||||
else if(mapParam.value("Algorithm").trimmed().compare("platform", Qt::CaseInsensitive) == 0)
|
||||
@@ -28,11 +30,13 @@ YMFilter* YMFilterFactory::getFilter(QMap<QString, QString> mapParam)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
YMOneDepthFilter::YMOneDepthFilter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
YMOneDepthFilter::~YMOneDepthFilter()
|
||||
{
|
||||
|
||||
|
||||
@@ -658,6 +658,205 @@ void YMOneDepthWidget::D3View()
|
||||
|
||||
QString strHtml;
|
||||
|
||||
strHtml = "<!DOCTYPE html>"
|
||||
"\n<head>"
|
||||
"\n<meta charset=\"utf8\">"
|
||||
"\n<style>"
|
||||
"\n"
|
||||
"\n.node circle {"
|
||||
"\n cursor: pointer;"
|
||||
"\n stroke: #3182bd;"
|
||||
"\n stroke-width: 1.5px;"
|
||||
"\n}"
|
||||
"\n"
|
||||
"\n.node text {"
|
||||
"\n font: 14px 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</head>"
|
||||
"\n<body>"
|
||||
"\n<script src=\"http://d3js.org/d3.v3.min.js\"></script>"
|
||||
"\n<script>"
|
||||
"\n"
|
||||
"\nvar width = 1920,"
|
||||
"\n height = 1080,"
|
||||
"\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.toUtf8() + "';"
|
||||
"\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 force"
|
||||
"\n .nodes(nodes)"
|
||||
"\n .links(links)"
|
||||
"\n .start();"
|
||||
"\n"
|
||||
"\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 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\""
|
||||
"\n : d.children ? \"#c6dbef\" "
|
||||
"\n : \"#fd8d3c\"; // leaf node"
|
||||
"\n}"
|
||||
"\n"
|
||||
"\nfunction click(d) {"
|
||||
"\n if (d3.event.defaultPrevented) return;"
|
||||
"\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"
|
||||
"\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></body></html>"
|
||||
"\n";
|
||||
|
||||
QRegExp re("\\s{2,}");
|
||||
qDebug() << strHtml;
|
||||
|
||||
strHtml = strHtml.replace(re,"");
|
||||
/*
|
||||
QFile file("d3onedepth.html");
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
||||
|
||||
QTextStream out(&file);
|
||||
|
||||
out << strHtml;
|
||||
|
||||
file.close();
|
||||
*/
|
||||
m_WVD3View.setHtml(strHtml);
|
||||
//QUrl url("https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/");
|
||||
//m_WVD3View.settings()->testAttribute( QWebEngineSetting::JavascriptEnabled );
|
||||
//m_WVD3View.setContent(strHtml.toUtf8(), "text/html; charset=utf-8", url);
|
||||
//m_WVD3View.setHtml(strHtml, QUrl("file:///"));
|
||||
//m_WVD3View.settings()->setObjectCacheCapacities(0,0,0);
|
||||
m_WVD3View.repaint();
|
||||
m_WVD3View.show();
|
||||
}
|
||||
|
||||
void YMOneDepthWidget::D3ViewFile()
|
||||
{
|
||||
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 = "<!DOCTYPE html>"
|
||||
"\n<meta charset=\"utf8\">"
|
||||
"\n<style>"
|
||||
@@ -682,7 +881,8 @@ void YMOneDepthWidget::D3View()
|
||||
"\n"
|
||||
"\n</style>"
|
||||
"\n<body>"
|
||||
"\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js\"></script>"
|
||||
//"\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js\"></script>"
|
||||
"\n<script src=\"http://d3js.org/d3.v3.min.js\"></script>"
|
||||
"\n<script>"
|
||||
"\n"
|
||||
"\nvar width = 1920,"
|
||||
@@ -800,10 +1000,11 @@ void YMOneDepthWidget::D3View()
|
||||
QTextStream out(&file);
|
||||
|
||||
out << strHtml;
|
||||
|
||||
file.close();
|
||||
|
||||
m_WVD3View.setHtml(strHtml);
|
||||
QUrl url = QUrl::fromLocalFile(QDir::current().absoluteFilePath("d3onedepth.html"));
|
||||
|
||||
m_WVD3View.load(url);
|
||||
//QUrl url("https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/");
|
||||
//m_WVD3View.settings()->testAttribute( QWebEngineSetting::JavascriptEnabled );
|
||||
//m_WVD3View.setContent(strHtml.toUtf8(), "text/html; charset=utf-8", url);
|
||||
@@ -814,6 +1015,7 @@ void YMOneDepthWidget::D3View()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void YMOneDepthWidget::D3ViewTree()
|
||||
{
|
||||
QString strCKeyword = getCenterKeyword();
|
||||
@@ -1027,6 +1229,238 @@ void YMOneDepthWidget::D3ViewTree()
|
||||
"\n </body>"
|
||||
"\n</html>";
|
||||
|
||||
qDebug() << strHtml;
|
||||
/*
|
||||
QFile file("d3onedepthtree.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 YMOneDepthWidget::D3ViewTreeFile()
|
||||
{
|
||||
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 = "<!DOCTYPE html>"
|
||||
"\n <head>"
|
||||
"\n <meta charset=\"utf8\">"
|
||||
"\n"
|
||||
"\n <title>Tree Example</title>"
|
||||
"\n"
|
||||
"\n <style>"
|
||||
"\n "
|
||||
"\n .node {"
|
||||
"\n cursor: pointer;"
|
||||
"\n }"
|
||||
"\n"
|
||||
"\n .node circle {"
|
||||
"\n fill: #fff;"
|
||||
"\n stroke: steelblue;"
|
||||
"\n stroke-width: 2px;"
|
||||
"\n }"
|
||||
"\n"
|
||||
"\n .node text {"
|
||||
"\n font: 14px sans-serif;"
|
||||
"\n }"
|
||||
"\n"
|
||||
"\n .link {"
|
||||
"\n fill: none;"
|
||||
"\n stroke: #ccc;"
|
||||
"\n stroke-width: 2px;"
|
||||
"\n }"
|
||||
"\n "
|
||||
"\n </style>"
|
||||
"\n"
|
||||
"\n </head>"
|
||||
"\n"
|
||||
"\n <body>"
|
||||
"\n"
|
||||
"\n<!-- load the d3.js library --> "
|
||||
"\n<script src=\"http://d3js.org/d3.v3.min.js\"></script>"
|
||||
"\n "
|
||||
"\n<script>"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n// ************** Generate the tree diagram *****************"
|
||||
"\nvar margin = {top: 20, right: 120, bottom: 20, left: 120},"
|
||||
"\n width = 1920 - margin.right - margin.left,"
|
||||
"\n height = 1080 - margin.top - margin.bottom;"
|
||||
"\n "
|
||||
"\nvar i = 0,"
|
||||
"\n duration = 950,"
|
||||
"\n root;"
|
||||
"\n"
|
||||
"\nvar tree = d3.layout.tree()"
|
||||
"\n .size([height, width]);"
|
||||
"\n"
|
||||
"\nvar diagonal = d3.svg.diagonal()"
|
||||
"\n .projection(function(d) { return [d.y, d.x]; });"
|
||||
"\n"
|
||||
"\nvar svg = d3.select(\"body\").append(\"svg\")"
|
||||
"\n .attr(\"width\", width + margin.right + margin.left)"
|
||||
"\n .attr(\"height\", height + margin.top + margin.bottom)"
|
||||
"\n .append(\"g\")"
|
||||
"\n .attr(\"transform\", \"translate(\" + margin.left + \",\" + margin.top + \")\");"
|
||||
"\n"
|
||||
"\nvar jsonparam = '" + strjson.toUtf8() + "';"
|
||||
"\n root = JSON.parse(jsonparam);"
|
||||
|
||||
"\nroot.x0 = height / 2;"
|
||||
"\nroot.y0 = 0;"
|
||||
"\n "
|
||||
"\nupdate(root);"
|
||||
"\n"
|
||||
"\nd3.select(self.frameElement).style(\"height\", \"500px\");"
|
||||
"\n"
|
||||
"\nfunction update(source) {"
|
||||
"\n"
|
||||
"\n // Compute the new tree layout."
|
||||
"\n var nodes = tree.nodes(root).reverse(),"
|
||||
"\n links = tree.links(nodes);"
|
||||
"\n"
|
||||
"\n // Normalize for fixed-depth."
|
||||
"\n nodes.forEach(function(d) { d.y = d.depth * 180; });"
|
||||
"\n"
|
||||
"\n var node = svg.selectAll(\"g.node\")"
|
||||
"\n .data(nodes, function(d) { return d.id || (d.id = ++i); });"
|
||||
"\n"
|
||||
"\n // Enter any new nodes at the parent's previous position."
|
||||
"\n var nodeEnter = node.enter().append(\"g\")"
|
||||
"\n .attr(\"class\", \"node\")"
|
||||
"\n .attr(\"transform\", function(d) { return \"translate(\" + source.y0 + \",\" + source.x0 + \")\"; })"
|
||||
"\n .on(\"click\", click);"
|
||||
"\n"
|
||||
"\n nodeEnter.append(\"circle\")"
|
||||
"\n .attr(\"r\", 1e-6)"
|
||||
"\n .style(\"fill\", function(d) { return d._children ? \"lightsteelblue\" : \"#fff\"; });"
|
||||
"\n"
|
||||
"\n nodeEnter.append(\"text\")"
|
||||
"\n .attr(\"x\", function(d) { return d.children || d._children ? -13 : 13; })"
|
||||
"\n .attr(\"dy\", \".35em\")"
|
||||
"\n .attr(\"text-anchor\", function(d) { return d.children || d._children ? \"end\" : \"start\"; })"
|
||||
"\n .text(function(d) { return d.name; })"
|
||||
"\n .style(\"fill-opacity\", 1e-6);"
|
||||
"\n"
|
||||
"\n // Transition nodes to their new position."
|
||||
"\n var nodeUpdate = node.transition()"
|
||||
"\n .duration(duration)"
|
||||
"\n .attr(\"transform\", function(d) { return \"translate(\" + d.y + \",\" + d.x + \")\"; });"
|
||||
"\n"
|
||||
"\n nodeUpdate.select(\"circle\")"
|
||||
"\n .attr(\"r\", 10)"
|
||||
"\n .style(\"fill\", function(d) { return d._children ? \"lightsteelblue\" : \"#fff\"; });"
|
||||
"\n"
|
||||
"\n nodeUpdate.select(\"text\")"
|
||||
"\n .style(\"fill-opacity\", 1);"
|
||||
"\n"
|
||||
"\n // Transition exiting nodes to the parent's new position."
|
||||
"\n var nodeExit = node.exit().transition()"
|
||||
"\n .duration(duration)"
|
||||
"\n .attr(\"transform\", function(d) { return \"translate(\" + source.y + \",\" + source.x + \")\"; })"
|
||||
"\n .remove();"
|
||||
"\n"
|
||||
"\n nodeExit.select(\"circle\")"
|
||||
"\n .attr(\"r\", 1e-6);"
|
||||
"\n"
|
||||
"\n nodeExit.select(\"text\")"
|
||||
"\n .style(\"fill-opacity\", 1e-6);"
|
||||
"\n"
|
||||
"\n var link = svg.selectAll(\"path.link\")"
|
||||
"\n .data(links, function(d) { return d.target.id; });"
|
||||
"\n"
|
||||
"\n // Enter any new links at the parent's previous position."
|
||||
"\n link.enter().insert(\"path\", \"g\")"
|
||||
"\n .attr(\"class\", \"link\")"
|
||||
"\n .attr(\"d\", function(d) {"
|
||||
"\n var o = {x: source.x0, y: source.y0};"
|
||||
"\n return diagonal({source: o, target: o});"
|
||||
"\n });"
|
||||
"\n"
|
||||
"\n // Transition links to their new position."
|
||||
"\n link.transition()"
|
||||
"\n .duration(duration)"
|
||||
"\n .attr(\"d\", diagonal);"
|
||||
"\n"
|
||||
"\n // Transition exiting nodes to the parent's new position."
|
||||
"\n link.exit().transition()"
|
||||
"\n .duration(duration)"
|
||||
"\n .attr(\"d\", function(d) {"
|
||||
"\n var o = {x: source.x, y: source.y};"
|
||||
"\n return diagonal({source: o, target: o});"
|
||||
"\n })"
|
||||
"\n .remove();"
|
||||
"\n"
|
||||
"\n // Stash the old positions for transition."
|
||||
"\n nodes.forEach(function(d) {"
|
||||
"\n d.x0 = d.x;"
|
||||
"\n d.y0 = d.y;"
|
||||
"\n });"
|
||||
"\n}"
|
||||
"\n"
|
||||
"\n// Toggle children on click."
|
||||
"\nfunction click(d) {"
|
||||
"\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(d);"
|
||||
"\n}"
|
||||
"\n"
|
||||
"\n</script>"
|
||||
"\n "
|
||||
"\n </body>"
|
||||
"\n</html>";
|
||||
|
||||
qDebug() << strHtml;
|
||||
|
||||
QFile file("d3onedepthtree.html");
|
||||
@@ -1037,7 +1471,10 @@ void YMOneDepthWidget::D3ViewTree()
|
||||
out << strHtml;
|
||||
|
||||
file.close();
|
||||
m_WVD3View.setHtml(strHtml);
|
||||
QUrl url = QUrl::fromLocalFile(QDir::current().absoluteFilePath("d3onedepthtree.html"));
|
||||
|
||||
m_WVD3View.load(url);
|
||||
//m_WVD3View.setHtml(strHtml);
|
||||
//m_WVD3View.settings()->setObjectCacheCapacities(0,0,0);
|
||||
m_WVD3View.repaint();
|
||||
m_WVD3View.show();
|
||||
|
||||
@@ -47,6 +47,8 @@ public:
|
||||
void TestUpload();
|
||||
void D3View();
|
||||
void D3ViewTree();
|
||||
void D3ViewFile();
|
||||
void D3ViewTreeFile();
|
||||
void setParam(QString strJson);
|
||||
private:
|
||||
// Data
|
||||
|
||||
@@ -74,6 +74,19 @@ void YMorphereWidget::D3ViewTree()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void YMorphereWidget::D3ViewFile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void YMorphereWidget::D3ViewTreeFile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void YMorphereWidget::setParam(QString strJson)
|
||||
{
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
#include "yalgorithm.h"
|
||||
#include <QTabWidget>
|
||||
#include "widget.h"
|
||||
#include <QWebEngineView>
|
||||
class QWebViewChild:public QWebEngineView
|
||||
#include <QWebView>
|
||||
class QWebViewChild:public QWebView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWebViewChild(QWidget *parent = 0):QWebEngineView(parent)
|
||||
QWebViewChild(QWidget *parent = 0):QWebView(parent)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -53,6 +53,8 @@ public:
|
||||
virtual void TestUpload();
|
||||
virtual void D3View();
|
||||
virtual void D3ViewTree();
|
||||
virtual void D3ViewFile();
|
||||
virtual void D3ViewTreeFile();
|
||||
void setTabWidget(QTabWidget* tabWidget);
|
||||
virtual void setParam(QString strJson);
|
||||
QString getName();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -49,6 +49,8 @@ public:
|
||||
void TestUpload();
|
||||
void D3View();
|
||||
void D3ViewTree();
|
||||
void D3ViewFile();
|
||||
void D3ViewTreeFile();
|
||||
void setParam(QString strJson);
|
||||
private:
|
||||
// Data
|
||||
|
||||
@@ -1242,6 +1242,7 @@ void YMTwoDepthWidget::D3View()
|
||||
QString strHtml;
|
||||
|
||||
strHtml = "<!DOCTYPE html>"
|
||||
"\n<head>"
|
||||
"\n<meta charset=\"utf8\">"
|
||||
"\n<style>"
|
||||
"\n"
|
||||
@@ -1264,8 +1265,9 @@ void YMTwoDepthWidget::D3View()
|
||||
"\n}"
|
||||
"\n"
|
||||
"\n</style>"
|
||||
"\n</head>"
|
||||
"\n<body>"
|
||||
"\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js\"></script>"
|
||||
"\n<script src=\"http://d3js.org/d3.v3.min.js\"></script>"
|
||||
"\n<script>"
|
||||
"\n"
|
||||
"\nvar width = 1920,"
|
||||
@@ -1298,13 +1300,11 @@ void YMTwoDepthWidget::D3View()
|
||||
"\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();"
|
||||
@@ -1312,7 +1312,6 @@ void YMTwoDepthWidget::D3View()
|
||||
"\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();"
|
||||
@@ -1343,14 +1342,13 @@ void YMTwoDepthWidget::D3View()
|
||||
"\n}"
|
||||
"\n"
|
||||
"\nfunction color(d) {"
|
||||
"\n return d._children ? \"#3182bd\" // collapsed package"
|
||||
"\n : d.children ? \"#c6dbef\" // expanded package"
|
||||
"\n return d._children ? \"#3182bd\""
|
||||
"\n : d.children ? \"#c6dbef\" "
|
||||
"\n : \"#fd8d3c\"; // leaf node"
|
||||
"\n}"
|
||||
"\n"
|
||||
"\n// Toggle children on click."
|
||||
"\nfunction click(d) {"
|
||||
"\n if (d3.event.defaultPrevented) return; // ignore drag"
|
||||
"\n if (d3.event.defaultPrevented) return;"
|
||||
"\n if (d.children) {"
|
||||
"\n d._children = d.children;"
|
||||
"\n d.children = null;"
|
||||
@@ -1361,7 +1359,6 @@ void YMTwoDepthWidget::D3View()
|
||||
"\n update();"
|
||||
"\n}"
|
||||
"\n"
|
||||
"\n// Returns a list of all nodes under the root."
|
||||
"\nfunction flatten(root) {"
|
||||
"\n var nodes = [], i = 0;"
|
||||
"\n"
|
||||
@@ -1378,6 +1375,232 @@ void YMTwoDepthWidget::D3View()
|
||||
"\n</script></body></html>"
|
||||
"\n";
|
||||
|
||||
QRegExp re("\\s{2,}");
|
||||
qDebug() << strHtml;
|
||||
|
||||
strHtml = strHtml.replace(re,"");
|
||||
/*
|
||||
qDebug() << strHtml;
|
||||
|
||||
QFile file("d3twodepth.html");
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
||||
|
||||
QTextStream out(&file);
|
||||
|
||||
out << strHtml;
|
||||
|
||||
file.close();
|
||||
*/
|
||||
m_WVD3View.setHtml(strHtml.toUtf8());
|
||||
//m_WVD3View.settings()->setObjectCacheCapacities(0,0,0);
|
||||
m_WVD3View.repaint();
|
||||
m_WVD3View.show();
|
||||
|
||||
}
|
||||
|
||||
void YMTwoDepthWidget::D3ViewFile()
|
||||
{
|
||||
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 = "<!DOCTYPE html>"
|
||||
"\n<head>"
|
||||
"\n<meta charset=\"utf8\">"
|
||||
"\n<style>"
|
||||
"\n"
|
||||
"\n.node circle {"
|
||||
"\n cursor: pointer;"
|
||||
"\n stroke: #3182bd;"
|
||||
"\n stroke-width: 1.5px;"
|
||||
"\n}"
|
||||
"\n"
|
||||
"\n.node text {"
|
||||
"\n font: 14px 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</head>"
|
||||
"\n<body>"
|
||||
"\n<script src=\"http://d3js.org/d3.v3.min.js\"></script>"
|
||||
"\n<script>"
|
||||
"\n"
|
||||
"\nvar width = 1920,"
|
||||
"\n height = 1080,"
|
||||
"\n root;"
|
||||
"\n"
|
||||
"\nvar force = d3.layout.force()"
|
||||
"\n .linkDistance(40)"
|
||||
"\n .charge(-60)"
|
||||
"\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.toUtf8() + "';"
|
||||
"\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 force"
|
||||
"\n .nodes(nodes)"
|
||||
"\n .links(links)"
|
||||
"\n .start();"
|
||||
"\n"
|
||||
"\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 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\""
|
||||
"\n : d.children ? \"#c6dbef\" "
|
||||
"\n : \"#fd8d3c\"; // leaf node"
|
||||
"\n}"
|
||||
"\n"
|
||||
"\nfunction click(d) {"
|
||||
"\n if (d3.event.defaultPrevented) return;"
|
||||
"\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"
|
||||
"\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></body></html>"
|
||||
"\n";
|
||||
|
||||
QRegExp re("\\s{2,}");
|
||||
qDebug() << strHtml;
|
||||
|
||||
strHtml = strHtml.replace(re,"");
|
||||
|
||||
qDebug() << strHtml;
|
||||
|
||||
QFile file("d3twodepth.html");
|
||||
@@ -1389,7 +1612,9 @@ void YMTwoDepthWidget::D3View()
|
||||
|
||||
file.close();
|
||||
|
||||
m_WVD3View.setHtml(strHtml.toUtf8());
|
||||
QUrl url = QUrl::fromLocalFile(QDir::current().absoluteFilePath("d3twodepth.html"));
|
||||
|
||||
m_WVD3View.load(url);
|
||||
//m_WVD3View.settings()->setObjectCacheCapacities(0,0,0);
|
||||
m_WVD3View.repaint();
|
||||
m_WVD3View.show();
|
||||
@@ -1631,6 +1856,261 @@ void YMTwoDepthWidget::D3ViewTree()
|
||||
"\n "
|
||||
"\n </body>"
|
||||
"\n</html>";
|
||||
/*
|
||||
qDebug() << strHtml;
|
||||
|
||||
QFile file("d3twodepthtree.html");
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
||||
|
||||
QTextStream out(&file);
|
||||
|
||||
out << strHtml;
|
||||
|
||||
file.close();
|
||||
*/
|
||||
m_WVD3View.setHtml(strHtml.toUtf8());
|
||||
//m_WVD3View.settings()->setObjectCacheCapacities(0,0,0);
|
||||
m_WVD3View.repaint();
|
||||
m_WVD3View.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void YMTwoDepthWidget::D3ViewTreeFile()
|
||||
{
|
||||
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 = "<!DOCTYPE html>"
|
||||
"\n <head>"
|
||||
"\n <meta charset=\"utf8\">"
|
||||
"\n"
|
||||
"\n <title>Tree Example</title>"
|
||||
"\n"
|
||||
"\n <style>"
|
||||
"\n "
|
||||
"\n .node {"
|
||||
"\n cursor: pointer;"
|
||||
"\n }"
|
||||
"\n"
|
||||
"\n .node circle {"
|
||||
"\n fill: #fff;"
|
||||
"\n stroke: steelblue;"
|
||||
"\n stroke-width: 2px;"
|
||||
"\n }"
|
||||
"\n"
|
||||
"\n .node text {"
|
||||
"\n font: 14px sans-serif;"
|
||||
"\n }"
|
||||
"\n"
|
||||
"\n .link {"
|
||||
"\n fill: none;"
|
||||
"\n stroke: #ccc;"
|
||||
"\n stroke-width: 2px;"
|
||||
"\n }"
|
||||
"\n "
|
||||
"\n </style>"
|
||||
"\n"
|
||||
"\n </head>"
|
||||
"\n"
|
||||
"\n <body>"
|
||||
"\n"
|
||||
"\n<!-- load the d3.js library --> "
|
||||
"\n<script src=\"http://d3js.org/d3.v3.min.js\"></script>"
|
||||
"\n "
|
||||
"\n<script>"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n// ************** Generate the tree diagram *****************"
|
||||
"\nvar margin = {top: 20, right: 120, bottom: 20, left: 120},"
|
||||
"\n width = 1920 - margin.right - margin.left,"
|
||||
"\n height = 1080 - margin.top - margin.bottom;"
|
||||
"\n "
|
||||
"\nvar i = 0,"
|
||||
"\n duration = 950,"
|
||||
"\n root;"
|
||||
"\n"
|
||||
"\nvar tree = d3.layout.tree()"
|
||||
"\n .size([height, width]);"
|
||||
"\n"
|
||||
"\nvar diagonal = d3.svg.diagonal()"
|
||||
"\n .projection(function(d) { return [d.y, d.x]; });"
|
||||
"\n"
|
||||
"\nvar svg = d3.select(\"body\").append(\"svg\")"
|
||||
"\n .attr(\"width\", width + margin.right + margin.left)"
|
||||
"\n .attr(\"height\", height + margin.top + margin.bottom)"
|
||||
"\n .append(\"g\")"
|
||||
"\n .attr(\"transform\", \"translate(\" + margin.left + \",\" + margin.top + \")\");"
|
||||
"\n"
|
||||
"\nvar jsonparam = '" + strjson.toUtf8() + "';"
|
||||
"\n root = JSON.parse(jsonparam);"
|
||||
|
||||
"\nroot.x0 = height / 2;"
|
||||
"\nroot.y0 = 0;"
|
||||
"\n "
|
||||
"\nupdate(root);"
|
||||
"\n"
|
||||
"\nd3.select(self.frameElement).style(\"height\", \"500px\");"
|
||||
"\n"
|
||||
"\nfunction update(source) {"
|
||||
"\n"
|
||||
"\n // Compute the new tree layout."
|
||||
"\n var nodes = tree.nodes(root).reverse(),"
|
||||
"\n links = tree.links(nodes);"
|
||||
"\n"
|
||||
"\n // Normalize for fixed-depth."
|
||||
"\n nodes.forEach(function(d) { d.y = d.depth * 180; });"
|
||||
"\n"
|
||||
"\n var node = svg.selectAll(\"g.node\")"
|
||||
"\n .data(nodes, function(d) { return d.id || (d.id = ++i); });"
|
||||
"\n"
|
||||
"\n // Enter any new nodes at the parent's previous position."
|
||||
"\n var nodeEnter = node.enter().append(\"g\")"
|
||||
"\n .attr(\"class\", \"node\")"
|
||||
"\n .attr(\"transform\", function(d) { return \"translate(\" + source.y0 + \",\" + source.x0 + \")\"; })"
|
||||
"\n .on(\"click\", click);"
|
||||
"\n"
|
||||
"\n nodeEnter.append(\"circle\")"
|
||||
"\n .attr(\"r\", 1e-6)"
|
||||
"\n .style(\"fill\", function(d) { return d._children ? \"lightsteelblue\" : \"#fff\"; });"
|
||||
"\n"
|
||||
"\n nodeEnter.append(\"text\")"
|
||||
"\n .attr(\"x\", function(d) { return d.children || d._children ? -13 : 13; })"
|
||||
"\n .attr(\"dy\", \".35em\")"
|
||||
"\n .attr(\"text-anchor\", function(d) { return d.children || d._children ? \"end\" : \"start\"; })"
|
||||
"\n .text(function(d) { return d.name; })"
|
||||
"\n .style(\"fill-opacity\", 1e-6);"
|
||||
"\n"
|
||||
"\n // Transition nodes to their new position."
|
||||
"\n var nodeUpdate = node.transition()"
|
||||
"\n .duration(duration)"
|
||||
"\n .attr(\"transform\", function(d) { return \"translate(\" + d.y + \",\" + d.x + \")\"; });"
|
||||
"\n"
|
||||
"\n nodeUpdate.select(\"circle\")"
|
||||
"\n .attr(\"r\", 10)"
|
||||
"\n .style(\"fill\", function(d) { return d._children ? \"lightsteelblue\" : \"#fff\"; });"
|
||||
"\n"
|
||||
"\n nodeUpdate.select(\"text\")"
|
||||
"\n .style(\"fill-opacity\", 1);"
|
||||
"\n"
|
||||
"\n // Transition exiting nodes to the parent's new position."
|
||||
"\n var nodeExit = node.exit().transition()"
|
||||
"\n .duration(duration)"
|
||||
"\n .attr(\"transform\", function(d) { return \"translate(\" + source.y + \",\" + source.x + \")\"; })"
|
||||
"\n .remove();"
|
||||
"\n"
|
||||
"\n nodeExit.select(\"circle\")"
|
||||
"\n .attr(\"r\", 1e-6);"
|
||||
"\n"
|
||||
"\n nodeExit.select(\"text\")"
|
||||
"\n .style(\"fill-opacity\", 1e-6);"
|
||||
"\n"
|
||||
"\n var link = svg.selectAll(\"path.link\")"
|
||||
"\n .data(links, function(d) { return d.target.id; });"
|
||||
"\n"
|
||||
"\n // Enter any new links at the parent's previous position."
|
||||
"\n link.enter().insert(\"path\", \"g\")"
|
||||
"\n .attr(\"class\", \"link\")"
|
||||
"\n .attr(\"d\", function(d) {"
|
||||
"\n var o = {x: source.x0, y: source.y0};"
|
||||
"\n return diagonal({source: o, target: o});"
|
||||
"\n });"
|
||||
"\n"
|
||||
"\n // Transition links to their new position."
|
||||
"\n link.transition()"
|
||||
"\n .duration(duration)"
|
||||
"\n .attr(\"d\", diagonal);"
|
||||
"\n"
|
||||
"\n // Transition exiting nodes to the parent's new position."
|
||||
"\n link.exit().transition()"
|
||||
"\n .duration(duration)"
|
||||
"\n .attr(\"d\", function(d) {"
|
||||
"\n var o = {x: source.x, y: source.y};"
|
||||
"\n return diagonal({source: o, target: o});"
|
||||
"\n })"
|
||||
"\n .remove();"
|
||||
"\n"
|
||||
"\n // Stash the old positions for transition."
|
||||
"\n nodes.forEach(function(d) {"
|
||||
"\n d.x0 = d.x;"
|
||||
"\n d.y0 = d.y;"
|
||||
"\n });"
|
||||
"\n}"
|
||||
"\n"
|
||||
"\n// Toggle children on click."
|
||||
"\nfunction click(d) {"
|
||||
"\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(d);"
|
||||
"\n}"
|
||||
"\n"
|
||||
"\n</script>"
|
||||
"\n "
|
||||
"\n </body>"
|
||||
"\n</html>";
|
||||
|
||||
qDebug() << strHtml;
|
||||
|
||||
@@ -1643,7 +2123,9 @@ void YMTwoDepthWidget::D3ViewTree()
|
||||
|
||||
file.close();
|
||||
|
||||
m_WVD3View.setHtml(strHtml.toUtf8());
|
||||
QUrl url = QUrl::fromLocalFile(QDir::current().absoluteFilePath("d3twodepthtree.html"));
|
||||
|
||||
m_WVD3View.load(url);
|
||||
//m_WVD3View.settings()->setObjectCacheCapacities(0,0,0);
|
||||
m_WVD3View.repaint();
|
||||
m_WVD3View.show();
|
||||
|
||||
@@ -49,6 +49,8 @@ public:
|
||||
void TestUpload();
|
||||
void D3View();
|
||||
void D3ViewTree();
|
||||
void D3ViewFile();
|
||||
void D3ViewTreeFile();
|
||||
void setParam(QString strJson);
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
#include <QJsonObject>
|
||||
YMUploadWidget::YMUploadWidget(QWidget *parent):QWidget(parent)
|
||||
{
|
||||
m_pgbAnalysis = setUploadWidgets();
|
||||
m_pgbMorphere = setUploadWidgets();
|
||||
QVBoxLayout *vMainLayout = new QVBoxLayout;
|
||||
|
||||
vMainLayout->addWidget(m_pgbAnalysis);
|
||||
AnalysisGroupRefresh();
|
||||
vMainLayout->addWidget(m_pgbMorphere);
|
||||
MorphereGroupRefresh();
|
||||
setLayout(vMainLayout);
|
||||
}
|
||||
|
||||
@@ -36,22 +36,22 @@ 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);
|
||||
m_plwMorphereGroup = new QListWidget;
|
||||
m_pleMorphereGroup = new QLineEdit;
|
||||
vlayout->addWidget(m_plwMorphereGroup);
|
||||
vlayout->addWidget(m_pleMorphereGroup);
|
||||
{
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
QPushButton *pbInsert = new QPushButton("Insert");
|
||||
connect(pbInsert, SIGNAL(released()),this, SLOT(AnalysisGroupInsert()));
|
||||
connect(pbInsert, SIGNAL(released()),this, SLOT(MorphereGroupInsert()));
|
||||
QPushButton *pbDelete = new QPushButton("Delete");
|
||||
connect(pbDelete, SIGNAL(released()),this, SLOT(AnalysisGroupDelete()));
|
||||
connect(pbDelete, SIGNAL(released()),this, SLOT(MorphereGroupDelete()));
|
||||
QPushButton *pbModify = new QPushButton("Modfiy");
|
||||
connect(pbModify, SIGNAL(released()),this, SLOT(AnalysisGroupModify()));
|
||||
connect(pbModify, SIGNAL(released()),this, SLOT(MorphereGroupModify()));
|
||||
QPushButton *pbCopy_Paste = new QPushButton("Copy&Paste");
|
||||
connect(pbCopy_Paste, SIGNAL(released()),this, SLOT(AnalysisGroupCopyPaste()));
|
||||
connect(pbCopy_Paste, SIGNAL(released()),this, SLOT(MorphereGroupCopyPaste()));
|
||||
QPushButton *pbRefresh = new QPushButton("Refresh");
|
||||
connect(pbRefresh, SIGNAL(released()),this, SLOT(AnalysisGroupRefresh()));
|
||||
connect(pbRefresh, SIGNAL(released()),this, SLOT(MorphereGroupRefresh()));
|
||||
|
||||
hlayout->addWidget(pbInsert);
|
||||
hlayout->addWidget(pbDelete);
|
||||
@@ -64,9 +64,9 @@ QGroupBox *YMUploadWidget::setUploadWidgets()
|
||||
}
|
||||
{
|
||||
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||
m_plwAnalysis = new QListWidget;
|
||||
vlayout->addWidget(m_plwAnalysis);
|
||||
connect(m_plwAnalysis,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(currentAnalysisItemChanged(QListWidgetItem*,QListWidgetItem*)));
|
||||
m_plwMorphere = new QListWidget;
|
||||
vlayout->addWidget(m_plwMorphere);
|
||||
connect(m_plwMorphere,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(currentMorphereItemChanged(QListWidgetItem*,QListWidgetItem*)));
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
QPushButton *pbAdd = new QPushButton("Add");
|
||||
QPushButton *pbUp = new QPushButton("Up");
|
||||
@@ -77,23 +77,23 @@ QGroupBox *YMUploadWidget::setUploadWidgets()
|
||||
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()));
|
||||
connect(pbAdd, SIGNAL(released()),this, SLOT(MorphereAdd()));
|
||||
connect(pbUp, SIGNAL(released()),this, SLOT(MorphereUp()));
|
||||
connect(pbDown, SIGNAL(released()),this, SLOT(MorphereDown()));
|
||||
connect(pbDelete, SIGNAL(released()),this, SLOT(MorphereDelete()));
|
||||
hMainlayout->addLayout(vlayout);
|
||||
}
|
||||
m_pgbAnalysis = new QGroupBox(tr("Upload"));
|
||||
m_pgbAnalysis->setCheckable(true);
|
||||
m_pgbAnalysis->setChecked(false);
|
||||
m_pgbAnalysis->setLayout(hMainlayout);
|
||||
m_pgbMorphere = new QGroupBox(tr("Upload"));
|
||||
m_pgbMorphere->setCheckable(true);
|
||||
m_pgbMorphere->setChecked(false);
|
||||
m_pgbMorphere->setLayout(hMainlayout);
|
||||
|
||||
connect(m_plwAnalysisGroup,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(currentGroupItemChanged(QListWidgetItem *, QListWidgetItem *)));
|
||||
return m_pgbAnalysis;
|
||||
connect(m_plwMorphereGroup,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(currentGroupItemChanged(QListWidgetItem *, QListWidgetItem *)));
|
||||
return m_pgbMorphere;
|
||||
}
|
||||
|
||||
|
||||
void YMUploadWidget::AnalysisGroupInsert()
|
||||
void YMUploadWidget::MorphereGroupInsert()
|
||||
{
|
||||
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||
@@ -108,14 +108,14 @@ void YMUploadWidget::AnalysisGroupInsert()
|
||||
return;
|
||||
}
|
||||
|
||||
QString strQuery = QString("insert into analysisgroup set "
|
||||
"name = '" + m_pleAnalysisGroup->text() + "'");
|
||||
QString strQuery = QString("insert into morpheregroup set "
|
||||
"name = '" + m_pleMorphereGroup->text() + "'");
|
||||
db.exec(strQuery.toUtf8());
|
||||
db.close();
|
||||
AnalysisGroupRefresh();
|
||||
MorphereGroupRefresh();
|
||||
}
|
||||
|
||||
void YMUploadWidget::AnalysisGroupDelete()
|
||||
void YMUploadWidget::MorphereGroupDelete()
|
||||
{
|
||||
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||
@@ -130,19 +130,19 @@ void YMUploadWidget::AnalysisGroupDelete()
|
||||
qDebug() << db.lastError().text();
|
||||
return;
|
||||
}
|
||||
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
|
||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||
{
|
||||
QString strQuery = QString("delete from analysisgroup where id = " + item->data(Qt::UserRole).toString());
|
||||
QString strQuery = QString("delete from morpheregroup where id = " + item->data(Qt::UserRole).toString());
|
||||
db.exec(strQuery.toUtf8());
|
||||
strQuery = QString("delete from analysis where analysisgroup_id = " + item->data(Qt::UserRole).toString());
|
||||
strQuery = QString("delete from morphere where morpheregroup_id = " + item->data(Qt::UserRole).toString());
|
||||
db.exec(strQuery.toUtf8());
|
||||
RefreshAnalysis(item->data(Qt::UserRole).toInt());
|
||||
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
||||
}
|
||||
db.close();
|
||||
AnalysisGroupRefresh();
|
||||
MorphereGroupRefresh();
|
||||
}
|
||||
|
||||
void YMUploadWidget::AnalysisGroupModify()
|
||||
void YMUploadWidget::MorphereGroupModify()
|
||||
{
|
||||
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||
@@ -156,17 +156,17 @@ void YMUploadWidget::AnalysisGroupModify()
|
||||
qDebug() << db.lastError().text();
|
||||
return;
|
||||
}
|
||||
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
|
||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||
{
|
||||
QString strQuery = QString("update analysisgroup set name = '" + m_pleAnalysisGroup->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());
|
||||
qDebug() << strQuery;
|
||||
db.exec(strQuery.toUtf8());
|
||||
}
|
||||
db.close();
|
||||
AnalysisGroupRefresh();
|
||||
MorphereGroupRefresh();
|
||||
}
|
||||
|
||||
void YMUploadWidget::AnalysisGroupCopyPaste()
|
||||
void YMUploadWidget::MorphereGroupCopyPaste()
|
||||
{
|
||||
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||
@@ -181,28 +181,28 @@ void YMUploadWidget::AnalysisGroupCopyPaste()
|
||||
qDebug() << db.lastError().text();
|
||||
return;
|
||||
}
|
||||
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
|
||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||
{
|
||||
QSqlQuery query;
|
||||
QString strQuery = QString("insert into analysisgroup set "
|
||||
QString strQuery = QString("insert into morpheregroup set "
|
||||
"name = '" + item->text() + "-'");
|
||||
query.exec(strQuery.toUtf8());
|
||||
query.exec("select max(id) from analysisgroup");
|
||||
query.exec("select max(id) from morpheregroup");
|
||||
if (query.next())
|
||||
{
|
||||
strQuery = QString("insert into analysis (type,data,analysisgroup_id) select type,data,");
|
||||
strQuery = QString("insert into morphere (type,data,morpheregroup_id) select type,data,");
|
||||
strQuery += query.value(0).toString();
|
||||
strQuery += " from analysis where analysisgroup_id = " + item->data(Qt::UserRole).toString();
|
||||
strQuery += " from morphere where morpheregroup_id = " + item->data(Qt::UserRole).toString();
|
||||
qDebug() << strQuery;
|
||||
query.exec(strQuery.toUtf8());
|
||||
}
|
||||
}
|
||||
db.close();
|
||||
AnalysisGroupRefresh();
|
||||
MorphereGroupRefresh();
|
||||
}
|
||||
|
||||
|
||||
void YMUploadWidget::AnalysisGroupRefresh()
|
||||
void YMUploadWidget::MorphereGroupRefresh()
|
||||
{
|
||||
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||
@@ -217,18 +217,18 @@ void YMUploadWidget::AnalysisGroupRefresh()
|
||||
qDebug() << db.lastError().text();
|
||||
return;
|
||||
}
|
||||
m_plwAnalysisGroup->clear();
|
||||
QSqlQuery query("select id,name from analysisgroup");
|
||||
m_plwMorphereGroup->clear();
|
||||
QSqlQuery query("select id,name from morpheregroup");
|
||||
while (query.next())
|
||||
{
|
||||
QListWidgetItem *pItem = new QListWidgetItem(query.value(1).toString(),m_plwAnalysisGroup);
|
||||
QListWidgetItem *pItem = new QListWidgetItem(query.value(1).toString(),m_plwMorphereGroup);
|
||||
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||
}
|
||||
db.close();
|
||||
}
|
||||
|
||||
|
||||
void YMUploadWidget::RefreshAnalysis(int _nGroup)
|
||||
void YMUploadWidget::RefreshMorphere(int _nGroup)
|
||||
{
|
||||
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||
@@ -243,10 +243,10 @@ void YMUploadWidget::RefreshAnalysis(int _nGroup)
|
||||
qDebug() << db.lastError().text();
|
||||
return;
|
||||
}
|
||||
QSqlQuery query("select id,type,data from analysis where analysisgroup_id = " + QString::number(_nGroup));
|
||||
QSqlQuery query("select id,type,data from morphere where morpheregroup_id = " + QString::number(_nGroup));
|
||||
|
||||
SJson json;
|
||||
m_plwAnalysis->clear();
|
||||
m_plwMorphere->clear();
|
||||
while (query.next())
|
||||
{
|
||||
QString str;
|
||||
@@ -263,7 +263,7 @@ void YMUploadWidget::RefreshAnalysis(int _nGroup)
|
||||
|
||||
str = str.left(str.length() - 1);
|
||||
|
||||
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwAnalysis);
|
||||
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwMorphere);
|
||||
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||
}
|
||||
db.close();
|
||||
@@ -274,14 +274,14 @@ void YMUploadWidget::currentGroupItemChanged(QListWidgetItem *_pCurrent, QListWi
|
||||
{
|
||||
Q_UNUSED(_pPrev);
|
||||
if (_pCurrent == 0) return;
|
||||
RefreshAnalysis(_pCurrent->data(Qt::UserRole).toInt());
|
||||
m_pleAnalysisGroup->setText(_pCurrent->text());
|
||||
m_pleAnalysisGroup->repaint();
|
||||
RefreshMorphere(_pCurrent->data(Qt::UserRole).toInt());
|
||||
m_pleMorphereGroup->setText(_pCurrent->text());
|
||||
m_pleMorphereGroup->repaint();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void YMUploadWidget::AnalysisDelete()
|
||||
void YMUploadWidget::MorphereDelete()
|
||||
{
|
||||
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||
@@ -296,32 +296,32 @@ void YMUploadWidget::AnalysisDelete()
|
||||
qDebug() << db.lastError().text();
|
||||
return;
|
||||
}
|
||||
foreach (QListWidgetItem *item,m_plwAnalysis->selectedItems())
|
||||
foreach (QListWidgetItem *item,m_plwMorphere->selectedItems())
|
||||
{
|
||||
QString strQuery = QString("delete from analysis where id = '" + item->data(Qt::UserRole).toString() + "'");
|
||||
QString strQuery = QString("delete from morphere 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());
|
||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
||||
}
|
||||
|
||||
void YMUploadWidget::AnalysisAdd()
|
||||
void YMUploadWidget::MorphereAdd()
|
||||
{
|
||||
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
|
||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->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);
|
||||
DataBaseMorphereMorphere(((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());
|
||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void YMUploadWidget::AnalysisUp()
|
||||
void YMUploadWidget::MorphereUp()
|
||||
{
|
||||
int nSelect = m_plwAnalysis->currentRow();
|
||||
int nSelect = m_plwMorphere->currentRow();
|
||||
if (nSelect <= 0) return;
|
||||
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||
@@ -337,22 +337,22 @@ void YMUploadWidget::AnalysisUp()
|
||||
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";
|
||||
QString strID1 = m_plwMorphere->item(nSelect)->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";
|
||||
db.exec(strQuery.toUtf8());
|
||||
db.close();
|
||||
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
|
||||
RefreshAnalysis(item->data(Qt::UserRole).toInt());
|
||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
||||
|
||||
m_plwAnalysis->setCurrentRow(nSelect-1);
|
||||
m_plwMorphere->setCurrentRow(nSelect-1);
|
||||
}
|
||||
|
||||
void YMUploadWidget::AnalysisDown()
|
||||
void YMUploadWidget::MorphereDown()
|
||||
{
|
||||
int nSelect = m_plwAnalysis->currentRow();
|
||||
int nSelect = m_plwMorphere->currentRow();
|
||||
if (nSelect < 0) return;
|
||||
if (nSelect >= (m_plwAnalysis->count() - 1)) return;
|
||||
if (nSelect >= (m_plwMorphere->count() - 1)) return;
|
||||
qDebug() << nSelect;
|
||||
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
||||
@@ -367,18 +367,18 @@ void YMUploadWidget::AnalysisDown()
|
||||
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";
|
||||
QString strID1 = m_plwMorphere->item(nSelect)->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";
|
||||
db.exec(strQuery.toUtf8());
|
||||
db.close();
|
||||
foreach (QListWidgetItem *item,m_plwAnalysisGroup->selectedItems())
|
||||
RefreshAnalysis(item->data(Qt::UserRole).toInt());
|
||||
foreach (QListWidgetItem *item,m_plwMorphereGroup->selectedItems())
|
||||
RefreshMorphere(item->data(Qt::UserRole).toInt());
|
||||
|
||||
m_plwAnalysis->setCurrentRow(nSelect+1);
|
||||
m_plwMorphere->setCurrentRow(nSelect+1);
|
||||
}
|
||||
|
||||
void YMUploadWidget::DataBaseMorphereAnalysis(int _nArticle,QMap<QString, QString> mapParam ,int _nGroup,int _nCommand, QString _strFilterId)
|
||||
void YMUploadWidget::DataBaseMorphereMorphere(int _nArticle,QMap<QString, QString> mapParam ,int _nGroup,int _nCommand, QString _strFilterId)
|
||||
{
|
||||
QString strJson;
|
||||
SJson json;
|
||||
@@ -388,11 +388,11 @@ void YMUploadWidget::DataBaseMorphereAnalysis(int _nArticle,QMap<QString, QStrin
|
||||
strJson = json.Set(strJson, iterPos.key(), iterPos.value());
|
||||
}
|
||||
|
||||
DataBaseAnalysis(_nArticle, json.Sql(strJson),_nGroup,_nCommand,_strFilterId);
|
||||
DataBaseMorphere(_nArticle, json.Sql(strJson),_nGroup,_nCommand,_strFilterId);
|
||||
}
|
||||
|
||||
|
||||
void YMUploadWidget::DataBaseAnalysis(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");
|
||||
@@ -413,15 +413,15 @@ void YMUploadWidget::DataBaseAnalysis(int _nType, QString _strJson,int _nGroup,i
|
||||
switch(_nCommand)
|
||||
{
|
||||
case E_DATABASE_COMMAND_INSERT:
|
||||
sql = "INSERT INTO analysis SET ";
|
||||
sql = "INSERT INTO morphere SET ";
|
||||
sql += QString("type=") + QString::number(_nType) + ",";
|
||||
break;
|
||||
case E_DATABASE_COMMAND_UPDATE:
|
||||
sql = "UPDATE filter SET ";
|
||||
sql = "UPDATE morphere SET ";
|
||||
break;
|
||||
}
|
||||
sql += QString("data='") + _strJson + "',";
|
||||
sql += QString("analysisgroup_id=" ) + QString::number(_nGroup);
|
||||
sql += QString("morpheregroup_id=" ) + QString::number(_nGroup);
|
||||
if (_nCommand == E_DATABASE_COMMAND_UPDATE)
|
||||
sql += QString(" where id=") + _strFilterId;
|
||||
QSqlQuery query;
|
||||
@@ -434,7 +434,7 @@ void YMUploadWidget::DataBaseAnalysis(int _nType, QString _strJson,int _nGroup,i
|
||||
}
|
||||
|
||||
|
||||
void YMUploadWidget::currentAnalysisItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev)
|
||||
void YMUploadWidget::currentMorphereItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev)
|
||||
{
|
||||
Q_UNUSED(_pPrev);
|
||||
if (_pCurrent == 0) return;
|
||||
@@ -445,12 +445,14 @@ void YMUploadWidget::currentAnalysisItemChanged(QListWidgetItem *_pCurrent, QLis
|
||||
db.setPassword("admin123");
|
||||
db.setDatabaseName("concepters");
|
||||
|
||||
|
||||
|
||||
if (db.open() == false)
|
||||
{
|
||||
qDebug() << db.lastError().text();
|
||||
return;
|
||||
}
|
||||
QSqlQuery query("select id,type,data from analysis 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;
|
||||
SJson json;
|
||||
QString strJson = query.value(2).toString();
|
||||
|
||||
@@ -24,32 +24,32 @@ public:
|
||||
|
||||
private:
|
||||
QGroupBox *setUploadWidgets();
|
||||
QListWidget* m_plwAnalysisGroup;
|
||||
QLineEdit* m_pleAnalysisGroup;
|
||||
QListWidget* m_plwAnalysis;
|
||||
QGroupBox* m_pgbAnalysis;
|
||||
QListWidget* m_plwMorphereGroup;
|
||||
QLineEdit* m_pleMorphereGroup;
|
||||
QListWidget* m_plwMorphere;
|
||||
QGroupBox* m_pgbMorphere;
|
||||
QTabWidget* m_ptwResult;
|
||||
QTabWidget* m_ptwSource;
|
||||
|
||||
public slots:
|
||||
void AnalysisGroupInsert();
|
||||
void AnalysisGroupDelete();
|
||||
void AnalysisGroupModify();
|
||||
void AnalysisGroupRefresh();
|
||||
void AnalysisGroupCopyPaste();
|
||||
void MorphereGroupInsert();
|
||||
void MorphereGroupDelete();
|
||||
void MorphereGroupModify();
|
||||
void MorphereGroupRefresh();
|
||||
void MorphereGroupCopyPaste();
|
||||
void currentGroupItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0);
|
||||
|
||||
void AnalysisDelete();
|
||||
void AnalysisUp();
|
||||
void AnalysisDown();
|
||||
void AnalysisAdd();
|
||||
void MorphereDelete();
|
||||
void MorphereUp();
|
||||
void MorphereDown();
|
||||
void MorphereAdd();
|
||||
|
||||
void currentAnalysisItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0);
|
||||
void RefreshAnalysis(int _nGroup);
|
||||
// void RefreshAnalysis(int _nGroup);
|
||||
void currentMorphereItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0);
|
||||
void RefreshMorphere(int _nGroup);
|
||||
// void RefreshMorphere(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 DataBaseMorphereMorphere(int _nArticle,QMap<QString, QString> mapParam ,int _nGroup,int _nCommand, QString _strFilterId = "");
|
||||
void DataBaseMorphere(int _nType, QString _strJson,int _nGroup,int _nCommand,QString _strFilterId);
|
||||
void setResultTabWidget(QTabWidget* tabWidget);
|
||||
void setSourceTabWidget(QTabWidget* tabWidget);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user