Changed: #1306 added leveldesign path dock widget
parent
2039038973
commit
d9c7bc8128
@ -0,0 +1,99 @@
|
||||
// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Project includes
|
||||
#include "georges_dirtree_dialog.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QtGui/QWidget>
|
||||
#include <QSettings>
|
||||
|
||||
// NeL includes
|
||||
|
||||
//using namespace NLMISC;
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent)
|
||||
:QDockWidget(parent), m_ldPath(ldPath)
|
||||
{
|
||||
|
||||
m_ui.setupUi(this);
|
||||
|
||||
m_dirModel = new CGeorgesFileSystemModel(m_ldPath);
|
||||
m_ui.dirTree->setModel(m_dirModel);
|
||||
|
||||
if (m_dirModel->isCorrectLDPath())
|
||||
{
|
||||
m_dirModel->setRootPath(m_ldPath);
|
||||
m_ui.dirTree->setRootIndex(m_dirModel->index(m_ldPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dirModel->setRootPath(QDir::currentPath());
|
||||
}
|
||||
|
||||
m_ui.dirTree->setAnimated(false);
|
||||
m_ui.dirTree->setIndentation(20);
|
||||
|
||||
connect(m_ui.dirTree, SIGNAL(activated(QModelIndex)),
|
||||
this, SLOT(fileSelected(QModelIndex)));
|
||||
}
|
||||
|
||||
CGeorgesDirTreeDialog::~CGeorgesDirTreeDialog()
|
||||
{
|
||||
delete m_dirModel;
|
||||
}
|
||||
|
||||
void CGeorgesDirTreeDialog::fileSelected(QModelIndex index)
|
||||
{
|
||||
QString name;
|
||||
if (index.isValid() && !m_dirModel->isDir(index))
|
||||
{
|
||||
Q_EMIT selectedForm(m_dirModel->fileName(index));
|
||||
}
|
||||
}
|
||||
|
||||
void CGeorgesDirTreeDialog::changeFile(QString file)
|
||||
{
|
||||
QModelIndex index = m_dirModel->index(file);
|
||||
m_ui.dirTree->selectionModel()->select(index,QItemSelectionModel::ClearAndSelect);
|
||||
m_ui.dirTree->scrollTo(index,QAbstractItemView::PositionAtCenter);
|
||||
fileSelected(index);
|
||||
}
|
||||
|
||||
void CGeorgesDirTreeDialog::ldPathChanged(QString path)
|
||||
{
|
||||
m_ldPath = path;
|
||||
|
||||
delete m_dirModel;
|
||||
|
||||
m_dirModel = new CGeorgesFileSystemModel(m_ldPath);
|
||||
m_ui.dirTree->setModel(m_dirModel);
|
||||
|
||||
if (m_dirModel->isCorrectLDPath())
|
||||
{
|
||||
m_dirModel->setRootPath(m_ldPath);
|
||||
m_ui.dirTree->setRootIndex(m_dirModel->index(m_ldPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dirModel->setRootPath(QDir::currentPath());
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace NLQT */
|
@ -0,0 +1,62 @@
|
||||
// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef GEORGES_DIRTREE_DIALOG_H
|
||||
#define GEORGES_DIRTREE_DIALOG_H
|
||||
|
||||
// Qt includes
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
|
||||
// Project includes
|
||||
#include "ui_georges_dirtree_form.h"
|
||||
#include "georges_filesystem_model.h"
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
class CGeorgesDirTreeDialog: public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CGeorgesDirTreeDialog(QString ldPath, QWidget *parent = 0);
|
||||
~CGeorgesDirTreeDialog();
|
||||
|
||||
void ldPathChanged(QString);
|
||||
|
||||
private:
|
||||
Ui::CGeorgesDirTreeDialog m_ui;
|
||||
|
||||
CGeorgesFileSystemModel *m_dirModel;
|
||||
QString m_ldPath;
|
||||
|
||||
Q_SIGNALS:
|
||||
void selectedForm(const QString);
|
||||
|
||||
private Q_SLOTS:
|
||||
void fileSelected(QModelIndex index);
|
||||
void changeFile(QString file);
|
||||
|
||||
friend class CMainWindow;
|
||||
}; /* CGEorgesDirTreeDialog */
|
||||
|
||||
} /* namespace NLQT */
|
||||
|
||||
#endif // GEORGES_DIRTREE_DIALOG_H
|
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CGeorgesDirTreeDialog</class>
|
||||
<widget class="QDockWidget" name="CGeorgesDirTreeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>111</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Leveldesign Path</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="dirTree">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -0,0 +1,95 @@
|
||||
// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "georges_filesystem_model.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
CGeorgesFileSystemModel::CGeorgesFileSystemModel(QString ldPath, QObject *parent)
|
||||
: QFileSystemModel(parent),
|
||||
m_ldPath(ldPath),
|
||||
m_correct(false)
|
||||
{
|
||||
checkLDPath();
|
||||
}
|
||||
|
||||
CGeorgesFileSystemModel::~CGeorgesFileSystemModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QVariant CGeorgesFileSystemModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
if (!m_correct)
|
||||
return QVariant();
|
||||
if (isDir(index))
|
||||
return QApplication::style()->standardIcon(QStyle::SP_DirIcon);
|
||||
}
|
||||
if (!m_correct && role == Qt::DisplayRole)
|
||||
{
|
||||
if (index.parent().isValid())
|
||||
return QVariant();
|
||||
return tr("Set a correct leveldesign path ...");
|
||||
}
|
||||
return QFileSystemModel::data(index, role);
|
||||
}
|
||||
|
||||
int CGeorgesFileSystemModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CGeorgesFileSystemModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
|
||||
if (!m_correct)
|
||||
{
|
||||
if(parent.isValid())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return qMin(QFileSystemModel::rowCount(parent),1);
|
||||
}
|
||||
}
|
||||
return QFileSystemModel::rowCount(parent);
|
||||
}
|
||||
|
||||
void CGeorgesFileSystemModel::checkLDPath()
|
||||
{
|
||||
QFileInfo check1(QString("%1/game_element").arg(m_ldPath));
|
||||
QFileInfo check2(QString("%1/DFN").arg(m_ldPath));
|
||||
|
||||
if (check1.exists() && check2.exists())
|
||||
{
|
||||
m_correct = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_correct = false;
|
||||
}
|
||||
}
|
||||
} /* namespace NLQT */
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,50 @@
|
||||
// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef GEORGES_FILESYSTEM_MODEL_H
|
||||
#define GEORGES_FILESYSTEM_MODEL_H
|
||||
|
||||
#include <QtGui/QFileSystemModel>
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
class CGeorgesFileSystemModel : public QFileSystemModel
|
||||
{
|
||||
QString m_ldPath;
|
||||
|
||||
public:
|
||||
CGeorgesFileSystemModel(QString ldPath, QObject *parent = 0);
|
||||
~CGeorgesFileSystemModel();
|
||||
|
||||
int columnCount(const QModelIndex &/*parent*/) const;
|
||||
int rowCount(const QModelIndex &/*parent*/) const;
|
||||
|
||||
QVariant data(const QModelIndex& index, int role) const ;
|
||||
|
||||
bool isCorrectLDPath()
|
||||
{
|
||||
return m_correct;
|
||||
}
|
||||
void checkLDPath();
|
||||
|
||||
private:
|
||||
bool m_correct;
|
||||
};/* class CGeorgesFileSystemModel */
|
||||
|
||||
} /* namespace NLQT */
|
||||
|
||||
#endif // GEORGES_FILESYSTEM_MODEL_H
|
Loading…
Reference in New Issue