kexi

kexifilterdlg.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
00003 
00004    This program is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this program; see the file COPYING.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include <qlistview.h>
00021 #include <qpushbutton.h>
00022 #include <qlayout.h>
00023 #include <qheader.h>
00024 #include <qstringlist.h>
00025 
00026 #include "kexiproject.h"
00027 #include "kexiprojecthandler.h"
00028 #include "kexiprojecthandleritem.h"
00029 #include "kexidataprovider.h"
00030 #include "kexifilterdlg.h"
00031 #include "kexiquerydesignersqleditor.h"
00032 
00033 KexiFilterDlg::KexiFilterDlg(KexiProject *project, QWidget *parent, const char *name)
00034  : QDialog(parent, name)
00035 {
00036     m_project = project;
00037 
00038     QHBoxLayout *lbraces = new QHBoxLayout(0, 0, 4);
00039 
00040     QPushButton *bsBO = createMiniButton("[");
00041     QPushButton *bBO = createMiniButton("(");
00042     QPushButton *bBC = createMiniButton(")");
00043     QPushButton *bsBC = createMiniButton("]");
00044     lbraces->addWidget(bsBO);
00045     lbraces->addWidget(bBO);
00046     lbraces->addWidget(bBC);
00047     lbraces->addWidget(bsBC);
00048 
00049     QHBoxLayout *lcond = new QHBoxLayout(0, 0, 4);
00050     QPushButton *blt = createMiniButton("<");
00051     QPushButton *beq = createMiniButton("=");
00052     QPushButton *bgt = createMiniButton(">");
00053     QPushButton *bp = createMiniButton("%");
00054     lcond->addWidget(blt);
00055     lcond->addWidget(beq);
00056     lcond->addWidget(bgt);
00057     lcond->addWidget(bp);
00058 
00059     QHBoxLayout *lbool = new QHBoxLayout(0, 0, 4);
00060     QPushButton *bAnd = new QPushButton("AND", this);
00061     bAnd->setFlat(true);
00062     QPushButton *bOr = new QPushButton("OR", this);
00063     bOr->setFlat(true);
00064     QPushButton *bLike = new QPushButton("LIKE", this);
00065     bLike->setFlat(true);
00066     lbool->addWidget(bLike);
00067     lbool->addWidget(bAnd);
00068     lbool->addWidget(bOr);
00069 
00070     m_catalog = new QListView(this);
00071     m_catalog->addColumn("a");
00072     m_catalog->header()->hide();
00073 
00074     KexiQueryDesignerSQLEditor *e = new KexiQueryDesignerSQLEditor(this);
00075 
00076     setupCatalog(QString("kexi/table"));
00077 
00078     QGridLayout *g = new QGridLayout(this);
00079     g->setSpacing(6);
00080     g->addMultiCellWidget(e,        0, 0, 0, 2);
00081     g->addItem(lbraces,         1, 0);
00082     g->addItem(lcond,           1, 1);
00083     g->addItem(lbool,           1, 2);
00084     g->addMultiCellWidget(m_catalog,    2, 2, 0, 2);
00085 }
00086 
00087 QPushButton*
00088 KexiFilterDlg::createMiniButton(const QString &text)
00089 {
00090     QPushButton *p = new QPushButton(text, this);
00091     p->setFlat(true);
00092     p->setMaximumSize(QSize(20, 300));
00093 
00094     return p;
00095 }
00096 
00097 void
00098 KexiFilterDlg::setupCatalog(const QStringList &mimes)
00099 {
00100     m_catalog->clear();
00101     m_catalog->setRootIsDecorated(true);
00102     QStringList::ConstIterator it, end( mimes.constEnd() );
00103     for( it = mimes.constBegin(); it != end; ++it)
00104     {
00105         KexiProjectHandler *h = m_project->handlerForMime(*it);
00106         if(h)
00107         {
00108             QListViewItem *base = new QListViewItem(m_catalog, h->name());
00109             base->setPixmap(0, h->groupPixmap());
00110 
00111             QDictIterator<KexiProjectHandlerItem> iit(*h->items()); // See QDictIterator
00112             for(; iit.current(); ++iit )
00113             {
00114                 QListViewItem *bi = new QListViewItem(base, iit.current()->name());
00115                 bi->setPixmap(0, h->itemPixmap());
00116 
00117                 KexiDataProvider *prov=KEXIDATAPROVIDER(h);
00118                 if(prov)
00119                 {
00120                     QStringList fields = prov->fields(0, iit.current()->identifier());
00121                     QStringList::ConstIterator fit, end( fields.constEnd() );
00122                     for( fit = fields.constBegin(); fit != end; ++fit)
00123                     {
00124                         QListViewItem *bif = new QListViewItem(bi, (*fit));
00125                     }
00126                 }
00127             }
00128         }
00129     }
00130 }
00131 
00132 void
00133 KexiFilterDlg::setupCatalog(const QString &mime)
00134 {
00135     QStringList l;
00136     l.append(mime);
00137     setupCatalog(l);
00138 }
00139 
00140 void
00141 KexiFilterDlg::insert(QListViewItem *)
00142 {
00143 }
00144 
00145 KexiFilterDlg::~KexiFilterDlg()
00146 {
00147 }
00148 
00149 #include "kexifilterdlg.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys