Changed: Implementing server list in settings page. Added dialog for editing/adding entries. Can add, remove and edit entries. Still need to implement read/write settings and provide a method to connect the table to the publishing options table.

This commit is contained in:
sfb 2011-07-01 07:19:46 -05:00
parent ef1e4131f8
commit 0d34a1982b
9 changed files with 270 additions and 189 deletions

View file

@ -11,7 +11,8 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.
SET(OVQT_PLUG_MISSION_COMPILER_HDR mission_compiler_plugin.h SET(OVQT_PLUG_MISSION_COMPILER_HDR mission_compiler_plugin.h
mission_compiler_main_window.h mission_compiler_main_window.h
mission_compiler_settings_page.h) mission_compiler_settings_page.h
server_entry_dialog.h)
SET(OVQT_PLUG_MISSION_COMPILER_UIS mission_compiler_main_window.ui server_entry_dialog.ui mission_compiler_settings_page.ui) SET(OVQT_PLUG_MISSION_COMPILER_UIS mission_compiler_main_window.ui server_entry_dialog.ui mission_compiler_settings_page.ui)

View file

@ -79,6 +79,7 @@ MissionCompilerMainWindow::MissionCompilerMainWindow(QWidget *parent) :
settings->endGroup(); settings->endGroup();
NLLIGO::Register(); NLLIGO::Register();
// TODO try/catch exception. Crashes if path invalid.
m_ligoConfig.readPrimitiveClass(NLMISC::CPath::lookup("world_editor_classes.xml").c_str(), false); m_ligoConfig.readPrimitiveClass(NLMISC::CPath::lookup("world_editor_classes.xml").c_str(), false);
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig; NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
} }

View file

@ -17,6 +17,8 @@
#include <QtGui/QAction> #include <QtGui/QAction>
#include <QtGui/QMenuBar> #include <QtGui/QMenuBar>
#include "mission_compiler_settings_page.h"
namespace Plugin namespace Plugin
{ {
@ -35,7 +37,7 @@ bool MissionCompilerPlugin::initialize(ExtensionSystem::IPluginManager *pluginMa
Q_UNUSED(errorString); Q_UNUSED(errorString);
_plugMan = pluginManager; _plugMan = pluginManager;
//addAutoReleasedObject(new CZonePainterSettingsPage(this)); addAutoReleasedObject(new MissionCompilerSettingsPage(this));
addAutoReleasedObject(new CMissionCompilerContext(this)); addAutoReleasedObject(new CMissionCompilerContext(this));
//addAutoReleasedObject(new CCoreListener(this)); //addAutoReleasedObject(new CCoreListener(this));
return true; return true;

View file

@ -20,7 +20,7 @@
#include "../core/core_constants.h" #include "../core/core_constants.h"
#include "../core/icore.h" #include "../core/icore.h"
#include "ui_server_entry_dialog.h" #include "server_entry_dialog.h"
// NeL includes // NeL includes
#include <nel/misc/path.h> #include <nel/misc/path.h>
@ -58,12 +58,12 @@ QString MissionCompilerSettingsPage::trName() const
QString MissionCompilerSettingsPage::category() const QString MissionCompilerSettingsPage::category() const
{ {
return QLatin1String("MissionCompilerSettings"); return QLatin1String("Mission Compiler");
} }
QString MissionCompilerSettingsPage::trCategory() const QString MissionCompilerSettingsPage::trCategory() const
{ {
return tr("MissionCompilerSettings"); return tr("Mission Compiler");
} }
QIcon MissionCompilerSettingsPage::categoryIcon() const QIcon MissionCompilerSettingsPage::categoryIcon() const
@ -77,19 +77,15 @@ QWidget *MissionCompilerSettingsPage::createPage(QWidget *parent)
m_ui.setupUi(m_page); m_ui.setupUi(m_page);
readSettings(); readSettings();
checkEnabledButton(); connect(m_ui.addToolButton, SIGNAL(clicked()), this, SLOT(addServer()));
connect(m_ui.addToolButton, SIGNAL(clicked()), this, SLOT(addPath())); connect(m_ui.removeToolButton, SIGNAL(clicked()), this, SLOT(delServer()));
connect(m_ui.removeToolButton, SIGNAL(clicked()), this, SLOT(delPath())); connect(m_ui.serversTableWidget, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(editServer(int,int)));
connect(m_ui.upToolButton, SIGNAL(clicked()), this, SLOT(upPath()));
connect(m_ui.downToolButton, SIGNAL(clicked()), this, SLOT(downPath()));
//connect(m_ui.resetToolButton, SIGNAL(clicked()), m_ui.serversTreeWidget, SLOT(clear()));
return m_page; return m_page;
} }
void MissionCompilerSettingsPage::apply() void MissionCompilerSettingsPage::apply()
{ {
writeSettings(); writeSettings();
applySearchPaths();
} }
void MissionCompilerSettingsPage::finish() void MissionCompilerSettingsPage::finish()
@ -98,74 +94,57 @@ void MissionCompilerSettingsPage::finish()
m_page = 0; m_page = 0;
} }
void MissionCompilerSettingsPage::applySearchPaths() void MissionCompilerSettingsPage::editServer(int row, int column)
{ {
QStringList paths, remapExt; ServerEntryDialog serverEntryDialog;
QSettings *settings = Core::ICore::instance()->settings(); serverEntryDialog.setModal(true);
settings->beginGroup(Core::Constants::DATA_PATH_SECTION); serverEntryDialog.show();
if (m_recurse)
paths = settings->value(Core::Constants::RECURSIVE_SEARCH_PATHS).toStringList();
else
paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList();
remapExt = settings->value(Core::Constants::REMAP_EXTENSIONS).toStringList(); // Copy the values from the row to the dialog.
settings->endGroup(); QTableWidgetItem *item1 = m_ui.serversTableWidget->item(row,0);
QTableWidgetItem *item2 = m_ui.serversTableWidget->item(row,1);
QTableWidgetItem *item3 = m_ui.serversTableWidget->item(row,2);
serverEntryDialog.setServerName(item1->text());
serverEntryDialog.setTextPath(item2->text());
serverEntryDialog.setPrimPath(item3->text());
for (int i = 1; i < remapExt.size(); i += 2) if(serverEntryDialog.exec())
NLMISC::CPath::remapExtension(remapExt.at(i - 1).toStdString(), remapExt.at(i).toStdString(), true);
Q_FOREACH(QString path, paths)
{ {
NLMISC::CPath::addSearchPath(path.toStdString(), m_recurse, false); item1->setText(serverEntryDialog.getServerName());
item2->setText(serverEntryDialog.getTextPath());
item3->setText(serverEntryDialog.getPrimPath());
} }
} }
void MissionCompilerSettingsPage::addPath() void MissionCompilerSettingsPage::addServer()
{ {
Ui::ServerEntryDialog serverEntryDialog; ServerEntryDialog serverEntryDialog;
serverEntryDialog.setModal(true);
serverEntryDialog.show();
//QString newPath = QFileDialog::getExistingDirectory(m_page, "", lastDir); if(serverEntryDialog.exec())
//if (!newPath.isEmpty()) {
//{ int row = m_ui.serversTableWidget->rowCount();
// QTreeWidgetItem *newItem = new QTreeWidgetItem; m_ui.serversTableWidget->insertRow(row);
// newItem->setText(newPath); QTableWidgetItem *item1 = new QTableWidgetItem(serverEntryDialog.getServerName());
// newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); QTableWidgetItem *item2 = new QTableWidgetItem(serverEntryDialog.getTextPath());
// m_ui.serversTreeWidget->addItem(newItem); QTableWidgetItem *item3 = new QTableWidgetItem(serverEntryDialog.getPrimPath());
// lastDir = newPath;
//}
//checkEnabledButton(); m_ui.serversTableWidget->setItem(row, 0, item1);
m_ui.serversTableWidget->setItem(row, 1, item2);
m_ui.serversTableWidget->setItem(row, 2, item3);
}
} }
void MissionCompilerSettingsPage::delPath() void MissionCompilerSettingsPage::delServer()
{ {
//QTreeWidgetItem *removeItem = m_ui.serversTreeWidget->takeItem(m_ui.serversTreeWidget->currentRow()); QList<QTableWidgetItem*> selectedItems = m_ui.serversTableWidget->selectedItems();
//if (!removeItem) while(selectedItems.size() > 0)
// delete removeItem; {
m_ui.serversTableWidget->removeRow(selectedItems.back()->row());
//checkEnabledButton(); selectedItems = m_ui.serversTableWidget->selectedItems();
} }
void MissionCompilerSettingsPage::upPath()
{
//int currentRow = m_ui.serversTreeWidget->currentRow();
//if (!(currentRow == 0))
//{
// QListWidgetItem *item = m_ui.serversListWidget->takeItem(currentRow);
// m_ui.serversListWidget->insertItem(--currentRow, item);
// m_ui.serversListWidget->setCurrentRow(currentRow);
//}
}
void MissionCompilerSettingsPage::downPath()
{
//int currentRow = m_ui.serversListWidget->currentRow();
//if (!(currentRow == m_ui.serversListWidget->count()-1))
//{
// QListWidgetItem *item = m_ui.serversListWidget->takeItem(currentRow);
// m_ui.serversTreeWidget->insertItem(++currentRow, item);
// m_ui.serversTreeWidget->setCurrentRow(currentRow);
//}
} }
void MissionCompilerSettingsPage::readSettings() void MissionCompilerSettingsPage::readSettings()
@ -203,15 +182,4 @@ void MissionCompilerSettingsPage::writeSettings()
//settings->sync(); //settings->sync();
} }
void MissionCompilerSettingsPage::checkEnabledButton()
{
//bool bEnabled = true;
//if (m_ui.serversTreeWidget->count() == 0)
// bEnabled = false;
//m_ui.removeToolButton->setEnabled(bEnabled);
//m_ui.upToolButton->setEnabled(bEnabled);
//m_ui.downToolButton->setEnabled(bEnabled);
}
} /* namespace Plugin */ } /* namespace Plugin */

View file

@ -50,21 +50,15 @@ public:
void apply(); void apply();
void finish(); void finish();
// Set of the search paths(not recursive) and the remap extensions (loading from settings file)
void applySearchPaths();
private Q_SLOTS: private Q_SLOTS:
void addPath(); void addServer();
void delPath(); void delServer();
void upPath(); void editServer(int row, int column);
void downPath();
private: private:
void readSettings(); void readSettings();
void writeSettings(); void writeSettings();
void checkEnabledButton();
bool m_recurse;
QWidget *m_page; QWidget *m_page;
Ui::MissionCompilerSettingsPage m_ui; Ui::MissionCompilerSettingsPage m_ui;
}; };

View file

@ -86,64 +86,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="upToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Up</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/ic_nel_up_item.png</normaloff>:/buttons/images/ic_nel_up_item.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="downToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Down</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/ic_nel_down_item.png</normaloff>:/buttons/images/ic_nel_down_item.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QToolButton" name="resetToolButton"> <widget class="QToolButton" name="resetToolButton">
<property name="toolTip"> <property name="toolTip">
@ -197,6 +139,9 @@
</item> </item>
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<widget class="QTableWidget" name="serversTableWidget"> <widget class="QTableWidget" name="serversTableWidget">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors"> <property name="alternatingRowColors">
<bool>true</bool> <bool>true</bool>
</property> </property>

View file

@ -0,0 +1,89 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 "server_entry_dialog.h"
#include "ui_server_entry_dialog.h"
// NeL includes
// Qt includes
#include <QFileDialog>
namespace Plugin
{
ServerEntryDialog::ServerEntryDialog(QWidget *parent)
: QDialog(parent),
m_ui(new Ui::ServerEntryDialog)
{
m_ui->setupUi(this);
connect(m_ui->serverTextPathButton, SIGNAL(clicked()), this, SLOT(lookupTextPath()));
connect(m_ui->serverPrimPathButton, SIGNAL(clicked()), this, SLOT(lookupPrimPath()));
}
ServerEntryDialog::~ServerEntryDialog()
{
delete m_ui;
}
QString ServerEntryDialog::getServerName()
{
return m_ui->serverNameEdit->text();
}
QString ServerEntryDialog::getTextPath()
{
return m_ui->serverTextPathEdit->text();
}
QString ServerEntryDialog::getPrimPath()
{
return m_ui->serverPrimPathEdit->text();
}
void ServerEntryDialog::setServerName(QString name)
{
m_ui->serverNameEdit->setText(name);
}
void ServerEntryDialog::setTextPath(QString path)
{
m_ui->serverTextPathEdit->setText(path);
}
void ServerEntryDialog::setPrimPath(QString path)
{
m_ui->serverPrimPathEdit->setText(path);
}
void ServerEntryDialog::lookupTextPath()
{
QString curPath = m_ui->serverTextPathEdit->text();
QString path = QFileDialog::getExistingDirectory(this, "", curPath);
m_ui->serverTextPathEdit->setText(path);
}
void ServerEntryDialog::lookupPrimPath()
{
QString curPath = m_ui->serverPrimPathEdit->text();
QString path = QFileDialog::getExistingDirectory(this, "", curPath);
m_ui->serverPrimPathEdit->setText(path);
}
} /* namespace Plugin */

View file

@ -0,0 +1,59 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 SERVER_ENTRY_DIALOG_H
#define SERVER_ENTRY_DIALOG_H
#include <QDialog>
namespace Ui {
class ServerEntryDialog;
}
namespace Plugin
{
/**
@class ServerEntryDialog
*/
class ServerEntryDialog : public QDialog
{
Q_OBJECT
public:
explicit ServerEntryDialog(QWidget *parent = 0);
~ServerEntryDialog();
QString getServerName();
QString getTextPath();
QString getPrimPath();
void setServerName(QString name);
void setTextPath(QString path);
void setPrimPath(QString path);
public Q_SLOTS:
void lookupTextPath();
void lookupPrimPath();
private:
Ui::ServerEntryDialog *m_ui;
};
} // namespace Plugin
#endif // SERVER_ENTRY_DIALOG_H

View file

@ -6,15 +6,15 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>488</width>
<height>300</height> <height>175</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="4" column="0"> <item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -24,48 +24,70 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="0" column="0">
<widget class="QLabel" name="serverNameLabel"> <widget class="QGroupBox" name="serverSettingsBox">
<property name="text"> <property name="title">
<string>Server Name</string> <string>Server Settings</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="serverTextPathLabel">
<property name="text">
<string>Server Text Path</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="serverPrimPathLabel">
<property name="text">
<string>Server Primitive Path</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="serverNameEdit"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="serverTextPathEdit"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="serverPrimPathEdit"/>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="serverTextPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="serverPrimPathButton">
<property name="text">
<string>...</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="serverNameLabel">
<property name="text">
<string>Server Name</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="serverNameEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="serverTextPathLabel">
<property name="text">
<string>Server Text Path</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="serverTextPathEdit"/>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="serverTextPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="serverPrimPathLabel">
<property name="text">
<string>Server Primitive Path</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="serverPrimPathEdit"/>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="serverPrimPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>