64bit 전환

git-svn-id: svn://192.168.0.12/source@125 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
admin
2015-05-27 03:43:49 +00:00
parent 992b9777a1
commit 8033b309d5
9 changed files with 665 additions and 77 deletions

View File

@@ -12,6 +12,7 @@ TARGET = MorphereAnalyzer
TEMPLATE = app TEMPLATE = app
SOURCES += main.cpp\ SOURCES += main.cpp\
mainwindow.cpp \ mainwindow.cpp \
widget.cpp \ widget.cpp \

View File

@@ -54,7 +54,6 @@ MainWindow::MainWindow()
//p_qwFile = new QWidget; //p_qwFile = new QWidget;
//p_qwAnalyzed1 = new QWidget; //p_qwAnalyzed1 = new QWidget;
//p_qwText = new QWidget; //p_qwText = new QWidget;
p_qwAnalyzer1 = new SAnaly1; p_qwAnalyzer1 = new SAnaly1;
//p_qwAnalyzer2 = new QWidget; //p_qwAnalyzer2 = new QWidget;
p_qwDict = new SDictionary; p_qwDict = new SDictionary;

View File

@@ -14,6 +14,7 @@
#include "../Json/sjson.h" #include "../Json/sjson.h"
#include "../common.h" #include "../common.h"
/* /*
QSqlDatabase dbWeb = QSqlDatabase::addDatabase("QMYSQL"); QSqlDatabase dbWeb = QSqlDatabase::addDatabase("QMYSQL");
dbWeb.setHostName("db.big-bird.co.kr"); dbWeb.setHostName("db.big-bird.co.kr");
@@ -30,11 +31,13 @@ dbWeb.setDatabaseName("dbconcepters");
SAnaly1::SAnaly1(QWidget *parent) SAnaly1::SAnaly1(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{
if(!setListMorphere(m_strlistMorphere, m_strlistMorphereko))
{ {
m_strlistMorphere << "NNG" <<"NNP"<<"NNB"<<"NNBC"<<"NR"<<"NP"<<"VV"<<"VA"<<"VX"<<"VCP"<<"VCN"<<"MM"<<"MAG"<<"MAJ"<<"IC"<<"JKS"<<"JKC"<<"JKG"<<"JKO"<<"JKB"<<"JKV"<<"JKQ"<<"JX"<<"JC"<<"EP"<<"EF"<<"EC"<<"ETN"<<"ETM"<<"XPN"<<"XSN"<<"XSV"<<"XSA"<<"XR"<<"SF"<<"SE"<<"SSO"<<"SSC"<<"SC"<<"SY"<<"SL"<<"SH"<<"SN"; m_strlistMorphere << "NNG" <<"NNP"<<"NNB"<<"NNBC"<<"NR"<<"NP"<<"VV"<<"VA"<<"VX"<<"VCP"<<"VCN"<<"MM"<<"MAG"<<"MAJ"<<"IC"<<"JKS"<<"JKC"<<"JKG"<<"JKO"<<"JKB"<<"JKV"<<"JKQ"<<"JX"<<"JC"<<"EP"<<"EF"<<"EC"<<"ETN"<<"ETM"<<"XPN"<<"XSN"<<"XSV"<<"XSA"<<"XR"<<"SF"<<"SE"<<"SSO"<<"SSC"<<"SC"<<"SY"<<"SL"<<"SH"<<"SN";
m_strlistMorphereko << "일반 명사(NNG)"<<"고유 명사(NNP)"<<"의존 명사(NNB)"<<"단위를 나타내는 명사(NNBC)"<<"수사(NR)"<<"대명사(NP)"<<"동사(VV)"<<"형용사(VA)"<<"보조 용언(VX)"<<"긍정 지정사(VCP)"<<"부정 지정사(VCN)"<<"관형사(MM)"<<"일반 부사(MAG)"<<"접속 부사(MAJ)"<<"감탄사(IC)"<<"주격 조사(JKS)"<<"보격 조사(JKC)"<<"관형격 조사(JKG)"<<"목적격 조사(JKO)"<<"부사격 조사(JKB)"<<"호격 조사(JKV)"<<"인용격 조사(JKQ)"<<"보조사(JX)"<<"접속 조사(JC)"<<"선어말 어미(EP)"<<"종결 어미(EF)"<<"연결 어미(EC)"<<"명사형 전성 어미(ETN)"<<"관형형 전성 어미(ETM)"<<"체언 접두사(XPN)"<<"명사 파생 접미사(XSN)"<<"동사 파생 접미사(XSV)"<<"형용사 파생 접미사(XSA)"<<"어근(XR)"<<"마침표, 물음표, 느낌표(SF)"<<"줄임표 …(SE)"<<"여는 괄호 (, [(SSO)"<<"닫는 괄호 ), ](SSC)"<<"구분자 , · / : (SC)"<<"SY(SY)"<<"외국어(SL)"<<"한자(SH)"<<"숫자(SN)"; m_strlistMorphereko << "NNG" <<"NNP"<<"NNB"<<"NNBC"<<"NR"<<"NP"<<"VV"<<"VA"<<"VX"<<"VCP"<<"VCN"<<"MM"<<"MAG"<<"MAJ"<<"IC"<<"JKS"<<"JKC"<<"JKG"<<"JKO"<<"JKB"<<"JKV"<<"JKQ"<<"JX"<<"JC"<<"EP"<<"EF"<<"EC"<<"ETN"<<"ETM"<<"XPN"<<"XSN"<<"XSV"<<"XSA"<<"XR"<<"SF"<<"SE"<<"SSO"<<"SSC"<<"SC"<<"SY"<<"SL"<<"SH"<<"SN";
// qDebug() << m_strlistMorphere.size(); }
qDebug() << m_strlistMorphereko.size();
QVBoxLayout *vMainLayout = new QVBoxLayout; QVBoxLayout *vMainLayout = new QVBoxLayout;
vMainLayout->setAlignment(Qt::AlignVCenter); vMainLayout->setAlignment(Qt::AlignVCenter);
QVBoxLayout *vboxlayout = new QVBoxLayout; QVBoxLayout *vboxlayout = new QVBoxLayout;
@@ -1537,3 +1540,35 @@ void SAnaly1::MemClear()
m_mapViewResult.clear(); m_mapViewResult.clear();
} }
bool SAnaly1::setListMorphere(QStringList& MorphereEN, QStringList& MorphereKO)
{
QFile fHeader("morpherelist.txt");
if (!fHeader.open(QIODevice::ReadOnly | QIODevice::Text)) return false;
QTextStream in(&fHeader);
QString str = in.readLine();
if(str.at(0) == "#")
{
}
else
{
qDebug() << "The wrong file is read";
return false;
}
while(!in.atEnd())
{
str = in.readLine();
QStringList strList = str.trimmed().split("@",QString::SkipEmptyParts);
if(strList.isEmpty())
break;
if(strList.size() < 2)
return false;
MorphereEN << strList.at(0).trimmed().replace("\"","").trimmed();
MorphereKO << strList.at(1).trimmed().replace("\"","").trimmed();
}
return true;
}

View File

@@ -186,6 +186,7 @@ public slots:
void MorphereListDel(); void MorphereListDel();
void AddDictionary(); void AddDictionary();
void DelDictionary(); void DelDictionary();
bool setListMorphere(QStringList& MorphereEN, QStringList& MorphereKO);
QTabWidget* getQTabWidget(); QTabWidget* getQTabWidget();

View File

@@ -1,6 +1,6 @@
#include "sanalyzer.h" #include "sanalyzer.h"
#include <QFile>
AnalyzerThread::AnalyzerThread(QObject *parent) : QThread(parent), m_nThread(1), m_pWidget(NULL), m_nSource(0), m_bPeriod(false), m_nPeriod(0) AnalyzerThread::AnalyzerThread(QObject *parent) : QThread(parent), m_nThread(1), m_pWidget(NULL), m_nSource(0), m_bPeriod(false), m_nPeriod(0)
{ {
} }
@@ -144,8 +144,19 @@ void AnalyzerThread::run()
if(userdict.length() < 1) if(userdict.length() < 1)
{ {
/*
char *t[] = {"RRR","-d","dic"}; char *t[] = {"RRR","-d","dic"};
int int_t = 3; 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); mecab = mecab_new(int_t, t);
} }
@@ -153,8 +164,21 @@ void AnalyzerThread::run()
{ {
char *cstr = new char[userdict.toStdString().length() + 1]; char *cstr = new char[userdict.toStdString().length() + 1];
strcpy(cstr, userdict.toStdString().c_str()); 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[] = {"RRR","-d","dic","-u",cstr}; char *t[5];
t[0] = a;
t[1] = b;
t[2] = c;
t[3] = d;
t[4] = cstr;
int int_t = 5; int int_t = 5;
mecab = mecab_new(int_t, t); mecab = mecab_new(int_t, t);

View File

@@ -51,6 +51,7 @@ Widget::Widget(QWidget *parent)
vlayout->addWidget(setSearchWidgets()); vlayout->addWidget(setSearchWidgets());
vlayout->addWidget(setLengthWidgets()); vlayout->addWidget(setLengthWidgets());
vlayout->addWidget(setCounterWidgets());
vlayout->addWidget(setReplaceWidgets()); vlayout->addWidget(setReplaceWidgets());
vlayout->setAlignment(Qt::AlignTop); vlayout->setAlignment(Qt::AlignTop);
@@ -176,7 +177,11 @@ QGroupBox *Widget::setDateWidgets()
{ {
QPushButton *pbInsert = new QPushButton("Insert"); QPushButton *pbInsert = new QPushButton("Insert");
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchDate())); connect(pbInsert , SIGNAL(released()),this, SLOT(SearchDate()));
QPushButton *pbModify = new QPushButton("Modify");
connect(pbModify , SIGNAL(released()),this, SLOT(SearchDateUpdate()));
hlayout->addWidget(pbInsert); hlayout->addWidget(pbInsert);
hlayout->addWidget(pbModify);
} }
hlayout->setAlignment(Qt::AlignLeft|Qt::AlignTop); hlayout->setAlignment(Qt::AlignLeft|Qt::AlignTop);
@@ -249,9 +254,15 @@ QGroupBox *Widget::setSearchWidgets()
hlayout->addLayout(vlayout); hlayout->addLayout(vlayout);
{ {
QVBoxLayout *vsublayout = new QVBoxLayout();
QPushButton *pbInsert = new QPushButton("Insert"); QPushButton *pbInsert = new QPushButton("Insert");
hlayout->addWidget(pbInsert); vsublayout->addWidget(pbInsert);
connect(pbInsert, SIGNAL(released()),this, SLOT(SearchKeyword())); connect(pbInsert, SIGNAL(released()),this, SLOT(SearchKeyword()));
QPushButton *pbModify = new QPushButton("Modify");
connect(pbModify , SIGNAL(released()),this, SLOT(SearchKeywordUpdate()));
vsublayout->addWidget(pbModify);
hlayout->addLayout(vsublayout);
} }
QGroupBox *groupBox = new QGroupBox(tr("Search")); QGroupBox *groupBox = new QGroupBox(tr("Search"));
@@ -286,13 +297,62 @@ QGroupBox *Widget::setLengthWidgets()
{ {
QPushButton *pbInsert = new QPushButton("Insert"); QPushButton *pbInsert = new QPushButton("Insert");
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchLengthInsert())); connect(pbInsert , SIGNAL(released()),this, SLOT(SearchLengthInsert()));
QPushButton *pbModify = new QPushButton("Modify");
connect(pbModify , SIGNAL(released()),this, SLOT(SearchLengthUpdate()));
hlayout->addWidget(pbInsert); hlayout->addWidget(pbInsert);
hlayout->addWidget(pbModify);
} }
QGroupBox *groupBox = new QGroupBox(tr("Length")); QGroupBox *groupBox = new QGroupBox(tr("Length"));
groupBox->setLayout(hlayout); groupBox->setLayout(hlayout);
return groupBox; return groupBox;
} }
QGroupBox *Widget::setCounterWidgets()
{
QHBoxLayout *hlayout = new QHBoxLayout();
m_pcbCounterCatalog = new QComboBox;
m_pcbCounterComp = new QComboBox;
m_pcbCounterInsDel = new QComboBox;
m_pcbCounterCntApl = new QComboBox;
m_pleCounter = new QLineEdit;
foreach(QStringList strList,m_vecColumn)
m_pcbCounterCatalog->addItem(strList.at(E_COLUMN_NAME));
m_pcbCounterComp->addItem(">",QVariant(E_LENGTH_COMP_GREATER));
m_pcbCounterComp->addItem("<",QVariant(E_LENGTH_COMP_LESS));
m_pcbCounterComp->addItem("=",QVariant(E_LENGTH_COMP_EQUAL));
m_pcbCounterInsDel->addItem("Add",QVariant(0));
m_pcbCounterInsDel->addItem("Del",QVariant(1));
m_pcbCounterCntApl->addItem("Count",QVariant(0));
m_pcbCounterCntApl->addItem("Apply",QVariant(1));
hlayout->addWidget(new QLabel("Item:"));
hlayout->addWidget(m_pcbCounterCatalog);
hlayout->addWidget(m_pcbCounterComp);
//hlayout->addWidget(m_pcbCounterCntApl);
hlayout->addWidget(new QLabel("Count:"));
hlayout->addWidget(m_pleCounter);
hlayout->addWidget(m_pcbCounterInsDel);
{
QPushButton *pbInsert = new QPushButton("Insert");
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchCounterInsert()));
QPushButton *pbModify = new QPushButton("Modify");
connect(pbModify , SIGNAL(released()),this, SLOT(SearchCounterUpdate()));
hlayout->addWidget(pbInsert);
hlayout->addWidget(pbModify);
}
QGroupBox *groupBox = new QGroupBox(tr("Counter"));
groupBox->setLayout(hlayout);
return groupBox;
}
QGroupBox *Widget::setReplaceWidgets() QGroupBox *Widget::setReplaceWidgets()
{ {
QHBoxLayout *hlayout = new QHBoxLayout(); QHBoxLayout *hlayout = new QHBoxLayout();
@@ -320,9 +380,14 @@ QGroupBox *Widget::setReplaceWidgets()
hlayout->addWidget(m_pcbReplace); hlayout->addWidget(m_pcbReplace);
hlayout->addWidget(m_pleReplace); hlayout->addWidget(m_pleReplace);
{ {
QVBoxLayout *vlayout = new QVBoxLayout();
QPushButton *pbInsert = new QPushButton("Insert"); QPushButton *pbInsert = new QPushButton("Insert");
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchReplaceInsert())); connect(pbInsert , SIGNAL(released()),this, SLOT(SearchReplaceInsert()));
hlayout->addWidget(pbInsert); vlayout->addWidget(pbInsert);
QPushButton *pbModify = new QPushButton("Modify");
connect(pbModify , SIGNAL(released()),this, SLOT(SearchReplaceUpdate()));
vlayout->addWidget(pbModify);
hlayout->addLayout(vlayout);
} }
QGroupBox *groupBox = new QGroupBox(tr("Replace")); QGroupBox *groupBox = new QGroupBox(tr("Replace"));
groupBox->setLayout(hlayout); groupBox->setLayout(hlayout);
@@ -432,7 +497,7 @@ void Widget::SearchDate()
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems()) foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
{ {
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt(); nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
InsertTimeFilter(pNew->getArticleSelect(),m_pdeStart->date(),m_pdeEnd->date(),nCurrentFilterGroupID); DataBaseTimeFilter(pNew->getArticleSelect(),m_pdeStart->date(),m_pdeEnd->date(),nCurrentFilterGroupID,E_DATABASE_COMMAND_INSERT);
} }
} }
@@ -489,7 +554,7 @@ void Widget::SearchKeyword()
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems()) foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
{ {
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt(); nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
InsertSearchFilter(pNew->getArticleSelect(),m_pcbCatalog->currentIndex(),m_pcbMethod->currentIndex(),m_pcbKeyword->currentIndex(),strKey,nCurrentFilterGroupID); DataBaseSearchFilter(pNew->getArticleSelect(),m_pcbCatalog->currentIndex(),m_pcbMethod->currentIndex(),m_pcbKeyword->currentIndex(),strKey,nCurrentFilterGroupID,E_DATABASE_COMMAND_INSERT);
} }
} }
@@ -553,6 +618,182 @@ void Widget::SearchKeyword()
RefreshFilter(nCurrentFilterGroupID); RefreshFilter(nCurrentFilterGroupID);
} }
void Widget::SearchCounterInsert()
{
bool ok;
m_pleCounter->text().toInt(&ok);
if(!ok)
return;
STable *pCurrent = (STable *)m_ptwData->currentWidget();
int nCatalog = m_pcbCounterCatalog->currentIndex();
int nFlag = m_pcbCounterInsDel->currentData().toInt();
int nComp = m_pcbCounterComp->currentData().toInt();
//int nCntApl = m_pcbCounterCntApl->currentData().toInt();
int nCurrentFilterGroupID = D_NOT_SELECT;
m_pProgress->setRange(0,pCurrent->rowCount()-1);
QString strKey = m_pcbCounterCatalog->currentText();
strKey += ",";
strKey += QString::number(m_pcbCounterComp->currentIndex());
strKey += ",";
strKey += m_pleCounter->text();
if (m_pgbFilter->isChecked())
{
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
{
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
DataBaseCounterFilter(pCurrent->getArticleSelect(), nCatalog, nComp, nFlag, m_pleCounter->text(), nCurrentFilterGroupID, E_DATABASE_COMMAND_INSERT);
}
}
//if(m_pcbCounterCntApl->currentIndex() == 0)
{
if(m_mapData.contains(strKey))
m_mapData[strKey].clear();
QMap<QString, int> mapData;
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
{
QString str;
if (nCatalog == m_nColumn)
{
QDateTime date;
str = date.fromString(pCurrent->item(nCount,nCatalog)->text().trimmed(),"yyyy-MM-dd hh:mm:ss").date().toString("yyyy-MM-dd");
}
else
str = pCurrent->item(nCount,nCatalog)->text().trimmed();
if(mapData.contains(str))
{
mapData[str] += 1;
}
else
{
mapData.insert(str,1);
}
m_pProgress->setValue(nCount);
m_pProgress->repaint();
}
int leCount = m_pleCounter->text().toInt();
if(m_pcbCounterComp->currentIndex() == 0)
{
for(QMap<QString, int>::iterator iterPos = mapData.begin(); iterPos != mapData.end() ;iterPos++)
{
if(iterPos.value() > leCount)
{
if(m_mapData.contains(strKey))
{
m_mapData[strKey].insert(iterPos.key(), iterPos.value());
}
else
{
QMap<QString, int> temp;
temp.insert(iterPos.key(), iterPos.value());
m_mapData.insert(strKey, temp);
}
}
}
}
else if(m_pcbCounterComp->currentIndex() == 1)
{
for(QMap<QString, int>::iterator iterPos = mapData.begin(); iterPos != mapData.end() ;iterPos++)
{
if(iterPos.value() < leCount)
{
if(m_mapData.contains(strKey))
{
m_mapData[strKey].insert(iterPos.key(), iterPos.value());
}
else
{
QMap<QString, int> temp;
temp.insert(iterPos.key(), iterPos.value());
m_mapData.insert(strKey, temp);
}
}
}
}
else if(m_pcbCounterComp->currentIndex() == 2)
{
for(QMap<QString, int>::iterator iterPos = mapData.begin(); iterPos != mapData.end() ;iterPos++)
{
if(iterPos.value() == leCount)
{
if(m_mapData.contains(strKey))
{
m_mapData[strKey].insert(iterPos.key(), iterPos.value());
}
else
{
QMap<QString, int> temp;
temp.insert(iterPos.key(), iterPos.value());
m_mapData.insert(strKey, temp);
}
}
}
}
}
//if(m_pcbCounterCntApl->currentIndex() == 1)
{
if(!m_mapData.contains(strKey))
return;
STable *pNew = new STable;
pNew->setArticleSelect(pCurrent->getArticleSelect());
pNew->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
m_pProgress->setRange(0,pCurrent->rowCount()-1);
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
{
bool bFlag = false;
QString strCurrent = pCurrent->item(nCount,nCatalog)->text().trimmed();
if(m_mapData[strKey].contains(strCurrent))
bFlag = true;
if (nFlag == 1) bFlag = !bFlag;
if (bFlag) InsertCopyRow(nCount,pCurrent,pNew);
m_pProgress->setValue(nCount);
m_pProgress->repaint();
}
m_ptwData->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
m_ptwData->setCurrentIndex(m_ptwData->count()-1);
}
if (nCurrentFilterGroupID != D_NOT_SELECT)
RefreshFilter(nCurrentFilterGroupID);
m_mapData[strKey].clear();
}
void Widget::SearchCounterUpdate()
{
if (m_pgbFilter->isChecked())
{
int nCurrentFilterGroupID = D_NOT_SELECT;
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
if (nCurrentFilterGroupID == D_NOT_SELECT) return;
int nCatalog = m_pcbCounterCatalog->currentIndex();
int nComp = m_pcbCounterComp->currentData().toInt();
int nFlag = m_pcbCounterInsDel->currentData().toInt();
foreach (QListWidgetItem *item,m_plwFilter->selectedItems())
DataBaseLengthFilter(((STable *)m_ptwData->currentWidget())->getArticleSelect(),nCatalog,nComp,nFlag,m_pleCounter->text(),nCurrentFilterGroupID,E_DATABASE_COMMAND_UPDATE,item->data(Qt::UserRole).toString());
RefreshFilter(nCurrentFilterGroupID);
}
}
void Widget::SearchLengthInsert() void Widget::SearchLengthInsert()
{ {
STable *pNew = new STable; STable *pNew = new STable;
@@ -572,7 +813,7 @@ void Widget::SearchLengthInsert()
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems()) foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
{ {
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt(); nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
InsertLengthFilter(pCurrent->getArticleSelect(),nCatalog,nComp,nFlag,m_pleLength->text(),nCurrentFilterGroupID); DataBaseLengthFilter(pCurrent->getArticleSelect(),nCatalog,nComp,nFlag,m_pleLength->text(),nCurrentFilterGroupID,E_DATABASE_COMMAND_INSERT);
} }
} }
@@ -628,10 +869,10 @@ void Widget::SearchReplaceInsert()
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems()) foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
{ {
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt(); nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
InsertReplaceFilter(pNew->getArticleSelect(),nCatalog, DataBaseReplaceFilter(pNew->getArticleSelect(),nCatalog,
m_pcbReplaceFind->currentData().toInt(), m_pcbReplaceFind->currentData().toInt(),
m_pleReplaceFind->text(),m_pleReplace->text(), m_pleReplaceFind->text(),m_pleReplace->text(),
nCurrentFilterGroupID); nCurrentFilterGroupID,E_DATABASE_COMMAND_INSERT);
} }
} }
pNew->setRowCount(pCurrent->rowCount()); pNew->setRowCount(pCurrent->rowCount());
@@ -715,6 +956,94 @@ void Widget::SearchReplaceInsert()
RefreshFilter(nCurrentFilterGroupID); RefreshFilter(nCurrentFilterGroupID);
} }
void Widget::SearchDateUpdate()
{
if (m_pgbFilter->isChecked())
{
int nCurrentFilterGroupID = D_NOT_SELECT;
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
if (nCurrentFilterGroupID == D_NOT_SELECT) return;
foreach (QListWidgetItem *item,m_plwFilter->selectedItems())
DataBaseTimeFilter(((STable *)m_ptwData->currentWidget())->getArticleSelect(),m_pdeStart->date(),m_pdeEnd->date(),nCurrentFilterGroupID,E_DATABASE_COMMAND_UPDATE,item->data(Qt::UserRole).toString());
RefreshFilter(nCurrentFilterGroupID);
}
}
void Widget::SearchKeywordUpdate()
{
if (m_pgbFilter->isChecked())
{
int nCurrentFilterGroupID = D_NOT_SELECT;
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
if (nCurrentFilterGroupID == D_NOT_SELECT) return;
QString strKey = m_pleString->text().replace("\r\n"," ");
strKey = strKey.replace("\n"," ");
strKey = strKey.replace("\t"," ");
QString strTemp;
foreach(QString str, strKey.split(" "))
{
if (str.trimmed().isEmpty() == false)
strTemp += str.trimmed() + " ";
}
strTemp = strTemp.trimmed();
m_pleString->setText(strTemp);
strKey = strTemp;
foreach (QListWidgetItem *item,m_plwFilter->selectedItems())
DataBaseSearchFilter(((STable *)m_ptwData->currentWidget())->getArticleSelect(),m_pcbCatalog->currentIndex(),m_pcbMethod->currentIndex(),m_pcbKeyword->currentIndex(),strKey,nCurrentFilterGroupID,E_DATABASE_COMMAND_UPDATE,item->data(Qt::UserRole).toString());
RefreshFilter(nCurrentFilterGroupID);
}
}
void Widget::SearchLengthUpdate()
{
if (m_pgbFilter->isChecked())
{
int nCurrentFilterGroupID = D_NOT_SELECT;
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
if (nCurrentFilterGroupID == D_NOT_SELECT) return;
int nCatalog = m_pcbLengthCatalog->currentIndex();
int nComp = m_pcbLengthComp->currentData().toInt();
int nFlag = m_pcbLengthInsDel->currentData().toInt();
foreach (QListWidgetItem *item,m_plwFilter->selectedItems())
DataBaseLengthFilter(((STable *)m_ptwData->currentWidget())->getArticleSelect(),nCatalog,nComp,nFlag,m_pleLength->text(),nCurrentFilterGroupID,E_DATABASE_COMMAND_UPDATE,item->data(Qt::UserRole).toString());
RefreshFilter(nCurrentFilterGroupID);
}
}
void Widget::SearchReplaceUpdate()
{
if (m_pgbFilter->isChecked())
{
int nCurrentFilterGroupID = D_NOT_SELECT;
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
if (nCurrentFilterGroupID == D_NOT_SELECT) return;
int nCatalog = m_pcbReplaceCatalog->currentIndex();
QStringList strListKeyword;
if (m_pcbReplaceFind->currentData().toInt() == E_REPLACE_SPACE)
strListKeyword = m_pleReplaceFind->text().split(" ");
else
strListKeyword.push_back(m_pleReplaceFind->text());
foreach (QListWidgetItem *item,m_plwFilter->selectedItems())
DataBaseReplaceFilter(((STable *)m_ptwData->currentWidget())->getArticleSelect(),nCatalog,
m_pcbReplaceFind->currentData().toInt(),
m_pleReplaceFind->text(),m_pleReplace->text(),
nCurrentFilterGroupID,E_DATABASE_COMMAND_UPDATE,item->data(Qt::UserRole).toString());
RefreshFilter(nCurrentFilterGroupID);
}
}
void Widget::DataGroupItemChanged( QListWidgetItem *item) void Widget::DataGroupItemChanged( QListWidgetItem *item)
{ {
QMessageBox msg; QMessageBox msg;
@@ -898,7 +1227,7 @@ void Widget::FilterGroupRefresh()
db.close(); db.close();
} }
void Widget::InsertFilter(int _nType,QString _strJson,int _nGroup) void Widget::DataBaseFilter(int _nType,QString _strJson,int _nGroup,int _nCommand,QString _strFilterId)
{ {
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org"); db.setHostName("bigbird.iptime.org");
@@ -911,10 +1240,21 @@ void Widget::InsertFilter(int _nType,QString _strJson,int _nGroup)
return; return;
} }
QString sql = "insert into filter (type,data,filtergroup_id) value ("; QString sql;
sql += QString::number(_nType); switch(_nCommand)
sql += ",'" + _strJson + "',"; {
sql += QString::number(_nGroup) + ")"; case E_DATABASE_COMMAND_INSERT:
sql = "INSERT INTO filter SET ";
sql += QString("type=") + QString::number(_nType) + ",";
break;
case E_DATABASE_COMMAND_UPDATE:
sql = "UPDATE filter SET ";
break;
}
sql += QString("data='") + _strJson + "',";
sql += QString("filtergroup_id=" ) + QString::number(_nGroup);
if (_nCommand == E_DATABASE_COMMAND_UPDATE)
sql += QString(" where id=") + _strFilterId;
QSqlQuery query; QSqlQuery query;
if (query.exec(sql.toUtf8()) == false) if (query.exec(sql.toUtf8()) == false)
{ {
@@ -924,17 +1264,17 @@ void Widget::InsertFilter(int _nType,QString _strJson,int _nGroup)
db.close(); db.close();
} }
void Widget::InsertTimeFilter(int _nArticle ,QDate _dateStart ,QDate _dateEnd ,int _nGroup) void Widget::DataBaseTimeFilter(int _nArticle ,QDate _dateStart ,QDate _dateEnd ,int _nGroup,int _nCommand,QString _strFilterId )
{ {
QString strJson; QString strJson;
SJson json; SJson json;
strJson = json.Set(strJson,"Article",QString::number(_nArticle)); strJson = json.Set(strJson,"Article",QString::number(_nArticle));
strJson = json.Set(strJson,"Start",_dateStart.toString("yyyy-MM-dd")); strJson = json.Set(strJson,"Start",_dateStart.toString("yyyy-MM-dd"));
strJson = json.Set(strJson,"End",_dateEnd.toString("yyyy-MM-dd")); strJson = json.Set(strJson,"End",_dateEnd.toString("yyyy-MM-dd"));
InsertFilter(E_FILTER_TYPE_DATE,json.Sql(strJson),_nGroup); DataBaseFilter(E_FILTER_TYPE_DATE,json.Sql(strJson),_nGroup,_nCommand,_strFilterId);
} }
void Widget::InsertSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _nKeyword, QString _str,int _nGroup) void Widget::DataBaseSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _nKeyword, QString _str,int _nGroup,int _nCommand,QString _strFilterId)
{ {
QString strJson; QString strJson;
SJson json; SJson json;
@@ -943,10 +1283,10 @@ void Widget::InsertSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _n
strJson = json.Set(strJson,"Method",_nMethod); strJson = json.Set(strJson,"Method",_nMethod);
strJson = json.Set(strJson,"Keyword",_nKeyword); strJson = json.Set(strJson,"Keyword",_nKeyword);
strJson = json.Set(strJson,"String",_str); strJson = json.Set(strJson,"String",_str);
InsertFilter(E_FILTER_TYPE_SEARCH,json.Sql(strJson),_nGroup); DataBaseFilter(E_FILTER_TYPE_SEARCH,json.Sql(strJson),_nGroup,_nCommand,_strFilterId);
} }
void Widget::InsertLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup) void Widget::DataBaseLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,QString _strFilterId)
{ {
QString strJson; QString strJson;
SJson json; SJson json;
@@ -955,10 +1295,25 @@ void Widget::InsertLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nIn
strJson = json.Set(strJson,"Comp",_nComp); strJson = json.Set(strJson,"Comp",_nComp);
strJson = json.Set(strJson,"InsDel",_nInsDel); strJson = json.Set(strJson,"InsDel",_nInsDel);
strJson = json.Set(strJson,"String",_str); strJson = json.Set(strJson,"String",_str);
InsertFilter(E_FILTER_TYPE_LENGTH,json.Sql(strJson),_nGroup); DataBaseFilter(E_FILTER_TYPE_LENGTH,json.Sql(strJson),_nGroup,_nCommand,_strFilterId);
} }
void Widget::InsertReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup)
void Widget::DataBaseCounterFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,QString _strFilterId)
{
QString strJson;
SJson json;
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
strJson = json.Set(strJson,"Category",_nCategory);
strJson = json.Set(strJson,"Comp",_nComp);
strJson = json.Set(strJson,"InsDel",_nInsDel);
strJson = json.Set(strJson,"String",_str);
DataBaseFilter(E_FILTER_TYPE_COUNTER,json.Sql(strJson),_nGroup,_nCommand,_strFilterId);
}
void Widget::DataBaseReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup,int _nCommand,QString _strFilterId)
{ {
QString strJson; QString strJson;
SJson json; SJson json;
@@ -967,7 +1322,7 @@ void Widget::InsertReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString
strJson = json.Set(strJson,"Find",_nFind); strJson = json.Set(strJson,"Find",_nFind);
strJson = json.Set(strJson,"String_Find",_strFind); strJson = json.Set(strJson,"String_Find",_strFind);
strJson = json.Set(strJson,"String_Replace",_strReplace); strJson = json.Set(strJson,"String_Replace",_strReplace);
InsertFilter(E_FILTER_TYPE_REPLACE,json.Sql(strJson),_nGroup); DataBaseFilter(E_FILTER_TYPE_REPLACE,json.Sql(strJson),_nGroup,_nCommand,_strFilterId);
} }
void Widget::RefreshFilter(int _nGroup) void Widget::RefreshFilter(int _nGroup)
@@ -1020,6 +1375,13 @@ void Widget::RefreshFilter(int _nGroup)
str += json.Get(strJson,"String_Find") + " --> "; str += json.Get(strJson,"String_Find") + " --> ";
str += json.Get(strJson,"String_Replace"); str += json.Get(strJson,"String_Replace");
break; break;
case E_FILTER_TYPE_COUNTER:
str += "<Counter> ";
str += m_pcbCounterCatalog->itemText(json.GetNumber(strJson,"Category")) + " ";
str += m_pcbCounterComp->itemText(json.GetNumber(strJson,"Comp")) + " ";
str += json.Get(strJson,"String") + " , ";
str += m_pcbCounterInsDel->itemText(json.GetNumber(strJson,"InsDel"));
break;
} }
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwFilter); QListWidgetItem *pItem = new QListWidgetItem(str,m_plwFilter);
pItem->setData(Qt::UserRole, QVariant(query.value(0))); pItem->setData(Qt::UserRole, QVariant(query.value(0)));
@@ -1113,15 +1475,27 @@ void Widget::currentFilterItemChanged(QListWidgetItem *_pCurrent, QListWidgetIte
m_pleString->setText(""); m_pleString->setText("");
m_pleLength->setText(""); m_pleLength->setText("");
break; 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;
} }
} }
bool Widget::ReloadColumn() bool Widget::ReloadColumn()
{ {
m_vecColumn.clear(); m_vecColumn.clear();
qDebug() << "file open ready";
QFile file("column.txt"); QFile file("column.txt");
if (file.open(QIODevice::ReadOnly | QIODevice::Text) == false) return false; if (file.open(QIODevice::ReadOnly | QIODevice::Text) == false) return false;
{ {
qDebug() << "file open starting";
while (!file.atEnd()) while (!file.atEnd())
{ {
QString str = QString(file.readLine()); QString str = QString(file.readLine());
@@ -1310,22 +1684,6 @@ void Widget::FileExit()
exit(1); exit(1);
} }
struct SCount
{
SCount()
{
m_str.clear();
m_nCount = 0;
}
SCount(QString _str)
{
m_str = _str;
m_nCount = 1;
}
QString m_str;
int m_nCount;
};
void Widget::CountSave() void Widget::CountSave()
{ {
@@ -1375,3 +1733,18 @@ void Widget::CountSave()
} }
file.close(); file.close();
} }
void Widget::Debug(QString _strMsg)
{
/*
QTime time = QTime::currentTime();
QString strOut = time.toString("[hh:mm:ss] ") + _strMsg;
QFile file(QDate::currentDate().toString(Qt::ISODate)+ "_" + QString::number(QCoreApplication::applicationPid())+ ".debug.txt");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
return;
QTextStream out(&file);
out << strOut << "\n";
file.close();
*/
}

View File

@@ -46,7 +46,7 @@ Widget::Widget(QWidget *parent)
if (m_nColumn != -1) if (m_nColumn != -1)
hlayout->addWidget(setDateWidgets()); hlayout->addWidget(setDateWidgets());
hlayout->addWidget(setCountWidgets()); hlayout->addWidget(setCountWidgets());
vlayout->addLayout(hlayout); //vlayout->addLayout(hlayout);
} }
vlayout->addWidget(setSearchWidgets()); vlayout->addWidget(setSearchWidgets());
@@ -57,7 +57,7 @@ Widget::Widget(QWidget *parent)
{ {
QHBoxLayout *hlayout = new QHBoxLayout; QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addWidget(setDataWidgets()); hlayout->addWidget(setDataWidgets());
//hlayout->addLayout(vlayout); hlayout->addLayout(vlayout);
//hlayout->addWidget(setFilterWidgets()); //hlayout->addWidget(setFilterWidgets());
setFilterWidgets(); setFilterWidgets();
vMainLayout->addLayout(hlayout,2); vMainLayout->addLayout(hlayout,2);
@@ -90,6 +90,7 @@ QTableWidget *Widget::AddTable(QString _str)
void Widget::CloseTab(int index) void Widget::CloseTab(int index)
{ {
((STable*)(m_ptwData->widget(index)))->clear();
m_ptwData->removeTab(index); m_ptwData->removeTab(index);
} }
@@ -297,6 +298,7 @@ QGroupBox *Widget::setReplaceWidgets()
QHBoxLayout *hlayout = new QHBoxLayout(); QHBoxLayout *hlayout = new QHBoxLayout();
m_pcbReplaceCatalog = new QComboBox; m_pcbReplaceCatalog = new QComboBox;
m_pcbReplaceFind = new QComboBox; m_pcbReplaceFind = new QComboBox;
m_pcbReplace = new QComboBox;
m_pleReplaceFind = new QLineEdit; m_pleReplaceFind = new QLineEdit;
m_pleReplace = new QLineEdit; m_pleReplace = new QLineEdit;
@@ -306,11 +308,16 @@ QGroupBox *Widget::setReplaceWidgets()
m_pcbReplaceFind->addItem("Sentence",QVariant(E_REPLACE_SENTENCE)); m_pcbReplaceFind->addItem("Sentence",QVariant(E_REPLACE_SENTENCE));
m_pcbReplaceFind->addItem("Space",QVariant(E_REPLACE_SPACE)); m_pcbReplaceFind->addItem("Space",QVariant(E_REPLACE_SPACE));
m_pcbReplace->addItem("0",QVariant(0));
m_pcbReplace->addItem("1",QVariant(1));
m_pcbReplace->addItem("2",QVariant(2));
hlayout->addWidget(m_pcbReplaceCatalog); hlayout->addWidget(m_pcbReplaceCatalog);
hlayout->addWidget(new QLabel("Find:")); hlayout->addWidget(new QLabel("Find:"));
hlayout->addWidget(m_pcbReplaceFind); hlayout->addWidget(m_pcbReplaceFind);
hlayout->addWidget(m_pleReplaceFind); hlayout->addWidget(m_pleReplaceFind);
hlayout->addWidget(new QLabel("Replace:")); hlayout->addWidget(new QLabel("Replace:"));
hlayout->addWidget(m_pcbReplace);
hlayout->addWidget(m_pleReplace); hlayout->addWidget(m_pleReplace);
{ {
QPushButton *pbInsert = new QPushButton("Insert"); QPushButton *pbInsert = new QPushButton("Insert");
@@ -339,11 +346,15 @@ QGroupBox *Widget::setFilterWidgets()
connect(pbDelete, SIGNAL(released()),this, SLOT(FilterGroupDelete())); connect(pbDelete, SIGNAL(released()),this, SLOT(FilterGroupDelete()));
QPushButton *pbModify = new QPushButton("Modfiy"); QPushButton *pbModify = new QPushButton("Modfiy");
connect(pbModify, SIGNAL(released()),this, SLOT(FilterGroupModify())); connect(pbModify, SIGNAL(released()),this, SLOT(FilterGroupModify()));
QPushButton *pbCopy_Paste = new QPushButton("Copy&Paste");
connect(pbCopy_Paste, SIGNAL(released()),this, SLOT(FilterGroupCopyPaste()));
QPushButton *pbRefresh = new QPushButton("Refresh"); QPushButton *pbRefresh = new QPushButton("Refresh");
connect(pbRefresh, SIGNAL(released()),this, SLOT(FilterGroupRefresh())); connect(pbRefresh, SIGNAL(released()),this, SLOT(FilterGroupRefresh()));
hlayout->addWidget(pbInsert); hlayout->addWidget(pbInsert);
hlayout->addWidget(pbDelete); hlayout->addWidget(pbDelete);
hlayout->addWidget(pbModify);
hlayout->addWidget(pbCopy_Paste);
hlayout->addWidget(pbRefresh); hlayout->addWidget(pbRefresh);
vlayout->addLayout(hlayout); vlayout->addLayout(hlayout);
} }
@@ -604,16 +615,14 @@ void Widget::SearchReplaceInsert()
pNew->SetHeaderList(&m_vecColumn,E_COLUMN_NAME); pNew->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
m_pProgress->setRange(0,pCurrent->rowCount()-1); m_pProgress->setRange(0,pCurrent->rowCount()-1);
int nCatalog = m_pcbReplaceCatalog->currentIndex(); int nCatalog = m_pcbReplaceCatalog->currentIndex();
bool bFlag = false;
QStringList strListKeyword; QStringList strListKeyword;
if (m_pcbReplaceFind->currentData().toInt() == E_REPLACE_SPACE) if (m_pcbReplaceFind->currentData().toInt() == E_REPLACE_SPACE)
{
bFlag = true;
strListKeyword = m_pleReplaceFind->text().split(" "); strListKeyword = m_pleReplaceFind->text().split(" ");
} else
int nCurrentFilterGroupID = D_NOT_SELECT; strListKeyword.push_back(m_pleReplaceFind->text());
int nCurrentFilterGroupID = D_NOT_SELECT;
int nReplace = m_pcbReplace->currentIndex();
if (m_pgbFilter->isChecked()) if (m_pgbFilter->isChecked())
{ {
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems()) foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
@@ -633,14 +642,63 @@ void Widget::SearchReplaceInsert()
if (nCatalog == nColumnCount) if (nCatalog == nColumnCount)
{ {
QString strOut = pCurrent->item(nCount,nColumnCount)->text(); QString strOut = pCurrent->item(nCount,nColumnCount)->text();
if (bFlag) switch(nReplace)
{
case 0:
{ {
foreach(QString str,strListKeyword) foreach(QString str,strListKeyword)
strOut = strOut.replace(str,m_pleReplace->text()); strOut = strOut.replace(str,m_pleReplace->text());
break;
}
case 1:
{
QString strMiddle;
foreach(QString strLine,strOut.split("\n"))
{
foreach(QString strWord,strLine.split(" "))
{
bool bFlag = false;
foreach(QString str,strListKeyword)
{
if (strWord == str)
{
strMiddle += m_pleReplace->text() + " ";
bFlag = true;
break;
}
}
if (bFlag == false)
strMiddle += strWord + " ";
}
strMiddle += "\n";
}
strOut = strMiddle;
break;
}
case 2:
QString strMiddle;
foreach(QString strLine,strOut.split("\n"))
{
foreach(QString strWord,strLine.split(" "))
{
bool bFlag = false;
foreach(QString str,strListKeyword)
{
if (strWord.contains(str))
{
strMiddle += m_pleReplace->text() + " ";
bFlag = true;
break;
}
}
if (bFlag == false)
strMiddle += strWord + " ";
}
strMiddle += "\n";
}
strOut = strMiddle;
break;
} }
else
strOut = strOut.replace(m_pleReplaceFind->text(),m_pleReplace->text());
pNew->setItem(nCount,nColumnCount,new QTableWidgetItem(strOut)); pNew->setItem(nCount,nColumnCount,new QTableWidgetItem(strOut));
} }
else else
@@ -776,7 +834,46 @@ void Widget::FilterGroupModify()
qDebug() << db.lastError().text(); qDebug() << db.lastError().text();
return; return;
} }
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
{
QString strQuery = QString("update filtergroup set name = '" + m_pleFilterGroup->text() + "' where id = " + item->data(Qt::UserRole).toString());
qDebug() << strQuery;
db.exec(strQuery.toUtf8());
}
db.close(); db.close();
FilterGroupRefresh();
}
void Widget::FilterGroupCopyPaste()
{
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_plwFilterGroup->selectedItems())
{
QSqlQuery query;
QString strQuery = QString("insert into filtergroup set "
"name = '" + item->text() + "-'");
query.exec(strQuery.toUtf8());
query.exec("select max(id) from filtergroup");
if (query.next())
{
strQuery = QString("insert into filter (type,data,filtergroup_id) select type,data,");
strQuery += query.value(0).toString();
strQuery += " from filter where filtergroup_id = " + item->data(Qt::UserRole).toString();
qDebug() << strQuery;
query.exec(strQuery.toUtf8());
}
}
db.close();
FilterGroupRefresh();
} }
void Widget::FilterGroupRefresh() void Widget::FilterGroupRefresh()
@@ -1038,6 +1135,7 @@ bool Widget::ReloadColumn()
m_nColumn = -1; m_nColumn = -1;
m_nTitle = -1; m_nTitle = -1;
m_nBody = -1; m_nBody = -1;
m_nPlatformTitle = -1;
foreach(QStringList strList,m_vecColumn) foreach(QStringList strList,m_vecColumn)
{ {
if (strList.at(E_COLUMN_DATE).trimmed() == QString("o") ) if (strList.at(E_COLUMN_DATE).trimmed() == QString("o") )
@@ -1063,6 +1161,14 @@ bool Widget::ReloadColumn()
} }
m_nBody++; m_nBody++;
foreach(QStringList strList,m_vecColumn)
{
if (strList.at(E_COLUMN_DATABASE).trimmed() == QString("platform_title") )
break;
else
m_nPlatformTitle++;
}
m_nPlatformTitle++;
return true; return true;
} }

View File

@@ -18,7 +18,22 @@
#include <QMenuBar> #include <QMenuBar>
#include <QSqlDatabase> #include <QSqlDatabase>
#include "stable.h" #include "stable.h"
struct SCount
{
SCount()
{
m_str.clear();
m_nCount = 0;
}
SCount(QString _str)
{
m_str = _str;
m_nCount = 1;
}
QString m_str;
int m_nCount;
};
class Widget : public QWidget class Widget : public QWidget
{ {
enum E_COLUMN enum E_COLUMN
@@ -35,6 +50,13 @@ class Widget : public QWidget
E_LENGTH_COMP_LESS, E_LENGTH_COMP_LESS,
E_LENGTH_COMP_EQUAL, E_LENGTH_COMP_EQUAL,
}; };
enum E_DATABASE_COMMAND
{
E_DATABASE_COMMAND_INSERT = 0,
E_DATABASE_COMMAND_UPDATE,
};
Q_OBJECT Q_OBJECT
public: public:
Widget(QWidget *parent = 0); Widget(QWidget *parent = 0);
@@ -84,6 +106,13 @@ private:
QComboBox *m_pcbLengthComp; QComboBox *m_pcbLengthComp;
QComboBox *m_pcbLengthInsDel; QComboBox *m_pcbLengthInsDel;
QLineEdit *m_pleLength; QLineEdit *m_pleLength;
// Counter
QComboBox *m_pcbCounterCatalog;
QComboBox *m_pcbCounterComp;
QComboBox *m_pcbCounterInsDel;
QComboBox *m_pcbCounterCntApl;
QLineEdit *m_pleCounter;
// Filter // Filter
QListWidget *m_plwFilterGroup; QListWidget *m_plwFilterGroup;
QListWidget *m_plwFilter; QListWidget *m_plwFilter;
@@ -105,6 +134,9 @@ private:
QProgressBar *m_pProgress; QProgressBar *m_pProgress;
// Column // Column
QVector <QStringList> m_vecColumn; QVector <QStringList> m_vecColumn;
QVector <SCount> vecData;
QMap <QString, QMap <QString, int> > m_mapData;
private: private:
QMenuBar *setMenuWidget(); QMenuBar *setMenuWidget();
QGroupBox *setDataWidgets(); QGroupBox *setDataWidgets();
@@ -112,6 +144,7 @@ private:
QGroupBox *setCountWidgets(); QGroupBox *setCountWidgets();
QGroupBox *setSearchWidgets(); QGroupBox *setSearchWidgets();
QGroupBox *setLengthWidgets(); QGroupBox *setLengthWidgets();
QGroupBox *setCounterWidgets();
QGroupBox *setFilterWidgets(); QGroupBox *setFilterWidgets();
QGroupBox *setReplaceWidgets(); QGroupBox *setReplaceWidgets();
@@ -119,21 +152,32 @@ private:
void SetTableHead(); void SetTableHead();
void InsertCopyRow(int _nRow,QTableWidget *_pCurrent,QTableWidget *_pNew); void InsertCopyRow(int _nRow,QTableWidget *_pCurrent,QTableWidget *_pNew);
void DataReload(QString _strTableName,int _nSelect); void DataReload(QString _strTableName,int _nSelect);
void InsertFilter(int _nType,QString _strJson,int _nGroup); void DataBaseFilter(int _nType,QString _strJson,int _nGroup,int _nCommand,QString _strFilterId ="");
void InsertTimeFilter(int _nTimeCategory ,QDate _dateStart ,QDate _dateEnd ,int _nGroup); void DataBaseTimeFilter(int _nTimeCategory ,QDate _dateStart ,QDate _dateEnd ,int _nGroup,int _nCommand,QString _strFilterId="");
void InsertSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _nKeyword, QString _str,int _nGroup); void DataBaseSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _nKeyword, QString _str,int _nGroup,int _nCommand,QString _strFilterId ="");
void InsertLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup); void DataBaseLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,QString _strFilterId ="");
void InsertReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup); void DataBaseReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup,int _nCommand,QString _strFilterId ="");
void RefreshFilter(int _nGroup); void RefreshFilter(int _nGroup);
void DataBaseCounterFilter(int _nArticle,int _nCategory,int _nComp, int _nInsDel,QString _str,int _nGroup,int _nCommand,QString _strFilterId ="");
bool ReloadColumn(); bool ReloadColumn();
QString GetArticleType(int _nSelect); QString GetArticleType(int _nSelect);
public slots: public slots:
void CloseTab(int index); void CloseTab(int index);
void DoubleClickTab(int index); void DoubleClickTab(int index);
void SearchDate();
void CountSave(); void CountSave();
void SearchDate();
void SearchKeyword(); void SearchKeyword();
void SearchLengthInsert();
void SearchReplaceInsert();
void SearchDateUpdate();
void SearchKeywordUpdate();
void SearchLengthUpdate();
void SearchReplaceUpdate();
void SearchCounterUpdate();
void SearchCounterInsert();
static void Debug(QString _strMsg);
void DataGroupRefresh(); void DataGroupRefresh();
void DataGroupItemChanged ( QListWidgetItem * item ); void DataGroupItemChanged ( QListWidgetItem * item );
void FilterGroupInsert(); void FilterGroupInsert();
@@ -144,8 +188,6 @@ public slots:
void currentGroupItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0); void currentGroupItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0);
void FilterDelete(); void FilterDelete();
void currentFilterItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0); void currentFilterItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0);
void SearchLengthInsert();
void SearchReplaceInsert();
void FileNew(); void FileNew();
void FileImport(); void FileImport();
void FileExport(); void FileExport();

View File

@@ -55,6 +55,10 @@ public:
{ {
return m_nBody; return m_nBody;
} }
int getPlatformTitlePosition()
{
return m_nPlatformTitle;
}
private: private:
// Data // Data
@@ -68,6 +72,7 @@ private:
int m_nColumn; int m_nColumn;
int m_nTitle; int m_nTitle;
int m_nBody; int m_nBody;
int m_nPlatformTitle;
// Keyword // Keyword
QComboBox *m_pcbCatalog; QComboBox *m_pcbCatalog;
QComboBox *m_pcbKeyword; QComboBox *m_pcbKeyword;
@@ -89,6 +94,7 @@ private:
QComboBox *m_pcbReplaceFind; QComboBox *m_pcbReplaceFind;
QLineEdit *m_pleReplaceFind; QLineEdit *m_pleReplaceFind;
QLineEdit *m_pleReplace; QLineEdit *m_pleReplace;
QComboBox *m_pcbReplace;
// Count // Count
QComboBox *m_pcbCountCatalog; QComboBox *m_pcbCountCatalog;
@@ -134,6 +140,7 @@ public slots:
void FilterGroupDelete(); void FilterGroupDelete();
void FilterGroupModify(); void FilterGroupModify();
void FilterGroupRefresh(); void FilterGroupRefresh();
void FilterGroupCopyPaste();
void currentGroupItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0); void currentGroupItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0);
void FilterDelete(); void FilterDelete();
void currentFilterItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0); void currentFilterItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0);