SqLiteStorage::SqLiteStorage() : SqlStorage() , m_database( QSqlDatabase::addDatabase( DriverName, DatabaseName ) ) { if ( ! QSqlDatabase::isDriverAvailable( DriverName ) ) { throw CharmException( QObject::tr( "QSQLITE driver not available" ) ); } }
void Controller::stateChanged( State previous, State next ) { Q_UNUSED( previous ); switch( next ) { case Connected: { // yes, it is that simple: TaskList tasks = m_storage->getAllTasks(); // tell the view about the existing tasks; if ( ! Task::checkForUniqueTaskIds( tasks ) ) { throw CharmException( tr( "The Charm database is corrupted, it contains duplicate task ids. " "Please have it looked after by a professional." ) ); } if ( ! Task::checkForTreeness( tasks ) ) { throw CharmException( tr( "The Charm database is corrupted, the tasks do not form a tree. " "Please have it looked after by a professional." ) ); } emit definedTasks( tasks ); EventList events = m_storage->getAllEvents(); emit allEvents( events ); } break; case Disconnecting: { emit readyToQuit(); if ( m_storage ) { // this will still leave Qt complaining about a repeated connection // qDebug() << "Application::enterConnectingState: closing existing storage interface"; m_storage->disconnect(); delete m_storage; m_storage = nullptr; } } break; default: break; }; if ( m_storage ) { emit currentBackendStatus( m_storage->description() ); m_storage->stateChanged( previous ); } }