778 lines
25 KiB
C++
778 lines
25 KiB
C++
/****************************************************************************
|
|
**
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
** Contact: http://www.qt-project.org/legal
|
|
**
|
|
** This file is part of the examples of the Qt Toolkit.
|
|
**
|
|
** $QT_BEGIN_LICENSE:BSD$
|
|
** You may use this file under the terms of the BSD license as follows:
|
|
**
|
|
** "Redistribution and use in source and binary forms, with or without
|
|
** modification, are permitted provided that the following conditions are
|
|
** met:
|
|
** * Redistributions of source code must retain the above copyright
|
|
** notice, this list of conditions and the following disclaimer.
|
|
** * Redistributions in binary form must reproduce the above copyright
|
|
** notice, this list of conditions and the following disclaimer in
|
|
** the documentation and/or other materials provided with the
|
|
** distribution.
|
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
|
** of its contributors may be used to endorse or promote products derived
|
|
** from this software without specific prior written permission.
|
|
**
|
|
**
|
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
**
|
|
** $QT_END_LICENSE$
|
|
**
|
|
****************************************************************************/
|
|
|
|
#include <QtWidgets>
|
|
|
|
#include "mainwindow.h"
|
|
#include "widget.h"
|
|
#include "stable.h"
|
|
#include "sanaly1.h"
|
|
#include "sdictionary.h"
|
|
//! [0]
|
|
MainWindow::MainWindow()
|
|
{
|
|
QWidget *widget = new QWidget;
|
|
setCentralWidget(widget);
|
|
p_qwDB = new Widget;
|
|
//p_qwFile = new QWidget;
|
|
//p_qwAnalyzed1 = new QWidget;
|
|
//p_qwText = new QWidget;
|
|
p_qwAnalyzer1 = new SAnaly1;
|
|
//p_qwAnalyzer2 = new QWidget;
|
|
p_qwDict = new SDictionary;
|
|
|
|
|
|
m_ptwSource = new QTabWidget;
|
|
m_ptwSource->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
m_ptwSource->addTab(p_qwDB,"DB");
|
|
//m_ptwSource->addTab(p_qwFile,"File");
|
|
//m_ptwSource->addTab(p_qwText,"Text");
|
|
//m_ptwSource->addTab(p_qwAnalyzed1,"Analyzed1");
|
|
|
|
|
|
m_ptwResult = new QTabWidget;
|
|
m_ptwResult->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
m_ptwResult->addTab(p_qwAnalyzer1, "Analysis1");
|
|
//m_ptwResult->addTab(p_qwAnalyzer2, "Analysis2");
|
|
|
|
QHBoxLayout *layout = new QHBoxLayout;
|
|
|
|
layout->setMargin(5);
|
|
layout->addWidget(m_ptwSource);
|
|
layout->addWidget(m_ptwResult);
|
|
|
|
widget->setLayout(layout);
|
|
//! [1]
|
|
|
|
//! [2]
|
|
createActions();
|
|
createMenus();
|
|
|
|
QString message = tr("A context menu is available by right-clicking");
|
|
statusBar()->showMessage(message);
|
|
|
|
setWindowTitle(tr("Morphere Analyzer"));
|
|
setMinimumSize(800, 600);
|
|
resize(800, 600);
|
|
//(STable*)(p_qwDB->GetTabWidget()->widget(1));
|
|
}
|
|
//! [2]
|
|
|
|
//! [3]
|
|
/*
|
|
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
|
{
|
|
QMenu menu(this);
|
|
menu.addAction(cutAct);
|
|
menu.addAction(copyAct);
|
|
menu.addAction(pasteAct);
|
|
menu.exec(event->globalPos());
|
|
}
|
|
*/
|
|
//! [3]
|
|
/*
|
|
void MainWindow::newFile()
|
|
{
|
|
}
|
|
|
|
void MainWindow::open()
|
|
{
|
|
}
|
|
|
|
void MainWindow::save()
|
|
{
|
|
}
|
|
|
|
void MainWindow::print()
|
|
{
|
|
}
|
|
|
|
void MainWindow::undo()
|
|
{
|
|
}
|
|
|
|
void MainWindow::redo()
|
|
{
|
|
}
|
|
|
|
void MainWindow::cut()
|
|
{
|
|
}
|
|
|
|
void MainWindow::copy()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::paste()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::bold()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::italic()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::leftAlign()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::rightAlign()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::justify()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::center()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::setLineSpacing()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::setParagraphSpacing()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::about()
|
|
{
|
|
|
|
QMessageBox::about(this, tr("About Menu"),
|
|
tr("The <b>Menu</b> example shows how to create "
|
|
"menu-bar menus and context menus."));
|
|
}
|
|
|
|
void MainWindow::aboutQt()
|
|
{
|
|
|
|
}
|
|
*/
|
|
//! [4]
|
|
void MainWindow::createActions()
|
|
{
|
|
//! [5]
|
|
//!
|
|
actDBNew = new QAction(tr("&New DB "), this);
|
|
actDBNew->setStatusTip(tr("Create a new DB"));
|
|
connect(actDBNew, SIGNAL(triggered()), this, SLOT(newDB()));
|
|
|
|
actDBCsvImport = new QAction(tr("DB - CSV Import"), this);
|
|
actDBCsvImport->setStatusTip(tr("Import DB as a csv file"));
|
|
connect(actDBCsvImport, SIGNAL(triggered()), this, SLOT(importDB()));
|
|
|
|
actDBCsvExport = new QAction(tr("DB - CSV Export"), this);
|
|
actDBCsvExport->setStatusTip(tr("Export DB as a csv file"));
|
|
connect(actDBCsvExport, SIGNAL(triggered()), this, SLOT(exportDB()));
|
|
|
|
actMorphereOriginalExport = new QAction(tr("Morphere - CSV Export(Raw Result)"), this);
|
|
actMorphereOriginalExport->setStatusTip(tr("Export Morphere as a csv file"));
|
|
connect(actMorphereOriginalExport, SIGNAL(triggered()), this, SLOT(exportOriginalMorphere()));
|
|
|
|
actMorphereExport = new QAction(tr("Morphere - CSV Export"), this);
|
|
actMorphereExport->setStatusTip(tr("Export Morphere as a csv file"));
|
|
connect(actMorphereExport, SIGNAL(triggered()), this, SLOT(exportMorphere()));
|
|
|
|
actMorphereImport = new QAction(tr("Morphere - CSV Import"), this);
|
|
actMorphereImport->setStatusTip(tr("Import Morphere as a csv file"));
|
|
connect(actMorphereImport, SIGNAL(triggered()), this, SLOT(importMorphere()));
|
|
|
|
|
|
|
|
actExit = new QAction(tr("Exit"), this);
|
|
actExit->setStatusTip(tr("Exit the application"));
|
|
connect(actExit, SIGNAL(triggered()), this, SLOT(close()));
|
|
|
|
actAnalyze = new QAction(tr("Analyze"), this);
|
|
actAnalyze->setStatusTip(tr("Analyze"));
|
|
connect(actAnalyze, SIGNAL(triggered()), this, SLOT(slotAnalyze()));
|
|
|
|
actDictionary = new QAction(tr("Dictionary"), this);
|
|
actAnalyze->setStatusTip(tr("Execute Dictionary Widget"));
|
|
connect(actDictionary, SIGNAL(triggered()), this, SLOT(slotDictionary()));
|
|
/*
|
|
//!
|
|
newAct = new QAction(tr("&New"), this);
|
|
newAct->setShortcuts(QKeySequence::New);
|
|
newAct->setStatusTip(tr("Create a new file"));
|
|
connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
|
|
//! [4]
|
|
|
|
openAct = new QAction(tr("&Open..."), this);
|
|
openAct->setShortcuts(QKeySequence::Open);
|
|
openAct->setStatusTip(tr("Open an existing file"));
|
|
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
|
|
//! [5]
|
|
|
|
saveAct = new QAction(tr("&Save"), this);
|
|
saveAct->setShortcuts(QKeySequence::Save);
|
|
saveAct->setStatusTip(tr("Save the document to disk"));
|
|
connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
|
|
|
|
printAct = new QAction(tr("&Print..."), this);
|
|
printAct->setShortcuts(QKeySequence::Print);
|
|
printAct->setStatusTip(tr("Print the document"));
|
|
connect(printAct, SIGNAL(triggered()), this, SLOT(print()));
|
|
|
|
exitAct = new QAction(tr("E&xit"), this);
|
|
exitAct->setShortcuts(QKeySequence::Quit);
|
|
exitAct->setStatusTip(tr("Exit the application"));
|
|
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
|
|
|
undoAct = new QAction(tr("&Undo"), this);
|
|
undoAct->setShortcuts(QKeySequence::Undo);
|
|
undoAct->setStatusTip(tr("Undo the last operation"));
|
|
connect(undoAct, SIGNAL(triggered()), this, SLOT(undo()));
|
|
|
|
redoAct = new QAction(tr("&Redo"), this);
|
|
redoAct->setShortcuts(QKeySequence::Redo);
|
|
redoAct->setStatusTip(tr("Redo the last operation"));
|
|
connect(redoAct, SIGNAL(triggered()), this, SLOT(redo()));
|
|
|
|
cutAct = new QAction(tr("Cu&t"), this);
|
|
cutAct->setShortcuts(QKeySequence::Cut);
|
|
cutAct->setStatusTip(tr("Cut the current selection's contents to the "
|
|
"clipboard"));
|
|
connect(cutAct, SIGNAL(triggered()), this, SLOT(cut()));
|
|
|
|
copyAct = new QAction(tr("&Copy"), this);
|
|
copyAct->setShortcuts(QKeySequence::Copy);
|
|
copyAct->setStatusTip(tr("Copy the current selection's contents to the "
|
|
"clipboard"));
|
|
connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));
|
|
|
|
pasteAct = new QAction(tr("&Paste"), this);
|
|
pasteAct->setShortcuts(QKeySequence::Paste);
|
|
pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
|
|
"selection"));
|
|
connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste()));
|
|
|
|
boldAct = new QAction(tr("&Bold"), this);
|
|
boldAct->setCheckable(true);
|
|
boldAct->setShortcut(QKeySequence::Bold);
|
|
boldAct->setStatusTip(tr("Make the text bold"));
|
|
connect(boldAct, SIGNAL(triggered()), this, SLOT(bold()));
|
|
|
|
QFont boldFont = boldAct->font();
|
|
boldFont.setBold(true);
|
|
boldAct->setFont(boldFont);
|
|
|
|
italicAct = new QAction(tr("&Italic"), this);
|
|
italicAct->setCheckable(true);
|
|
italicAct->setShortcut(QKeySequence::Italic);
|
|
italicAct->setStatusTip(tr("Make the text italic"));
|
|
connect(italicAct, SIGNAL(triggered()), this, SLOT(italic()));
|
|
|
|
QFont italicFont = italicAct->font();
|
|
italicFont.setItalic(true);
|
|
italicAct->setFont(italicFont);
|
|
|
|
setLineSpacingAct = new QAction(tr("Set &Line Spacing..."), this);
|
|
setLineSpacingAct->setStatusTip(tr("Change the gap between the lines of a "
|
|
"paragraph"));
|
|
connect(setLineSpacingAct, SIGNAL(triggered()), this, SLOT(setLineSpacing()));
|
|
|
|
setParagraphSpacingAct = new QAction(tr("Set &Paragraph Spacing..."), this);
|
|
setParagraphSpacingAct->setStatusTip(tr("Change the gap between paragraphs"));
|
|
connect(setParagraphSpacingAct, SIGNAL(triggered()),
|
|
this, SLOT(setParagraphSpacing()));
|
|
|
|
aboutAct = new QAction(tr("&About"), this);
|
|
aboutAct->setStatusTip(tr("Show the application's About box"));
|
|
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
|
|
|
aboutQtAct = new QAction(tr("About &Qt"), this);
|
|
aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
|
|
connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
|
connect(aboutQtAct, SIGNAL(triggered()), this, SLOT(aboutQt()));
|
|
|
|
leftAlignAct = new QAction(tr("&Left Align"), this);
|
|
leftAlignAct->setCheckable(true);
|
|
leftAlignAct->setShortcut(tr("Ctrl+L"));
|
|
leftAlignAct->setStatusTip(tr("Left align the selected text"));
|
|
connect(leftAlignAct, SIGNAL(triggered()), this, SLOT(leftAlign()));
|
|
|
|
rightAlignAct = new QAction(tr("&Right Align"), this);
|
|
rightAlignAct->setCheckable(true);
|
|
rightAlignAct->setShortcut(tr("Ctrl+R"));
|
|
rightAlignAct->setStatusTip(tr("Right align the selected text"));
|
|
connect(rightAlignAct, SIGNAL(triggered()), this, SLOT(rightAlign()));
|
|
|
|
justifyAct = new QAction(tr("&Justify"), this);
|
|
justifyAct->setCheckable(true);
|
|
justifyAct->setShortcut(tr("Ctrl+J"));
|
|
justifyAct->setStatusTip(tr("Justify the selected text"));
|
|
connect(justifyAct, SIGNAL(triggered()), this, SLOT(justify()));
|
|
|
|
centerAct = new QAction(tr("&Center"), this);
|
|
centerAct->setCheckable(true);
|
|
centerAct->setShortcut(tr("Ctrl+E"));
|
|
centerAct->setStatusTip(tr("Center the selected text"));
|
|
connect(centerAct, SIGNAL(triggered()), this, SLOT(center()));
|
|
|
|
//! [6] //! [7]
|
|
alignmentGroup = new QActionGroup(this);
|
|
alignmentGroup->addAction(leftAlignAct);
|
|
alignmentGroup->addAction(rightAlignAct);
|
|
alignmentGroup->addAction(justifyAct);
|
|
alignmentGroup->addAction(centerAct);
|
|
leftAlignAct->setChecked(true);
|
|
//! [6]
|
|
//! */
|
|
}
|
|
//! [7]
|
|
|
|
//! [8]
|
|
//!
|
|
void MainWindow::createMenus()
|
|
{
|
|
//! [9] //! [10]
|
|
menuFile = menuBar()->addMenu(tr("File"));
|
|
|
|
menuFile->addAction(actDBNew);
|
|
menuFile->addSeparator();
|
|
//! [9]
|
|
menuFile->addAction(actDBCsvImport);
|
|
//! [10]
|
|
menuFile->addAction(actDBCsvExport);
|
|
menuFile->addSeparator();
|
|
menuFile->addAction(actMorphereImport);
|
|
menuFile->addAction(actMorphereExport);
|
|
menuFile->addAction(actMorphereOriginalExport);
|
|
|
|
menuFile->addSeparator();
|
|
menuFile->addAction(actExit);
|
|
//! [11]
|
|
|
|
//! [11]
|
|
menuDictionary = menuBar()->addMenu(tr("Dictionary"));
|
|
menuDictionary->addAction(actDictionary);
|
|
|
|
menuAnalyze = menuBar()->addMenu(tr("Analyze"));
|
|
menuAnalyze->addAction(actAnalyze);
|
|
|
|
|
|
/*
|
|
editMenu = menuBar()->addMenu(tr("&Edit"));
|
|
editMenu->addAction(undoAct);
|
|
editMenu->addAction(redoAct);
|
|
editMenu->addSeparator();
|
|
editMenu->addAction(cutAct);
|
|
editMenu->addAction(copyAct);
|
|
editMenu->addAction(pasteAct);
|
|
editMenu->addSeparator();
|
|
|
|
helpMenu = menuBar()->addMenu(tr("&Help"));
|
|
helpMenu->addAction(aboutAct);
|
|
helpMenu->addAction(aboutQtAct);
|
|
//! [8]
|
|
|
|
//! [12]
|
|
formatMenu = editMenu->addMenu(tr("&Format"));
|
|
formatMenu->addAction(boldAct);
|
|
formatMenu->addAction(italicAct);
|
|
formatMenu->addSeparator()->setText(tr("Alignment"));
|
|
formatMenu->addAction(leftAlignAct);
|
|
formatMenu->addAction(rightAlignAct);
|
|
formatMenu->addAction(justifyAct);
|
|
formatMenu->addAction(centerAct);
|
|
formatMenu->addSeparator();
|
|
formatMenu->addAction(setLineSpacingAct);
|
|
formatMenu->addAction(setParagraphSpacingAct);
|
|
*/
|
|
}
|
|
//! [12]
|
|
|
|
|
|
void MainWindow::newDB()
|
|
{
|
|
p_qwDB->FileNew();
|
|
}
|
|
|
|
void MainWindow::importDB()
|
|
{
|
|
p_qwDB->FileImport();
|
|
}
|
|
|
|
void MainWindow::exportDB()
|
|
{
|
|
p_qwDB->FileExport();
|
|
}
|
|
|
|
void MainWindow::importMorphere()
|
|
{
|
|
qDebug() << "import is executed";
|
|
p_qwAnalyzer1->FileImport();
|
|
ViewResult();
|
|
}
|
|
|
|
void MainWindow::exportMorphere()
|
|
{
|
|
p_qwAnalyzer1->FileExport();
|
|
}
|
|
|
|
void MainWindow::exportOriginalMorphere()
|
|
{
|
|
|
|
QString strFilename = QFileDialog::getSaveFileName(0,"Exoprt 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);
|
|
|
|
/*
|
|
out << "#Head#,";
|
|
for (int nCount = 0;nCount < pCurrent->columnCount() ;nCount++ )
|
|
out << pCurrent->horizontalHeaderItem(nCount)->text() << ",";
|
|
|
|
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
|
*/
|
|
|
|
for( QMap<QString,QMap<QString,QMap<int, QString> > >::iterator iterPos = p_qwAnalyzer1->m_mapViewResult.begin(); iterPos != p_qwAnalyzer1->m_mapViewResult.end(); iterPos++)
|
|
{
|
|
for(QMap<QString, QMap<int, QString> >::iterator iterPos2 = iterPos.value().begin(); iterPos2 != iterPos.value().end(); iterPos2++)
|
|
{
|
|
QMapIterator<int, QString> i(p_qwAnalyzer1->m_mapViewResult[iterPos.key()][iterPos2.key()]);
|
|
i.toBack();
|
|
while(i.hasPrevious())
|
|
{
|
|
i.previous();
|
|
out << "\"" << iterPos.key() << "\"" << ",";
|
|
out << "\"" << iterPos2.key() << "\"" << ",";
|
|
out << "\"" << i.value() << "\"" << ",";
|
|
out << "\"" << i.key() << "\"" << "\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
file.close();
|
|
|
|
/*
|
|
for( QMap<QString,QMap<QString,QMap<int, QString> > >::iterator iterPos = p_qwAnalyzer1->m_mapViewResult.begin(); iterPos != p_qwAnalyzer1->m_mapViewResult.end(); iterPos++)
|
|
{
|
|
for(QMap<QString, QMap<int, QString> >::iterator iterPos2 = iterPos.value().begin(); iterPos2 != iterPos.value().end(); iterPos2++)
|
|
{
|
|
for(QMap<int, QString>::iterator iterPos3 = iterPos2.value().begin();iterPos3 != iterPos2.value().end(); iterPos3++)
|
|
{
|
|
out2 << iterPos.key() << "," << iterPos2.key() << "," << iterPos3.key() << "," << iterPos3.value() << "\n";
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
for( QMap<QString,QMap<QString,QMap<int, QString> > >::iterator iterPos = p_qwAnalyzer1->m_mapViewResult.begin(); iterPos != p_qwAnalyzer1->m_mapViewResult.end(); iterPos++)
|
|
{
|
|
for(QMap<QString, QMap<int, QString> >::iterator iterPos2 = iterPos.value().begin(); iterPos2 != iterPos.value().end(); iterPos2++)
|
|
{
|
|
QMapIterator<int, QString> i(p_qwAnalyzer1->m_mapViewResult[iterPos.key()][iterPos2.key()]);
|
|
i.toBack();
|
|
while(i.hasPrevious())
|
|
{
|
|
i.previous();
|
|
out2 << iterPos.key() << "," << iterPos2.key() << "," << i.key() << "," << i.value() << "\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
QFile file("result.txt");
|
|
|
|
if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
qDebug() << "File read error";
|
|
|
|
return ;
|
|
}
|
|
QTextStream out(&file);
|
|
|
|
for(QMap<QString, int>::iterator iterPos = p_qwAnalyzer1->m_TotalResult.begin(); iterPos != p_qwAnalyzer1->m_TotalResult.end(); iterPos++)
|
|
{
|
|
QString strkey = iterPos.key();
|
|
QStringList strlistKey = strkey.split("~!@");
|
|
foreach(QString str, strlistKey)
|
|
{
|
|
out << str << ",";
|
|
}
|
|
out << iterPos.value() << "\n";
|
|
}
|
|
|
|
file.close();
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
void MainWindow::slotAnalyze()
|
|
{
|
|
QMessageBox msg;
|
|
msg.setText("Please choose...");
|
|
msg.setModal(true);
|
|
QPushButton *pbTitle = msg.addButton("Title",QMessageBox::ActionRole);
|
|
QPushButton *pbBody = msg.addButton("Body",QMessageBox::ActionRole);
|
|
QPushButton *pbAll = msg.addButton("ALL",QMessageBox::ActionRole);
|
|
QPushButton *pbPlatformTitle = msg.addButton("Platform Title",QMessageBox::ActionRole);
|
|
int setbody;
|
|
msg.exec();
|
|
if (msg.clickedButton() == pbTitle) { setbody = 0; }
|
|
else if (msg.clickedButton() == pbBody) { setbody = 1; }
|
|
else if (msg.clickedButton() == pbAll) { setbody = 2; }
|
|
else if (msg.clickedButton() == pbPlatformTitle) { setbody = 3; }
|
|
|
|
QMessageBox msg2;
|
|
msg2.setText("Please wait...");
|
|
msg2.setVisible(true);
|
|
|
|
for(int i = 0; i < 16;i++)
|
|
{
|
|
p_qwAnalyzer1->m_HashResult[i].clear();
|
|
}
|
|
//p_qwAnalyzer1->MemClear();
|
|
p_qwAnalyzer1->m_mapViewResult.clear();
|
|
p_qwAnalyzer1->m_TotalResult.clear();
|
|
|
|
if(m_ptwResult->currentIndex() == 0)
|
|
{
|
|
ExecThread(setbody);
|
|
EmergeThreadResult();
|
|
SortViewResult();
|
|
ViewResult();
|
|
}
|
|
msg2.setVisible(false);
|
|
}
|
|
|
|
void MainWindow::slotDictionary()
|
|
{
|
|
p_qwDict->show();
|
|
p_qwDict->repaint();
|
|
}
|
|
|
|
void MainWindow::ExecThread(int _setBodyTitle)
|
|
{
|
|
int nCount = 0;
|
|
m_pThread = new AnalyzerThread*[p_qwAnalyzer1->getThread()];
|
|
for(int i=0;i<p_qwAnalyzer1->getThread();i++)
|
|
{
|
|
m_pThread[i] = new AnalyzerThread(mutex, i, nCount);
|
|
m_pThread[i]->setParametersfromWidget(p_qwAnalyzer1,m_ptwResult->currentIndex());
|
|
m_pThread[i]->setWidget(p_qwDB);
|
|
m_pThread[i]->setPosBody(p_qwDB->getBodyPosition());
|
|
m_pThread[i]->setPosDate(p_qwDB->getDatePosition());
|
|
m_pThread[i]->setPosTitle(p_qwDB->getTitlePosition());
|
|
m_pThread[i]->setPosPlatformTitle(p_qwDB->getPlatformTitlePosition());
|
|
m_pThread[i]->setTitleBody(_setBodyTitle);
|
|
}
|
|
for(int i=0;i<p_qwAnalyzer1->getThread();i++)
|
|
{
|
|
m_pThread[i]->start();
|
|
}
|
|
for(int i=0;i<p_qwAnalyzer1->getThread();i++)
|
|
{
|
|
m_pThread[i]->wait();
|
|
}
|
|
|
|
for(int i=0;i<p_qwAnalyzer1->getThread();i++)
|
|
{
|
|
delete m_pThread[i];
|
|
}
|
|
delete[] m_pThread;
|
|
|
|
}
|
|
|
|
|
|
void MainWindow::EmergeThreadResult()
|
|
{
|
|
for(int i=0;i<p_qwAnalyzer1->getThread();i++)
|
|
{
|
|
for(QHash<QString, int>::iterator iterPos = p_qwAnalyzer1->m_HashResult[i].begin(); iterPos != p_qwAnalyzer1->m_HashResult[i].end();iterPos++)
|
|
{
|
|
if(p_qwAnalyzer1->m_TotalResult.contains(iterPos.key()))
|
|
{
|
|
p_qwAnalyzer1->m_TotalResult[iterPos.key()] += iterPos.value();
|
|
}
|
|
else
|
|
{
|
|
p_qwAnalyzer1->m_TotalResult.insert(iterPos.key(), iterPos.value());
|
|
}
|
|
}
|
|
p_qwAnalyzer1->m_HashResult[i].clear();
|
|
}
|
|
}
|
|
|
|
void MainWindow::SortViewResult()
|
|
{
|
|
|
|
if(p_qwAnalyzer1->isSortDateMorphereChecked())
|
|
{
|
|
for(QMap<QString, int>::iterator iterPos = p_qwAnalyzer1->m_TotalResult.begin(); iterPos != p_qwAnalyzer1->m_TotalResult.end(); iterPos++)
|
|
{
|
|
QString strkey = iterPos.key();
|
|
int count = iterPos.value();
|
|
QStringList strlistKey = strkey.split("~!@");
|
|
QString strDate = strlistKey.at(0);
|
|
QString strMorphere = strlistKey.at(1);
|
|
QString strKeyword = strlistKey.at(2);
|
|
|
|
if(p_qwAnalyzer1->m_mapViewResult.contains(strDate))
|
|
{
|
|
if(p_qwAnalyzer1->m_mapViewResult.value(strDate).contains(strMorphere))
|
|
{
|
|
p_qwAnalyzer1->m_mapViewResult[(strDate)][(strMorphere)].insertMulti(count, strKeyword);
|
|
}
|
|
else
|
|
{
|
|
QMap<int, QString> qLast;
|
|
qLast.insert(count, strKeyword);
|
|
p_qwAnalyzer1->m_mapViewResult[(strDate)].insert(strMorphere, qLast);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
QMap<int, QString> qLast;
|
|
qLast.insert(count , strKeyword);
|
|
QMap<QString, QMap<int, QString> > qMedium;
|
|
qMedium.insert(strMorphere, qLast);
|
|
p_qwAnalyzer1->m_mapViewResult.insert(strDate, qMedium);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for(QMap<QString, int>::iterator iterPos = p_qwAnalyzer1->m_TotalResult.begin(); iterPos != p_qwAnalyzer1->m_TotalResult.end(); iterPos++)
|
|
{
|
|
QString strkey = iterPos.key();
|
|
int count = iterPos.value();
|
|
QStringList strlistKey = strkey.split("~!@");
|
|
QString strDate = strlistKey.at(0);
|
|
QString strMorphere = strlistKey.at(1);
|
|
QString strKeyword = strlistKey.at(2);
|
|
|
|
if(p_qwAnalyzer1->m_mapViewResult.contains(strMorphere))
|
|
{
|
|
if(p_qwAnalyzer1->m_mapViewResult.value(strMorphere).contains(strDate))
|
|
{
|
|
p_qwAnalyzer1->m_mapViewResult[(strMorphere)][(strDate)].insertMulti(count, strKeyword);
|
|
}
|
|
else
|
|
{
|
|
QMap<int, QString> qLast;
|
|
qLast.insert(count, strKeyword);
|
|
p_qwAnalyzer1->m_mapViewResult[(strMorphere)].insert(strDate, qLast);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
QMap<int, QString> qLast;
|
|
qLast.insert(count , strKeyword);
|
|
QMap<QString, QMap<int, QString> > qMedium;
|
|
qMedium.insert(strDate, qLast);
|
|
p_qwAnalyzer1->m_mapViewResult.insert(strMorphere, qMedium);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void MainWindow::ViewResult()
|
|
{
|
|
|
|
foreach(STable* ptable, m_lTable)
|
|
{
|
|
ptable->clear();
|
|
delete ptable;
|
|
}
|
|
m_lTable.clear();
|
|
|
|
foreach(QTabWidget* pwidget, m_lTabWidget)
|
|
{
|
|
pwidget->clear();
|
|
delete pwidget;
|
|
}
|
|
m_lTabWidget.clear();
|
|
|
|
|
|
m_ptwTable = p_qwAnalyzer1->getQTabWidget();
|
|
m_ptwTable->clear();
|
|
|
|
for( QMap<QString,QMap<QString,QMap<int, QString> > >::iterator iterPos = p_qwAnalyzer1->m_mapViewResult.begin(); iterPos != p_qwAnalyzer1->m_mapViewResult.end(); iterPos++)
|
|
{
|
|
QTabWidget* temp = new QTabWidget;
|
|
for(QMap<QString, QMap<int, QString> >::iterator iterPos2 = iterPos.value().begin(); iterPos2 != iterPos.value().end(); iterPos2++)
|
|
{
|
|
int ncRow = 0;
|
|
|
|
STable *pNew = new STable;
|
|
pNew->setColumnCount(2);
|
|
pNew->setRowCount(p_qwAnalyzer1->m_mapViewResult[iterPos.key()][iterPos2.key()].size());
|
|
pNew->setHorizontalHeaderItem(0 ,new QTableWidgetItem("Keyword"));
|
|
pNew->setHorizontalHeaderItem(1 ,new QTableWidgetItem("Count"));
|
|
|
|
QMapIterator<int, QString> i(p_qwAnalyzer1->m_mapViewResult[iterPos.key()][iterPos2.key()]);
|
|
i.toBack();
|
|
while(i.hasPrevious())
|
|
{
|
|
i.previous();
|
|
pNew->setItem(ncRow,0,new QTableWidgetItem(QString(i.value())));
|
|
pNew->setItem(ncRow,1,new QTableWidgetItem(QString::number(i.key())));
|
|
ncRow++;
|
|
}
|
|
temp->addTab(pNew, iterPos2.key());
|
|
m_lTable << pNew;
|
|
}
|
|
m_ptwTable->addTab(temp, iterPos.key());
|
|
m_lTabWidget << temp;
|
|
}
|
|
}
|