mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:57:59 +02:00
sorter variable names
This commit is contained in:
parent
41f3b792b6
commit
b0f21c6931
1 changed files with 14 additions and 14 deletions
|
@ -76,21 +76,21 @@ QVariant TabletButtonListModel::data(const QModelIndex& index, int role) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
TabletButtonProxy* TabletButtonListModel::addButton(const QVariant& properties) {
|
TabletButtonProxy* TabletButtonListModel::addButton(const QVariant& properties) {
|
||||||
QVariantMap newTabletButtonProperties = properties.toMap();
|
QVariantMap newProperties = properties.toMap();
|
||||||
if (newTabletButtonProperties.find(BUTTON_SORT_ORDER_KEY) == newTabletButtonProperties.end()) {
|
if (newProperties.find(BUTTON_SORT_ORDER_KEY) == newProperties.end()) {
|
||||||
newTabletButtonProperties[BUTTON_SORT_ORDER_KEY] = DEFAULT_BUTTON_SORT_ORDER;
|
newProperties[BUTTON_SORT_ORDER_KEY] = DEFAULT_BUTTON_SORT_ORDER;
|
||||||
}
|
}
|
||||||
int insertButtonUsingIndex = computeNewButtonIndex(newTabletButtonProperties);
|
int index = computeNewButtonIndex(newProperties);
|
||||||
auto newTabletButtonProxy = QSharedPointer<TabletButtonProxy>(new TabletButtonProxy(newTabletButtonProperties));
|
auto button = QSharedPointer<TabletButtonProxy>(new TabletButtonProxy(newProperties));
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
int buttonCount = (int)_buttons.size();
|
int numButtons = (int)_buttons.size();
|
||||||
if (insertButtonUsingIndex < buttonCount) {
|
if (index < numButtons) {
|
||||||
_buttons.insert(_buttons.begin() + insertButtonUsingIndex, newTabletButtonProxy);
|
_buttons.insert(_buttons.begin() + index, button);
|
||||||
} else {
|
} else {
|
||||||
_buttons.push_back(newTabletButtonProxy);
|
_buttons.push_back(button);
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
return newTabletButtonProxy.data();
|
return button.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabletButtonListModel::removeButton(TabletButtonProxy* button) {
|
void TabletButtonListModel::removeButton(TabletButtonProxy* button) {
|
||||||
|
@ -105,17 +105,17 @@ void TabletButtonListModel::removeButton(TabletButtonProxy* button) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int TabletButtonListModel::computeNewButtonIndex(const QVariantMap& newButtonProperties) {
|
int TabletButtonListModel::computeNewButtonIndex(const QVariantMap& newButtonProperties) {
|
||||||
int buttonCount = (int)_buttons.size();
|
int numButtons = (int)_buttons.size();
|
||||||
int newButtonSortOrder = newButtonProperties[BUTTON_SORT_ORDER_KEY].toInt();
|
int newButtonSortOrder = newButtonProperties[BUTTON_SORT_ORDER_KEY].toInt();
|
||||||
if (newButtonSortOrder == DEFAULT_BUTTON_SORT_ORDER) return buttonCount;
|
if (newButtonSortOrder == DEFAULT_BUTTON_SORT_ORDER) return numButtons;
|
||||||
for (int i = 0; i < buttonCount; i++) {
|
for (int i = 0; i < numButtons; i++) {
|
||||||
QVariantMap tabletButtonProperties = _buttons[i]->getProperties();
|
QVariantMap tabletButtonProperties = _buttons[i]->getProperties();
|
||||||
int tabletButtonSortOrder = tabletButtonProperties[BUTTON_SORT_ORDER_KEY].toInt();
|
int tabletButtonSortOrder = tabletButtonProperties[BUTTON_SORT_ORDER_KEY].toInt();
|
||||||
if (newButtonSortOrder <= tabletButtonSortOrder) {
|
if (newButtonSortOrder <= tabletButtonSortOrder) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buttonCount;
|
return numButtons;
|
||||||
}
|
}
|
||||||
|
|
||||||
TabletButtonsProxyModel::TabletButtonsProxyModel(QObject *parent)
|
TabletButtonsProxyModel::TabletButtonsProxyModel(QObject *parent)
|
||||||
|
|
Loading…
Reference in a new issue