From 0d34a1982bb6b78aa91cebdd3c57e189d4829033 Mon Sep 17 00:00:00 2001 From: sfb Date: Fri, 1 Jul 2011 07:19:46 -0500 Subject: [PATCH] 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. --- .../plugins/mission_compiler/CMakeLists.txt | 3 +- .../mission_compiler_main_window.cpp | 1 + .../mission_compiler_plugin.cpp | 4 +- .../mission_compiler_settings_page.cpp | 120 +++++++----------- .../mission_compiler_settings_page.h | 12 +- .../mission_compiler_settings_page.ui | 61 +-------- .../mission_compiler/server_entry_dialog.cpp | 89 +++++++++++++ .../mission_compiler/server_entry_dialog.h | 59 +++++++++ .../mission_compiler/server_entry_dialog.ui | 110 +++++++++------- 9 files changed, 270 insertions(+), 189 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/CMakeLists.txt index 4919bceff..f277a4b14 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/CMakeLists.txt @@ -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 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) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp index 95d7ca50f..9bab135d4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp @@ -79,6 +79,7 @@ MissionCompilerMainWindow::MissionCompilerMainWindow(QWidget *parent) : settings->endGroup(); NLLIGO::Register(); + // TODO try/catch exception. Crashes if path invalid. m_ligoConfig.readPrimitiveClass(NLMISC::CPath::lookup("world_editor_classes.xml").c_str(), false); NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin.cpp index 7bd06de91..d67128a50 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_plugin.cpp @@ -17,6 +17,8 @@ #include #include +#include "mission_compiler_settings_page.h" + namespace Plugin { @@ -35,7 +37,7 @@ bool MissionCompilerPlugin::initialize(ExtensionSystem::IPluginManager *pluginMa Q_UNUSED(errorString); _plugMan = pluginManager; - //addAutoReleasedObject(new CZonePainterSettingsPage(this)); + addAutoReleasedObject(new MissionCompilerSettingsPage(this)); addAutoReleasedObject(new CMissionCompilerContext(this)); //addAutoReleasedObject(new CCoreListener(this)); return true; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.cpp index f500933a7..028ac51db 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.cpp @@ -20,7 +20,7 @@ #include "../core/core_constants.h" #include "../core/icore.h" -#include "ui_server_entry_dialog.h" +#include "server_entry_dialog.h" // NeL includes #include @@ -58,12 +58,12 @@ QString MissionCompilerSettingsPage::trName() const QString MissionCompilerSettingsPage::category() const { - return QLatin1String("MissionCompilerSettings"); + return QLatin1String("Mission Compiler"); } QString MissionCompilerSettingsPage::trCategory() const { - return tr("MissionCompilerSettings"); + return tr("Mission Compiler"); } QIcon MissionCompilerSettingsPage::categoryIcon() const @@ -77,19 +77,15 @@ QWidget *MissionCompilerSettingsPage::createPage(QWidget *parent) m_ui.setupUi(m_page); readSettings(); - checkEnabledButton(); - connect(m_ui.addToolButton, SIGNAL(clicked()), this, SLOT(addPath())); - connect(m_ui.removeToolButton, SIGNAL(clicked()), this, SLOT(delPath())); - 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())); + connect(m_ui.addToolButton, SIGNAL(clicked()), this, SLOT(addServer())); + connect(m_ui.removeToolButton, SIGNAL(clicked()), this, SLOT(delServer())); + connect(m_ui.serversTableWidget, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(editServer(int,int))); return m_page; } void MissionCompilerSettingsPage::apply() { writeSettings(); - applySearchPaths(); } void MissionCompilerSettingsPage::finish() @@ -98,74 +94,57 @@ void MissionCompilerSettingsPage::finish() m_page = 0; } -void MissionCompilerSettingsPage::applySearchPaths() +void MissionCompilerSettingsPage::editServer(int row, int column) { - QStringList paths, remapExt; - QSettings *settings = Core::ICore::instance()->settings(); - settings->beginGroup(Core::Constants::DATA_PATH_SECTION); - if (m_recurse) - paths = settings->value(Core::Constants::RECURSIVE_SEARCH_PATHS).toStringList(); - else - paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList(); + ServerEntryDialog serverEntryDialog; + serverEntryDialog.setModal(true); + serverEntryDialog.show(); - remapExt = settings->value(Core::Constants::REMAP_EXTENSIONS).toStringList(); - settings->endGroup(); + // Copy the values from the row to the dialog. + 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) - NLMISC::CPath::remapExtension(remapExt.at(i - 1).toStdString(), remapExt.at(i).toStdString(), true); - - Q_FOREACH(QString path, paths) + if(serverEntryDialog.exec()) { - 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 (!newPath.isEmpty()) - //{ - // QTreeWidgetItem *newItem = new QTreeWidgetItem; - // newItem->setText(newPath); - // newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - // m_ui.serversTreeWidget->addItem(newItem); - // lastDir = newPath; - //} + if(serverEntryDialog.exec()) + { + int row = m_ui.serversTableWidget->rowCount(); + m_ui.serversTableWidget->insertRow(row); + QTableWidgetItem *item1 = new QTableWidgetItem(serverEntryDialog.getServerName()); + QTableWidgetItem *item2 = new QTableWidgetItem(serverEntryDialog.getTextPath()); + QTableWidgetItem *item3 = new QTableWidgetItem(serverEntryDialog.getPrimPath()); - //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()); - //if (!removeItem) - // delete removeItem; - - //checkEnabledButton(); -} - -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); - //} + QList selectedItems = m_ui.serversTableWidget->selectedItems(); + while(selectedItems.size() > 0) + { + m_ui.serversTableWidget->removeRow(selectedItems.back()->row()); + selectedItems = m_ui.serversTableWidget->selectedItems(); + } } void MissionCompilerSettingsPage::readSettings() @@ -203,15 +182,4 @@ void MissionCompilerSettingsPage::writeSettings() //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 */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.h index 43fc4ec5c..32b59e050 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.h @@ -50,21 +50,15 @@ public: void apply(); void finish(); - // Set of the search paths(not recursive) and the remap extensions (loading from settings file) - void applySearchPaths(); - private Q_SLOTS: - void addPath(); - void delPath(); - void upPath(); - void downPath(); + void addServer(); + void delServer(); + void editServer(int row, int column); private: void readSettings(); void writeSettings(); - void checkEnabledButton(); - bool m_recurse; QWidget *m_page; Ui::MissionCompilerSettingsPage m_ui; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.ui index 905cc5185..2ee2c2bce 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_settings_page.ui @@ -86,64 +86,6 @@ - - - - - 0 - 0 - - - - Up - - - - - - - :/buttons/images/ic_nel_up_item.png:/buttons/images/ic_nel_up_item.png - - - - 20 - 20 - - - - true - - - - - - - - 0 - 0 - - - - Down - - - - - - - :/buttons/images/ic_nel_down_item.png:/buttons/images/ic_nel_down_item.png - - - - 20 - 20 - - - - true - - - @@ -197,6 +139,9 @@ + + QAbstractItemView::NoEditTriggers + true diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.cpp new file mode 100644 index 000000000..b930eb5ec --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.cpp @@ -0,0 +1,89 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +// Project includes +#include "server_entry_dialog.h" + +#include "ui_server_entry_dialog.h" + +// NeL includes + +// Qt includes +#include + +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 */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.h new file mode 100644 index 000000000..e2a1d5016 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.h @@ -0,0 +1,59 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + + +#ifndef SERVER_ENTRY_DIALOG_H +#define SERVER_ENTRY_DIALOG_H + +#include + +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 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.ui index 5f7c6d827..002af82eb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.ui @@ -6,15 +6,15 @@ 0 0 - 400 - 300 + 488 + 175 Dialog - + Qt::Horizontal @@ -24,48 +24,70 @@ - - - - Server Name - - - - - - - Server Text Path - - - - - - - Server Primitive Path - - - - - - - - - - - - - - - - ... - - - - - - - ... + + + + Server Settings + + + + + Server Name + + + + + + + + + + Server Text Path + + + + + + + + + + ... + + + + + + + Server Primitive Path + + + + + + + + + + ... + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + +