git-svn-id: svn://192.168.0.12/source@24 8346c931-da38-4b9b-9d4c-e48b93cbd075

This commit is contained in:
admin
2015-02-23 08:34:56 +00:00
parent 8f0a9e3998
commit 98de8471ea
4 changed files with 236 additions and 137 deletions

View File

@@ -11,7 +11,7 @@
#include <QSqlError>
#include <QMenuBar>
#include <QInputDialog>
#include "../Json/sjson.h"
/*
QSqlDatabase dbWeb = QSqlDatabase::addDatabase("QMYSQL");
dbWeb.setHostName("db.big-bird.co.kr");
@@ -160,7 +160,6 @@ QGroupBox *Widget::setDateWidgets()
m_pdeEnd->setCalendarWidget(m_pcw);
m_pdeEnd->setCalendarPopup(true);
m_ppbInsertCalc = new QPushButton("Insert");
QHBoxLayout *hlayout = new QHBoxLayout();
//hlayout->addWidget(new QLabel("Catalog:"));
//hlayout->addWidget(m_pcbDateCatalog);
@@ -168,13 +167,19 @@ QGroupBox *Widget::setDateWidgets()
hlayout->addWidget(m_pdeStart);
hlayout->addWidget(new QLabel("End:"));
hlayout->addWidget(m_pdeEnd);
hlayout->addWidget(m_ppbInsertCalc);
{
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);
groupBox->setLayout(hlayout);
//m_pcbDateCatalog->addItems(QStringList() << "body + reply" << "body" << "reply");
connect(m_ppbInsertCalc, SIGNAL(released()),this, SLOT(SearchDate()));
return groupBox;
}
@@ -201,16 +206,17 @@ QGroupBox *Widget::setCountWidgets()
QGroupBox *Widget::setSearchWidgets()
{
m_pcbCatalog = new QComboBox;
m_pcbKeyword = 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 = new QComboBox;
m_pcbMethod->addItem(QString("Sentence"));
m_pcbMethod->addItem(QString("Space"));
m_pleString = new QLineEdit;
m_ppbInsertSearch = new QPushButton("Insert");
m_pcbMethod->addItem(QString("Space"));
foreach(QStringList strList,m_vecColumn)
m_pcbCatalog->addItem(strList.at(E_COLUMN_NAME));
@@ -236,55 +242,15 @@ QGroupBox *Widget::setSearchWidgets()
QHBoxLayout *hlayout = new QHBoxLayout();
hlayout->addLayout(vlayout);
hlayout->addWidget(m_ppbInsertSearch);
{
QPushButton *pbInsert = new QPushButton("Insert");
hlayout->addWidget(pbInsert);
connect(pbInsert, SIGNAL(released()),this, SLOT(SearchKeyword()));
}
QGroupBox *groupBox = new QGroupBox(tr("Search"));
groupBox->setLayout(hlayout);
connect(m_ppbInsertSearch, SIGNAL(released()),this, SLOT(SearchKeyword()));
return groupBox;
}
QGroupBox *Widget::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);
}
QGroupBox *groupBox = new QGroupBox(tr("Filter"));
groupBox->setLayout(hMainlayout);
connect(m_plwFilterGroup,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(currentGroupItemChanged(QListWidgetItem *, QListWidgetItem *)));
groupBox->setLayout(hlayout);
return groupBox;
}
@@ -352,6 +318,51 @@ QGroupBox *Widget::setReplaceWidgets()
return groupBox;
}
QGroupBox *Widget::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);
}
QGroupBox *groupBox = new QGroupBox(tr("Filter"));
groupBox->setLayout(hMainlayout);
connect(m_plwFilterGroup,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(currentGroupItemChanged(QListWidgetItem *, QListWidgetItem *)));
return groupBox;
}
void Widget::DataGroupRefresh()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
@@ -386,14 +397,15 @@ void Widget::InsertCopyRow(int _nRow,QTableWidget *_pCurrent,QTableWidget *_pNew
void Widget::SearchDate()
{
STable *pNew = new STable;
QTableWidget *pCurrent = (QTableWidget *)m_ptwData->currentWidget();
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;
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
{
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
InsertTimeFilter(m_nColumn,m_pdeStart->date(),m_pdeEnd->date(),nCurrentFilterGroupID);
InsertTimeFilter(pNew->getArticleSelect(),m_pdeStart->date(),m_pdeEnd->date(),nCurrentFilterGroupID);
}
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
@@ -422,13 +434,14 @@ void Widget::SearchDate()
void Widget::SearchKeyword()
{
STable *pNew = new STable;
QTableWidget *pCurrent = (QTableWidget *)m_ptwData->currentWidget();
STable *pCurrent = (STable *)m_ptwData->currentWidget();
pNew->setArticleSelect(pCurrent->getArticleSelect());
pNew->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
int nCurrentFilterGroupID = D_NOT_SELECT;
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
{
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
InsertSearchFilter(m_pcbCatalog->currentIndex(),m_pcbMethod->currentIndex(),m_pcbKeyword->currentIndex(),m_pleString->text(),nCurrentFilterGroupID);
InsertSearchFilter(pNew->getArticleSelect(),m_pcbCatalog->currentIndex(),m_pcbMethod->currentIndex(),m_pcbKeyword->currentIndex(),m_pleString->text(),nCurrentFilterGroupID);
}
QStringList strListKeyword = m_pleString->text().split(" ");
@@ -493,7 +506,8 @@ void Widget::SearchKeyword()
void Widget::SearchLengthInsert()
{
STable *pNew = new STable;
QTableWidget *pCurrent = (QTableWidget *)m_ptwData->currentWidget();
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();
@@ -505,10 +519,9 @@ void Widget::SearchLengthInsert()
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
{
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
//InsertTimeFilter(m_nColumn,m_pdeStart->date(),m_pdeEnd->date(),nCurrentFilterGroupID);
InsertLengthFilter(pCurrent->getArticleSelect(),nCatalog,nComp,nFlag,m_pleLength->text(),nCurrentFilterGroupID);
}
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
{
bool bFlag = false;
@@ -542,7 +555,8 @@ void Widget::SearchLengthInsert()
void Widget::SearchReplaceInsert()
{
STable *pNew = new STable;
QTableWidget *pCurrent = (QTableWidget *)m_ptwData->currentWidget();
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();
@@ -554,11 +568,14 @@ void Widget::SearchReplaceInsert()
bFlag = true;
strListKeyword = m_pleReplaceFind->text().split(" ");
}
int nCurrentFilterGroupID = D_NOT_SELECT;
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
{
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
InsertFilter(m_nColumn,nCurrentFilterGroupID);
InsertReplaceFilter(pNew->getArticleSelect(),nCatalog,
m_pcbReplaceFind->currentData().toInt(),
m_pleReplaceFind->text(),m_pleReplace->text(),
nCurrentFilterGroupID);
}
pNew->setRowCount(pCurrent->rowCount());
@@ -731,7 +748,7 @@ void Widget::FilterGroupRefresh()
db.close();
}
void Widget::InsertTimeFilter(int _nCategory ,QDate _dateStart ,QDate _dateEnd ,int _nGroup)
void Widget::InsertFilter(int _nType,QString _strJson,int _nGroup)
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("bigbird.iptime.org");
@@ -744,49 +761,66 @@ void Widget::InsertTimeFilter(int _nCategory ,QDate _dateStart ,QDate _dateEnd ,
return;
}
QString sql = "insert into filter (type,timecategory,timestart,timeend,filtergroup_id) value (";
sql += "0,";
sql += QString::number(_nCategory) + ",'";
sql += _dateStart.toString("yyyy-MM-dd") + "','";
sql += _dateEnd.toString("yyyy-MM-dd") + "',";
QString sql = "insert into filter (type,data,filtergroup_id) value (";
sql += QString::number(_nType);
sql += ",'" + _strJson + "',";
sql += QString::number(_nGroup) + ")";
QSqlQuery query;
QSqlQuery query;
if (query.exec(sql.toUtf8()) == false)
{
qDebug() << sql;
qDebug() << query.lastError().text();
}
db.close();
}
void Widget::InsertSearchFilter(int _nCategory,int _nMethod,int _nKeyword, QString str,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,searchescategory,searchesmethod,searcheskeyword,searchesstring,filtergroup_id) value (";
sql += "1,";
sql += QString::number(_nCategory) + ",";
sql += QString::number(_nMethod) + ",";
sql += QString::number(_nKeyword) + ",";
sql += "'" + str + "',";
sql += QString::number(_nGroup) + ")";
QSqlQuery query;
if (query.exec(sql.toUtf8()) == false)
{
qDebug() << query.lastError().text();
}
db.close();
}
void Widget::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 Widget::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 Widget::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 Widget::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 Widget::RefreshFilter(int _nGroup)
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
@@ -799,36 +833,46 @@ void Widget::RefreshFilter(int _nGroup)
qDebug() << db.lastError().text();
return;
}
QSqlQuery query("select id,type,timecategory,timestart,timeend,searchescategory,searchesmethod,searcheskeyword,searchesstring from filter where filtergroup_id = " + QString::number(_nGroup));
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();
switch(query.value(1).toInt())
{
case 0:
str = "Type : Date ";
str += ", Start : ";
str += query.value(3).toString();
str += ", End : ";
str += query.value(4).toString();
case E_FILTER_TYPE_DATE:
str = "<Date> Start : ";
str += json.Get(strJson,"Start");
str += " End : ";
str += json.Get(strJson,"End");
break;
case 1:
str = "Type : Seracher ";
str += ", Catalog : ";
str += m_pcbCatalog->itemText(query.value(5).toInt());
str += ", Method : ";
str += m_pcbMethod->itemText(query.value(6).toInt());
str += ", Keyword : ";
str += m_pcbKeyword->itemText(query.value(7).toInt());
str += ", Search : ";
str += query.value(8).toString();
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)));
//m_plwFilter->insertItem(m_plwFilter->size().height()-1,pItem);
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
}
db.close();
}
@@ -878,20 +922,46 @@ void Widget::currentFilterItemChanged(QListWidgetItem *_pCurrent, QListWidgetIte
qDebug() << db.lastError().text();
return;
}
QSqlQuery query("select id,type,timecategory,timestart,timeend,searchescategory,searchesmethod,searcheskeyword,searchesstring from filter where id = " + _pCurrent->data(Qt::UserRole).toString());
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 0:
m_pdeStart->setDate(query.value(3).toDate());
m_pdeEnd->setDate(query.value(4).toDate());
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 1:
m_pcbCatalog->setCurrentIndex(query.value(5).toInt());
m_pcbMethod->setCurrentIndex(query.value(6).toInt());
m_pcbKeyword->setCurrentIndex(query.value(7).toInt());
m_pleString->setText(query.value(8).toString());
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;
}
}