summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer/db/datacache.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/tableviewer/db/datacache.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/db/datacache.cpp68
1 files changed, 34 insertions, 34 deletions
diff --git a/noncore/apps/tableviewer/db/datacache.cpp b/noncore/apps/tableviewer/db/datacache.cpp
index 6380e1b..de57961 100644
--- a/noncore/apps/tableviewer/db/datacache.cpp
+++ b/noncore/apps/tableviewer/db/datacache.cpp
@@ -13,13 +13,13 @@
**
** 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.
**
-**********************************************************************/
+**********************************************************************/
/*
* This file is used to load the xml files that represent the database.
* The main requirment for said file is each data entry must contain a key,
* otherwise any other data headings are allowed.
*/
@@ -60,16 +60,16 @@ DBStore::DBStore()
table_size = INIT_TABLE_SIZE;
current_elem = 0;
archive = 0;
}
-//TODO
+//TODO
/*!
- Reinitializes the table to empty (include a resize of the master table,
- which should free some memory)
+ Reinitializes the table to empty (include a resize of the master table,
+ which should free some memory)
*/
void DBStore::freeTable()
{
name = "";
if(archive) {
delete archive;
@@ -90,62 +90,62 @@ void DBStore::freeTable()
DBStore::~DBStore()
{
freeTable();
}
/*!
- This function opens the given xml file, loads it and sets up the
+ This function opens the given xml file, loads it and sets up the
appropriate data structures.
\param file_name A string representing the name of the file to be opened
\return true if successful, false otherwise.
*/
bool DBStore::openSource(QIODevice *inDev, const QString &source) {
- /* first check if db is already open, if contains data.. then clear */
+ /* first check if db is already open, if contains data.. then clear */
if(number_elems > 0) {
freeTable();
}
if (source == "text/x-xml-tableviewer") {
archive = new DBXml(this);
} else if (source == "text/csv") {
- archive = new DBCsv(this);
+ archive = new DBCsv(this);
} else
- return false;
+ return false;
return (archive->openSource(inDev));
}
-bool DBStore::saveSource(QIODevice *outDev, const QString &source)
+bool DBStore::saveSource(QIODevice *outDev, const QString &source)
{
/* saving a new file */
if(!archive) {
if (source == "text/x-xml-tableviewer") {
archive = new DBXml(this);
- } else if (source == "text/x-xml-tableviewer") {
+ } else if (source == "text/x-xml-tableviewer") {
archive = new DBCsv(this);
} else
- return false;
+ return false;
}
/* changing file type */
if(archive->type() != source) {
delete archive;
if (source == "text/x-xml-tableviewer") {
archive = new DBXml(this);
- } else if (source == "text/x-xml-tableviewer") {
+ } else if (source == "text/x-xml-tableviewer") {
archive = new DBCsv(this);
- } else
- return false;
+ } else
+ return false;
}
return (archive->saveSource(outDev));
}
-/*!
+/*!
This function is used to add new elements to the database. If the database
has already reached the maximum allowable size this function does not alter
the database.
\param delm An already allocated and initialized data element to be added
*/
@@ -153,15 +153,15 @@ void DBStore::addItem(DataElem *delem)
{
addItemInternal(delem);
}
void DBStore::addItemInternal(DataElem *delem)
{
- /* if already full, don't over fill, do a qWarning though */
+ /* if already full, don't over fill, do a owarn though */
if (full) {
- owarn << "Attempted to add items to already full table" << oendl;
+ owarn << "Attempted to add items to already full table" << oendl;
return;
}
master_table.insert(number_elems, delem);
current_elem = number_elems;
@@ -182,43 +182,43 @@ void DBStore::addItemInternal(DataElem *delem)
}
}
void DBStore::removeItem(DataElem *r)
{
int position = master_table.findRef(r);
- if(position != -1) {
- /* there is at least one item, this is it */
- /* replace this with the last element, decrease the element count */
- master_table.insert(position, master_table.at(--number_elems));
- master_table.remove(number_elems);
- delete r;
- }
+ if(position != -1) {
+ /* there is at least one item, this is it */
+ /* replace this with the last element, decrease the element count */
+ master_table.insert(position, master_table.at(--number_elems));
+ master_table.remove(number_elems);
+ delete r;
+ }
}
/*!
Sets the name of the database
\param n A string representing the new name of the database.
*/
void DBStore::setName(const QString &n)
{
- name = n;
+ name = n;
}
/*!
Gets the name of the database
\return A string representing the name of the database.
*/
QString DBStore::getName()
{
- return name;
+ return name;
}
/*!
- Retrieves a pointer to the key representation of the database for
+ Retrieves a pointer to the key representation of the database for
other classes to use as reference.
\return a pointer to the databases key representaion
*/
KeyList *DBStore::getKeys()
{
@@ -232,21 +232,21 @@ KeyList *DBStore::getKeys()
void DBStore::setKeys(KeyList *k)
{
kRep = k;
}
/*!
- Sets the current element to the first element of the database
+ Sets the current element to the first element of the database
*/
void DBStore::first()
{
current_elem = 0;
}
/*!
- Sets the current element to the last element of the database
+ Sets the current element to the last element of the database
*/
void DBStore::last()
{
current_elem = number_elems - 1;
}
@@ -254,13 +254,13 @@ void DBStore::last()
Sets the current element to the next element of the database if
there exists an element after the current one.
*/
bool DBStore::next()
{
unsigned int new_current_elem = current_elem + 1;
- if (current_elem < number_elems)
+ if (current_elem < number_elems)
/* was valid before inc (it is possible but unlikely that inc current
elem will change it from invalid to valid) */
if (new_current_elem < number_elems) {
/* is valid after inc */
current_elem = new_current_elem;
return true;
@@ -275,27 +275,27 @@ bool DBStore::next()
bool DBStore::previous()
{
unsigned int new_current_elem = current_elem -1;
if (current_elem < number_elems)
/* was valid */
if (new_current_elem < number_elems) {
- /* still is (if was 0, then now -1, but as is unsigned will wrap
+ /* still is (if was 0, then now -1, but as is unsigned will wrap
and hence be invalid */
current_elem = new_current_elem;
return true;
}
return false;
}
/*!
Returns the current data element in the database. Which element is current
- is affected by newly added items, findItem, next, previous, first and
+ is affected by newly added items, findItem, next, previous, first and
last functions
\return a pointer to the current data element
*/
-DataElem *DBStore::getCurrentData()
+DataElem *DBStore::getCurrentData()
{
- if (current_elem >= number_elems)
+ if (current_elem >= number_elems)
return NULL;
return master_table[current_elem];
}