/
Model.cpp
77 lines (60 loc) · 1.72 KB
/
Model.cpp
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
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "Model.h"
#include <stdio.h>
#include <Catalog.h>
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Model"
Model::Model()
:
fSearchTerms(),
fDepots(),
fCategoryAudio(new PackageCategory(
BitmapRef(),
B_TRANSLATE("Audio"), "audio"), true),
fCategoryVideo(new PackageCategory(
BitmapRef(),
B_TRANSLATE("Video"), "video"), true),
fCategoryGraphics(new PackageCategory(
BitmapRef(),
B_TRANSLATE("Graphics"), "graphics"), true),
fCategoryProductivity(new PackageCategory(
BitmapRef(),
B_TRANSLATE("Productivity"), "productivity"), true),
fCategoryDevelopment(new PackageCategory(
BitmapRef(),
B_TRANSLATE("Development"), "development"), true),
fCategoryCommandLine(new PackageCategory(
BitmapRef(),
B_TRANSLATE("Command line"), "command-line"), true)
{
// Don't forget to add new categories to this list:
fCategories.Add(fCategoryAudio);
fCategories.Add(fCategoryVideo);
fCategories.Add(fCategoryGraphics);
fCategories.Add(fCategoryProductivity);
fCategories.Add(fCategoryDevelopment);
fCategories.Add(fCategoryCommandLine);
}
PackageInfoList
Model::CreatePackageList() const
{
// TODO: Allow to restrict depot, filter by search terms, ...
// Return all packages from all depots.
PackageInfoList resultList;
for (int32 i = 0; i < fDepots.CountItems(); i++) {
const PackageInfoList& packageList
= fDepots.ItemAtFast(i).PackageList();
for (int32 j = 0; j < packageList.CountItems(); j++) {
resultList.Add(packageList.ItemAtFast(j));
}
}
return resultList;
}
bool
Model::AddDepot(const DepotInfo& depot)
{
return fDepots.Add(depot);
}