50 return mySelected.count(
id) > 0;
56 mySelected.insert(
id);
78const std::unordered_set<GUIGlID>&
133 throw ProcessError(
"Unknown object in GUISelectedStorage::deselect (id=" +
toString(
id) +
").");
150 throw ProcessError(
"Unknown object in GUISelectedStorage::toggleSelection (id=" +
toString(
id) +
").");
153 bool selected =
isSelected(object->getType(),
id);
163const std::unordered_set<GUIGlID>&
169const std::unordered_set<GUIGlID>&
178 selection.second.clear();
197 std::set<GUIGlID> result;
198 std::ostringstream msg;
201 while (strm.good()) {
204 if (line.length() == 0) {
213 if (type !=
GLO_MAX && (object->getType() != type)) {
215 if (numIgnored + numMissing <= maxErrors) {
216 msg <<
TLF(
"Ignoring item '%' because of invalid type %\n", line,
toString(object->getType()));
219 result.insert(object->getGlID());
223 if (dynamicNotFound !=
nullptr && (
227 (*dynamicNotFound) << line <<
"\n";
229 if (numIgnored + numMissing <= maxErrors) {
230 msg <<
TLF(
"Item '%' not found\n", line);
236 if (numIgnored + numMissing > maxErrors) {
237 msg <<
"...\n" <<
TLF(
"% objects ignored, % objects not found\n", numIgnored, numMissing);
246 std::ifstream strm(filename.c_str());
248 return TLF(
"Could not open '%'.\n", filename);
250 std::string errors =
load(strm, type, dynamicNotFound);
259 const std::set<GUIGlID> ids =
loadIDs(strm, errors, type, dynamicNotFound);
260 for (
const auto glID : ids) {
297 for (
const auto glID : ids) {
299 if (
object !=
nullptr) {
@ GLO_NETWORK
The network - empty.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const std::string & getFullName() const
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIGlID getGlID() const
Returns the numerical id of the object.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
GUIGlObject * getObjectBlocking(GUIGlID id) const
Returns the object from the container locking it.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
void clear()
Clears the list of selected objects.
void select(GUIGlID id)
Adds the object with the given id to the list of selected objects.
const std::unordered_set< GUIGlID > & getSelected() const
Returns the list of selected ids.
~SingleTypeSelections()
Destructor.
void deselect(GUIGlID id)
Deselects the object with the given id from the list of selected objects.
SingleTypeSelections()
Constructor.
void save(const std::string &filename)
Saves the list of selected objects to a file named as given.
bool isSelected(GUIGlID id)
Returns the information whether the object with the given id is qithin the selection.
virtual void selectionUpdated()=0
called when selection is updated
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.
std::map< GUIGlObjectType, SingleTypeSelections > mySelections
map with the selections
void notifyChanged()
inform the update target of earlier changes
~GUISelectedStorage()
Destructor.
void clear()
Clears the list of selected objects.
std::set< GUIGlID > loadIDs(std::istream &strm, std::string &msgOut, GUIGlObjectType type=GLO_MAX, std::ostream *dynamicNotFound=nullptr, int maxErrors=16)
Loads a selection list (optionally with restricted type) and returns the ids of all active objects.
void toggleSelection(GUIGlID id)
Toggles selection of an object.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
UpdateTarget * myUpdateTarget
The dialog to be updated.
void add2Update(UpdateTarget *updateTarget)
Adds a dialog to be updated.
void remove2Update()
Removes the dialog to be updated.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
GUISelectedStorage()
Constructor.
std::unordered_set< GUIGlID > myAllSelected
List of selected objects.
void deselect(GUIGlID id)
Deselects the object with the given id.
const std::unordered_set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
std::string load(const std::string &filename, GUIGlObjectType type=GLO_MAX, std::ostream *dynamicNotFound=nullptr)
Loads a selection list (optionally with restricted type)
Static storage of an output device and its base (abstract) implementation.
void close()
Closes the device and removes it from the dictionary.
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
static std::string replace(std::string str, const std::string &what, const std::string &by)
Replaces all occurrences of the second string by the third string within the first string.
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.