aboutsummaryrefslogtreecommitdiff
path: root/data/siglist_imp.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-02-21 17:40:11 +0100
committerPetr Mrázek <peterix@gmail.com>2013-02-21 17:40:11 +0100
commit1beef3f73cd126af9ce3805b6990c64b835a593b (patch)
tree9673caef42b2a2de6d5a7694a351341d0d38b7d5 /data/siglist_imp.h
parent18b087e99280d2c8d5a6115a178f9e6f03606656 (diff)
parentb8844e441334db5e9bf90348aa591b63087193c4 (diff)
downloadPrismLauncher-1beef3f73cd126af9ce3805b6990c64b835a593b.tar.gz
PrismLauncher-1beef3f73cd126af9ce3805b6990c64b835a593b.tar.bz2
PrismLauncher-1beef3f73cd126af9ce3805b6990c64b835a593b.zip
Merge https://github.com/Forkk/MultiMC5
Diffstat (limited to 'data/siglist_imp.h')
-rw-r--r--data/siglist_imp.h156
1 files changed, 156 insertions, 0 deletions
diff --git a/data/siglist_imp.h b/data/siglist_imp.h
new file mode 100644
index 00000000..16ddd9b0
--- /dev/null
+++ b/data/siglist_imp.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;
+}