kexi
kexifilterdlg.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 for(QStringList::ConstIterator it = mimes.begin(); it != mimes.end(); ++it)
00103 {
00104 KexiProjectHandler *h = m_project->handlerForMime(*it);
00105 if(h)
00106 {
00107 QListViewItem *base = new QListViewItem(m_catalog, h->name());
00108 base->setPixmap(0, h->groupPixmap());
00109
00110 QDictIterator<KexiProjectHandlerItem> iit(*h->items());
00111 for(; iit.current(); ++iit )
00112 {
00113 QListViewItem *bi = new QListViewItem(base, iit.current()->name());
00114 bi->setPixmap(0, h->itemPixmap());
00115
00116 KexiDataProvider *prov=KEXIDATAPROVIDER(h);
00117 if(prov)
00118 {
00119 QStringList fields = prov->fields(0, iit.current()->identifier());
00120 for(QStringList::Iterator fit = fields.begin(); fit != fields.end(); ++fit)
00121 {
00122 QListViewItem *bif = new QListViewItem(bi, (*fit));
00123 }
00124 }
00125 }
00126 }
00127 }
00128 }
00129
00130 void
00131 KexiFilterDlg::setupCatalog(const QString &mime)
00132 {
00133 QStringList l;
00134 l.append(mime);
00135 setupCatalog(l);
00136 }
00137
00138 void
00139 KexiFilterDlg::insert(QListViewItem *)
00140 {
00141 }
00142
00143 KexiFilterDlg::~KexiFilterDlg()
00144 {
00145 }
00146
00147 #include "kexifilterdlg.moc"
|