Changed: #1193 Added display sheet id plugin (plugin provided pemeon).
This commit is contained in:
parent
cb294a76e4
commit
4eb4248102
8 changed files with 431 additions and 0 deletions
|
@ -0,0 +1,44 @@
|
|||
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${LIBXML2_INCLUDE_DIR}
|
||||
${QT_INCLUDES})
|
||||
|
||||
FILE(GLOB SRC *.cpp *.h)
|
||||
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
||||
|
||||
SET(OVQT_DISP_SHEET_ID_PLUGIN_HDR
|
||||
bin_reader.h
|
||||
dialog.h
|
||||
disp_sheet_id_plugin.h)
|
||||
|
||||
SET(OVQT_DISP_SHEET_ID_PLUGIN_UIS
|
||||
dialog.ui)
|
||||
|
||||
SET(QT_USE_QTGUI TRUE)
|
||||
SET(QT_USE_QTOPENGL TRUE)
|
||||
|
||||
QT4_WRAP_CPP(OVQT_DISP_SHEET_ID_PLUGIN_MOC_SRC ${OVQT_DISP_SHEET_ID_PLUGIN_HDR})
|
||||
QT4_WRAP_UI(OVQT_DISP_SHEET_ID_PLUGIN_UI_HDRS ${OVQT_DISP_SHEET_ID_PLUGIN_UIS})
|
||||
|
||||
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_DISP_SHEET_ID_PLUGIN_UI_HDRS})
|
||||
SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_DISP_SHEET_ID_PLUGIN_MOC_SRC})
|
||||
SOURCE_GROUP("Display sheet id Plugin" FILES ${SRC})
|
||||
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})
|
||||
|
||||
IF(WITH_STLPORT)
|
||||
TARGET_LINK_LIBRARIES(ovqt_plugin_disp_sheet_id ${CMAKE_THREAD_LIBS_INIT})
|
||||
ENDIF(WITH_STLPORT)
|
||||
|
||||
NL_DEFAULT_PROPS(ovqt_plugin_disp_sheet_id "NeL, Tools, 3D: Object Viewer Qt Plugin: Display sheet id")
|
||||
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_disp_sheet_id)
|
||||
NL_ADD_LIB_SUFFIX(ovqt_plugin_disp_sheet_id)
|
||||
|
||||
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
|
||||
|
||||
INSTALL(TARGETS ovqt_plugin_disp_sheet_id LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d)
|
|
@ -0,0 +1,55 @@
|
|||
#include "nel/misc/types_nl.h"
|
||||
#include <stdio.h>
|
||||
#include "bin_reader.h"
|
||||
#include <QTableWidget>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QByteArray>
|
||||
#include <QVector>
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/sheet_id.h"
|
||||
#include <vector>
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
class CPred
|
||||
{
|
||||
public:
|
||||
bool operator()(const CSheetId &a, const CSheetId &b)
|
||||
{
|
||||
return a.toString()<b.toString();
|
||||
}
|
||||
};
|
||||
|
||||
BinReader::BinReader(QString dir)
|
||||
{
|
||||
QByteArray dirChar = dir.toLatin1();
|
||||
char* dirCharRef = dirChar.data();
|
||||
// NLMISC::CApplicationContext appContext;
|
||||
CPath::addSearchPath(dirCharRef);
|
||||
CSheetId::init(false);
|
||||
CSheetId::buildIdVector(this->SheetList);
|
||||
CPred Pred;
|
||||
sort(this->SheetList.begin(), this->SheetList.end(), Pred);
|
||||
// this->SheetList.fromStdVector(sheets);
|
||||
}
|
||||
int BinReader::count()
|
||||
{
|
||||
return this->SheetList.size();
|
||||
}
|
||||
std::vector<CSheetId> 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#include "nel/misc/types_nl.h"
|
||||
#include <stdio.h>
|
||||
#include <QTableWidget>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QByteArray>
|
||||
#include <QVector>
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/sheet_id.h"
|
||||
#include <vector>
|
||||
#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<CSheetId> getVector() const;
|
||||
private:
|
||||
std::vector<CSheetId> SheetList;
|
||||
};
|
|
@ -0,0 +1,47 @@
|
|||
#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();
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QFileDialog>
|
||||
|
||||
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
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>508</width>
|
||||
<height>531</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="table"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="browseButton">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="reloadButton">
|
||||
<property name="text">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="endButton">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>endButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>371</x>
|
||||
<y>282</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>199</x>
|
||||
<y>149</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -0,0 +1,97 @@
|
|||
#include "disp_sheet_id_plugin.h"
|
||||
#include "dialog.h"
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QMenuBar>
|
||||
|
||||
#include "../../extension_system/iplugin_spec.h"
|
||||
|
||||
#include "nel/misc/debug.h"
|
||||
|
||||
using namespace Plugin;
|
||||
|
||||
bool MyPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
||||
{
|
||||
Q_UNUSED(errorString);
|
||||
_plugMan = pluginManager;
|
||||
QMainWindow *wnd = qobject_cast<QMainWindow *>(objectByName("CMainWindow"));
|
||||
if (!wnd)
|
||||
{
|
||||
*errorString = tr("Not found QMainWindow Object Viewer Qt.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MyPlugin::extensionsInitialized()
|
||||
{
|
||||
QMenu *toolsMenu = qobject_cast<QMenu *>(objectByName("ovqt.Menu.Tools"));
|
||||
nlassert(toolsMenu);
|
||||
|
||||
QAction *newAction = toolsMenu->addAction("Display sheet id");
|
||||
|
||||
connect(newAction, SIGNAL(triggered()), this, SLOT(execMessageBox()));
|
||||
}
|
||||
|
||||
void MyPlugin::execMessageBox()
|
||||
{
|
||||
Dialog dialog;
|
||||
dialog.show();
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
void MyPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
// Ensure that a context doesn't exist yet.
|
||||
// This only applies to platforms without PIC, e.g. Windows.
|
||||
nlassert(!NLMISC::INelContext::isContextInitialised());
|
||||
#endif // NL_OS_WINDOWS
|
||||
_LibContext = new NLMISC::CLibraryContext(*nelContext);
|
||||
}
|
||||
|
||||
QString MyPlugin::name() const
|
||||
{
|
||||
return "Display sheet id";
|
||||
}
|
||||
|
||||
QString MyPlugin::version() const
|
||||
{
|
||||
return "0.1";
|
||||
}
|
||||
|
||||
QString MyPlugin::vendor() const
|
||||
{
|
||||
return "pemeon";
|
||||
}
|
||||
|
||||
QString MyPlugin::description() const
|
||||
{
|
||||
return "Display sheet id";
|
||||
}
|
||||
|
||||
QList<QString> MyPlugin::dependencies() const
|
||||
{
|
||||
return QList<QString>();
|
||||
}
|
||||
|
||||
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)
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef PLUGIN1_H
|
||||
#define PLUGIN1_H
|
||||
|
||||
#include "../../extension_system/iplugin.h"
|
||||
|
||||
#include "nel/misc/app_context.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
class CLibraryContext;
|
||||
}
|
||||
|
||||
namespace NLQT
|
||||
{
|
||||
class IPluginSpec;
|
||||
}
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
class MyPlugin : public QObject, public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(ExtensionSystem::IPlugin)
|
||||
public:
|
||||
|
||||
bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString);
|
||||
void extensionsInitialized();
|
||||
|
||||
void setNelContext(NLMISC::INelContext *nelContext);
|
||||
|
||||
QString name() const;
|
||||
QString version() const;
|
||||
QString vendor() const;
|
||||
QString description() const;
|
||||
QList<QString> dependencies() const;
|
||||
|
||||
QObject *objectByName(const QString &name) const;
|
||||
ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void execMessageBox();
|
||||
|
||||
protected:
|
||||
NLMISC::CLibraryContext *_LibContext;
|
||||
|
||||
private:
|
||||
ExtensionSystem::IPluginManager *_plugMan;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Plugin1
|
||||
|
||||
#endif // PLUGIN1_H
|
Loading…
Reference in a new issue