filealias.h
1 //------------------------------------------------------------------------------
2 // filealias.h
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 #ifndef id8E04D971_DF78_4DB4_97E84A8D859F3694
24 #define id8E04D971_DF78_4DB4_97E84A8D859F3694
25 
26 #include <QList>
27 #include <QString>
28 #include <QStringList>
29 #include <QVariant>
30 
31 class FileAlias
32 {
33  public:
34  enum MatchType
35  {
36  LeftToRight,
37  AllEqual
38  };
39 
40  static FileAlias freeDoom1Aliases();
41  static QList<FileAlias> freeDoom2Aliases();
45  static QList<FileAlias> standardWadAliases();
46 
47  FileAlias();
48  FileAlias(const QString &name);
49 
53  void addAlias(const QString &val);
57  void addAliases(const QStringList &val);
58 
59  const QStringList &aliases() const;
60  void setAliases(const QStringList &val);
61 
62  static FileAlias deserializeQVariant(const QVariant &var);
63  QVariant serializeQVariant() const;
64 
69  bool isSameName(const QString &otherName) const;
70 
74  bool isValid() const;
75 
76  MatchType matchType() const;
77  void setMatchType(MatchType matchType);
78 
79  const QString &name() const;
80  void setName(const QString &val);
81 
82  private:
83  class PrivData
84  {
85  public:
86  QStringList aliases;
87  MatchType matchType;
88  QString name;
89  };
90 
91  PrivData d;
92 
93  static MatchType deserializeMatchType(const QVariant &variant);
94  static QVariant serializeMatchType(MatchType matchType);
95 };
96 
98 {
99  public:
104  static QStringList aliases(const QList<FileAlias> &candidates, const QString &name);
105  static QList<FileAlias> mergeDuplicates(const QList<FileAlias> &input);
106 };
107 
108 #endif // header
bool isValid() const
Valid FileAlias has a name and at least one alias.
Definition: filealias.cpp:145
void addAliases(const QStringList &val)
Will ensure unique values.
Definition: filealias.cpp:46
static QList< FileAlias > standardWadAliases()
Standard/default aliases for configuration init.
Definition: filealias.cpp:170
bool isSameName(const QString &otherName) const
Compares passed string to local name and checks if they&#39;re same.
Definition: filealias.cpp:140
void addAlias(const QString &val)
Will ensure unique values.
Definition: filealias.cpp:38