-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.cpp
More file actions
90 lines (79 loc) · 2.64 KB
/
mod.cpp
File metadata and controls
90 lines (79 loc) · 2.64 KB
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
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2013 Jarno van der Kolk <jarno@jarno.ca>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "mod.h"
#include <QLabel>
Mod::Mod(const QString &Key, const QString &DisplayName, const QString &Description, const QString &Author, const QUrl &Forum, const QStringList &Category, const QString &Version, const QStringList &Requires, const QDate &Date, const QString &Build, context_t Context)
: QWidget(), Key(Key), DisplayName(DisplayName), Description(Description), Author(Author), Forum(Forum), Category(Category), Version(Version), Date(Date), Build(Build), Context(Context)
{
Mod::Requires = Requires;
Mod::Requires.removeAll("rPAMM");
}
Mod::~Mod()
{
}
void Mod::setRelativeFontSizeForLabel(QLabel* label, qreal size)
{
QFont font = label->font();
font.setPointSizeF(size * font.pointSizeF());
label->setFont(font);
}
bool Mod::sortLastUpdated(const Mod* m1, const Mod* m2)
{
if(m1->Context == m2->Context)
return (m1->Date > m2->Date);
else
return (m1->Context < m2->Context);
}
bool Mod::sortAuthor(const Mod* m1, const Mod* m2)
{
if(m1->Context == m2->Context)
return (m1->Author.compare(m2->Author, Qt::CaseInsensitive) <= 0);
else
return (m1->Context < m2->Context);
}
bool Mod::sortBuild(const Mod* m1, const Mod* m2)
{
if(m1->Context == m2->Context)
return (m1->Build >= m2->Build);
else
return (m1->Context < m2->Context);
}
bool Mod::sortRandom(const Mod* m1, const Mod* m2)
{
if(m1->Context == m2->Context)
return (rand() < RAND_MAX / 2);
else
return (m1->Context < m2->Context);
}
bool Mod::sortTitle(const Mod* m1, const Mod* m2)
{
if(m1->Context == m2->Context)
return (m1->DisplayName.compare(m2->DisplayName, Qt::CaseInsensitive) < 0);
else
return (m1->Context < m2->Context);
}
bool Mod::textContains(QString filtertext)
{
return
DisplayName.toLower().contains(filtertext) ||
Author.toLower().contains(filtertext) ||
Description.toLower().contains(filtertext) ||
Key.toLower().contains(filtertext);
}
#include "mod.moc"