diff options
author | tg(x) <*@tg-x.net> | 2016-03-19 00:42:54 +0100 |
---|---|---|
committer | tg(x) <*@tg-x.net> | 2016-03-19 00:42:54 +0100 |
commit | c0b49453eb61e6979c2f378398f84fef7f954a51 (patch) | |
tree | 5deb5be56e3150248a8b3d183f2599e6b85de9c4 | |
parent | ef51a76cd4a4ec8aaa8f4622d23b80d2b7f61a71 (diff) | |
download | secushare-c0b49453eb61e6979c2f378398f84fef7f954a51.tar.gz secushare-c0b49453eb61e6979c2f378398f84fef7f954a51.zip |
models
-rw-r--r-- | src/model/EgoListModel.cpp | 15 | ||||
-rw-r--r-- | src/model/EgoListModel.h | 3 | ||||
-rw-r--r-- | src/model/NymListModel.cpp | 15 | ||||
-rw-r--r-- | src/model/NymListModel.h | 3 | ||||
-rw-r--r-- | src/model/PlaceListModel.cpp | 4 | ||||
-rw-r--r-- | src/model/PlaceListModel.h | 1 | ||||
-rw-r--r-- | src/model/ThreadListModel.cpp | 4 | ||||
-rw-r--r-- | src/model/ThreadListModel.h | 1 |
8 files changed, 30 insertions, 16 deletions
diff --git a/src/model/EgoListModel.cpp b/src/model/EgoListModel.cpp index 0cef0d4..8327274 100644 --- a/src/model/EgoListModel.cpp +++ b/src/model/EgoListModel.cpp | |||
@@ -29,6 +29,11 @@ EgoListModel::EgoListModel (const QList<Ego *> &data, QObject * parent) | |||
29 | : QAbstractListModel (parent), | 29 | : QAbstractListModel (parent), |
30 | m_data (data) | 30 | m_data (data) |
31 | { | 31 | { |
32 | QListIterator<Ego *> it (m_data); | ||
33 | while (it.hasNext ()) | ||
34 | { | ||
35 | rowAdded (it.next ()); | ||
36 | } | ||
32 | } | 37 | } |
33 | 38 | ||
34 | 39 | ||
@@ -82,9 +87,9 @@ EgoListModel::roleNames () const | |||
82 | void | 87 | void |
83 | EgoListModel::rowAdded (Ego *ego) | 88 | EgoListModel::rowAdded (Ego *ego) |
84 | { | 89 | { |
85 | int index = m_data.count (); | 90 | int idx = m_count++; |
86 | beginInsertRows (QModelIndex (), index, index); | 91 | beginInsertRows (QModelIndex (), idx, idx); |
87 | ego->setIndex (index); | 92 | ego->setIndex (idx); |
88 | 93 | ||
89 | connect (ego, &Ego::modified, | 94 | connect (ego, &Ego::modified, |
90 | this, &EgoListModel::rowModified); | 95 | this, &EgoListModel::rowModified); |
@@ -103,9 +108,9 @@ EgoListModel::rowModified (int index) | |||
103 | 108 | ||
104 | 109 | ||
105 | int | 110 | int |
106 | EgoListModel::getCount () | 111 | EgoListModel::count () |
107 | { | 112 | { |
108 | return m_data.count (); | 113 | return m_count; |
109 | } | 114 | } |
110 | 115 | ||
111 | 116 | ||
diff --git a/src/model/EgoListModel.h b/src/model/EgoListModel.h index bb2d94b..3347ab7 100644 --- a/src/model/EgoListModel.h +++ b/src/model/EgoListModel.h | |||
@@ -44,7 +44,7 @@ public: | |||
44 | EgoListModel (const QList<Ego *> &data, QObject *parent = 0); | 44 | EgoListModel (const QList<Ego *> &data, QObject *parent = 0); |
45 | 45 | ||
46 | Q_INVOKABLE int | 46 | Q_INVOKABLE int |
47 | getCount (); | 47 | count (); |
48 | 48 | ||
49 | Q_INVOKABLE Ego * | 49 | Q_INVOKABLE Ego * |
50 | get (int index); | 50 | get (int index); |
@@ -83,6 +83,7 @@ private: | |||
83 | roleNames () const; | 83 | roleNames () const; |
84 | 84 | ||
85 | const QList<Ego *> &m_data; | 85 | const QList<Ego *> &m_data; |
86 | int m_count; | ||
86 | 87 | ||
87 | #if FIXME | 88 | #if FIXME |
88 | QHash<QString, int> m_lookupIndex; | 89 | QHash<QString, int> m_lookupIndex; |
diff --git a/src/model/NymListModel.cpp b/src/model/NymListModel.cpp index 76fa9a4..1277800 100644 --- a/src/model/NymListModel.cpp +++ b/src/model/NymListModel.cpp | |||
@@ -29,6 +29,11 @@ NymListModel::NymListModel (const QList<Nym *> &data, QObject * parent) | |||
29 | : QAbstractListModel (parent), | 29 | : QAbstractListModel (parent), |
30 | m_data (data) | 30 | m_data (data) |
31 | { | 31 | { |
32 | QListIterator<Nym *> it (m_data); | ||
33 | while (it.hasNext ()) | ||
34 | { | ||
35 | rowAdded (it.next ()); | ||
36 | } | ||
32 | } | 37 | } |
33 | 38 | ||
34 | 39 | ||
@@ -82,9 +87,9 @@ NymListModel::roleNames () const | |||
82 | void | 87 | void |
83 | NymListModel::rowAdded (Nym *nym) | 88 | NymListModel::rowAdded (Nym *nym) |
84 | { | 89 | { |
85 | int index = m_data.count (); | 90 | int idx = m_count++; |
86 | beginInsertRows (QModelIndex (), index, index); | 91 | beginInsertRows (QModelIndex (), idx, idx); |
87 | nym->setIndex (index); | 92 | nym->setIndex (idx); |
88 | 93 | ||
89 | connect (nym, &Nym::modified, | 94 | connect (nym, &Nym::modified, |
90 | this, &NymListModel::rowModified); | 95 | this, &NymListModel::rowModified); |
@@ -103,9 +108,9 @@ NymListModel::rowModified (int index) | |||
103 | 108 | ||
104 | 109 | ||
105 | int | 110 | int |
106 | NymListModel::getCount () | 111 | NymListModel::count () |
107 | { | 112 | { |
108 | return m_data.count (); | 113 | return m_count; |
109 | } | 114 | } |
110 | 115 | ||
111 | 116 | ||
diff --git a/src/model/NymListModel.h b/src/model/NymListModel.h index c680d98..1546c26 100644 --- a/src/model/NymListModel.h +++ b/src/model/NymListModel.h | |||
@@ -44,7 +44,7 @@ public: | |||
44 | NymListModel (const QList<Nym *> &data, QObject *parent = 0); | 44 | NymListModel (const QList<Nym *> &data, QObject *parent = 0); |
45 | 45 | ||
46 | Q_INVOKABLE int | 46 | Q_INVOKABLE int |
47 | getCount (); | 47 | count (); |
48 | 48 | ||
49 | Q_INVOKABLE Nym * | 49 | Q_INVOKABLE Nym * |
50 | get (int index); | 50 | get (int index); |
@@ -81,6 +81,7 @@ private: | |||
81 | roleNames () const; | 81 | roleNames () const; |
82 | 82 | ||
83 | const QList<Nym *> &m_data; | 83 | const QList<Nym *> &m_data; |
84 | int m_count; | ||
84 | 85 | ||
85 | #if FIXME | 86 | #if FIXME |
86 | QHash<QString, int> m_lookupIndex; | 87 | QHash<QString, int> m_lookupIndex; |
diff --git a/src/model/PlaceListModel.cpp b/src/model/PlaceListModel.cpp index d14ac60..f1b8c29 100644 --- a/src/model/PlaceListModel.cpp +++ b/src/model/PlaceListModel.cpp | |||
@@ -95,7 +95,7 @@ PlaceListModel::roleNames () const | |||
95 | void | 95 | void |
96 | PlaceListModel::rowAdded (Place *place) | 96 | PlaceListModel::rowAdded (Place *place) |
97 | { | 97 | { |
98 | int idx = m_data.count () - 1; | 98 | int idx = m_count++; |
99 | qDebug () << "PlaceListModel::rowAdded: " << idx; | 99 | qDebug () << "PlaceListModel::rowAdded: " << idx; |
100 | 100 | ||
101 | m_threads += new ThreadListModel (place->threads (), this); | 101 | m_threads += new ThreadListModel (place->threads (), this); |
@@ -122,7 +122,7 @@ PlaceListModel::rowModified (Place *place) | |||
122 | int | 122 | int |
123 | PlaceListModel::count () | 123 | PlaceListModel::count () |
124 | { | 124 | { |
125 | return m_data.count (); | 125 | return m_count; |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
diff --git a/src/model/PlaceListModel.h b/src/model/PlaceListModel.h index b3c9941..452162a 100644 --- a/src/model/PlaceListModel.h +++ b/src/model/PlaceListModel.h | |||
@@ -83,6 +83,7 @@ class PlaceListModel : public QAbstractListModel | |||
83 | roleNames () const; | 83 | roleNames () const; |
84 | 84 | ||
85 | const QList<Place *> &m_data; | 85 | const QList<Place *> &m_data; |
86 | int m_count; | ||
86 | 87 | ||
87 | QList<ThreadListModel *> m_threads; | 88 | QList<ThreadListModel *> m_threads; |
88 | }; | 89 | }; |
diff --git a/src/model/ThreadListModel.cpp b/src/model/ThreadListModel.cpp index 02f0092..cb310f4 100644 --- a/src/model/ThreadListModel.cpp +++ b/src/model/ThreadListModel.cpp | |||
@@ -72,7 +72,7 @@ ThreadListModel::roleNames () const | |||
72 | void | 72 | void |
73 | ThreadListModel::rowAdded (Message *msg) | 73 | ThreadListModel::rowAdded (Message *msg) |
74 | { | 74 | { |
75 | int idx = m_data.count () - 1; | 75 | int idx = m_count++; |
76 | qDebug () << "ThreadListModel::rowAdded: " << idx; | 76 | qDebug () << "ThreadListModel::rowAdded: " << idx; |
77 | 77 | ||
78 | m_thread += new ThreadModel (msg, this); | 78 | m_thread += new ThreadModel (msg, this); |
@@ -100,7 +100,7 @@ ThreadListModel::rowModified (Message *msg) | |||
100 | int | 100 | int |
101 | ThreadListModel::count () | 101 | ThreadListModel::count () |
102 | { | 102 | { |
103 | return m_data.count (); | 103 | return m_count; |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
diff --git a/src/model/ThreadListModel.h b/src/model/ThreadListModel.h index d5a664d..d31e2e2 100644 --- a/src/model/ThreadListModel.h +++ b/src/model/ThreadListModel.h | |||
@@ -62,6 +62,7 @@ class ThreadListModel : public QAbstractListModel | |||
62 | roleNames () const; | 62 | roleNames () const; |
63 | 63 | ||
64 | const QList<Message *> &m_data; | 64 | const QList<Message *> &m_data; |
65 | int m_count; | ||
65 | 66 | ||
66 | QList<ThreadModel *> m_thread; | 67 | QList<ThreadModel *> m_thread; |
67 | }; | 68 | }; |