1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
|
#ifndef MODINFOREGULAR_H
#define MODINFOREGULAR_H
#include "modinfowithconflictinfo.h"
#include "nexusinterface.h"
/**
* @brief Represents meta information about a single mod.
*
* Represents meta information about a single mod. The class interface is used
* to manage the mod collection
*
**/
class ModInfoRegular : public ModInfoWithConflictInfo
{
Q_OBJECT
friend class ModInfo;
public:
~ModInfoRegular();
virtual bool isRegular() const { return true; }
virtual bool isEmpty() const;
bool isAlternate() { return m_IsAlternate; }
bool isConverted() { return m_Converted; }
bool isValidated() { return m_Validated; }
/**
* @brief test if there is a newer version of the mod
*
* test if there is a newer version of the mod. This does NOT cause
* information to be retrieved from the nexus, it will only test version information already
* available locally. Use checkAllForUpdate() to update this version information
*
* @return true if there is a newer version
**/
bool updateAvailable() const;
/**
* @return true if the current update is being ignored
*/
virtual bool updateIgnored() const { return m_IgnoredVersion.isValid() && m_IgnoredVersion == m_NewestVersion; }
/**
* @brief test if there is a newer version of the mod
*
* test if there is a newer version of the mod. This does NOT cause
* information to be retrieved from the nexus, it will only test version information already
* available locally. Use checkAllForUpdate() to update this version information
*
* @return true if there is a newer version
**/
bool downgradeAvailable() const;
/**
* @brief request an update of nexus description for this mod.
*
* This requests mod information from the nexus. This is an asynchronous request,
* so there is no immediate effect of this call.
*
* @return returns true if information for this mod will be updated, false if there is no nexus mod id to use
**/
bool updateNXMInfo();
/**
* @brief assign or unassign the specified category
*
* Every mod can have an arbitrary number of categories assigned to it
*
* @param categoryID id of the category to set
* @param active determines wheter the category is assigned or unassigned
* @note this function does not test whether categoryID actually identifies a valid category
**/
void setCategory(int categoryID, bool active);
/**
* @brief set the name of this mod
*
* set the name of this mod. This will also update the name of the
* directory that contains this mod
*
* @param name new name of the mod
* @return true on success, false if the new name can't be used (i.e. because the new
* directory name wouldn't be valid)
**/
bool setName(const QString &name);
/**
* @brief changes the comments (manually set information displayed in the mod list) for this mod
* @param comments new comments
*/
void setComments(const QString &comments);
/**
* @brief change the notes (manually set information) for this mod
* @param notes new notes
*/
void setNotes(const QString ¬es);
/**
* @brief set/change the source game of this mod
*
* @param gameName the source game shortName
*/
void setGameName(const QString &gameName);
/**
* @brief set/change the nexus mod id of this mod
*
* @param modID the nexus mod id
**/
void setNexusID(int modID);
/**
* @brief set the version of this mod
*
* this can be used to overwrite the version of a mod without actually
* updating the mod
*
* @param version the new version to use
**/
void setVersion(const MOBase::VersionInfo &version);
/**
* @brief set the newest version of this mod on the nexus
*
* this can be used to overwrite the version of a mod without actually
* updating the mod
*
* @param version the new version to use
* @todo this function should be made obsolete. All queries for mod information should go through
* this class so no public function for this change is required
**/
void setNewestVersion(const MOBase::VersionInfo &version);
/**
* @brief changes/updates the nexus description text
* @param description the current description text
*/
virtual void setNexusDescription(const QString &description);
virtual void setInstallationFile(const QString &fileName);
/**
* @brief sets the category id from a nexus category id. Conversion to MO id happens internally
* @param categoryID the nexus category id
* @note if a mapping is not possible, the category is set to the default value
*/
virtual void addNexusCategory(int categoryID);
/**
* @brief sets the new primary category of the mod
* @param categoryID the category to set
*/
virtual void setPrimaryCategory(int categoryID) { m_PrimaryCategory = categoryID; m_MetaInfoChanged = true; }
/**
* @brief sets the download repository
* @param repository
*/
virtual void setRepository(const QString &repository) { m_Repository = repository; }
/**
* update the endorsement state for the mod. This only changes the
* buffered state, it does not sync with Nexus
* @param endorsed the new endorsement state
*/
virtual void setIsEndorsed(bool endorsed);
/**
* set the mod to "i don't intend to endorse". The mod will not show as unendorsed but can still be endorsed
*/
virtual void setNeverEndorse();
/**
* update the tracked state for the mod. This only changes the
* buffered state. It does not sync with Nexus
* @param tracked the new tracked state
*/
virtual void setIsTracked(bool tracked);
/**
* @brief delete the mod from the disc. This does not update the global ModInfo structure or indices
* @return true if the mod was successfully removed
**/
bool remove();
/**
* @brief endorse or un-endorse the mod
* @param doEndorse if true, the mod is endorsed, if false, it's un-endorsed.
* @note if doEndorse doesn't differ from the current value, nothing happens.
*/
virtual void endorse(bool doEndorse);
/**
* @brief track or untrack the mod. This will sync with nexus!
* @param doTrack if true, the mod is tracked, if false, it's untracked.
* @note if doTrack doesn't differ from the current value, nothing happens.
*/
virtual void track(bool doTrack);
/**
* @brief updates the mod to flag it as converted in order to ignore the alternate game warning
*/
virtual void markConverted(bool converted) override;
/**
* @brief updates the mod to flag it as valid in order to ignore the invalid game data flag
*/
virtual void markValidated(bool validated) override;
/**
* @brief getter for the mod name
*
* @return the mod name
**/
QString name() const { return m_Name; }
/**
* @brief getter for the mod path
*
* @return the (absolute) path to the mod
**/
QString absolutePath() const;
/**
* @brief getter for the newest version number of this mod
*
* @return newest version of the mod
**/
MOBase::VersionInfo getNewestVersion() const { return m_NewestVersion; }
/**
* @brief ignore the newest version for updates
*/
void ignoreUpdate(bool ignore);
/**
* @brief getter for the installation file
*
* @return file used to install this mod from
*/
virtual QString getInstallationFile() const { return m_InstallationFile; }
/**
* @brief getter for the source game repository
*
* @return the source game repository. should default to the active game.
**/
QString getGameName() const { return m_GameName; }
/**
* @brief getter for the nexus mod id
*
* @return the nexus mod id. may be 0 if the mod id isn't known or doesn't exist
**/
int getNexusID() const { return m_NexusID; }
/**
* @return the fixed priority of mods of this type or INT_MIN if the priority of mods
* needs to be user-modifiable
*/
virtual int getFixedPriority() const { return INT_MIN; }
/**
* @return true if the mod can be updated
*/
virtual bool canBeUpdated() const;
/**
* @return the update expiration date based on the last updated date from Nexus
*/
virtual QDateTime getExpires() const;
/**
* @return true if the mod can be enabled/disabled
*/
virtual bool canBeEnabled() const { return true; }
/**
* @return a list of flags for this mod
*/
virtual std::vector<EFlag> getFlags() const;
virtual std::vector<EContent> getContents() const;
/**
* @return an indicator if and how this mod should be highlighted by the UI
*/
virtual int getHighlight() const;
/**
* @return list of names of ini tweaks
**/
std::vector<QString> getIniTweaks() const;
/**
* @return a description about the mod, to be displayed in the ui
*/
virtual QString getDescription() const;
/**
* @return the nexus file status (aka category ID)
*/
virtual int getNexusFileStatus() const;
/**
* @brief sets the file status (category ID) from Nexus
* @param status the status id of the installed file
*/
virtual void setNexusFileStatus(int status);
/**
* @return comments for this mod
*/
virtual QString comments() const;
/**
* @return manually set notes for this mod
*/
virtual QString notes() const;
/**
* @return time this mod was created (file time of the directory)
*/
virtual QDateTime creationTime() const;
/**
* @return nexus description of the mod (html)
*/
QString getNexusDescription() const;
/**
* @return repository from which the file was downloaded
*/
virtual QString repository() const;
/**
* @return true if the file has been endorsed on nexus
*/
virtual EEndorsedState endorsedState() const;
/**
* @return true if the file is being tracked on nexus
*/
virtual ETrackedState trackedState() const;
/**
* @brief get the last time nexus was checked for file updates on this mod
*/
virtual QDateTime getLastNexusUpdate() const;
/**
* @brief set the last time nexus was checked for file updates on this mod
*/
virtual void setLastNexusUpdate(QDateTime time);
/**
* @return last time nexus was queried for infos on this mod
*/
virtual QDateTime getLastNexusQuery() const;
/**
* @brief set the last time nexus was queried for info on this mod
*/
virtual void setLastNexusQuery(QDateTime time);
/**
* @return last time the mod was updated on Nexus
*/
virtual QDateTime getNexusLastModified() const;
/**
* @brief set the last time the mod was updated on Nexus
*/
virtual void setNexusLastModified(QDateTime time);
virtual QStringList archives(bool checkOnDisk = false);
virtual void setColor(QColor color);
virtual QColor getColor();
virtual void addInstalledFile(int modId, int fileId);
/**
* @brief stores meta information back to disk
*/
virtual void saveMeta();
void readMeta();
/**
* @brief set the URL for a mod
*/
virtual void setURL(QString const &);
/**
* @returns the URL for a mod
*/
virtual QString getURL() const;
private:
void setEndorsedState(EEndorsedState endorsedState);
void setTrackedState(ETrackedState trackedState);
private slots:
void nxmDescriptionAvailable(QString, int modID, QVariant userData, QVariant resultData);
void nxmEndorsementToggled(QString, int, QVariant userData, QVariant resultData);
void nxmTrackingToggled(QString, int, QVariant userData, bool tracked);
void nxmRequestFailed(QString, int modID, int fileID, QVariant userData, QNetworkReply::NetworkError error, const QString &errorMessage);
protected:
ModInfoRegular(PluginContainer *pluginContainer, const MOBase::IPluginGame *game, const QDir &path, MOShared::DirectoryEntry **directoryStructure);
private:
QString m_Name;
QString m_Path;
QString m_InstallationFile;
QString m_Comments;
QString m_Notes;
QString m_NexusDescription;
QString m_Repository;
QString m_URL;
QString m_GameName;
mutable QStringList m_Archives;
QDateTime m_CreationTime;
QDateTime m_LastNexusQuery;
QDateTime m_LastNexusUpdate;
QDateTime m_NexusLastModified;
QColor m_Color;
int m_NexusID;
std::set<std::pair<int, int>> m_InstalledFileIDs;
bool m_MetaInfoChanged;
bool m_IsAlternate;
bool m_Converted;
bool m_Validated;
int m_NexusFileStatus;
MOBase::VersionInfo m_NewestVersion;
MOBase::VersionInfo m_IgnoredVersion;
EEndorsedState m_EndorsedState;
ETrackedState m_TrackedState;
NexusBridge m_NexusBridge;
mutable std::vector<ModInfo::EContent> m_CachedContent;
mutable QTime m_LastContentCheck;
bool needsDescriptionUpdate() const;
};
#endif // MODINFOREGULAR_H
|