##// END OF EJS Templates
A lot of refactoring:...
A lot of refactoring: QLopPlot now handle more than one plot. File browser uses QFileSystemModel and QItemView Wrapped QCustomPlot.

File last commit:

r1:a1d6d9df437f default
r6:665de41c4c74 default
Show More
folderview.cpp
165 lines | 4.5 KiB | text/x-c | CppLexer
First init
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 "folderview.h"
#include "ui_folderview.h"
#include <QFileDialog>
#include <QLabel>
Drag and drop implemented, improved plot interactions.
r1 #include <QDebug>
First init
r0
Drag and drop implemented, improved plot interactions.
r1 p_FolderView::p_FolderView(QWidget *parent) :
QWidget(parent),
ui(new Ui::p_FolderView)
First init
r0 {
ui->setupUi(this);
connect(this->ui->setFolderQpb,SIGNAL(clicked()),this,SLOT(openFolder()));
connect(this->ui->refreshQpb,SIGNAL(clicked()),this,SLOT(refreshFolder()));
connect(this->ui->listWidget,SIGNAL(itemActivated(QListWidgetItem*)),this,SLOT(itemActivated(QListWidgetItem*)));
Drag and drop implemented, improved plot interactions.
r1 //this->ui->listWidget->installEventFilter(this);
connect(this->ui->listWidget,SIGNAL(askGlobalRescan()),this,SIGNAL(askGlobalRescan()));
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 p_FolderView::~p_FolderView()
First init
r0 {
delete ui;
}
Drag and drop implemented, improved plot interactions.
r1 bool p_FolderView::contains(const QString &fileName)
First init
r0 {
for(int i=0;i<this->ui->listWidget->count();i++)
{
if(this->ui->listWidget->item(i)->text()==fileName)
{
return true;
}
}
return false;
}
Drag and drop implemented, improved plot interactions.
r1 bool p_FolderView::isDraging(const QString &name)
{
return this->ui->listWidget->isDraging(name);
}
void p_FolderView::setMainWindow(MainWindow *mw)
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->ui->listWidget->setMainWindow(mw);
}
QString p_FolderView::currentFolder()
{
return p_currentFolder;
}
void p_FolderView::openFolder()
{
p_currentFolder = QFileDialog::getExistingDirectory(this, tr("Open Directory"),NULL,QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
First init
r0 refreshFolder();
}
Drag and drop implemented, improved plot interactions.
r1 void p_FolderView::refreshFolder()
First init
r0 {
QDir dir;
Drag and drop implemented, improved plot interactions.
r1 dir.setPath(p_currentFolder);
First init
r0 this->ui->listWidget->clear();
dir.setFilter(QDir::Files | QDir::NoSymLinks);
dir.setSorting(QDir::Name);
QFileInfoList list = dir.entryInfoList();
for (int i = 0; i < list.size(); ++i)
{
if(!list.at(i).completeSuffix().compare("TAB"))
{
this->ui->listWidget->addItem(list.at(i).fileName());
}
}
Drag and drop implemented, improved plot interactions.
r1 this->ui->listWidget->setPath(p_currentFolder);
this->ui->groupBox->setTitle(p_currentFolder);
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 void p_FolderView::itemActivated(QListWidgetItem *item)
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 emit itemActivated(p_currentFolder+'/'+item->text());
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 void p_FolderView::changeEvent(QEvent *e)
First init
r0 {
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
Drag and drop implemented, improved plot interactions.
r1
bool p_FolderView::eventFilter(QObject *object, QEvent *event)
{
if(object == this->ui->listWidget )
{
qDebug()<<event->type();
if(event->type() == QEvent::Drop)
{
QDropEvent *DropEvent = static_cast<QDropEvent *>(event);
qDebug()<< DropEvent->mimeData();
}
}
return false;
}
FolderView::FolderView(MainWindow *parent)
:QDockWidget(parent)
{
this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
this->setAllowedAreas(Qt::AllDockWidgetAreas);
this->ui = new p_FolderView(this);
this->setWidget(this->ui);
connect(this->ui,SIGNAL(itemActivated(QString)),this,SIGNAL(itemActivated(QString)));
connect(this->ui,SIGNAL(askGlobalRescan()),this,SIGNAL(askGlobalRescan()));
this->ui->setMainWindow(parent);
}
bool FolderView::contains(const QString &fileName)
{
return ui->contains(fileName);
}
bool FolderView::isDraging(const QString &name)
{
return this->ui->isDraging(name);
}
QString FolderView::currentFolder()
{
return this->ui->currentFolder();
}
void FolderView::openFolder()
{
this->ui->openFolder();
}
void FolderView::refreshFolder()
{
this->ui->refreshFolder();
}