fix(editor): hidden internal services
This commit is contained in:
parent
6803a659cb
commit
93984ce1c0
5 changed files with 22 additions and 4 deletions
|
@ -3,7 +3,7 @@
|
||||||
#include "objects/annotation.h"
|
#include "objects/annotation.h"
|
||||||
#include "objects/base/service.h"
|
#include "objects/base/service.h"
|
||||||
|
|
||||||
class DEF_INST_SERVICE JointsService : public Service {
|
class DEF_INST_SERVICE_(hidden) JointsService : public Service {
|
||||||
AUTOGEN_PREAMBLE
|
AUTOGEN_PREAMBLE
|
||||||
private:
|
private:
|
||||||
std::optional<std::shared_ptr<Workspace>> jointWorkspace();
|
std::optional<std::shared_ptr<Workspace>> jointWorkspace();
|
||||||
|
|
|
@ -15,7 +15,7 @@ struct SleepingThread {
|
||||||
|
|
||||||
class Script;
|
class Script;
|
||||||
|
|
||||||
class DEF_INST_SERVICE ScriptContext : public Service {
|
class DEF_INST_SERVICE_(hidden) ScriptContext : public Service {
|
||||||
AUTOGEN_PREAMBLE
|
AUTOGEN_PREAMBLE
|
||||||
|
|
||||||
std::vector<SleepingThread> sleepingThreads;
|
std::vector<SleepingThread> sleepingThreads;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
// Container class for server scripts
|
// Container class for server scripts
|
||||||
// Also handles/manages running server scripts on run
|
// Also handles/manages running server scripts on run
|
||||||
class DEF_INST_SERVICE_(explorer_icon="server-scripts") ServerScriptService : public Service {
|
class DEF_INST_SERVICE_(explorer_icon="server-scripts", hidden) ServerScriptService : public Service {
|
||||||
AUTOGEN_PREAMBLE
|
AUTOGEN_PREAMBLE
|
||||||
protected:
|
protected:
|
||||||
void InitService() override;
|
void InitService() override;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class DEF_INST_SERVICE Selection : public Service {
|
class DEF_INST_SERVICE_(hidden) Selection : public Service {
|
||||||
AUTOGEN_PREAMBLE
|
AUTOGEN_PREAMBLE
|
||||||
private:
|
private:
|
||||||
std::vector<std::shared_ptr<Instance>> selection;
|
std::vector<std::shared_ptr<Instance>> selection;
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
#include <qmimedata.h>
|
#include <qmimedata.h>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#ifdef _NDEBUG
|
||||||
|
#define NDEBUG
|
||||||
|
#endif
|
||||||
|
|
||||||
#define M_mainWindow dynamic_cast<MainWindow*>(dynamic_cast<QWidget*>(dynamic_cast<QObject*>(this)->parent())->window())
|
#define M_mainWindow dynamic_cast<MainWindow*>(dynamic_cast<QWidget*>(dynamic_cast<QObject*>(this)->parent())->window())
|
||||||
|
|
||||||
// https://doc.qt.io/qt-6/qtwidgets-itemviews-simpletreemodel-example.html#testing-the-model
|
// https://doc.qt.io/qt-6/qtwidgets-itemviews-simpletreemodel-example.html#testing-the-model
|
||||||
|
@ -49,8 +53,14 @@ QModelIndex ExplorerModel::index(int row, int column, const QModelIndex &parent)
|
||||||
? static_cast<Instance*>(parent.internalPointer())
|
? static_cast<Instance*>(parent.internalPointer())
|
||||||
: rootItem.get();
|
: rootItem.get();
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
if (parentItem->GetChildren().size() >= (size_t)row && !(parentItem->GetChildren()[row]->GetClass()->flags & INSTANCE_HIDDEN))
|
if (parentItem->GetChildren().size() >= (size_t)row && !(parentItem->GetChildren()[row]->GetClass()->flags & INSTANCE_HIDDEN))
|
||||||
return createIndex(row, column, parentItem->GetChildren()[row].get());
|
return createIndex(row, column, parentItem->GetChildren()[row].get());
|
||||||
|
#else
|
||||||
|
// Don't hide in debug builds
|
||||||
|
if (parentItem->GetChildren().size() >= (size_t)row)
|
||||||
|
return createIndex(row, column, parentItem->GetChildren()[row].get());
|
||||||
|
#endif
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +107,15 @@ int ExplorerModel::rowCount(const QModelIndex &parent) const {
|
||||||
? static_cast<Instance*>(parent.internalPointer())
|
? static_cast<Instance*>(parent.internalPointer())
|
||||||
: rootItem.get();
|
: rootItem.get();
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
// Trim trailing hidden items as they make the branches look weird
|
||||||
|
int count = parentItem->GetChildren().size();
|
||||||
|
while (count > 0 && parentItem->GetChildren()[count-1]->GetClass()->flags & INSTANCE_HIDDEN) count--;
|
||||||
|
return count;
|
||||||
|
#else
|
||||||
|
// Don't hide in debug builds
|
||||||
return parentItem->GetChildren().size();
|
return parentItem->GetChildren().size();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int ExplorerModel::columnCount(const QModelIndex &parent) const {
|
int ExplorerModel::columnCount(const QModelIndex &parent) const {
|
||||||
|
|
Loading…
Add table
Reference in a new issue