homescreenapp/hsdomainmodel/src/hsdatabase.cpp
changeset 46 23b5d6a29cce
parent 39 4e8ebe173323
child 51 4785f57bf3d4
equal deleted inserted replaced
39:4e8ebe173323 46:23b5d6a29cce
    50 
    50 
    51 /*!
    51 /*!
    52     Constructs a new database with the given \a parent object.
    52     Constructs a new database with the given \a parent object.
    53 */
    53 */
    54 HsDatabase::HsDatabase(QObject *parent)
    54 HsDatabase::HsDatabase(QObject *parent)
    55   : QObject(parent)
    55   : QObject(parent),
       
    56   	mBlocked(false)
    56 {
    57 {
    57 }
    58 }
    58 
    59 
    59 /*!
    60 /*!
    60     Destroys this database.
    61     Destroys this database.
   100     Opens the database connection using the current connection
   101     Opens the database connection using the current connection
   101     values. Returns true on success, otherwise returns false.
   102     values. Returns true on success, otherwise returns false.
   102 */  
   103 */  
   103 bool HsDatabase::open()
   104 bool HsDatabase::open()
   104 {
   105 {
       
   106 	if (mBlocked) {
       
   107 		return false;
       
   108 	}
       
   109 
   105     QSqlDatabase database;
   110     QSqlDatabase database;
   106     if (QSqlDatabase::contains(mConnectionName)) {
   111     if (QSqlDatabase::contains(mConnectionName)) {
   107         database = QSqlDatabase::database(mConnectionName);
   112         database = QSqlDatabase::database(mConnectionName);
   108     } else {
   113     } else {
   109         database = QSqlDatabase::addDatabase("QSQLITE", mConnectionName);
   114         database = QSqlDatabase::addDatabase("QSQLITE", mConnectionName);
   188         data.id                  = query.value(0).toInt();
   193         data.id                  = query.value(0).toInt();
   189         data.portraitWallpaper   = query.value(1).toString();
   194         data.portraitWallpaper   = query.value(1).toString();
   190         data.landscapeWallpaper  = query.value(2).toString();
   195         data.landscapeWallpaper  = query.value(2).toString();
   191         data.defaultPageId       = query.value(3).toInt();
   196         data.defaultPageId       = query.value(3).toInt();
   192         data.maximumPageCount    = query.value(4).toInt();
   197         data.maximumPageCount    = query.value(4).toInt();
   193         data.maximumWidgetHeight = query.value(5).toInt();
   198         data.maximumWidgetHeight = query.value(5).toReal();
   194         data.maximumWidgetWidth  = query.value(6).toInt();
   199         data.maximumWidgetWidth  = query.value(6).toReal();
   195         data.minimumWidgetHeight = query.value(7).toInt();
   200         data.minimumWidgetHeight = query.value(7).toReal();
   196         data.minimumWidgetWidth  = query.value(8).toInt();
   201         data.minimumWidgetWidth  = query.value(8).toReal();
   197         return true;
   202         return true;
   198     }
   203     }
   199     
   204     
   200     return false;
   205     return false;
   201 }
   206 }
   750         }
   755         }
   751     }
   756     }
   752 
   757 
   753     return true;
   758     return true;
   754 }
   759 }
   755  
   760 
       
   761 /*!
       
   762     Sets the database blocked or unblocked.
       
   763 */
       
   764 void HsDatabase::setDataBaseBlocked(bool blocked)
       
   765 {
       
   766 	mBlocked = blocked;
       
   767 }
       
   768 
       
   769 /*!
       
   770     Returns is the database blocked.
       
   771     Return value true if blocked.
       
   772 */
       
   773 bool HsDatabase::getDataBaseBlocked()
       
   774 {
       
   775 	return mBlocked;
       
   776 }
       
   777 
   756 /*!
   778 /*!
   757     Sets the database instance. The existing instance
   779     Sets the database instance. The existing instance
   758     will be deleted.
   780     will be deleted.
   759 */
   781 */
   760 void HsDatabase::setInstance(HsDatabase *instance)
   782 void HsDatabase::setInstance(HsDatabase *instance)