dynamically load available sql plugins

  • Spockmeat

    Spockmeat - 2006-11-07

    I wasn't sure where to post this, but I made a few modifications to the loginOptions.cpp file under the common directory that allows the login window to automatically get the available sql plugins and allow the user to select the one they prefer. I needed to do this to suppose the mysql database I'm using, and I find it much better to dynamically generate the plug in list rather than hard code it for a particular database. I don't see anywhere to post the file, so I'll just paste my modified version here (based on what was current in CVS as of this post date). I hope this is useful to someone, I tested it under linux and windows with the QMYSQL driver and it works for me.

    * Copyright (c) 2002-2006 by OpenMFG, LLC
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version.
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * GNU General Public License for more details.
    * You should have received a copy of the GNU General Public License
    * along with this program; if not, write to the Free Software
    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    * If you do not wish to be bound by the terms of the GNU General Public
    * License, DO NOT USE THIS SOFTWARE.  Please contact OpenMFG, LLC at
    * info@openmfg.com for details on how to purchase a commercial license.

    #include "loginOptions.h"

    #include <qvariant.h>
    #include <qsettings.h>
    #include "dbtools.h"

    *  Constructs a loginOptions as a child of 'parent', with the
    *  name 'name' and widget flags set to 'f'.
    *  The dialog will by default be modeless, unless you set 'modal' to
    *  true to construct a modal dialog.
    loginOptions::loginOptions(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
        : QDialog(parent, name, modal, fl)

        // fill in the sql driver list
        // signals and slots connections
        connect(_save, SIGNAL(clicked()), this, SLOT(sSave()));

    *  Destroys the object and frees any allocated resources
        // no need to delete child widgets, Qt does it all for us

    *  Sets the strings of the subwidgets using the current
    *  language.
    void loginOptions::languageChange()

    void loginOptions::init()

    void loginOptions::set(ParameterList &pParams)
      QVariant param;
      bool     valid;

      param = pParams.value("databaseURL", &valid);
      if (valid)
        _databaseURL = param.toString();

        QString protocol;
        QString server;
        QString database;
        QString port;
        parseDatabaseURL(_databaseURL, protocol, server, database, port);
        int index = _driver->findText(protocol,Qt::MatchExactly);
        if(index == -1)
            qDebug((QString("Error, the protocol %1 was not found!").arg(protocol)));
        // just set something
        } else {

    void loginOptions::sSave()
      buildDatabaseURL(_databaseURL, _driver->currentText(), _server->text(), _database->text(), _port->text());
      QSettings setting;
      setting.setPath("OpenMFG.com", "OpenRPT", QSettings::UserScope);
      setting.writeEntry("/OpenRPT/_databaseURL", _databaseURL);


    • Chris Ryan

      Chris Ryan - 2006-11-27

      I have committed these changes along with several modifications to have the code support aliases and user readable driver names.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks