--- as_dataop.cpp 2003/02/11 14:19:57 1.46
+++ as_dataop.cpp 2003/02/11 22:17:17 1.47
@@ -29,6 +29,10 @@
// tidatops.cpp: ISO C++ implementation
//
+// System headers
+#include <map>
+#include <string>
+
// Qt general headers
#include <qregexp.h> // Portable regular expressions
#include <qdatetime.h>
@@ -72,7 +76,13 @@
//
void Titraqform::loadAccounts(QTextStream &Tstream)
{
- QString Line; // Used for linewise editing and whitespace eating
+ using namespace std; // Needed for hash tables with hmap
+ map<string, int> Hashnames; // Hashtable for storing names
+ map<int, string> Hashnums; // Hashtable for storing repetitions
+ map<string, int>::iterator Nameiter; // The hashtable name iterator
+ map<int, string>::iterator Numiter; // The hashtable number iterator
+
+ QString Line; // Used for linewise editing and whitespace eating
// Eat lines until reading the start accounts token
while (!Line.startsWith(trUtf8("%!AS-ACCOUNTS")) && !Tstream.atEnd()) {
@@ -99,7 +109,8 @@
if (Temp == QString(QChar('R'))) { // Copy the account field
Asline >> Temp; // to temporary for transfer
- *m_pTaskentries << Temp; // to internal account bank
+ string Convstring = Temp; // Convert to string (can't cast?)
+ Hashnames[Convstring] += Hashnames[Convstring];
}
Line = QString(""); // Clear line for next round
@@ -110,6 +121,22 @@
Line = QString("");
}
}
+
+// Hashnames.insert(map<string, int>::value_type((string)QString, int));
+ for (Nameiter = Hashnames.begin(); Nameiter != Hashnames.end(); Nameiter++)
+ Hashnums[Nameiter->second] += Nameiter->first + '\n';
+
+// FIXME: Put this in loadData, to load custom and most used task names before
+// FIXME: default listings are sorted and inserted
+ for (Numiter = Hashnums.begin(); Numiter != Hashnums.end(); Numiter++) {
+
+ // Count the number of lines of sorted task names
+ int nNumlines = QString(Numiter->second).contains('\n');
+
+ // Iterate through the lines of task names, feeding them into the menu
+ for (int nIter = 0; nIter < nNumlines; nIter++)
+ *m_pTaskentries << QString(Numiter->second).section('\n', nIter, nIter);
+ }
}
//
|