1575 lines
51 KiB
C++
1575 lines
51 KiB
C++
#include "sanaly1.h"
|
|
#include <QGroupBox>
|
|
#include <QButtonGroup>
|
|
#include <QLabel>
|
|
#include <QSqlQuery>
|
|
#include <QDebug>
|
|
#include <QFile>
|
|
#include <QFileDialog>
|
|
#include <QTextCodec>
|
|
#include <QMessageBox>
|
|
#include <QSqlError>
|
|
#include <QMenuBar>
|
|
#include <QInputDialog>
|
|
#include "../Json/sjson.h"
|
|
#include "../common.h"
|
|
|
|
|
|
/*
|
|
QSqlDatabase dbWeb = QSqlDatabase::addDatabase("QMYSQL");
|
|
dbWeb.setHostName("db.big-bird.co.kr");
|
|
dbWeb.setUserName("concepters");
|
|
dbWeb.setPassword("con97996655");
|
|
dbWeb.setDatabaseName("dbconcepters");
|
|
*/
|
|
|
|
#define D_NOT_SELECT -1
|
|
|
|
#define SAFE_DELETE(x) if(x != NULL) { delete x; x = NULL; }
|
|
#define SAFE_DELETEARRAY(x) if(x != NULL) { delete [] x; x = NULL; }
|
|
#define SAFE_RELEASE(x) if(x != NULL) { x->Release(); x = NULL; }
|
|
|
|
SAnaly1::SAnaly1(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_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";
|
|
}
|
|
|
|
QVBoxLayout *vMainLayout = new QVBoxLayout;
|
|
vMainLayout->setAlignment(Qt::AlignVCenter);
|
|
QVBoxLayout *vboxlayout = new QVBoxLayout;
|
|
|
|
QGroupBox *gBox = setMorphereList();
|
|
QGroupBox *gDate = setDate();
|
|
QGroupBox *gFilter = setFilter();
|
|
QGroupBox *gOther = setOther();
|
|
QGroupBox *gSort = setSort();
|
|
QHBoxLayout *hboxlayout = new QHBoxLayout;
|
|
QGroupBox *gDictionary = setDictionary();
|
|
|
|
hboxlayout->addWidget(gBox,5);
|
|
vboxlayout->addWidget(gDate,3);
|
|
//vboxlayout->addWidget(gFilter,3);
|
|
vboxlayout->addWidget(gSort,2);
|
|
vboxlayout->addWidget(gOther,2);
|
|
vboxlayout->addWidget(gDictionary,2);
|
|
hboxlayout->addLayout(vboxlayout,5);
|
|
|
|
vMainLayout->addLayout(hboxlayout, 2);
|
|
|
|
m_ptwData = new QTabWidget;
|
|
m_ptwData->setTabsClosable(true);
|
|
connect(m_ptwData,SIGNAL(tabCloseRequested(int)),this,SLOT(CloseTab(int)));
|
|
connect(m_ptwData,SIGNAL(tabBarDoubleClicked(int)),this,SLOT(DoubleClickTab(int)));
|
|
AddTable("Start");
|
|
|
|
vMainLayout->addWidget(m_ptwData, 8);
|
|
setLayout(vMainLayout);
|
|
}
|
|
|
|
QGroupBox *SAnaly1::setMorphereList()
|
|
{
|
|
QVBoxLayout *vlayout = new QVBoxLayout;
|
|
QVBoxLayout *vlayout1 = new QVBoxLayout;
|
|
|
|
QHBoxLayout *hlayout = new QHBoxLayout;
|
|
QGroupBox *groupBox = new QGroupBox(tr("Morphere List"));
|
|
|
|
m_plwMorphereList = new QListWidget;
|
|
m_plwMorphereAdd = new QListWidget;
|
|
m_plwMorphereList->setSelectionMode(QAbstractItemView::MultiSelection);
|
|
m_plwMorphereAdd->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
|
|
for(int i=0;i<m_strlistMorphere.size();i++)
|
|
{
|
|
QListWidgetItem* pitem = new QListWidgetItem(m_strlistMorphereko.at(i), m_plwMorphereList);
|
|
pitem->setData(Qt::UserRole, QVariant(m_strlistMorphere.at(i)));
|
|
}
|
|
|
|
for(int i=0;i<m_strlistMorphere.size();i++)
|
|
{
|
|
QListWidgetItem* pitem = new QListWidgetItem(m_strlistMorphereko.at(i), m_plwMorphereAdd);
|
|
pitem->setData(Qt::UserRole, QVariant(m_strlistMorphere.at(i)));
|
|
}
|
|
|
|
for(int i=0;i<m_plwMorphereAdd->count();i++)
|
|
{
|
|
m_plwMorphereAdd->item(i)->setHidden(true);
|
|
}
|
|
|
|
|
|
QPushButton *ppbAdd = new QPushButton("Add");
|
|
QPushButton *ppbDel = new QPushButton("Del");
|
|
vlayout->addWidget(m_plwMorphereList);
|
|
vlayout->addWidget(ppbAdd);
|
|
|
|
vlayout1->addWidget(m_plwMorphereAdd);
|
|
vlayout1->addWidget(ppbDel);
|
|
|
|
connect(ppbAdd, SIGNAL(released()),this, SLOT(MorphereListAdd()));
|
|
connect(ppbDel, SIGNAL(released()),this, SLOT(MorphereListDel()));
|
|
|
|
|
|
|
|
hlayout->addLayout(vlayout);
|
|
hlayout->addLayout(vlayout1);
|
|
|
|
groupBox->setLayout(hlayout);
|
|
groupBox->setCheckable(true);
|
|
return groupBox;
|
|
}
|
|
|
|
|
|
QGroupBox *SAnaly1::setDate()
|
|
{
|
|
QHBoxLayout *hlayout = new QHBoxLayout;
|
|
QHBoxLayout *hlayout1 = new QHBoxLayout;
|
|
QVBoxLayout *vlayout = new QVBoxLayout;
|
|
|
|
QGroupBox *groupBox = new QGroupBox(tr("Date"));
|
|
|
|
m_pdeStart = new QDateEdit(QDate::currentDate());
|
|
m_pdeEnd = new QDateEdit(QDate::currentDate());
|
|
|
|
m_pdeStart->setDateRange(QDate(2003, 5, 20),QDate::currentDate());
|
|
m_pdeEnd->setDateRange(QDate(2003, 5, 20),QDate::currentDate());
|
|
|
|
QCalendarWidget *pCalender = new QCalendarWidget();
|
|
m_pdeStart->setCalendarWidget(pCalender);
|
|
m_pdeStart->setCalendarPopup(true);
|
|
|
|
m_pdeEnd->setCalendarWidget(pCalender);
|
|
m_pdeEnd->setCalendarPopup(true);
|
|
|
|
m_pcbDate = new QComboBox;
|
|
m_pcbDate->addItems(QStringList() << "ALL" << "NotAll");
|
|
|
|
m_pcbPeriod = new QComboBox;
|
|
m_pcbPeriod->addItems(QStringList() << "None" << "1 Day" << "1 Week" << "1 Month");
|
|
|
|
hlayout->addWidget(m_pcbDate);
|
|
hlayout->addWidget(new QLabel("Start:"));
|
|
hlayout->addWidget(m_pdeStart);
|
|
hlayout->addWidget(new QLabel("End:"));
|
|
hlayout->addWidget(m_pdeEnd);
|
|
|
|
hlayout1->addWidget(new QLabel("Period:"));
|
|
hlayout1->addWidget(m_pcbPeriod);
|
|
|
|
vlayout->addLayout(hlayout);
|
|
vlayout->addLayout(hlayout1);
|
|
|
|
vlayout->addLayout(hlayout);
|
|
vlayout->addLayout(hlayout1);
|
|
groupBox->setCheckable(true);
|
|
|
|
groupBox->setLayout(vlayout);
|
|
|
|
return groupBox;
|
|
}
|
|
|
|
QGroupBox *SAnaly1::setFilter()
|
|
{
|
|
QHBoxLayout *hlayout = new QHBoxLayout;
|
|
|
|
m_pleKeyword = new QLineEdit;
|
|
m_pleTop = new QLineEdit;
|
|
|
|
hlayout->addWidget(new QLabel("Top: <"));
|
|
hlayout->addWidget(m_pleTop);
|
|
hlayout->addWidget(new QLabel("Keyword:"));
|
|
hlayout->addWidget(m_pleKeyword);
|
|
|
|
QGroupBox *groupBox = new QGroupBox(tr("Filter"));
|
|
|
|
groupBox->setCheckable(true);
|
|
|
|
groupBox->setLayout(hlayout);
|
|
groupBox->setChecked(false);
|
|
return groupBox;
|
|
}
|
|
|
|
QGroupBox *SAnaly1::setOther()
|
|
{
|
|
QHBoxLayout *hlayout = new QHBoxLayout;
|
|
|
|
m_pcbThread = new QComboBox;
|
|
|
|
hlayout->addWidget(new QLabel("Thread:"));
|
|
hlayout->addWidget(m_pcbThread);
|
|
|
|
m_pcbThread->addItems(QStringList() << "1" << "2" << "4" << "8");
|
|
|
|
QGroupBox *groupBox = new QGroupBox(tr("Other"));
|
|
groupBox->setCheckable(true);
|
|
|
|
groupBox->setLayout(hlayout);
|
|
|
|
return groupBox;
|
|
}
|
|
|
|
QGroupBox *SAnaly1::setSort()
|
|
{
|
|
QHBoxLayout *hlayout = new QHBoxLayout;
|
|
|
|
m_rbDateMorphere = new QRadioButton("Date/Morphere");
|
|
m_rbMorphereDate = new QRadioButton("Morphere/Date");
|
|
|
|
|
|
m_bgRadioGroup = new QButtonGroup;
|
|
|
|
m_bgRadioGroup->addButton(m_rbMorphereDate);
|
|
m_bgRadioGroup->addButton(m_rbDateMorphere);
|
|
|
|
m_rbMorphereDate->setChecked(true);
|
|
|
|
hlayout->addWidget(m_rbMorphereDate);
|
|
hlayout->addWidget(m_rbDateMorphere);
|
|
|
|
QGroupBox *groupBox = new QGroupBox(tr("Sort"));
|
|
groupBox->setCheckable(true);
|
|
|
|
groupBox->setLayout(hlayout);
|
|
|
|
return groupBox;
|
|
}
|
|
|
|
|
|
QGroupBox *SAnaly1::setDictionary()
|
|
{
|
|
QHBoxLayout *hlayout = new QHBoxLayout;
|
|
|
|
m_pcbDictionary = new QComboBox;
|
|
|
|
m_pcbDictionary->setEditable(true);
|
|
m_pcbDictionary->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
QPushButton* add = new QPushButton;
|
|
QPushButton* del = new QPushButton;
|
|
add->setText(tr("+"));
|
|
del->setText(tr("-"));
|
|
|
|
//hlayout->addWidget(new QLabel(tr("User-Dict: ")));
|
|
hlayout->addWidget(m_pcbDictionary);
|
|
hlayout->addWidget(add);
|
|
hlayout->addWidget(del);
|
|
|
|
connect(add, SIGNAL(released()),this, SLOT(AddDictionary()));
|
|
connect(del, SIGNAL(released()),this, SLOT(DelDictionary()));
|
|
|
|
QGroupBox *groupBox = new QGroupBox(tr("User Dictionary"));
|
|
groupBox->setCheckable(true);
|
|
|
|
groupBox->setLayout(hlayout);
|
|
|
|
return groupBox;
|
|
}
|
|
|
|
void SAnaly1::AddDictionary()
|
|
{
|
|
QStringList strFilenames = QFileDialog::getOpenFileNames(0,"Dictionary file",QDir::currentPath(),
|
|
"dic files (*.dic);;All files (*.*)",new QString("Dictionary files (*.dic)"));
|
|
|
|
foreach(QString strFilename, strFilenames)
|
|
{
|
|
QFile file(strFilename);
|
|
if (!file.open(QIODevice::ReadOnly)) return;
|
|
}
|
|
|
|
|
|
for(int i = 0; i < m_pcbDictionary->count(); i++)
|
|
{
|
|
if(strFilenames.contains(m_pcbDictionary->itemText(i)))
|
|
strFilenames.removeOne(m_pcbDictionary->itemText(i));
|
|
}
|
|
|
|
m_pcbDictionary->addItems(strFilenames);
|
|
}
|
|
|
|
QString SAnaly1::getUserDictList()
|
|
{
|
|
QStringList strList;
|
|
|
|
for(int i = 0; i < m_pcbDictionary->count();i++)
|
|
{
|
|
strList << m_pcbDictionary->itemText(i);
|
|
}
|
|
|
|
return strList.join(",");
|
|
}
|
|
|
|
|
|
|
|
void SAnaly1::DelDictionary()
|
|
{
|
|
m_pcbDictionary->removeItem(0);
|
|
qDebug() << getUserDictList();
|
|
}
|
|
|
|
bool SAnaly1::isSortMorphereDateChecked()
|
|
{
|
|
return m_rbMorphereDate->isChecked();
|
|
}
|
|
|
|
bool SAnaly1::isSortDateMorphereChecked()
|
|
{
|
|
return m_rbDateMorphere->isChecked();
|
|
}
|
|
|
|
SAnaly1::~SAnaly1()
|
|
{
|
|
}
|
|
|
|
void SAnaly1::MorphereListAdd()
|
|
{
|
|
QList<QListWidgetItem *> listitem = m_plwMorphereList->selectedItems();
|
|
|
|
foreach(QListWidgetItem *item, listitem)
|
|
{
|
|
for(int i = 0; i < m_plwMorphereAdd->count();i++)
|
|
{
|
|
if(item->data(Qt::UserRole) == m_plwMorphereAdd->item(i)->data(Qt::UserRole))
|
|
m_plwMorphereAdd->item(i)->setHidden(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
void SAnaly1::MorphereListDel()
|
|
{
|
|
for(int i = m_plwMorphereAdd->count() - 1; i >= 0 ;i--)
|
|
{
|
|
if(m_plwMorphereAdd->item(i)->isSelected())
|
|
{
|
|
m_plwMorphereAdd->item(i)->setHidden(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
QTableWidget *SAnaly1::AddTable(QString _str)
|
|
{
|
|
STable *pTable = new STable;
|
|
m_ptwData->addTab(pTable,_str);
|
|
return (QTableWidget *)pTable;
|
|
}
|
|
|
|
void SAnaly1::CloseTab(int index)
|
|
{
|
|
((STable*)(m_ptwData->widget(index)))->clear();
|
|
m_ptwData->removeTab(index);
|
|
}
|
|
|
|
void SAnaly1::DoubleClickTab(int index)
|
|
{
|
|
bool ok;
|
|
if (index < 0) return;
|
|
QString text = QInputDialog::getText(this,"Tab name change","Name : ", QLineEdit::Normal,m_ptwData->tabText(index), &ok);
|
|
if (ok)
|
|
{
|
|
m_ptwData->setTabText(index,text);
|
|
}
|
|
}
|
|
|
|
QMenuBar *SAnaly1::setMenuWidget()
|
|
{
|
|
QMenuBar *pMenuBar = new QMenuBar();
|
|
{
|
|
QMenu *pFile = pMenuBar->addMenu("File");
|
|
connect(pFile->addAction("New"), SIGNAL(triggered()), this, SLOT(FileNew()));
|
|
connect(pFile->addAction("CSV Import"), SIGNAL(triggered()), this, SLOT(FileImport()));
|
|
connect(pFile->addAction("CSV Export"), SIGNAL(triggered()), this, SLOT(FileExport()));
|
|
pFile->addSeparator();
|
|
connect(pFile->addAction("Exit"), SIGNAL(triggered()), this, SLOT(FileExit()));
|
|
}
|
|
return pMenuBar;
|
|
}
|
|
|
|
void SAnaly1::FileNew()
|
|
{
|
|
bool ok;
|
|
QString text = QInputDialog::getText(this,"New Row Count","Count :", QLineEdit::Normal,"0", &ok);
|
|
|
|
if (ok)
|
|
{
|
|
STable *pTable = (STable*)AddTable("new");
|
|
pTable->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
|
|
m_ptwData->setCurrentIndex(m_ptwData->count()-1);
|
|
pTable->setRowCount(text.toInt());
|
|
}
|
|
}
|
|
|
|
QGroupBox *SAnaly1::setDataWidgets()
|
|
{
|
|
QVBoxLayout *vlayout = new QVBoxLayout;
|
|
|
|
QGroupBox *groupBox = new QGroupBox(tr("Data Group"));
|
|
m_plwData = new QListWidget;
|
|
vlayout->addWidget(m_plwData);
|
|
m_plwData->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
QPushButton *ppbRefresh = new QPushButton("Refresh");
|
|
vlayout->addWidget(ppbRefresh);
|
|
connect(ppbRefresh, SIGNAL(released()),this, SLOT(DataGroupRefresh()));
|
|
groupBox->setLayout(vlayout);
|
|
connect(m_plwData,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(DataGroupItemChanged(QListWidgetItem*)));
|
|
return groupBox;
|
|
}
|
|
|
|
QGroupBox *SAnaly1::setDateWidgets()
|
|
{
|
|
//m_pcbDateCatalog = new QComboBox;
|
|
m_pdeStart = new QDateEdit(QDate::currentDate());
|
|
m_pdeEnd = new QDateEdit(QDate::currentDate());
|
|
|
|
m_pdeStart->setDateRange(QDate(2003, 5, 20),QDate::currentDate());
|
|
m_pdeEnd->setDateRange(QDate(2003, 5, 20),QDate::currentDate());
|
|
|
|
m_pcw = new QCalendarWidget();
|
|
m_pdeStart->setCalendarWidget(m_pcw);
|
|
m_pdeStart->setCalendarPopup(true);
|
|
|
|
m_pdeEnd->setCalendarWidget(m_pcw);
|
|
m_pdeEnd->setCalendarPopup(true);
|
|
|
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
|
//hlayout->addWidget(new QLabel("Catalog:"));
|
|
//hlayout->addWidget(m_pcbDateCatalog);
|
|
hlayout->addWidget(new QLabel("Start:"));
|
|
hlayout->addWidget(m_pdeStart);
|
|
hlayout->addWidget(new QLabel("End:"));
|
|
hlayout->addWidget(m_pdeEnd);
|
|
|
|
{
|
|
QPushButton *pbInsert = new QPushButton("Insert");
|
|
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchDate()));
|
|
hlayout->addWidget(pbInsert);
|
|
}
|
|
|
|
hlayout->setAlignment(Qt::AlignLeft|Qt::AlignTop);
|
|
QGroupBox *groupBox = new QGroupBox(tr("Term"));
|
|
groupBox->setAlignment(Qt::AlignLeft|Qt::AlignTop);
|
|
groupBox->setLayout(hlayout);
|
|
//m_pcbDateCatalog->addItems(QStringList() << "body + reply" << "body" << "reply");
|
|
|
|
return groupBox;
|
|
}
|
|
|
|
QGroupBox *SAnaly1::setCountWidgets()
|
|
{
|
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
|
m_pcbCountCatalog = new QComboBox;
|
|
|
|
hlayout->addWidget(m_pcbCountCatalog);
|
|
|
|
foreach(QStringList strList,m_vecColumn)
|
|
m_pcbCountCatalog->addItem(strList.at(E_COLUMN_NAME));
|
|
|
|
{
|
|
QPushButton *pbInsert = new QPushButton("Save");
|
|
connect(pbInsert , SIGNAL(released()),this, SLOT(CountSave()));
|
|
hlayout->addWidget(pbInsert);
|
|
}
|
|
QGroupBox *groupBox = new QGroupBox(tr("Count"));
|
|
groupBox->setLayout(hlayout);
|
|
return groupBox;
|
|
}
|
|
|
|
QGroupBox *SAnaly1::setSearchWidgets()
|
|
{
|
|
m_pcbCatalog = new QComboBox;
|
|
m_pcbKeyword = new QComboBox;
|
|
m_pcbMethod = new QComboBox;
|
|
m_pleString = new QLineEdit;
|
|
|
|
m_pcbKeyword->addItem(QString("Or"));// or
|
|
m_pcbKeyword->addItem(QString("And"));// and
|
|
m_pcbKeyword->addItem(QString("Cell Delete"));
|
|
m_pcbKeyword->addItem(QString("Word Delete"));
|
|
|
|
m_pcbMethod->addItem(QString("Sentence"));
|
|
m_pcbMethod->addItem(QString("Space"));
|
|
|
|
foreach(QStringList strList,m_vecColumn)
|
|
m_pcbCatalog->addItem(strList.at(E_COLUMN_NAME));
|
|
|
|
QVBoxLayout *vlayout = new QVBoxLayout();
|
|
{
|
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
|
hlayout->addWidget(new QLabel("Item:"));
|
|
hlayout->addWidget(m_pcbCatalog);
|
|
hlayout->addWidget(new QLabel("Method:"));
|
|
hlayout->addWidget(m_pcbMethod);
|
|
hlayout->addWidget(new QLabel("keyword:"));
|
|
hlayout->addWidget(m_pcbKeyword);
|
|
vlayout->addLayout(hlayout);
|
|
}
|
|
|
|
{
|
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
|
hlayout->addWidget(new QLabel("Search:"));
|
|
hlayout->addWidget(m_pleString);
|
|
vlayout->addLayout(hlayout);
|
|
}
|
|
|
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
|
hlayout->addLayout(vlayout);
|
|
|
|
{
|
|
QPushButton *pbInsert = new QPushButton("Insert");
|
|
hlayout->addWidget(pbInsert);
|
|
connect(pbInsert, SIGNAL(released()),this, SLOT(SearchKeyword()));
|
|
}
|
|
|
|
QGroupBox *groupBox = new QGroupBox(tr("Search"));
|
|
groupBox->setLayout(hlayout);
|
|
return groupBox;
|
|
}
|
|
|
|
QGroupBox *SAnaly1::setLengthWidgets()
|
|
{
|
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
|
m_pcbLengthCatalog = new QComboBox;
|
|
m_pcbLengthComp = new QComboBox;
|
|
m_pcbLengthInsDel = new QComboBox;
|
|
m_pleLength = new QLineEdit;
|
|
|
|
foreach(QStringList strList,m_vecColumn)
|
|
m_pcbLengthCatalog->addItem(strList.at(E_COLUMN_NAME));
|
|
|
|
m_pcbLengthComp->addItem(">",QVariant(E_LENGTH_COMP_GREATER));
|
|
m_pcbLengthComp->addItem("<",QVariant(E_LENGTH_COMP_LESS));
|
|
m_pcbLengthComp->addItem("=",QVariant(E_LENGTH_COMP_EQUAL));
|
|
|
|
m_pcbLengthInsDel->addItem("Add",QVariant(0));
|
|
m_pcbLengthInsDel->addItem("Del",QVariant(1));
|
|
|
|
hlayout->addWidget(new QLabel("Item:"));
|
|
hlayout->addWidget(m_pcbLengthCatalog);
|
|
hlayout->addWidget(m_pcbLengthComp);
|
|
hlayout->addWidget(new QLabel("Length:"));
|
|
hlayout->addWidget(m_pleLength);
|
|
hlayout->addWidget(m_pcbLengthInsDel);
|
|
{
|
|
QPushButton *pbInsert = new QPushButton("Insert");
|
|
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchLengthInsert()));
|
|
hlayout->addWidget(pbInsert);
|
|
}
|
|
QGroupBox *groupBox = new QGroupBox(tr("Length"));
|
|
groupBox->setLayout(hlayout);
|
|
return groupBox;
|
|
}
|
|
|
|
QGroupBox *SAnaly1::setReplaceWidgets()
|
|
{
|
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
|
m_pcbReplaceCatalog = new QComboBox;
|
|
m_pcbReplaceFind = new QComboBox;
|
|
m_pleReplaceFind = new QLineEdit;
|
|
m_pleReplace = new QLineEdit;
|
|
|
|
foreach(QStringList strList,m_vecColumn)
|
|
m_pcbReplaceCatalog->addItem(strList.at(E_COLUMN_NAME));
|
|
|
|
m_pcbReplaceFind->addItem("Sentence",QVariant(E_REPLACE_SENTENCE));
|
|
m_pcbReplaceFind->addItem("Space",QVariant(E_REPLACE_SPACE));
|
|
|
|
hlayout->addWidget(m_pcbReplaceCatalog);
|
|
hlayout->addWidget(new QLabel("Find:"));
|
|
hlayout->addWidget(m_pcbReplaceFind);
|
|
hlayout->addWidget(m_pleReplaceFind);
|
|
hlayout->addWidget(new QLabel("Replace:"));
|
|
hlayout->addWidget(m_pleReplace);
|
|
{
|
|
QPushButton *pbInsert = new QPushButton("Insert");
|
|
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchReplaceInsert()));
|
|
hlayout->addWidget(pbInsert);
|
|
}
|
|
QGroupBox *groupBox = new QGroupBox(tr("Replace"));
|
|
groupBox->setLayout(hlayout);
|
|
return groupBox;
|
|
}
|
|
|
|
QGroupBox *SAnaly1::setFilterWidgets()
|
|
{
|
|
QHBoxLayout *hMainlayout = new QHBoxLayout();
|
|
{
|
|
QVBoxLayout *vlayout = new QVBoxLayout();
|
|
m_plwFilterGroup = new QListWidget;
|
|
m_pleFilterGroup = new QLineEdit;
|
|
vlayout->addWidget(m_plwFilterGroup);
|
|
vlayout->addWidget(m_pleFilterGroup);
|
|
{
|
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
|
QPushButton *pbInsert = new QPushButton("Insert");
|
|
connect(pbInsert, SIGNAL(released()),this, SLOT(FilterGroupInsert()));
|
|
QPushButton *pbDelete = new QPushButton("Delete");
|
|
connect(pbDelete, SIGNAL(released()),this, SLOT(FilterGroupDelete()));
|
|
QPushButton *pbModify = new QPushButton("Modfiy");
|
|
connect(pbModify, SIGNAL(released()),this, SLOT(FilterGroupModify()));
|
|
QPushButton *pbRefresh = new QPushButton("Refresh");
|
|
connect(pbRefresh, SIGNAL(released()),this, SLOT(FilterGroupRefresh()));
|
|
|
|
hlayout->addWidget(pbInsert);
|
|
hlayout->addWidget(pbDelete);
|
|
hlayout->addWidget(pbRefresh);
|
|
vlayout->addLayout(hlayout);
|
|
}
|
|
hMainlayout->addLayout(vlayout);
|
|
}
|
|
{
|
|
QVBoxLayout *vlayout = new QVBoxLayout();
|
|
m_plwFilter = new QListWidget;
|
|
vlayout->addWidget(m_plwFilter);
|
|
connect(m_plwFilter,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(currentFilterItemChanged(QListWidgetItem*,QListWidgetItem*)));
|
|
QPushButton *pbDelete = new QPushButton("Delete");
|
|
vlayout->addWidget(pbDelete);
|
|
connect(pbDelete, SIGNAL(released()),this, SLOT(FilterDelete()));
|
|
hMainlayout->addLayout(vlayout);
|
|
}
|
|
m_pgbFilter = new QGroupBox(tr("Filter"));
|
|
m_pgbFilter->setCheckable(true);
|
|
m_pgbFilter->setChecked(false);
|
|
m_pgbFilter->setLayout(hMainlayout);
|
|
|
|
connect(m_plwFilterGroup,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(currentGroupItemChanged(QListWidgetItem *, QListWidgetItem *)));
|
|
return m_pgbFilter;
|
|
}
|
|
|
|
|
|
void SAnaly1::DataGroupRefresh()
|
|
{
|
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
|
db.setHostName("bigbird.iptime.org");
|
|
db.setUserName("admin");
|
|
db.setPassword("admin123");
|
|
db.setDatabaseName("concepters");
|
|
if (db.open() == false)
|
|
{
|
|
qDebug() << db.lastError().text();
|
|
return;
|
|
}
|
|
m_plwData->clear();
|
|
QSqlQuery query("select id,name from datagroup");
|
|
while (query.next())
|
|
{
|
|
QListWidgetItem *pItem = new QListWidgetItem(query.value(1).toString(),m_plwData);
|
|
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
|
}
|
|
db.close();
|
|
}
|
|
|
|
void SAnaly1::InsertCopyRow(int _nRow,QTableWidget *_pCurrent,QTableWidget *_pNew)
|
|
{
|
|
_pNew->setRowCount(_pNew->rowCount()+1);
|
|
for (int nCount = 0;nCount < _pCurrent->columnCount() ;nCount++ )
|
|
{
|
|
_pNew->setItem(_pNew->rowCount()-1,nCount,new QTableWidgetItem(*_pCurrent->item(_nRow,nCount)));
|
|
}
|
|
}
|
|
|
|
void SAnaly1::SearchDate()
|
|
{
|
|
STable *pNew = new STable;
|
|
STable *pCurrent = (STable *)m_ptwData->currentWidget();
|
|
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
|
pNew->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
|
|
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
|
|
|
int nCurrentFilterGroupID = D_NOT_SELECT;
|
|
|
|
if (m_pgbFilter->isChecked())
|
|
{
|
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
|
{
|
|
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
|
|
InsertTimeFilter(pNew->getArticleSelect(),m_pdeStart->date(),m_pdeEnd->date(),nCurrentFilterGroupID);
|
|
}
|
|
}
|
|
|
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
|
{
|
|
bool bFlag = false;
|
|
QString strTime = pCurrent->item(nCount,m_nColumn)->text().trimmed();
|
|
if (strTime.size() >= 10)
|
|
{
|
|
QChar ch = strTime.at(4);
|
|
QString strFormat = QString("yyyy")+ch+QString("MM")+ch+QString("dd");
|
|
QDate date = QDate::fromString(strTime.left(10),strFormat);
|
|
if (m_pdeStart->date() <= date && m_pdeEnd->date() >= date)
|
|
bFlag = true;
|
|
}
|
|
if (bFlag)
|
|
InsertCopyRow(nCount,pCurrent,pNew);
|
|
m_pProgress->setValue(nCount);
|
|
m_pProgress->repaint();
|
|
}
|
|
//m_ptwData->addTab(pNew,m_ptwData->tabText(m_ptwData->currentIndex())+" d");
|
|
m_ptwData->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
|
m_ptwData->setCurrentIndex(m_ptwData->count()-1);
|
|
if (nCurrentFilterGroupID != D_NOT_SELECT)
|
|
RefreshFilter(nCurrentFilterGroupID);
|
|
}
|
|
|
|
void SAnaly1::SearchKeyword()
|
|
{
|
|
STable *pNew = new STable;
|
|
STable *pCurrent = (STable *)m_ptwData->currentWidget();
|
|
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
|
pNew->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
|
|
int nCurrentFilterGroupID = D_NOT_SELECT;
|
|
|
|
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;
|
|
|
|
if (m_pgbFilter->isChecked())
|
|
{
|
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
|
{
|
|
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
|
|
InsertSearchFilter(pNew->getArticleSelect(),m_pcbCatalog->currentIndex(),m_pcbMethod->currentIndex(),m_pcbKeyword->currentIndex(),strKey,nCurrentFilterGroupID);
|
|
}
|
|
}
|
|
|
|
QStringList strListKeyword = strKey.split(" ");
|
|
if (m_pcbMethod->currentIndex() == 1)
|
|
{
|
|
for (int i = 0 ; i < strListKeyword.size(); i++ )
|
|
{
|
|
strListKeyword[i] = " " + strListKeyword[i] + " ";
|
|
}
|
|
}
|
|
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
|
{
|
|
bool bFlag = false;
|
|
//if (m_pcbCatalog->currentText() == "ALL")
|
|
QString strData = pCurrent->item(nCount,m_pcbCatalog->currentIndex())->text();
|
|
switch(m_pcbKeyword->currentIndex())
|
|
{
|
|
case 0:
|
|
{
|
|
foreach(QString strKey , strListKeyword)
|
|
if (strData.contains(strKey)){bFlag = true;break;}
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
int nKeyCount = 0;
|
|
foreach(QString strKey , strListKeyword)
|
|
if (strData.contains(strKey)) nKeyCount++;
|
|
if (nKeyCount == strListKeyword.size())
|
|
bFlag = true;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
bFlag = true;
|
|
foreach(QString strKey , strListKeyword)
|
|
if (strData.contains(strKey)){bFlag = false;break;}
|
|
break;
|
|
}
|
|
case 3: bFlag = true;break;
|
|
}
|
|
if (bFlag) InsertCopyRow(nCount,pCurrent,pNew);
|
|
if (m_pcbKeyword->currentIndex() == 3)
|
|
{
|
|
foreach(QString strKey , strListKeyword)
|
|
{
|
|
strData.replace(strKey,"");
|
|
}
|
|
pNew->item(nCount,m_pcbCatalog->currentIndex())->setText(strData);
|
|
}
|
|
m_pProgress->setValue(nCount);
|
|
m_pProgress->repaint();
|
|
}
|
|
//m_ptwData->addTab(pNew,m_ptwData->tabText(m_ptwData->currentIndex())+" k");
|
|
m_ptwData->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
|
m_ptwData->setCurrentIndex(m_ptwData->count()-1);
|
|
|
|
if (nCurrentFilterGroupID != D_NOT_SELECT)
|
|
RefreshFilter(nCurrentFilterGroupID);
|
|
}
|
|
|
|
void SAnaly1::SearchLengthInsert()
|
|
{
|
|
STable *pNew = new STable;
|
|
STable *pCurrent = (STable *)m_ptwData->currentWidget();
|
|
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
|
pNew->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
|
|
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
|
int nCatalog = m_pcbLengthCatalog->currentIndex();
|
|
int nComp = m_pcbLengthComp->currentData().toInt();
|
|
int nFlag = m_pcbLengthInsDel->currentData().toInt();
|
|
int nLength = m_pleLength->text().toInt();
|
|
|
|
int nCurrentFilterGroupID = D_NOT_SELECT;
|
|
|
|
if (m_pgbFilter->isChecked())
|
|
{
|
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
|
{
|
|
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
|
|
InsertLengthFilter(pCurrent->getArticleSelect(),nCatalog,nComp,nFlag,m_pleLength->text(),nCurrentFilterGroupID);
|
|
}
|
|
}
|
|
|
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
|
{
|
|
bool bFlag = false;
|
|
int nCurrentLength = pCurrent->item(nCount,nCatalog)->text().trimmed().length();
|
|
switch(nComp)
|
|
{
|
|
case E_LENGTH_COMP_GREATER:
|
|
if (nCurrentLength > nLength)
|
|
bFlag = true;
|
|
break;
|
|
case E_LENGTH_COMP_LESS:
|
|
if (nCurrentLength < nLength)
|
|
bFlag = true;
|
|
break;
|
|
case E_LENGTH_COMP_EQUAL:
|
|
if (nLength == nCurrentLength)
|
|
bFlag = true;
|
|
break;
|
|
}
|
|
if (nFlag == 1) bFlag = !bFlag;
|
|
if (bFlag) InsertCopyRow(nCount,pCurrent,pNew);
|
|
m_pProgress->setValue(nCount);
|
|
m_pProgress->repaint();
|
|
}
|
|
//m_ptwData->addTab(pNew,m_ptwData->tabText(m_ptwData->currentIndex())+" c");
|
|
m_ptwData->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
|
m_ptwData->setCurrentIndex(m_ptwData->count()-1);
|
|
if (nCurrentFilterGroupID != D_NOT_SELECT)
|
|
RefreshFilter(nCurrentFilterGroupID);
|
|
}
|
|
|
|
void SAnaly1::SearchReplaceInsert()
|
|
{
|
|
STable *pNew = new STable;
|
|
STable *pCurrent = (STable *)m_ptwData->currentWidget();
|
|
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
|
pNew->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
|
|
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
|
int nCatalog = m_pcbReplaceCatalog->currentIndex();
|
|
|
|
bool bFlag = false;
|
|
QStringList strListKeyword;
|
|
if (m_pcbReplaceFind->currentData().toInt() == E_REPLACE_SPACE)
|
|
{
|
|
bFlag = true;
|
|
strListKeyword = m_pleReplaceFind->text().split(" ");
|
|
}
|
|
int nCurrentFilterGroupID = D_NOT_SELECT;
|
|
|
|
if (m_pgbFilter->isChecked())
|
|
{
|
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
|
{
|
|
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
|
|
InsertReplaceFilter(pNew->getArticleSelect(),nCatalog,
|
|
m_pcbReplaceFind->currentData().toInt(),
|
|
m_pleReplaceFind->text(),m_pleReplace->text(),
|
|
nCurrentFilterGroupID);
|
|
}
|
|
}
|
|
pNew->setRowCount(pCurrent->rowCount());
|
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
|
{
|
|
for (int nColumnCount = 0;nColumnCount < pCurrent->columnCount() ;nColumnCount++ )
|
|
{
|
|
if (nCatalog == nColumnCount)
|
|
{
|
|
QString strOut = pCurrent->item(nCount,nColumnCount)->text();
|
|
if (bFlag)
|
|
{
|
|
foreach(QString str,strListKeyword)
|
|
strOut = strOut.replace(str,m_pleReplace->text());
|
|
}
|
|
else
|
|
strOut = strOut.replace(m_pleReplaceFind->text(),m_pleReplace->text());
|
|
|
|
pNew->setItem(nCount,nColumnCount,new QTableWidgetItem(strOut));
|
|
}
|
|
else
|
|
pNew->setItem(nCount,nColumnCount,new QTableWidgetItem(*pCurrent->item(nCount,nColumnCount)));
|
|
}
|
|
m_pProgress->setValue(nCount);
|
|
m_pProgress->repaint();
|
|
}
|
|
//m_ptwData->addTab(pNew,m_ptwData->tabText(m_ptwData->currentIndex())+" r");
|
|
m_ptwData->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
|
m_ptwData->setCurrentIndex(m_ptwData->count()-1);
|
|
|
|
if (nCurrentFilterGroupID != D_NOT_SELECT)
|
|
RefreshFilter(nCurrentFilterGroupID);
|
|
}
|
|
|
|
void SAnaly1::DataGroupItemChanged( QListWidgetItem *item)
|
|
{
|
|
QMessageBox msg;
|
|
msg.setText("Please choose...");
|
|
msg.setModal(true);
|
|
QPushButton *pbAll = msg.addButton("All",QMessageBox::ActionRole);
|
|
QPushButton *pbBody = msg.addButton("Body",QMessageBox::ActionRole);
|
|
QPushButton *pbReply = msg.addButton("Reply",QMessageBox::ActionRole);
|
|
msg.exec();
|
|
if (msg.clickedButton() == pbAll) DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_ALL);
|
|
else if (msg.clickedButton() == pbBody) DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_BODY);
|
|
else if (msg.clickedButton() == pbReply) DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_REPLY);
|
|
}
|
|
|
|
void SAnaly1::DataReload(QString _strTableName,int _nSelect)
|
|
{
|
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
|
db.setHostName("bigbird.iptime.org");
|
|
db.setUserName("admin");
|
|
db.setPassword("admin123");
|
|
db.setDatabaseName("concepters");
|
|
if (db.open() == false)
|
|
{
|
|
qDebug() << db.lastError().text();
|
|
return;
|
|
}
|
|
QString strSelect;
|
|
strSelect = "select ";
|
|
foreach(QStringList strlist,m_vecColumn)
|
|
strSelect += "CONVERT(" + strlist.at(E_COLUMN_DATABASE) + " USING utf8),";
|
|
strSelect = strSelect.left(strSelect.size()-1);
|
|
strSelect += " from ";
|
|
strSelect += _strTableName;
|
|
|
|
if (_nSelect == STable::E_ARTICLE_BODY)
|
|
strSelect += " WHERE article_form = 'body'";
|
|
if (_nSelect == STable::E_ARTICLE_REPLY)
|
|
strSelect += " WHERE article_form = 'reply'";
|
|
|
|
QSqlQuery query(strSelect);
|
|
STable *pTable = (STable *)m_ptwData->currentWidget();
|
|
pTable->setArticleSelect(_nSelect);
|
|
pTable->clear();
|
|
pTable->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
|
|
pTable->setRowCount(query.size());
|
|
m_pProgress->setRange(0,query.size());
|
|
int nCount = 0;
|
|
while (query.next())
|
|
{
|
|
for (int i = 0; i < pTable->columnCount() ; i++)
|
|
{
|
|
QString str = query.value(i).toString().replace("\n"," ");
|
|
pTable->setItem(nCount,i,new QTableWidgetItem(" "+str.replace("\t"," ")+" "));
|
|
}
|
|
nCount++;
|
|
m_pProgress->setValue(nCount);
|
|
m_pProgress->repaint();
|
|
}
|
|
db.close();
|
|
}
|
|
|
|
void SAnaly1::FilterGroupInsert()
|
|
{
|
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
|
db.setHostName("bigbird.iptime.org");
|
|
db.setUserName("admin");
|
|
db.setPassword("admin123");
|
|
db.setDatabaseName("concepters");
|
|
if (db.open() == false)
|
|
{
|
|
qDebug() << db.lastError().text();
|
|
return;
|
|
}
|
|
|
|
QString strQuery = QString("insert into filtergroup set "
|
|
"name = '" + m_pleFilterGroup->text() + "'");
|
|
db.exec(strQuery.toUtf8());
|
|
db.close();
|
|
FilterGroupRefresh();
|
|
}
|
|
|
|
void SAnaly1::FilterGroupDelete()
|
|
{
|
|
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())
|
|
{
|
|
QString strQuery = QString("delete from filtergroup where id = " + item->data(Qt::UserRole).toString());
|
|
db.exec(strQuery.toUtf8());
|
|
strQuery = QString("delete from filter where filtergroup_id = " + item->data(Qt::UserRole).toString());
|
|
db.exec(strQuery.toUtf8());
|
|
RefreshFilter(item->data(Qt::UserRole).toInt());
|
|
}
|
|
db.close();
|
|
FilterGroupRefresh();
|
|
}
|
|
|
|
void SAnaly1::FilterGroupModify()
|
|
{
|
|
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;
|
|
}
|
|
db.close();
|
|
}
|
|
|
|
void SAnaly1::FilterGroupRefresh()
|
|
{
|
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
|
db.setHostName("bigbird.iptime.org");
|
|
db.setUserName("admin");
|
|
db.setPassword("admin123");
|
|
db.setDatabaseName("concepters");
|
|
if (db.open() == false)
|
|
{
|
|
qDebug() << db.lastError().text();
|
|
return;
|
|
}
|
|
m_plwFilterGroup->clear();
|
|
QSqlQuery query("select id,name from filtergroup");
|
|
while (query.next())
|
|
{
|
|
QListWidgetItem *pItem = new QListWidgetItem(query.value(1).toString(),m_plwFilterGroup);
|
|
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
|
}
|
|
db.close();
|
|
}
|
|
|
|
void SAnaly1::InsertFilter(int _nType,QString _strJson,int _nGroup)
|
|
{
|
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
|
db.setHostName("bigbird.iptime.org");
|
|
db.setUserName("admin");
|
|
db.setPassword("admin123");
|
|
db.setDatabaseName("concepters");
|
|
if (db.open() == false)
|
|
{
|
|
qDebug() << db.lastError().text();
|
|
return;
|
|
}
|
|
|
|
QString sql = "insert into filter (type,data,filtergroup_id) value (";
|
|
sql += QString::number(_nType);
|
|
sql += ",'" + _strJson + "',";
|
|
sql += QString::number(_nGroup) + ")";
|
|
QSqlQuery query;
|
|
if (query.exec(sql.toUtf8()) == false)
|
|
{
|
|
qDebug() << sql;
|
|
qDebug() << query.lastError().text();
|
|
}
|
|
db.close();
|
|
}
|
|
|
|
void SAnaly1::InsertTimeFilter(int _nArticle ,QDate _dateStart ,QDate _dateEnd ,int _nGroup)
|
|
{
|
|
QString strJson;
|
|
SJson json;
|
|
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
|
strJson = json.Set(strJson,"Start",_dateStart.toString("yyyy-MM-dd"));
|
|
strJson = json.Set(strJson,"End",_dateEnd.toString("yyyy-MM-dd"));
|
|
InsertFilter(E_FILTER_TYPE_DATE,json.Sql(strJson),_nGroup);
|
|
}
|
|
|
|
void SAnaly1::InsertSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _nKeyword, QString _str,int _nGroup)
|
|
{
|
|
QString strJson;
|
|
SJson json;
|
|
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
|
strJson = json.Set(strJson,"Category",_nCategory);
|
|
strJson = json.Set(strJson,"Method",_nMethod);
|
|
strJson = json.Set(strJson,"Keyword",_nKeyword);
|
|
strJson = json.Set(strJson,"String",_str);
|
|
InsertFilter(E_FILTER_TYPE_SEARCH,json.Sql(strJson),_nGroup);
|
|
}
|
|
|
|
void SAnaly1::InsertLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup)
|
|
{
|
|
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);
|
|
InsertFilter(E_FILTER_TYPE_LENGTH,json.Sql(strJson),_nGroup);
|
|
}
|
|
|
|
void SAnaly1::InsertReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup)
|
|
{
|
|
QString strJson;
|
|
SJson json;
|
|
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
|
strJson = json.Set(strJson,"Category",_nCategory);
|
|
strJson = json.Set(strJson,"Find",_nFind);
|
|
strJson = json.Set(strJson,"String_Find",_strFind);
|
|
strJson = json.Set(strJson,"String_Replace",_strReplace);
|
|
InsertFilter(E_FILTER_TYPE_REPLACE,json.Sql(strJson),_nGroup);
|
|
}
|
|
|
|
void SAnaly1::RefreshFilter(int _nGroup)
|
|
{
|
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
|
db.setHostName("bigbird.iptime.org");
|
|
db.setUserName("admin");
|
|
db.setPassword("admin123");
|
|
db.setDatabaseName("concepters");
|
|
if (db.open() == false)
|
|
{
|
|
qDebug() << db.lastError().text();
|
|
return;
|
|
}
|
|
QSqlQuery query("select id,type,data from filter where filtergroup_id = " + QString::number(_nGroup));
|
|
|
|
SJson json;
|
|
m_plwFilter->clear();
|
|
while (query.next())
|
|
{
|
|
QString str;
|
|
QString strJson = query.value(2).toString();
|
|
str = STable::GetArticleType(json.Get(strJson,"Article").toInt());
|
|
switch(query.value(1).toInt())
|
|
{
|
|
case E_FILTER_TYPE_DATE:
|
|
str += "<Date> Start : ";
|
|
str += json.Get(strJson,"Start");
|
|
str += " End : ";
|
|
str += json.Get(strJson,"End");
|
|
break;
|
|
case E_FILTER_TYPE_SEARCH:
|
|
str += "<Search> ";
|
|
str += m_pcbCatalog->itemText(json.GetNumber(strJson,"Category")) + " , ";
|
|
str += m_pcbMethod->itemText(json.GetNumber(strJson,"Method")) + " , ";
|
|
str += m_pcbKeyword->itemText(json.GetNumber(strJson,"Keyword")) + " , ";
|
|
str += json.Get(strJson,"String");
|
|
break;
|
|
case E_FILTER_TYPE_LENGTH:
|
|
str += "<Length> ";
|
|
str += m_pcbLengthCatalog->itemText(json.GetNumber(strJson,"Category")) + " ";
|
|
str += m_pcbLengthComp->itemText(json.GetNumber(strJson,"Comp")) + " ";
|
|
str += json.Get(strJson,"String") + " , ";
|
|
str += m_pcbLengthInsDel->itemText(json.GetNumber(strJson,"InsDel"));
|
|
break;
|
|
case E_FILTER_TYPE_REPLACE:
|
|
str += "<Replace> ";
|
|
str += m_pcbReplaceCatalog->itemText(json.GetNumber(strJson,"Category")) + " , ";
|
|
str += m_pcbReplaceFind->itemText(json.GetNumber(strJson,"Find")) + " ";
|
|
str += json.Get(strJson,"String_Find") + " --> ";
|
|
str += json.Get(strJson,"String_Replace");
|
|
break;
|
|
}
|
|
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwFilter);
|
|
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
|
}
|
|
db.close();
|
|
}
|
|
|
|
void SAnaly1::currentGroupItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev)
|
|
{
|
|
Q_UNUSED(_pPrev);
|
|
if (_pCurrent == 0) return;
|
|
RefreshFilter(_pCurrent->data(Qt::UserRole).toInt());
|
|
m_pleFilterGroup->setText(_pCurrent->text());
|
|
m_pleFilterGroup->repaint();
|
|
}
|
|
|
|
void SAnaly1::FilterDelete()
|
|
{
|
|
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_plwFilter->selectedItems())
|
|
{
|
|
QString strQuery = QString("delete from filter where id = '" + item->data(Qt::UserRole).toString() + "'");
|
|
db.exec(strQuery.toUtf8());
|
|
}
|
|
db.close();
|
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
|
RefreshFilter(item->data(Qt::UserRole).toInt());
|
|
}
|
|
|
|
void SAnaly1::currentFilterItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev)
|
|
{
|
|
Q_UNUSED(_pPrev);
|
|
if (_pCurrent == 0) return;
|
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
|
db.setHostName("bigbird.iptime.org");
|
|
db.setUserName("admin");
|
|
db.setPassword("admin123");
|
|
db.setDatabaseName("concepters");
|
|
if (db.open() == false)
|
|
{
|
|
qDebug() << db.lastError().text();
|
|
return;
|
|
}
|
|
QSqlQuery query("select id,type,data from filter where id = " + _pCurrent->data(Qt::UserRole).toString());
|
|
if (!query.next()) return;
|
|
SJson json;
|
|
QString strJson = query.value(2).toString();
|
|
switch(query.value(1).toInt())
|
|
{
|
|
case E_FILTER_TYPE_DATE:
|
|
m_pdeStart->setDate(QDate::fromString(json.Get(strJson,"Start"),"yyyy-MM-dd"));
|
|
m_pdeEnd->setDate(QDate::fromString(json.Get(strJson,"End"),"yyyy-MM-dd"));
|
|
m_pleString->setText("");
|
|
m_pleLength->setText("");
|
|
m_pleReplaceFind->setText("");
|
|
m_pleReplace->setText("");
|
|
break;
|
|
case E_FILTER_TYPE_SEARCH:
|
|
m_pcbCatalog->setCurrentIndex(json.GetNumber(strJson,"Category"));
|
|
m_pcbMethod->setCurrentIndex(json.GetNumber(strJson,"Method"));
|
|
m_pcbKeyword->setCurrentIndex(json.GetNumber(strJson,"Keyword"));
|
|
m_pleString->setText(json.Get(strJson,"String"));
|
|
m_pleLength->setText("");
|
|
m_pleReplaceFind->setText("");
|
|
m_pleReplace->setText("");
|
|
|
|
break;
|
|
case E_FILTER_TYPE_LENGTH:
|
|
m_pcbLengthCatalog->setCurrentIndex(json.GetNumber(strJson,"Category"));
|
|
m_pcbLengthComp->setCurrentIndex(json.GetNumber(strJson,"Comp"));
|
|
m_pcbLengthInsDel->setCurrentIndex(json.GetNumber(strJson,"InsDel"));
|
|
m_pleLength->setText(json.Get(strJson,"String"));
|
|
m_pleReplaceFind->setText("");
|
|
m_pleReplace->setText("");
|
|
m_pleString->setText("");
|
|
break;
|
|
case E_FILTER_TYPE_REPLACE:
|
|
m_pcbReplaceCatalog->setCurrentIndex(json.GetNumber(strJson,"Category"));
|
|
m_pcbReplaceFind->setCurrentIndex(json.GetNumber(strJson,"Find"));
|
|
m_pleReplaceFind->setText(json.Get(strJson,"String_Find"));
|
|
m_pleReplace->setText(json.Get(strJson,"String_Replace"));
|
|
m_pleString->setText("");
|
|
m_pleLength->setText("");
|
|
break;
|
|
}
|
|
}
|
|
|
|
bool SAnaly1::ReloadColumn()
|
|
{
|
|
m_vecColumn.clear();
|
|
QFile file("column.txt");
|
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text) == false) return false;
|
|
{
|
|
while (!file.atEnd())
|
|
{
|
|
QString str = QString(file.readLine());
|
|
if (str.at(0) == QChar('#')) continue;
|
|
if (str.trimmed().isEmpty()) continue;
|
|
m_vecColumn.push_back(str.split(","));
|
|
}
|
|
}
|
|
if (m_vecColumn.size() <= 0) return false;
|
|
|
|
m_nColumn = -1;
|
|
foreach(QStringList strList,m_vecColumn)
|
|
{
|
|
if (strList.at(E_COLUMN_DATE).trimmed() == QString("o") )
|
|
break;
|
|
else
|
|
m_nColumn++;
|
|
}
|
|
m_nColumn++;
|
|
return true;
|
|
}
|
|
|
|
void SAnaly1::FileImport()
|
|
{
|
|
QString strFilename = QFileDialog::getOpenFileName(0,"Import file",QDir::currentPath(),
|
|
"csv files (*.csv);;All files (*.*)",new QString("Text files (*.csv)"));
|
|
|
|
QFile file(strFilename);
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
|
|
|
|
m_TotalResult.clear();
|
|
m_mapViewResult.clear();
|
|
|
|
//qDebug() << "clear is complete";
|
|
|
|
QTextStream in(&file);
|
|
|
|
while(!in.atEnd())
|
|
{
|
|
QString strLine = in.readLine();
|
|
strLine = strLine.replace("\"","");
|
|
//qDebug() << strLine;
|
|
QStringList strListLine = strLine.split(",");
|
|
|
|
if(strListLine.size() != 4)
|
|
continue;
|
|
|
|
//qDebug() << strListLine.at(4).trimmed().toInt();
|
|
|
|
QString strKey = strListLine.at(0).trimmed() + "~!@" + strListLine.at(1).trimmed() + "~!@" + strListLine.at(2).trimmed();
|
|
m_TotalResult.insert(strKey, strListLine.at(3).trimmed().toInt());
|
|
}
|
|
|
|
file.close();
|
|
|
|
for(QMap<QString, int>::iterator iterPos = m_TotalResult.begin(); iterPos != m_TotalResult.end(); iterPos++)
|
|
{
|
|
QString strkey = iterPos.key();
|
|
int count = iterPos.value();
|
|
QStringList strlistKey = strkey.split("~!@");
|
|
QString strDate = strlistKey.at(0);
|
|
QString strMorphere = strlistKey.at(1);
|
|
QString strKeyword = strlistKey.at(2);
|
|
|
|
if(m_mapViewResult.contains(strDate))
|
|
{
|
|
if(m_mapViewResult.value(strDate).contains(strMorphere))
|
|
{
|
|
m_mapViewResult[(strDate)][(strMorphere)].insertMulti(count, strKeyword);
|
|
}
|
|
else
|
|
{
|
|
QMap<int, QString> qLast;
|
|
qLast.insert(count, strKeyword);
|
|
m_mapViewResult[(strDate)].insert(strMorphere, qLast);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
QMap<int, QString> qLast;
|
|
qLast.insert(count , strKeyword);
|
|
QMap<QString, QMap<int, QString> > qMedium;
|
|
qMedium.insert(strMorphere, qLast);
|
|
m_mapViewResult.insert(strDate, qMedium);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void SAnaly1::FileExport()
|
|
{
|
|
QString strFilename = QFileDialog::getSaveFileName(0,"Exoprt file",QDir::currentPath(),
|
|
"csv files (*.csv);;All files (*.*)",new QString("Text files (*.csv)"));
|
|
if (strFilename.toLower().right(4) != QString(".csv"))
|
|
strFilename += ".csv";
|
|
QFile file(strFilename);
|
|
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
|
|
|
QTextStream out(&file);
|
|
|
|
|
|
for (int i = 0; i < m_ptwData->count(); i++)
|
|
{
|
|
m_ptwData->setTabEnabled(i, true);
|
|
QTabWidget* p_childWidget = (QTabWidget*)(m_ptwData->widget(i));
|
|
|
|
for (int j = 0; j < p_childWidget->count(); j++)
|
|
{
|
|
p_childWidget->setTabEnabled(j, true);
|
|
STable *stable = (STable *) (p_childWidget->widget(j));
|
|
for (int nCount = 0 ; nCount < stable->rowCount(); nCount++ )
|
|
{
|
|
|
|
QString str = stable->item(nCount,0)->text().trimmed() + "," + stable->item(nCount,1)->text().trimmed();
|
|
out << m_ptwData->tabText(i).trimmed() << "," << p_childWidget->tabText(j).trimmed() << ",";
|
|
out << str << endl;
|
|
}
|
|
}
|
|
}
|
|
|
|
file.close();
|
|
}
|
|
|
|
void SAnaly1::FileExit()
|
|
{
|
|
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 SAnaly1::CountSave()
|
|
{
|
|
QTableWidget *pCurrent = (QTableWidget *)m_ptwData->currentWidget();
|
|
int nCatalog = m_pcbCountCatalog->currentIndex();
|
|
QString strFilename = QFileDialog::getSaveFileName(0,"Count file",QDir::currentPath(),
|
|
"csv files (*.csv);;All files (*.*)",new QString("csv files (*.csv)"));
|
|
if (strFilename.toLower().right(4) != QString(".csv"))
|
|
strFilename += ".csv";
|
|
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
|
|
|
QVector <SCount> vecData;
|
|
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();
|
|
bool bInsert = true;
|
|
for (int i = 0; i < vecData.size(); i++)
|
|
{
|
|
if(vecData[i].m_str.compare(str) == 0)
|
|
{
|
|
vecData[i].m_nCount++;
|
|
bInsert = false;
|
|
break;
|
|
}
|
|
}
|
|
if (bInsert)
|
|
vecData.push_back(SCount(str));
|
|
m_pProgress->setValue(nCount);
|
|
m_pProgress->repaint();
|
|
}
|
|
QFile file(strFilename);
|
|
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
|
QTextStream out(&file);
|
|
out << pCurrent->horizontalHeaderItem(nCatalog)->text() << "," << vecData.size() << endl << endl;
|
|
foreach(SCount stCount,vecData)
|
|
{
|
|
QString str = stCount.m_str.replace(",",".");
|
|
str = str.replace("\n","");
|
|
out << "\"" << str << "\"" << "," << stCount.m_nCount << endl;
|
|
}
|
|
file.close();
|
|
}
|
|
|
|
|
|
int SAnaly1::getThread()
|
|
{
|
|
return m_pcbThread->currentText().toInt();
|
|
}
|
|
|
|
unsigned int SAnaly1::getDateStart()
|
|
{
|
|
return m_pdeStart->dateTime().toString("yyyy-MM-dd").replace("-","").trimmed().toInt();
|
|
}
|
|
|
|
unsigned int SAnaly1::getDateEnd()
|
|
{
|
|
return m_pdeEnd->dateTime().toString("yyyy-MM-dd").replace("-","").trimmed().toInt();
|
|
}
|
|
|
|
int SAnaly1::getPeriod()
|
|
{
|
|
return m_pcbPeriod->currentIndex();
|
|
}
|
|
|
|
QStringList SAnaly1::getMorphereList()
|
|
{
|
|
QStringList strList;
|
|
for(int i = 0; i < m_plwMorphereAdd->count();i++)
|
|
{
|
|
if(m_plwMorphereAdd->item(i)->isHidden())
|
|
continue;
|
|
else
|
|
{
|
|
strList << m_plwMorphereAdd->item(i)->data(Qt::UserRole).toString();
|
|
}
|
|
}
|
|
return strList;
|
|
}
|
|
|
|
bool SAnaly1::getDateAll()
|
|
{
|
|
if(m_pcbDate->currentIndex() == 0)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
QTabWidget* SAnaly1::getQTabWidget()
|
|
{
|
|
return m_ptwData;
|
|
}
|
|
|
|
|
|
void SAnaly1::MemClear()
|
|
{
|
|
for(int i=0;i<16;i++)
|
|
{
|
|
m_HashResult[i].clear();
|
|
}
|
|
|
|
m_TotalResult.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;
|
|
}
|