summaryrefslogtreecommitdiffstats
path: root/kpilot/conduits/memofileconduit/memofiles.cc
diff options
context:
space:
mode:
Diffstat (limited to 'kpilot/conduits/memofileconduit/memofiles.cc')
-rw-r--r--kpilot/conduits/memofileconduit/memofiles.cc114
1 files changed, 57 insertions, 57 deletions
diff --git a/kpilot/conduits/memofileconduit/memofiles.cc b/kpilot/conduits/memofileconduit/memofiles.cc
index 2846d448b..db3d8cacc 100644
--- a/kpilot/conduits/memofileconduit/memofiles.cc
+++ b/kpilot/conduits/memofileconduit/memofiles.cc
@@ -30,17 +30,17 @@
#include "memofiles.h"
#include "memofile.h"
-QString Memofiles::FIELD_SEP = CSL1("\t");
+TQString Memofiles::FIELD_SEP = CSL1("\t");
Memofiles::Memofiles (MemoCategoryMap & categories, PilotMemoInfo &appInfo,
- QString & baseDirectory, CUDCounter &fCtrPC) :
+ TQString & baseDirectory, CUDCounter &fCtrPC) :
_categories(categories), _memoAppInfo(appInfo),
_baseDirectory(baseDirectory), _cudCounter(fCtrPC)
{
FUNCTIONSETUP;
_memofiles.clear();
- _memoMetadataFile = _baseDirectory + QDir::separator() + CSL1(".ids");
- _categoryMetadataFile = _baseDirectory + QDir::separator() + CSL1(".categories");
+ _memoMetadataFile = _baseDirectory + TQDir::separator() + CSL1(".ids");
+ _categoryMetadataFile = _baseDirectory + TQDir::separator() + CSL1(".categories");
_memofiles.setAutoDelete(true);
_ready = ensureDirectoryReady();
@@ -67,10 +67,10 @@ void Memofiles::load (bool loadAll)
for ( it = _categories.begin(); it != _categories.end(); ++it ) {
int category = it.key();
- QString categoryName = it.data();
- QString categoryDirname = _baseDirectory + QDir::separator() + categoryName;
+ TQString categoryName = it.data();
+ TQString categoryDirname = _baseDirectory + TQDir::separator() + categoryName;
- QDir dir = QDir(categoryDirname);
+ TQDir dir = TQDir(categoryDirname);
if (! dir.exists() ) {
DEBUGKPILOT << fname
<< ": category directory: [" << categoryDirname
@@ -79,11 +79,11 @@ void Memofiles::load (bool loadAll)
}
- QStringList entries = dir.entryList(QDir::Files);
- QString file;
- for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
+ TQStringList entries = dir.entryList(TQDir::Files);
+ TQString file;
+ for(TQStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
file = *it;
- QFileInfo info(dir, file);
+ TQFileInfo info(dir, file);
if(info.isFile() && info.isReadable()) {
// DEBUGKPILOT << fname
@@ -151,13 +151,13 @@ bool Memofiles::ensureDirectoryReady()
int failures = 0;
// now make sure that a directory for each category exists.
- QString _category_name;
- QString dir;
+ TQString _category_name;
+ TQString dir;
MemoCategoryMap::Iterator it;
for ( it = _categories.begin(); it != _categories.end(); ++it ) {
_category_name = it.data();
- dir = _baseDirectory + QDir::separator() + _category_name;
+ dir = _baseDirectory + TQDir::separator() + _category_name;
DEBUGKPILOT << fname
<< ": checking directory: [" << dir << "]" << endl;
@@ -169,12 +169,12 @@ bool Memofiles::ensureDirectoryReady()
return failures == 0;
}
-bool Memofiles::checkDirectory(QString & dir)
+bool Memofiles::checkDirectory(TQString & dir)
{
FUNCTIONSETUP;
// make sure that the directory we're asked to write to exists
- QDir d(dir);
- QFileInfo fid( dir );
+ TQDir d(dir);
+ TQFileInfo fid( dir );
if ( ! fid.isDir() ) {
@@ -212,15 +212,15 @@ void Memofiles::eraseLocalMemos ()
MemoCategoryMap::Iterator it;
for ( it = _categories.begin(); it != _categories.end(); ++it ) {
- QString dir = _baseDirectory + QDir::separator() + it.data();
+ TQString dir = _baseDirectory + TQDir::separator() + it.data();
- if (!folderRemove(QDir(dir))) {
+ if (!folderRemove(TQDir(dir))) {
DEBUGKPILOT << fname
<< ": couldn't erase all local memos from: ["
<< dir << "]." << endl;
}
}
- QDir d(_baseDirectory);
+ TQDir d(_baseDirectory);
d.remove(_memoMetadataFile);
ensureDirectoryReady();
@@ -228,7 +228,7 @@ void Memofiles::eraseLocalMemos ()
_memofiles.clear();
}
-void Memofiles::setPilotMemos (QPtrList<PilotMemo> & memos)
+void Memofiles::setPilotMemos (TQPtrList<PilotMemo> & memos)
{
FUNCTIONSETUP;
@@ -252,7 +252,7 @@ bool Memofiles::loadFromMetadata ()
_memofiles.clear();
- QFile f( _memoMetadataFile );
+ TQFile f( _memoMetadataFile );
if ( !f.open( IO_ReadOnly ) ) {
DEBUGKPILOT << fname
<< ": ooh, bad. couldn't open your memo-id file for reading."
@@ -260,15 +260,15 @@ bool Memofiles::loadFromMetadata ()
return false;
}
- QTextStream t( &f );
+ TQTextStream t( &f );
Memofile * memofile;
while ( !t.atEnd() ) {
- QString data = t.readLine();
+ TQString data = t.readLine();
int errors = 0;
bool ok;
- QStringList fields = QStringList::split( FIELD_SEP, data );
+ TQStringList fields = TQStringList::split( FIELD_SEP, data );
if ( fields.count() >= 4 ) {
int id = fields[0].toInt( &ok );
if ( !ok )
@@ -282,7 +282,7 @@ bool Memofiles::loadFromMetadata ()
uint size = fields[3].toInt( &ok );
if ( !ok )
errors++;
- QString filename = fields[4];
+ TQString filename = fields[4];
if ( filename.isEmpty() )
errors++;
@@ -331,7 +331,7 @@ Memofile * Memofiles::find (recordid_t id)
}
-Memofile * Memofiles::find (const QString & category, const QString & filename)
+Memofile * Memofiles::find (const TQString & category, const TQString & filename)
{
Memofile * memofile;
@@ -371,8 +371,8 @@ void Memofiles::addModifiedMemo (PilotMemo * memo)
return;
}
- QString debug = CSL1(": adding a PilotMemo. id: [")
- + QString::number(memo->id()) + CSL1("], title: [")
+ TQString debug = CSL1(": adding a PilotMemo. id: [")
+ + TQString::number(memo->id()) + CSL1("], title: [")
+ memo->getTitle() + CSL1("]. ");
Memofile * memofile = find(memo->id());
@@ -400,11 +400,11 @@ void Memofiles::addModifiedMemo (PilotMemo * memo)
}
-QPtrList<Memofile> Memofiles::getModified ()
+TQPtrList<Memofile> Memofiles::getModified ()
{
FUNCTIONSETUP;
- QPtrList<Memofile> modList;
+ TQPtrList<Memofile> modList;
modList.clear();
Memofile * memofile;
@@ -441,8 +441,8 @@ bool Memofiles::saveMemoMetadata()
<< ": saving memo metadata to file: ["
<< _memoMetadataFile << "]" << endl;
- QFile f( _memoMetadataFile );
- QTextStream stream(&f);
+ TQFile f( _memoMetadataFile );
+ TQTextStream stream(&f);
if( !f.open(IO_WriteOnly) ) {
DEBUGKPILOT << fname
@@ -484,8 +484,8 @@ MemoCategoryMap Memofiles::readCategoryMetadata()
MemoCategoryMap map;
map.clear();
- QFile f( _categoryMetadataFile );
- QTextStream stream(&f);
+ TQFile f( _categoryMetadataFile );
+ TQTextStream stream(&f);
if( !f.open(IO_ReadOnly) ) {
DEBUGKPILOT << fname
@@ -496,16 +496,16 @@ MemoCategoryMap Memofiles::readCategoryMetadata()
while ( !stream.atEnd() ) {
- QString data = stream.readLine();
+ TQString data = stream.readLine();
int errors = 0;
bool ok;
- QStringList fields = QStringList::split( FIELD_SEP, data );
+ TQStringList fields = TQStringList::split( FIELD_SEP, data );
if ( fields.count() >= 2 ) {
int id = fields[0].toInt( &ok );
if ( !ok )
errors++;
- QString categoryName = fields[1];
+ TQString categoryName = fields[1];
if ( categoryName.isEmpty() )
errors++;
@@ -541,8 +541,8 @@ bool Memofiles::saveCategoryMetadata()
<< ": saving categories to file: ["
<< _categoryMetadataFile << "]" << endl;
- QFile f( _categoryMetadataFile );
- QTextStream stream(&f);
+ TQFile f( _categoryMetadataFile );
+ TQTextStream stream(&f);
if( !f.open(IO_WriteOnly) ) {
DEBUGKPILOT << fname
@@ -601,8 +601,8 @@ bool Memofiles::saveMemos()
bool Memofiles::isFirstSync()
{
FUNCTIONSETUP;
- bool metadataExists = QFile::exists(_memoMetadataFile) &&
- QFile::exists(_categoryMetadataFile);
+ bool metadataExists = TQFile::exists(_memoMetadataFile) &&
+ TQFile::exists(_categoryMetadataFile);
bool valid = metadataExists && _metadataLoaded;
@@ -615,19 +615,19 @@ bool Memofiles::isFirstSync()
-bool Memofiles::folderRemove(const QDir &_d)
+bool Memofiles::folderRemove(const TQDir &_d)
{
FUNCTIONSETUP;
- QDir d = _d;
+ TQDir d = _d;
- QStringList entries = d.entryList();
- for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
+ TQStringList entries = d.entryList();
+ for(TQStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
if(*it == CSL1(".") || *it == CSL1(".."))
continue;
- QFileInfo info(d, *it);
+ TQFileInfo info(d, *it);
if(info.isDir()) {
- if(!folderRemove(QDir(info.filePath())))
+ if(!folderRemove(TQDir(info.filePath())))
return FALSE;
} else {
DEBUGKPILOT << fname
@@ -635,7 +635,7 @@ bool Memofiles::folderRemove(const QDir &_d)
d.remove(info.filePath());
}
}
- QString name = d.dirName();
+ TQString name = d.dirName();
if(!d.cdUp())
return FALSE;
DEBUGKPILOT << fname
@@ -645,14 +645,14 @@ bool Memofiles::folderRemove(const QDir &_d)
return TRUE;
}
-QString Memofiles::filename(PilotMemo * memo)
+TQString Memofiles::filename(PilotMemo * memo)
{
FUNCTIONSETUP;
- QString filename = memo->getTitle();
+ TQString filename = memo->getTitle();
if (filename.isEmpty()) {
- QString text = memo->text();
+ TQString text = memo->text();
int i = text.find(CSL1("\n"));
if (i > 1) {
filename = text.left(i);
@@ -664,7 +664,7 @@ QString Memofiles::filename(PilotMemo * memo)
filename = sanitizeName(filename);
- QString category = _categories[memo->category()];
+ TQString category = _categories[memo->category()];
Memofile * memofile = find(category, filename);
@@ -676,22 +676,22 @@ QString Memofiles::filename(PilotMemo * memo)
}
int uniq = 2;
- QString newfilename;
+ TQString newfilename;
// try to find a good filename, but only do this 20 times at the most.
// if our user has 20 memos with the same filename, he/she is asking
// for trouble.
while (NULL != memofile && uniq <=20) {
- newfilename = QString(filename + CSL1(".") + QString::number(uniq++) );
+ newfilename = TQString(filename + CSL1(".") + TQString::number(uniq++) );
memofile = find(category, newfilename);
}
return newfilename;
}
-QString Memofiles::sanitizeName(QString name)
+TQString Memofiles::sanitizeName(TQString name)
{
- QString clean = name;
+ TQString clean = name;
// safety net. we can't save a
// filesystem separator as part of a filename, now can we?
clean.replace('/', CSL1("-"));