git-svn-id: svn://192.168.0.12/source@179 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
35
Analyzer/Analyzer.pro
Normal file
35
Analyzer/Analyzer.pro
Normal file
@@ -0,0 +1,35 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2015-07-20T15:56:47
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui sql webkitwidgets
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = Analyzer
|
||||
TEMPLATE = app
|
||||
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
sloaddlg.cpp \
|
||||
stable.cpp \
|
||||
sdatadlg.cpp \
|
||||
scountdlg.cpp \
|
||||
scolumn.cpp \
|
||||
sfilterobject.cpp \
|
||||
../Json/sjson.cpp \
|
||||
sfilterdlg.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
../Json/sjson.h \
|
||||
../common.h \
|
||||
sloaddlg.h \
|
||||
stable.h \
|
||||
sdatadlg.h \
|
||||
scountdlg.h \
|
||||
scolumn.h \
|
||||
sfilterobject.h \
|
||||
sfilterdlg.h
|
||||
38
Analyzer/main.cpp
Normal file
38
Analyzer/main.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "scolumn.h"
|
||||
|
||||
MainWindow *g_pMain;
|
||||
|
||||
MainWindow *GetMainWindow()
|
||||
{
|
||||
return g_pMain;
|
||||
}
|
||||
|
||||
SColumn g_column;
|
||||
SColumn GetColumn()
|
||||
{
|
||||
return g_column;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
if (g_column.reload())
|
||||
{
|
||||
MainWindow w;
|
||||
g_pMain = &w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox msg;
|
||||
msg.setText("Can not read column data...");
|
||||
msg.exec();
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
230
Analyzer/mainwindow.cpp
Normal file
230
Analyzer/mainwindow.cpp
Normal file
@@ -0,0 +1,230 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QTime>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
{
|
||||
if (initDb() == false)
|
||||
{
|
||||
QMessageBox msg;
|
||||
msg.setText("Can't open database...");
|
||||
msg.exec();
|
||||
return;
|
||||
}
|
||||
setMenu();
|
||||
setDialog();
|
||||
setCentralWidget(&m_progress);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
if (m_db.isOpen() == false) return;
|
||||
QFile file("size.sts");
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
return;
|
||||
int anData[(D_DIALOG_MAX+1)*4];
|
||||
for (int i = 0; i < D_DIALOG_MAX;i++)
|
||||
{
|
||||
anData[i*4+0] = m_pDialogs[i]->geometry().left();
|
||||
anData[i*4+1] = m_pDialogs[i]->geometry().top();
|
||||
anData[i*4+2] = m_pDialogs[i]->geometry().width();
|
||||
anData[i*4+3] = m_pDialogs[i]->geometry().height();
|
||||
}
|
||||
anData[D_DIALOG_MAX*4+0] = geometry().left();
|
||||
anData[D_DIALOG_MAX*4+1] = geometry().top();
|
||||
anData[D_DIALOG_MAX*4+2] = geometry().width();
|
||||
anData[D_DIALOG_MAX*4+3] = geometry().height();
|
||||
file.write((char*)&anData,sizeof(int)*(D_DIALOG_MAX+1)*4);
|
||||
file.close();
|
||||
m_db.close();
|
||||
}
|
||||
|
||||
bool MainWindow::initDb()
|
||||
{
|
||||
m_db = QSqlDatabase::addDatabase("QMYSQL");
|
||||
m_db.setHostName("bigbird.iptime.org");
|
||||
m_db.setUserName("admin");
|
||||
m_db.setPassword("admin123");
|
||||
m_db.setDatabaseName("concepters");
|
||||
|
||||
connect(&m_timerAlive, SIGNAL(timeout()), this, SLOT(Alive()));
|
||||
m_timerAlive.start(60*60000);
|
||||
return m_db.open();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setMenu()
|
||||
{
|
||||
{
|
||||
QMenu *pFile = menuBar()->addMenu("File");
|
||||
connect(pFile->addAction("New"), SIGNAL(triggered()), this, SLOT(FileNew()));
|
||||
connect(pFile->addAction("CSV Import"), SIGNAL(triggered()), this, SLOT(FileImport()));
|
||||
connect(pFile->addAction("CSV Export"), SIGNAL(triggered()), this, SLOT(FileExport()));
|
||||
pFile->addSeparator();
|
||||
connect(pFile->addAction("Exit"), SIGNAL(triggered()), this, SLOT(FileExit()));
|
||||
}
|
||||
{
|
||||
QMenu *pFile = menuBar()->addMenu("Window");
|
||||
connect(pFile->addAction("Load"), SIGNAL(triggered()), this, SLOT(WindowLoad()));
|
||||
connect(pFile->addAction("Data"), SIGNAL(triggered()), this, SLOT(WindowData()));
|
||||
connect(pFile->addAction("Filter Object"), SIGNAL(triggered()), this, SLOT(WindowFilterObject()));
|
||||
connect(pFile->addAction("Filter"), SIGNAL(triggered()), this, SLOT(WindowFilter()));
|
||||
connect(pFile->addAction("Count"), SIGNAL(triggered()), this, SLOT(WindowCount()));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setDialog()
|
||||
{
|
||||
m_pDataDlg = new SDataDlg;
|
||||
m_ploadDlg = new SLoadDlg;
|
||||
m_pCountDlg = new SCountDlg;
|
||||
m_pFilterObjectDlg = new SFilterObject;
|
||||
m_pFilterDlg = new SFilterDlg;
|
||||
m_pDialogs[0] = m_pDataDlg;
|
||||
m_pDialogs[1] = m_ploadDlg;
|
||||
m_pDialogs[2] = m_pCountDlg;
|
||||
m_pDialogs[3] = m_pFilterObjectDlg;
|
||||
m_pDialogs[4] = m_pFilterDlg;
|
||||
|
||||
QFile file("size.sts");
|
||||
if (file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
int anData[D_DIALOG_MAX*4] = {0,};
|
||||
file.read((char*)&anData[0],D_DIALOG_MAX*4*sizeof(int));
|
||||
for (int i = 0; i < D_DIALOG_MAX;i++)
|
||||
{
|
||||
if (anData[i*4+2] != 0)
|
||||
m_pDialogs[i]->setGeometry(anData[i*4+0],anData[i*4+1],anData[i*4+2],anData[i*4+3]);
|
||||
}
|
||||
file.seek(D_DIALOG_MAX*4*sizeof(int));
|
||||
if (file.read((char*)&anData[0],4*sizeof(int)) > 0 )
|
||||
setGeometry(anData[0],anData[1],anData[2],anData[3]);
|
||||
file.close();
|
||||
}
|
||||
for (int i = 0; i < D_DIALOG_MAX;i++)
|
||||
m_pDialogs[i]->show();
|
||||
}
|
||||
|
||||
void MainWindow::InsertLog(QString str)
|
||||
{
|
||||
/*
|
||||
QTime time = QTime::currentTime();
|
||||
QString strOut = time.toString("[hh:mm:ss] ") + str;
|
||||
m_pLog->addItem(strOut);
|
||||
if (m_pLog->count() > 1024)
|
||||
{
|
||||
m_pLog->removeItemWidget(m_pLog->item(0));
|
||||
QListWidgetItem* item = m_pLog->takeItem(0);
|
||||
delete item;
|
||||
}
|
||||
m_pLog->setCurrentRow( m_pLog->count() - 1 );
|
||||
m_pLog->repaint();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::FileNew()
|
||||
{
|
||||
bool ok;
|
||||
QString text = QInputDialog::getText(this,"New Row Count","Count :", QLineEdit::Normal,"0", &ok);
|
||||
if (ok)
|
||||
{
|
||||
STable *pTable = (STable *)m_pDataDlg->AddTable("<New>");
|
||||
QVector <QStringList> column = GetColumn().data();
|
||||
pTable->SetHeaderList(&column,SColumn::E_NAME);
|
||||
pTable->setRowCount(text.toInt());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::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;
|
||||
|
||||
QVector <QByteArray> vecByte;
|
||||
bool bQuit = true;
|
||||
while(bQuit)
|
||||
{
|
||||
QByteArray byte = file.readLine();
|
||||
if (byte.isEmpty()) { bQuit = false; continue; }
|
||||
vecByte.push_back(byte);
|
||||
}
|
||||
file.close();
|
||||
m_pDataDlg->Import(vecByte);
|
||||
}
|
||||
|
||||
void MainWindow::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";
|
||||
|
||||
m_pDataDlg->Export(strFilename);
|
||||
}
|
||||
|
||||
void MainWindow::FileExit()
|
||||
{
|
||||
for (int i = 0; i < D_DIALOG_MAX;i++)
|
||||
m_pDialogs[i]->close();
|
||||
m_graph.close();
|
||||
close();
|
||||
}
|
||||
|
||||
void MainWindow::WindowLoad()
|
||||
{
|
||||
if (m_ploadDlg->isHidden())
|
||||
m_ploadDlg->show();
|
||||
else
|
||||
m_ploadDlg->hide();
|
||||
}
|
||||
|
||||
void MainWindow::WindowFilterObject()
|
||||
{
|
||||
if(m_pFilterObjectDlg->isHidden())
|
||||
m_pFilterObjectDlg->show();
|
||||
else
|
||||
m_pFilterObjectDlg->hide();
|
||||
}
|
||||
|
||||
void MainWindow::WindowCount()
|
||||
{
|
||||
if (m_pCountDlg->isHidden())
|
||||
m_pCountDlg->show();
|
||||
else
|
||||
m_pCountDlg->hide();
|
||||
}
|
||||
|
||||
void MainWindow::WindowFilter()
|
||||
{
|
||||
if (m_pFilterDlg->isHidden())
|
||||
m_pFilterDlg->show();
|
||||
else
|
||||
m_pFilterDlg->hide();
|
||||
}
|
||||
|
||||
void MainWindow::WindowData()
|
||||
{
|
||||
if (m_pDataDlg->isHidden())
|
||||
m_pDataDlg->show();
|
||||
else
|
||||
m_pDataDlg->hide();
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent * event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
FileExit();
|
||||
}
|
||||
|
||||
void MainWindow::Alive()
|
||||
{
|
||||
QSqlQuery query;
|
||||
query.exec("SELECT 1");
|
||||
query.next();
|
||||
}
|
||||
67
Analyzer/mainwindow.h
Normal file
67
Analyzer/mainwindow.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMenuBar>
|
||||
#include <QDebug>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlError>
|
||||
#include <QWebView>
|
||||
#include <QProgressBar>
|
||||
#include <QSqlDatabase>
|
||||
#include <QTimer>
|
||||
|
||||
#include "sloaddlg.h"
|
||||
#include "sdatadlg.h"
|
||||
#include "scountdlg.h"
|
||||
#include "sfilterobject.h"
|
||||
#include "sfilterdlg.h"
|
||||
|
||||
#include "SColumn.h"
|
||||
|
||||
#define D_DIALOG_MAX 5
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
void InsertLog(QString str);
|
||||
bool initDb();
|
||||
private:
|
||||
void setMenu();
|
||||
bool ReloadColumn();
|
||||
void setDialog();
|
||||
private slots:
|
||||
void FileNew();
|
||||
void FileImport();
|
||||
void FileExport();
|
||||
void FileExit();
|
||||
void WindowLoad();
|
||||
void WindowData();
|
||||
void WindowFilter();
|
||||
void WindowCount();
|
||||
void WindowFilterObject();
|
||||
void Alive();
|
||||
public:
|
||||
SLoadDlg *m_ploadDlg;
|
||||
SDataDlg *m_pDataDlg;
|
||||
SCountDlg *m_pCountDlg;
|
||||
SFilterObject *m_pFilterObjectDlg;
|
||||
SFilterDlg *m_pFilterDlg;
|
||||
QWebView m_graph;
|
||||
QSqlDatabase m_db;
|
||||
QProgressBar m_progress;
|
||||
private:
|
||||
QDialog *m_pDialogs[D_DIALOG_MAX];
|
||||
QTimer m_timerAlive;
|
||||
protected:
|
||||
void closeEvent(QCloseEvent * event);
|
||||
};
|
||||
|
||||
MainWindow *GetMainWindow();
|
||||
SColumn GetColumn();
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
57
Analyzer/scolumn.cpp
Normal file
57
Analyzer/scolumn.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "scolumn.h"
|
||||
#include <QFile>
|
||||
|
||||
SColumn::SColumn() : m_bUse(false)
|
||||
{
|
||||
}
|
||||
|
||||
SColumn::~SColumn()
|
||||
{
|
||||
}
|
||||
|
||||
int SColumn::getColumnIndex(QString _str)
|
||||
{
|
||||
int nIndex = 0;
|
||||
foreach(QStringList strList,m_vecColumn)
|
||||
{
|
||||
if (strList.at(E_DATABASE).trimmed() == _str.trimmed())
|
||||
return nIndex;
|
||||
if (strList.at(E_NAME).trimmed() == _str.trimmed())
|
||||
return nIndex;
|
||||
nIndex++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
bool SColumn::reload()
|
||||
{
|
||||
m_bUse = false;
|
||||
m_vecColumn.clear();
|
||||
QFile file("column.txt");
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text) == false) return m_bUse;
|
||||
{
|
||||
while (!file.atEnd())
|
||||
{
|
||||
QString str = QString(file.readLine());
|
||||
if (str.at(0) == QChar('#')) continue;
|
||||
if (str.trimmed().isEmpty()) continue;
|
||||
m_vecColumn.push_back(str.split(","));
|
||||
}
|
||||
}
|
||||
if (m_vecColumn.size() <= 0) return m_bUse;
|
||||
|
||||
m_nDateColumn = -1;
|
||||
foreach(QStringList strList,m_vecColumn)
|
||||
{
|
||||
if (strList.at(E_DATE).trimmed() == QString("o"))
|
||||
break;
|
||||
else
|
||||
m_nDateColumn++;
|
||||
}
|
||||
m_nDateColumn++;
|
||||
m_bUse = true;
|
||||
return m_bUse;
|
||||
}
|
||||
|
||||
|
||||
32
Analyzer/scolumn.h
Normal file
32
Analyzer/scolumn.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef SCOLUMN_H
|
||||
#define SCOLUMN_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QStringList>
|
||||
|
||||
class SColumn
|
||||
{
|
||||
public:
|
||||
enum E_COLUMN
|
||||
{
|
||||
E_DATABASE=0,
|
||||
E_NAME,
|
||||
E_DATE,
|
||||
E_COUNT,
|
||||
};
|
||||
public:
|
||||
SColumn();
|
||||
~SColumn();
|
||||
bool reload();
|
||||
bool isUse(){return m_bUse;}
|
||||
bool isDateColumn(int _nColumn) {return (_nColumn == m_nDateColumn);}
|
||||
QVector <QStringList> data() { return m_vecColumn; }
|
||||
int getDateColumn() { return m_nDateColumn;}
|
||||
int getColumnIndex(QString _str);
|
||||
private:
|
||||
QVector <QStringList> m_vecColumn;
|
||||
bool m_bUse;
|
||||
int m_nDateColumn;
|
||||
};
|
||||
|
||||
#endif // SCOLUMN_H
|
||||
221
Analyzer/scountdlg.cpp
Normal file
221
Analyzer/scountdlg.cpp
Normal file
@@ -0,0 +1,221 @@
|
||||
#include "scountdlg.h"
|
||||
#include "mainwindow.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
#include <QFile>
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
|
||||
const int C_COMBO_MAX = 2;
|
||||
|
||||
SCountDlg::SCountDlg()
|
||||
{
|
||||
setWidgets();
|
||||
}
|
||||
|
||||
SCountDlg::~SCountDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void SCountDlg::setWidgets()
|
||||
{
|
||||
setWindowTitle("Count");
|
||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||
{
|
||||
QHBoxLayout *hlayout = new QHBoxLayout;
|
||||
|
||||
|
||||
m_pCombo = new QComboBox[C_COMBO_MAX];
|
||||
for (int i = 0; i < C_COMBO_MAX ; i++)
|
||||
hlayout->addWidget(&m_pCombo[i]);
|
||||
|
||||
QPushButton *ppbRun = new QPushButton("Run");
|
||||
connect(ppbRun, SIGNAL(released()),this, SLOT(run()));
|
||||
hlayout->addWidget(ppbRun);
|
||||
QPushButton *ppbGraph = new QPushButton("Graph");
|
||||
connect(ppbGraph, SIGNAL(released()),this, SLOT(graph()));
|
||||
hlayout->addWidget(ppbGraph);
|
||||
vlayout->addLayout(hlayout);
|
||||
}
|
||||
m_pTable = new STable;
|
||||
m_pTable->SetHeaderList(QStringList() << "Item" << "Count");
|
||||
vlayout->addWidget(m_pTable);
|
||||
|
||||
setLayout(vlayout);
|
||||
|
||||
for (int i = 0; i < C_COMBO_MAX ; i++)
|
||||
{
|
||||
m_pCombo[i].clear();
|
||||
foreach(QStringList strList,GetColumn().data())
|
||||
m_pCombo[i].addItem(strList.at(SColumn::E_NAME));
|
||||
}
|
||||
|
||||
QFile file(QApplication::applicationDirPath()+"/graph.html");
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return;
|
||||
//m_strGraph = file.readAll();
|
||||
|
||||
QTextStream batStream (&file);
|
||||
while(!batStream.atEnd())
|
||||
{
|
||||
m_strGraph += batStream.readLine();
|
||||
}
|
||||
QMessageBox msg;
|
||||
msg.setText(m_strGraph);
|
||||
msg.setModal(true);
|
||||
msg.exec();
|
||||
|
||||
m_strGraph = m_strGraph.replace("[!F*i!l*e!]",QApplication::applicationDirPath()+"/graph.tsv");
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
void SCountDlg::run()
|
||||
{
|
||||
QTableWidget *pCurrent = (QTableWidget *)GetMainWindow()->m_pDataDlg->GetCurrentWidget();
|
||||
int anCatalog[C_COMBO_MAX];
|
||||
|
||||
for (int i = 0; i < C_COMBO_MAX ; i++)
|
||||
anCatalog[i] = m_pCombo[i].currentIndex();
|
||||
|
||||
QMap <QString,QMap<QString,int> > mapCount;
|
||||
QSet <QString> setList;
|
||||
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount());
|
||||
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||
{
|
||||
QString astr[C_COMBO_MAX];
|
||||
bool bFlag=true;
|
||||
for (int i = 0; i < C_COMBO_MAX ; i++)
|
||||
{
|
||||
if (GetColumn().isDateColumn(anCatalog[i]))
|
||||
{
|
||||
QDateTime date;
|
||||
astr[i] = date.fromString(pCurrent->item(nCount,anCatalog[i])->text().trimmed(),"yyyy-MM-dd hh:mm:ss").date().toString("yyyy-MM-dd").trimmed();
|
||||
}
|
||||
else
|
||||
astr[i] = pCurrent->item(nCount,anCatalog[i])->text().trimmed();
|
||||
if (astr[i].isEmpty()) bFlag = false;
|
||||
}
|
||||
if (bFlag == false) continue;
|
||||
if (mapCount.contains(astr[0]) == false)
|
||||
{
|
||||
QMap <QString,int> mapSec;
|
||||
mapCount.insert(astr[0],mapSec);
|
||||
}
|
||||
if (mapCount[astr[0]].contains(astr[1]) == false)
|
||||
mapCount[astr[0]].insert(astr[1],0);
|
||||
if (setList.contains(astr[1]) == false)
|
||||
setList.insert(astr[1]);
|
||||
mapCount[astr[0]][astr[1]]++;
|
||||
GetMainWindow()->m_progress.setValue(nCount);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
m_pTable->clear();
|
||||
QStringList strList;
|
||||
strList.push_back(m_pCombo[0].currentText());
|
||||
for (QSet<QString>::iterator i = setList.begin(); i != setList.end(); ++i)
|
||||
strList.push_back(*i);
|
||||
m_pTable->SetHeaderList(strList);
|
||||
m_pTable->setRowCount(mapCount.size());
|
||||
int nCount = 0;
|
||||
m_dTotal = 0.0;
|
||||
for (QMap<QString,QMap<QString,int> >::iterator i = mapCount.begin(); i != mapCount.end(); ++i)
|
||||
{
|
||||
int nCol = 0;
|
||||
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(i.key()));
|
||||
for (QSet<QString>::iterator j = setList.begin(); j != setList.end(); ++j)
|
||||
{
|
||||
if (i->contains(*j))
|
||||
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(QString::number(i->value(*j))));
|
||||
else
|
||||
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(QString::number(0)));
|
||||
}
|
||||
nCount++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void SCountDlg::run()
|
||||
{
|
||||
QTableWidget *pCurrent = (QTableWidget *)GetMainWindow()->m_pDataDlg->GetCurrentWidget();
|
||||
if (pCurrent == NULL) return;
|
||||
QMap <QString,QMap<QString,int> > mapCount;
|
||||
QSet <QString> setList;
|
||||
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount());
|
||||
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||
{
|
||||
QString astr[2];
|
||||
astr[0] = QDateTime::fromString(pCurrent->item(nCount,GetColumn().getDateColumn())->text().trimmed(),"yyyy-MM-dd hh:mm:ss").date().toString("yyyy-MM-dd").trimmed();
|
||||
astr[1] = pCurrent->item(nCount,GetColumn().getColumnIndex("platform_name"))->text().trimmed() + "-";
|
||||
astr[1] += pCurrent->item(nCount,GetColumn().getColumnIndex("platform_form"))->text().trimmed() + "-";
|
||||
astr[1] += pCurrent->item(nCount,GetColumn().getColumnIndex("article_form"))->text().trimmed();
|
||||
if (mapCount.contains(astr[0]) == false)
|
||||
{
|
||||
QMap <QString,int> mapSec;
|
||||
mapCount.insert(astr[0],mapSec);
|
||||
}
|
||||
if (mapCount[astr[0]].contains(astr[1]) == false)
|
||||
mapCount[astr[0]].insert(astr[1],0);
|
||||
if (setList.contains(astr[1]) == false)
|
||||
setList.insert(astr[1]);
|
||||
mapCount[astr[0]][astr[1]]++;
|
||||
GetMainWindow()->m_progress.setValue(nCount);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
m_pTable->clear();
|
||||
QStringList strList;
|
||||
strList.push_back("date");
|
||||
//strList.push_back(m_pCombo[0].currentText());
|
||||
for (QSet<QString>::iterator i = setList.begin(); i != setList.end(); ++i)
|
||||
strList.push_back(*i);
|
||||
m_pTable->SetHeaderList(strList);
|
||||
m_pTable->setRowCount(mapCount.size());
|
||||
int nCount = 0;
|
||||
m_dTotal = 0.0;
|
||||
for (QMap<QString,QMap<QString,int> >::iterator i = mapCount.begin(); i != mapCount.end(); ++i)
|
||||
{
|
||||
int nCol = 0;
|
||||
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(i.key()));
|
||||
for (QSet<QString>::iterator j = setList.begin(); j != setList.end(); ++j)
|
||||
{
|
||||
if (i->contains(*j))
|
||||
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(QString::number(i->value(*j))));
|
||||
else
|
||||
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(QString::number(0)));
|
||||
}
|
||||
nCount++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void SCountDlg::graph()
|
||||
{
|
||||
QFile file(QApplication::applicationDirPath()+"/graph.tsv");
|
||||
if (!file.open(QIODevice::WriteOnly)) return;
|
||||
QTextStream out(&file);
|
||||
out << "date\t";
|
||||
for (int i = 1; i < m_pTable->columnCount();i++)
|
||||
out << m_pTable->horizontalHeaderItem(i)->text() << "\t";
|
||||
out << "\n";
|
||||
GetMainWindow()->m_progress.setRange(0,m_pTable->rowCount());
|
||||
for (int i = 0 ; i < m_pTable->rowCount() ; i++ )
|
||||
{
|
||||
for (int j = 0; j < m_pTable->columnCount();j++)
|
||||
{
|
||||
out << m_pTable->item(i,j)->text().trimmed().toUtf8() << "\t";
|
||||
}
|
||||
out << "\n";
|
||||
GetMainWindow()->m_progress.setValue(i);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
file.close();
|
||||
|
||||
GetMainWindow()->m_graph.setHtml(m_strGraph.toUtf8(),QUrl("file:///"));
|
||||
GetMainWindow()->m_graph.settings()->setObjectCacheCapacities(0,0,0);
|
||||
GetMainWindow()->m_graph.repaint();
|
||||
GetMainWindow()->m_graph.show();
|
||||
}
|
||||
26
Analyzer/scountdlg.h
Normal file
26
Analyzer/scountdlg.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef SCOUNTDLG_H
|
||||
#define SCOUNTDLG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTableWidget>
|
||||
#include <QComboBox>
|
||||
#include "stable.h"
|
||||
|
||||
class SCountDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SCountDlg();
|
||||
~SCountDlg();
|
||||
private slots:
|
||||
void run();
|
||||
void graph();
|
||||
private:
|
||||
QComboBox *m_pCombo;
|
||||
STable *m_pTable;
|
||||
QString m_strGraph;
|
||||
double m_dTotal;
|
||||
void setWidgets();
|
||||
};
|
||||
|
||||
#endif // SCOUNTDLG_H
|
||||
471
Analyzer/sdatadlg.cpp
Normal file
471
Analyzer/sdatadlg.cpp
Normal file
@@ -0,0 +1,471 @@
|
||||
#include "sdatadlg.h"
|
||||
#include "STable.h"
|
||||
#include "mainwindow.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QInputDialog>
|
||||
#include <QTextCodec>
|
||||
#include <QFile>
|
||||
|
||||
#define D_NOT_SELECT -1
|
||||
|
||||
SDataDlg::SDataDlg()
|
||||
{
|
||||
setWidgets();
|
||||
}
|
||||
|
||||
SDataDlg::~SDataDlg()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SDataDlg::setWidgets()
|
||||
{
|
||||
setWindowTitle("Data");
|
||||
m_ptab = new QTabWidget;
|
||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||
vlayout->addWidget(m_ptab);
|
||||
setLayout(vlayout);
|
||||
|
||||
m_ptab->setTabsClosable(true);
|
||||
connect(m_ptab,SIGNAL(tabCloseRequested(int)),this,SLOT(CloseTab(int)));
|
||||
connect(m_ptab,SIGNAL(tabBarDoubleClicked(int)),this,SLOT(DoubleClickTab(int)));
|
||||
}
|
||||
|
||||
QTableWidget *SDataDlg::AddTable(QString _str)
|
||||
{
|
||||
STable *pTable = new STable;
|
||||
m_ptab->addTab(pTable,_str);
|
||||
return (QTableWidget *)pTable;
|
||||
}
|
||||
|
||||
void SDataDlg::CloseTab(int index)
|
||||
{
|
||||
((STable*)(m_ptab->widget(index)))->clear();
|
||||
m_ptab->removeTab(index);
|
||||
}
|
||||
|
||||
void SDataDlg::DoubleClickTab(int index)
|
||||
{
|
||||
bool ok;
|
||||
if (index < 0) return;
|
||||
QString text = QInputDialog::getText(this,"Tab name change","Name : ", QLineEdit::Normal,m_ptab->tabText(index), &ok);
|
||||
if (ok)
|
||||
{
|
||||
m_ptab->setTabText(index,text);
|
||||
}
|
||||
}
|
||||
|
||||
void SDataDlg::DataReload(QString _strTableName,int _nSelect)
|
||||
{
|
||||
QString strSelect;
|
||||
strSelect = "select ";
|
||||
QVector <QStringList> column = GetColumn().data();
|
||||
foreach(QStringList strlist,column)
|
||||
strSelect += "CONVERT(" + strlist.at(SColumn::E_DATABASE) + " USING utf8),";
|
||||
strSelect = strSelect.left(strSelect.size()-1);
|
||||
strSelect += " from ";
|
||||
strSelect += _strTableName;
|
||||
|
||||
if (_nSelect == STable::E_ARTICLE_BODY)
|
||||
strSelect += " WHERE article_form = 'body'";
|
||||
if (_nSelect == STable::E_ARTICLE_REPLY)
|
||||
strSelect += " WHERE article_form = 'reply'";
|
||||
|
||||
QSqlQuery query(strSelect);
|
||||
STable *pTable = (STable *)m_ptab->currentWidget();
|
||||
if (pTable == NULL)
|
||||
pTable = (STable*)AddTable("<first>");
|
||||
pTable->setArticleSelect(_nSelect);
|
||||
pTable->clear();
|
||||
pTable->SetHeaderList(&column,SColumn::E_NAME);
|
||||
pTable->setRowCount(query.size());
|
||||
GetMainWindow()->m_progress.setRange(0,query.size());
|
||||
int nCount = 0;
|
||||
while (query.next())
|
||||
{
|
||||
for (int i = 0; i < pTable->columnCount() ; i++)
|
||||
{
|
||||
QString str = query.value(i).toString().replace("\n"," ");
|
||||
pTable->setItem(nCount,i,new QTableWidgetItem(" "+str.replace("\t"," ")+" "));
|
||||
}
|
||||
nCount++;
|
||||
GetMainWindow()->m_progress.setValue(nCount);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void SDataDlg::InsertCopyRow(int _nRow,QTableWidget *_pCurrent,QTableWidget *_pNew)
|
||||
{
|
||||
_pNew->setRowCount(_pNew->rowCount()+1);
|
||||
for (int nCount = 0;nCount < _pCurrent->columnCount() ;nCount++ )
|
||||
_pNew->setItem(_pNew->rowCount()-1,nCount,new QTableWidgetItem(*_pCurrent->item(_nRow,nCount)));
|
||||
}
|
||||
|
||||
void SDataDlg::SearchDate(QDate _dtStart,QDate _dtEnd)
|
||||
{
|
||||
STable *pCurrent = (STable *)m_ptab->currentWidget();
|
||||
if (pCurrent == NULL) return;
|
||||
STable *pNew = new STable;
|
||||
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
||||
QVector <QStringList> column = GetColumn().data();
|
||||
pNew->SetHeaderList(&column,SColumn::E_NAME);
|
||||
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||
|
||||
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||
{
|
||||
bool bFlag = false;
|
||||
QString strTime = pCurrent->item(nCount,GetColumn().getDateColumn())->text().trimmed();
|
||||
if (strTime.size() >= 10)
|
||||
{
|
||||
QChar ch = strTime.at(4);
|
||||
QString strFormat = QString("yyyy")+ch+QString("MM")+ch+QString("dd");
|
||||
QDate date = QDate::fromString(strTime.left(10),strFormat);
|
||||
if (_dtStart <= date && _dtEnd >= date)
|
||||
bFlag = true;
|
||||
}
|
||||
if (bFlag)
|
||||
InsertCopyRow(nCount,pCurrent,pNew);
|
||||
GetMainWindow()->m_progress.setValue(nCount);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
m_ptab->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
||||
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||
}
|
||||
|
||||
void SDataDlg::SearchCounter(int _nCatalogIndex,int _nCompIndex,int _nInsDelIndex,int _nCounter)
|
||||
{
|
||||
STable *pCurrent = (STable *)m_ptab->currentWidget();
|
||||
if (pCurrent == NULL) return;
|
||||
QMap<QString, int> mapData,mapDataResult;
|
||||
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||
|
||||
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||
{
|
||||
QString str;
|
||||
if (_nCatalogIndex == GetColumn().getDateColumn())
|
||||
str = QDateTime::fromString(pCurrent->item(nCount,_nCatalogIndex)->text().trimmed(),"yyyy-MM-dd hh:mm:ss").date().toString("yyyy-MM-dd");
|
||||
else
|
||||
str = pCurrent->item(nCount,_nCatalogIndex)->text().trimmed();
|
||||
|
||||
if (str.isEmpty() == false)
|
||||
{
|
||||
if(mapData.contains(str))
|
||||
mapData[str]++;
|
||||
else
|
||||
mapData.insert(str,1);
|
||||
}
|
||||
GetMainWindow()->m_progress.setValue(nCount);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
|
||||
for(QMap <QString, int>::iterator iterPos = mapData.begin(); iterPos != mapData.end(); iterPos++)
|
||||
{
|
||||
bool bFlag = false;
|
||||
switch(_nCompIndex)
|
||||
{
|
||||
case E_LENGTH_COMP_GREATER:
|
||||
if (iterPos.value() > _nCounter)
|
||||
bFlag = true;
|
||||
break;
|
||||
case E_LENGTH_COMP_LESS:
|
||||
if (iterPos.value() < _nCounter)
|
||||
bFlag = true;
|
||||
break;
|
||||
case E_LENGTH_COMP_EQUAL:
|
||||
if (iterPos.value() == _nCounter)
|
||||
bFlag = true;
|
||||
break;
|
||||
}
|
||||
if (bFlag)
|
||||
mapDataResult.insert(iterPos.key(), iterPos.value());
|
||||
}
|
||||
|
||||
{
|
||||
STable *pNew = new STable;
|
||||
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
||||
QVector <QStringList> column = GetColumn().data();
|
||||
pNew->SetHeaderList(&column,SColumn::E_NAME);
|
||||
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||
|
||||
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||
{
|
||||
bool bFlag = false;
|
||||
QString strCurrent = pCurrent->item(nCount,_nCatalogIndex)->text().trimmed();
|
||||
if(mapDataResult.contains(strCurrent))
|
||||
bFlag = true;
|
||||
if (_nInsDelIndex == 1) bFlag = !bFlag;
|
||||
if (bFlag) InsertCopyRow(nCount,pCurrent,pNew);
|
||||
GetMainWindow()->m_progress.setValue(nCount);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
m_ptab->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
||||
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||
}
|
||||
}
|
||||
|
||||
void SDataDlg::SearchLength(int _nCatalogIndex,int _nCompIndex,int _nInsDelIndex,int _nLength)
|
||||
{
|
||||
STable *pCurrent = (STable *)m_ptab->currentWidget();
|
||||
if (pCurrent == NULL) return;
|
||||
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||
STable *pNew = new STable;
|
||||
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
||||
QVector <QStringList> column = GetColumn().data();
|
||||
pNew->SetHeaderList(&column,SColumn::E_NAME);
|
||||
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||
|
||||
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||
{
|
||||
bool bFlag = false;
|
||||
int nCurrentLength = pCurrent->item(nCount,_nCatalogIndex)->text().trimmed().length();
|
||||
switch(_nCompIndex)
|
||||
{
|
||||
case E_LENGTH_COMP_GREATER:
|
||||
if (nCurrentLength > _nLength)
|
||||
bFlag = true;
|
||||
break;
|
||||
case E_LENGTH_COMP_LESS:
|
||||
if (nCurrentLength < _nLength)
|
||||
bFlag = true;
|
||||
break;
|
||||
case E_LENGTH_COMP_EQUAL:
|
||||
if (nCurrentLength == _nLength)
|
||||
bFlag = true;
|
||||
break;
|
||||
}
|
||||
if (_nInsDelIndex == 1) bFlag = !bFlag;
|
||||
if (bFlag) InsertCopyRow(nCount,pCurrent,pNew);
|
||||
GetMainWindow()->m_progress.setValue(nCount);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
m_ptab->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
||||
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||
}
|
||||
|
||||
void SDataDlg::SearchReplace(int _nCatalogIndex,int _nReplaceFindIndex,int _nReplaceIndex,QString _strFind,QString _strReplace)
|
||||
{
|
||||
STable *pCurrent = (STable *)m_ptab->currentWidget();
|
||||
if (pCurrent == NULL) return;
|
||||
STable *pNew = new STable;
|
||||
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
||||
QVector <QStringList> column = GetColumn().data();
|
||||
pNew->SetHeaderList(&column,SColumn::E_NAME);
|
||||
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||
//int nCatalog = m_pcbReplaceCatalog->currentIndex();
|
||||
QStringList strListKeyword;
|
||||
if (_nReplaceFindIndex == E_REPLACE_SPACE)
|
||||
strListKeyword = _strFind.split(" ");
|
||||
else
|
||||
strListKeyword.push_back(_strFind);
|
||||
|
||||
pNew->setRowCount(pCurrent->rowCount());
|
||||
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||
{
|
||||
for (int nColumnCount = 0;nColumnCount < pCurrent->columnCount() ;nColumnCount++ )
|
||||
{
|
||||
if (_nCatalogIndex == nColumnCount)
|
||||
{
|
||||
QString strOut = pCurrent->item(nCount,nColumnCount)->text();
|
||||
switch(_nReplaceIndex)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
foreach(QString str,strListKeyword)
|
||||
strOut = strOut.replace(str,_strReplace);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
QString strMiddle;
|
||||
foreach(QString strLine,strOut.split("\n"))
|
||||
{
|
||||
foreach(QString strWord,strLine.split(" "))
|
||||
{
|
||||
bool bFlag = false;
|
||||
foreach(QString str,strListKeyword)
|
||||
{
|
||||
if (strWord == str)
|
||||
{
|
||||
strMiddle += _strReplace + " ";
|
||||
bFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bFlag == false)
|
||||
strMiddle += strWord + " ";
|
||||
}
|
||||
strMiddle += "\n";
|
||||
}
|
||||
strOut = strMiddle;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
QString strMiddle;
|
||||
foreach(QString strLine,strOut.split("\n"))
|
||||
{
|
||||
foreach(QString strWord,strLine.split(" "))
|
||||
{
|
||||
bool bFlag = false;
|
||||
foreach(QString str,strListKeyword)
|
||||
{
|
||||
if (strWord.contains(str))
|
||||
{
|
||||
strMiddle += _strReplace + " ";
|
||||
bFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bFlag == false)
|
||||
strMiddle += strWord + " ";
|
||||
}
|
||||
strMiddle += "\n";
|
||||
}
|
||||
strOut = strMiddle;
|
||||
break;
|
||||
}
|
||||
pNew->setItem(nCount,nColumnCount,new QTableWidgetItem(strOut));
|
||||
}
|
||||
else
|
||||
pNew->setItem(nCount,nColumnCount,new QTableWidgetItem(*pCurrent->item(nCount,nColumnCount)));
|
||||
}
|
||||
GetMainWindow()->m_progress.setValue(nCount);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
//m_ptwData->addTab(pNew,m_ptwData->tabText(m_ptwData->currentIndex())+" r");
|
||||
m_ptab->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
||||
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||
}
|
||||
|
||||
int SDataDlg::GetCurrentArticle()
|
||||
{
|
||||
if (m_ptab->count() == 0) return E_ARTICLE_NONE;
|
||||
return ((STable *)m_ptab->currentWidget())->getArticleSelect();
|
||||
}
|
||||
|
||||
void SDataDlg::SearchKeyword(QVector <SKeyword> _vecKeyword)
|
||||
{
|
||||
STable *pCurrent = (STable *)m_ptab->currentWidget();
|
||||
if (pCurrent == NULL) return;
|
||||
STable *pNew = new STable;
|
||||
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
||||
QVector <QStringList> column = GetColumn().data();
|
||||
pNew->SetHeaderList(&column,SColumn::E_NAME);
|
||||
|
||||
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||
|
||||
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||
{
|
||||
bool bFlag = false;
|
||||
foreach(SKeyword stKeyword,_vecKeyword)
|
||||
{
|
||||
QString strData = pCurrent->item(nCount,stKeyword.m_nCatalog)->text();
|
||||
switch(stKeyword.m_nKeyword)
|
||||
{
|
||||
case E_SEARCH_KEYWORD_OR:
|
||||
{
|
||||
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||
if (strData.contains(strKey)){bFlag = true;break;}
|
||||
break;
|
||||
}
|
||||
case E_SEARCH_KEYWORD_AND:
|
||||
{
|
||||
int nKeyCount = 0;
|
||||
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||
if (strData.contains(strKey)) nKeyCount++;
|
||||
if (nKeyCount == stKeyword.m_strListKeyword.size())
|
||||
bFlag = true;
|
||||
break;
|
||||
}
|
||||
case E_SEARCH_KEYWORD_CELL_DELETE_OR:
|
||||
{
|
||||
bFlag = true;
|
||||
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||
if (strData.contains(strKey)){bFlag = false;break;}
|
||||
break;
|
||||
}
|
||||
case E_SEARCH_KEYWORD_CELL_DELETE_AND:
|
||||
{
|
||||
bFlag = true;
|
||||
int nCount = 0;
|
||||
foreach(QString strKey , stKeyword.m_strListKeyword)
|
||||
if (strData.contains(strKey)){nCount++;}
|
||||
if (nCount == stKeyword.m_strListKeyword.size())
|
||||
bFlag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bFlag) InsertCopyRow(nCount,pCurrent,pNew);
|
||||
GetMainWindow()->m_progress.setValue(nCount);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
m_ptab->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
||||
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||
}
|
||||
|
||||
void SDataDlg::Import(QVector <QByteArray> _vecImport )
|
||||
{
|
||||
STable *pNew = new STable;
|
||||
QTextCodec *codec = QTextCodec::codecForName("eucKR");
|
||||
GetMainWindow()->m_progress.setRange(0,_vecImport.size());
|
||||
int ncRow = 0;
|
||||
bool bFirst = true;
|
||||
pNew->setRowCount(_vecImport.size());
|
||||
foreach (QByteArray byte,_vecImport)
|
||||
{
|
||||
QString strLine = codec->toUnicode(byte);
|
||||
if (bFirst)
|
||||
{
|
||||
QStringList strings = strLine.split(",");
|
||||
if (strings.at(0) == QString("#Head#"))
|
||||
{
|
||||
pNew->setColumnCount(strings.size()-1);
|
||||
for (int i = 1; i < strings.size();i++)
|
||||
pNew->setHorizontalHeaderItem(i-1,new QTableWidgetItem(strings.at(i)));
|
||||
bFirst = false;
|
||||
pNew->setRowCount(_vecImport.size()-1);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
pNew->setColumnCount(strings.size());
|
||||
}
|
||||
bFirst = false;
|
||||
strLine = strLine.replace("\"","");
|
||||
QStringList strings = strLine.split(",");
|
||||
int ncCol=0;
|
||||
foreach(QString str,strings)
|
||||
pNew->setItem(ncRow,ncCol++,new QTableWidgetItem(QString(" " + str + " ")));
|
||||
GetMainWindow()->m_progress.setValue(ncRow++);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
m_ptab->addTab(pNew,"import");
|
||||
m_ptab->setCurrentIndex(m_ptab->count()-1);
|
||||
}
|
||||
|
||||
void SDataDlg::Export(QString _strFilename)
|
||||
{
|
||||
QFile file(_strFilename);
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
||||
QTextStream out(&file);
|
||||
QTableWidget *pCurrent = (QTableWidget *)m_ptab->currentWidget();
|
||||
out << "#Head#,";
|
||||
QVector <QStringList> column = GetColumn().data();
|
||||
foreach(QStringList strList,column)
|
||||
out << strList.at(SColumn::E_NAME) << ",";
|
||||
out << endl;
|
||||
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount()-1);
|
||||
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||
{
|
||||
for (int nColumnCount = 0;nColumnCount < pCurrent->columnCount() ;nColumnCount++ )
|
||||
{
|
||||
QString str = pCurrent->item(nCount,nColumnCount)->text();
|
||||
str = str.replace(",",".");
|
||||
str = str.replace("\n","");
|
||||
out << "\"" << str << "\"" << ",";
|
||||
}
|
||||
out << "\"\"" << endl;
|
||||
GetMainWindow()->m_progress.setValue(nCount);
|
||||
GetMainWindow()->m_progress.repaint();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
39
Analyzer/sdatadlg.h
Normal file
39
Analyzer/sdatadlg.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef SDATADLG_H
|
||||
#define SDATADLG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTabWidget>
|
||||
#include <QTableWidget>
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
class SDataDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SDataDlg();
|
||||
~SDataDlg();
|
||||
void setWidgets();
|
||||
QTableWidget *AddTable(QString _str);
|
||||
void DataReload(QString _strTableName,int _nSelect);
|
||||
QTableWidget *GetCurrentWidget() { return (QTableWidget *)m_ptab->currentWidget();}
|
||||
int GetCurrentArticle();
|
||||
void InsertCopyRow(int _nRow,QTableWidget *_pCurrent,QTableWidget *_pNew);
|
||||
|
||||
void SearchDate(QDate _dtStart,QDate _dtEnd);
|
||||
void SearchCounter(int _nCatalogIndex,int _nCompIndex,int _nInsDelIndex,int _nCounter);
|
||||
void SearchLength(int _nCatalogIndex,int _nCompIndex,int _nInsDelIndex,int _nLength);
|
||||
void SearchReplace(int _nCatalogIndex,int _nReplaceFindIndex,int _nReplaceIndex,QString _strFind,QString _strReplace);
|
||||
void SearchKeyword(QVector <SKeyword> _vecKeyword);
|
||||
|
||||
void Import(QVector <QByteArray> _vecImport);
|
||||
void Export(QString _strFilename);
|
||||
//void SearchCounter(int _nCatalogIndex,int _nCompIndex,int _nInsDelIndex,QString _strCounter);
|
||||
private:
|
||||
QTabWidget *m_ptab;
|
||||
private slots:
|
||||
void DoubleClickTab(int index);
|
||||
void CloseTab(int index);
|
||||
};
|
||||
|
||||
#endif // SDATADLG_H
|
||||
229
Analyzer/sfilterdlg.cpp
Normal file
229
Analyzer/sfilterdlg.cpp
Normal file
@@ -0,0 +1,229 @@
|
||||
#include "sfilterdlg.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QSqlQuery>
|
||||
|
||||
#include "./../common.h"
|
||||
|
||||
SFilterDlg::SFilterDlg()
|
||||
{
|
||||
setWindowTitle("Filter");
|
||||
setWidgets();
|
||||
}
|
||||
|
||||
SFilterDlg::~SFilterDlg()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SFilterDlg::setWidgets()
|
||||
{
|
||||
QHBoxLayout *hMainlayout = new QHBoxLayout();
|
||||
{
|
||||
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||
m_plwFilterGroup = new QListWidget;
|
||||
m_pleFilterGroup = new QLineEdit;
|
||||
vlayout->addWidget(m_plwFilterGroup);
|
||||
vlayout->addWidget(m_pleFilterGroup);
|
||||
connect(m_plwFilterGroup,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(GroupItemChanged(QListWidgetItem *, QListWidgetItem *)));
|
||||
{
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
QPushButton *pbInsert = new QPushButton("Insert");
|
||||
connect(pbInsert, SIGNAL(released()),this, SLOT(Group_Insert()));
|
||||
QPushButton *pbDelete = new QPushButton("Delete");
|
||||
connect(pbDelete, SIGNAL(released()),this, SLOT(Group_Delete()));
|
||||
QPushButton *pbModify = new QPushButton("Modfiy");
|
||||
connect(pbModify, SIGNAL(released()),this, SLOT(Group_Modify()));
|
||||
QPushButton *pbCopy_Paste = new QPushButton("Copy&Paste");
|
||||
connect(pbCopy_Paste, SIGNAL(released()),this, SLOT(Group_CopyPaste()));
|
||||
QPushButton *pbRefresh = new QPushButton("Refresh");
|
||||
connect(pbRefresh, SIGNAL(released()),this, SLOT(Group_Refresh()));
|
||||
|
||||
hlayout->addWidget(pbInsert);
|
||||
hlayout->addWidget(pbDelete);
|
||||
hlayout->addWidget(pbModify);
|
||||
hlayout->addWidget(pbCopy_Paste);
|
||||
hlayout->addWidget(pbRefresh);
|
||||
vlayout->addLayout(hlayout);
|
||||
}
|
||||
hMainlayout->addLayout(vlayout,1);
|
||||
}
|
||||
{
|
||||
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||
m_plwFilter = new QListWidget;
|
||||
vlayout->addWidget(m_plwFilter);
|
||||
connect(m_plwFilter,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(ItemChanged(QListWidgetItem*,QListWidgetItem*)));
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
QPushButton *pbUp = new QPushButton("Up");
|
||||
QPushButton *pbDown = new QPushButton("Down");
|
||||
QPushButton *pbDelete = new QPushButton("Delete");
|
||||
hlayout->addWidget(pbUp);
|
||||
hlayout->addWidget(pbDown);
|
||||
hlayout->addWidget(pbDelete);
|
||||
vlayout->addLayout(hlayout);
|
||||
connect(pbUp, SIGNAL(released()),this, SLOT(Up()));
|
||||
connect(pbDown, SIGNAL(released()),this, SLOT(Down()));
|
||||
connect(pbDelete, SIGNAL(released()),this, SLOT(Delete()));
|
||||
hMainlayout->addLayout(vlayout,3);
|
||||
}
|
||||
setLayout(hMainlayout);
|
||||
}
|
||||
|
||||
void SFilterDlg::Group_Insert()
|
||||
{
|
||||
QSqlQuery query;
|
||||
QString strQuery = QString("insert into filtergroup set "
|
||||
"name = '" + m_pleFilterGroup->text() + "'");
|
||||
query.exec(strQuery.toUtf8());
|
||||
Group_Refresh();
|
||||
}
|
||||
|
||||
void SFilterDlg::Group_Delete()
|
||||
{
|
||||
QSqlQuery query;
|
||||
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||
{
|
||||
QString strQuery = QString("delete from filtergroup where id = " + item->data(Qt::UserRole).toString());
|
||||
query.exec(strQuery.toUtf8());
|
||||
strQuery = QString("delete from filter where filtergroup_id = " + item->data(Qt::UserRole).toString());
|
||||
query.exec(strQuery.toUtf8());
|
||||
RefreshFilter(item->data(Qt::UserRole).toInt());
|
||||
}
|
||||
Group_Refresh();
|
||||
}
|
||||
|
||||
void SFilterDlg::Group_Modify()
|
||||
{
|
||||
QSqlQuery query;
|
||||
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||
{
|
||||
QString strQuery = QString("update filtergroup set name = '" + m_pleFilterGroup->text() + "' where id = " + item->data(Qt::UserRole).toString());
|
||||
query.exec(strQuery.toUtf8());
|
||||
}
|
||||
Group_Refresh();
|
||||
}
|
||||
|
||||
void SFilterDlg::Group_CopyPaste()
|
||||
{
|
||||
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||
{
|
||||
QSqlQuery query;
|
||||
QString strQuery = QString("insert into filtergroup set "
|
||||
"name = '" + item->text() + "-'");
|
||||
query.exec(strQuery.toUtf8());
|
||||
query.exec("select max(id) from filtergroup");
|
||||
if (query.next())
|
||||
{
|
||||
strQuery = QString("insert into filter (type,data,filtergroup_id) select type,data,");
|
||||
strQuery += query.value(0).toString();
|
||||
strQuery += " from filter where filtergroup_id = " + item->data(Qt::UserRole).toString();
|
||||
query.exec(strQuery.toUtf8());
|
||||
}
|
||||
}
|
||||
Group_Refresh();
|
||||
}
|
||||
|
||||
void SFilterDlg::Group_Refresh()
|
||||
{
|
||||
m_plwFilterGroup->clear();
|
||||
QSqlQuery query("select id,name from filtergroup");
|
||||
while (query.next())
|
||||
{
|
||||
QListWidgetItem *pItem = new QListWidgetItem(query.value(1).toString(),m_plwFilterGroup);
|
||||
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||
}
|
||||
}
|
||||
|
||||
void SFilterDlg::RefreshFilter(int _nGroup)
|
||||
{
|
||||
if (_nGroup == D_NOT_SELECT) return;
|
||||
QSqlQuery query("select id,type,data from filter where filtergroup_id = " + QString::number(_nGroup));
|
||||
m_plwFilter->clear();
|
||||
while (query.next())
|
||||
{
|
||||
QString str = GetMainWindow()->m_pFilterObjectDlg->JsonToString(query.value(1).toInt(),query.value(2).toString());
|
||||
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwFilter);
|
||||
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SFilterDlg::GroupItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev)
|
||||
{
|
||||
Q_UNUSED(_pPrev);
|
||||
if (_pCurrent == 0) return;
|
||||
RefreshFilter(_pCurrent->data(Qt::UserRole).toInt());
|
||||
m_pleFilterGroup->setText(_pCurrent->text());
|
||||
m_pleFilterGroup->repaint();
|
||||
}
|
||||
|
||||
void SFilterDlg::ItemChanged(QListWidgetItem*_pCurrent, QListWidgetItem *_pPrev)
|
||||
{
|
||||
Q_UNUSED(_pPrev);
|
||||
if (_pCurrent == 0) return;
|
||||
QSqlQuery query("select id,type,data from filter where id = " + _pCurrent->data(Qt::UserRole).toString());
|
||||
if (!query.next()) return;
|
||||
GetMainWindow()->m_pFilterObjectDlg->JsonToWidget(query.value(1).toInt(),query.value(2).toString());
|
||||
}
|
||||
|
||||
|
||||
void SFilterDlg::Up()
|
||||
{
|
||||
int nSelect = m_plwFilter->currentRow();
|
||||
if (nSelect <= 0) return;
|
||||
QString strID1 = m_plwFilter->item(nSelect)->data(Qt::UserRole).toString();
|
||||
QString strID2 = m_plwFilter->item(nSelect-1)->data(Qt::UserRole).toString();
|
||||
QString strQuery = "UPDATE filter t1 INNER JOIN filter t2 ON (t1.id, t2.id) IN ((" + strID1 + ","+ strID2 +"),("+ strID2 + "," + strID1 + ")) SET t1.type = t2.type,t1.filtergroup_id = t2.filtergroup_id,t1.data = t2.data";
|
||||
QSqlQuery query;
|
||||
query.exec(strQuery.toUtf8());
|
||||
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||
RefreshFilter(item->data(Qt::UserRole).toInt());
|
||||
m_plwFilter->setCurrentRow(nSelect-1);
|
||||
}
|
||||
|
||||
void SFilterDlg::Down()
|
||||
{
|
||||
int nSelect = m_plwFilter->currentRow();
|
||||
if (nSelect < 0) return;
|
||||
if (nSelect >= (m_plwFilter->count() - 1)) return;
|
||||
QString strID1 = m_plwFilter->item(nSelect)->data(Qt::UserRole).toString();
|
||||
QString strID2 = m_plwFilter->item(nSelect+1)->data(Qt::UserRole).toString();
|
||||
QString strQuery = "UPDATE filter t1 INNER JOIN filter t2 ON (t1.id, t2.id) IN ((" + strID1 + ","+ strID2 +"),("+ strID2 + "," + strID1 + ")) SET t1.type = t2.type,t1.filtergroup_id = t2.filtergroup_id,t1.data = t2.data";
|
||||
QSqlQuery query;
|
||||
query.exec(strQuery.toUtf8());
|
||||
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||
RefreshFilter(item->data(Qt::UserRole).toInt());
|
||||
m_plwFilter->setCurrentRow(nSelect+1);
|
||||
}
|
||||
|
||||
void SFilterDlg::Delete()
|
||||
{
|
||||
QSqlQuery query;
|
||||
foreach (QListWidgetItem *item,m_plwFilter->selectedItems())
|
||||
{
|
||||
QString strQuery = QString("delete from filter where id = '" + item->data(Qt::UserRole).toString() + "'");
|
||||
query.exec(strQuery.toUtf8());
|
||||
}
|
||||
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||
RefreshFilter(item->data(Qt::UserRole).toInt());
|
||||
}
|
||||
|
||||
int SFilterDlg::GetSelectGroupID()
|
||||
{
|
||||
int nCurrentFilterGroupID = D_NOT_SELECT;
|
||||
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
|
||||
return nCurrentFilterGroupID;
|
||||
}
|
||||
|
||||
int SFilterDlg::GetSelectFilterID()
|
||||
{
|
||||
int nCurrentFilterID = D_NOT_SELECT;
|
||||
foreach (QListWidgetItem *item,m_plwFilter->selectedItems())
|
||||
nCurrentFilterID = item->data(Qt::UserRole).toInt();
|
||||
return nCurrentFilterID;
|
||||
}
|
||||
|
||||
40
Analyzer/sfilterdlg.h
Normal file
40
Analyzer/sfilterdlg.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef SFILTERDLG_H
|
||||
#define SFILTERDLG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QListWidget>
|
||||
#include <QLineEdit>
|
||||
|
||||
|
||||
class SFilterDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SFilterDlg();
|
||||
~SFilterDlg();
|
||||
|
||||
int GetSelectGroupID();
|
||||
int GetSelectFilterID();
|
||||
void RefreshFilter(int _nGroup);
|
||||
private :
|
||||
void setWidgets();
|
||||
private :
|
||||
QListWidget *m_plwFilterGroup;
|
||||
QListWidget *m_plwFilter;
|
||||
QLineEdit *m_pleFilterGroup;
|
||||
private slots:
|
||||
void Group_Insert();
|
||||
void Group_Delete();
|
||||
void Group_Modify();
|
||||
void Group_CopyPaste();
|
||||
void Group_Refresh();
|
||||
|
||||
void GroupItemChanged(QListWidgetItem *, QListWidgetItem *);
|
||||
void ItemChanged(QListWidgetItem*,QListWidgetItem*);
|
||||
|
||||
void Up();
|
||||
void Down();
|
||||
void Delete();
|
||||
};
|
||||
|
||||
#endif // SFILTERDLG_H
|
||||
610
Analyzer/sfilterobject.cpp
Normal file
610
Analyzer/sfilterobject.cpp
Normal file
@@ -0,0 +1,610 @@
|
||||
#include "sfilterobject.h"
|
||||
#include "mainwindow.h"
|
||||
#include "../Json/sjson.h"
|
||||
#include "../common.h"
|
||||
|
||||
#include <QLayout>
|
||||
#include <QCalendarWidget>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QGroupBox>
|
||||
|
||||
SFilterObject::SFilterObject()
|
||||
{
|
||||
setWindowTitle("Object");
|
||||
setWidgets();
|
||||
}
|
||||
|
||||
SFilterObject::~SFilterObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SFilterObject::setWidgets()
|
||||
{
|
||||
m_tab.setParent(this);
|
||||
m_tab.addTab(setDateWidgets(),"Date");
|
||||
m_tab.addTab(setSearchWidgets(),"Search");
|
||||
m_tab.addTab(setLengthWidgets(),"Length");
|
||||
m_tab.addTab(setReplaceWidgets(),"Replace");
|
||||
m_tab.addTab(setCounterWidgets(),"Counter");
|
||||
}
|
||||
|
||||
QWidget *SFilterObject::setDateWidgets()
|
||||
{
|
||||
m_pdeStart = new QDateEdit(QDate::currentDate());
|
||||
m_pdeEnd = new QDateEdit(QDate::currentDate());
|
||||
|
||||
m_pdeStart->setDateRange(QDate(2003, 5, 20),QDate::currentDate());
|
||||
m_pdeEnd->setDateRange(QDate(2003, 5, 20),QDate::currentDate());
|
||||
|
||||
QCalendarWidget *pcw = new QCalendarWidget();
|
||||
m_pdeStart->setCalendarWidget(pcw);
|
||||
m_pdeStart->setCalendarPopup(true);
|
||||
|
||||
m_pdeEnd->setCalendarWidget(pcw);
|
||||
m_pdeEnd->setCalendarPopup(true);
|
||||
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
hlayout->addWidget(new QLabel("Start:"));
|
||||
hlayout->addWidget(m_pdeStart);
|
||||
hlayout->addWidget(new QLabel("End:"));
|
||||
hlayout->addWidget(m_pdeEnd);
|
||||
|
||||
{
|
||||
QPushButton *pbInsert = new QPushButton("Insert");
|
||||
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchDate()));
|
||||
QPushButton *pbModify = new QPushButton("Modify");
|
||||
connect(pbModify , SIGNAL(released()),this, SLOT(SearchDateUpdate()));
|
||||
|
||||
hlayout->addWidget(pbInsert);
|
||||
hlayout->addWidget(pbModify);
|
||||
}
|
||||
|
||||
hlayout->setAlignment(Qt::AlignLeft|Qt::AlignTop);
|
||||
QWidget *pWidget = new QWidget;
|
||||
pWidget->setLayout(hlayout);
|
||||
return pWidget;
|
||||
}
|
||||
|
||||
QWidget *SFilterObject::setSearchWidgets()
|
||||
{
|
||||
m_pcbCatalog = new QComboBox;
|
||||
m_pcbKeyword = new QComboBox;
|
||||
m_pcbMethod = new QComboBox;
|
||||
m_pleString = new QLineEdit;
|
||||
m_pchbLast = new QCheckBox;
|
||||
|
||||
m_pcbKeyword->addItem(QString("Or"));// or
|
||||
m_pcbKeyword->addItem(QString("And"));// and
|
||||
m_pcbKeyword->addItem(QString("Cell Delete Or"));
|
||||
m_pcbKeyword->addItem(QString("Cell Delete And"));
|
||||
//m_pcbKeyword->addItem(QString("Word Delete"));
|
||||
|
||||
m_pcbMethod->addItem(QString("Sentence"));
|
||||
m_pcbMethod->addItem(QString("Space"));
|
||||
|
||||
m_pchbLast->setText("Last");
|
||||
|
||||
foreach(QStringList strList,GetColumn().data())
|
||||
m_pcbCatalog->addItem(strList.at(SColumn::E_NAME));
|
||||
|
||||
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||
{
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
hlayout->addWidget(new QLabel("Item:"));
|
||||
hlayout->addWidget(m_pcbCatalog);
|
||||
hlayout->addWidget(new QLabel("Method:"));
|
||||
hlayout->addWidget(m_pcbMethod);
|
||||
hlayout->addWidget(new QLabel("keyword:"));
|
||||
hlayout->addWidget(m_pcbKeyword);
|
||||
hlayout->addWidget(m_pchbLast);
|
||||
vlayout->addLayout(hlayout);
|
||||
}
|
||||
|
||||
{
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
hlayout->addWidget(new QLabel("Search:"));
|
||||
hlayout->addWidget(m_pleString);
|
||||
vlayout->addLayout(hlayout);
|
||||
}
|
||||
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
hlayout->addLayout(vlayout);
|
||||
|
||||
{
|
||||
QVBoxLayout *vsublayout = new QVBoxLayout();
|
||||
QPushButton *pbInsert = new QPushButton("Insert");
|
||||
vsublayout->addWidget(pbInsert);
|
||||
connect(pbInsert, SIGNAL(released()),this, SLOT(SearchKeyword()));
|
||||
|
||||
QPushButton *pbModify = new QPushButton("Modify");
|
||||
connect(pbModify , SIGNAL(released()),this, SLOT(SearchKeywordUpdate()));
|
||||
vsublayout->addWidget(pbModify);
|
||||
hlayout->addLayout(vsublayout);
|
||||
}
|
||||
|
||||
QWidget *pWidget = new QWidget;
|
||||
pWidget->setLayout(hlayout);
|
||||
return pWidget;
|
||||
}
|
||||
|
||||
QWidget *SFilterObject::setLengthWidgets()
|
||||
{
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
m_pcbLengthCatalog = new QComboBox;
|
||||
m_pcbLengthComp = new QComboBox;
|
||||
m_pcbLengthInsDel = new QComboBox;
|
||||
m_pleLength = new QLineEdit;
|
||||
|
||||
foreach(QStringList strList,GetColumn().data())
|
||||
m_pcbLengthCatalog->addItem(strList.at(SColumn::E_NAME));
|
||||
|
||||
m_pcbLengthComp->addItem(">",QVariant(E_LENGTH_COMP_GREATER));
|
||||
m_pcbLengthComp->addItem("<",QVariant(E_LENGTH_COMP_LESS));
|
||||
m_pcbLengthComp->addItem("=",QVariant(E_LENGTH_COMP_EQUAL));
|
||||
|
||||
m_pcbLengthInsDel->addItem("Add",QVariant(0));
|
||||
m_pcbLengthInsDel->addItem("Del",QVariant(1));
|
||||
|
||||
hlayout->addWidget(new QLabel("Item:"));
|
||||
hlayout->addWidget(m_pcbLengthCatalog);
|
||||
hlayout->addWidget(m_pcbLengthComp);
|
||||
hlayout->addWidget(new QLabel("Length:"));
|
||||
hlayout->addWidget(m_pleLength);
|
||||
hlayout->addWidget(m_pcbLengthInsDel);
|
||||
{
|
||||
QVBoxLayout *vsublayout = new QVBoxLayout();
|
||||
QPushButton *pbInsert = new QPushButton("Insert");
|
||||
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchLength()));
|
||||
QPushButton *pbModify = new QPushButton("Modify");
|
||||
connect(pbModify , SIGNAL(released()),this, SLOT(SearchLengthUpdate()));
|
||||
vsublayout->addWidget(pbInsert);
|
||||
vsublayout->addWidget(pbModify);
|
||||
hlayout->addLayout(vsublayout);
|
||||
}
|
||||
QWidget *pWidget = new QWidget;
|
||||
pWidget->setLayout(hlayout);
|
||||
return pWidget;
|
||||
}
|
||||
|
||||
QWidget *SFilterObject::setCounterWidgets()
|
||||
{
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
m_pcbCounterCatalog = new QComboBox;
|
||||
m_pcbCounterComp = new QComboBox;
|
||||
m_pcbCounterInsDel = new QComboBox;
|
||||
m_pcbCounterCntApl = new QComboBox;
|
||||
m_pleCounter = new QLineEdit;
|
||||
|
||||
foreach(QStringList strList,GetColumn().data())
|
||||
m_pcbCounterCatalog->addItem(strList.at(SColumn::E_NAME));
|
||||
|
||||
m_pcbCounterComp->addItem(">",QVariant(E_LENGTH_COMP_GREATER));
|
||||
m_pcbCounterComp->addItem("<",QVariant(E_LENGTH_COMP_LESS));
|
||||
m_pcbCounterComp->addItem("=",QVariant(E_LENGTH_COMP_EQUAL));
|
||||
|
||||
m_pcbCounterInsDel->addItem("Add",QVariant(0));
|
||||
m_pcbCounterInsDel->addItem("Del",QVariant(1));
|
||||
|
||||
m_pcbCounterCntApl->addItem("Count",QVariant(0));
|
||||
m_pcbCounterCntApl->addItem("Apply",QVariant(1));
|
||||
|
||||
hlayout->addWidget(new QLabel("Item:"));
|
||||
hlayout->addWidget(m_pcbCounterCatalog);
|
||||
hlayout->addWidget(m_pcbCounterComp);
|
||||
//hlayout->addWidget(m_pcbCounterCntApl);
|
||||
hlayout->addWidget(new QLabel("Count:"));
|
||||
hlayout->addWidget(m_pleCounter);
|
||||
hlayout->addWidget(m_pcbCounterInsDel);
|
||||
{
|
||||
QVBoxLayout *vsublayout = new QVBoxLayout();
|
||||
QPushButton *pbInsert = new QPushButton("Insert");
|
||||
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchCounter()));
|
||||
QPushButton *pbModify = new QPushButton("Modify");
|
||||
connect(pbModify , SIGNAL(released()),this, SLOT(SearchCounterUpdate()));
|
||||
vsublayout->addWidget(pbInsert);
|
||||
vsublayout->addWidget(pbModify);
|
||||
hlayout->addLayout(vsublayout);
|
||||
}
|
||||
|
||||
QWidget *pWidget = new QWidget;
|
||||
pWidget->setLayout(hlayout);
|
||||
return pWidget;
|
||||
}
|
||||
|
||||
QWidget *SFilterObject::setReplaceWidgets()
|
||||
{
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
m_pcbReplaceCatalog = new QComboBox;
|
||||
m_pcbReplaceFind = new QComboBox;
|
||||
m_pcbReplace = new QComboBox;
|
||||
m_pleReplaceFind = new QLineEdit;
|
||||
m_pleReplace = new QLineEdit;
|
||||
|
||||
foreach(QStringList strList,GetColumn().data())
|
||||
m_pcbReplaceCatalog->addItem(strList.at(SColumn::E_NAME));
|
||||
|
||||
m_pcbReplaceFind->addItem("Sentence",QVariant(E_REPLACE_SENTENCE));
|
||||
m_pcbReplaceFind->addItem("Space",QVariant(E_REPLACE_SPACE));
|
||||
|
||||
m_pcbReplace->addItem("0",QVariant(0));
|
||||
m_pcbReplace->addItem("1",QVariant(1));
|
||||
m_pcbReplace->addItem("2",QVariant(2));
|
||||
|
||||
hlayout->addWidget(m_pcbReplaceCatalog);
|
||||
hlayout->addWidget(new QLabel("Find:"));
|
||||
hlayout->addWidget(m_pcbReplaceFind);
|
||||
hlayout->addWidget(m_pleReplaceFind);
|
||||
hlayout->addWidget(new QLabel("Replace:"));
|
||||
hlayout->addWidget(m_pcbReplace);
|
||||
hlayout->addWidget(m_pleReplace);
|
||||
{
|
||||
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||
QPushButton *pbInsert = new QPushButton("Insert");
|
||||
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchReplace()));
|
||||
vlayout->addWidget(pbInsert);
|
||||
QPushButton *pbModify = new QPushButton("Modify");
|
||||
connect(pbModify , SIGNAL(released()),this, SLOT(SearchReplaceUpdate()));
|
||||
vlayout->addWidget(pbModify);
|
||||
hlayout->addLayout(vlayout);
|
||||
}
|
||||
QWidget *pWidget = new QWidget;
|
||||
pWidget->setLayout(hlayout);
|
||||
return pWidget;
|
||||
}
|
||||
|
||||
QString SFilterObject::JsonToString(int _nSelect,QString _strJson)
|
||||
{
|
||||
SJson json;
|
||||
QString str = STable::GetArticleType(json.Get(_strJson,"Article").toInt());
|
||||
switch(_nSelect)
|
||||
{
|
||||
case E_FILTER_TYPE_DATE:
|
||||
str += "<Date> Start : ";
|
||||
str += json.Get(_strJson,"Start");
|
||||
str += " End : ";
|
||||
str += json.Get(_strJson,"End");
|
||||
break;
|
||||
case E_FILTER_TYPE_SEARCH:
|
||||
str += "<Search> ";
|
||||
str += m_pcbCatalog->itemText(json.GetNumber(_strJson,"Category")) + " , ";
|
||||
str += m_pcbMethod->itemText(json.GetNumber(_strJson,"Method")) + " , ";
|
||||
str += m_pcbKeyword->itemText(json.GetNumber(_strJson,"Keyword")) + " , ";
|
||||
str += (json.GetBool(_strJson,"Last")) ? "Last : o , " : "Last : x , ";
|
||||
str += json.Get(_strJson,"String");
|
||||
break;
|
||||
case E_FILTER_TYPE_LENGTH:
|
||||
str += "<Length> ";
|
||||
str += m_pcbLengthCatalog->itemText(json.GetNumber(_strJson,"Category")) + " ";
|
||||
str += m_pcbLengthComp->itemText(json.GetNumber(_strJson,"Comp")) + " ";
|
||||
str += json.Get(_strJson,"String") + " , ";
|
||||
str += m_pcbLengthInsDel->itemText(json.GetNumber(_strJson,"InsDel"));
|
||||
break;
|
||||
case E_FILTER_TYPE_REPLACE:
|
||||
str += "<Replace> ";
|
||||
str += m_pcbReplaceCatalog->itemText(json.GetNumber(_strJson,"Category")) + " , ";
|
||||
str += m_pcbReplaceFind->itemText(json.GetNumber(_strJson,"Find")) + " ";
|
||||
str += json.Get(_strJson,"String_Find") + " --> ";
|
||||
str += json.Get(_strJson,"String_Replace");
|
||||
break;
|
||||
case E_FILTER_TYPE_COUNTER:
|
||||
str += "<Counter> ";
|
||||
str += m_pcbCounterCatalog->itemText(json.GetNumber(_strJson,"Category")) + " ";
|
||||
str += m_pcbCounterComp->itemText(json.GetNumber(_strJson,"Comp")) + " ";
|
||||
str += json.Get(_strJson,"String") + " , ";
|
||||
str += m_pcbCounterInsDel->itemText(json.GetNumber(_strJson,"InsDel"));
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
void SFilterObject::JsonToWidget(int _nSelect,QString _strJson)
|
||||
{
|
||||
if (m_tab.isTabEnabled(_nSelect))
|
||||
m_tab.setCurrentIndex(_nSelect);
|
||||
SJson json;
|
||||
switch(_nSelect)
|
||||
{
|
||||
case E_FILTER_TYPE_DATE:
|
||||
m_pdeStart->setDate(QDate::fromString(json.Get(_strJson,"Start"),"yyyy-MM-dd"));
|
||||
m_pdeEnd->setDate(QDate::fromString(json.Get(_strJson,"End"),"yyyy-MM-dd"));
|
||||
break;
|
||||
case E_FILTER_TYPE_SEARCH:
|
||||
m_pcbCatalog->setCurrentIndex(json.GetNumber(_strJson,"Category"));
|
||||
m_pcbMethod->setCurrentIndex(json.GetNumber(_strJson,"Method"));
|
||||
m_pcbKeyword->setCurrentIndex(json.GetNumber(_strJson,"Keyword"));
|
||||
m_pleString->setText(json.Get(_strJson,"String"));
|
||||
m_pchbLast->setChecked(json.GetBool(_strJson,"Last"));
|
||||
break;
|
||||
case E_FILTER_TYPE_LENGTH:
|
||||
m_pcbLengthCatalog->setCurrentIndex(json.GetNumber(_strJson,"Category"));
|
||||
m_pcbLengthComp->setCurrentIndex(json.GetNumber(_strJson,"Comp"));
|
||||
m_pcbLengthInsDel->setCurrentIndex(json.GetNumber(_strJson,"InsDel"));
|
||||
m_pleLength->setText(json.Get(_strJson,"String"));
|
||||
break;
|
||||
case E_FILTER_TYPE_REPLACE:
|
||||
m_pcbReplaceCatalog->setCurrentIndex(json.GetNumber(_strJson,"Category"));
|
||||
m_pcbReplaceFind->setCurrentIndex(json.GetNumber(_strJson,"Find"));
|
||||
m_pleReplaceFind->setText(json.Get(_strJson,"String_Find"));
|
||||
m_pleReplace->setText(json.Get(_strJson,"String_Replace"));
|
||||
break;
|
||||
case E_FILTER_TYPE_COUNTER:
|
||||
m_pcbCounterCatalog->setCurrentIndex(json.GetNumber(_strJson,"Category"));
|
||||
m_pcbCounterComp->setCurrentIndex(json.GetNumber(_strJson,"Comp"));
|
||||
m_pcbCounterInsDel->setCurrentIndex(json.GetNumber(_strJson,"InsDel"));
|
||||
m_pleCounter->setText(json.Get(_strJson,"String"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SFilterObject::SearchDate()
|
||||
{
|
||||
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||
DataBaseTimeFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),m_pdeStart->date(),m_pdeEnd->date(),nSelect,E_DATABASE_COMMAND_INSERT);
|
||||
GetMainWindow()->m_pDataDlg->SearchDate(m_pdeStart->date(),m_pdeEnd->date());
|
||||
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||
}
|
||||
|
||||
void SFilterObject::SearchCounter()
|
||||
{
|
||||
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||
DataBaseCounterFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||
m_pcbCounterCatalog->currentIndex(),
|
||||
m_pcbCounterComp->currentIndex(),
|
||||
m_pcbCounterInsDel->currentIndex(),
|
||||
m_pleCounter->text(),
|
||||
nSelect, E_DATABASE_COMMAND_INSERT);
|
||||
GetMainWindow()->m_pDataDlg->SearchCounter(m_pcbCounterCatalog->currentIndex(),
|
||||
m_pcbCounterComp->currentIndex(),
|
||||
m_pcbCounterInsDel->currentIndex(),
|
||||
m_pleCounter->text().toInt());
|
||||
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||
}
|
||||
|
||||
void SFilterObject::SearchLength()
|
||||
{
|
||||
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||
DataBaseLengthFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||
m_pcbLengthCatalog->currentIndex(),
|
||||
m_pcbLengthComp->currentIndex(),
|
||||
m_pcbLengthInsDel->currentIndex(),m_pleLength->text(),
|
||||
nSelect,E_DATABASE_COMMAND_INSERT);
|
||||
GetMainWindow()->m_pDataDlg->SearchLength(m_pcbLengthCatalog->currentIndex(),
|
||||
m_pcbLengthComp->currentIndex(),
|
||||
m_pcbLengthInsDel->currentIndex(),
|
||||
m_pleLength->text().toInt());
|
||||
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||
}
|
||||
|
||||
void SFilterObject::SearchReplace()
|
||||
{
|
||||
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||
DataBaseReplaceFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||
m_pcbReplaceCatalog->currentIndex(),
|
||||
m_pcbReplaceFind->currentData().toInt(),
|
||||
m_pleReplaceFind->text(),
|
||||
m_pleReplace->text(),
|
||||
nSelect,E_DATABASE_COMMAND_INSERT);
|
||||
|
||||
GetMainWindow()->m_pDataDlg->SearchReplace(m_pcbReplaceCatalog->currentIndex(),
|
||||
m_pcbReplaceFind->currentIndex(),
|
||||
m_pcbReplace->currentIndex(),
|
||||
m_pleReplaceFind->text(),
|
||||
m_pleReplace->text());
|
||||
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||
}
|
||||
|
||||
void SFilterObject::SearchKeyword()
|
||||
{
|
||||
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||
{
|
||||
SKeyword stKeyword;
|
||||
stKeyword.m_nCatalog = m_pcbCatalog->currentIndex();
|
||||
stKeyword.m_nKeyword = m_pcbKeyword->currentIndex();
|
||||
QString strKey = m_pleString->text().replace("\r\n"," ");
|
||||
strKey = strKey.replace("\n"," ");
|
||||
strKey = strKey.replace("\t"," ");
|
||||
|
||||
QString strTemp;
|
||||
foreach(QString str, strKey.split(" "))
|
||||
{
|
||||
if (str.trimmed().isEmpty() == false)
|
||||
strTemp += str.trimmed() + " ";
|
||||
}
|
||||
strTemp = strTemp.trimmed();
|
||||
m_pleString->setText(strTemp);
|
||||
strKey = strTemp;
|
||||
|
||||
DataBaseSearchFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||
m_pcbCatalog->currentIndex(),
|
||||
m_pcbMethod->currentIndex(),
|
||||
m_pcbKeyword->currentIndex(),
|
||||
m_pchbLast->isChecked(),
|
||||
strKey,
|
||||
nSelect,E_DATABASE_COMMAND_INSERT);
|
||||
|
||||
stKeyword.m_strListKeyword = strKey.split(" ");
|
||||
if (m_pcbMethod->currentIndex() == E_SEARCH_METHOD_SPACE)
|
||||
{
|
||||
for (int i = 0 ; i < stKeyword.m_strListKeyword.size(); i++ )
|
||||
{
|
||||
stKeyword.m_strListKeyword[i] = " " + stKeyword.m_strListKeyword[i] + " ";
|
||||
}
|
||||
}
|
||||
m_vecKeyword.push_back(stKeyword);
|
||||
if (m_pchbLast->isChecked())
|
||||
{
|
||||
GetMainWindow()->m_pDataDlg->SearchKeyword(m_vecKeyword);
|
||||
m_vecKeyword.clear();
|
||||
unlockTabs();
|
||||
}
|
||||
else
|
||||
lockTabs(1);
|
||||
}
|
||||
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||
}
|
||||
|
||||
void SFilterObject::SearchDateUpdate()
|
||||
{
|
||||
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||
DataBaseTimeFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||
m_pdeStart->date(),m_pdeEnd->date(),
|
||||
nSelect,E_DATABASE_COMMAND_UPDATE,
|
||||
GetMainWindow()->m_pFilterDlg->GetSelectFilterID());
|
||||
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||
}
|
||||
|
||||
void SFilterObject::SearchCounterUpdate()
|
||||
{
|
||||
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||
DataBaseCounterFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||
m_pcbCounterCatalog->currentIndex(),
|
||||
m_pcbCounterComp->currentIndex(),
|
||||
m_pcbCounterInsDel->currentIndex(),
|
||||
m_pleCounter->text(),
|
||||
nSelect, E_DATABASE_COMMAND_UPDATE,
|
||||
GetMainWindow()->m_pFilterDlg->GetSelectFilterID());
|
||||
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||
}
|
||||
|
||||
void SFilterObject::SearchLengthUpdate()
|
||||
{
|
||||
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||
DataBaseLengthFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||
m_pcbLengthCatalog->currentIndex(),
|
||||
m_pcbLengthComp->currentIndex(),
|
||||
m_pcbLengthInsDel->currentIndex(),
|
||||
m_pleLength->text(),
|
||||
nSelect,E_DATABASE_COMMAND_UPDATE,
|
||||
GetMainWindow()->m_pFilterDlg->GetSelectFilterID());
|
||||
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||
}
|
||||
|
||||
void SFilterObject::SearchReplaceUpdate()
|
||||
{
|
||||
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||
DataBaseReplaceFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||
m_pcbReplaceCatalog->currentIndex(),
|
||||
m_pcbReplaceFind->currentData().toInt(),
|
||||
m_pleReplaceFind->text(),
|
||||
m_pleReplace->text(),
|
||||
nSelect,E_DATABASE_COMMAND_UPDATE,
|
||||
GetMainWindow()->m_pFilterDlg->GetSelectFilterID());
|
||||
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||
|
||||
}
|
||||
|
||||
void SFilterObject::SearchKeywordUpdate()
|
||||
{
|
||||
int nSelect = GetMainWindow()->m_pFilterDlg->GetSelectGroupID();
|
||||
QString strKey = m_pleString->text().replace("\r\n"," ").replace("\n"," ").replace("\t"," ");
|
||||
DataBaseSearchFilter(GetMainWindow()->m_pDataDlg->GetCurrentArticle(),
|
||||
m_pcbCatalog->currentIndex(),
|
||||
m_pcbMethod->currentIndex(),
|
||||
m_pcbKeyword->currentIndex(),
|
||||
m_pchbLast->isChecked(),strKey,
|
||||
nSelect,E_DATABASE_COMMAND_UPDATE,GetMainWindow()->m_pFilterDlg->GetSelectFilterID());
|
||||
GetMainWindow()->m_pFilterDlg->RefreshFilter(nSelect);
|
||||
}
|
||||
|
||||
void SFilterObject::lockTabs(int _nExcept)
|
||||
{
|
||||
for (int i=0; i<m_tab.count(); i++)
|
||||
{
|
||||
if (i!=_nExcept)
|
||||
m_tab.setTabEnabled(i, false);
|
||||
}
|
||||
}
|
||||
|
||||
void SFilterObject::unlockTabs()
|
||||
{
|
||||
for (int i=0; i<m_tab.count(); i++)
|
||||
m_tab.setTabEnabled(i, true);
|
||||
}
|
||||
|
||||
void SFilterObject::DataBaseFilter(int _nType,QString _strJson,int _nGroup,int _nCommand,int _nFilterID)
|
||||
{
|
||||
QString sql;
|
||||
if (_nGroup == D_NOT_SELECT) return;
|
||||
switch(_nCommand)
|
||||
{
|
||||
case E_DATABASE_COMMAND_INSERT:
|
||||
sql = "INSERT INTO filter SET ";
|
||||
sql += QString("type=") + QString::number(_nType) + ",";
|
||||
break;
|
||||
case E_DATABASE_COMMAND_UPDATE:
|
||||
sql = "UPDATE filter SET ";
|
||||
break;
|
||||
}
|
||||
sql += QString("data='") + _strJson + "',";
|
||||
sql += QString("type=") + QString::number(_nType) + ",";
|
||||
sql += QString("filtergroup_id=" ) + QString::number(_nGroup);
|
||||
if (_nCommand == E_DATABASE_COMMAND_UPDATE)
|
||||
{
|
||||
if (_nFilterID == D_NOT_SELECT) return;
|
||||
sql += QString(" where id=") + QString::number(_nFilterID);
|
||||
}
|
||||
QSqlQuery query;
|
||||
query.exec(sql.toUtf8());
|
||||
}
|
||||
|
||||
void SFilterObject::DataBaseTimeFilter(int _nArticle ,QDate _dateStart ,QDate _dateEnd ,int _nGroup,int _nCommand,int _nFilterID )
|
||||
{
|
||||
QString strJson;
|
||||
SJson json;
|
||||
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
||||
strJson = json.Set(strJson,"Start",_dateStart.toString("yyyy-MM-dd"));
|
||||
strJson = json.Set(strJson,"End",_dateEnd.toString("yyyy-MM-dd"));
|
||||
DataBaseFilter(E_FILTER_TYPE_DATE,json.Sql(strJson),_nGroup,_nCommand,_nFilterID);
|
||||
}
|
||||
|
||||
void SFilterObject::DataBaseSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _nKeyword ,bool _bLast, QString _str,int _nGroup,int _nCommand,int _nFilterID)
|
||||
{
|
||||
QString strJson;
|
||||
SJson json;
|
||||
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
||||
strJson = json.Set(strJson,"Category",_nCategory);
|
||||
strJson = json.Set(strJson,"Method",_nMethod);
|
||||
strJson = json.Set(strJson,"Keyword",_nKeyword);
|
||||
strJson = json.Set(strJson,"Last",_bLast);
|
||||
strJson = json.Set(strJson,"String",_str);
|
||||
DataBaseFilter(E_FILTER_TYPE_SEARCH,json.Sql(strJson),_nGroup,_nCommand,_nFilterID);
|
||||
}
|
||||
|
||||
void SFilterObject::DataBaseLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,int _nFilterID)
|
||||
{
|
||||
QString strJson;
|
||||
SJson json;
|
||||
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
||||
strJson = json.Set(strJson,"Category",_nCategory);
|
||||
strJson = json.Set(strJson,"Comp",_nComp);
|
||||
strJson = json.Set(strJson,"InsDel",_nInsDel);
|
||||
strJson = json.Set(strJson,"String",_str);
|
||||
DataBaseFilter(E_FILTER_TYPE_LENGTH,json.Sql(strJson),_nGroup,_nCommand,_nFilterID);
|
||||
}
|
||||
|
||||
|
||||
void SFilterObject::DataBaseCounterFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,int _nFilterID)
|
||||
{
|
||||
QString strJson;
|
||||
SJson json;
|
||||
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
||||
strJson = json.Set(strJson,"Category",_nCategory);
|
||||
strJson = json.Set(strJson,"Comp",_nComp);
|
||||
strJson = json.Set(strJson,"InsDel",_nInsDel);
|
||||
strJson = json.Set(strJson,"String",_str);
|
||||
DataBaseFilter(E_FILTER_TYPE_COUNTER,json.Sql(strJson),_nGroup,_nCommand,_nFilterID);
|
||||
}
|
||||
|
||||
void SFilterObject::DataBaseReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup,int _nCommand,int _nFilterID)
|
||||
{
|
||||
QString strJson;
|
||||
SJson json;
|
||||
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
||||
strJson = json.Set(strJson,"Category",_nCategory);
|
||||
strJson = json.Set(strJson,"Find",_nFind);
|
||||
strJson = json.Set(strJson,"String_Find",_strFind);
|
||||
strJson = json.Set(strJson,"String_Replace",_strReplace);
|
||||
DataBaseFilter(E_FILTER_TYPE_REPLACE,json.Sql(strJson),_nGroup,_nCommand,_nFilterID);
|
||||
}
|
||||
86
Analyzer/sfilterobject.h
Normal file
86
Analyzer/sfilterobject.h
Normal file
@@ -0,0 +1,86 @@
|
||||
#ifndef SFILTEROBJECT_H
|
||||
#define SFILTEROBJECT_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTabWidget>
|
||||
#include <QDateEdit>
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
|
||||
#include "./../common.h"
|
||||
|
||||
class SFilterObject : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SFilterObject();
|
||||
~SFilterObject();
|
||||
void setWidgets();
|
||||
QWidget *setDateWidgets();
|
||||
QWidget *setSearchWidgets();
|
||||
QWidget *setReplaceWidgets();
|
||||
QWidget *setLengthWidgets();
|
||||
QWidget *setCounterWidgets();
|
||||
|
||||
void lockTabs(int _nExcept);
|
||||
void unlockTabs();
|
||||
|
||||
void JsonToWidget(int _nSelect,QString _strJson);
|
||||
QString JsonToString(int _nSelect,QString _strJson);
|
||||
|
||||
void DataBaseFilter(int _nType,QString _strJson,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||
void DataBaseTimeFilter(int _nArticle ,QDate _dateStart ,QDate _dateEnd ,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||
void DataBaseSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _nKeyword ,bool _nLast , QString _str,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||
void DataBaseLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||
void DataBaseCounterFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||
void DataBaseReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
|
||||
private:
|
||||
enum E_DATABASE_COMMAND
|
||||
{
|
||||
E_DATABASE_COMMAND_INSERT = 0,
|
||||
E_DATABASE_COMMAND_UPDATE,
|
||||
};
|
||||
QTabWidget m_tab;
|
||||
|
||||
QDateEdit *m_pdeStart;
|
||||
QDateEdit *m_pdeEnd;
|
||||
|
||||
QComboBox *m_pcbCatalog;
|
||||
QComboBox *m_pcbKeyword;
|
||||
QComboBox *m_pcbMethod;
|
||||
QCheckBox *m_pchbLast;
|
||||
QLineEdit *m_pleString;
|
||||
|
||||
QComboBox *m_pcbLengthCatalog;
|
||||
QComboBox *m_pcbLengthComp;
|
||||
QComboBox *m_pcbLengthInsDel;
|
||||
QLineEdit *m_pleLength;
|
||||
|
||||
QComboBox *m_pcbCounterCatalog;
|
||||
QComboBox *m_pcbCounterComp;
|
||||
QComboBox *m_pcbCounterInsDel;
|
||||
QComboBox *m_pcbCounterCntApl;
|
||||
QLineEdit *m_pleCounter;
|
||||
|
||||
QComboBox *m_pcbReplaceCatalog;
|
||||
QComboBox *m_pcbReplaceFind;
|
||||
QComboBox *m_pcbReplace;
|
||||
QLineEdit *m_pleReplaceFind;
|
||||
QLineEdit *m_pleReplace;
|
||||
|
||||
QVector <SKeyword> m_vecKeyword;
|
||||
private slots:
|
||||
void SearchDate();
|
||||
void SearchDateUpdate();
|
||||
void SearchCounter();
|
||||
void SearchCounterUpdate();
|
||||
void SearchLength();
|
||||
void SearchLengthUpdate();
|
||||
void SearchReplace();
|
||||
void SearchReplaceUpdate();
|
||||
void SearchKeyword();
|
||||
void SearchKeywordUpdate();
|
||||
};
|
||||
|
||||
#endif // SFILTEROBJECT_H
|
||||
64
Analyzer/sloaddlg.cpp
Normal file
64
Analyzer/sloaddlg.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "sloaddlg.h"
|
||||
#include <QMessageBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "stable.h"
|
||||
|
||||
|
||||
SLoadDlg::SLoadDlg()
|
||||
{
|
||||
setWidgets();
|
||||
}
|
||||
|
||||
SLoadDlg::~SLoadDlg()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SLoadDlg::setWidgets()
|
||||
{
|
||||
setWindowTitle("Load");
|
||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||
m_plwData = new QListWidget;
|
||||
vlayout->addWidget(m_plwData);
|
||||
m_plwData->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
QPushButton *ppbRefresh = new QPushButton("Refresh");
|
||||
vlayout->addWidget(ppbRefresh);
|
||||
connect(ppbRefresh, SIGNAL(released()),this, SLOT(Refresh()));
|
||||
setLayout(vlayout);
|
||||
connect(m_plwData,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(ItemChanged(QListWidgetItem*)));
|
||||
}
|
||||
|
||||
void SLoadDlg::Refresh()
|
||||
{
|
||||
m_plwData->clear();
|
||||
QSqlQuery query("select id,name,count from datagroup");
|
||||
while (query.next())
|
||||
{
|
||||
QString str = query.value(1).toString();
|
||||
str += " ( ";
|
||||
str += query.value(0).toString();
|
||||
str += " , ";
|
||||
str += query.value(2).toString();
|
||||
str += " )";
|
||||
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwData);
|
||||
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||
}
|
||||
GetMainWindow()->InsertLog("Start");
|
||||
}
|
||||
|
||||
void SLoadDlg::ItemChanged( QListWidgetItem *item)
|
||||
{
|
||||
QMessageBox msg;
|
||||
msg.setText("Please choose...");
|
||||
msg.setModal(true);
|
||||
QPushButton *pbAll = msg.addButton("All",QMessageBox::ActionRole);
|
||||
QPushButton *pbBody = msg.addButton("Body",QMessageBox::ActionRole);
|
||||
QPushButton *pbReply = msg.addButton("Reply",QMessageBox::ActionRole);
|
||||
msg.exec();
|
||||
if (msg.clickedButton() == pbAll) GetMainWindow()->m_pDataDlg->DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_ALL);
|
||||
else if (msg.clickedButton() == pbBody) GetMainWindow()->m_pDataDlg->DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_BODY);
|
||||
else if (msg.clickedButton() == pbReply) GetMainWindow()->m_pDataDlg->DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_REPLY);
|
||||
}
|
||||
22
Analyzer/sloaddlg.h
Normal file
22
Analyzer/sloaddlg.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef SLOADDLG_H
|
||||
#define SLOADDLG_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
#include <QListWidget>
|
||||
|
||||
class SLoadDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SLoadDlg();
|
||||
~SLoadDlg();
|
||||
private:
|
||||
void setWidgets();
|
||||
QListWidget *m_plwData;
|
||||
private slots:
|
||||
void Refresh();
|
||||
void ItemChanged( QListWidgetItem *item);
|
||||
};
|
||||
|
||||
#endif // SLOADDLG_H
|
||||
Reference in New Issue
Block a user