2depth 추가
git-svn-id: svn://192.168.0.12/source@170 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
#include <QMenuBar>
|
||||
#include <QInputDialog>
|
||||
#include <QIntValidator>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
#define D_NOT_SELECT -1
|
||||
|
||||
@@ -966,6 +969,112 @@ void YMOneDepthWidget::SaveFile()
|
||||
file.close();
|
||||
}
|
||||
|
||||
void YMOneDepthWidget::SaveFileSimple()
|
||||
{
|
||||
QString strFilename = QFileDialog::getSaveFileName(0,"save file",QDir::currentPath(),
|
||||
"csv files (*.csv);;All files (*.*)",new QString("Text files (*.csv)"));
|
||||
if (strFilename.toLower().right(4) != QString(".csv"))
|
||||
strFilename += ".csv";
|
||||
QFile file(strFilename);
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
||||
|
||||
QTextStream out(&file);
|
||||
|
||||
STable* pTable = (STable*)((QTabWidget*)(m_ptwTable->currentWidget()))->currentWidget();
|
||||
int nCountIndex = pTable->columnCount() - 1;
|
||||
int nKeywordIndex = pTable->columnCount() - 2;
|
||||
|
||||
QString strCKeyword = m_pleCKeyword->text().trimmed();
|
||||
out << strCKeyword;
|
||||
|
||||
for (int i = 0; i < pTable->rowCount(); i++)
|
||||
{
|
||||
QString strKeyword = pTable->item(i, nKeywordIndex)->text().trimmed();
|
||||
int nCount = pTable->item(i, nCountIndex)->text().trimmed().toInt();
|
||||
for(int j = 0; j < nCount; j++)
|
||||
{
|
||||
out << "," << strKeyword;
|
||||
}
|
||||
|
||||
}
|
||||
out << endl;
|
||||
file.close();
|
||||
}
|
||||
|
||||
QMap<QString, int> YMOneDepthWidget::getResult()
|
||||
{
|
||||
return m_mapResult;
|
||||
}
|
||||
|
||||
|
||||
void YMOneDepthWidget::TestUpload()
|
||||
{
|
||||
//QMap<QString, int> mapResult = m_mapResult;
|
||||
|
||||
QString strCKeyword = getCenterKeyword();
|
||||
//qDebug() << "executed";
|
||||
QString strjson = "{\n\t\"name\":\" " + strCKeyword + "\",\n";
|
||||
strjson += ("\t\"children\": [\n");
|
||||
|
||||
STable* pTable = (STable*)((QTabWidget*)(m_ptwTable->currentWidget()))->currentWidget();
|
||||
int nCountIndex = pTable->columnCount() - 1;
|
||||
int nKeywordIndex = pTable->columnCount() - 2;
|
||||
|
||||
for (int i = 0; i < pTable->rowCount(); i++)
|
||||
{
|
||||
QString strKeyword = pTable->item(i, nKeywordIndex)->text().trimmed();
|
||||
int nCount = pTable->item(i, nCountIndex)->text().trimmed().toInt();
|
||||
strjson += ("\t{\"name\": \"" + strKeyword + "\", \"size\": " + QString::number(nCount) + "},\n");
|
||||
}
|
||||
strjson = strjson.trimmed();
|
||||
strjson = strjson.left(strjson.length() - 1);
|
||||
strjson += "\n\t]\n}";
|
||||
|
||||
/*
|
||||
QFile file("c:/data/jsontest.txt");
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
||||
QTextStream out(&file);
|
||||
|
||||
out << strjson;
|
||||
|
||||
file.close();
|
||||
*/
|
||||
|
||||
|
||||
|
||||
QSqlDatabase dbWeb = QSqlDatabase::addDatabase("QMYSQL");
|
||||
dbWeb.setHostName("db.big-bird.co.kr");
|
||||
dbWeb.setUserName("concepters");
|
||||
dbWeb.setPassword("con97996655");
|
||||
dbWeb.setDatabaseName("dbconcepters");
|
||||
|
||||
int nCompany = 90;
|
||||
|
||||
if(!dbWeb.open())
|
||||
qDebug() << "DB open Failed";
|
||||
|
||||
|
||||
|
||||
QSqlQuery query(QSqlDatabase::database(dbWeb.connectionName()));
|
||||
|
||||
QString strquery;
|
||||
|
||||
strquery = "insert into stats_json (jdata, company_num) values ('" + strjson + "', " + QString::number(nCompany) + ")";
|
||||
|
||||
if(!query.exec(strquery.toUtf8()))
|
||||
{
|
||||
strquery = "update stats_json set jdata='" + strjson + "' where company_num=" + QString::number(nCompany);
|
||||
if(!query.exec(strquery.toUtf8()))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dbWeb.close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
QString YMOneDepthWidget::getCenterKeyword()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user