From b436e7a8f6b9446a436131df0e3444d77abb41c8 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Fri, 4 Mar 2011 15:50:24 +0200 Subject: [PATCH] Changed: #1193 Polish sheet id view plugin code. --- .../src/plugins/disp_sheet_id/CMakeLists.txt | 7 +- .../src/plugins/disp_sheet_id/bin_reader.cpp | 55 ------------ .../src/plugins/disp_sheet_id/bin_reader.h | 24 ----- .../src/plugins/disp_sheet_id/dialog.cpp | 47 ---------- .../src/plugins/disp_sheet_id/dialog.h | 28 ------ .../disp_sheet_id/disp_sheet_id_plugin.cpp | 89 ++++++++++--------- .../disp_sheet_id/disp_sheet_id_plugin.h | 33 ++++--- .../plugins/disp_sheet_id/sheet_id_view.cpp | 75 ++++++++++++++++ .../src/plugins/disp_sheet_id/sheet_id_view.h | 43 +++++++++ .../{dialog.ui => sheet_id_view.ui} | 27 +++--- .../src/plugins/object_viewer/emitter_form.ui | 2 +- 11 files changed, 203 insertions(+), 227 deletions(-) delete mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.cpp delete mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.h delete mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.cpp delete mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/sheet_id_view.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/sheet_id_view.h rename code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/{dialog.ui => sheet_id_view.ui} (76%) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/CMakeLists.txt index de5083dad..34c65c178 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/CMakeLists.txt @@ -9,12 +9,11 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) SET(OVQT_DISP_SHEET_ID_PLUGIN_HDR - bin_reader.h - dialog.h + sheet_id_view.h disp_sheet_id_plugin.h) SET(OVQT_DISP_SHEET_ID_PLUGIN_UIS - dialog.ui) + sheet_id_view.ui) SET(QT_USE_QTGUI TRUE) SET(QT_USE_QTOPENGL TRUE) @@ -29,7 +28,7 @@ SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) ADD_LIBRARY(ovqt_plugin_disp_sheet_id MODULE ${SRC} ${OVQT_DISP_SHEET_ID_PLUGIN_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_DISP_SHEET_ID_PLUGIN_UI_HDRS}) -TARGET_LINK_LIBRARIES(ovqt_plugin_disp_sheet_id nelmisc nel3d ${QT_LIBRARIES}) +TARGET_LINK_LIBRARIES(ovqt_plugin_disp_sheet_id ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES}) IF(WITH_STLPORT) TARGET_LINK_LIBRARIES(ovqt_plugin_disp_sheet_id ${CMAKE_THREAD_LIBS_INIT}) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.cpp deleted file mode 100644 index 720dc6af5..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "nel/misc/types_nl.h" -#include -#include "bin_reader.h" -#include -#include -#include -#include -#include "nel/misc/path.h" -#include "nel/misc/sheet_id.h" -#include -#include "nel/misc/types_nl.h" - -class CPred -{ -public: - bool operator()(const CSheetId &a, const CSheetId &b) - { - return a.toString()SheetList); - CPred Pred; - sort(this->SheetList.begin(), this->SheetList.end(), Pred); -// this->SheetList.fromStdVector(sheets); -} -int BinReader::count() -{ - return this->SheetList.size(); -} -std::vector BinReader::getVector() const -{ - return this->SheetList; -} -void BinReader::pushToTable(QTableWidget*& table) -{ - table->clear(); - table->setRowCount(this->SheetList.size()); - table->setColumnCount(2); - for (int i = 0; i < this->SheetList.size(); i++) - { - QTableWidgetItem* item1 = new QTableWidgetItem(QString(this->SheetList[i].toString().c_str())); - QTableWidgetItem* item2 = new QTableWidgetItem(QString("%1").arg(this->SheetList[i].asInt())); - table->setItem(i,1,item1); - table->setItem(i,2,item2); - } - -} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.h deleted file mode 100644 index a63bd6b90..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.h +++ /dev/null @@ -1,24 +0,0 @@ -#include "nel/misc/types_nl.h" -#include -#include -#include -#include -#include -#include "nel/misc/path.h" -#include "nel/misc/sheet_id.h" -#include -#include "nel/misc/types_nl.h" - -using namespace std; -using namespace NLMISC; - -class BinReader -{ -public: - BinReader(QString dir); - int count(); - void pushToTable(QTableWidget*& table); - std::vector getVector() const; -private: - std::vector SheetList; -}; \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.cpp deleted file mode 100644 index 8ea976369..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "dialog.h" -#include "ui_dialog.h" -#include "bin_reader.h" - -#include "QMessageBox" -#include "QSettings" - -Dialog::Dialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog) -{ - ui->setupUi(this); - QSettings settings("ovqt_sheet_builder.ini", QSettings::IniFormat); - dir = settings.value("PathToSheetId", "").toString(); - connect(ui->reloadButton,SIGNAL(clicked()),this,SLOT(reloadTable())); - connect(ui->browseButton,SIGNAL(clicked()),this,SLOT(getDir())); - -} - -Dialog::~Dialog() -{ - delete ui; -} -void Dialog::reloadTable() -{ - QFile file(dir + QString("./sheet_id.bin")); - if(file.exists() == true) - { - QSettings settings("ovqt_sheet_builder.ini", QSettings::IniFormat); - settings.setValue("PathToSheetId", dir); - BinReader reader(this->dir); - reader.pushToTable(ui->table); - - } - else - { - QMessageBox errorBox; - errorBox.setText(QString("File sheet_id.bin doesn't exist in direcotry: \n") + this->dir); - errorBox.exec(); - } -} -void Dialog::getDir() -{ - QFileDialog fileDialog(this); - fileDialog.setFileMode(QFileDialog::DirectoryOnly); - this->dir = fileDialog.getExistingDirectory(); -} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.h deleted file mode 100644 index 6c33c3797..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef DIALOG_H -#define DIALOG_H - -#include -#include - -namespace Ui -{ -class Dialog; -} - -class Dialog : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog(QWidget *parent = 0); - ~Dialog(); -public Q_SLOTS: - void reloadTable(); - void getDir(); - -private: - QString dir; - Ui::Dialog *ui; -}; - -#endif // DIALOG_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.cpp index 7a45fc8cb..54cba53a6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.cpp @@ -1,5 +1,27 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// 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 "disp_sheet_id_plugin.h" -#include "dialog.h" +#include "sheet_id_view.h" +#include "../core/icore.h" +#include "../core/imenu_manager.h" +#include "../core/core_constants.h" + +// Qt includes #include #include #include @@ -7,43 +29,38 @@ #include #include -#include "../../extension_system/iplugin_spec.h" - +// NeL includes #include "nel/misc/debug.h" -using namespace Plugin; +using namespace SheetIdViewPlugin; -bool MyPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) +bool DispSheetIdPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) { Q_UNUSED(errorString); _plugMan = pluginManager; - QMainWindow *wnd = qobject_cast(objectByName("CMainWindow")); - if (!wnd) - { - *errorString = tr("Not found QMainWindow Object Viewer Qt."); - return false; - } return true; } -void MyPlugin::extensionsInitialized() +void DispSheetIdPlugin::extensionsInitialized() { - QMenu *toolsMenu = qobject_cast(objectByName("ovqt.Menu.Tools")); - nlassert(toolsMenu); + Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); - QAction *newAction = toolsMenu->addAction("Display sheet id"); + QMenu *sheetMenu = menuManager->menu(Core::Constants::M_SHEET); + QAction *sheetIdViewAction = sheetMenu->addAction(tr("Sheet id view")); + menuManager->registerAction(sheetIdViewAction, "SheetIdView"); + connect(sheetIdViewAction, SIGNAL(triggered()), this, SLOT(execBuilderDialog())); - connect(newAction, SIGNAL(triggered()), this, SLOT(execMessageBox())); + connect(sheetIdViewAction, SIGNAL(triggered()), this, SLOT(execMessageBox())); } -void MyPlugin::execMessageBox() +void DispSheetIdPlugin::execMessageBox() { - Dialog dialog; + SheetIdView dialog; dialog.show(); dialog.exec(); } -void MyPlugin::setNelContext(NLMISC::INelContext *nelContext) +void DispSheetIdPlugin::setNelContext(NLMISC::INelContext *nelContext) { #ifdef NL_OS_WINDOWS // Ensure that a context doesn't exist yet. @@ -53,45 +70,31 @@ void MyPlugin::setNelContext(NLMISC::INelContext *nelContext) _LibContext = new NLMISC::CLibraryContext(*nelContext); } -QString MyPlugin::name() const +QString DispSheetIdPlugin::name() const { return "Display sheet id"; } -QString MyPlugin::version() const +QString DispSheetIdPlugin::version() const { - return "0.1"; + return "1.0"; } -QString MyPlugin::vendor() const +QString DispSheetIdPlugin::vendor() const { return "pemeon"; } -QString MyPlugin::description() const +QString DispSheetIdPlugin::description() const { return "Display sheet id"; } -QList MyPlugin::dependencies() const +QStringList DispSheetIdPlugin::dependencies() const { - return QList(); + QStringList list; + list.append(Core::Constants::OVQT_CORE_PLUGIN); + return list; } -QObject* MyPlugin::objectByName(const QString &name) const -{ - Q_FOREACH (QObject *qobj, _plugMan->allObjects()) - if (qobj->objectName() == name) - return qobj; - return 0; -} - -ExtensionSystem::IPluginSpec *MyPlugin::pluginByName(const QString &name) const -{ - Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins()) - if (spec->name() == name) - return spec; - return 0; -} - -Q_EXPORT_PLUGIN(MyPlugin) +Q_EXPORT_PLUGIN(DispSheetIdPlugin) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.h index 4c9eb78a6..75a25b724 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.h @@ -1,5 +1,21 @@ -#ifndef PLUGIN1_H -#define PLUGIN1_H +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// 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 SHEET_ID_VIEW_PLUGIN_H +#define SHEET_ID_VIEW_PLUGIN_H #include "../../extension_system/iplugin.h" @@ -17,10 +33,10 @@ namespace NLQT class IPluginSpec; } -namespace Plugin +namespace SheetIdViewPlugin { -class MyPlugin : public QObject, public ExtensionSystem::IPlugin +class DispSheetIdPlugin : public QObject, public ExtensionSystem::IPlugin { Q_OBJECT Q_INTERFACES(ExtensionSystem::IPlugin) @@ -35,10 +51,7 @@ public: QString version() const; QString vendor() const; QString description() const; - QList dependencies() const; - - QObject *objectByName(const QString &name) const; - ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const; + QStringList dependencies() const; private Q_SLOTS: void execMessageBox(); @@ -51,6 +64,6 @@ private: }; -} // namespace Plugin1 +} // namespace SheetIdViewPlugin -#endif // PLUGIN1_H +#endif // SHEET_ID_VIEW_PLUGIN_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/sheet_id_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/sheet_id_view.cpp new file mode 100644 index 000000000..bdd93ad41 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/sheet_id_view.cpp @@ -0,0 +1,75 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// 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 . + +#include "sheet_id_view.h" +#include "ui_dialog.h" + +#include "nel/misc/path.h" + +#include +#include + +class CPred +{ +public: + bool operator()(const NLMISC::CSheetId &a, const NLMISC::CSheetId &b) + { + return a.toString()clear(); + m_ui.table->setRowCount(m_sheetList.size()); + m_ui.table->setColumnCount(2); + for (size_t i = 0; i < m_sheetList.size(); i++) + { + QApplication::processEvents(); + QTableWidgetItem* item1 = new QTableWidgetItem(QString(m_sheetList[i].toString().c_str())); + QTableWidgetItem* item2 = new QTableWidgetItem(QString("%1").arg(m_sheetList[i].asInt())); + m_ui.table->setItem(i,1,item1); + m_ui.table->setItem(i,2,item2); + } +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/sheet_id_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/sheet_id_view.h new file mode 100644 index 000000000..e9c758481 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/sheet_id_view.h @@ -0,0 +1,43 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// 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 SHEET_ID_VIEW_H +#define SHEET_ID_VIEW_H + +#include "ui_sheet_id_view.h" + +#include "nel/misc/types_nl.h" +#include "nel/misc/sheet_id.h" + +#include + +class SheetIdView : public QDialog +{ + Q_OBJECT + +public: + explicit SheetIdView(QWidget *parent = 0); + ~SheetIdView(); + +public Q_SLOTS: + void pushToTable(); + +private: + std::vector m_sheetList; + Ui::SheetIdView m_ui; +}; + +#endif // SHEET_ID_VIEW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/sheet_id_view.ui similarity index 76% rename from code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.ui rename to code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/sheet_id_view.ui index 23e88c691..1d1d4e1ac 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/sheet_id_view.ui @@ -1,21 +1,25 @@ - Dialog - + SheetIdView + 0 0 - 508 - 531 + 426 + 393 - Dialog + Sheet Id View - + + + QAbstractItemView::NoEditTriggers + + @@ -32,17 +36,10 @@ - - - - Browse - - - - Display + Fill table @@ -63,7 +60,7 @@ endButton clicked() - Dialog + SheetIdView reject() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/emitter_form.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/emitter_form.ui index 79f9dcce1..134a06f79 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/emitter_form.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/emitter_form.ui @@ -26,7 +26,7 @@ QTabWidget::East - 1 + 0 true