Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AppEngine::AppEngine() : defaultDBFileName("tasklist_db.txt")
- {
- }
- AppEngine::~AppEngine()
- {
- }
- void AppEngine::readTasklistFromFile(QString filename)
- {
- tasklist.clear();
- filename = ( filename.isEmpty() ? defaultDBFileName : filename );
- QFile tasklistDB( filename );
- tasklistDB.open(QIODevice::ReadOnly);
- QTextStream textStream( &tasklistDB );
- while( !textStream.atEnd() )
- tasklist.add( parseTask(textStream) );
- tasklistDB.close();
- }
- Task AppEngine::parseTask(QTextStream &textStream)
- {
- int ID = textStream.readLine().trimmed().toInt();
- QString dateOfCreation = textStream.readLine();
- QString dateTaskFinished = textStream.readLine();
- QString name = textStream.readLine();
- QString content = textStream.readLine();
- bool done = ( textStream.readLine().trimmed() == "1" );
- int priority = textStream.readLine().trimmed().toInt();
- return Task( ID, dateOfCreation, dateTaskFinished, name, content, done, priority );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement