use DisplayName namespace everywhere for setting displayname attribute

Dieser Commit ist enthalten in:
Reinder Feenstra 2021-06-29 21:04:52 +02:00
Ursprung 42a958d3f8
Commit 5694305ab8
17 geänderte Dateien mit 41 neuen und 23 gelöschten Zeilen

Datei anzeigen

@ -26,6 +26,7 @@
#include "../world/world.hpp" #include "../world/world.hpp"
#include "../world/worldloader.hpp" #include "../world/worldloader.hpp"
#include "../core/attributes.hpp" #include "../core/attributes.hpp"
#include "../utils/displayname.hpp"
Board::Board(const std::weak_ptr<World>& world, std::string_view _id) : Board::Board(const std::weak_ptr<World>& world, std::string_view _id) :
IdObject(world, _id), IdObject(world, _id),
@ -98,7 +99,7 @@ Board::Board(const std::weak_ptr<World>& world, std::string_view _id) :
const bool editable = w && contains(w->state.value(), WorldState::Edit); const bool editable = w && contains(w->state.value(), WorldState::Edit);
const bool stopped = w && !contains(w->state.value(), WorldState::Run); const bool stopped = w && !contains(w->state.value(), WorldState::Run);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, editable); Attributes::addEnabled(name, editable);
m_interfaceItems.add(name); m_interfaceItems.add(name);
m_interfaceItems.add(left); m_interfaceItems.add(left);

Datei anzeigen

@ -23,6 +23,7 @@
#include "blockrailtile.hpp" #include "blockrailtile.hpp"
#include "../../../world/world.hpp" #include "../../../world/world.hpp"
#include "../../../core/attributes.hpp" #include "../../../core/attributes.hpp"
#include "../../../utils/displayname.hpp"
BlockRailTile::BlockRailTile(const std::weak_ptr<World>& world, std::string_view _id) : BlockRailTile::BlockRailTile(const std::weak_ptr<World>& world, std::string_view _id) :
RailTile(world, _id, TileId::RailBlock), RailTile(world, _id, TileId::RailBlock),
@ -39,7 +40,7 @@ BlockRailTile::BlockRailTile(const std::weak_ptr<World>& world, std::string_view
const bool editable = w && contains(w->state.value(), WorldState::Edit); const bool editable = w && contains(w->state.value(), WorldState::Edit);
Attributes::addEnabled(name, editable); Attributes::addEnabled(name, editable);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
m_interfaceItems.add(name); m_interfaceItems.add(name);
m_interfaceItems.add(inputMap); m_interfaceItems.add(inputMap);
Attributes::addValues(state, blockStateValues); Attributes::addValues(state, blockStateValues);

Datei anzeigen

@ -24,6 +24,7 @@
#include "../../../world/world.hpp" #include "../../../world/world.hpp"
#include "../../../core/attributes.hpp" #include "../../../core/attributes.hpp"
#include "../../../utils/sensor.hpp" #include "../../../utils/sensor.hpp"
#include "../../../utils/displayname.hpp"
SensorRailTile::SensorRailTile(const std::weak_ptr<World>& world, std::string_view _id) : SensorRailTile::SensorRailTile(const std::weak_ptr<World>& world, std::string_view _id) :
StraightRailTile(world, _id, TileId::RailSensor), StraightRailTile(world, _id, TileId::RailSensor),
@ -64,7 +65,7 @@ SensorRailTile::SensorRailTile(const std::weak_ptr<World>& world, std::string_vi
const bool editable = w && contains(w->state.value(), WorldState::Edit); const bool editable = w && contains(w->state.value(), WorldState::Edit);
Attributes::addEnabled(name, editable); Attributes::addEnabled(name, editable);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
m_interfaceItems.add(name); m_interfaceItems.add(name);
Attributes::addEnabled(input, editable); Attributes::addEnabled(input, editable);
Attributes::addObjectList(input, w->inputs); Attributes::addObjectList(input, w->inputs);

Datei anzeigen

@ -23,6 +23,7 @@
#include "signalrailtile.hpp" #include "signalrailtile.hpp"
#include "../../../../core/attributes.hpp" #include "../../../../core/attributes.hpp"
#include "../../../../world/getworld.hpp" #include "../../../../world/getworld.hpp"
#include "../../../../utils/displayname.hpp"
SignalRailTile::SignalRailTile(const std::weak_ptr<World>& world, std::string_view _id, TileId tileId) : SignalRailTile::SignalRailTile(const std::weak_ptr<World>& world, std::string_view _id, TileId tileId) :
StraightRailTile(world, _id, tileId), StraightRailTile(world, _id, tileId),
@ -38,7 +39,7 @@ SignalRailTile::SignalRailTile(const std::weak_ptr<World>& world, std::string_vi
auto w = world.lock(); auto w = world.lock();
const bool editable = w && contains(w->state.value(), WorldState::Edit); const bool editable = w && contains(w->state.value(), WorldState::Edit);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, editable); Attributes::addEnabled(name, editable);
m_interfaceItems.add(name); m_interfaceItems.add(name);
Attributes::addObjectEditor(aspect, false); Attributes::addObjectEditor(aspect, false);

Datei anzeigen

@ -23,6 +23,7 @@
#include "turnoutrailtile.hpp" #include "turnoutrailtile.hpp"
#include "../../../../core/attributes.hpp" #include "../../../../core/attributes.hpp"
#include "../../../../world/world.hpp" #include "../../../../world/world.hpp"
#include "../../../../utils/displayname.hpp"
TurnoutRailTile::TurnoutRailTile(const std::weak_ptr<World>& world, std::string_view _id, TileId tileId) : TurnoutRailTile::TurnoutRailTile(const std::weak_ptr<World>& world, std::string_view _id, TileId tileId) :
RailTile(world, _id, tileId), RailTile(world, _id, tileId),
@ -38,7 +39,7 @@ TurnoutRailTile::TurnoutRailTile(const std::weak_ptr<World>& world, std::string_
auto w = world.lock(); auto w = world.lock();
const bool editable = w && contains(w->state.value(), WorldState::Edit); const bool editable = w && contains(w->state.value(), WorldState::Edit);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, editable); Attributes::addEnabled(name, editable);
m_interfaceItems.add(name); m_interfaceItems.add(name);
Attributes::addObjectEditor(position, false); Attributes::addObjectEditor(position, false);

Datei anzeigen

@ -23,6 +23,7 @@
#include "console.hpp" #include "console.hpp"
#include "../world/getworld.hpp" #include "../world/getworld.hpp"
#include "attributes.hpp" #include "attributes.hpp"
#include "../utils/displayname.hpp"
IdObject::IdObject(const std::weak_ptr<World>& world, std::string_view _id) : IdObject::IdObject(const std::weak_ptr<World>& world, std::string_view _id) :
Object{}, Object{},
@ -49,7 +50,7 @@ IdObject::IdObject(const std::weak_ptr<World>& world, std::string_view _id) :
auto w = world.lock(); auto w = world.lock();
const bool editable = w && contains(w->state.value(), WorldState::Edit); const bool editable = w && contains(w->state.value(), WorldState::Edit);
Attributes::addDisplayName(id, "object:id"); Attributes::addDisplayName(id, DisplayName::Object::id);
Attributes::addEnabled(id, editable); Attributes::addEnabled(id, editable);
m_interfaceItems.add(id); m_interfaceItems.add(id);
} }

Datei anzeigen

@ -28,6 +28,7 @@
#include "../decoder/decoder.hpp" #include "../decoder/decoder.hpp"
#include "../decoder/decoderlist.hpp" #include "../decoder/decoderlist.hpp"
#include "../../core/attributes.hpp" #include "../../core/attributes.hpp"
#include "../../utils/displayname.hpp"
CommandStation::CommandStation(const std::weak_ptr<World>& world, std::string_view _id) : CommandStation::CommandStation(const std::weak_ptr<World>& world, std::string_view _id) :
IdObject(world, _id), IdObject(world, _id),
@ -60,7 +61,7 @@ CommandStation::CommandStation(const std::weak_ptr<World>& world, std::string_vi
auto w = world.lock(); auto w = world.lock();
const bool editable = w && contains(w->state.value(), WorldState::Edit); const bool editable = w && contains(w->state.value(), WorldState::Edit);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, editable); Attributes::addEnabled(name, editable);
m_interfaceItems.add(name); m_interfaceItems.add(name);
@ -78,7 +79,7 @@ CommandStation::CommandStation(const std::weak_ptr<World>& world, std::string_vi
m_interfaceItems.add(controllers); m_interfaceItems.add(controllers);
Attributes::addDisplayName(notes, "object:notes"); Attributes::addDisplayName(notes, DisplayName::Object::notes);
m_interfaceItems.add(notes); m_interfaceItems.add(notes);
} }

Datei anzeigen

@ -26,6 +26,7 @@
#include "../commandstation/commandstation.hpp" #include "../commandstation/commandstation.hpp"
#include "../../world/getworld.hpp" #include "../../world/getworld.hpp"
#include "../../core/attributes.hpp" #include "../../core/attributes.hpp"
#include "../../utils/displayname.hpp"
Controller::Controller(const std::weak_ptr<World>& _world, std::string_view _id) : Controller::Controller(const std::weak_ptr<World>& _world, std::string_view _id) :
IdObject(_world, _id), IdObject(_world, _id),
@ -51,13 +52,13 @@ Controller::Controller(const std::weak_ptr<World>& _world, std::string_view _id)
auto world = _world.lock(); auto world = _world.lock();
const bool editable = world && contains(world->state.value(), WorldState::Edit); const bool editable = world && contains(world->state.value(), WorldState::Edit);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
m_interfaceItems.add(name); m_interfaceItems.add(name);
Attributes::addEnabled(commandStation, editable); Attributes::addEnabled(commandStation, editable);
Attributes::addObjectList(commandStation, world->commandStations); Attributes::addObjectList(commandStation, world->commandStations);
m_interfaceItems.add(commandStation); m_interfaceItems.add(commandStation);
m_interfaceItems.add(active); m_interfaceItems.add(active);
Attributes::addDisplayName(notes, "object:notes"); Attributes::addDisplayName(notes, DisplayName::Object::notes);
m_interfaceItems.add(notes); m_interfaceItems.add(notes);
} }

Datei anzeigen

@ -3,7 +3,7 @@
* *
* This file is part of the traintastic source code. * This file is part of the traintastic source code.
* *
* Copyright (C) 2019-2020 Reinder Feenstra * Copyright (C) 2019-2021 Reinder Feenstra
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -29,6 +29,7 @@
#include "../../world/world.hpp" #include "../../world/world.hpp"
#include "../commandstation/commandstation.hpp" #include "../commandstation/commandstation.hpp"
#include "../../core/attributes.hpp" #include "../../core/attributes.hpp"
#include "../../utils/displayname.hpp"
//constexpr uint16_t addressDCCMin = 1; //constexpr uint16_t addressDCCMin = 1;
constexpr uint16_t addressDCCShortMax = 127; constexpr uint16_t addressDCCShortMax = 127;
@ -111,7 +112,7 @@ Decoder::Decoder(const std::weak_ptr<World>& world, std::string_view _id) :
// const bool editable = w && contains(w->state.value(), WorldState::Edit) && speedStep == 0; // const bool editable = w && contains(w->state.value(), WorldState::Edit) && speedStep == 0;
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, false); Attributes::addEnabled(name, false);
m_interfaceItems.add(name); m_interfaceItems.add(name);
Attributes::addEnabled(commandStation, false); Attributes::addEnabled(commandStation, false);
@ -131,7 +132,7 @@ Decoder::Decoder(const std::weak_ptr<World>& world, std::string_view _id) :
m_interfaceItems.add(speedSteps); m_interfaceItems.add(speedSteps);
m_interfaceItems.add(speedStep); m_interfaceItems.add(speedStep);
m_interfaceItems.add(functions); m_interfaceItems.add(functions);
Attributes::addDisplayName(notes, "object:notes"); Attributes::addDisplayName(notes, DisplayName::Object::notes);
m_interfaceItems.add(notes); m_interfaceItems.add(notes);
updateEditable(); updateEditable();

Datei anzeigen

@ -23,6 +23,7 @@
#include "decoderchangeflags.hpp" #include "decoderchangeflags.hpp"
#include "../../world/world.hpp" #include "../../world/world.hpp"
#include "../../core/attributes.hpp" #include "../../core/attributes.hpp"
#include "../../utils/displayname.hpp"
const std::shared_ptr<DecoderFunction> DecoderFunction::null; const std::shared_ptr<DecoderFunction> DecoderFunction::null;
@ -54,7 +55,7 @@ DecoderFunction::DecoderFunction(Decoder& decoder, std::string_view _id) :
Attributes::addEnabled(number, editable); Attributes::addEnabled(number, editable);
m_interfaceItems.add(number); m_interfaceItems.add(number);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, editable); Attributes::addEnabled(name, editable);
m_interfaceItems.add(name); m_interfaceItems.add(name);
Attributes::addEnabled(type, editable); Attributes::addEnabled(type, editable);

Datei anzeigen

@ -24,6 +24,7 @@
#include "../../world/world.hpp" #include "../../world/world.hpp"
#include "list/inputlisttablemodel.hpp" #include "list/inputlisttablemodel.hpp"
#include "../../core/attributes.hpp" #include "../../core/attributes.hpp"
#include "../../utils/displayname.hpp"
Input::Input(const std::weak_ptr<World> world, std::string_view _id) : Input::Input(const std::weak_ptr<World> world, std::string_view _id) :
IdObject(world, _id), IdObject(world, _id),
@ -33,7 +34,7 @@ Input::Input(const std::weak_ptr<World> world, std::string_view _id) :
auto w = world.lock(); auto w = world.lock();
const bool editable = w && contains(w->state.value(), WorldState::Edit); const bool editable = w && contains(w->state.value(), WorldState::Edit);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, editable); Attributes::addEnabled(name, editable);
m_interfaceItems.add(name); m_interfaceItems.add(name);
Attributes::addObjectEditor(value, false); Attributes::addObjectEditor(value, false);

Datei anzeigen

@ -24,6 +24,7 @@
#include "../../world/world.hpp" #include "../../world/world.hpp"
#include "list/outputlisttablemodel.hpp" #include "list/outputlisttablemodel.hpp"
#include "../../core/attributes.hpp" #include "../../core/attributes.hpp"
#include "../../utils/displayname.hpp"
Output::Output(const std::weak_ptr<World> world, std::string_view _id) : Output::Output(const std::weak_ptr<World> world, std::string_view _id) :
IdObject(world, _id), IdObject(world, _id),
@ -41,7 +42,7 @@ Output::Output(const std::weak_ptr<World> world, std::string_view _id) :
auto w = world.lock(); auto w = world.lock();
const bool editable = w && contains(w->state.value(), WorldState::Edit); const bool editable = w && contains(w->state.value(), WorldState::Edit);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, editable); Attributes::addEnabled(name, editable);
m_interfaceItems.add(name); m_interfaceItems.add(name);
Attributes::addObjectEditor(value, false); Attributes::addObjectEditor(value, false);

Datei anzeigen

@ -30,6 +30,7 @@
#include "../core/attributes.hpp" #include "../core/attributes.hpp"
#include "../world/worldloader.hpp" #include "../world/worldloader.hpp"
#include "../world/worldsaver.hpp" #include "../world/worldsaver.hpp"
#include "../utils/displayname.hpp"
namespace Lua { namespace Lua {
@ -64,6 +65,7 @@ Script::Script(const std::weak_ptr<World>& world, std::string_view _id) :
stopSandbox(); stopSandbox();
}} }}
{ {
Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, false); Attributes::addEnabled(name, false);
m_interfaceItems.add(name); m_interfaceItems.add(name);
Attributes::addValues(state, LuaScriptStateValues); Attributes::addValues(state, LuaScriptStateValues);

Datei anzeigen

@ -3,7 +3,7 @@
* *
* This file is part of the traintastic source code. * This file is part of the traintastic source code.
* *
* Copyright (C) 2019-2020 Reinder Feenstra * Copyright (C) 2019-2021 Reinder Feenstra
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,6 +24,7 @@
#include "../world/world.hpp" #include "../world/world.hpp"
#include "trainlisttablemodel.hpp" #include "trainlisttablemodel.hpp"
#include "../core/attributes.hpp" #include "../core/attributes.hpp"
#include "../utils/displayname.hpp"
Train::Train(const std::weak_ptr<World>& world, std::string_view _id) : Train::Train(const std::weak_ptr<World>& world, std::string_view _id) :
IdObject(world, _id), IdObject(world, _id),
@ -42,7 +43,7 @@ Train::Train(const std::weak_ptr<World>& world, std::string_view _id) :
auto w = world.lock(); auto w = world.lock();
const bool editable = w && contains(w->state.value(), WorldState::Edit); const bool editable = w && contains(w->state.value(), WorldState::Edit);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, editable); Attributes::addEnabled(name, editable);
m_interfaceItems.add(name); m_interfaceItems.add(name);
m_interfaceItems.add(lob); m_interfaceItems.add(lob);
@ -57,7 +58,7 @@ Train::Train(const std::weak_ptr<World>& world, std::string_view _id) :
m_interfaceItems.add(throttleSpeed); m_interfaceItems.add(throttleSpeed);
m_interfaceItems.add(weight); m_interfaceItems.add(weight);
m_interfaceItems.add(vehicles); m_interfaceItems.add(vehicles);
Attributes::addDisplayName(notes, "object:notes"); Attributes::addDisplayName(notes, DisplayName::Object::notes);
m_interfaceItems.add(notes); m_interfaceItems.add(notes);
} }

Datei anzeigen

@ -31,6 +31,7 @@ namespace DisplayName
{ {
constexpr std::string_view id = "object:id"; constexpr std::string_view id = "object:id";
constexpr std::string_view name = "object:name"; constexpr std::string_view name = "object:name";
constexpr std::string_view notes = "object:notes";
} }
} }

Datei anzeigen

@ -3,7 +3,7 @@
* *
* This file is part of the traintastic source code. * This file is part of the traintastic source code.
* *
* Copyright (C) 2019-2020 Reinder Feenstra * Copyright (C) 2019-2021 Reinder Feenstra
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -23,6 +23,7 @@
#include "vehicle.hpp" #include "vehicle.hpp"
#include "../world/world.hpp" #include "../world/world.hpp"
#include "../core/attributes.hpp" #include "../core/attributes.hpp"
#include "../utils/displayname.hpp"
Vehicle::Vehicle(const std::weak_ptr<World>& world, std::string_view _id) : Vehicle::Vehicle(const std::weak_ptr<World>& world, std::string_view _id) :
IdObject(world, _id), IdObject(world, _id),
@ -32,10 +33,10 @@ Vehicle::Vehicle(const std::weak_ptr<World>& world, std::string_view _id) :
auto w = world.lock(); auto w = world.lock();
const bool editable = w && contains(w->state.value(), WorldState::Edit); const bool editable = w && contains(w->state.value(), WorldState::Edit);
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, editable); Attributes::addEnabled(name, editable);
m_interfaceItems.add(name); m_interfaceItems.add(name);
Attributes::addDisplayName(notes, "object:notes"); Attributes::addDisplayName(notes, DisplayName::Object::notes);
m_interfaceItems.add(notes); m_interfaceItems.add(notes);
} }

Datei anzeigen

@ -31,6 +31,7 @@
#include "../core/objectlisttablemodel.hpp" #include "../core/objectlisttablemodel.hpp"
#include "../core/attributes.hpp" #include "../core/attributes.hpp"
#include "../core/abstractvectorproperty.hpp" #include "../core/abstractvectorproperty.hpp"
#include "../utils/displayname.hpp"
using nlohmann::json; using nlohmann::json;
@ -187,7 +188,7 @@ World::World(Private) :
m_filename = Traintastic::instance->worldDir() / to_string(m_uuid) / filename; m_filename = Traintastic::instance->worldDir() / to_string(m_uuid) / filename;
m_filenameState = Traintastic::instance->worldDir() / to_string(m_uuid) / filenameState; m_filenameState = Traintastic::instance->worldDir() / to_string(m_uuid) / filenameState;
Attributes::addDisplayName(name, "object:name"); Attributes::addDisplayName(name, DisplayName::Object::name);
m_interfaceItems.add(name); m_interfaceItems.add(name);
Attributes::addEnabled(scale, false); Attributes::addEnabled(scale, false);
Attributes::addValues(scale, WorldScaleValues); Attributes::addValues(scale, WorldScaleValues);