|
|
|
|
@@ -8,6 +8,7 @@
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
|
|
|
|
const int C_COMBO_MAX = 2;
|
|
|
|
|
|
|
|
|
|
@@ -38,6 +39,10 @@ void SCountDlg::setWidgets()
|
|
|
|
|
QPushButton *ppbGraph = new QPushButton("Graph");
|
|
|
|
|
connect(ppbGraph, SIGNAL(released()),this, SLOT(graph()));
|
|
|
|
|
hlayout->addWidget(ppbGraph);
|
|
|
|
|
QPushButton *ppbSave = new QPushButton("Save");
|
|
|
|
|
connect(ppbSave, SIGNAL(released()),this, SLOT(save()));
|
|
|
|
|
hlayout->addWidget(ppbSave);
|
|
|
|
|
|
|
|
|
|
vlayout->addLayout(hlayout);
|
|
|
|
|
}
|
|
|
|
|
m_pTable = new STable;
|
|
|
|
|
@@ -79,7 +84,7 @@ void SCountDlg::setWidgets()
|
|
|
|
|
"\r\n"
|
|
|
|
|
"\r\n</style>"
|
|
|
|
|
"\r\n<body>"
|
|
|
|
|
"\r\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js\"></script>"
|
|
|
|
|
"\r\n<script src=\"http://d3js.org/d3.v3.min.js\"></script>"
|
|
|
|
|
"\r\n<script>"
|
|
|
|
|
"\r\n"
|
|
|
|
|
"\r\nvar margin = {top: 20, right: 80, bottom: 30, left: 50},"
|
|
|
|
|
@@ -152,8 +157,8 @@ void SCountDlg::setWidgets()
|
|
|
|
|
"\r\n .attr(\"transform\", \"rotate(-90)\")"
|
|
|
|
|
"\r\n .attr(\"y\", 6)"
|
|
|
|
|
"\r\n .attr(\"dy\", \".71em\")"
|
|
|
|
|
"\r\n .style(\"text-anchor\", \"end\")"
|
|
|
|
|
"\r\n .text(\"Buzzy\");"
|
|
|
|
|
"\r\n .style(\"text-anchor\", \"end\")"
|
|
|
|
|
"\r\n .text(\"Count\");"
|
|
|
|
|
"\r\n"
|
|
|
|
|
"\r\n var city = svg.selectAll(\".city\")"
|
|
|
|
|
"\r\n .data(cities)"
|
|
|
|
|
@@ -174,8 +179,9 @@ void SCountDlg::setWidgets()
|
|
|
|
|
"\r\n});"
|
|
|
|
|
"\r\n"
|
|
|
|
|
"\r\n</script>"
|
|
|
|
|
"\r\n";
|
|
|
|
|
|
|
|
|
|
"\r\n";
|
|
|
|
|
QRegExp re("\\s{2,}");
|
|
|
|
|
m_strGraph = m_strGraph.replace(re,"");
|
|
|
|
|
m_strGraph = m_strGraph.replace("[!F*i!l*e!]",QApplication::applicationDirPath()+"/graph.tsv");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -189,6 +195,7 @@ void SCountDlg::run()
|
|
|
|
|
|
|
|
|
|
QMap <QString,QMap<QString,int> > mapCount;
|
|
|
|
|
QSet <QString> setList;
|
|
|
|
|
QDate dateStart(2055,12,31),dateEnd(1900,1,1);
|
|
|
|
|
GetMainWindow()->m_progress.setRange(0,pCurrent->rowCount());
|
|
|
|
|
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
|
|
|
|
{
|
|
|
|
|
@@ -199,7 +206,12 @@ void SCountDlg::run()
|
|
|
|
|
if (GetColumn().isDateColumn(anCatalog[i]))
|
|
|
|
|
{
|
|
|
|
|
QDateTime date;
|
|
|
|
|
astr[i] = date.fromString(pCurrent->item(nCount,anCatalog[i])->text().trimmed(),"yyyy-MM-dd hh:mm:ss").date().toString("yyyy-MM-dd").trimmed();
|
|
|
|
|
QDate day = date.fromString(pCurrent->item(nCount,anCatalog[i])->text().trimmed(),"yyyy-MM-dd hh:mm:ss").date();
|
|
|
|
|
astr[i] = day.toString("yyyy-MM-dd").trimmed();
|
|
|
|
|
if(astr[i].isEmpty()) continue;
|
|
|
|
|
if (day.year() == 0) continue;
|
|
|
|
|
if (day < dateStart) dateStart=day;
|
|
|
|
|
if (day > dateEnd) dateEnd=day;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
astr[i] = pCurrent->item(nCount,anCatalog[i])->text().trimmed();
|
|
|
|
|
@@ -224,22 +236,52 @@ void SCountDlg::run()
|
|
|
|
|
strList.push_back(m_pCombo[0].currentText());
|
|
|
|
|
for (QSet<QString>::iterator i = setList.begin(); i != setList.end(); ++i)
|
|
|
|
|
strList.push_back(*i);
|
|
|
|
|
m_pTable->SetHeaderList(strList);
|
|
|
|
|
m_pTable->setRowCount(mapCount.size());
|
|
|
|
|
m_pTable->SetHeaderList(strList);
|
|
|
|
|
int nCount = 0;
|
|
|
|
|
m_dTotal = 0.0;
|
|
|
|
|
for (QMap<QString,QMap<QString,int> >::iterator i = mapCount.begin(); i != mapCount.end(); ++i)
|
|
|
|
|
{
|
|
|
|
|
int nCol = 0;
|
|
|
|
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(i.key()));
|
|
|
|
|
for (QSet<QString>::iterator j = setList.begin(); j != setList.end(); ++j)
|
|
|
|
|
if (GetColumn().isDateColumn(anCatalog[0]))
|
|
|
|
|
{
|
|
|
|
|
qDebug() << dateStart.daysTo(dateEnd);
|
|
|
|
|
m_pTable->setRowCount(dateStart.daysTo(dateEnd));
|
|
|
|
|
for (QDate now = dateStart; now < dateEnd ; now=now.addDays(1) )
|
|
|
|
|
{
|
|
|
|
|
if (i->contains(*j))
|
|
|
|
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(QString::number(i->value(*j))));
|
|
|
|
|
int nCol = 0;
|
|
|
|
|
QString str = now.toString("yyyy-MM-dd").trimmed();
|
|
|
|
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(str));
|
|
|
|
|
if (mapCount.contains(str))
|
|
|
|
|
{
|
|
|
|
|
for (QSet<QString>::iterator j = setList.begin(); j != setList.end(); ++j)
|
|
|
|
|
{
|
|
|
|
|
if (mapCount[str].contains(*j))
|
|
|
|
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(QString::number(mapCount[str].value(*j))));
|
|
|
|
|
else
|
|
|
|
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(QString::number(0)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(QString::number(0)));
|
|
|
|
|
{
|
|
|
|
|
for (;nCol < strList.size();nCol++)
|
|
|
|
|
m_pTable->setItem(nCount,nCol,new QTableWidgetItem(QString::number(0)));
|
|
|
|
|
}
|
|
|
|
|
nCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_pTable->setRowCount(mapCount.size());
|
|
|
|
|
for (QMap<QString,QMap<QString,int> >::iterator i = mapCount.begin(); i != mapCount.end(); ++i)
|
|
|
|
|
{
|
|
|
|
|
int nCol = 0;
|
|
|
|
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(i.key()));
|
|
|
|
|
for (QSet<QString>::iterator j = setList.begin(); j != setList.end(); ++j)
|
|
|
|
|
{
|
|
|
|
|
if (i->contains(*j))
|
|
|
|
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(QString::number(i->value(*j))));
|
|
|
|
|
else
|
|
|
|
|
m_pTable->setItem(nCount,nCol++,new QTableWidgetItem(QString::number(0)));
|
|
|
|
|
}
|
|
|
|
|
nCount++;
|
|
|
|
|
}
|
|
|
|
|
nCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -320,7 +362,29 @@ void SCountDlg::graph()
|
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
|
|
GetMainWindow()->m_graph.setHtml(m_strGraph.toUtf8(),QUrl("file:///"));
|
|
|
|
|
//GetMainWindow()->m_graph.settings()->setObjectCacheCapacities(0,0,0);
|
|
|
|
|
GetMainWindow()->m_graph.settings()->setObjectCacheCapacities(0,0,0);
|
|
|
|
|
GetMainWindow()->m_graph.repaint();
|
|
|
|
|
GetMainWindow()->m_graph.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCountDlg::save()
|
|
|
|
|
{
|
|
|
|
|
QFile file(QFileDialog::getSaveFileName(this,tr("Save Csv"), "", tr("Csv Files (*.csv)")));
|
|
|
|
|
if (!file.open(QIODevice::WriteOnly)) return;
|
|
|
|
|
QTextStream out(&file);
|
|
|
|
|
for (int i = 0; i < m_pTable->columnCount();i++)
|
|
|
|
|
out << m_pTable->horizontalHeaderItem(i)->text().toUtf8() << QString(",").toUtf8();
|
|
|
|
|
out << QString("\r\n").toUtf8();
|
|
|
|
|
GetMainWindow()->m_progress.setRange(0,m_pTable->rowCount());
|
|
|
|
|
for (int i = 0 ; i < m_pTable->rowCount() ; i++ )
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < m_pTable->columnCount();j++)
|
|
|
|
|
{
|
|
|
|
|
out << m_pTable->item(i,j)->text().trimmed().toUtf8() << QString(",").toUtf8();
|
|
|
|
|
}
|
|
|
|
|
out << QString("\r\n").toUtf8();
|
|
|
|
|
GetMainWindow()->m_progress.setValue(i);
|
|
|
|
|
GetMainWindow()->m_progress.repaint();
|
|
|
|
|
}
|
|
|
|
|
file.close();
|
|
|
|
|
}
|
|
|
|
|
|