joinerror.cpp
1 //------------------------------------------------------------------------------
2 // joinerror.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2014 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "joinerror.h"
25 
26 #include <QList>
27 
28 DClass<JoinError>
29 {
30 public:
32  QString error;
33 
37  QString missingIwad;
38 
42  QList<PWad> missingWads;
43  QList<PWad> incompatibleWads;
44 };
45 
46 DPointered(JoinError)
47 
49 {
50  d->type = NoError;
51 }
52 
53 JoinError::JoinError(JoinError::JoinErrorType type)
54 {
55  d->type = type;
56 }
57 
58 JoinError::JoinError(const JoinError &other)
59 {
60  d = other.d;
61 }
62 
63 JoinError &JoinError::operator=(const JoinError &other)
64 {
65  d = other.d;
66  return *this;
67 }
68 
69 JoinError::~JoinError()
70 {
71 }
72 
73 void JoinError::addMissingWad(const PWad &wad)
74 {
75  d->missingWads << wad;
76 }
77 
78 void JoinError::clearMissingWads()
79 {
80  d->missingWads.clear();
81 }
82 
83 const QString &JoinError::error() const
84 {
85  return d->error;
86 }
87 
88 bool JoinError::isError() const
89 {
90  return d->type != NoError;
91 }
92 
93 bool JoinError::isMissingIwadOnly() const
94 {
95  return d->type == MissingWads
96  && !d->missingIwad.isEmpty()
97  && d->missingWads.isEmpty()
98  && d->incompatibleWads.isEmpty();
99 }
100 
101 bool JoinError::isMissingWadsError() const
102 {
103  return d->type == MissingWads;
104 }
105 
106 const QString &JoinError::missingIwad() const
107 {
108  return d->missingIwad;
109 }
110 
111 const QList<PWad> &JoinError::missingWads() const
112 {
113  return d->missingWads;
114 }
115 
116 const QList<PWad> &JoinError::incompatibleWads() const
117 {
118  return d->incompatibleWads;
119 }
120 
121 void JoinError::setError(const QString &error)
122 {
123  d->error = error;
124 }
125 
126 void JoinError::setMissingIwad(const QString &iwad)
127 {
128  d->missingIwad = iwad;
129 }
130 
131 void JoinError::setMissingWads(const QList<PWad> &wads)
132 {
133  d->missingWads = wads;
134 }
135 
136 void JoinError::setIncompatibleWads(const QList<PWad> &wads)
137 {
138  d->incompatibleWads = wads;
139 }
140 
141 void JoinError::setType(JoinErrorType type)
142 {
143  d->type = type;
144 }
145 
146 JoinError::JoinErrorType JoinError::type() const
147 {
148  return d->type;
149 }