##// END OF EJS Templates
Added Python Console and some Wrappers....
Added Python Console and some Wrappers. More code cleaning, WIP.

File last commit:

r1:a1d6d9df437f default
r5:92e4585e8fab default
Show More
folderview.cpp
165 lines | 4.5 KiB | text/x-c | CppLexer
/*------------------------------------------------------------------------------
-- 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>
#include <QDebug>
p_FolderView::p_FolderView(QWidget *parent) :
QWidget(parent),
ui(new Ui::p_FolderView)
{
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*)));
//this->ui->listWidget->installEventFilter(this);
connect(this->ui->listWidget,SIGNAL(askGlobalRescan()),this,SIGNAL(askGlobalRescan()));
}
p_FolderView::~p_FolderView()
{
delete ui;
}
bool p_FolderView::contains(const QString &fileName)
{
for(int i=0;i<this->ui->listWidget->count();i++)
{
if(this->ui->listWidget->item(i)->text()==fileName)
{
return true;
}
}
return false;
}
bool p_FolderView::isDraging(const QString &name)
{
return this->ui->listWidget->isDraging(name);
}
void p_FolderView::setMainWindow(MainWindow *mw)
{
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);
refreshFolder();
}
void p_FolderView::refreshFolder()
{
QDir dir;
dir.setPath(p_currentFolder);
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());
}
}
this->ui->listWidget->setPath(p_currentFolder);
this->ui->groupBox->setTitle(p_currentFolder);
}
void p_FolderView::itemActivated(QListWidgetItem *item)
{
emit itemActivated(p_currentFolder+'/'+item->text());
}
void p_FolderView::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
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();
}