~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kexi/tests/widgets/kexidbdrivercombotest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   This file is part of the KDE project                                  *
 
3
 *   Copyright (C) 2005 Martin Ellis <martin.ellis@kdemail.net>            *
 
4
 *                                                                         *
 
5
 *   Permission is hereby granted, free of charge, to any person obtaining *
 
6
 *   a copy of this software and associated documentation files (the       *
 
7
 *   "Software"), to deal in the Software without restriction, including   *
 
8
 *   without limitation the rights to use, copy, modify, merge, publish,   *
 
9
 *   distribute, sublicense, and/or sell copies of the Software, and to    *
 
10
 *   permit persons to whom the Software is furnished to do so, subject to *
 
11
 *   the following conditions:                                             *
 
12
 *                                                                         *
 
13
 *   The above copyright notice and this permission notice shall be        *
 
14
 *   included in all copies or substantial portions of the Software.       *
 
15
 *                                                                         *
 
16
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
 
17
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
 
18
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
 
19
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
 
20
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
 
21
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
 
22
 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
 
23
 ***************************************************************************/
 
24
 
 
25
#include <qlayout.h>
 
26
#include <qpushbutton.h>
 
27
#include <kdebug.h>
 
28
#include <kcmdlineargs.h>
 
29
#include <kapplication.h>
 
30
#include <kinstance.h>
 
31
 
 
32
#include <kexidb/drivermanager.h>
 
33
#include <widget/kexidbdrivercombobox.h>
 
34
 
 
35
/*
 
36
   This is an example of the KexiDBDriverComboBox class, used to 
 
37
   allow the user to pick a database driver.
 
38
 
 
39
   When run it shows two comboboxes. The top one allows the user to
 
40
   pick any database driver. The second allows the user to pick
 
41
   any of the drivers for database servers (i.e. it does not include
 
42
   file based drivers).
 
43
*/
 
44
 
 
45
int main(int argc, char** argv)
 
46
{
 
47
  // Initialise the program
 
48
  KCmdLineArgs::init(argc, argv, "kexidbcomboboxtest", "", "", "", true);
 
49
  KApplication* app = new KApplication(true, true);
 
50
 
 
51
  // Look for installed database drivers
 
52
  KexiDB::DriverManager manager;
 
53
  KexiDB::Driver::InfoMap drvs = manager.driversInfo();
 
54
 
 
55
  // Set up a combo box and a quit widget in a new container
 
56
  QWidget* vbox = new QWidget();
 
57
  QVBoxLayout* vbLayout = new QVBoxLayout(vbox);
 
58
 
 
59
  KexiDBDriverComboBox* all = new KexiDBDriverComboBox(drvs, true, vbox);
 
60
  KexiDBDriverComboBox* srvOnly = new KexiDBDriverComboBox(drvs, false, vbox);
 
61
 
 
62
  QPushButton* quit = new QPushButton("Quit", vbox);
 
63
 
 
64
  vbLayout->addWidget(all);     // Combobox listing all drivers
 
65
  vbLayout->addWidget(srvOnly); // Combobox only drivers for DB servers
 
66
  vbLayout->addWidget(quit);
 
67
 
 
68
  // Show the whole lot
 
69
  QObject::connect(quit, SIGNAL(clicked()), app, SLOT(quit()));
 
70
  vbox->show();
 
71
  app->exec();
 
72
 
 
73
  delete app;
 
74
}
 
75