mainwindow.cpp
146 lines
| 4.3 KiB
| text/x-c
|
CppLexer
/ src / mainwindow.cpp
r0 | /*------------------------------------------------------------------------------ | |||
-- This file is a part of the QLop Software | ||||
-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS | ||||
-- | ||||
-- This program is free software; you can redistribute it and/or modify | ||||
-- it under the terms of the GNU General Public License as published by | ||||
-- the Free Software Foundation; either version 2 of the License, or | ||||
-- (at your option) any later version. | ||||
-- | ||||
-- This program is distributed in the hope that it will be useful, | ||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
-- GNU General Public License for more details. | ||||
-- | ||||
-- You should have received a copy of the GNU General Public License | ||||
-- along with this program; if not, write to the Free Software | ||||
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
-------------------------------------------------------------------------------*/ | ||||
/*-- Author : Alexis Jeandet | ||||
-- Mail : alexis.jeandet@member.fsf.org | ||||
----------------------------------------------------------------------------*/ | ||||
#include "mainwindow.h" | ||||
#include "ui_mainwindow.h" | ||||
#include <QFileDialog> | ||||
#include <QDir> | ||||
#include "qcustomplot.h" | ||||
#include <omp.h> | ||||
r4 | #include <QAction> | |||
#include <downloadhistory.h> | ||||
#include <QDateTime> | ||||
#include <QDate> | ||||
#include <filedownloader.h> | ||||
r5 | #include <cassinitools.h> | |||
#include <qlopplots.h> | ||||
r4 | ||||
r5 | const QList<QLopService*>ServicesToLoad=QList<QLopService*>() | |||
<<FileDownloader::self() | ||||
<<CassiniTools::self() | ||||
<< QLopPlots::self(); | ||||
r0 | ||||
MainWindow::MainWindow(int OMP_THREADS, QWidget *parent) : | ||||
QMainWindow(parent), | ||||
ui(new Ui::MainWindow) | ||||
{ | ||||
this->OMP_THREADS = OMP_THREADS; | ||||
ui->setupUi(this); | ||||
r6 | // QLopPlots::getPlot()->setXaxisTickLabelType(QCPAxis::ltDateTime); | |||
// QLopPlots::getPlot()->setXaxisDateTimeFormat("hh:mm:ss.zzz"); | ||||
r0 | this->progressWidget = new QWidget(); | |||
this->progressLayout = new QVBoxLayout(this->progressWidget); | ||||
this->progressWidget->setLayout(this->progressLayout); | ||||
this->progressWidget->setWindowModality(Qt::WindowModal); | ||||
r1 | progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); | |||
r0 | for(int i=0;i<OMP_THREADS;i++) | |||
{ | ||||
this->progress.append(new QProgressBar(this->progressWidget)); | ||||
this->progress.last()->setMinimum(0); | ||||
this->progress.last()->setMaximum(100); | ||||
r5 | // connect(&this->fileReader,SIGNAL(updateProgress(int,int)),this,SLOT(updateProgress(int,int))); | |||
r0 | this->progressLayout->addWidget(this->progress.last()); | |||
this->progressWidget->hide(); | ||||
r1 | this->progressThreadIds[i] = -1; | |||
r0 | } | |||
this->progressWidget->setWindowTitle("Loading File"); | ||||
r5 | for(int i=0;i<ServicesToLoad.count();i++) | |||
{ | ||||
qDebug()<<ServicesToLoad.at(i)->serviceName(); | ||||
QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI(); | ||||
wdgt->setAllowedAreas(Qt::AllDockWidgetAreas); | ||||
this->addDockWidget(Qt::TopDockWidgetArea,wdgt); | ||||
PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i)); | ||||
} | ||||
r0 | } | |||
MainWindow::~MainWindow() | ||||
{ | ||||
delete ui; | ||||
} | ||||
r7 | //QString MainWindow::getFilePath(const QString &name) | |||
//{ | ||||
//// for(int i=0;i<this->folderViews.count();i++) | ||||
//// { | ||||
//// if(folderViews.at(i)->isDraging(name)) | ||||
//// return folderViews.at(i)->currentFolder(); | ||||
//// } | ||||
// return ""; | ||||
//} | ||||
r1 | ||||
r0 | ||||
r3 | ||||
r0 | ||||
void MainWindow::updateProgress(int threadId, int percentProgress) | ||||
{ | ||||
r1 | bool updated=false; | |||
for(int i=0;i<OMP_THREADS;i++) | ||||
{ | ||||
if(progressThreadIds[i]==threadId) | ||||
{ | ||||
r2 | if(threadId<this->progress.count()) | |||
{ | ||||
r4 | this->progress.at(i)->setValue(percentProgress); | |||
r2 | updated=true; | |||
} | ||||
r1 | } | |||
} | ||||
if(Q_UNLIKELY(updated==false)) | ||||
{ | ||||
for(int i=0;i<OMP_THREADS;i++) | ||||
{ | ||||
if(progressThreadIds[i]==-1) | ||||
{ | ||||
progressThreadIds[i] = threadId; | ||||
updateProgress(threadId,percentProgress); | ||||
r4 | return; | |||
r1 | } | |||
} | ||||
} | ||||
r0 | } | |||
r1 | void MainWindow::askGlobalRescan() | |||
{ | ||||
r5 | // for(int i=0;i<this->folderViews.count();i++) | |||
// { | ||||
// this->folderViews.at(i)->refreshFolder(); | ||||
// } | ||||
r4 | } | |||
void MainWindow::showThemisIndexViewer() | ||||
{ | ||||
r5 | ||||
r1 | } | |||
r0 | void MainWindow::changeEvent(QEvent *e) | |||
{ | ||||
QMainWindow::changeEvent(e); | ||||
switch (e->type()) { | ||||
case QEvent::LanguageChange: | ||||
ui->retranslateUi(this); | ||||
break; | ||||
default: | ||||
break; | ||||
} | ||||
} | ||||