-rw-r--r-- | noncore/apps/tableviewer/db/common.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/tableviewer/db/csvsource.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/commonwidgets.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvbrowseview.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tveditview.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvfilterview.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvkeyedit.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvlistview.cpp | 4 |
8 files changed, 15 insertions, 14 deletions
diff --git a/noncore/apps/tableviewer/db/common.cpp b/noncore/apps/tableviewer/db/common.cpp index 71844a5..dbf9370 100644 --- a/noncore/apps/tableviewer/db/common.cpp +++ b/noncore/apps/tableviewer/db/common.cpp @@ -618,129 +618,129 @@ bool TVVariant::closer(TVVariant n, TVVariant o) QTime iv = toTime(); /* definition of closer is the least difference in days */ int diff1 = i1.msecsTo(iv); if (diff1 < 0) diff1 = -diff1; int diff2 = i2.msecsTo(iv); if (diff2 < 0) diff2 = -diff2; if (diff1 < diff2) return TRUE; return FALSE; } default: /* don't know how to do 'closer' on this type, hence never closer * or even close */ break; } return FALSE; } /*! True if n is close to this */ bool TVVariant::close(TVVariant n) { /* Nothing is close to an invalid, so nothing can be closer */ if(type() == Invalid) return FALSE; /* can't be close if of different type */ if(n.type() != type()) return FALSE; switch(type()){ case String: { /* case for strings is close is a substring.. closer is * earlier alphabetically */ QString qs1 = n.toString().lower(); QString qsv = toString().lower(); if (!qs1.startsWith(qsv)) return FALSE; return TRUE; } case Int: case Date: case Time: return TRUE; default: /* don't know how to do 'closer' on this type, hence never closer * or even close */ break; } return FALSE; } /*! \class Key \brief document me! document me! */ Key::Key() : kname(), kexample(), kflags(0) { } -Key::Key(QString name, TVVariant example, int flags = 0) : +Key::Key(QString name, TVVariant example, int flags) : kname(name), kexample(example), kflags(flags) { } Key::Key(const Key &other) { kname = other.kname; kexample = other.kexample; kflags = other.kflags; } Key& Key::operator=(const Key& key) { kname = key.kname; kexample = key.kexample; kflags = key.kflags; return *this; } QString Key::name() const { return QString(kname); } TVVariant Key::example() const { return TVVariant(kexample); } TVVariant::KeyType Key::type() const { return kexample.type(); } void Key::setName(const QString &name) { kname = QString(name); } void Key::setExample(const TVVariant &e) { kexample = TVVariant(e); } int Key::flags() const { return kflags; } void Key::setFlags(int fl) { kflags = fl; } bool Key::delFlag() const { if(kflags & del_flag) return TRUE; return FALSE; } bool Key::newFlag() const { if(kflags & new_flag) return TRUE; return FALSE; diff --git a/noncore/apps/tableviewer/db/csvsource.cpp b/noncore/apps/tableviewer/db/csvsource.cpp index 2561b4b..ea36300 100644 --- a/noncore/apps/tableviewer/db/csvsource.cpp +++ b/noncore/apps/tableviewer/db/csvsource.cpp @@ -37,128 +37,129 @@ DBCsv::~DBCsv() QString DBCsv::type() { return "csv"; } QStringList readElem(QString in) { QStringList out; if (in.isEmpty()) return out; bool firstChar = TRUE; bool quotedElem = FALSE; uint index = 0; while(index < in.length()) { if(firstChar) { /* skip whitespace */ while(index < in.length() && in[index] == ' ') index++; if(in[index] == '"') { quotedElem = TRUE; index++; } } /* real first char */ QString elem; if(quotedElem) { while(index < in.length() && in[index] != '"') { /* check for escape character */ if (in[index] == '\\') { if (index++ < in.length()) { elem.append(in[index]); index++; } } else { elem.append(in[index]); index++; } } } else { while(index < in.length() && in[index] != ',') { if (in[index] == '\\') { if (index++ < in.length()) { elem.append(in[index]); index++; } } else { elem.append(in[index]); index++; } } } /* we have our current elem */ out << elem.stripWhiteSpace(); firstChar = TRUE; quotedElem = FALSE; /* skip till a , or end of line */ while (index < in.length() && in[index] != ',') index++; if(index == in.length()) return out; else index++; } + return out; } bool DBCsv::openSource(QIODevice *inDev) { QTextStream tsIn(inDev); QString in = tsIn.readLine().stripWhiteSpace(); QStringList keys; keys = readElem(in); QMap<int,int> keyIndexes; KeyList *keyR = new KeyList(); QStringList::Iterator i = keys.begin(); uint fileIndex = 0; while(i != keys.end()) { if ((*i).isEmpty()) keyIndexes.insert(fileIndex, keyR->addKey("Unamed", TVVariant::String)); else keyIndexes.insert(fileIndex, keyR->addKey(*i, TVVariant::String)); i++; fileIndex++; } dstore->setKeys(keyR); in = tsIn.readLine().stripWhiteSpace(); while(!in.isNull()) { QStringList elems = readElem(in); i = elems.begin(); fileIndex = 0; DataElem *current_data = new DataElem(dstore); while(i != elems.end()) { if(!(*i).isEmpty()) { current_data->setField(keyIndexes[fileIndex], *i); } fileIndex++; i++; } dstore->addItem(current_data); in = tsIn.readLine().stripWhiteSpace(); } return TRUE; } bool DBCsv::saveSource(QIODevice *outDev) { /* try not to use the escape character when possible. */ int i; DataElem *elem; KeyList *k; QTextStream outstream(outDev); k = dstore->getKeys(); KeyListIterator it(*k); while(it.current()) { if(!it.current()->delFlag()) { QString name = it.current()->name(); name.replace(QRegExp("\\"), "\\\\"); name.replace(QRegExp("\""), "\\\""); if(name.find(',') != -1) { diff --git a/noncore/apps/tableviewer/ui/commonwidgets.cpp b/noncore/apps/tableviewer/ui/commonwidgets.cpp index bf4c36f..4c47951 100644 --- a/noncore/apps/tableviewer/ui/commonwidgets.cpp +++ b/noncore/apps/tableviewer/ui/commonwidgets.cpp @@ -1,210 +1,210 @@ /********************************************************************** ** 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 = 0, const char *name = 0, WFlags f = 0 ) +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)), 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 = 0, const char *name = 0, WFlags f = 0 ) +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) { /* pm */ h = h + 12; } /* hour now ranges 1->24 */ if (h == 12) h = 0; if (h == 24) h = 12; if(QTime::isValid(h, m, s)) return QTime(h, m, s); return QTime(0, 0, 0); } void TimeEdit::setTime(QTime t) { int h = t.hour(); secondKey->setValue(t.second()); minuteKey->setValue(t.minute()); /* h 0..23 */ if (h > 11) { h -= 12; ampm->setCurrentItem(1); } else { ampm->setCurrentItem(0); } if (h == 0) h = 12; hourKey->setValue(h); } QSizePolicy TimeEdit::sizePolicy() const { QSizePolicy sp; sp.setHorData(QSizePolicy::Preferred); sp.setVerData(QSizePolicy::Fixed); return sp; } void TimeEdit::clear() { secondKey->setValue(0); minuteKey->setValue(0); hourKey->setValue(12); ampm->setCurrentItem(0); } void TimeEdit::subValueChanged() { emit valueChanged(time()); } -IntEdit::IntEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ) +IntEdit::IntEdit( QWidget *parent, const char *name, WFlags f ) : QSpinBox(INT_MIN, INT_MAX, 1, parent, name) { setValue(0); } IntEdit::~IntEdit() {} int IntEdit::value() { return cleanText().toInt(); } void IntEdit::clear() { setValue(0); } diff --git a/noncore/apps/tableviewer/ui/tvbrowseview.cpp b/noncore/apps/tableviewer/ui/tvbrowseview.cpp index 9bfc791..f5f2555 100644 --- a/noncore/apps/tableviewer/ui/tvbrowseview.cpp +++ b/noncore/apps/tableviewer/ui/tvbrowseview.cpp @@ -1,105 +1,105 @@ /********************************************************************** ** 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> /*! \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 = 0, const char *name = 0, - WFlags fl =0) +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(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>" + it.current()->name() diff --git a/noncore/apps/tableviewer/ui/tveditview.cpp b/noncore/apps/tableviewer/ui/tveditview.cpp index ba2bd06..23e2b42 100644 --- a/noncore/apps/tableviewer/ui/tveditview.cpp +++ b/noncore/apps/tableviewer/ui/tveditview.cpp @@ -1,108 +1,108 @@ /********************************************************************** ** 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. ** **********************************************************************/ /* The edit view widget. For each key in the DB display an * appropriate edit box, and a 'key' button to change that particular * key information (delete or edit). * * Bottem line should be a 'new key' button. Should be able to scroll * in both directions. */ #include "tveditview.h" #include "commonwidgets.h" #include <qlayout.h> #include <qgrid.h> #include <qvbox.h> #include <qlineedit.h> #include <qcheckbox.h> #include <qlist.h> #include <qlabel.h> #include <qscrollview.h> #include <qsignalmapper.h> -TVEditView::TVEditView(TableState *s, DataElem *d, QWidget* parent = 0, - const char *name = 0, WFlags fl =0) : QDialog(parent, name, true, fl) +TVEditView::TVEditView(TableState *s, DataElem *d, QWidget* parent, + const char *name, WFlags fl ) : QDialog(parent, name, true, fl) { if (!name) setName("TVEditView"); QVBoxLayout *layout = new QVBoxLayout(this, 0); /* only so that will resize correctly in other widgets */ toggles = new QSignalMapper(this); QScrollView *sv = new QScrollView(this, 0); sv->setResizePolicy(QScrollView::AutoOneFit); layout->addWidget(sv); editDisplay = new QGrid(3, sv, 0); editDisplay->setSpacing(3); sv->addChild(editDisplay); connect(toggles, SIGNAL(mapped(int)), this, SLOT(toggleEnabled(int))); setData(s, d); #ifdef Q_WS_QWS showMaximized(); #endif } TVEditView::~TVEditView() { } /*! set up the widgets in the grid, Set up initial values */ void TVEditView::setData(TableState *t, DataElem *d) { /* TODO need to somehow clear old children... a delete of each * child? */ keyIds.clear(); KeyListIterator it(*t->kRep); int i = 0; while(it.current()) { if (t->kRep->validIndex(it.currentKey())) { new QLabel(it.current()->name(), editDisplay); keyIds.insert(i, it.currentKey()); if (d->hasValidValue(it.currentKey())) { switch(it.current()->type()) { case TVVariant::String: { QLineEdit *edit = new QLineEdit(editDisplay, 0); edit->setText(d->getField(it.currentKey()).toString()); edits.append(edit); break; } case TVVariant::Int: { IntEdit *edit = new IntEdit(editDisplay, 0); edit->setValue(d->getField(it.currentKey()).toInt()); edits.append(edit); break; } case TVVariant::Time: { TimeEdit *edit = new TimeEdit(editDisplay, 0); edit->setTime(d->getField(it.currentKey()).toTime()); edits.append(edit); break; diff --git a/noncore/apps/tableviewer/ui/tvfilterview.cpp b/noncore/apps/tableviewer/ui/tvfilterview.cpp index 72d39d6..0182127 100644 --- a/noncore/apps/tableviewer/ui/tvfilterview.cpp +++ b/noncore/apps/tableviewer/ui/tvfilterview.cpp @@ -1,94 +1,94 @@ /********************************************************************** ** 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> -TVFilterView::TVFilterView(TableState *t, QWidget* parent = 0, - const char *name = 0, WFlags fl =0) : QDialog(parent, name, TRUE, fl) +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 *))); ts = t; current = 0; terms.setAutoDelete(true); diff --git a/noncore/apps/tableviewer/ui/tvkeyedit.cpp b/noncore/apps/tableviewer/ui/tvkeyedit.cpp index fb7b7fe..4849e87 100644 --- a/noncore/apps/tableviewer/ui/tvkeyedit.cpp +++ b/noncore/apps/tableviewer/ui/tvkeyedit.cpp @@ -31,130 +31,130 @@ class TVKEListViewItem : public QListViewItem { public: TVKEListViewItem(QString n, TVVariant::KeyType kt, int p, QListView *parent) : QListViewItem(parent) { name = n; keyType = kt; position = p; } QString text(int i) const { if(i) { return TVVariant::typeToName(keyType); } return name; } /* always sort by key index, ignore i */ QString key(int, bool) const { return QString().sprintf("%08d", position); } void setText(int i, const QString &) { ; } QString getName() const { return name; } void setName(QString n) { name = n; repaint(); } TVVariant::KeyType getKeyType() const { return keyType; } void setKeyType(TVVariant::KeyType k) { keyType = k; repaint(); } inline int getPos() const { return position; } private: QString name; TVVariant::KeyType keyType; int position; }; -TVKeyEdit::TVKeyEdit(TableState *t, QWidget* parent = 0, const char *name = 0, - WFlags fl = 0) : TVKeyEdit_gen(parent, name, true, fl) +TVKeyEdit::TVKeyEdit(TableState *t, QWidget* parent, const char *name, + WFlags fl) : TVKeyEdit_gen(parent, name, true, fl) { int i; ts = t; if(!ts) return; if(!ts->kRep) return; working_state = *ts->kRep; i = 1; keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); i++; keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); i++; keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); i++; keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); KeyListIterator it(*ts->kRep); while(it.current()) { if(t->kRep->validIndex(it.currentKey())) { new TVKEListViewItem(it.current()->name(), it.current()->type(), it.currentKey(), display); } ++it; } num_keys = ts->kRep->getNumFields(); if(display->childCount() > 0) { display->setCurrentItem(display->firstChild()); setTerm(display->currentItem()); } else { deleteKeyButton->setEnabled(FALSE); clearKeysButton->setEnabled(FALSE); keyNameEdit->setEnabled(FALSE); keyTypeEdit->setEnabled(FALSE); } display->setSorting(0); #ifdef Q_WS_QWS showMaximized(); #endif } /*! Destroys the TVKeyEdit widget */ TVKeyEdit::~TVKeyEdit() { } /* SLOTS */ void TVKeyEdit::newTerm() { /* new item, make current Item */ int i; i = working_state.addKey("<New Key>", TVVariant::String); //working_state.setNewFlag(i, TRUE); TVKEListViewItem *nItem = new TVKEListViewItem("<New Key>", TVVariant::String, i, display); diff --git a/noncore/apps/tableviewer/ui/tvlistview.cpp b/noncore/apps/tableviewer/ui/tvlistview.cpp index 82d67c6..b25e813 100644 --- a/noncore/apps/tableviewer/ui/tvlistview.cpp +++ b/noncore/apps/tableviewer/ui/tvlistview.cpp @@ -24,130 +24,130 @@ #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 = 0, - const char *name = 0, WFlags fl =0) : QWidget(parent, name, fl) +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(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(); |