테이블 복사 및 부분 복사 추가
git-svn-id: svn://192.168.0.12/source@62 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -64,7 +64,7 @@ QGroupBox *Widget::setKeywordWidgets()
|
||||
m_ptableKeyword = new QTableView;
|
||||
m_ptableKeyword->setModel(m_pmodelKeyword);
|
||||
m_ptableKeyword->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_ptableKeyword->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_ptableKeyword->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
vlayout->addWidget(m_ptableKeyword);
|
||||
|
||||
connect(m_ptableKeyword->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
|
||||
@@ -180,6 +180,66 @@ QGroupBox *Widget::setGroupWidgets()
|
||||
connect(pExport, SIGNAL(released()),this, SLOT(on_group_button_export()));
|
||||
vlayout->addLayout(hlayout);
|
||||
}
|
||||
|
||||
{
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
m_pleCopyFrom = new QLineEdit();
|
||||
m_pleCopyTo = new QLineEdit();
|
||||
m_pleCopyFrom->setReadOnly(true);
|
||||
m_pleCopyTo->setReadOnly(true);
|
||||
QPushButton *pCopyAddFrom = new QPushButton("Add");
|
||||
QPushButton *pCopyAddTo = new QPushButton("Add");
|
||||
QPushButton *pStart = new QPushButton("Start");
|
||||
QPushButton *pClear = new QPushButton("Clear");
|
||||
|
||||
|
||||
hlayout->addWidget(new QLabel("Copy From: "));
|
||||
hlayout->addWidget(m_pleCopyFrom);
|
||||
hlayout->addWidget(pCopyAddFrom);
|
||||
hlayout->addWidget(new QLabel("To :"));
|
||||
hlayout->addWidget(m_pleCopyTo);
|
||||
hlayout->addWidget(pCopyAddTo);
|
||||
hlayout->addWidget(pStart);
|
||||
hlayout->addWidget(pClear);
|
||||
|
||||
connect(pStart, SIGNAL(released()),this, SLOT(on_group_button_copy_start()));
|
||||
connect(pClear, SIGNAL(released()),this, SLOT(on_group_button_copy_clear()));
|
||||
connect(pCopyAddFrom, SIGNAL(released()),this, SLOT(on_group_button_copy_from()));
|
||||
connect(pCopyAddTo, SIGNAL(released()),this, SLOT(on_group_button_copy_to()));
|
||||
|
||||
vlayout->addLayout(hlayout);
|
||||
}
|
||||
|
||||
{
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
m_pchbDate = new QCheckBox();
|
||||
|
||||
m_pdeCopyStart = new QDateEdit(QDate::currentDate());
|
||||
m_pdeCopyEnd = new QDateEdit(QDate::currentDate());
|
||||
|
||||
m_pdeCopyStart->setDateRange(QDate(2003, 5, 20),QDate::currentDate());
|
||||
m_pdeCopyEnd->setDateRange(QDate(2003, 5, 20),QDate::currentDate());
|
||||
|
||||
QCalendarWidget *pCalender = new QCalendarWidget();
|
||||
m_pdeCopyStart->setCalendarWidget(pCalender);
|
||||
m_pdeCopyStart->setCalendarPopup(true);
|
||||
|
||||
m_pdeCopyEnd->setCalendarWidget(pCalender);
|
||||
m_pdeCopyEnd->setCalendarPopup(true);
|
||||
|
||||
hlayout->addWidget(new QLabel("Date Check: "));
|
||||
hlayout->addWidget(m_pchbDate);
|
||||
hlayout->addWidget(new QLabel("Start"));
|
||||
hlayout->addWidget(m_pdeCopyStart);
|
||||
hlayout->addWidget(new QLabel("End"));
|
||||
hlayout->addWidget(m_pdeCopyEnd);
|
||||
|
||||
hlayout->setAlignment(Qt::AlignLeft);
|
||||
|
||||
vlayout->addLayout(hlayout);
|
||||
|
||||
|
||||
}
|
||||
QGroupBox *groupBox = new QGroupBox("Group");
|
||||
groupBox->setAlignment(Qt::AlignLeft|Qt::AlignTop);
|
||||
groupBox->setLayout(vlayout);
|
||||
@@ -534,6 +594,163 @@ void Widget::on_crawling_button_delete()
|
||||
"FROM crawling _crawling INNER JOIN keyword _keyword ON _crawling.keyword_id = _keyword.id "
|
||||
"inner join datagroup _datagroup on _crawling.datagroup_id = _datagroup.id");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Widget::on_group_button_copy_clear()
|
||||
{
|
||||
m_pleCopyFrom->setText("");
|
||||
m_pleCopyTo->setText("");
|
||||
}
|
||||
|
||||
void Widget::on_group_button_copy_from()
|
||||
{
|
||||
QString strGroupId;
|
||||
foreach (QModelIndex index , m_ptableGroup->selectionModel()->selectedIndexes())
|
||||
strGroupId = m_pmodelGroup->record(index.row()).value("id").toString();
|
||||
if (strGroupId.isEmpty()) return;
|
||||
|
||||
QString str = m_pleCopyFrom->text();
|
||||
|
||||
|
||||
QStringList strList = str.split(";");
|
||||
|
||||
foreach(QString _str, strList)
|
||||
{
|
||||
if(_str.compare(strGroupId) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
QString strTo = m_pleCopyTo->text();
|
||||
strList = strTo.split(";");
|
||||
|
||||
foreach(QString _str, strList)
|
||||
{
|
||||
if(_str.compare(strGroupId) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
str += (strGroupId + ";");
|
||||
m_pleCopyFrom->setText(str);
|
||||
}
|
||||
|
||||
|
||||
void Widget::on_group_button_copy_to()
|
||||
{
|
||||
QString strGroupId;
|
||||
foreach (QModelIndex index , m_ptableGroup->selectionModel()->selectedIndexes())
|
||||
strGroupId = m_pmodelGroup->record(index.row()).value("id").toString();
|
||||
if (strGroupId.isEmpty()) return;
|
||||
|
||||
QString str = m_pleCopyTo->text();
|
||||
QStringList strList = str.split(";");
|
||||
|
||||
foreach(QString _str, strList)
|
||||
{
|
||||
if(_str.compare(strGroupId) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
QString strFrom = m_pleCopyFrom->text();
|
||||
strList = strFrom.split(";");
|
||||
|
||||
foreach(QString _str, strList)
|
||||
{
|
||||
if(_str.compare(strGroupId) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
str += (strGroupId + ";");
|
||||
m_pleCopyTo->setText(str);
|
||||
}
|
||||
|
||||
void Widget::on_group_button_copy_start()
|
||||
{
|
||||
QString strQuery;
|
||||
QString strQueryUtf;
|
||||
QSqlQuery query;
|
||||
|
||||
QString strFrom = m_pleCopyFrom->text();
|
||||
QString strTo = m_pleCopyTo->text();
|
||||
|
||||
if(strFrom.length() == 0)
|
||||
return;
|
||||
if(strTo.length() == 0)
|
||||
return;
|
||||
|
||||
QStringList strListFrom = strFrom.split(";",QString::SkipEmptyParts);
|
||||
QStringList strListTo = strTo.split(";",QString::SkipEmptyParts);
|
||||
|
||||
if(strListFrom.length() == 0)
|
||||
return;
|
||||
if(strListTo.length() == 0)
|
||||
return;
|
||||
|
||||
bool ok;
|
||||
for(int i = 0; i < strListTo.length(); i++)
|
||||
{
|
||||
strListTo.at(i).toInt(&ok);
|
||||
if(!ok)
|
||||
return;
|
||||
for(int j = 0; j < strListFrom.length(); j++)
|
||||
{
|
||||
|
||||
strListFrom.at(i).toInt(&ok);
|
||||
if(!ok)
|
||||
return;
|
||||
if(m_pchbDate->isChecked())
|
||||
{
|
||||
strQuery = "insert into ";
|
||||
strQuery += ("data_" + strListTo.at(i).trimmed());
|
||||
strQuery += (" (select platform_name,platform_form,platform_title,article_form,article_parent,article_id,article_nickname,article_title,article_data,article_url,article_hit,article_date,article_order,article_profile,article_profileurl,platform_id,keyword_id,reply_url from data_" + strListFrom.at(i).trimmed());
|
||||
strQuery += (" where article_url in (select distinct article_url from data_" + strListFrom.at(i).trimmed());
|
||||
strQuery += (" where article_date between '" + m_pdeCopyStart->date().toString("yyyy-MM-dd") + " 00:00:00' and '");
|
||||
strQuery += (m_pdeCopyEnd->date().toString("yyyy-MM-dd") + " 23:59:59' and article_form='body')");
|
||||
strQuery += (" and article_date >= '" + m_pdeCopyStart->date().toString("yyyy-MM-dd") + " 00:00:00' and article_date is not null)");
|
||||
|
||||
//insert into data_to (select * from data_67 where article_url in (select distinct article_url from data_67 where article_date between '2015-02-01 00:00:00' and '2015-03-21 23:59:59' and article_form='body') and article_date >= '2015-02-01 00:00:00' and article_date is not null)
|
||||
/*
|
||||
strQuery = "insert into ";
|
||||
strQuery += ("data_" + strListTo.at(i).trimmed());
|
||||
strQuery += (" (select platform_name,platform_form,platform_title,article_form,article_parent,article_id,article_nickname,article_title,article_data,article_url,article_hit,article_date,article_order,article_profile,article_profileurl,platform_id,keyword_id,reply_url from data_" + strListFrom.at(i).trimmed());
|
||||
strQuery += (" where article_url in (select distinct article_url from data_" + strListFrom.at(i).trimmed());
|
||||
strQuery += (" where article_date between '" + m_pdeCopyStart->date().toString("yyyy-MM-dd") + " 00:00:00' and '");
|
||||
strQuery += (m_pdeCopyEnd->date().toString("yyyy-MM-dd") + " 23:59:59' and article_form='body'))");
|
||||
|
||||
|
||||
*/
|
||||
//m_pdeStart->date().toString("yyyy-MM-dd");
|
||||
//insert into data_92
|
||||
//(select * from data_93 where article_url in
|
||||
//(select distinct article_url from data_93 where article_date between '2015-01-01 00:00:00' and '2015-01-01 23:59:59') and article_date >= '2015-01-01 00:00:00' and article_date is not null);
|
||||
}
|
||||
else
|
||||
{
|
||||
strQuery = "insert into ";
|
||||
strQuery += ("data_" + strListTo.at(i).trimmed());
|
||||
strQuery += " (select platform_name,platform_form,platform_title,article_form,article_parent,article_id,article_nickname,article_title,article_data,article_url,article_hit,article_date,article_order,article_profile,article_profileurl,platform_id,keyword_id,reply_url from ";
|
||||
strQuery += ("data_" + strListFrom.at(j).trimmed());
|
||||
strQuery += " where (article_url, article_order) not in (select article_url, article_order from ";
|
||||
strQuery += ("data_" + strListTo.at(i).trimmed());
|
||||
strQuery += "))";
|
||||
//insert into data_to from
|
||||
//(select * from data_from where
|
||||
//(article_url, article_order) not in (select article_url, article_order from data_to))
|
||||
}
|
||||
qDebug(strQuery.toLatin1());
|
||||
strQueryUtf = strQuery.toUtf8();
|
||||
if(query.exec(strQueryUtf) == false)
|
||||
{
|
||||
m_pleCopyFrom->setText("Error");
|
||||
m_pleCopyTo->setText("Error");
|
||||
qDebug(query.lastError().text().toLatin1());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_pleCopyFrom->setText("Success");
|
||||
m_pleCopyTo->setText("Sucess");
|
||||
|
||||
|
||||
// on_group_button_copy_clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user