summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer/ui
Side-by-side diff
Diffstat (limited to 'noncore/apps/tableviewer/ui') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/ui/commonwidgets.cpp2
-rw-r--r--noncore/apps/tableviewer/ui/tvbrowseview.cpp4
-rw-r--r--noncore/apps/tableviewer/ui/tvfilterview.cpp2
-rw-r--r--noncore/apps/tableviewer/ui/tvlistview.cpp4
4 files changed, 6 insertions, 6 deletions
diff --git a/noncore/apps/tableviewer/ui/commonwidgets.cpp b/noncore/apps/tableviewer/ui/commonwidgets.cpp
index 4c47951..e82018c 100644
--- a/noncore/apps/tableviewer/ui/commonwidgets.cpp
+++ b/noncore/apps/tableviewer/ui/commonwidgets.cpp
@@ -1,136 +1,136 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <qlineedit.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qcombobox.h>
#include <qpe/datebookmonth.h>
#include <qpopupmenu.h>
#include <qspinbox.h>
#include "commonwidgets.h"
DateEdit::DateEdit( QWidget *parent, const char *name, WFlags f )
: QToolButton(parent, name)
{
QPopupMenu *m1 = new QPopupMenu(this);
dateSelector = new DateBookMonth(m1, 0, TRUE);
m1->insertItem(dateSelector);
setPopup(m1);
setPopupDelay(0);
- connect(dateSelector, SIGNAL(dateClicked(int, int, int)),
+ connect(dateSelector, SIGNAL(dateClicked(int,int,int)),
this, SLOT(subValueChanged()));
setText(dateSelector->selectedDate().toString());
}
DateEdit::~DateEdit() {}
QDate DateEdit::date() const
{
return dateSelector->selectedDate();
}
void DateEdit::setDate(QDate d)
{
dateSelector->setDate(d.year(), d.month(), d.day());
setText(d.toString());
}
QSizePolicy DateEdit::sizePolicy() const
{
QSizePolicy sp;
sp.setHorData(QToolButton::sizePolicy().horData());
sp.setVerData(QSizePolicy::Fixed);
return sp;
}
void DateEdit::clear()
{
QDate today = QDate::currentDate();
dateSelector->setDate(today.year(), today.month(), today.day());
setText(today.toString());
}
void DateEdit::subValueChanged()
{
QDate current = dateSelector->selectedDate();
setText(current.toString());
emit valueChanged(current);
}
TimeEdit::TimeEdit( QWidget *parent, const char *name, WFlags f )
: QWidget(parent, name, f)
{
QHBoxLayout *layout = new QHBoxLayout(this, 0);
layout->addWidget(hourKey = new QSpinBox(1, 12, 1, this));
hourKey->setWrapping(true);
hourKey->setMinimumWidth(30);
hourKey->setMaximumWidth(35);
layout->addWidget(new QLabel(" : ", this));
layout->addWidget(minuteKey = new QSpinBox(0, 59, 1, this));
minuteKey->setWrapping(true);
minuteKey->setMinimumWidth(30);
minuteKey->setMaximumWidth(35);
layout->addWidget(new QLabel(" : ", this));
layout->addWidget(secondKey = new QSpinBox(0, 59, 1, this, 0));
secondKey->setWrapping(true);
secondKey->setMinimumWidth(30);
secondKey->setMaximumWidth(35);
layout->addWidget(ampm = new QComboBox(this));
ampm->insertItem("AM");
ampm->insertItem("PM");
layout->addStretch(-1);
clear();
connect(secondKey, SIGNAL(valueChanged(const QString&)),
this, SLOT(subValueChanged()));
connect(minuteKey, SIGNAL(valueChanged(const QString&)),
this, SLOT(subValueChanged()));
connect(hourKey, SIGNAL(valueChanged(const QString&)),
this, SLOT(subValueChanged()));
connect(ampm, SIGNAL(activated(int)),
this, SLOT(subValueChanged()));
}
TimeEdit::~TimeEdit() {}
QTime TimeEdit::time() const
{
int s,m,h;
s = secondKey->text().toInt();
m = minuteKey->text().toInt();
h = hourKey->text().toInt();
if(ampm->currentItem() == 1) {
diff --git a/noncore/apps/tableviewer/ui/tvbrowseview.cpp b/noncore/apps/tableviewer/ui/tvbrowseview.cpp
index 22bac55..8a65ed1 100644
--- a/noncore/apps/tableviewer/ui/tvbrowseview.cpp
+++ b/noncore/apps/tableviewer/ui/tvbrowseview.cpp
@@ -1,123 +1,123 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "tvbrowseview.h"
#include "browsekeyentry.h"
#include <qtoolbutton.h>
#include <qtextview.h>
#include <qtextbrowser.h>
#include <qlayout.h>
#include "../xmlencodeattr.h"
/*!
\class TVBrowseView
\brief The widget describing how to draw the browse view user interface
This widget allows for the user to browse through the table, one element
at a time, or search on a single key. Its main goal is to show a
single element in a readable format and make it easy for the user to
rapidly find specific elements in the table.
*/
/*!
Constructs a new TVBrowseView widget
*/
TVBrowseView::TVBrowseView(TableState *t, QWidget* parent, const char *name,
WFlags fl )
{
if (!name)
setName("BrowseView");
// setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) );
QVBoxLayout *vlayout = new QVBoxLayout(this);
textViewDisplay = new QTextBrowser(this, "textViewDisplay");
vlayout->addWidget( textViewDisplay );
keyEntry = new TVBrowseKeyEntry(this, "keyEntry");
vlayout->addWidget( keyEntry );
/* connect the signals down */
- connect(keyEntry, SIGNAL(searchOnKey(int, TVVariant)),
- this, SIGNAL(searchOnKey(int, TVVariant)));
+ connect(keyEntry, SIGNAL(searchOnKey(int,TVVariant)),
+ this, SIGNAL(searchOnKey(int,TVVariant)));
connect(keyEntry, SIGNAL(sortChanged(int)),
this, SIGNAL(sortChanged(int)));
ts = t;
keyEntry->setTableState(t);
}
/*!
Destroys the TVBrowseView widget
*/
TVBrowseView::~TVBrowseView()
{
}
void TVBrowseView::rebuildData()
{
if(!ts)
return;
if(!ts->current_elem) {
/* also disable buttons */
textViewDisplay->setText("");
return;
}
setDisplayText(ts->current_elem);
}
/* Reset to initial state */
void TVBrowseView::reset()
{
textViewDisplay->setText("");
keyEntry->reset();
}
/*!
sets the data element to be displayed to element
*/
void TVBrowseView::setDisplayText(const DataElem *element)
{
QString rep = "";
KeyListIterator it(*ts->kRep);
while (it.current()) {
if (element->hasValidValue(it.currentKey())) {
if(it.currentKey() == ts->current_column) {
rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>"
+ encodeAttr(it.current()->name())
+ ":</FONT></B> ";
} else {
rep += "<B>" + encodeAttr(it.current()->name()) + ":</B> ";
}
rep += encodeAttr(element->toQString(it.currentKey())) + "<BR>";
}
++it;
}
textViewDisplay->setText(rep);
textViewDisplay->scrollToAnchor("ckey");
}
void TVBrowseView::rebuildKeys()
{
keyEntry->rebuildKeys();
}
diff --git a/noncore/apps/tableviewer/ui/tvfilterview.cpp b/noncore/apps/tableviewer/ui/tvfilterview.cpp
index b03e846..22f1fb7 100644
--- a/noncore/apps/tableviewer/ui/tvfilterview.cpp
+++ b/noncore/apps/tableviewer/ui/tvfilterview.cpp
@@ -1,188 +1,188 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "tvfilterview.h"
#include <qtoolbutton.h>
#include <qcombobox.h>
#include <qlistview.h>
#include <qlayout.h>
#include <qheader.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qpe/qpeapplication.h>
TVFilterView::TVFilterView(TableState *t, QWidget* parent,
const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl)
{
if ( !name )
setName( "Filter View" );
QVBoxLayout *vlayout = new QVBoxLayout(this);
display = new QListView(this, "display");
display->addColumn("Key");
display->addColumn("Constraint");
display->addColumn("Value");
display->header()->setClickEnabled(FALSE);
display->header()->setResizeEnabled(FALSE);
vlayout->addWidget(display);
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
newFilterButton = new QPushButton(this, "new Filter");
newFilterButton->setMaximumSize(QSize(50, 32767));
newFilterButton->setText("New");
hlayout->addWidget(newFilterButton);
deleteFilterButton = new QPushButton(this, "delete Filter");
deleteFilterButton->setMaximumSize(QSize(50, 32767));
deleteFilterButton->setText("Delete");
hlayout->addWidget(deleteFilterButton);
clearFilterButton = new QPushButton(this, "delete Filter");
clearFilterButton->setMaximumSize(QSize(60, 32767));
clearFilterButton->setText("Clear All");
hlayout->addWidget(clearFilterButton);
vlayout->addLayout(hlayout);
QHBoxLayout *hlayout2 = new QHBoxLayout;
keyNameCombo = new QComboBox(FALSE, this, "key name");
keyNameCombo->setEnabled(FALSE);
hlayout2->addWidget(keyNameCombo);
QLabel *label = new QLabel(this);
label->setText("has value");
hlayout2->addWidget(label);
keyEntry = new TVFilterKeyEntry(this, "key entry");
keyEntry->setEnabled(FALSE);
vlayout->addLayout(hlayout2);
vlayout->addWidget(keyEntry);
connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() ));
connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm()));
connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms()));
connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() ));
connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() ));
connect(display, SIGNAL(selectionChanged(QListViewItem*)), this,
- SLOT(setTerm(QListViewItem *)));
+ SLOT(setTerm(QListViewItem*)));
ts = t;
current = 0;
terms.setAutoDelete(true);
do_filter = false;
#ifdef Q_WS_QWS
QPEApplication::showDialog( this );
#endif
}
/*!
Destroys the TVFilterView widget
*/
TVFilterView::~TVFilterView()
{
}
void TVFilterView::rebuildData()
{
}
void TVFilterView::reset()
{
keyNameCombo->clear();
keyIds.clear();
}
void TVFilterView::rebuildKeys()
{
int i;
if (!ts) return;
if(!ts->kRep) return;
keyEntry->setTableState(ts);
/* set up the list of keys that can be compared on */
keyNameCombo->clear();
KeyListIterator it(*ts->kRep);
i = 0;
while(it.current()) {
if(ts->kRep->validIndex(it.currentKey())) {
keyNameCombo->insertItem(it.current()->name());
keyIds.insert(i, it.currentKey());
++i;
}
++it;
}
}
bool TVFilterView::passesFilter(DataElem *d) {
if (!filterActive()) return true;
FilterTerm *t;
for (t = terms.first(); t != 0; t = terms.next() ) {
/* check against filter */
switch(t->ct) {
case ct_less:
if (!d->lessThan(t->keyIndex, t->value))
return false;
break;
case ct_more:
if (!d->moreThan(t->keyIndex, t->value))
return false;
break;
case ct_equal:
if (!d->equalTo(t->keyIndex, t->value))
return false;
break;
case ct_contains:
if (!d->contains(t->keyIndex, t->value))
return false;
break;
case ct_startswith:
if (!d->startsWith(t->keyIndex, t->value))
return false;
break;
case ct_endswith:
if (!d->endsWith(t->keyIndex, t->value))
return false;
break;
default:
qWarning("TVFilterView::passesFilter() "
"unrecognized filter type");
return false;
}
}
return true;
}
bool TVFilterView::filterActive() const
{
/* when button operated, also check the do_filter value
diff --git a/noncore/apps/tableviewer/ui/tvlistview.cpp b/noncore/apps/tableviewer/ui/tvlistview.cpp
index b25e813..b10ff1d 100644
--- a/noncore/apps/tableviewer/ui/tvlistview.cpp
+++ b/noncore/apps/tableviewer/ui/tvlistview.cpp
@@ -11,194 +11,194 @@
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "tvlistview.h"
#include "../db/common.h"
#include <qtoolbutton.h>
#include <qlistview.h>
#include <qlayout.h>
void TVListViewPrivate::setColumnWidth(int column, int width)
{
if(width > 70) width = 70;
QListView::setColumnWidth(column, width);
}
void TVListViewPrivate::setSorting(int column, bool increasing)
{
emit sortChanged(column);
QListView::setSorting(column, increasing);
}
TVListViewPrivate::TVListViewPrivate(QWidget *parent, const char* name,
WFlags fl) : QListView(parent, name, fl) {
;
}
class TVListViewItem : public QListViewItem
{
public:
TVListViewItem(QListView *parent, DataElem *d);
~TVListViewItem();
QString text(int i) const
{
return data_reference->toQString(i);
}
/* Do nothing... all data for this item should be generated */
void setText(int i, const QString &)
{
;
}
QString key(int i, bool a) const
{
return data_reference->toSortableQString(i);
}
void setDataElem(DataElem *d)
{
data_reference = d;
}
DataElem *getDataElem() {
return data_reference;
}
private:
DataElem *data_reference;
};
TVListViewItem::TVListViewItem(QListView *parent, DataElem *d)
: QListViewItem(parent)
{
data_reference = d;
}
TVListViewItem::~TVListViewItem()
{
data_reference = 0;
}
TVListView::TVListView(TableState *t, QWidget* parent,
const char *name, WFlags fl ) : QWidget(parent, name, fl)
{
if (!name)
setName("TVListView");
// the next two lines need to be rationalized.
resize(318,457);
setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
(QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth()));
setCaption(tr("List View"));
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setSpacing(0);
layout->setMargin(0);
listViewDisplay = new TVListViewPrivate(this, "listViewDisplay");
layout->addWidget(listViewDisplay);
- connect(listViewDisplay, SIGNAL(currentChanged(QListViewItem *)), this,
- SLOT(setCurrent(QListViewItem *)));
+ connect(listViewDisplay, SIGNAL(currentChanged(QListViewItem*)), this,
+ SLOT(setCurrent(QListViewItem*)));
connect(listViewDisplay, SIGNAL(sortChanged(int)), this,
SLOT(setSorting(int)));
listViewDisplay->setShowSortIndicator(true);
it = new QListViewItemIterator(listViewDisplay);
ts = t;
}
TVListView::~TVListView()
{
}
void TVListView::addItem(DataElem *d)
{
TVListViewItem *i = new TVListViewItem(listViewDisplay, d);
delete it;
it = new QListViewItemIterator(i);
}
/* remove current (it) item */
void TVListView::removeItem()
{
QListViewItemIterator other(*it);
QListViewItemIterator tmp = *it;
(*it)++;
if (!it->current()) {
*it = tmp;
(*it)--;
if (!it->current()) {
delete it;
it = 0;
}
}
delete other.current();
}
void TVListView::clearItems()
{
/* This is ok since the destructor for TVListItem does not know about
the data_reference pointer.. and hence will leave it alone */
listViewDisplay->clear();
delete it;
it = new QListViewItemIterator(listViewDisplay);
}
void TVListView::first()
{
delete it;
it = new QListViewItemIterator(listViewDisplay);
}
void TVListView::last()
{
qWarning("TVListView::last not yet implemented");
}
void TVListView::next()
{
QListViewItemIterator tmp = *it;
(*it)++;
if (!it->current()) {
*it = tmp;
}
}
void TVListView::previous()
{
QListViewItemIterator tmp = *it;
(*it)--;
if (!it->current()) {
*it = tmp;
}
}
DataElem *TVListView::getCurrentData() {
if (it->current()) {
return ((TVListViewItem *)it->current())->getDataElem();
}
return NULL;
}
/*! Now to implement the closest match function */
void TVListView::findItem(int keyId, TVVariant value)
{
QListViewItem *i;
TVListViewItem *best_so_far = NULL;
/* start at the beginning... go through till find the closest elem */
i = listViewDisplay->firstChild();
while (i) {
/* search stuff */
if(best_so_far) {
if (DataElem::closer(