Skip to content

Commit

Permalink
Cleaned up CustomTypesEditor and made it auto-save values
Browse files Browse the repository at this point in the history
When adding, removing or changing values, the custom types are now
automatically saved. The explicit "Load" and "Save" buttons have been
removed, as well as the "Debug" button.

Also switched it from using a QTableWidget to a QTreeView and a model
derived from QStringListModel for the values.

Empty values are no longer automatically removed and new values get a
default text.
  • Loading branch information
bjorn committed Jun 17, 2021
1 parent 3eb8467 commit f5f5634
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 240 deletions.
12 changes: 0 additions & 12 deletions src/libtiled/customtype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ namespace Tiled {

int CustomType::nextId = 0;

void CustomType::addValue(const QString &name)
{
values << name;
validateValues();
}

void CustomType::validateValues()
{
values.removeAll(QString());
values.removeDuplicates();
}

QVariant CustomType::wrap(QVariant value) const
{
return QVariant::fromValue(CustomValue { value, id });
Expand Down
3 changes: 0 additions & 3 deletions src/libtiled/customtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ class TILEDSHARED_EXPORT CustomType

static int nextId;

void addValue(const QString &name);
void validateValues();

QVariant wrap(QVariant value) const;
QVariant defaultValue() const;

Expand Down
2 changes: 1 addition & 1 deletion src/libtiled/properties.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* properties.h
* Copyright 2010, Thorbjørn Lindeijer <[email protected]>
* Copyright 2010-2021, Thorbjørn Lindeijer <[email protected]>
*
* This file is part of libtiled.
*
Expand Down
Loading

0 comments on commit f5f5634

Please sign in to comment.