|
|
|
|
@@ -10,6 +10,7 @@
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QSqlError>
|
|
|
|
|
#include <QMenuBar>
|
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
QSqlDatabase dbWeb = QSqlDatabase::addDatabase("QMYSQL");
|
|
|
|
|
@@ -62,7 +63,7 @@ Widget::Widget(QWidget *parent)
|
|
|
|
|
vMainLayout->addWidget(m_ptwData,8);
|
|
|
|
|
m_ptwData->setTabsClosable(true);
|
|
|
|
|
connect(m_ptwData,SIGNAL(tabCloseRequested(int)),this,SLOT(CloseTab(int)));
|
|
|
|
|
|
|
|
|
|
connect(m_ptwData,SIGNAL(tabBarDoubleClicked(int)),this,SLOT(DoubleClickTab(int)));
|
|
|
|
|
m_pProgress = new QProgressBar;
|
|
|
|
|
vMainLayout->addWidget(m_pProgress,1);
|
|
|
|
|
}
|
|
|
|
|
@@ -88,11 +89,23 @@ void Widget::CloseTab(int index)
|
|
|
|
|
m_ptwData->removeTab(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Widget::DoubleClickTab(int index)
|
|
|
|
|
{
|
|
|
|
|
bool ok;
|
|
|
|
|
if (index < 0) return;
|
|
|
|
|
QString text = QInputDialog::getText(this,"Tab name change","Name : ", QLineEdit::Normal,m_ptwData->tabText(index), &ok);
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
m_ptwData->setTabText(index,text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMenuBar *Widget::setMenuWidget()
|
|
|
|
|
{
|
|
|
|
|
QMenuBar *pMenuBar = new QMenuBar();
|
|
|
|
|
{
|
|
|
|
|
QMenu *pFile = pMenuBar->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();
|
|
|
|
|
@@ -101,6 +114,20 @@ QMenuBar *Widget::setMenuWidget()
|
|
|
|
|
return pMenuBar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Widget::FileNew()
|
|
|
|
|
{
|
|
|
|
|
bool ok;
|
|
|
|
|
QString text = QInputDialog::getText(this,"New Row Count","Count :", QLineEdit::Normal,"0", &ok);
|
|
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
STable *pTable = (STable*)AddTable("new");
|
|
|
|
|
pTable->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
|
|
|
|
|
m_ptwData->setCurrentIndex(m_ptwData->count()-1);
|
|
|
|
|
pTable->setRowCount(text.toInt());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QGroupBox *Widget::setDataWidgets()
|
|
|
|
|
{
|
|
|
|
|
QVBoxLayout *vlayout = new QVBoxLayout;
|
|
|
|
|
@@ -163,7 +190,7 @@ QGroupBox *Widget::setCountWidgets()
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
QPushButton *pbInsert = new QPushButton("Save");
|
|
|
|
|
//connect(pbInsert , SIGNAL(released()),this, SLOT(SearchLengthInsert()));
|
|
|
|
|
connect(pbInsert , SIGNAL(released()),this, SLOT(CountSave()));
|
|
|
|
|
hlayout->addWidget(pbInsert);
|
|
|
|
|
}
|
|
|
|
|
QGroupBox *groupBox = new QGroupBox(tr("Count"));
|
|
|
|
|
@@ -458,6 +485,7 @@ void Widget::SearchKeyword()
|
|
|
|
|
}
|
|
|
|
|
m_ptwData->addTab(pNew,m_ptwData->tabText(m_ptwData->currentIndex())+" k");
|
|
|
|
|
m_ptwData->setCurrentIndex(m_ptwData->count()-1);
|
|
|
|
|
|
|
|
|
|
if (nCurrentFilterGroupID != D_NOT_SELECT)
|
|
|
|
|
RefreshFilter(nCurrentFilterGroupID);
|
|
|
|
|
}
|
|
|
|
|
@@ -472,19 +500,19 @@ void Widget::SearchLengthInsert()
|
|
|
|
|
int nComp = m_pcbLengthComp->currentData().toInt();
|
|
|
|
|
int nFlag = m_pcbLengthInsDel->currentData().toInt();
|
|
|
|
|
int nLength = m_pleLength->text().toInt();
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
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(m_nColumn,m_pdeStart->date(),m_pdeEnd->date(),nCurrentFilterGroupID);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
|
|
|
|
{
|
|
|
|
|
bool bFlag = false;
|
|
|
|
|
int nCurrentLength = pCurrent->item(nCount,nCatalog)->text().trimmed().length();
|
|
|
|
|
int nCurrentLength = pCurrent->item(nCount,nCatalog)->text().trimmed().length();
|
|
|
|
|
switch(nComp)
|
|
|
|
|
{
|
|
|
|
|
case E_LENGTH_COMP_GREATER:
|
|
|
|
|
@@ -507,8 +535,8 @@ void Widget::SearchLengthInsert()
|
|
|
|
|
}
|
|
|
|
|
m_ptwData->addTab(pNew,m_ptwData->tabText(m_ptwData->currentIndex())+" c");
|
|
|
|
|
m_ptwData->setCurrentIndex(m_ptwData->count()-1);
|
|
|
|
|
//if (nCurrentFilterGroupID != D_NOT_SELECT)
|
|
|
|
|
// RefreshFilter(nCurrentFilterGroupID);
|
|
|
|
|
if (nCurrentFilterGroupID != D_NOT_SELECT)
|
|
|
|
|
RefreshFilter(nCurrentFilterGroupID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Widget::SearchReplaceInsert()
|
|
|
|
|
@@ -527,6 +555,12 @@ void Widget::SearchReplaceInsert()
|
|
|
|
|
strListKeyword = m_pleReplaceFind->text().split(" ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (QListWidgetItem *item,m_plwFilterGroup->selectedItems())
|
|
|
|
|
{
|
|
|
|
|
nCurrentFilterGroupID = item->data(Qt::UserRole).toInt();
|
|
|
|
|
InsertFilter(m_nColumn,nCurrentFilterGroupID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pNew->setRowCount(pCurrent->rowCount());
|
|
|
|
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
|
|
|
|
{
|
|
|
|
|
@@ -553,10 +587,9 @@ void Widget::SearchReplaceInsert()
|
|
|
|
|
}
|
|
|
|
|
m_ptwData->addTab(pNew,m_ptwData->tabText(m_ptwData->currentIndex())+" r");
|
|
|
|
|
m_ptwData->setCurrentIndex(m_ptwData->count()-1);
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
if (nCurrentFilterGroupID != D_NOT_SELECT)
|
|
|
|
|
RefreshFilter(nCurrentFilterGroupID);
|
|
|
|
|
*/
|
|
|
|
|
RefreshFilter(nCurrentFilterGroupID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Widget::DataGroupItemChanged( QListWidgetItem *item)
|
|
|
|
|
@@ -568,9 +601,9 @@ void Widget::DataGroupItemChanged( QListWidgetItem *item)
|
|
|
|
|
QPushButton *pbBody = msg.addButton("Body",QMessageBox::ActionRole);
|
|
|
|
|
QPushButton *pbReply = msg.addButton("Reply",QMessageBox::ActionRole);
|
|
|
|
|
msg.exec();
|
|
|
|
|
if (msg.clickedButton() == pbAll) DataReload("data_" + item->data(Qt::UserRole).toString(),E_ARTICLE_ALL);
|
|
|
|
|
else if (msg.clickedButton() == pbBody) DataReload("data_" + item->data(Qt::UserRole).toString(),E_ARTICLE_BODY);
|
|
|
|
|
else if (msg.clickedButton() == pbReply) DataReload("data_" + item->data(Qt::UserRole).toString(),E_ARTICLE_REPLY);
|
|
|
|
|
if (msg.clickedButton() == pbAll) DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_ALL);
|
|
|
|
|
else if (msg.clickedButton() == pbBody) DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_BODY);
|
|
|
|
|
else if (msg.clickedButton() == pbReply) DataReload("data_" + item->data(Qt::UserRole).toString(),STable::E_ARTICLE_REPLY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Widget::DataReload(QString _strTableName,int _nSelect)
|
|
|
|
|
@@ -593,13 +626,14 @@ void Widget::DataReload(QString _strTableName,int _nSelect)
|
|
|
|
|
strSelect += " from ";
|
|
|
|
|
strSelect += _strTableName;
|
|
|
|
|
|
|
|
|
|
if (_nSelect == E_ARTICLE_BODY)
|
|
|
|
|
if (_nSelect == STable::E_ARTICLE_BODY)
|
|
|
|
|
strSelect += " WHERE article_form = 'body'";
|
|
|
|
|
if (_nSelect == E_ARTICLE_REPLY)
|
|
|
|
|
if (_nSelect == STable::E_ARTICLE_REPLY)
|
|
|
|
|
strSelect += " WHERE article_form = 'reply'";
|
|
|
|
|
|
|
|
|
|
QSqlQuery query(strSelect);
|
|
|
|
|
STable *pTable = (STable *)m_ptwData->currentWidget();
|
|
|
|
|
pTable->setArticleSelect(_nSelect);
|
|
|
|
|
pTable->clear();
|
|
|
|
|
pTable->SetHeaderList(&m_vecColumn,E_COLUMN_NAME);
|
|
|
|
|
pTable->setRowCount(query.size());
|
|
|
|
|
@@ -983,3 +1017,69 @@ void Widget::FileExit()
|
|
|
|
|
{
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
QTableWidget *pCurrent = (QTableWidget *)m_ptwData->currentWidget();
|
|
|
|
|
int nCatalog = m_pcbCountCatalog->currentIndex();
|
|
|
|
|
QString strFilename = QFileDialog::getSaveFileName(0,"Count file",QDir::currentPath(),
|
|
|
|
|
"csv files (*.csv);;All files (*.*)",new QString("csv files (*.csv)"));
|
|
|
|
|
if (strFilename.toLower().right(4) != QString(".csv"))
|
|
|
|
|
strFilename += ".csv";
|
|
|
|
|
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
|
|
|
|
|
|
|
|
|
QVector <SCount> vecData;
|
|
|
|
|
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();
|
|
|
|
|
bool bInsert = true;
|
|
|
|
|
for (int i = 0; i < vecData.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
if(vecData[i].m_str.compare(str) == 0)
|
|
|
|
|
{
|
|
|
|
|
vecData[i].m_nCount++;
|
|
|
|
|
bInsert = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (bInsert)
|
|
|
|
|
vecData.push_back(SCount(str));
|
|
|
|
|
m_pProgress->setValue(nCount);
|
|
|
|
|
m_pProgress->repaint();
|
|
|
|
|
}
|
|
|
|
|
QFile file(strFilename);
|
|
|
|
|
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
|
|
|
|
QTextStream out(&file);
|
|
|
|
|
out << pCurrent->horizontalHeaderItem(nCatalog)->text() << "," << vecData.size() << endl << endl;
|
|
|
|
|
foreach(SCount stCount,vecData)
|
|
|
|
|
{
|
|
|
|
|
QString str = stCount.m_str.replace(",",".");
|
|
|
|
|
str = str.replace("\n","");
|
|
|
|
|
out << "\"" << str << "\"" << "," << stCount.m_nCount << endl;
|
|
|
|
|
}
|
|
|
|
|
file.close();
|
|
|
|
|
}
|
|
|
|
|
|