summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/tableviewer/db/common.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/tableviewer/db/common.cpp b/noncore/apps/tableviewer/db/common.cpp
index 6e544ba..b58af85 100644
--- a/noncore/apps/tableviewer/db/common.cpp
+++ b/noncore/apps/tableviewer/db/common.cpp
@@ -989,202 +989,202 @@ bool KeyList::validIndex(int i) const
{
if(!find(i))
return FALSE;
if(find(i)->delFlag())
return FALSE;
return TRUE;
}
QDataStream &operator<<( QDataStream &s, const KeyList &k)
{
s << k.getNumFields();
KeyListIterator it(k);
while(it.current()) {
s << (Q_UINT16)it.currentKey();
s << it.current()->name();
s << it.current()->example();
s << (Q_UINT16)it.current()->flags();
++it;
}
return s;
}
QDataStream &operator>>( QDataStream &s, KeyList &k)
{
int i;
int size;
int index = 0;
int flags = 0;
TVVariant type = TVVariant();
QString name;
s >> size;
for (i=0; i < size; i++) {
s >> (Q_UINT16 &)index;
s >> name;
s >> type;
s >> (Q_UINT16 &)flags;
k.replace(index, new Key(name, type, flags));
}
return s;
}
/*!
\class DataElem
\brief A class representing a single row or element of a table in a DBStore
This class holds the data of a row in a table.
*/
/*!
Constructs a DataElem. This function needs a container because the
size, types of keys and primary key are all defined by the containing
database
*/
DataElem::DataElem(DBStore *c) : values(20)
{
int size;
contained = c;
size = c->getNumFields();
values.setAutoDelete(TRUE);
}
/*!
Destroys a DataElem and frees memory used by the DataElem
*/
DataElem::~DataElem() {
}
QDataStream &operator<<( QDataStream &s, const DataElem &d)
{
int size = d.getNumFields();
s << size; /* redundent data but makes streaming easier */
KeyList k = d.getKeys();
KeyListIterator it(k);
while(it.current()) {
s << (Q_UINT16)it.currentKey();
s << d.getField(it.currentKey());
++it;
}
return s;
}
QDataStream &operator>>( QDataStream &s, DataElem &d)
{
int i;
int size;
TVVariant t;
- int index = 0;
+ Q_UINT16 index = 0;
s >> size; /* redundent data but makes streaming easier */
if (size != d.getNumFields()) {
owarn << "DataSize mis-match" << oendl;
return s; /* sanity check failed.. don't load */
}
for(i = 0; i < size; i++) {
- s >> (Q_UINT16)index;
+ s >> index;
s >> t;
d.setField(index, t);
}
return s;
}
/*! Returns the number of possible (not valid) fields in the data element */
int DataElem::getNumFields() const
{
return contained->getNumFields();
}
KeyList DataElem::getKeys() const
{
return *(contained->getKeys());
}
/*!
This function determines whether field index i of the element has been
set yet.
\return A boolean value that is TRUE if the specfied field of this
element has been set and FALSE if the field has not yet been set
*/
bool DataElem::hasValidValue(int i) const
{
if(!values.find(i))
return FALSE;
if(!contained->getKeys()->validIndex(i))
return FALSE;
return values.find(i)->isValid();
}
/*!
This function determines whether field name qs of the element has been
set yet.
\return A boolean value that is TRUE if the specfied field of this
element has been set and FALSE if the field has not yet been set
*/
bool DataElem::hasValidValue(QString qs) const
{
int i = contained->getKeyIndex(qs);
return hasValidValue(i);
}
/*! returns the type of the field specified by index i */
TVVariant::KeyType DataElem::getFieldType(int i) const
{
return contained->getKeyType(i);
}
/*! returns the type of the field specified by name qs */
TVVariant::KeyType DataElem::getFieldType(QString qs) const
{
int i = contained->getKeyIndex(qs);
return contained->getKeyType(i);
}
/*!
returns a pointer to the data stored in field index i for this
data element, (value may not be valid)
*/
TVVariant DataElem::getField(int i) const
{
if(hasValidValue(i))
return TVVariant(*values.find(i));
return TVVariant();
}
/*!
returns a pointer to the data stored in field name qs for this
data element, (value may not be valid)
*/
TVVariant DataElem::getField(QString qs) const
{
int i = contained->getKeyIndex(qs);
return getField(i);
}
/*!
Sets the value of the elements field index i to the value represented in
the QString q.
\param i index of the field to set
\param q a string that can be parsed to get the value to be set
*/
void DataElem::setField(int i, QString q)
{
/* from the type of the field, parse q and store */
TVVariant::KeyType kt = contained->getKeyType(i);
TVVariant t = TVVariant(q);
switch(kt) {
case TVVariant::Int: {