-
Notifications
You must be signed in to change notification settings - Fork 0
/
TFV_Classes.cpp
286 lines (224 loc) · 6.64 KB
/
TFV_Classes.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
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
#include "TFV_Classes.h"
using std::cout;
using std::string;
using std::vector;
using std::endl;
// summary of the file: stores most of the classes used to run the program
///////////////
/// \brief The priority class
///
/// Priority class for items, to work out sorting and to store the priority status for further data manipulation
// took me a full workday to write this class, which I guess I can use as a reference point for other workloads and my skills development
void priority::clear()
{
// reset to an arbitrarily high value as a placeholder null
index = 100;
}
// !!!!!!!!!!!!!!!!!!!!!!!!!
// NOTICE NOTICE NOTICE
// WARNING WARNING WARNING WARNING WARNING
// !!!!!!!!!!!!!!!!!!!!!!!!!
// HEADS UP. We might cause a HUGE bug by returning the string from the array instead of directly copying the original string!!!
// But also I spent a whole day trying to compare strings to array strings THAT ARE EXACTLY THE SAME BUT THEY DON'T WORK FOR SOME REASON so I gave up; the time spent wasn't worth the effort. If the bug pops up in the future, ASK FOR HELP. But right now (2Feb2021) it's just not worth the time.
string priority::GetPriority()
{
//cout << "index is " << index << endl;
//cout << "so string should be: " << priorities[index] << endl;
string error = "INVALID";
if ((index <= 7) & (index >= 0)) return priorities[index];
else return error;
}
int priority::GetPriorityIndex()
{
return index;
}
void priority::SetPriority(string priorityInput)
{
//cout << "Priority in SetPriority() is " << priorityInput << endl;
// potential bug: HIGH gets confirmed twice
// also I got array comparison to work an hour after typing that warning above. Yay.
for (int i = 0; i < 7; i++)
{
string iPrio = priorities[i].c_str();
if ((priorityInput.find(priorities[i].c_str()) != string::npos) & (priorities[i].length() == priorityInput.length()))
{
// UPDATE6MAY2021: bug for double high and double low confirmations fixed by comparing the length of both strings
index = i;
cout << "priority confirmed to be " << index << endl;
}
}
cout << "resulting priority is " << index << endl;
}
void priority::SetPriority(int inputIndex)
{
if ((inputIndex < 8) & (inputIndex > -1)) index = inputIndex;
else cout << "The inputted priority number " << inputIndex << " is an INVALID PRIORITY!" << endl;
}
/////////////////////
/// \brief The item class
/// Proto task item object, containing all the stuff in one item
// getters and setters
void item::SetName (string name)
{
fromName = name;
}
string item::GetName ()
{
return fromName;
}
void item::SetDescription(string newDescription)
{
descr = newDescription;
}
string item::GetDesc()
{
return descr;
}
void item::SetStatPrimary (string newStatPrim)
{
statusPrimary = newStatPrim;
}
string item::GetStatPrimary()
{
return statusPrimary;
}
void item::SetStatSec(string newStatSec)
{
statusSecondary = newStatSec;
}
string item::GetStatSec()
{
return statusSecondary;
}
void item::SetPriority (priority newPriority)
{
currentPriority = newPriority;
}
string item::ReadPriority()
{
return currentPriority.GetPriority();
}
priority item::GetPriority()
{
return currentPriority;
}
void item::ClearAll()
{
fromName.clear();
project.clear();
descr.clear();
statusPrimary.clear();
statusSecondary.clear();
currentPriority.clear();
}
void item::SetMTOD (bool newState)
{
movedToOtherDay = newState;
}
bool item::GetMTOD ()
{
return movedToOtherDay;
}
string item::GetMTODAnswer()
{
if (movedToOtherDay) return "Yes";
else return "No";
}
void item::PrintCurrentItem()
{
// summary: for debugging only. Prints the current contents of the item
cout << "----" << std::endl;
cout << "FROM: " << fromName << std::endl
<< "PROJECT: " << project << std::endl
<< descr << std::endl
<< "STATUS: " << statusPrimary << ";" << statusSecondary << std::endl
<< "Moved To Tomorrow? " << GetMTODAnswer() << std::endl
<< "PRIORITY: " << currentPriority.GetPriority() << std::endl;
}
bool item::operator<(item& i)
{
return currentPriority.GetPriorityIndex() < i.currentPriority.GetPriorityIndex();
}
void item::SetProject(string newProject)
{
project = newProject;
}
string item::GetProject()
{
return project;
}
///////////////
/// \brief The tab class
/// Tab Object meant to contain the items of each tab as well as its name and associated file
QString tab::GetFile()
{
return matchingFile;
}
void tab::SetFile(QString newFile)
{
matchingFile = newFile;
}
string tab::GetName()
{
return tabName;
}
void tab::SetTabName(QString newFile)
{
string newTabName = newFile.toUtf8().constData();
string omitString = "Task Feed ";
string omitEnd = ".txt";
string dash = "- ";
tabName = newTabName.erase(newTabName.find(omitString),omitString.length());
if (tabName.find(dash) != string::npos) tabName = tabName.erase(tabName.find(dash),dash.length());
tabName = tabName.erase(tabName.find(omitEnd),omitEnd.length());
}
bool tab::operator<(const tab& t) const
{
return tabName < t.tabName;
}
////////////
/// \brief The taskFeedFile class
/// Simple wrapper to contain both the task feed file location vector and the tabs vector
///
vector<tab> taskFeedFile::GetTabsVector()
{
return tabsVector;
}
void taskFeedFile::setTabsVector(vector<tab> inputtedTabsVector)
{
tabsVector = inputtedTabsVector;
}
QStringList taskFeedFile::GetFileLocations()
{
return fileLocations;
}
void taskFeedFile::setFileLocations(QStringList inputtedFileLocations)
{
fileLocations = inputtedFileLocations;
}
bool taskFeedFile::emptyTabs()
{
if (tabsVector.empty()) return true;
else return false;
}
// don't mind this - just making sure I still have the code I used to make alphanum work before. Still trying to figure it out btw.
//namespace doj
//{
// template<class Ty>
// struct alphanum_less : public std::binary_function<Ty, Ty, bool>
// {
// bool operator()(const Ty& left, const Ty& right) const
// {
// return alphanum_comp(left, right) < 0;
// }
//
// bool operator()(tab& left, tab& right) const
// {
// return alphanum_comp(left.GetName(), right.GetName()) < 0;
// }
// bool operator()(item& left, item& right) const
// {
// return alphanum_comp(left.GetPriority().GetPriorityIndex(),right.GetPriority().GetPriorityIndex()) <0;
// }
// };
//}