diff options
author | Andrew <forkk@forkk.net> | 2013-02-14 22:40:00 -0600 |
---|---|---|
committer | Andrew <forkk@forkk.net> | 2013-02-14 22:40:00 -0600 |
commit | 4b1680f2428f33dc8ecbf3f4f4b964b0a02e7e06 (patch) | |
tree | 152b4274af09dace56ad4448963eb8647678b273 /data/siglist_impl.h | |
parent | fe452e3ac96699d51d47ecdc43c58778b512d72a (diff) | |
download | MultiMC-4b1680f2428f33dc8ecbf3f4f4b964b0a02e7e06.tar MultiMC-4b1680f2428f33dc8ecbf3f4f4b964b0a02e7e06.tar.gz MultiMC-4b1680f2428f33dc8ecbf3f4f4b964b0a02e7e06.tar.lz MultiMC-4b1680f2428f33dc8ecbf3f4f4b964b0a02e7e06.tar.xz MultiMC-4b1680f2428f33dc8ecbf3f4f4b964b0a02e7e06.zip |
Started reworking the instance system.
Diffstat (limited to 'data/siglist_impl.h')
-rw-r--r-- | data/siglist_impl.h | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/data/siglist_impl.h b/data/siglist_impl.h new file mode 100644 index 00000000..16ddd9b0 --- /dev/null +++ b/data/siglist_impl.h @@ -0,0 +1,156 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "siglist.h" + +template <typename T> +void SigList<T>::append(const T &value) +{ + QList<T>::append(value); + onItemAdded(value, length() - 1); +} + +template <typename T> +void SigList<T>::prepend(const T &value) +{ + QList<T>::prepend(value); + onItemAdded(value, 0); +} + +template <typename T> +void SigList<T>::append(const QList<T> &other) +{ + int index = length(); + QList<T>::append(other); + onItemsAdded(other, index); +} + +template <typename T> +void SigList<T>::clear() +{ + QList<T>::clear(); + onInvalidated(); +} + +template <typename T> +void SigList<T>::erase(QList<T>::iterator pos) +{ + T value = *pos; + int index = indexOf(*pos); + QList<T>::erase(pos); + onItemRemoved(value, index); +} + +template <typename T> +void SigList<T>::erase(QList<T>::iterator first, QList<T>::iterator last) +{ + QList<T> removedValues; + int firstIndex = indexOf(*first); + + for (QList<T>::iterator iter = first; iter < last; iter++) + { + removedValues << *iter; + QList<T>::erase(iter); + } + + onItemsRemoved(removedValues, firstIndex); +} + +template <typename T> +void SigList<T>::insert(int i, const T &t) +{ + QList<T>::insert(i, t); + onItemAdded(t, i); +} + +template <typename T> +void SigList<T>::insert(QList<T>::iterator before, const T &t) +{ + QList<T>::insert(before, t); + onItemAdded(t, indexOf(t)); +} + +template <typename T> +void SigList<T>::move(int from, int to) +{ + const T &item = at(from); + QList<T>::move(from, to); + onItemMoved(item, from, to); +} + +template <typename T> +int SigList<T>::removeAll(const T &t) +{ + int retVal = QList<T>::removeAll(t); + onInvalidated(); + return retVal; +} + +template <typename T> +bool SigList<T>::removeOne(const T &t) +{ + int index = indexOf(t); + if (QList<T>::removeOne(t)) + { + onItemRemoved(t, index); + return true; + } + return false; +} + +template <typename T> +void SigList<T>::swap(QList<T> &other) +{ + QList<T>::swap(other); + onInvalidated(); +} + +template <typename T> +void SigList<T>::swap(int i, int j) +{ + const T &item1 = at(i); + const T &item2 = at(j); + QList<T>::swap(i, j); + onItemMoved(item1, i, j); + onItemMoved(item2, j, i); +} + +template <typename T> +T SigList<T>::takeAt(int i) +{ + T val = QList<T>::takeAt(i); + onItemRemoved(val, i); + return val; +} + +template <typename T> +T SigList<T>::takeFirst() +{ + return takeAt(0); +} + +template <typename T> +T SigList<T>::takeLast() +{ + return takeAt(length() - 1); +} + +template <typename T> +QList<T> &SigList<T>::operator =(const QList<T> &other) +{ + QList<T>::operator =(other); + onInvalidated(); + return *this; +} |