kexi

kexifilterdlg.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <tqlistview.h>
21#include <tqpushbutton.h>
22#include <tqlayout.h>
23#include <tqheader.h>
24#include <tqstringlist.h>
25
26#include "kexiproject.h"
27#include "kexiprojecthandler.h"
28#include "kexiprojecthandleritem.h"
29#include "kexidataprovider.h"
30#include "kexifilterdlg.h"
31#include "kexiquerydesignersqleditor.h"
32
33KexiFilterDlg::KexiFilterDlg(KexiProject *project, TQWidget *parent, const char *name)
34 : TQDialog(parent, name)
35{
36 m_project = project;
37
38 TQHBoxLayout *lbraces = new TQHBoxLayout(0, 0, 4);
39
40 TQPushButton *bsBO = createMiniButton("[");
41 TQPushButton *bBO = createMiniButton("(");
42 TQPushButton *bBC = createMiniButton(")");
43 TQPushButton *bsBC = createMiniButton("]");
44 lbraces->addWidget(bsBO);
45 lbraces->addWidget(bBO);
46 lbraces->addWidget(bBC);
47 lbraces->addWidget(bsBC);
48
49 TQHBoxLayout *lcond = new TQHBoxLayout(0, 0, 4);
50 TQPushButton *blt = createMiniButton("<");
51 TQPushButton *beq = createMiniButton("=");
52 TQPushButton *bgt = createMiniButton(">");
53 TQPushButton *bp = createMiniButton("%");
54 lcond->addWidget(blt);
55 lcond->addWidget(beq);
56 lcond->addWidget(bgt);
57 lcond->addWidget(bp);
58
59 TQHBoxLayout *lbool = new TQHBoxLayout(0, 0, 4);
60 TQPushButton *bAnd = new TQPushButton("AND", this);
61 bAnd->setFlat(true);
62 TQPushButton *bOr = new TQPushButton("OR", this);
63 bOr->setFlat(true);
64 TQPushButton *bLike = new TQPushButton("LIKE", this);
65 bLike->setFlat(true);
66 lbool->addWidget(bLike);
67 lbool->addWidget(bAnd);
68 lbool->addWidget(bOr);
69
70 m_catalog = new TQListView(this);
71 m_catalog->addColumn("a");
72 m_catalog->header()->hide();
73
75
76 setupCatalog(TQString("kexi/table"));
77
78 TQGridLayout *g = new TQGridLayout(this);
79 g->setSpacing(6);
80 g->addMultiCellWidget(e, 0, 0, 0, 2);
81 g->addItem(lbraces, 1, 0);
82 g->addItem(lcond, 1, 1);
83 g->addItem(lbool, 1, 2);
84 g->addMultiCellWidget(m_catalog, 2, 2, 0, 2);
85}
86
87TQPushButton*
88KexiFilterDlg::createMiniButton(const TQString &text)
89{
90 TQPushButton *p = new TQPushButton(text, this);
91 p->setFlat(true);
92 p->setMaximumSize(TQSize(20, 300));
93
94 return p;
95}
96
97void
98KexiFilterDlg::setupCatalog(const TQStringList &mimes)
99{
100 m_catalog->clear();
101 m_catalog->setRootIsDecorated(true);
102 TQStringList::ConstIterator it, end( mimes.constEnd() );
103 for( it = mimes.constBegin(); it != end; ++it)
104 {
105 KexiProjectHandler *h = m_project->handlerForMime(*it);
106 if(h)
107 {
108 TQListViewItem *base = new TQListViewItem(m_catalog, h->name());
109 base->setPixmap(0, h->groupPixmap());
110
111 TQDictIterator<KexiProjectHandlerItem> iit(*h->items()); // See TQDictIterator
112 for(; iit.current(); ++iit )
113 {
114 TQListViewItem *bi = new TQListViewItem(base, iit.current()->name());
115 bi->setPixmap(0, h->itemPixmap());
116
117 KexiDataProvider *prov=KEXIDATAPROVIDER(h);
118 if(prov)
119 {
120 TQStringList fields = prov->fields(0, iit.current()->identifier());
121 TQStringList::ConstIterator fit, end( fields.constEnd() );
122 for( fit = fields.constBegin(); fit != end; ++fit)
123 {
124 TQListViewItem *bif = new TQListViewItem(bi, (*fit));
125 }
126 }
127 }
128 }
129 }
130}
131
132void
133KexiFilterDlg::setupCatalog(const TQString &mime)
134{
135 TQStringList l;
136 l.append(mime);
137 setupCatalog(l);
138}
139
140void
141KexiFilterDlg::insert(TQListViewItem *)
142{
143}
144
145KexiFilterDlg::~KexiFilterDlg()
146{
147}
148
149#include "kexifilterdlg.moc"
A project's main controller.
Definition kexiproject.h:68
Text editor for entering query statements.