Advertisement
Glenpl

Untitled

Jun 28th, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. AppEngine::AppEngine() : defaultDBFileName("tasklist_db.txt")
  2. {
  3.  
  4. }
  5.  
  6. AppEngine::~AppEngine()
  7. {
  8.  
  9. }
  10.  
  11. void AppEngine::readTasklistFromFile(QString filename)
  12. {
  13.   tasklist.clear();
  14.  
  15.   filename = ( filename.isEmpty() ? defaultDBFileName : filename );
  16.   QFile tasklistDB( filename );
  17.   tasklistDB.open(QIODevice::ReadOnly);
  18.  
  19.   QTextStream textStream( &tasklistDB );
  20.  
  21.   while( !textStream.atEnd() )
  22.       tasklist.add( parseTask(textStream) );
  23.  
  24.   tasklistDB.close();
  25. }
  26.  
  27. Task AppEngine::parseTask(QTextStream &textStream)
  28. {
  29.   int ID = textStream.readLine().trimmed().toInt();
  30.   QString dateOfCreation = textStream.readLine();
  31.   QString dateTaskFinished = textStream.readLine();
  32.   QString name = textStream.readLine();
  33.   QString content = textStream.readLine();
  34.   bool done = ( textStream.readLine().trimmed() == "1" );
  35.   int priority = textStream.readLine().trimmed().toInt();
  36.  
  37.   return Task( ID, dateOfCreation, dateTaskFinished, name, content, done, priority );
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement