351 lines
12 KiB
C++
351 lines
12 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 "sdictionary.h"
|
|
#include "tablealgorithm_interface.h"
|
|
#include "yalgorithm.h"
|
|
#include "ymbasicwidget.h"
|
|
#include "ymonedepthwidget.h"
|
|
#include "ymnxnmatrixwidget.h"
|
|
#include <QSqlQuery>
|
|
#include <QSqlDatabase>
|
|
#include <QSqlError>
|
|
#include "ymtwodepthwidget.h"
|
|
#include "ymplatformwidget.h"
|
|
#include <QShortcut>
|
|
#include <QKeySequence>
|
|
#include <QUrl>
|
|
//! [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 SAnaly2;
|
|
m_pYMBasicWidget = new YMBasicWidget;
|
|
m_pYMOneDepthWidget = new YMOneDepthWidget;
|
|
m_pYMTwoDepthWidget = new YMTwoDepthWidget;
|
|
m_pYMNxNMatrixWidget = new YMNxNMatrixWidget;
|
|
m_pYMPlatformWidget = new YMPlatformWidget;
|
|
p_qwDict = new SDictionary;
|
|
|
|
//p_qwAnalyzer1->setWidget(p_qwDB);
|
|
//p_qwAnalyzer2->setWidget(p_qwDB);
|
|
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_pTAInterface = new TableAlgorithmInterface;
|
|
m_pTAInterface->ReloadColumn();
|
|
m_pUploadWidget = new YMUploadWidget();
|
|
|
|
|
|
m_ptwResult = new QTabWidget;
|
|
m_ptwResult->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
//m_ptwResult->addTab(p_qwAnalyzer1, "Analysis1");
|
|
//m_ptwResult->addTab(p_qwAnalyzer2, "Analysis2");
|
|
m_ptwResult->addTab(m_pYMBasicWidget, "Basic");
|
|
m_ptwResult->addTab(m_pYMOneDepthWidget, "OneDepth");
|
|
m_ptwResult->addTab(m_pYMTwoDepthWidget, "TwoDepth");
|
|
m_ptwResult->addTab(m_pYMNxNMatrixWidget, "NxNMatrix");
|
|
m_ptwResult->addTab(m_pYMPlatformWidget, "Platform");
|
|
|
|
m_pYMBasicWidget->setTabWidget(m_ptwSource);
|
|
m_pYMOneDepthWidget->setTabWidget(m_ptwSource);
|
|
m_pYMTwoDepthWidget->setTabWidget(m_ptwSource);
|
|
m_pYMNxNMatrixWidget->setTabWidget(m_ptwSource);
|
|
m_pYMPlatformWidget->setTabWidget(m_ptwSource);
|
|
|
|
m_pUploadWidget->setResultTabWidget(m_ptwResult);
|
|
m_pUploadWidget->setSourceTabWidget(m_ptwSource);
|
|
QHBoxLayout *layout = new QHBoxLayout;
|
|
|
|
layout->setMargin(5);
|
|
layout->addWidget(m_ptwSource);
|
|
layout->addWidget(m_ptwResult);
|
|
|
|
widget->setLayout(layout);
|
|
//! [1]
|
|
|
|
actD3View = new QAction(tr("D3View"), this);
|
|
actD3View->setShortcut(Qt::Key_0 | Qt::CTRL);
|
|
connect(actD3View, SIGNAL(triggered()), this, SLOT(slotD3View()));
|
|
this->addAction(actD3View);
|
|
|
|
//! [2]
|
|
createActions();
|
|
createMenus();
|
|
|
|
QString message = tr("A context menu is available by right-clicking");
|
|
statusBar()->showMessage(message);
|
|
//test = new QWebView(this);
|
|
|
|
setWindowTitle(tr("Morphere Analyzer"));
|
|
setMinimumSize(800, 600);
|
|
resize(800, 600);
|
|
}
|
|
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(OtherType 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()));
|
|
|
|
actTestUpload = new QAction(tr("Test Upload"), this);
|
|
connect(actTestUpload, SIGNAL(triggered()), this, SLOT(slotTestUpload()));
|
|
actShowUpload = new QAction(tr("Show Upload"), this);
|
|
connect(actShowUpload, SIGNAL(triggered()), this, SLOT(slotShowUpload()));
|
|
}
|
|
|
|
void MainWindow::slotShowUpload()
|
|
{
|
|
m_pUploadWidget->show();
|
|
|
|
}
|
|
|
|
void MainWindow::slotD3View()
|
|
{
|
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->D3View();
|
|
//qDebug() << "hide the D3View";
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
menuTestUpload = menuBar()->addMenu(tr("TestUpload"));
|
|
menuTestUpload->addAction(actTestUpload);
|
|
|
|
menuShowUpload = menuBar()->addMenu(tr("ShowUpload"));
|
|
menuShowUpload->addAction(actShowUpload);
|
|
|
|
menuD3View = menuBar()->addMenu(tr("D3View"));
|
|
menuD3View->addAction(actD3View);
|
|
|
|
}
|
|
//! [12]
|
|
|
|
|
|
void MainWindow::newDB()
|
|
{
|
|
p_qwDB->FileNew();
|
|
}
|
|
|
|
void MainWindow::importDB()
|
|
{
|
|
p_qwDB->FileImport();
|
|
}
|
|
|
|
void MainWindow::exportDB()
|
|
{
|
|
p_qwDB->FileExport();
|
|
}
|
|
|
|
void MainWindow::importMorphere()
|
|
{
|
|
// p_qwAnalyzer1->FileImport();
|
|
}
|
|
|
|
void MainWindow::exportMorphere()
|
|
{
|
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->SaveFile();
|
|
// p_qwAnalyzer1->FileExport();
|
|
}
|
|
|
|
void MainWindow::exportOriginalMorphere()
|
|
{
|
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->SaveFileSimple();
|
|
// p_qwAnalyzer1->RawFileExport();
|
|
}
|
|
|
|
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.setWindowFlags(msg2.windowFlags() | Qt::WindowCloseButtonHint);
|
|
msg2.setText("Please wait...");
|
|
msg2.setVisible(true);
|
|
//qDebug() << p_qwDB->GetTabWidget()->currentIndex();
|
|
m_pTAInterface->setSource(p_qwDB->GetTabWidget()->currentWidget());
|
|
YAFactory::getInstance()->getYAlgorithm(((YMorphereWidget*)(m_ptwResult->currentWidget()))->convertToParam())->setDataAlgorithmInterface(m_pTAInterface);
|
|
m_ptwResult->currentWidget();
|
|
//qDebug() << m_ptwResult->currentIndex();
|
|
|
|
/*
|
|
if(m_ptwResult->currentIndex() == 0)
|
|
{
|
|
p_qwAnalyzer1->Exec(setbody);
|
|
}
|
|
else if(m_ptwResult->currentIndex() == 1)
|
|
{
|
|
p_qwAnalyzer2->Exec(setbody);
|
|
}
|
|
else if(m_ptwResult->currentIndex() == 2)
|
|
{
|
|
m_pYMBasicWidget->Exec(setbody);
|
|
}
|
|
else if(m_ptwResult->currentIndex() == 3)
|
|
{
|
|
m_pYMOneDepthWidget->Exec(setbody);
|
|
}
|
|
else if(m_ptwResult->currentIndex() == 4)
|
|
{
|
|
m_pYMNxNMatrixWidget->Exec(setbody);
|
|
}
|
|
*/
|
|
/*
|
|
if(m_ptwResult->currentIndex() == 0)
|
|
{
|
|
m_pYMBasicWidget->Exec(setbody);
|
|
}
|
|
else if(m_ptwResult->currentIndex() == 1)
|
|
{
|
|
m_pYMOneDepthWidget->Exec(setbody);
|
|
}
|
|
else if(m_ptwResult->currentIndex() == 2)
|
|
{
|
|
m_pYMNxNMatrixWidget->Exec(setbody);
|
|
}
|
|
*/
|
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->Exec();
|
|
|
|
msg2.setVisible(false);
|
|
}
|
|
|
|
void MainWindow::slotTestUpload()
|
|
{
|
|
((YMorphereWidget*)(m_ptwResult->currentWidget()))->TestUpload();
|
|
}
|
|
|
|
void MainWindow::slotDictionary()
|
|
{
|
|
p_qwDict->show();
|
|
p_qwDict->repaint();
|
|
}
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *event)
|
|
{
|
|
QApplication::quit();
|
|
|
|
}
|