diff options
Diffstat (limited to 'src/notes.cpp')
-rw-r--r-- | src/notes.cpp | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/src/notes.cpp b/src/notes.cpp index 0c53883..4030f8f 100644 --- a/src/notes.cpp +++ b/src/notes.cpp @@ -16,11 +16,11 @@ ***************************************************************************/ #include "notes.h" -#include <qstringlist.h> -#include <qfile.h> -#include <qdatetime.h> -#include <qtextstream.h> -#include <qtextcodec.h> +#include <tqstringlist.h> +#include <tqfile.h> +#include <tqdatetime.h> +#include <tqtextstream.h> +#include <tqtextcodec.h> #include <klocale.h> #include <klistview.h> #include <kglobal.h> @@ -37,7 +37,7 @@ #endif -void TNoteLink::save(QTextStream& ts) const +void TNoteLink::save(TQTextStream& ts) const { if (!link.isEmpty()) { ts << "\\Link " << link << "\n"; @@ -46,16 +46,16 @@ void TNoteLink::save(QTextStream& ts) const } } -QString TNoteLink::text(int fmt) const +TQString TNoteLink::text(int fmt) const { if (fmt == LinkOnly || description.isEmpty()) return link; else if (fmt == DescriptionOnly) return description; else if (fmt == LinkDescription) - return QString("%1 (%2)").arg(link).arg(description); - else return QString("%1 (%2)").arg(description).arg(link); + return TQString("%1 (%2)").tqarg(link).tqarg(description); + else return TQString("%1 (%2)").tqarg(description).tqarg(link); } -QPixmap TNoteLink::icon() const +TQPixmap TNoteLink::icon() const { return KGlobal::iconLoader()->loadIcon(KMimeType::iconForURL(KURL(link)), KIcon::Small); @@ -98,40 +98,40 @@ TNotesCollection::TNotesCollection() TNotesCollection::~TNotesCollection() {} -void TNotesCollection::addNote(QListViewItem* item) +void TNotesCollection::addNote(TQListViewItem* item) { insert(item, new TNote(item, this)); - QListViewItem* parent = item->parent(); - if (parent) find(parent)->updateView(); + TQListViewItem* tqparent = item->tqparent(); + if (tqparent) tqfind(tqparent)->updateView(); modified = true; } -void TNotesCollection::addNote(QListViewItem* item, const QString& s) +void TNotesCollection::addNote(TQListViewItem* item, const TQString& s) { insert(item, new TNote(item, this, s)); - QListViewItem* parent = item->parent(); - if (parent) find(parent)->updateView(); + TQListViewItem* tqparent = item->tqparent(); + if (tqparent) tqfind(tqparent)->updateView(); modified = true; } -void TNotesCollection::removeNote(QListViewItem* item) +void TNotesCollection::removeNote(TQListViewItem* item) { - TNote* note = find(item); + TNote* note = tqfind(item); if (!note) qWarning("Internal error while removing note\n"); else { - QListViewItem* parent = item->parent(); - for (QListViewItemIterator it(item); it.current() && + TQListViewItem* tqparent = item->tqparent(); + for (TQListViewItemIterator it(item); it.current() && (it.current() == item || it.current()->depth() > item->depth()); ++it) - find(it.current())->destroy(); + tqfind(it.current())->destroy(); delete item; - if (parent) find(parent)->updateView(); + if (tqparent) tqfind(tqparent)->updateView(); modified = true; } } -bool TNotesCollection::changeNote(QListViewItem* item, const QString& s) +bool TNotesCollection::changeNote(TQListViewItem* item, const TQString& s) { - TNote* changed = find(item); + TNote* changed = tqfind(item); if (!changed) { qWarning("Internal error while changing note\n"); return false; @@ -149,9 +149,9 @@ void TNotesCollection::clearNotes() setAutoDelete(false); } -const QString& TNotesCollection::text(QListViewItem* item) +const TQString& TNotesCollection::text(TQListViewItem* item) { - TNote* note = find(item); + TNote* note = tqfind(item); if (!note) qFatal("Internal error while accessing note text\n"); return note->text; @@ -159,7 +159,7 @@ const QString& TNotesCollection::text(QListViewItem* item) void TNotesCollection::updateNotesView() { - for (QPtrDictIterator<TNote> it(*this); it.current(); ++it) + for (TQPtrDictIterator<TNote> it(*this); it.current(); ++it) it.current()->updateView(); } @@ -167,14 +167,14 @@ void TNotesCollection::updateNotesView() -TNote::TNote(QListViewItem* i, TNotesCollection* coll) : text() +TNote::TNote(TQListViewItem* i, TNotesCollection* coll) : text() { collection = coll; item = i; updateView(); } -TNote::TNote(QListViewItem* i, TNotesCollection* coll, const QString& s) : +TNote::TNote(TQListViewItem* i, TNotesCollection* coll, const TQString& s) : text(s) { collection = coll; @@ -187,9 +187,9 @@ bool TNote::isEmpty() return !text.length(); } -bool TNote::contains(const QString& sought, bool case_sensitive) +bool TNote::tqcontains(const TQString& sought, bool case_sensitive) { - return text.contains(sought, case_sensitive); + return text.tqcontains(sought, case_sensitive); } @@ -203,7 +203,7 @@ void TNote::destroy() delete this; } -bool TNote::change(const QString& s) +bool TNote::change(const TQString& s) { if (text == s) return false; @@ -226,27 +226,27 @@ void TNote::updateView() item->setPixmap(0, collection->Pixmaps[state()]); } -bool TNote::saveHTML(const KURL& fname, const QString& origname, const QString& style, +bool TNote::saveHTML(const KURL& fname, const TQString& origname, const TQString& style, int flags) { - QFile file(fname.path()); + TQFile file(fname.path()); if (!file.open( IO_WriteOnly)) return false; - QTextStream ts(&file); - if (flags & UseUTF8) ts.setEncoding(QTextStream::UnicodeUTF8); - else ts.setEncoding(QTextStream::Locale); + TQTextStream ts(&file); + if (flags & UseUTF8) ts.setEncoding(TQTextStream::UnicodeUTF8); + else ts.setEncoding(TQTextStream::Locale); ts << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n" "<html>\n<head>\n <title>" << i18n("KnowIt document") << - QString("</title>\n <meta http-equiv=\"Content-Type\" " - "content=\"text/html; charset=%1\">\n").arg(ts.codec()->mimeName()); + TQString("</title>\n <meta http-equiv=\"Content-Type\" " + "content=\"text/html; charset=%1\">\n").tqarg(ts.codec()->mimeName()); if (!style.isEmpty()) ts << " <style type=\"text/css\">\n " << style << "\n </style>\n"; ts << "</head>\n\n<body>\n"; - QValueVector<int> Depths; + TQValueVector<int> Depths; Depths.append(0); if (flags & TOC) { - ts << QString("<h1>%1</h1>\n").arg(i18n("Table of contents")); + ts << TQString("<h1>%1</h1>\n").tqarg(i18n("Table of contents")); saveHTMLTocEntry(ts, Depths, flags); ts << "\n\n"; } @@ -255,62 +255,62 @@ bool TNote::saveHTML(const KURL& fname, const QString& origname, const QString& Depths.append(0); saveHTMLBuf(ts, Depths, flags); - QString epilog = i18n("Exported from %1 by KnowIt %2, %3."); - ts << "<br><br><br><small>" << epilog.arg(origname) - .arg(VERSION) - .arg(QDateTime::currentDateTime().toString()) << "</small>\n\n"; + TQString epilog = i18n("Exported from %1 by KnowIt %2, %3."); + ts << "<br><br><br><small>" << epilog.tqarg(origname) + .tqarg(VERSION) + .tqarg(TQDateTime::tqcurrentDateTime().toString()) << "</small>\n\n"; ts << "</body>\n</html>\n\n"; return true; } -bool TNote::saveHTMLBuf(QTextStream& ts, QValueVector<int>& depths, +bool TNote::saveHTMLBuf(TQTextStream& ts, TQValueVector<int>& depths, int flags) { int hlevel = depths.count(); depths.last() = depths.last()+1; if (hlevel < 1) hlevel = 1; else if (hlevel > 3) hlevel = 3; - QString id, number; + TQString id, number; for (uint i=0; i<depths.count(); i++) - id += QString("%1.").arg(depths[i]); + id += TQString("%1.").tqarg(depths[i]); if (flags & Enumerate) number = id + " "; - ts << QString("<h%1 id=\"S%2\">%3%4</h%5>").arg(hlevel).arg(id).arg(number) - .arg(item->text(0)).arg(hlevel); - QString htmltext = text; - int begin = htmltext.find("<body"); - if (begin >= 0) begin = htmltext.find(">", begin); - int end = htmltext.find("</body>"); + ts << TQString("<h%1 id=\"S%2\">%3%4</h%5>").tqarg(hlevel).tqarg(id).tqarg(number) + .tqarg(item->text(0)).tqarg(hlevel); + TQString htmltext = text; + int begin = htmltext.tqfind("<body"); + if (begin >= 0) begin = htmltext.tqfind(">", begin); + int end = htmltext.tqfind("</body>"); if (begin < 0) begin = 0; if (end <= begin) end = htmltext.length(); ts << htmltext.mid(begin+1, end-begin-1); /* save links */ - for (QValueList<TNoteLink>::Iterator LinkList = links.begin(); + for (TQValueList<TNoteLink>::Iterator LinkList = links.begin(); LinkList != links.end(); ++LinkList) - ts << QString("<a href=\"%1\">%2</a><br>\n").arg((*LinkList).link) - .arg((*LinkList).text(TNoteLink::DescriptionOnly)); + ts << TQString("<a href=\"%1\">%2</a><br>\n").tqarg((*LinkList).link) + .tqarg((*LinkList).text(TNoteLink::DescriptionOnly)); /* save rule */ if (flags & AddRule) ts << "<hr size=\"1\" noshade>\n\n"; else ts << "\n\n"; - /* save children */ + /* save tqchildren */ if ((SaveSubnotes | SaveAll) & flags && item->childCount()) { depths.append(0); - collection->find(item->firstChild())->saveHTMLBuf(ts, depths, flags); + collection->tqfind(item->firstChild())->saveHTMLBuf(ts, depths, flags); } if ((SaveSubnotes | SaveAll) & flags && item->nextSibling()) - collection->find(item->nextSibling())->saveHTMLBuf(ts, depths, flags); + collection->tqfind(item->nextSibling())->saveHTMLBuf(ts, depths, flags); if (!item->nextSibling()) depths.pop_back(); return true; } -bool TNote::saveHTMLTocEntry(QTextStream& ts, QValueVector<int>& depths, int flags) +bool TNote::saveHTMLTocEntry(TQTextStream& ts, TQValueVector<int>& depths, int flags) { - QString space; + TQString space; space.fill(' ', depths.count()); depths.last() = depths.last()+1; if (depths.last() == 1) { @@ -319,20 +319,20 @@ bool TNote::saveHTMLTocEntry(QTextStream& ts, QValueVector<int>& depths, int fla ts << "<dl>\n"; } - QString id, number; + TQString id, number; for (uint i=0; i<depths.count(); i++) - id += QString("%1.").arg(depths[i]); + id += TQString("%1.").tqarg(depths[i]); if (flags & Enumerate) number = id + " "; ts << space; - ts << QString("<dt><a href=\"#S%1\">%2%3</a></dt>\n").arg(id).arg(number). + ts << TQString("<dt><a href=\"#S%1\">%2%3</a></dt>\n").tqarg(id).tqarg(number). arg(item->text(0)); if ((SaveSubnotes | SaveAll) & flags && item->childCount()) { depths.append(0); - collection->find(item->firstChild())->saveHTMLTocEntry(ts, depths, flags); + collection->tqfind(item->firstChild())->saveHTMLTocEntry(ts, depths, flags); } if ((SaveSubnotes | SaveAll) & flags && item->nextSibling()) - collection->find(item->nextSibling())->saveHTMLTocEntry(ts, depths, flags); + collection->tqfind(item->nextSibling())->saveHTMLTocEntry(ts, depths, flags); if (!item->nextSibling()) { depths.pop_back(); ts << space; @@ -343,7 +343,7 @@ bool TNote::saveHTMLTocEntry(QTextStream& ts, QValueVector<int>& depths, int fla return true; } -void TNote::addLink(const QString& s) +void TNote::addLink(const TQString& s) { links.append(TNoteLink(s)); collection->modified = true; @@ -361,7 +361,7 @@ void TNote::removeLink(int i) collection->modified = true; } -void TNote::modifyLink(int i, const QString& s) +void TNote::modifyLink(int i, const TQString& s) { links[i].link = s; collection->modified = true; @@ -374,7 +374,7 @@ void TNote::modifyLink(int i, TNoteLink& l) links[i] = l; } -void TNote::modifyLinkDescription(int i, const QString& s) +void TNote::modifyLinkDescription(int i, const TQString& s) { links[i].description = s; collection->modified = true; @@ -391,16 +391,16 @@ const TNoteLink& TNote::link(int i) const } -void TNote::save(QTextStream& ts, bool current) +void TNote::save(TQTextStream& ts, bool current) { - const QString header = "\\NewEntry %1 %2\n"; - const QString activeheader = "\\CurrentEntry %1 %2\n"; + const TQString header = "\\NewEntry %1 %2\n"; + const TQString activeheader = "\\CurrentEntry %1 %2\n"; if (current) - ts << activeheader.arg(item->depth()).arg(item->text(0)); + ts << activeheader.tqarg(item->depth()).tqarg(item->text(0)); else - ts << header.arg(item->depth()).arg(item->text(0)); - for (QValueList<TNoteLink>::Iterator LinkList = links.begin(); + ts << header.tqarg(item->depth()).tqarg(item->text(0)); + for (TQValueList<TNoteLink>::Iterator LinkList = links.begin(); LinkList != links.end(); ++LinkList) (*LinkList).save(ts); ts << text; @@ -409,9 +409,9 @@ void TNote::save(QTextStream& ts, bool current) ts << '\n'; } -void TNote::open(QTextStream& ts) +void TNote::open(TQTextStream& ts) { - QString s; + TQString s; text = ""; links.clear(); |