610 lines
24 KiB
C++
610 lines
24 KiB
C++
#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().addYears(1));
|
|
|
|
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 ";
|
|
break;
|
|
case E_DATABASE_COMMAND_UPDATE:
|
|
sql = "UPDATE filter SET ";
|
|
break;
|
|
}
|
|
sql += QString("type=") + QString::number(_nType) + ",";
|
|
sql += QString("data='") + _strJson + "',";
|
|
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;
|
|
if(query.exec(sql.toUtf8()) == false) { qDebug() << query.lastError().text();}
|
|
}
|
|
|
|
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);
|
|
}
|