Chapter 5. A runtime version
Prev |  |

## Chapter 5. A runtime version

Sometimes the user should not have the possibility to change the data structure. To hide the design mode just set hk_drivermanager(true). Below is the program of the previous chapter.

Example 5.1. Using a table - the runtime version

    #define HAVE_SSTREAM 1
    #include <kapp.h>
    #include <kaboutdata.h>
    #include <kcmdlineargs.h>
    #include <klocale.h>
    #include <hk_classes.h>
    #include <iostream>
    #include <hk_kdetable.h>
    #include <hk_kdemessages.h>

    static const char *description =
        I18N_NOOP("A hk_kdeclasses example Application");

    static const char *version = "v0.1";

    int main(int argc, char **argv)
    {
        KAboutData about("hk_kdeexample", I18N_NOOP("hk_kdeexample"), version, description, KAboutData::License_GPL, "(C) 2001 Horst Knorr", 0, 0, "hk_classes@knoda.org");
        about.addAuthor( "Horst Knorr", 0, "hk_classes@knoda.org" );
        KCmdLineArgs::init(argc, argv, &about);
        KApplication app;

        set_kdestandarddialogs();
        hk_drivermanager* mydrivermanager = new hk_drivermanager(true);
        hk_kdetable* table = new hk_kdetable(NULL);

        app.setMainWidget(table);
        if (mydrivermanager==NULL) {cout <<"error creating mydrivermanager"<<endl;exit(1);}
        hk_connection* myconnection = mydrivermanager->new_connection("mysql");
        if (myconnection==NULL) {cout <<"error creating myconnection"<<endl;exit(1);}
        myconnection->connect();

        hk_database* mydatabase=myconnection->new_database("exampledb");
        if (mydatabase==NULL) {cout <<"error creating mydatabase"<<endl;exit(1);}
        hk_datasource* mydatasource= mydatabase->new_table("authors");
        if (mydatasource==NULL) {cout <<"error creating mydatasource"<<endl;exit(1);}

        table->set_datasource(mydatasource);
        table->show();
        table->set_viewmode();

        int res= app.exec();
        delete mydrivermanager;
        return res;
    }

Prev |  |
Tables | Home |