New lua versions
[ryzomcore.git] / studio / src / plugins / bnp_manager / bnp_dirtree_dialog.cpp
blob1ddb25df1e26cb86c0c2181f530ffc39bc83b3a5
1 // Object Viewer Qt - BNP Manager Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2011 Roland WINKLMEIER <roland.m.winklmeier@gmail.com>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // Project includes
18 #include "bnp_dirtree_dialog.h"
19 #include "bnp_filesystem_model.h"
20 #include "bnp_proxy_model.h"
22 // Qt includes
23 #include <QtGui/QWidget>
25 // NeL includes
26 #include <nel/misc/debug.h>
28 namespace BNPManager
31 CBnpDirTreeDialog::CBnpDirTreeDialog(QString bnpPath, QWidget *parent)
32 : QDockWidget(parent),
33 m_DataPath(bnpPath)
35 // Setup the dialog
36 m_ui.setupUi(this);
38 // Filter settings to only display files with bnp extension.
39 // Could be changed to display all files and react according to the extension:
40 // Bnp file: opened and displayed
41 // all other files: added to the currently opened bnp file
42 QStringList filter;
43 filter << tr("*.bnp");
45 // Setup the directory tree model
46 m_dirModel= new BNPFileSystemModel();
47 m_proxyModel = new BNPSortProxyModel();
48 m_ui.dirTree->setSortingEnabled(true);
49 m_dirModel->setRootPath(m_DataPath);
50 m_dirModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::AllEntries);
51 m_dirModel->setNameFilters(filter);
52 m_dirModel->setNameFilterDisables(0);
54 m_proxyModel->setSourceModel(m_dirModel);
56 m_ui.dirTree->setModel(m_proxyModel);
58 m_ui.dirTree->setRootIndex( m_proxyModel->mapFromSource (m_dirModel->index(m_DataPath) ) );
60 // Trigger if one filename is activated
61 // In future drag&drop should be also possible
62 connect(m_ui.dirTree, SIGNAL(activated(QModelIndex)),
63 this, SLOT(fileSelected(QModelIndex)));
65 // ***************************************************************************
66 CBnpDirTreeDialog::~CBnpDirTreeDialog()
70 // ***************************************************************************
71 void CBnpDirTreeDialog::fileSelected(QModelIndex index)
73 QModelIndex source = m_proxyModel->mapToSource(index);
74 if (source.isValid() && !m_dirModel->isDir(source))
76 // emit the according signal to BNPManagerWindow class
77 Q_EMIT selectedFile(m_dirModel->fileInfo(source).filePath());
80 // ***************************************************************************
81 void CBnpDirTreeDialog::changeFile(QString file)
85 // ***************************************************************************
86 void CBnpDirTreeDialog::BnpPathChanged(QString path)
90 // ***************************************************************************