Replace 기능 추가

git-svn-id: svn://192.168.0.12/source@73 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
admin
2015-04-14 07:51:50 +00:00
parent 099e82ffbf
commit 3a06a539dc
2 changed files with 65 additions and 11 deletions

View File

@@ -295,6 +295,7 @@ QGroupBox *Widget::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;
@@ -304,11 +305,16 @@ QGroupBox *Widget::setReplaceWidgets()
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);
{
QPushButton *pbInsert = new QPushButton("Insert");
@@ -605,17 +611,15 @@ void Widget::SearchReplaceInsert()
pNew->setArticleSelect(pCurrent->getArticleSelect());
pNew->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
m_pProgress->setRange(0,pCurrent->rowCount()-1);
int nCatalog = m_pcbReplaceCatalog->currentIndex();
bool bFlag = false;
int nCatalog = m_pcbReplaceCatalog->currentIndex();
QStringList strListKeyword;
if (m_pcbReplaceFind->currentData().toInt() == E_REPLACE_SPACE)
{
bFlag = true;
strListKeyword = m_pleReplaceFind->text().split(" ");
}
int nCurrentFilterGroupID = D_NOT_SELECT;
else
strListKeyword.push_back(m_pleReplaceFind->text());
int nCurrentFilterGroupID = D_NOT_SELECT;
int nReplace = m_pcbReplace->currentIndex();
if (m_pgbFilter->isChecked())
{
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
@@ -635,14 +639,63 @@ void Widget::SearchReplaceInsert()
if (nCatalog == nColumnCount)
{
QString strOut = pCurrent->item(nCount,nColumnCount)->text();
if (bFlag)
switch(nReplace)
{
case 0:
{
foreach(QString str,strListKeyword)
strOut = strOut.replace(str,m_pleReplace->text());
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 += m_pleReplace->text() + " ";
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 += m_pleReplace->text() + " ";
bFlag = true;
break;
}
}
if (bFlag == false)
strMiddle += strWord + " ";
}
strMiddle += "\n";
}
strOut = strMiddle;
break;
}
else
strOut = strOut.replace(m_pleReplaceFind->text(),m_pleReplace->text());
pNew->setItem(nCount,nColumnCount,new QTableWidgetItem(strOut));
}
else