Browse Source

TQt4 port knowit

This enables compilation under both Qt3 and Qt4


git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/knowit@1238876 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
tags/v3.5.13
tpearson 9 years ago
parent
commit
e86f8310a9
20 changed files with 728 additions and 720 deletions
  1. +340
    -340
      src/knowit.cpp
  2. +27
    -26
      src/knowit.h
  3. +1
    -1
      src/knowitapp.cpp
  4. +4
    -3
      src/knowitapp.h
  5. +17
    -17
      src/knowitchooser.cpp
  6. +6
    -5
      src/knowitchooser.h
  7. +15
    -15
      src/knowitedit.cpp
  8. +8
    -7
      src/knowitedit.h
  9. +20
    -20
      src/knowitlink.cpp
  10. +3
    -2
      src/knowitlink.h
  11. +10
    -10
      src/knowitlinks.cpp
  12. +9
    -8
      src/knowitlinks.h
  13. +101
    -101
      src/knowitpref.cpp
  14. +21
    -20
      src/knowitpref.h
  15. +5
    -5
      src/knowittray.cpp
  16. +1
    -1
      src/knowittray.h
  17. +19
    -19
      src/knowittree.cpp
  18. +7
    -6
      src/knowittree.h
  19. +78
    -78
      src/notes.cpp
  20. +36
    -36
      src/notes.h

+ 340
- 340
src/knowit.cpp
File diff suppressed because it is too large
View File


+ 27
- 26
src/knowit.h View File

@@ -22,7 +22,7 @@
#include <config.h>
#endif

#include <qurloperator.h>
#include <tqurloperator.h>

#include <keditcl.h>
#include <klocale.h>
@@ -34,8 +34,8 @@
#include "knowitlink.h"
#include "notes.h"

class QSplitter;
class QTimer;
class TQSplitter;
class TQTimer;
class KAction;
class KConfig;
class KListBox;
@@ -51,15 +51,16 @@ class KnowitTree;
class Knowit : public KMainWindow
{
Q_OBJECT
TQ_OBJECT
private:
static const QString Untitled;
static const TQString Untitled;
KConfig *config;
QSplitter* Layout;
TQSplitter* Layout;
KnowitTree* Items;
KListBox* Links;
KnowitEdit* Edit;
KURL filename;
QPixmap pixmapFolder, pixmapFolderText, pixmapText, pixmapEmpty;
TQPixmap pixmapFolder, pixmapFolderText, pixmapText, pixmapEmpty;
KEdFind FindDlg;
KnowitOptions Options;
KnowitPreferences PrefDlg;
@@ -69,11 +70,11 @@ class Knowit : public KMainWindow
/* data items */
TNotesCollection Notes;
bool runMinimized;
QListViewItem* lastSought;
QString soughtText;
QTimer* AutosaveTimer;
TQListViewItem* lastSought;
TQString soughtText;
TQTimer* AutosaveTimer;
/* for saving backups */
QUrlOperator URLOperator;
TQUrlOperator URLOperator;
/* false by default, set to true on queryClose() */
bool shuttingDown;
/* actions */
@@ -87,7 +88,7 @@ class Knowit : public KMainWindow
enum {StatusText = 1, StatusOvr = 2};
public:
/** Constructor of main window */
Knowit(QWidget* parent=0, const char *name=0);
Knowit(TQWidget* tqparent=0, const char *name=0);
/** Standard destructor */
~Knowit();
/** Opens document */
@@ -108,23 +109,23 @@ class Knowit : public KMainWindow

/** Finds and shows next occurence of currently sought text
- or show message that it couldn't be found */
void find(QListViewItem* start = 0);
void tqfind(TQListViewItem* start = 0);
/** Returns true if notes or current text were modified */
bool modified();
/** Reimplemented from QWidget to prevent from closing when docked */
virtual void closeEvent(QCloseEvent* e);
/** Reimplemented from TQWidget to prevent from closing when docked */
virtual void closeEvent(TQCloseEvent* e);
/** Apply current configuration */
void applyOptions(const KnowitOptions& O, bool store = true);
/** Returns current note */
TNote* currentNote() const;

public slots:
/** Status bar text has changed - displays it */
void slotStatusMsg(const QString& text);
/** tqStatus bar text has changed - displays it */
void slotStatusMsg(const TQString& text);
/** Shows requested popup menu for notes */
void slotContextMenu(KListView*, QListViewItem*, const QPoint&);
void slotContextMenu(KListView*, TQListViewItem*, const TQPoint&);
/** Shows given note */
void slotNoteChanged(QListViewItem* item);
void slotNoteChanged(TQListViewItem* item);
/** Add same-level note */
void slotNoteAdd();
/** Adds subnote */
@@ -150,7 +151,7 @@ class Knowit : public KMainWindow
void slotNoteMoveRight();

/** Current item has changed - updates associated text and shows next */
void slotItemChanged(QListViewItem*);
void slotItemChanged(TQListViewItem*);
/** Resets to a new file */
void slotFileNew();
/** Prompts for a file to open and opens it */
@@ -179,11 +180,11 @@ class Knowit : public KMainWindow
void slotEditUnderline();
/** Changes color of selected/current text */
void slotEditColor();
/** Changes vertical alignment to superscript */
/** Changes vertical tqalignment to superscript */
void slotEditSuperscript();
/** Changes vertical alignment to subscript */
/** Changes vertical tqalignment to subscript */
void slotEditSubscript();
/** Restores normal vertical alignment */
/** Restores normal vertical tqalignment */
void slotEditNormal();
/** Prompts for text and shows note containing it */
void slotEditFind();
@@ -199,7 +200,7 @@ class Knowit : public KMainWindow
void slotEditAlignJustify();
/** Centers text */
void slotEditAlignCenter();
/** Change selected paragraphs to list. Warning: uses obsolete Qt function */
/** Change selected paragraphs to list. Warning: uses obsolete TQt function */
void slotEditListBullet();
void slotEditListNumber();
void slotEditListUpper();
@@ -235,13 +236,13 @@ class Knowit : public KMainWindow
void slotRawTextMode();
/** Shows requested popup menu for links */
void slotContextLinksMenu(QListBoxItem* item, const QPoint&);
void slotContextLinksMenu(TQListBoxItem* item, const TQPoint&);
/** show current attachment **/
void slotShowAttachment(QListBoxItem* i);
void slotShowAttachment(TQListBoxItem* i);
/** Add link **/
void slotLinkAdd();
/** Handle dropped link **/
void slotLinkDropped(const QString& s, int flags);
void slotLinkDropped(const TQString& s, int flags);
/** Remove link **/
void slotLinkRemove();
/** Open link **/


+ 1
- 1
src/knowitapp.cpp View File

@@ -26,7 +26,7 @@ KnowitApplication::~KnowitApplication()
{
}

void KnowitApplication::commitData(QSessionManager& sm)
void KnowitApplication::commitData(TQSessionManager& sm)
{
mcloseByLogout = true;
KUniqueApplication::commitData(sm);


+ 4
- 3
src/knowitapp.h View File

@@ -22,18 +22,19 @@
class KnowitApplication : public KUniqueApplication
{
Q_OBJECT
TQ_OBJECT

public:
KnowitApplication(bool allowStyles = true, bool GUIEnabled = true);
~KnowitApplication();
/** Commits all Application-relevant data on shutdown.
*
* This function is called when the QSessionManager wants to close the
* This function is called when the TQSessionManager wants to close the
* Application. It is reimplemented to set the boolean sessionClose flag.
*
* @param sm The QSessionManager object.
* @param sm The TQSessionManager object.
*/
virtual void commitData(QSessionManager& sm);
virtual void commitData(TQSessionManager& sm);
/** Returns TRUE if the Application is closed by the session manager. */
bool closeByLogout() {return(mcloseByLogout);}



+ 17
- 17
src/knowitchooser.cpp View File

@@ -17,10 +17,10 @@

#include "knowitchooser.h"

#include <qcheckbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qvbox.h>
#include <tqcheckbox.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqvbox.h>

#include <kcombobox.h>
#include <klocale.h>
@@ -29,30 +29,30 @@
KnowitChooser::KnowitChooser(int flags)
: KDialogBase(Plain, i18n("Export"), Ok|Cancel, Ok)
{
QLabel* l1;
QLabel* l2;
QVBoxLayout* layout = new QVBoxLayout(plainPage());
layout->addWidget(l1 = new QLabel(i18n("&Exported notes:"), plainPage()));
layout->addWidget(notes = new KComboBox(plainPage(), "Notes"));
TQLabel* l1;
TQLabel* l2;
TQVBoxLayout* tqlayout = new TQVBoxLayout(plainPage());
tqlayout->addWidget(l1 = new TQLabel(i18n("&Exported notes:"), plainPage()));
tqlayout->addWidget(notes = new KComboBox(plainPage(), "Notes"));
l1->setBuddy(notes);
notes->insertItem(i18n("All"));
notes->insertItem(i18n("Current with children"));
notes->insertItem(i18n("Current with tqchildren"));
notes->insertItem(i18n("Current only"));
layout->addWidget(l2 = new QLabel(i18n("&Encoding:"), plainPage()));
layout->addWidget(charset = new KComboBox(plainPage(), "Encoding"));
tqlayout->addWidget(l2 = new TQLabel(i18n("&Encoding:"), plainPage()));
tqlayout->addWidget(charset = new KComboBox(plainPage(), "Encoding"));
l2->setBuddy(charset);
charset->insertItem(i18n("Local (8-bit)"));
charset->insertItem(i18n("UTF-8"));

layout->addItem(new QSpacerItem(0, 10));
layout->addWidget(enumerate = new QCheckBox(i18n("Numbered titles"),
tqlayout->addItem(new TQSpacerItem(0, 10));
tqlayout->addWidget(enumerate = new TQCheckBox(i18n("Numbered titles"),
plainPage(), "Numbered"));
layout->addWidget(toc = new QCheckBox(i18n("Table of contents"),
tqlayout->addWidget(toc = new TQCheckBox(i18n("Table of contents"),
plainPage(), "TOC"));
layout->addWidget(rule = new QCheckBox(i18n("Rule betweeen notes"),
tqlayout->addWidget(rule = new TQCheckBox(i18n("Rule betweeen notes"),
plainPage(), "Rule"));
layout->addWidget(style = new QCheckBox(i18n("Use editor font and colors"),
tqlayout->addWidget(style = new TQCheckBox(i18n("Use editor font and colors"),
plainPage(), "Style"));
setChoice(flags);
}


+ 6
- 5
src/knowitchooser.h View File

@@ -20,7 +20,7 @@

#include <kdialogbase.h>

class QCheckBox;
class TQCheckBox;
class KComboBox;

/**
@@ -29,13 +29,14 @@ class KComboBox;

class KnowitChooser : public KDialogBase {
Q_OBJECT
TQ_OBJECT
protected:
KComboBox* notes;
KComboBox* charset;
QCheckBox* enumerate;
QCheckBox* toc;
QCheckBox* rule;
QCheckBox* style;
TQCheckBox* enumerate;
TQCheckBox* toc;
TQCheckBox* rule;
TQCheckBox* style;
public:
enum {SaveCurrent = 0, SaveSubnotes = 0x0001, SaveAll = 0x0002, UseUTF8 = 0x0040,
Enumerate = 0x0080, AddRule = 0x0100, Style = 0x0200, TOC = 0x0400};


+ 15
- 15
src/knowitedit.cpp View File

@@ -18,42 +18,42 @@
#include "knowitedit.h"
#include <kurldrag.h>

KnowitEdit::KnowitEdit(const QString& text, const QString& context, QWidget* parent,
const char* name) : KTextEdit(text, context, parent, name), swapEOL(true)
KnowitEdit::KnowitEdit(const TQString& text, const TQString& context, TQWidget* tqparent,
const char* name) : KTextEdit(text, context, tqparent, name), swapEOL(true)
{
setAcceptDrops(true);
}

KnowitEdit::KnowitEdit(QWidget* parent, const char* name) : KTextEdit(parent, name),
KnowitEdit::KnowitEdit(TQWidget* tqparent, const char* name) : KTextEdit(tqparent, name),
swapEOL(true)
{

}

void KnowitEdit::keyPressEvent(QKeyEvent* e)
void KnowitEdit::keyPressEvent(TQKeyEvent* e)
{
if (swapEOL &&
(e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) &&
(e->state() | (Qt::NoButton | Qt::ControlButton | Qt::Keypad) ==
(Qt::NoButton | Qt::ControlButton | Qt::Keypad))) {
QKeyEvent* e1 = new QKeyEvent(QKeyEvent::KeyPress, e->key(),
e->ascii(), e->state() ^ Qt::ControlButton, e->text(), e->isAutoRepeat(),
(e->key() == TQt::Key_Enter || e->key() == TQt::Key_Return) &&
(e->state() | (Qt::NoButton | TQt::ControlButton | TQt::Keypad) ==
(Qt::NoButton | TQt::ControlButton | TQt::Keypad))) {
TQKeyEvent* e1 = new TQKeyEvent(TQKeyEvent::KeyPress, e->key(),
e->ascii(), e->state() ^ TQt::ControlButton, e->text(), e->isAutoRepeat(),
e->count());
e->ignore();
QTextEdit::keyPressEvent(e1);
TQTextEdit::keyPressEvent(e1);
}
else QTextEdit::keyPressEvent(e);
else TQTextEdit::keyPressEvent(e);
}

void KnowitEdit::contentsDragEnterEvent(QDragEnterEvent* event)
void KnowitEdit::contentsDragEnterEvent(TQDragEnterEvent* event)
{
if (KURLDrag::canDecode(event))
event->accept(true);
else QTextEdit::contentsDragEnterEvent(event);
else TQTextEdit::contentsDragEnterEvent(event);
}

void KnowitEdit::contentsDropEvent(QDropEvent* event)
void KnowitEdit::contentsDropEvent(TQDropEvent* event)
{
if (KURLDrag::canDecode(event)) {
KURL::List L;
@@ -61,6 +61,6 @@ void KnowitEdit::contentsDropEvent(QDropEvent* event)
for (uint i=0; i<L.count(); i++)
emit textDropped(L[i].url(), L.count() > 1);
}
else QTextEdit::contentsDropEvent(event);
else TQTextEdit::contentsDropEvent(event);
}


+ 8
- 7
src/knowitedit.h View File

@@ -21,16 +21,17 @@
class KnowitEdit : public KTextEdit
{
Q_OBJECT
TQ_OBJECT
public:
bool swapEOL;
KnowitEdit(const QString& text, const QString& context=QString::null,
QWidget* parent=0, const char* name = 0);
KnowitEdit(QWidget* parent=0, const char* name = 0);
virtual void keyPressEvent(QKeyEvent* e);
virtual void contentsDragEnterEvent(QDragEnterEvent* event);
virtual void contentsDropEvent(QDropEvent* event);
KnowitEdit(const TQString& text, const TQString& context=TQString(),
TQWidget* tqparent=0, const char* name = 0);
KnowitEdit(TQWidget* tqparent=0, const char* name = 0);
virtual void keyPressEvent(TQKeyEvent* e);
virtual void contentsDragEnterEvent(TQDragEnterEvent* event);
virtual void contentsDropEvent(TQDropEvent* event);
signals:
void textDropped(const QString& s, int flags);
void textDropped(const TQString& s, int flags);
};




+ 20
- 20
src/knowitlink.cpp View File

@@ -18,10 +18,10 @@
#include "knowitlink.h"
#include "notes.h"

#include <qtoolbutton.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qvbox.h>
#include <tqtoolbutton.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqvbox.h>

#include <kfiledialog.h>
#include <kglobal.h>
@@ -33,30 +33,30 @@
KnowitLinkDialog::KnowitLinkDialog()
: KDialogBase(Plain, i18n("Modify link"), Ok|Cancel, Ok)
{
QVBoxLayout* layout = new QVBoxLayout(plainPage());
TQVBoxLayout* tqlayout = new TQVBoxLayout(plainPage());

QHBox* typeBox = new QHBox(plainPage());
layout->addWidget(typeBox);
new QLabel(i18n("Referenced item:"), typeBox);
TQHBox* typeBox = new TQHBox(plainPage());
tqlayout->addWidget(typeBox);
new TQLabel(i18n("Referenced item:"), typeBox);
linkType = new KComboBox(typeBox, "LinkType");
linkType->insertItem(i18n("File or URL"));
linkType->insertItem(i18n("KnowIt note"));

layout->addItem(new QSpacerItem(0, 5));
QHBox* editBox = new QHBox(plainPage());
layout->addWidget(editBox);
tqlayout->addItem(new TQSpacerItem(0, 5));
TQHBox* editBox = new TQHBox(plainPage());
tqlayout->addWidget(editBox);
linkValue = new KLineEdit("Link text", editBox);
linkValue->setMinimumWidth(300);
browse = new QToolButton(editBox, "Browse");
browse->setIconSet(QIconSet(KGlobal::iconLoader()->loadIcon("fileopen",
browse = new TQToolButton(editBox, "Browse");
browse->setIconSet(TQIconSet(KGlobal::iconLoader()->loadIcon("fileopen",
KIcon::Toolbar, KIcon::SizeSmall)));
layout->addItem(new QSpacerItem(0, 5));
layout->addWidget(new QLabel(i18n("Link description:"), plainPage()));
layout->addWidget(linkDescription = new KLineEdit("Link description", plainPage()));
tqlayout->addItem(new TQSpacerItem(0, 5));
tqlayout->addWidget(new TQLabel(i18n("Link description:"), plainPage()));
tqlayout->addWidget(linkDescription = new KLineEdit("Link description", plainPage()));

connect(browse, SIGNAL(clicked()), this, SLOT(slotBrowse()));
connect(linkType, SIGNAL(activated(int)), this, SLOT(slotTypeChanged(int)));
connect(browse, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotBrowse()));
connect(linkType, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotTypeChanged(int)));
}

KnowitLinkDialog::~KnowitLinkDialog()
@@ -72,7 +72,7 @@ bool KnowitLinkDialog::modifyLink(TNoteLink& link)
else
linkValue->setText(link.link);
slotTypeChanged(linkType->currentItem());
if (exec() == QDialog::Accepted) {
if (exec() == TQDialog::Accepted) {
link.description = linkDescription->text();
if (linkType->currentItem())
link.link = "knowit://" + linkValue->text();
@@ -86,7 +86,7 @@ bool KnowitLinkDialog::modifyLink(TNoteLink& link)

void KnowitLinkDialog::slotBrowse()
{
KURL url=KFileDialog::getOpenURL(QString::null,
KURL url=KFileDialog::getOpenURL(TQString(),
i18n("*|All files"), this, i18n("Choose link..."));
if (!url.isEmpty()) {
linkValue->setText(url.url());


+ 3
- 2
src/knowitlink.h View File

@@ -23,15 +23,16 @@
class KComboBox;
class KLineEdit;
class TNoteLink;
class QToolButton;
class TQToolButton;

class KnowitLinkDialog : public KDialogBase {
Q_OBJECT
TQ_OBJECT
protected:
KComboBox* linkType;
KLineEdit* linkValue;
KLineEdit* linkDescription;
QToolButton* browse;
TQToolButton* browse;
public:
KnowitLinkDialog();
~KnowitLinkDialog();


+ 10
- 10
src/knowitlinks.cpp View File

@@ -16,21 +16,21 @@
***************************************************************************/

#include "knowitlinks.h"
#include <qevent.h>
#include <tqevent.h>
#include <kurldrag.h>

KnowitLinks::KnowitLinks(QWidget* parent, const char* name)
: KListBox(parent, name)
KnowitLinks::KnowitLinks(TQWidget* tqparent, const char* name)
: KListBox(tqparent, name)
{
setAcceptDrops(true);
}

void KnowitLinks::dragEnterEvent(QDragEnterEvent* event)
void KnowitLinks::dragEnterEvent(TQDragEnterEvent* event)
{
event->accept(KURLDrag::canDecode(event));
}

void KnowitLinks::dropEvent(QDropEvent* event)
void KnowitLinks::dropEvent(TQDropEvent* event)
{
if (KURLDrag::canDecode(event)) {
KURL::List L;
@@ -40,15 +40,15 @@ void KnowitLinks::dropEvent(QDropEvent* event)
}
}

void KnowitLinks::keyPressEvent(QKeyEvent* e)
void KnowitLinks::keyPressEvent(TQKeyEvent* e)
{
if (currentItem() != -1 && (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return)) {
if (currentItem() != -1 && (e->key() == TQt::Key_Enter || e->key() == TQt::Key_Return)) {
e->ignore();
if ((e->state() | Qt::NoButton | Qt::Keypad) ==
(Qt::NoButton | Qt::Keypad)) emit linkOpen();
if ((e->state() | Qt::NoButton | TQt::Keypad) ==
(Qt::NoButton | TQt::Keypad)) emit linkOpen();
else emit linkOpenWith();
}
else if (currentItem() != -1 && e->key() == Qt::Key_Delete) {
else if (currentItem() != -1 && e->key() == TQt::Key_Delete) {
e->ignore();
emit linkRemove();
}


+ 9
- 8
src/knowitlinks.h View File

@@ -19,21 +19,22 @@
#define __KNOWIT_LINKS_H__
#include <klistbox.h>

class QDropEvent;
class QKeyEvent;
class QDragEnterEvent;
class TQDropEvent;
class TQKeyEvent;
class TQDragEnterEvent;

class KnowitLinks : public KListBox
{
Q_OBJECT
TQ_OBJECT
public:
KnowitLinks(QWidget* parent=0, const char* name = 0);
KnowitLinks(TQWidget* tqparent=0, const char* name = 0);
protected:
virtual void dragEnterEvent(QDragEnterEvent* event);
virtual void dropEvent(QDropEvent* event);
virtual void keyPressEvent(QKeyEvent* e);
virtual void dragEnterEvent(TQDragEnterEvent* event);
virtual void dropEvent(TQDropEvent* event);
virtual void keyPressEvent(TQKeyEvent* e);
signals:
void textDropped(const QString& s, int flags);
void textDropped(const TQString& s, int flags);
void linkRemove();
void linkOpen();
void linkOpenWith();


+ 101
- 101
src/knowitpref.cpp View File

@@ -2,7 +2,7 @@
knowitpref.cpp - description
-------------------
begin : czw lis 28 2002
copyright : (C) 2002-2004 by Micha³ Rudolf
copyright : (C) 2002-2004 by Micha� Rudolf
email : mrudolf@kdewebdev.org
***************************************************************************/

@@ -18,16 +18,16 @@
#include "knowitpref.h"


#include <qcheckbox.h>
#include <qcolor.h>
#include <qtoolbutton.h>
#include <qspinbox.h>
#include <qdatetime.h>
#include <qlayout.h>
#include <qwhatsthis.h>
#include <qstring.h>
#include <qlabel.h>
#include <qvbox.h>
#include <tqcheckbox.h>
#include <tqcolor.h>
#include <tqtoolbutton.h>
#include <tqspinbox.h>
#include <tqdatetime.h>
#include <tqlayout.h>
#include <tqwhatsthis.h>
#include <tqstring.h>
#include <tqlabel.h>
#include <tqvbox.h>

#include <kconfig.h>
#include <kcombobox.h>
@@ -95,7 +95,7 @@ void KnowitOptions::read(KConfig* config)
horizontalSplit = config->readNumEntry("HorizontalSplit", true);
defaultName = config->readEntry("DefaultName", i18n("New note"));
alternateTree = config->readBoolEntry("AlternateTree", false);
alternateColor = config->readEntry("AlternateColor", QString("LightYellow"));
alternateColor = config->readEntry("AlternateColor", TQString("LightYellow"));
autoCollapse = config->readBoolEntry("AutoCollapse", false);
unconditionalSave = config->readBoolEntry("UnconditionalSave", false);
backup = config->readBoolEntry("Backup", true);
@@ -109,15 +109,15 @@ void KnowitOptions::read(KConfig* config)
enterBreakLine = config->readBoolEntry("EnterBreakLine", true);
tabfocus = config->readBoolEntry("TabFocus", false);
customColors = config->readBoolEntry("CustomColors", false);
foreEditColor = config->readEntry("ForeEditColor", QString("Black"));
backEditColor = config->readEntry("BackEditColor", QString("White"));
foreEditColor = config->readEntry("ForeEditColor", TQString("Black"));
backEditColor = config->readEntry("BackEditColor", TQString("White"));
customFont = config->readBoolEntry("CustomFont", false);
fontFamily = config->readEntry("FontFamily", QString("Helvetica"));
fontFamily = config->readEntry("FontFamily", TQString("Helvetica"));
fontSize = config->readNumEntry("FontSize", 10); // KDE-Default?

config->setGroup("Templates");
insertDateFormat = config->readEntry("InsertDateFormatString", QString("ddd d MMM yyyy, hh:mm:ss"));
insertDateColor = config->readEntry("InsertDateColor", QString("Blue"));
insertDateFormat = config->readEntry("InsertDateFormatString", TQString("ddd d MMM yyyy, hh:mm:ss"));
insertDateColor = config->readEntry("InsertDateColor", TQString("Blue"));
insertDateBold = config->readBoolEntry("InsertDateBold", false);
insertDateItalic = config->readBoolEntry("InsertDateItalic", true);
insertDateUnderline = config->readBoolEntry("InsertDateUnderline", false);
@@ -131,118 +131,118 @@ void KnowitOptions::read(KConfig* config)
KnowitPreferences::KnowitPreferences()
: KDialogBase(IconList, i18n("KnowIt Preferences"), Ok|Cancel, Ok)
{
QFrame* page;
QVBoxLayout* layout;
TQFrame* page;
TQVBoxLayout* tqlayout;

/* first page: General */
page = addPage(i18n("General"), i18n("General options"),
KGlobal::iconLoader()->loadIcon(QString("configure"), KIcon::Toolbar, KIcon::SizeMedium));
layout = new QVBoxLayout(page, 0, spacingHint());
layout->addWidget(docked = new QCheckBox(i18n("&Dock in System tray"), page, "Dock"));
layout->addWidget(reopen = new QCheckBox(i18n("Open &last file on startup"), page, "Reopen"));
QHBox* autosaveBox = new QHBox(page);
layout->addWidget(autosaveBox);
new QLabel(i18n("Autosave:"), autosaveBox);
autosave = new QSpinBox(0, 120, 5, autosaveBox, "Autosave");
KGlobal::iconLoader()->loadIcon(TQString("configure"), KIcon::Toolbar, KIcon::SizeMedium));
tqlayout = new TQVBoxLayout(page, 0, spacingHint());
tqlayout->addWidget(docked = new TQCheckBox(i18n("&Dock in System tray"), page, "Dock"));
tqlayout->addWidget(reopen = new TQCheckBox(i18n("Open &last file on startup"), page, "Reopen"));
TQHBox* autosaveBox = new TQHBox(page);
tqlayout->addWidget(autosaveBox);
new TQLabel(i18n("Autosave:"), autosaveBox);
autosave = new TQSpinBox(0, 120, 5, autosaveBox, "Autosave");
autosave->setPrefix(i18n("every "));
autosave->setSuffix(i18n(" min."));
autosave->setSpecialValueText(i18n("Never"));
QWhatsThis::add(autosave, i18n("Current file will be automatically saved "
TQWhatsThis::add(autosave, i18n("Current file will be automatically saved "
"after the specified interval. Set to <i>never</i> to disable autosave."));

layout->addWidget(unconditionalSave = new QCheckBox(i18n("Automatically save file on e&xit"),
tqlayout->addWidget(unconditionalSave = new TQCheckBox(i18n("Automatically save file on e&xit"),
page, "UnconditionalSave"));
QWhatsThis::add(unconditionalSave, i18n("Current file will be automatically saved "
TQWhatsThis::add(unconditionalSave, i18n("Current file will be automatically saved "
"on exit without confirmation."));
layout->addWidget(backup = new QCheckBox(i18n("Create &backups"),
tqlayout->addWidget(backup = new TQCheckBox(i18n("Create &backups"),
page, "Backup"));
QWhatsThis::add(backup, i18n("Create backup of current document before it is saved."));
layout->addWidget(multipleInstances = new QCheckBox(i18n("Allow &multiple instances of KnowIt"),
TQWhatsThis::add(backup, i18n("Create backup of current document before it is saved."));
tqlayout->addWidget(multipleInstances = new TQCheckBox(i18n("Allow &multiple instances of KnowIt"),
page, "Instances"));
QWhatsThis::add(multipleInstances, i18n("If this option is disabled, only one "
TQWhatsThis::add(multipleInstances, i18n("If this option is disabled, only one "
"instance of KnowIt will be allowed. If there is another instance already running, "
"it will be automatically activated instead of running new one."));
layout->addStretch(1);
tqlayout->addStretch(1);


/* second page: Interface */
page = addPage(i18n("Interface"), i18n("Interface options"),
KGlobal::iconLoader()->loadIcon(QString("misc"), KIcon::Toolbar, KIcon::SizeMedium));
layout = new QVBoxLayout(page, 0, spacingHint());
layout->addWidget(horizontalSplit = new QCheckBox(i18n("Split window &horizontally"), page, "Split"));
QWhatsThis::add(horizontalSplit, i18n("If this option is set, notes tree will "
KGlobal::iconLoader()->loadIcon(TQString("misc"), KIcon::Toolbar, KIcon::SizeMedium));
tqlayout = new TQVBoxLayout(page, 0, spacingHint());
tqlayout->addWidget(horizontalSplit = new TQCheckBox(i18n("Split window &horizontally"), page, "Split"));
TQWhatsThis::add(horizontalSplit, i18n("If this option is set, notes tree will "
"be displayed on the left and the editor on the right (this is default).<br>"
"Otherwise notes tree will be displayed at the top and the editor at the bottom."));

QHBox* defaultNameBox = new QHBox(page);
layout->addWidget(defaultNameBox);
new QLabel(i18n("Default note name:"), defaultNameBox);
TQHBox* defaultNameBox = new TQHBox(page);
tqlayout->addWidget(defaultNameBox);
new TQLabel(i18n("Default note name:"), defaultNameBox);
defaultName = new KLineEdit(defaultNameBox, "DefaultName");
QWhatsThis::add(defaultName, i18n("Default name for new notes. It would be "
TQWhatsThis::add(defaultName, i18n("Default name for new notes. It would be "
"autoselected, so if you often copy text using mouse selection, you may "
"consider setting default name to none."));

QHBox* linkBox = new QHBox(page);
layout->addWidget(linkBox);
new QLabel(i18n("Link format:"), linkBox);
TQHBox* linkBox = new TQHBox(page);
tqlayout->addWidget(linkBox);
new TQLabel(i18n("Link format:"), linkBox);
linkFormat = new KComboBox(linkBox, "LinkFormat");
linkFormat->insertItem(i18n("Description (link)"));
linkFormat->insertItem(i18n("Link (description)"));
linkFormat->insertItem(i18n("Link only"));
linkFormat->insertItem(i18n("Description only"));
QHBox* alternateBox = new QHBox(page);
layout->addWidget(alternateBox);
alternateTree = new QCheckBox(i18n("Alternate colors in tree"), alternateBox, "Alternate");
alternateColor = new KColorButton(QColor("White"), alternateBox, "AlternateColor");
TQHBox* alternateBox = new TQHBox(page);
tqlayout->addWidget(alternateBox);
alternateTree = new TQCheckBox(i18n("Alternate colors in tree"), alternateBox, "Alternate");
alternateColor = new KColorButton(TQColor("White"), alternateBox, "AlternateColor");

layout->addWidget(autoCollapse = new QCheckBox(i18n("Automatically collapse other notes"), page, "AutoCollapse"));
QWhatsThis::add(autoCollapse, i18n("If this option is set, only current subtree "
tqlayout->addWidget(autoCollapse = new TQCheckBox(i18n("Automatically collapse other notes"), page, "AutoCollapse"));
TQWhatsThis::add(autoCollapse, i18n("If this option is set, only current subtree "
"will be visible, other notes will be automatically collapsed."));
layout->addStretch(1);
tqlayout->addStretch(1);


/* third page: Editor */
page = addPage(i18n("Editor"), i18n("Editor options"),
KGlobal::iconLoader()->loadIcon(QString("edit"), KIcon::Toolbar, KIcon::SizeMedium));
layout = new QVBoxLayout(page, 0, spacingHint());
layout->addWidget(wordwrap = new QCheckBox(i18n("Use &word wrap"),
KGlobal::iconLoader()->loadIcon(TQString("edit"), KIcon::Toolbar, KIcon::SizeMedium));
tqlayout = new TQVBoxLayout(page, 0, spacingHint());
tqlayout->addWidget(wordwrap = new TQCheckBox(i18n("Use &word wrap"),
page, "WordWrap"));
layout->addWidget(enterBreakLine = new QCheckBox(i18n("'Enter' ends current line, not paragraph"),
tqlayout->addWidget(enterBreakLine = new TQCheckBox(i18n("'Enter' ends current line, not paragraph"),
page, "EnterLineBreak"));
layout->addWidget(tabfocus = new QCheckBox(i18n("'Tab' in editor changes focus"),
tqlayout->addWidget(tabfocus = new TQCheckBox(i18n("'Tab' in editor changes focus"),
page, "TabFocus"));
#if KDE_VERSION_MAJOR == 3 && KDE_VERSION_MINOR < 1
tabfocus->hide();
#endif
QHBox* colorBox = new QHBox(page);
layout->addWidget(colorBox);
customColors = new QCheckBox(i18n("Use &custom colors"), colorBox, "CustomColors");
TQHBox* colorBox = new TQHBox(page);
tqlayout->addWidget(colorBox);
customColors = new TQCheckBox(i18n("Use &custom colors"), colorBox, "CustomColors");
editColors = new KDualColorButton(colorBox);

const char fontSizes[] = {4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,24,26,28,32,48,64,0};
QStringList fontList;
TQStringList fontList;
KFontChooser::getFontList(fontList, false);

QHBox* fontBox = new QHBox(page);
layout->addWidget(fontBox);
customFont = new QCheckBox(i18n("Use custom font:"), fontBox, "customFont");
TQHBox* fontBox = new TQHBox(page);
tqlayout->addWidget(fontBox);
customFont = new TQCheckBox(i18n("Use custom font:"), fontBox, "customFont");
fontFamily = new KComboBox(true, fontBox);
fontFamily->insertStringList(fontList);
fontSize = new KComboBox(true, fontBox);
for( int i=0; fontSizes[i] != 0; i++ ){
fontSize->insertItem(QString().setNum(fontSizes[i]),i);
fontSize->insertItem(TQString(TQString().setNum(fontSizes[i])),i);
}

layout->addStretch(1);
tqlayout->addStretch(1);


/* fourth page: Templates */
page = addPage(i18n("Templates"), i18n("Templates configuration"),
KGlobal::iconLoader()->loadIcon(QString("wizard"), KIcon::Toolbar, KIcon::SizeMedium));
layout = new QVBoxLayout(page, 0, spacingHint());
QWhatsThis::add(page, i18n("<html>\n"
KGlobal::iconLoader()->loadIcon(TQString("wizard"), KIcon::Toolbar, KIcon::SizeMedium));
tqlayout = new TQVBoxLayout(page, 0, spacingHint());
TQWhatsThis::add(page, i18n("<html>\n"
"<p>These expressions may be used: </p>\n"
"<table>\n"
"<tr><th>d</th><td>the day as number without a leading zero (1-31)</td></tr>\n"
@@ -265,28 +265,28 @@ KnowitPreferences::KnowitPreferences()
"<tr><th>AP</th><td>use am/pm display</td></tr>\n"
"</table></html>"));

QHBox* topBox = new QHBox(page);
layout->addWidget(topBox);
QLabel * label1 = new QLabel(i18n("Date Format: "), topBox);
label1->setFixedSize(label1->sizeHint());
insertDatePreview = new QLabel("", topBox);
TQHBox* topBox = new TQHBox(page);
tqlayout->addWidget(topBox);
TQLabel * label1 = new TQLabel(i18n("Date Format: "), topBox);
label1->setFixedSize(label1->tqsizeHint());
insertDatePreview = new TQLabel("", topBox);
QHBox *tmpBox = new QHBox(page);
layout->addWidget(tmpBox);
insertDateColorButton = new KColorButton(QColor("Blue"), tmpBox, "InsertDateColorButton");
TQHBox *tmpBox = new TQHBox(page);
tqlayout->addWidget(tmpBox);
insertDateColorButton = new KColorButton(TQColor("Blue"), tmpBox, "InsertDateColorButton");
insertDateFormatEdit = new KLineEdit(tmpBox, "InsertDateFormatEdit");
insertDateItalicButton = new QToolButton(tmpBox,"InsertDateItalicButton");
insertDateItalicButton->setIconSet(QIconSet(KGlobal::iconLoader()->loadIcon("text_italic", KIcon::Toolbar)));
insertDateItalicButton = new TQToolButton(tmpBox,"InsertDateItalicButton");
insertDateItalicButton->setIconSet(TQIconSet(KGlobal::iconLoader()->loadIcon("text_italic", KIcon::Toolbar)));
insertDateItalicButton->setToggleButton(true);
insertDateBoldButton = new QToolButton(tmpBox,"InsertDateBoldButton");
insertDateBoldButton->setIconSet(QIconSet(KGlobal::iconLoader()->loadIcon("text_bold", KIcon::Toolbar)));
insertDateBoldButton = new TQToolButton(tmpBox,"InsertDateBoldButton");
insertDateBoldButton->setIconSet(TQIconSet(KGlobal::iconLoader()->loadIcon("text_bold", KIcon::Toolbar)));
insertDateBoldButton->setToggleButton(true);
insertDateUnderlineButton = new QToolButton(tmpBox, "InsertDateUnderlineButton");
insertDateUnderlineButton->setIconSet(QIconSet(KGlobal::iconLoader()->loadIcon("text_under", KIcon::Toolbar)));
insertDateUnderlineButton = new TQToolButton(tmpBox, "InsertDateUnderlineButton");
insertDateUnderlineButton->setIconSet(TQIconSet(KGlobal::iconLoader()->loadIcon("text_under", KIcon::Toolbar)));
insertDateUnderlineButton->setToggleButton(true);
insertDateColorButton->setFixedSize(insertDateBoldButton->sizeHint());
insertDateFormatEdit->setMinimumWidth(6*insertDateBoldButton->sizeHint().width());
layout->addStretch(1);
insertDateColorButton->setFixedSize(insertDateBoldButton->tqsizeHint());
insertDateFormatEdit->setMinimumWidth(6*insertDateBoldButton->tqsizeHint().width());
tqlayout->addStretch(1);

setIconListAllVisible(true);
}
@@ -303,7 +303,7 @@ void KnowitPreferences::setOptions(const KnowitOptions& Options)
horizontalSplit->setChecked(Options.horizontalSplit);
defaultName->setText(Options.defaultName);
alternateTree->setChecked(Options.alternateTree);
alternateColor->setColor(QColor(Options.alternateColor));
alternateColor->setColor(TQColor(Options.alternateColor));
autoCollapse->setChecked(Options.autoCollapse);
linkFormat->setCurrentItem(Options.linkFormat);
@@ -311,23 +311,23 @@ void KnowitPreferences::setOptions(const KnowitOptions& Options)
enterBreakLine->setChecked(Options.enterBreakLine);
tabfocus->setChecked(Options.tabfocus);
customColors->setChecked(Options.customColors);
editColors->setForeground(QColor(Options.foreEditColor));
editColors->setBackground(QColor(Options.backEditColor));
editColors->setForeground(TQColor(Options.foreEditColor));
editColors->setBackground(TQColor(Options.backEditColor));
customFont->setChecked(Options.customFont);
fontFamily->setCurrentText(Options.fontFamily);
fontSize->setCurrentText(QString().setNum(Options.fontSize));
fontSize->setCurrentText(TQString().setNum(Options.fontSize));
insertDateFormatEdit->setText(Options.insertDateFormat);
insertDateColorButton->setColor(QColor(Options.insertDateColor));
insertDateColorButton->setColor(TQColor(Options.insertDateColor));
insertDateBoldButton->setOn(Options.insertDateBold);
insertDateItalicButton->setOn(Options.insertDateItalic);
insertDateUnderlineButton->setOn(Options.insertDateUnderline);
slotUpdateDatePreview();
connect(insertDateColorButton, SIGNAL(clicked()), this, SLOT(slotUpdateDatePreview()));
connect(insertDateFormatEdit, SIGNAL(textChanged (const QString &)), this, SLOT(slotUpdateDatePreview()));
connect(insertDateItalicButton, SIGNAL(toggled(bool)), this, SLOT(slotUpdateDatePreview()));
connect(insertDateBoldButton, SIGNAL(toggled(bool)), this, SLOT(slotUpdateDatePreview()));
connect(insertDateUnderlineButton, SIGNAL(toggled(bool)), this, SLOT(slotUpdateDatePreview()));
connect(insertDateColorButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotUpdateDatePreview()));
connect(insertDateFormatEdit, TQT_SIGNAL(textChanged (const TQString &)), this, TQT_SLOT(slotUpdateDatePreview()));
connect(insertDateItalicButton, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotUpdateDatePreview()));
connect(insertDateBoldButton, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotUpdateDatePreview()));
connect(insertDateUnderlineButton, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotUpdateDatePreview()));

/* non-GUI options */
firstLink = Options.firstLink;
@@ -374,18 +374,18 @@ KnowitOptions KnowitPreferences::getOptions() const

void KnowitPreferences::slotUpdateDatePreview()
{
QString str = "<html><p align=\"center\">";
TQString str = "<html><p align=\"center\">";
if(insertDateBoldButton->isOn()) str += "<b>";
if(insertDateItalicButton->isOn()) str +="<i>";
if(insertDateUnderlineButton->isOn()) str += "<u>";
str += "<font COLOR=\""+insertDateColorButton->color().name()+"\">";
str += QString("%1").arg(QDateTime::currentDateTime().toString(insertDateFormatEdit->text()));
str += TQString("%1").tqarg(TQDateTime::tqcurrentDateTime().toString(insertDateFormatEdit->text()));
str += "</font>";
if(insertDateUnderlineButton->isOn()) str += "</u>";
if(insertDateItalicButton->isOn()) str +="</i>";
if(insertDateBoldButton->isOn()) str += "</b>";
str += "</p></html>";
insertDatePreview->setPaletteBackgroundColor(QColor("White"));
insertDatePreview->setPaletteBackgroundColor(TQColor("White"));
insertDatePreview->setText(str);
}



+ 21
- 20
src/knowitpref.h View File

@@ -18,12 +18,12 @@
#ifndef KNOWITPREF_H
#define KNOWITPREF_H

#include <qstring.h>
#include <tqstring.h>
#include <kdialogbase.h>

class QCheckBox;
class QSpinBox;
class QToolButton;
class TQCheckBox;
class TQSpinBox;
class TQToolButton;
class KLineEdit;
class KColorButton;
class KDualColorButton;
@@ -43,9 +43,9 @@ public:
/* GUI */
bool horizontalSplit;
int linkFormat;
QString defaultName;
TQString defaultName;
bool alternateTree;
QString alternateColor;
TQString alternateColor;
bool autoCollapse;
/* Links */
bool firstLink;
@@ -54,13 +54,13 @@ public:
bool enterBreakLine;
bool tabfocus;
bool customColors;
QString backEditColor;
QString foreEditColor;
TQString backEditColor;
TQString foreEditColor;
bool customFont;
QString fontFamily;
TQString fontFamily;
int fontSize;
/* Date format */
QString insertDateFormat, insertDateColor;
TQString insertDateFormat, insertDateColor;
bool insertDateBold, insertDateItalic, insertDateUnderline;
void save(KConfig* config) const;
void read(KConfig* config);
@@ -72,24 +72,25 @@ public:
class KnowitPreferences : public KDialogBase
{
Q_OBJECT
TQ_OBJECT
private:
QCheckBox *docked, *reopen, *horizontalSplit, *multipleInstances, *backup;
QCheckBox *unconditionalSave;
QCheckBox *wordwrap, *tabfocus, *customColors;
TQCheckBox *docked, *reopen, *horizontalSplit, *multipleInstances, *backup;
TQCheckBox *unconditionalSave;
TQCheckBox *wordwrap, *tabfocus, *customColors;
KDualColorButton* editColors;
QCheckBox *enterBreakLine;
TQCheckBox *enterBreakLine;
KLineEdit *defaultName;
QCheckBox *alternateTree;
TQCheckBox *alternateTree;
KColorButton *alternateColor;
QCheckBox* autoCollapse;
QCheckBox* customFont;
TQCheckBox* autoCollapse;
TQCheckBox* customFont;
KComboBox *fontFamily, *fontSize;
KComboBox *linkFormat;
KLineEdit *insertDateFormatEdit;
KColorButton *insertDateColorButton;
QLabel *insertDatePreview;
QSpinBox* autosave;
QToolButton *insertDateItalicButton, *insertDateBoldButton, *insertDateUnderlineButton;
TQLabel *insertDatePreview;
TQSpinBox* autosave;
TQToolButton *insertDateItalicButton, *insertDateBoldButton, *insertDateUnderlineButton;
bool firstLink;
int exportFlags;
public:


+ 5
- 5
src/knowittray.cpp View File

@@ -18,16 +18,16 @@
#include <kpopupmenu.h>
#include <klocale.h>
KnowitTray::KnowitTray (QWidget* parent, const char* name) :
KSystemTray(parent, name)
KnowitTray::KnowitTray (TQWidget* tqparent, const char* name) :
KSystemTray(tqparent, name)
{
contextMenu()->insertItem(i18n("&Undock"), parent,
SLOT(slotUndock()));
contextMenu()->insertItem(i18n("&Undock"), tqparent,
TQT_SLOT(slotUndock()));
}

void KnowitTray::contextMenuAboutToShow (KPopupMenu* menu)
{
menu->removeItemAt(menu->count()-1);
menu->insertItem(i18n("&Quit"), parent(), SLOT(slotFileQuit()));
menu->insertItem(i18n("&Quit"), tqparent(), TQT_SLOT(slotFileQuit()));
}


+ 1
- 1
src/knowittray.h View File

@@ -22,7 +22,7 @@
class KnowitTray : public KSystemTray
{
public:
KnowitTray(QWidget* parent=0, const char* name=0);
KnowitTray(TQWidget* tqparent=0, const char* name=0);
protected:
virtual void contextMenuAboutToShow (KPopupMenu* menu);
};


+ 19
- 19
src/knowittree.cpp View File

@@ -16,14 +16,14 @@
***************************************************************************/

#include <klocale.h>
#include <qevent.h>
#include <qdragobject.h>
#include <qheader.h>
#include <qwhatsthis.h>
#include <tqevent.h>
#include <tqdragobject.h>
#include <tqheader.h>
#include <tqwhatsthis.h>
#include "knowittree.h"

KnowitTree::KnowitTree(QWidget* parent, const char* name)
: KListView(parent, name)
KnowitTree::KnowitTree(TQWidget* tqparent, const char* name)
: KListView(tqparent, name)
{
setMinimumSize(150, 150);
addColumn(i18n("Notes"));
@@ -35,25 +35,25 @@ KnowitTree::KnowitTree(QWidget* parent, const char* name)
setSorting(-1);
setDragAutoScroll(true);
prevItem = 0;
QWhatsThis::add(this, i18n("<h2>Notes hierarchy</h2>"
TQWhatsThis::add(this, i18n("<h2>Notes hierarchy</h2>"
"Here you can browse notes tree. "
"You can also add notes using right-click menu, or reorganize them using "
"drag and drop."));
}


void KnowitTree::takeNode(QListViewItem* item)
void KnowitTree::takeNode(TQListViewItem* item)
{
if (item->parent())
item->parent()->takeItem(item);
if (item->tqparent())
item->tqparent()->takeItem(item);
else
takeItem(item);
}

void KnowitTree::insertNode(QListViewItem* parent, QListViewItem* item, QListViewItem* after)
void KnowitTree::insertNode(TQListViewItem* tqparent, TQListViewItem* item, TQListViewItem* after)
{
if (parent)
parent->insertItem(item);
if (tqparent)
tqparent->insertItem(item);
else
insertItem(item);
if (after)
@@ -61,9 +61,9 @@ void KnowitTree::insertNode(QListViewItem* parent, QListViewItem* item, QListVie
}


void KnowitTree::contentsDragMoveEvent(QDragMoveEvent* event)
void KnowitTree::contentsDragMoveEvent(TQDragMoveEvent* event)
{
QListViewItem* item = itemAt(event->pos());
TQListViewItem* item = itemAt(event->pos());
/* check if on root decoration */
if (!item || event->pos().x() > header()->cellPos(header()->mapToActual(0)) +
treeStepSize() * (item->depth() + 1) + itemMargin() ||
@@ -75,7 +75,7 @@ void KnowitTree::contentsDragMoveEvent(QDragMoveEvent* event)

void KnowitTree::slotCollapseAll()
{
QListViewItem* it = firstChild();
TQListViewItem* it = firstChild();
while(it) {
it->setOpen(false);
it = it->nextSibling();
@@ -91,7 +91,7 @@ void KnowitTree::slotCollapse()

void KnowitTree::slotExpandAll()
{
QListViewItem* it = firstChild();
TQListViewItem* it = firstChild();
while(it) {
it->setOpen(true);
it = it->nextSibling();
@@ -123,7 +123,7 @@ void KnowitTree::slotItemBegin()

void KnowitTree::slotItemEnd()
{
QListViewItem* elt = firstChild();
TQListViewItem* elt = firstChild();
if (elt)
while (elt->itemBelow())
elt = elt->itemBelow();
@@ -133,7 +133,7 @@ void KnowitTree::slotItemEnd()
void KnowitTree::slotItemLeft()
{
if (currentItem())
setCurrentItem(currentItem()->parent());
setCurrentItem(currentItem()->tqparent());
}

void KnowitTree::slotItemRight()


+ 7
- 6
src/knowittree.h View File

@@ -17,17 +17,18 @@
#ifndef __KNOWIT_TREE_H__
#define __KNOWIT_TREE_H__
#include <klistview.h>
class QDragMoveEvent;
class TQDragMoveEvent;
class KnowitTree : public KListView
{
Q_OBJECT
TQ_OBJECT
public:
KnowitTree(QWidget* parent=0, const char* name = 0);
QListViewItem* prevItem;
void takeNode(QListViewItem* item);
void insertNode(QListViewItem* parent, QListViewItem* item, QListViewItem* after = 0);
KnowitTree(TQWidget* tqparent=0, const char* name = 0);
TQListViewItem* prevItem;
void takeNode(TQListViewItem* item);
void insertNode(TQListViewItem* tqparent, TQListViewItem* item, TQListViewItem* after = 0);
protected:
virtual void contentsDragMoveEvent(QDragMoveEvent* event);
virtual void contentsDragMoveEvent(TQDragMoveEvent* event);
public slots:
/** Shows only first-level notes */
void slotCollapseAll();


+ 78
- 78
src/notes.cpp View File

@@ -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();



+ 36
- 36
src/notes.h View File

@@ -17,13 +17,13 @@
#ifndef KNOWIT_NOTES_H
#define KNOWIT_NOTES_H

#include <qstring.h>
#include <qpixmap.h>
#include <qvaluelist.h>
#include <qvaluevector.h>
#include <qptrdict.h>
class QTextStream;
class QListViewItem;
#include <tqstring.h>
#include <tqpixmap.h>
#include <tqvaluelist.h>
#include <tqvaluevector.h>
#include <tqptrdict.h>
class TQTextStream;
class TQListViewItem;
class KURL;

class TNote;
@@ -32,74 +32,74 @@ class TNoteLink
{
public:
enum {DescriptionLink, LinkDescription, LinkOnly, DescriptionOnly};
QString link;
QString description;
TQString link;
TQString description;
TNoteLink() {}
TNoteLink(const QString& s) {link = s;}
TNoteLink(const QString& s1, const QString& s2) {link = s1; description = s2;}
TNoteLink(const TQString& s) {link = s;}
TNoteLink(const TQString& s1, const TQString& s2) {link = s1; description = s2;}
int operator==(const TNoteLink& N) const {return link == N.link &&
description == N.description;}
int operator!=(const TNoteLink& N) const {return link != N.link ||
description != N.description;}
void save(QTextStream& ts) const;
void save(TQTextStream& ts) const;
void open() const;
void openWith() const;
QString text(int fmt = DescriptionLink) const;
QPixmap icon() const;
TQString text(int fmt = DescriptionLink) const;
TQPixmap icon() const;
bool isLocalReference() const;
};


class TNotesCollection : public QPtrDict<TNote> {
class TNotesCollection : public TQPtrDict<TNote> {
public:
QPixmap Pixmaps[4];
TQPixmap Pixmaps[4];
TNotesCollection();
~TNotesCollection();
void addNote(QListViewItem* item);
void addNote(QListViewItem* item, const QString& s);
void removeNote(QListViewItem* item);
bool changeNote(QListViewItem* item, const QString& s);
void addNote(TQListViewItem* item);
void addNote(TQListViewItem* item, const TQString& s);
void removeNote(TQListViewItem* item);
bool changeNote(TQListViewItem* item, const TQString& s);
void clearNotes();
void updateNotesView();
bool modified;
bool autoUpdate;
const QString& text(QListViewItem* item);
const TQString& text(TQListViewItem* item);
};


class TNote {
private:
QValueList<TNoteLink> links;
TQValueList<TNoteLink> links;
TNotesCollection* collection;
bool saveHTMLBuf(QTextStream& ts, QValueVector<int>& depths,
bool saveHTMLBuf(TQTextStream& ts, TQValueVector<int>& depths,
int flags = SaveAll);
bool saveHTMLTocEntry(QTextStream& ts, QValueVector<int>& depths, int flags);
bool saveHTMLTocEntry(TQTextStream& ts, TQValueVector<int>& depths, int flags);
public:
typedef enum {Empty, Text, EmptyParent, TextParent} State;
enum {SaveCurrent = 0, SaveSubnotes = 0x0001, SaveAll = 0x0002, UseUTF8 = 0x0040,
Enumerate = 0x0080, AddRule = 0x0100, Style = 0x0200, TOC = 0x0400};
QListViewItem* item;
QString text;
TQListViewItem* item;
TQString text;
bool isEmpty();
bool contains(const QString& sought, bool case_sensitive = false);
bool change(const QString& s);
bool tqcontains(const TQString& sought, bool case_sensitive = false);
bool change(const TQString& s);
void destroy();
void updateView();
State state();
void open(QTextStream& ts);
void save(QTextStream& ts, bool current = false);
bool saveHTML(const KURL& fname, const QString& origname, const QString& style,
void open(TQTextStream& ts);
void save(TQTextStream& ts, bool current = false);
bool saveHTML(const KURL& fname, const TQString& origname, const TQString& style,
int flags = SaveAll);
void addLink(const QString& s);
void addLink(const TQString& s);
void addLink(const TNoteLink& l);
int linkCount() const;
const TNoteLink& link(int i) const;
void removeLink(int i);
void modifyLink(int i, const QString& s);
void modifyLink(int i, const TQString& s);
void modifyLink(int i, TNoteLink& l);
void modifyLinkDescription(int i, const QString& s);
TNote(QListViewItem* i, TNotesCollection* coll);
TNote(QListViewItem* i, TNotesCollection* coll, const QString& s);
void modifyLinkDescription(int i, const TQString& s);
TNote(TQListViewItem* i, TNotesCollection* coll);
TNote(TQListViewItem* i, TNotesCollection* coll, const TQString& s);
~TNote();
};
#endif


Loading…
Cancel
Save