Counter 적용
git-svn-id: svn://192.168.0.12/source@110 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
|
||||||
STable::STable(QWidget *parent):
|
STable::STable(QWidget *parent):
|
||||||
QTableWidget(parent)
|
QTableWidget(parent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ Widget::Widget(QWidget *parent)
|
|||||||
|
|
||||||
vlayout->addWidget(setSearchWidgets());
|
vlayout->addWidget(setSearchWidgets());
|
||||||
vlayout->addWidget(setLengthWidgets());
|
vlayout->addWidget(setLengthWidgets());
|
||||||
|
vlayout->addWidget(setCounterWidgets());
|
||||||
vlayout->addWidget(setReplaceWidgets());
|
vlayout->addWidget(setReplaceWidgets());
|
||||||
vlayout->setAlignment(Qt::AlignTop);
|
vlayout->setAlignment(Qt::AlignTop);
|
||||||
|
|
||||||
@@ -303,6 +304,52 @@ QGroupBox *Widget::setLengthWidgets()
|
|||||||
return groupBox;
|
return groupBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QGroupBox *Widget::setCounterWidgets()
|
||||||
|
{
|
||||||
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||||
|
m_pcbCounterCatalog = new QComboBox;
|
||||||
|
m_pcbCounterComp = new QComboBox;
|
||||||
|
m_pcbCounterInsDel = new QComboBox;
|
||||||
|
m_pcbCounterCntApl = new QComboBox;
|
||||||
|
m_pleCounter = new QLineEdit;
|
||||||
|
|
||||||
|
foreach(QStringList strList,m_vecColumn)
|
||||||
|
m_pcbCounterCatalog->addItem(strList.at(E_COLUMN_NAME));
|
||||||
|
|
||||||
|
m_pcbCounterComp->addItem(">",QVariant(E_LENGTH_COMP_GREATER));
|
||||||
|
m_pcbCounterComp->addItem("<",QVariant(E_LENGTH_COMP_LESS));
|
||||||
|
m_pcbCounterComp->addItem("=",QVariant(E_LENGTH_COMP_EQUAL));
|
||||||
|
|
||||||
|
m_pcbCounterInsDel->addItem("Add",QVariant(0));
|
||||||
|
m_pcbCounterInsDel->addItem("Del",QVariant(1));
|
||||||
|
|
||||||
|
m_pcbCounterCntApl->addItem("Count",QVariant(0));
|
||||||
|
m_pcbCounterCntApl->addItem("Apply",QVariant(1));
|
||||||
|
|
||||||
|
hlayout->addWidget(new QLabel("Item:"));
|
||||||
|
hlayout->addWidget(m_pcbCounterCatalog);
|
||||||
|
hlayout->addWidget(m_pcbCounterComp);
|
||||||
|
//hlayout->addWidget(m_pcbCounterCntApl);
|
||||||
|
hlayout->addWidget(new QLabel("Count:"));
|
||||||
|
hlayout->addWidget(m_pleCounter);
|
||||||
|
hlayout->addWidget(m_pcbCounterInsDel);
|
||||||
|
{
|
||||||
|
QPushButton *pbInsert = new QPushButton("Insert");
|
||||||
|
connect(pbInsert , SIGNAL(released()),this, SLOT(SearchCounterInsert()));
|
||||||
|
QPushButton *pbModify = new QPushButton("Modify");
|
||||||
|
connect(pbModify , SIGNAL(released()),this, SLOT(SearchCounterUpdate()));
|
||||||
|
hlayout->addWidget(pbInsert);
|
||||||
|
hlayout->addWidget(pbModify);
|
||||||
|
}
|
||||||
|
|
||||||
|
QGroupBox *groupBox = new QGroupBox(tr("Counter"));
|
||||||
|
groupBox->setLayout(hlayout);
|
||||||
|
return groupBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QGroupBox *Widget::setReplaceWidgets()
|
QGroupBox *Widget::setReplaceWidgets()
|
||||||
{
|
{
|
||||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||||
@@ -568,6 +615,182 @@ void Widget::SearchKeyword()
|
|||||||
RefreshFilter(nCurrentFilterGroupID);
|
RefreshFilter(nCurrentFilterGroupID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::SearchCounterInsert()
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
m_pleCounter->text().toInt(&ok);
|
||||||
|
if(!ok)
|
||||||
|
return;
|
||||||
|
|
||||||
|
STable *pCurrent = (STable *)m_ptwData->currentWidget();
|
||||||
|
|
||||||
|
int nCatalog = m_pcbCounterCatalog->currentIndex();
|
||||||
|
int nFlag = m_pcbCounterInsDel->currentData().toInt();
|
||||||
|
int nComp = m_pcbCounterComp->currentData().toInt();
|
||||||
|
//int nCntApl = m_pcbCounterCntApl->currentData().toInt();
|
||||||
|
int nCurrentFilterGroupID = D_NOT_SELECT;
|
||||||
|
|
||||||
|
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
||||||
|
|
||||||
|
QString strKey = m_pcbCounterCatalog->currentText();
|
||||||
|
strKey += ",";
|
||||||
|
strKey += QString::number(m_pcbCounterComp->currentIndex());
|
||||||
|
strKey += ",";
|
||||||
|
strKey += m_pleCounter->text();
|
||||||
|
|
||||||
|
|
||||||
|
if (m_pgbFilter->isChecked())
|
||||||
|
{
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||||
|
{
|
||||||
|
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
|
||||||
|
DataBaseCounterFilter(pCurrent->getArticleSelect(), nCatalog, nComp, nFlag, m_pleCounter->text(), nCurrentFilterGroupID, E_DATABASE_COMMAND_INSERT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if(m_pcbCounterCntApl->currentIndex() == 0)
|
||||||
|
{
|
||||||
|
if(m_mapData.contains(strKey))
|
||||||
|
m_mapData[strKey].clear();
|
||||||
|
|
||||||
|
QMap<QString, int> mapData;
|
||||||
|
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
if (nCatalog == m_nColumn)
|
||||||
|
{
|
||||||
|
QDateTime date;
|
||||||
|
str = date.fromString(pCurrent->item(nCount,nCatalog)->text().trimmed(),"yyyy-MM-dd hh:mm:ss").date().toString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
str = pCurrent->item(nCount,nCatalog)->text().trimmed();
|
||||||
|
|
||||||
|
|
||||||
|
if(mapData.contains(str))
|
||||||
|
{
|
||||||
|
mapData[str] += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mapData.insert(str,1);
|
||||||
|
}
|
||||||
|
m_pProgress->setValue(nCount);
|
||||||
|
m_pProgress->repaint();
|
||||||
|
}
|
||||||
|
int leCount = m_pleCounter->text().toInt();
|
||||||
|
|
||||||
|
if(m_pcbCounterComp->currentIndex() == 0)
|
||||||
|
{
|
||||||
|
for(QMap<QString, int>::iterator iterPos = mapData.begin(); iterPos != mapData.end() ;iterPos++)
|
||||||
|
{
|
||||||
|
if(iterPos.value() > leCount)
|
||||||
|
{
|
||||||
|
if(m_mapData.contains(strKey))
|
||||||
|
{
|
||||||
|
m_mapData[strKey].insert(iterPos.key(), iterPos.value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMap<QString, int> temp;
|
||||||
|
temp.insert(iterPos.key(), iterPos.value());
|
||||||
|
m_mapData.insert(strKey, temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(m_pcbCounterComp->currentIndex() == 1)
|
||||||
|
{
|
||||||
|
for(QMap<QString, int>::iterator iterPos = mapData.begin(); iterPos != mapData.end() ;iterPos++)
|
||||||
|
{
|
||||||
|
if(iterPos.value() < leCount)
|
||||||
|
{
|
||||||
|
if(m_mapData.contains(strKey))
|
||||||
|
{
|
||||||
|
m_mapData[strKey].insert(iterPos.key(), iterPos.value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMap<QString, int> temp;
|
||||||
|
temp.insert(iterPos.key(), iterPos.value());
|
||||||
|
m_mapData.insert(strKey, temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(m_pcbCounterComp->currentIndex() == 2)
|
||||||
|
{
|
||||||
|
for(QMap<QString, int>::iterator iterPos = mapData.begin(); iterPos != mapData.end() ;iterPos++)
|
||||||
|
{
|
||||||
|
if(iterPos.value() == leCount)
|
||||||
|
{
|
||||||
|
if(m_mapData.contains(strKey))
|
||||||
|
{
|
||||||
|
m_mapData[strKey].insert(iterPos.key(), iterPos.value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMap<QString, int> temp;
|
||||||
|
temp.insert(iterPos.key(), iterPos.value());
|
||||||
|
m_mapData.insert(strKey, temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if(m_pcbCounterCntApl->currentIndex() == 1)
|
||||||
|
{
|
||||||
|
if(!m_mapData.contains(strKey))
|
||||||
|
return;
|
||||||
|
|
||||||
|
STable *pNew = new STable;
|
||||||
|
pNew->setArticleSelect(pCurrent->getArticleSelect());
|
||||||
|
pNew->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
|
||||||
|
|
||||||
|
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
||||||
|
|
||||||
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||||
|
{
|
||||||
|
bool bFlag = false;
|
||||||
|
QString strCurrent = pCurrent->item(nCount,nCatalog)->text().trimmed();
|
||||||
|
if(m_mapData[strKey].contains(strCurrent))
|
||||||
|
bFlag = true;
|
||||||
|
if (nFlag == 1) bFlag = !bFlag;
|
||||||
|
if (bFlag) InsertCopyRow(nCount,pCurrent,pNew);
|
||||||
|
m_pProgress->setValue(nCount);
|
||||||
|
m_pProgress->repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ptwData->addTab(pNew,STable::GetArticleType(pCurrent->getArticleSelect()));
|
||||||
|
m_ptwData->setCurrentIndex(m_ptwData->count()-1);
|
||||||
|
}
|
||||||
|
if (nCurrentFilterGroupID != D_NOT_SELECT)
|
||||||
|
RefreshFilter(nCurrentFilterGroupID);
|
||||||
|
m_mapData[strKey].clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::SearchCounterUpdate()
|
||||||
|
{
|
||||||
|
if (m_pgbFilter->isChecked())
|
||||||
|
{
|
||||||
|
int nCurrentFilterGroupID = D_NOT_SELECT;
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
||||||
|
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
|
||||||
|
|
||||||
|
if (nCurrentFilterGroupID == D_NOT_SELECT) return;
|
||||||
|
|
||||||
|
int nCatalog = m_pcbCounterCatalog->currentIndex();
|
||||||
|
int nComp = m_pcbCounterComp->currentData().toInt();
|
||||||
|
int nFlag = m_pcbCounterInsDel->currentData().toInt();
|
||||||
|
foreach (QListWidgetItem *item,m_plwFilter->selectedItems())
|
||||||
|
DataBaseLengthFilter(((STable *)m_ptwData->currentWidget())->getArticleSelect(),nCatalog,nComp,nFlag,m_pleCounter->text(),nCurrentFilterGroupID,E_DATABASE_COMMAND_UPDATE,item->data(Qt::UserRole).toString());
|
||||||
|
RefreshFilter(nCurrentFilterGroupID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Widget::SearchLengthInsert()
|
void Widget::SearchLengthInsert()
|
||||||
{
|
{
|
||||||
STable *pNew = new STable;
|
STable *pNew = new STable;
|
||||||
@@ -1071,6 +1294,21 @@ void Widget::DataBaseLengthFilter(int _nArticle,int _nCategory,int _nComp,int _n
|
|||||||
DataBaseFilter(E_FILTER_TYPE_LENGTH,json.Sql(strJson),_nGroup,_nCommand,_strFilterId);
|
DataBaseFilter(E_FILTER_TYPE_LENGTH,json.Sql(strJson),_nGroup,_nCommand,_strFilterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Widget::DataBaseCounterFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,QString _strFilterId)
|
||||||
|
{
|
||||||
|
QString strJson;
|
||||||
|
SJson json;
|
||||||
|
strJson = json.Set(strJson,"Article",QString::number(_nArticle));
|
||||||
|
strJson = json.Set(strJson,"Category",_nCategory);
|
||||||
|
strJson = json.Set(strJson,"Comp",_nComp);
|
||||||
|
strJson = json.Set(strJson,"InsDel",_nInsDel);
|
||||||
|
strJson = json.Set(strJson,"String",_str);
|
||||||
|
DataBaseFilter(E_FILTER_TYPE_COUNTER,json.Sql(strJson),_nGroup,_nCommand,_strFilterId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Widget::DataBaseReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup,int _nCommand,QString _strFilterId)
|
void Widget::DataBaseReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup,int _nCommand,QString _strFilterId)
|
||||||
{
|
{
|
||||||
QString strJson;
|
QString strJson;
|
||||||
@@ -1133,6 +1371,13 @@ void Widget::RefreshFilter(int _nGroup)
|
|||||||
str += json.Get(strJson,"String_Find") + " --> ";
|
str += json.Get(strJson,"String_Find") + " --> ";
|
||||||
str += json.Get(strJson,"String_Replace");
|
str += json.Get(strJson,"String_Replace");
|
||||||
break;
|
break;
|
||||||
|
case E_FILTER_TYPE_COUNTER:
|
||||||
|
str += "<Counter> ";
|
||||||
|
str += m_pcbCounterCatalog->itemText(json.GetNumber(strJson,"Category")) + " ";
|
||||||
|
str += m_pcbCounterComp->itemText(json.GetNumber(strJson,"Comp")) + " ";
|
||||||
|
str += json.Get(strJson,"String") + " , ";
|
||||||
|
str += m_pcbCounterInsDel->itemText(json.GetNumber(strJson,"InsDel"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwFilter);
|
QListWidgetItem *pItem = new QListWidgetItem(str,m_plwFilter);
|
||||||
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
pItem->setData(Qt::UserRole, QVariant(query.value(0)));
|
||||||
@@ -1225,6 +1470,15 @@ void Widget::currentFilterItemChanged(QListWidgetItem *_pCurrent, QListWidgetIte
|
|||||||
m_pleString->setText("");
|
m_pleString->setText("");
|
||||||
m_pleLength->setText("");
|
m_pleLength->setText("");
|
||||||
break;
|
break;
|
||||||
|
case E_FILTER_TYPE_COUNTER:
|
||||||
|
m_pcbCounterCatalog->setCurrentIndex(json.GetNumber(strJson,"Category"));
|
||||||
|
m_pcbCounterComp->setCurrentIndex(json.GetNumber(strJson,"Comp"));
|
||||||
|
m_pcbCounterInsDel->setCurrentIndex(json.GetNumber(strJson,"InsDel"));
|
||||||
|
m_pleCounter->setText(json.Get(strJson,"String"));
|
||||||
|
m_pleReplaceFind->setText("");
|
||||||
|
m_pleReplace->setText("");
|
||||||
|
m_pleString->setText("");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1352,22 +1606,6 @@ void Widget::FileExit()
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SCount
|
|
||||||
{
|
|
||||||
SCount()
|
|
||||||
{
|
|
||||||
m_str.clear();
|
|
||||||
m_nCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCount(QString _str)
|
|
||||||
{
|
|
||||||
m_str = _str;
|
|
||||||
m_nCount = 1;
|
|
||||||
}
|
|
||||||
QString m_str;
|
|
||||||
int m_nCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
void Widget::CountSave()
|
void Widget::CountSave()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,22 @@
|
|||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
#include "stable.h"
|
#include "stable.h"
|
||||||
|
struct SCount
|
||||||
|
{
|
||||||
|
SCount()
|
||||||
|
{
|
||||||
|
m_str.clear();
|
||||||
|
m_nCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCount(QString _str)
|
||||||
|
{
|
||||||
|
m_str = _str;
|
||||||
|
m_nCount = 1;
|
||||||
|
}
|
||||||
|
QString m_str;
|
||||||
|
int m_nCount;
|
||||||
|
};
|
||||||
class Widget : public QWidget
|
class Widget : public QWidget
|
||||||
{
|
{
|
||||||
enum E_COLUMN
|
enum E_COLUMN
|
||||||
@@ -67,6 +82,13 @@ private:
|
|||||||
QComboBox *m_pcbLengthComp;
|
QComboBox *m_pcbLengthComp;
|
||||||
QComboBox *m_pcbLengthInsDel;
|
QComboBox *m_pcbLengthInsDel;
|
||||||
QLineEdit *m_pleLength;
|
QLineEdit *m_pleLength;
|
||||||
|
// Counter
|
||||||
|
QComboBox *m_pcbCounterCatalog;
|
||||||
|
QComboBox *m_pcbCounterComp;
|
||||||
|
QComboBox *m_pcbCounterInsDel;
|
||||||
|
QComboBox *m_pcbCounterCntApl;
|
||||||
|
QLineEdit *m_pleCounter;
|
||||||
|
|
||||||
// Filter
|
// Filter
|
||||||
QListWidget *m_plwFilterGroup;
|
QListWidget *m_plwFilterGroup;
|
||||||
QListWidget *m_plwFilter;
|
QListWidget *m_plwFilter;
|
||||||
@@ -87,7 +109,10 @@ private:
|
|||||||
//
|
//
|
||||||
QProgressBar *m_pProgress;
|
QProgressBar *m_pProgress;
|
||||||
// Column
|
// Column
|
||||||
QVector <QStringList> m_vecColumn;
|
QVector <QStringList> m_vecColumn;
|
||||||
|
QVector <SCount> vecData;
|
||||||
|
QMap <QString, QMap <QString, int> > m_mapData;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMenuBar *setMenuWidget();
|
QMenuBar *setMenuWidget();
|
||||||
QGroupBox *setDataWidgets();
|
QGroupBox *setDataWidgets();
|
||||||
@@ -95,6 +120,7 @@ private:
|
|||||||
QGroupBox *setCountWidgets();
|
QGroupBox *setCountWidgets();
|
||||||
QGroupBox *setSearchWidgets();
|
QGroupBox *setSearchWidgets();
|
||||||
QGroupBox *setLengthWidgets();
|
QGroupBox *setLengthWidgets();
|
||||||
|
QGroupBox *setCounterWidgets();
|
||||||
QGroupBox *setFilterWidgets();
|
QGroupBox *setFilterWidgets();
|
||||||
QGroupBox *setReplaceWidgets();
|
QGroupBox *setReplaceWidgets();
|
||||||
|
|
||||||
@@ -108,7 +134,7 @@ private:
|
|||||||
void DataBaseLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,QString _strFilterId ="");
|
void DataBaseLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,QString _strFilterId ="");
|
||||||
void DataBaseReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup,int _nCommand,QString _strFilterId ="");
|
void DataBaseReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup,int _nCommand,QString _strFilterId ="");
|
||||||
void RefreshFilter(int _nGroup);
|
void RefreshFilter(int _nGroup);
|
||||||
|
void DataBaseCounterFilter(int _nArticle,int _nCategory,int _nComp, int _nInsDel,QString _str,int _nGroup,int _nCommand,QString _strFilterId ="");
|
||||||
bool ReloadColumn();
|
bool ReloadColumn();
|
||||||
QString GetArticleType(int _nSelect);
|
QString GetArticleType(int _nSelect);
|
||||||
public slots:
|
public slots:
|
||||||
@@ -124,6 +150,9 @@ public slots:
|
|||||||
void SearchKeywordUpdate();
|
void SearchKeywordUpdate();
|
||||||
void SearchLengthUpdate();
|
void SearchLengthUpdate();
|
||||||
void SearchReplaceUpdate();
|
void SearchReplaceUpdate();
|
||||||
|
void SearchCounterUpdate();
|
||||||
|
void SearchCounterInsert();
|
||||||
|
|
||||||
|
|
||||||
void DataGroupRefresh();
|
void DataGroupRefresh();
|
||||||
void DataGroupItemChanged ( QListWidgetItem * item );
|
void DataGroupItemChanged ( QListWidgetItem * item );
|
||||||
|
|||||||
Reference in New Issue
Block a user