Changeset View
Changeset View
Standalone View
Standalone View
shell/problemmodelset.cpp
Show All 12 Lines | |||||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU General Public | 14 | * You should have received a copy of the GNU General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "problemmodelset.h" | 20 | #include "problemmodelset.h" | ||
21 | #include "problemmodel.h" | ||||
21 | #include <QAction> | 22 | #include <QAction> | ||
22 | 23 | | |||
23 | namespace KDevelop | 24 | namespace KDevelop | ||
24 | { | 25 | { | ||
25 | 26 | | |||
26 | struct ProblemModelSetPrivate | 27 | struct ProblemModelSetPrivate | ||
27 | { | 28 | { | ||
28 | QVector<ModelData> data; | 29 | QVector<ModelData> data; | ||
Show All 9 Lines | |||||
38 | 39 | | |||
39 | void ProblemModelSet::addModel(const QString &name, ProblemModel *model) | 40 | void ProblemModelSet::addModel(const QString &name, ProblemModel *model) | ||
40 | { | 41 | { | ||
41 | ModelData m; | 42 | ModelData m; | ||
42 | m.name = name; | 43 | m.name = name; | ||
43 | m.model = model; | 44 | m.model = model; | ||
44 | d->data.push_back(m); | 45 | d->data.push_back(m); | ||
45 | 46 | | |||
47 | connect(model, &ProblemModel::problemsChanged, this, &ProblemModelSet::problemsChanged); | ||||
48 | | ||||
46 | emit added(m); | 49 | emit added(m); | ||
47 | } | 50 | } | ||
48 | 51 | | |||
49 | ProblemModel* ProblemModelSet::findModel(const QString &name) const | 52 | ProblemModel* ProblemModelSet::findModel(const QString &name) const | ||
50 | { | 53 | { | ||
51 | ProblemModel *model = nullptr; | 54 | ProblemModel *model = nullptr; | ||
52 | 55 | | |||
53 | foreach (const ModelData &data, d->data) { | 56 | foreach (const ModelData &data, d->data) { | ||
Show All 10 Lines | |||||
64 | { | 67 | { | ||
65 | QVector<ModelData>::iterator itr = d->data.begin(); | 68 | QVector<ModelData>::iterator itr = d->data.begin(); | ||
66 | while (itr != d->data.end()) { | 69 | while (itr != d->data.end()) { | ||
67 | if(itr->name == name) | 70 | if(itr->name == name) | ||
68 | break; | 71 | break; | ||
69 | ++itr; | 72 | ++itr; | ||
70 | } | 73 | } | ||
71 | 74 | | |||
72 | if(itr != d->data.end()) | 75 | if(itr != d->data.end()) { | ||
76 | (*itr).model->disconnect(this); | ||||
73 | d->data.erase(itr); | 77 | d->data.erase(itr); | ||
78 | } | ||||
74 | 79 | | |||
75 | emit removed(name); | 80 | emit removed(name); | ||
76 | } | 81 | } | ||
77 | 82 | | |||
78 | void ProblemModelSet::showModel(const QString &name) | 83 | void ProblemModelSet::showModel(const QString &name) | ||
79 | { | 84 | { | ||
80 | for (const ModelData &data : d->data) { | 85 | for (const ModelData &data : d->data) { | ||
81 | if (data.name == name) { | 86 | if (data.name == name) { | ||
Show All 12 Lines |