[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenonbeta/krecipes/src
From: Unai Garro <ugarro () telefonica ! net>
Date: 2004-03-19 20:07:35
Message-ID: 20040319200735.EB77B99AC () office ! kde ! org
[Download RAW message or body]
CVS commit by uga:
Allow the user to change the DB type when MySQL doesn't connect, reruns wizard and \
switches to SQLite
M +45 -5 krecipesview.cpp 1.136
--- kdenonbeta/krecipes/src/krecipesview.cpp #1.135:1.136
@@ -82,9 +82,11 @@ KrecipesView::KrecipesView(QWidget *pare
// Read the database setup
- KConfig *config; config=kapp->config(); config->sync(); \
config->setGroup("DBType"); + KConfig *config; config=kapp->config(); \
config->sync();
// Check if the database type is among those supported
+ // and initialize the database in each case
+ config->setGroup("DBType");
dbtype=checkCorrectDBType(config);
@@ -119,4 +121,6 @@ KrecipesView::KrecipesView(QWidget *pare
}
+
+ // Design the GUI
splitter=new QHBox(this);
@@ -898,8 +902,44 @@ void KrecipesView::initMySQLDatabase(KCo
questionRerunWizard(database->err(), i18n("Unable to open \
database"));
- // Try opening the database again
+ // Reread the configuration file.
+ // The user may have changed the data and/or DB type
+
+ config->setGroup("DBType");
+ dbtype=checkCorrectDBType(config);
+ config->setGroup("Server");
+ QString host=config->readEntry( "Host","localhost");
+ QString user=config->readEntry( "Username",QString::null);
+ QString pass=config->readEntry("Password",QString::null);
+ QString dbname=config->readEntry( "DBName", DEFAULT_DB_NAME);
+
+
+ if(dbtype=="MySQL") // First case, MySQL
+ {
+ kdDebug()<<i18n("Configured type... MySQL\n").latin1();
+
+ // Try opening the database again with the new details
delete (MySQLRecipeDB *)database;
database=new MySQLRecipeDB(host,user,pass,dbname);
}
+
+ #if HAVE_SQLITE
+
+ else if (dbtype=="SQLite")// The user chose SQLite this time
+ {
+ kdDebug()<<i18n("Configured type... SQLite\n").latin1();
+ database=new LiteRecipeDB(QString::null); // server \
parameterss make no sense for SQLite + }
+
+ #endif //HAVE_SQLITE
+ else{
+
+ // No DB type has been enabled (should not happen at all, but just \
in case) +
+ kdError()<<i18n("Code error. No DB support was built in. \
Exiting")<<endl; + exit(1);
+ }
+
+
+ }
kdDebug()<<i18n("DB started correctly\n").latin1();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic