TQt4 port Abakus

This enables compilation under both Qt3 and Qt4


git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/abakus@1231045 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 13 years ago
parent 4488b6112c
commit f4f8ac034f

@ -166,25 +166,26 @@ def detect_kde(env):
env.Exit(1) env.Exit(1)
env['QT_MOC'] = moc env['QT_MOC'] = moc
## check for the tqt and kde includes ## check for the qt and kde includes
print "Checking for the tqt includes : ", print "Checking for the qt includes : ",
if qtincludes and os.path.isfile(qtincludes + "/tqt.h"): if qtincludes and os.path.isfile(qtincludes + "/qlayout.h"):
# The user told where to look for and it looks valid # The user told where to look for and it looks valid
print GREEN + "ok " + qtincludes + NORMAL print GREEN + "ok " + qtincludes + NORMAL
else: else:
if os.path.isfile(qtdir + "/include/tqt.h"): if os.path.isfile(qtdir + "/include/qlayout.h"):
# Automatic detection # Automatic detection
print GREEN + "ok " + qtdir + "/include/ " + NORMAL print GREEN + "ok " + qtdir + "/include/ " + NORMAL
qtincludes = qtdir + "/include/" qtincludes = qtdir + "/include/"
elif os.path.isfile("/usr/include/tqt.h"): elif os.path.isfile("/usr/include/qt3/qlayout.h"):
print YELLOW + "the tqt headers were found in /usr/include/ " + NORMAL
qtincludes = "/usr/include"
elif os.path.isfile("/usr/include/tqt/tqt.h"):
# Debian probably # Debian probably
print YELLOW + "the tqt headers were found in /usr/include/tqt/ " + NORMAL print YELLOW + "the qt headers were found in /usr/include/qt3/ " + NORMAL
qtincludes = "/usr/include/tqt" qtincludes = "/usr/include/qt3"
elif os.path.isfile("/usr/include/qt4/Qt/qglobal.h"):
# Debian probably
print YELLOW + "the qt headers were found in /usr/include/qt4/ " + NORMAL
qtincludes = "/usr/include/qt4"
else: else:
print RED + "the tqt headers were not found" + NORMAL print RED + "the qt headers were not found" + NORMAL
env.Exit(1) env.Exit(1)
print "Checking for the kde includes : ", print "Checking for the kde includes : ",

@ -66,7 +66,7 @@ myenv.Append(CXXFLAGS = '-Wno-non-virtual-dtor -I/usr/include/tqt -include tqt.h
myenv.KDEaddpaths_includes('#/src/ #/') myenv.KDEaddpaths_includes('#/src/ #/')
## Necessary libraries to link against ## Necessary libraries to link against
myenv.KDEaddlibs( 'qt-mt kio kdecore kdeprint kdeui' ) myenv.KDEaddlibs( 'kio kdecore kdeprint kdeui' )
############################# #############################
## Data to install ## Data to install

@ -66,7 +66,7 @@ int main(int argc, char **argv)
MainWindow *win = new MainWindow; MainWindow *win = new MainWindow;
app.setMainWidget(win); app.setMainWidget(win);
app.connect(&app, SIGNAL(lastWindowClosed()), SLOT(quit())); app.connect(&app, TQT_SIGNAL(lastWindowClosed()), TQT_SLOT(quit()));
win->show(); win->show();
win->resize(500, 300); win->resize(500, 300);

@ -11,9 +11,9 @@
#include <kpopupmenu.h> #include <kpopupmenu.h>
#include <kaction.h> #include <kaction.h>
#include <qlabel.h> #include <tqlabel.h>
#include <qregexp.h> #include <tqregexp.h>
#include <qtimer.h> #include <tqtimer.h>
#include "function.h" #include "function.h"
#include "node.h" #include "node.h"

@ -20,38 +20,38 @@
#include <kpopupmenu.h> #include <kpopupmenu.h>
#include <kdebug.h> #include <kdebug.h>
#include <qdragobject.h> #include <tqdragobject.h>
#include <qcursor.h> #include <tqcursor.h>
#include <qheader.h> #include <tqheader.h>
#include "dragsupport.h" #include "dragsupport.h"
#include "abakuslistview.h" #include "abakuslistview.h"
#include "valuemanager.h" #include "valuemanager.h"
#include "function.h" #include "function.h"
ListView::ListView(QWidget *parent, const char *name) : ListView::ListView(TQWidget *tqparent, const char *name) :
KListView(parent, name), m_menu(0), m_usePopup(false), m_removeSingleId(0), KListView(tqparent, name), m_menu(0), m_usePopup(false), m_removeSingleId(0),
m_removeAllId(0) m_removeAllId(0)
{ {
setResizeMode(LastColumn); setResizeMode(LastColumn);
setDragEnabled(true); setDragEnabled(true);
connect(this, SIGNAL(contextMenuRequested(QListViewItem *, const QPoint &, int)), connect(this, TQT_SIGNAL(contextMenuRequested(TQListViewItem *, const TQPoint &, int)),
SLOT(rightClicked(QListViewItem *, const QPoint &))); TQT_SLOT(rightClicked(TQListViewItem *, const TQPoint &)));
} }
QDragObject *ListView::dragObject() TQDragObject *ListView::dragObject()
{ {
QPoint viewportPos = viewport()->mapFromGlobal(QCursor::pos()); TQPoint viewportPos = viewport()->mapFromGlobal(TQCursor::pos());
QListViewItem *item = itemAt(viewportPos); TQListViewItem *item = itemAt(viewportPos);
if(!item) if(!item)
return 0; return 0;
int column = header()->sectionAt(viewportPos.x()); int column = header()->sectionAt(viewportPos.x());
QString dragText = item->text(column); TQString dragText = item->text(column);
QDragObject *drag = new QTextDrag(dragText, this, "list item drag"); TQDragObject *drag = new TQTextDrag(dragText, this, "list item drag");
drag->setPixmap(DragSupport::makePixmap(dragText, font())); drag->setPixmap(DragSupport::makePixmap(dragText, font()));
return drag; return drag;
@ -70,8 +70,8 @@ void ListView::enablePopupHandler(bool enable)
m_menu = new KPopupMenu(this); m_menu = new KPopupMenu(this);
m_removeSingleId = m_menu->insertItem(removeItemString(), this, SLOT(removeSelected())); m_removeSingleId = m_menu->insertItem(removeItemString(), this, TQT_SLOT(removeSelected()));
m_removeAllId = m_menu->insertItem("Placeholder", this, SLOT(removeAllItems())); m_removeAllId = m_menu->insertItem("Placeholder", this, TQT_SLOT(removeAllItems()));
} }
else { else {
delete m_menu; delete m_menu;
@ -79,19 +79,19 @@ void ListView::enablePopupHandler(bool enable)
} }
} }
QString ListView::removeItemString() const TQString ListView::removeItemString() const
{ {
return QString(); return TQString();
} }
QString ListView::removeAllItemsString(unsigned count) const TQString ListView::removeAllItemsString(unsigned count) const
{ {
Q_UNUSED(count); Q_UNUSED(count);
return QString(); return TQString();
} }
void ListView::removeSelectedItem(QListViewItem *item) void ListView::removeSelectedItem(TQListViewItem *item)
{ {
Q_UNUSED(item); Q_UNUSED(item);
} }
@ -100,14 +100,14 @@ void ListView::removeAllItems()
{ {
} }
bool ListView::isItemRemovable(QListViewItem *item) const bool ListView::isItemRemovable(TQListViewItem *item) const
{ {
Q_UNUSED(item); Q_UNUSED(item);
return false; return false;
} }
void ListView::rightClicked(QListViewItem *item, const QPoint &pt) void ListView::rightClicked(TQListViewItem *item, const TQPoint &pt)
{ {
if(!m_usePopup) if(!m_usePopup)
return; return;
@ -122,7 +122,7 @@ void ListView::removeSelected()
removeSelectedItem(selectedItem()); removeSelectedItem(selectedItem());
} }
ValueListViewItem::ValueListViewItem(QListView *listView, const QString &name, ValueListViewItem::ValueListViewItem(TQListView *listView, const TQString &name,
const Abakus::number_t &value) : const Abakus::number_t &value) :
KListViewItem(listView, name), m_value(value) KListViewItem(listView, name), m_value(value)
{ {
@ -132,7 +132,7 @@ ValueListViewItem::ValueListViewItem(QListView *listView, const QString &name,
void ValueListViewItem::valueChanged() void ValueListViewItem::valueChanged()
{ {
setText(1, m_value.toString()); setText(1, m_value.toString());
repaint(); tqrepaint();
} }
void ValueListViewItem::valueChanged(const Abakus::number_t &newValue) void ValueListViewItem::valueChanged(const Abakus::number_t &newValue)
@ -147,25 +147,25 @@ Abakus::number_t ValueListViewItem::itemValue() const
return m_value; return m_value;
} }
VariableListView::VariableListView(QWidget *parent, const char *name) : VariableListView::VariableListView(TQWidget *tqparent, const char *name) :
ListView(parent, name) ListView(tqparent, name)
{ {
enablePopupHandler(true); enablePopupHandler(true);
} }
QString VariableListView::removeItemString() const TQString VariableListView::removeItemString() const
{ {
return i18n("Remove selected variable"); return i18n("Remove selected variable");
} }
QString VariableListView::removeAllItemsString(unsigned count) const TQString VariableListView::removeAllItemsString(unsigned count) const
{ {
// count is unreliable because not all of the elements in the list view // count is unreliable because not all of the elements in the list view
// can be removed. // can be removed.
count = 0; count = 0;
QStringList values = ValueManager::instance()->valueNames(); TQStringList values = ValueManager::instance()->valueNames();
for(QStringList::ConstIterator value = values.constBegin(); value != values.constEnd(); ++value) for(TQStringList::ConstIterator value = values.constBegin(); value != values.constEnd(); ++value)
if(!ValueManager::instance()->isValueReadOnly(*value)) if(!ValueManager::instance()->isValueReadOnly(*value))
++count; ++count;
@ -174,12 +174,12 @@ QString VariableListView::removeAllItemsString(unsigned count) const
count); count);
} }
bool VariableListView::isItemRemovable(QListViewItem *item) const bool VariableListView::isItemRemovable(TQListViewItem *item) const
{ {
return !ValueManager::instance()->isValueReadOnly(item->text(0)); return !ValueManager::instance()->isValueReadOnly(item->text(0));
} }
void VariableListView::removeSelectedItem(QListViewItem *item) void VariableListView::removeSelectedItem(TQListViewItem *item)
{ {
ValueManager::instance()->removeValue(item->text(0)); ValueManager::instance()->removeValue(item->text(0));
} }
@ -189,43 +189,43 @@ void VariableListView::removeAllItems()
ValueManager::instance()->slotRemoveUserVariables(); ValueManager::instance()->slotRemoveUserVariables();
} }
FunctionListView::FunctionListView(QWidget *parent, const char *name) : FunctionListView::FunctionListView(TQWidget *tqparent, const char *name) :
ListView(parent, name) ListView(tqparent, name)
{ {
enablePopupHandler(true); enablePopupHandler(true);
} }
QString FunctionListView::removeItemString() const TQString FunctionListView::removeItemString() const
{ {
return i18n("Remove selected function"); return i18n("Remove selected function");
} }
QString FunctionListView::removeAllItemsString(unsigned count) const TQString FunctionListView::removeAllItemsString(unsigned count) const
{ {
return i18n("Remove all functions (1 function)", return i18n("Remove all functions (1 function)",
"Remove all functions (%n functions)", "Remove all functions (%n functions)",
count); count);
} }
bool FunctionListView::isItemRemovable(QListViewItem *item) const bool FunctionListView::isItemRemovable(TQListViewItem *item) const
{ {
return true; return true;
} }
void FunctionListView::removeSelectedItem(QListViewItem *item) void FunctionListView::removeSelectedItem(TQListViewItem *item)
{ {
// Use section to get the beginning of the string up to (and not // Use section to get the beginning of the string up to (and not
// including) the first ( // including) the first (
QString name = item->text(0).section('(', 0, 0); TQString name = item->text(0).section('(', 0, 0);
FunctionManager::instance()->removeFunction(name); FunctionManager::instance()->removeFunction(name);
} }
void FunctionListView::removeAllItems() void FunctionListView::removeAllItems()
{ {
QStringList fns = FunctionManager::instance()->functionList(FunctionManager::UserDefined); TQStringList fns = FunctionManager::instance()->functionList(FunctionManager::UserDefined);
for(QStringList::ConstIterator fn = fns.constBegin(); fn != fns.constEnd(); ++fn) for(TQStringList::ConstIterator fn = fns.constBegin(); fn != fns.constEnd(); ++fn)
FunctionManager::instance()->removeFunction(*fn); FunctionManager::instance()->removeFunction(*fn);
} }

@ -28,12 +28,13 @@ class KPopupMenu;
class ListView : public KListView class ListView : public KListView
{ {
Q_OBJECT Q_OBJECT
TQ_OBJECT
public: public:
ListView(QWidget *parent, const char *name = 0); ListView(TQWidget *tqparent, const char *name = 0);
protected: protected:
virtual QDragObject *dragObject(); virtual TQDragObject *dragObject();
/** /**
* Used to enable fancy popup handling support in subclasses. Subclasses * Used to enable fancy popup handling support in subclasses. Subclasses
@ -47,7 +48,7 @@ class ListView : public KListView
* If using the popup menu handling, the subclass needs to return a * If using the popup menu handling, the subclass needs to return a
* translated string of the form "Remove selected <itemtype>". * translated string of the form "Remove selected <itemtype>".
*/ */
virtual QString removeItemString() const; virtual TQString removeItemString() const;
/** /**
* If using the popup menu handling, the subclass needs to return a * If using the popup menu handling, the subclass needs to return a
@ -55,7 +56,7 @@ class ListView : public KListView
* also appending a " (%n <itemtype>s), which you can use the @p count * also appending a " (%n <itemtype>s), which you can use the @p count
* parameter for. * parameter for.
*/ */
virtual QString removeAllItemsString(unsigned count) const; virtual TQString removeAllItemsString(unsigned count) const;
protected slots: protected slots:
/** /**
@ -63,7 +64,7 @@ class ListView : public KListView
* function to remove the selected item, which is passed in as a * function to remove the selected item, which is passed in as a
* parameter. * parameter.
*/ */
virtual void removeSelectedItem(QListViewItem *item); virtual void removeSelectedItem(TQListViewItem *item);
/** /**
* If using the popup menu handling, the subclass needs to reimplement this * If using the popup menu handling, the subclass needs to reimplement this
@ -75,10 +76,10 @@ class ListView : public KListView
* If using the popup menu handling, this function may be called to * If using the popup menu handling, this function may be called to
* determine whether the selected item given by @p item is removable. * determine whether the selected item given by @p item is removable.
*/ */
virtual bool isItemRemovable(QListViewItem *item) const; virtual bool isItemRemovable(TQListViewItem *item) const;
private slots: private slots:
void rightClicked(QListViewItem *item, const QPoint &pt); void rightClicked(TQListViewItem *item, const TQPoint &pt);
void removeSelected(); void removeSelected();
private: private:
@ -92,7 +93,7 @@ class ListView : public KListView
class ValueListViewItem : public KListViewItem class ValueListViewItem : public KListViewItem
{ {
public: public:
ValueListViewItem (QListView *listView, const QString &name, const Abakus::number_t &value); ValueListViewItem (TQListView *listView, const TQString &name, const Abakus::number_t &value);
// Will cause the list item to rethink the text. // Will cause the list item to rethink the text.
void valueChanged(); void valueChanged();
@ -110,17 +111,18 @@ class ValueListViewItem : public KListViewItem
class VariableListView : public ListView class VariableListView : public ListView
{ {
Q_OBJECT Q_OBJECT
TQ_OBJECT
public: public:
VariableListView(QWidget *parent, const char *name = 0); VariableListView(TQWidget *tqparent, const char *name = 0);
protected: protected:
virtual QString removeItemString() const; virtual TQString removeItemString() const;
virtual QString removeAllItemsString(unsigned count) const; virtual TQString removeAllItemsString(unsigned count) const;
virtual bool isItemRemovable(QListViewItem *item) const; virtual bool isItemRemovable(TQListViewItem *item) const;
protected slots: protected slots:
virtual void removeSelectedItem(QListViewItem *item); virtual void removeSelectedItem(TQListViewItem *item);
virtual void removeAllItems(); virtual void removeAllItems();
}; };
@ -130,17 +132,18 @@ class VariableListView : public ListView
class FunctionListView : public ListView class FunctionListView : public ListView
{ {
Q_OBJECT Q_OBJECT
TQ_OBJECT
public: public:
FunctionListView(QWidget *parent, const char *name = 0); FunctionListView(TQWidget *tqparent, const char *name = 0);
protected: protected:
virtual QString removeItemString() const; virtual TQString removeItemString() const;
virtual QString removeAllItemsString(unsigned count) const; virtual TQString removeAllItemsString(unsigned count) const;
virtual bool isItemRemovable(QListViewItem *item) const; virtual bool isItemRemovable(TQListViewItem *item) const;
protected slots: protected slots:
virtual void removeSelectedItem(QListViewItem *item); virtual void removeSelectedItem(TQListViewItem *item);
virtual void removeAllItems(); virtual void removeAllItems();
}; };

@ -22,7 +22,7 @@
#include <kdebug.h> #include <kdebug.h>
#include <dcopobject.h> #include <dcopobject.h>
#include <qstring.h> #include <tqstring.h>
#include "mainwindow.h" #include "mainwindow.h"
#include "numerictypes.h" #include "numerictypes.h"
@ -37,7 +37,7 @@ class AbakusIface : virtual public DCOPObject
} }
k_dcop: k_dcop:
virtual double evaluate(const QString &expr) virtual double evaluate(const TQString &expr)
{ {
Abakus::number_t result = parseString(expr.latin1()); Abakus::number_t result = parseString(expr.latin1());
return result.asDouble(); return result.asDouble();

@ -17,42 +17,42 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <qstring.h> #include <tqstring.h>
#include <qpixmap.h> #include <tqpixmap.h>
#include <qimage.h> #include <tqimage.h>
#include <qpainter.h> #include <tqpainter.h>
#include <qcolor.h> #include <tqcolor.h>
#include <qfont.h> #include <tqfont.h>
#include <qbrush.h> #include <tqbrush.h>
#include <qfontmetrics.h> #include <tqfontmetrics.h>
#include "dragsupport.h" #include "dragsupport.h"
namespace DragSupport namespace DragSupport
{ {
QPixmap makePixmap(const QString &text, const QFont &font) TQPixmap makePixmap(const TQString &text, const TQFont &font)
{ {
QColor background(234, 178, 230); TQColor background(234, 178, 230);
QFontMetrics fm(font); TQFontMetrics fm(font);
int height = 2 * fm.height(); int height = 2 * fm.height();
QSize bonusSize (height, 0); TQSize bonusSize (height, 0);
QSize size(fm.width(text), height); TQSize size(fm.width(text), height);
QImage image(size + bonusSize, 32); TQImage image(size + bonusSize, 32);
image.setAlphaBuffer(false); image.setAlphaBuffer(false);
image.fill(0); // All transparent pixels image.fill(0); // All transparent pixels
image.setAlphaBuffer(true); image.setAlphaBuffer(true);
QPixmap pix(size + bonusSize); TQPixmap pix(size + bonusSize);
pix.fill(Qt::magenta); // Watch for incoming hacks pix.fill(TQt::magenta); // Watch for incoming hacks
QPainter painter(&pix); TQPainter painter(&pix);
painter.setFont(font); painter.setFont(font);
// Outline black, background white // Outline black, background white
painter.setPen(Qt::black); painter.setPen(TQt::black);
painter.setBrush(background); painter.setBrush(background);
// roundRect is annoying in that the four "pies" in each corner aren't // roundRect is annoying in that the four "pies" in each corner aren't
@ -64,19 +64,19 @@ QPixmap makePixmap(const QString &text, const QFont &font)
int textLeft = height / 2; int textLeft = height / 2;
// Draw text // Draw text
painter.setPen(Qt::black); painter.setPen(TQt::black);
painter.drawText(textLeft, height / 4, size.width(), size.height(), 0, text); painter.drawText(textLeft, height / 4, size.width(), size.height(), 0, text);
QImage overlay(pix.convertToImage()); TQImage overlay(pix.convertToImage());
// The images should have the same size, copy pixels from overlay to the // The images should have the same size, copy pixels from overlay to the
// bottom unless the pixel is called magenta. The pixels we don't copy // bottom unless the pixel is called magenta. The pixels we don't copy
// are transparent in the QImage, and will remain transparent when // are transparent in the TQImage, and will remain transparent when
// converted to a QPixmap. // converted to a TQPixmap.
for(int i = 0; i < image.width(); ++i) for(int i = 0; i < image.width(); ++i)
for(int j = 0; j < image.height(); ++j) { for(int j = 0; j < image.height(); ++j) {
if(QColor(overlay.pixel(i, j)) != Qt::magenta) if(TQColor(overlay.pixel(i, j)) != TQt::magenta)
image.setPixel(i, j, overlay.pixel(i, j)); image.setPixel(i, j, overlay.pixel(i, j));
} }

@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
class QPixmap; class TQPixmap;
class QString; class TQString;
class QFont; class TQFont;
namespace DragSupport { namespace DragSupport {
QPixmap makePixmap(const QString &text, const QFont &font); TQPixmap makePixmap(const TQString &text, const TQFont &font);
} }
#endif #endif

@ -25,23 +25,23 @@
#include "evaluator.h" #include "evaluator.h"
#include "result.h" #include "result.h"
#include <qapplication.h> #include <tqapplication.h>
#include <qlabel.h> #include <tqlabel.h>
#include <qlineedit.h> #include <tqlineedit.h>
#include <qlistbox.h> #include <tqlistbox.h>
#include <qpainter.h> #include <tqpainter.h>
#include <qregexp.h> #include <tqregexp.h>
#include <qstringlist.h> #include <tqstringlist.h>
#include <qstyle.h> #include <tqstyle.h>
#include <qsyntaxhighlighter.h> #include <tqsyntaxhighlighter.h>
#include <qtimer.h> #include <tqtimer.h>
#include <qtooltip.h> #include <tqtooltip.h>
#include <qmessagebox.h> #include <tqmessagebox.h>
#include <qvbox.h> #include <tqvbox.h>
#include <netwm.h> #include <netwm.h>
#include <fixx11h.h> // netwm.h includes X11 headers which conflict with qevent #include <fixx11h.h> // netwm.h includes X11 headers which conflict with qevent
#include <qevent.h> #include <tqevent.h>
#include <kdebug.h> #include <kdebug.h>
@ -50,26 +50,26 @@
// XXX: QT 4: Replace this with qBinaryFind(). // XXX: QT 4: Replace this with qBinaryFind().
using std::binary_search; using std::binary_search;
class CalcResultLabel : public QLabel class CalcResultLabel : public TQLabel
{ {
public: public:
CalcResultLabel(QWidget *parent, const char *name, int WFlags) : CalcResultLabel(TQWidget *tqparent, const char *name, int WFlags) :
QLabel(parent, name, WFlags) TQLabel(tqparent, name, WFlags)
{ {
} }
protected: protected:
virtual void mousePressEvent(QMouseEvent *) virtual void mousePressEvent(TQMouseEvent *)
{ {
hide(); hide();
} }
}; };
class EditorHighlighter : public QSyntaxHighlighter class EditorHighlighter : public TQSyntaxHighlighter
{ {
public: public:
EditorHighlighter( Editor* ); EditorHighlighter( Editor* );
int highlightParagraph ( const QString & text, int ); int highlightParagraph ( const TQString & text, int );
private: private:
Editor* editor; Editor* editor;
@ -79,50 +79,50 @@ class Editor::Private
{ {
public: public:
Evaluator* eval; Evaluator* eval;
QStringList history; TQStringList history;
int index; int index;
bool autoCompleteEnabled; bool autoCompleteEnabled;
EditorCompletion* completion; EditorCompletion* completion;
QTimer* completionTimer; TQTimer* completionTimer;
bool autoCalcEnabled; bool autoCalcEnabled;
char format; char format;
int decimalDigits; int decimalDigits;
QTimer* autoCalcTimer; TQTimer* autoCalcTimer;
QLabel* autoCalcLabel; TQLabel* autoCalcLabel;
bool syntaxHighlightEnabled; bool syntaxHighlightEnabled;
EditorHighlighter* highlighter; EditorHighlighter* highlighter;
QMap<ColorType,QColor> highlightColors; TQMap<ColorType,TQColor> highlightColors;
QTimer* matchingTimer; TQTimer* matchingTimer;
}; };
class EditorCompletion::Private class EditorCompletion::Private
{ {
public: public:
Editor* editor; Editor* editor;
QVBox *completionPopup; TQVBox *completionPopup;
QListBox *completionListBox; TQListBox *completionListBox;
}; };
class ChoiceItem: public QListBoxText class ChoiceItem: public TQListBoxText
{ {
public: public:
ChoiceItem( QListBox*, const QString& ); ChoiceItem( TQListBox*, const TQString& );
void setMinNameWidth (int w) { minNameWidth = w; } void setMinNameWidth (int w) { minNameWidth = w; }
int nameWidth() const; int nameWidth() const;
protected: protected:
void paint( QPainter* p ); void paint( TQPainter* p );
private: private:
QString item; TQString item;
QString desc; TQString desc;
int minNameWidth; int minNameWidth;
}; };
ChoiceItem::ChoiceItem( QListBox* listBox, const QString& text ): ChoiceItem::ChoiceItem( TQListBox* listBox, const TQString& text ):
QListBoxText( listBox, text ), minNameWidth(0) TQListBoxText( listBox, text ), minNameWidth(0)
{ {
QStringList list = QStringList::split( ':', text ); TQStringList list = TQStringList::split( ':', text );
if( list.count() ) item = list[0]; if( list.count() ) item = list[0];
if( list.count()>1 ) desc = list[1]; if( list.count()>1 ) desc = list[1];
} }
@ -133,48 +133,48 @@ int ChoiceItem::nameWidth() const
if(item.isEmpty()) if(item.isEmpty())
return 0; return 0;
QFontMetrics fm = listBox()->fontMetrics(); TQFontMetrics fm = listBox()->fontMetrics();
return fm.width( item ); return fm.width( item );
} }
void ChoiceItem::paint( QPainter* painter ) void ChoiceItem::paint( TQPainter* painter )
{ {
int itemHeight = height( listBox() ); int itemHeight = height( listBox() );
QFontMetrics fm = painter->fontMetrics(); TQFontMetrics fm = painter->fontMetrics();
int yPos = ( ( itemHeight - fm.height() ) / 2 ) + fm.ascent(); int yPos = ( ( itemHeight - fm.height() ) / 2 ) + fm.ascent();
painter->drawText( 3, yPos, item ); painter->drawText( 3, yPos, item );
//int xPos = fm.width( item ); //int xPos = fm.width( item );
int xPos = QMAX(fm.width(item), minNameWidth); int xPos = TQMAX(fm.width(item), minNameWidth);
if( !isSelected() ) if( !isSelected() )
painter->setPen( listBox()->palette().disabled().text().dark() ); painter->setPen( listBox()->tqpalette().disabled().text().dark() );
painter->drawText( 10 + xPos, yPos, desc ); painter->drawText( 10 + xPos, yPos, desc );
} }
EditorHighlighter::EditorHighlighter( Editor* e ): EditorHighlighter::EditorHighlighter( Editor* e ):
QSyntaxHighlighter( e ) TQSyntaxHighlighter( e )
{ {
editor = e; editor = e;
} }
int EditorHighlighter::highlightParagraph ( const QString & text, int ) int EditorHighlighter::highlightParagraph ( const TQString & text, int )
{ {
if( !editor->isSyntaxHighlightEnabled() ) if( !editor->isSyntaxHighlightEnabled() )
{ {
setFormat( 0, text.length(), editor->colorGroup().text() ); setFormat( 0, text.length(), editor->tqcolorGroup().text() );
return 0; return 0;
} }
QStringList fnames = FunctionManager::instance()->functionList(FunctionManager::All); TQStringList fnames = FunctionManager::instance()->functionList(FunctionManager::All);
fnames.sort(); // Sort list so we can bin search it. fnames.sort(); // Sort list so we can bin search it.
Tokens tokens = Evaluator::scan( text ); Tokens tokens = Evaluator::scan( text );
for( unsigned i = 0; i < tokens.count(); i++ ) for( unsigned i = 0; i < tokens.count(); i++ )
{ {
Token& token = tokens[i]; Token& token = tokens[i];
QString text = token.text().lower(); TQString text = token.text().lower();
QFont font = editor->font(); TQFont font = editor->font();
QColor color = Qt::black; TQColor color = TQt::black;
switch( token.type() ) switch( token.type() )
{ {
case Token::Number: case Token::Number:
@ -204,22 +204,22 @@ int EditorHighlighter::highlightParagraph ( const QString & text, int )
Editor::Editor( QWidget* parent, const char* name ): Editor::Editor( TQWidget* tqparent, const char* name ):
QTextEdit( parent, name ) TQTextEdit( tqparent, name )
{ {
d = new Private; d = new Private;
d->eval = 0; d->eval = 0;
d->index = 0; d->index = 0;
d->autoCompleteEnabled = true; d->autoCompleteEnabled = true;
d->completion = new EditorCompletion( this ); d->completion = new EditorCompletion( this );
d->completionTimer = new QTimer( this ); d->completionTimer = new TQTimer( this );
d->autoCalcEnabled = true; d->autoCalcEnabled = true;
d->syntaxHighlightEnabled = true; d->syntaxHighlightEnabled = true;
d->highlighter = new EditorHighlighter( this ); d->highlighter = new EditorHighlighter( this );
d->autoCalcTimer = new QTimer( this ); d->autoCalcTimer = new TQTimer( this );
d->matchingTimer = new QTimer( this ); d->matchingTimer = new TQTimer( this );
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); tqsetSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed );
setWordWrap( NoWrap ); setWordWrap( NoWrap );
setHScrollBarMode( AlwaysOff ); setHScrollBarMode( AlwaysOff );
setVScrollBarMode( AlwaysOff ); setVScrollBarMode( AlwaysOff );
@ -228,26 +228,26 @@ Editor::Editor( QWidget* parent, const char* name ):
setTabChangesFocus( true ); setTabChangesFocus( true );
setLinkUnderline( false ); setLinkUnderline( false );
connect( d->completion, SIGNAL( selectedCompletion( const QString& ) ), connect( d->completion, TQT_SIGNAL( selectedCompletion( const TQString& ) ),
SLOT( autoComplete( const QString& ) ) ); TQT_SLOT( autoComplete( const TQString& ) ) );
connect( this, SIGNAL( textChanged() ), SLOT( checkAutoComplete() ) ); connect( this, TQT_SIGNAL( textChanged() ), TQT_SLOT( checkAutoComplete() ) );
connect( d->completionTimer, SIGNAL( timeout() ), SLOT( triggerAutoComplete() ) ); connect( d->completionTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( triggerAutoComplete() ) );
connect( this, SIGNAL( textChanged() ), SLOT( checkMatching() ) ); connect( this, TQT_SIGNAL( textChanged() ), TQT_SLOT( checkMatching() ) );
connect( d->matchingTimer, SIGNAL( timeout() ), SLOT( doMatchingLeft() ) ); connect( d->matchingTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( doMatchingLeft() ) );
connect( d->matchingTimer, SIGNAL( timeout() ), SLOT( doMatchingRight() ) ); connect( d->matchingTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( doMatchingRight() ) );
connect( this, SIGNAL( textChanged() ), SLOT( checkAutoCalc() ) ); connect( this, TQT_SIGNAL( textChanged() ), TQT_SLOT( checkAutoCalc() ) );
connect( d->autoCalcTimer, SIGNAL( timeout() ), SLOT( autoCalc() ) ); connect( d->autoCalcTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( autoCalc() ) );
d->autoCalcLabel = new CalcResultLabel( 0, "autocalc", WStyle_StaysOnTop | d->autoCalcLabel = new CalcResultLabel( 0, "autocalc", WStyle_StaysOnTop |
WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WX11BypassWM ); WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WX11BypassWM );
d->autoCalcLabel->setFrameStyle( QFrame::Plain | QFrame::Box ); d->autoCalcLabel->setFrameStyle( TQFrame::Plain | TQFrame::Box );
d->autoCalcLabel->setPalette( QToolTip::palette() ); d->autoCalcLabel->setPalette( TQToolTip::palette() );
d->autoCalcLabel->hide(); d->autoCalcLabel->hide();
setHighlightColor( Number, QColor(0,0,127) ); setHighlightColor( Number, TQColor(0,0,127) );
setHighlightColor( FunctionName, QColor(85,0,0) ); setHighlightColor( FunctionName, TQColor(85,0,0) );
setHighlightColor( Variable, QColor(0,85,0) ); setHighlightColor( Variable, TQColor(0,85,0) );
setHighlightColor( MatchedPar, QColor(255,255,183) ); setHighlightColor( MatchedPar, TQColor(255,255,183) );
} }
Editor::~Editor() Editor::~Editor()
@ -256,24 +256,24 @@ Editor::~Editor()
delete d; delete d;
} }
QSize Editor::sizeHint() const TQSize Editor::tqsizeHint() const
{ {
constPolish(); constPolish();
QFontMetrics fm = fontMetrics(); TQFontMetrics fm = fontMetrics();
int h = QMAX(fm.lineSpacing(), 14); int h = TQMAX(fm.lineSpacing(), 14);
int w = fm.width( 'x' ) * 20; int w = fm.width( 'x' ) * 20;
int m = frameWidth() * 2; int m = frameWidth() * 2;
return( style().sizeFromContents(QStyle::CT_LineEdit, this, return( tqstyle().tqsizeFromContents(TQStyle::CT_LineEdit, this,
QSize( w + m, h + m + 4 ). TQSize( w + m, h + m + 4 ).
expandedTo(QApplication::globalStrut()))); expandedTo(TQApplication::globalStrut())));
} }
QStringList Editor::history() const TQStringList Editor::history() const
{ {
return d->history; return d->history;
} }
void Editor::setHistory( const QStringList& h ) void Editor::setHistory( const TQStringList& h )
{ {
d->history = h; d->history = h;
d->index = d->history.count(); d->index = d->history.count();
@ -309,11 +309,11 @@ void Editor::setDecimalDigits( int digits )
d->decimalDigits = digits; d->decimalDigits = digits;
} }
void Editor::appendHistory( const QString& text ) void Editor::appendHistory( const TQString& text )
{ {
if( text.isEmpty() ) return; if( text.isEmpty() ) return;
QString lastText; TQString lastText;
if( d->history.count() ) if( d->history.count() )
lastText = d->history[ d->history.count()-1 ]; lastText = d->history[ d->history.count()-1 ];
if( text == lastText ) return; if( text == lastText ) return;
@ -333,9 +333,9 @@ void Editor::squelchNextAutoCalc()
d->autoCalcTimer->stop(); d->autoCalcTimer->stop();
} }
void Editor::setText(const QString &txt) void Editor::setText(const TQString &txt)
{ {
QTextEdit::setText(txt); TQTextEdit::setText(txt);
squelchNextAutoCalc(); squelchNextAutoCalc();
} }
@ -374,7 +374,7 @@ void Editor::doMatchingLeft()
getCursorPosition( &para, &curPos ); getCursorPosition( &para, &curPos );
// check for right par // check for right par
QString subtext = text().left( curPos ); TQString subtext = text().left( curPos );
Tokens tokens = Evaluator::scan( subtext ); Tokens tokens = Evaluator::scan( subtext );
if( !tokens.valid() ) return; if( !tokens.valid() ) return;
if( tokens.count()<1 ) return; if( tokens.count()<1 ) return;
@ -423,7 +423,7 @@ void Editor::doMatchingRight()
getCursorPosition( &para, &curPos ); getCursorPosition( &para, &curPos );
// check for left par // check for left par
QString subtext = text().right( text().length() - curPos ); TQString subtext = text().right( text().length() - curPos );
Tokens tokens = Evaluator::scan( subtext ); Tokens tokens = Evaluator::scan( subtext );
if( !tokens.valid() ) return; if( !tokens.valid() ) return;
if( tokens.count()<1 ) return; if( tokens.count()<1 ) return;
@ -472,7 +472,7 @@ void Editor::triggerAutoComplete()
// faster now that it uses flex. ;) // faster now that it uses flex. ;)
int para = 0, curPos = 0; int para = 0, curPos = 0;
getCursorPosition( &para, &curPos ); getCursorPosition( &para, &curPos );
QString subtext = text().left( curPos ); TQString subtext = text().left( curPos );
Tokens tokens = Evaluator::scan( subtext ); Tokens tokens = Evaluator::scan( subtext );
if(!tokens.valid()) if(!tokens.valid())
{ {
@ -489,18 +489,18 @@ void Editor::triggerAutoComplete()
if( !lastToken.isIdentifier() ) if( !lastToken.isIdentifier() )
return; return;
QString id = lastToken.text(); TQString id = lastToken.text();
if( id.isEmpty() ) if( id.isEmpty() )
return; return;
// find matches in function names // find matches in function names
QStringList fnames = FunctionManager::instance()->functionList(FunctionManager::All); TQStringList fnames = FunctionManager::instance()->functionList(FunctionManager::All);
QStringList choices; TQStringList choices;
for( unsigned i=0; i<fnames.count(); i++ ) for( unsigned i=0; i<fnames.count(); i++ )
if( fnames[i].startsWith( id, false ) ) if( fnames[i].tqstartsWith( id, false ) )
{ {
QString str = fnames[i]; TQString str = fnames[i];
::Function* f = FunctionManager::instance()->function( str ); ::Function* f = FunctionManager::instance()->function( str );
if( f && !f->description.isEmpty() ) if( f && !f->description.isEmpty() )
@ -512,17 +512,17 @@ void Editor::triggerAutoComplete()
choices.sort(); choices.sort();
// find matches in variables names // find matches in variables names
QStringList vchoices; TQStringList vchoices;
QStringList values = ValueManager::instance()->valueNames(); TQStringList values = ValueManager::instance()->valueNames();
for(QStringList::ConstIterator it = values.begin(); it != values.end(); ++it) for(TQStringList::ConstIterator it = values.begin(); it != values.end(); ++it)
if( (*it).startsWith( id, false ) ) if( (*it).tqstartsWith( id, false ) )
{ {
QString choice = ValueManager::description(*it); TQString choice = ValueManager::description(*it);
if(choice.isEmpty()) if(choice.isEmpty())
choice = ValueManager::instance()->value(*it).toString(); choice = ValueManager::instance()->value(*it).toString();
vchoices.append( QString("%1:%2").arg( *it, choice ) ); vchoices.append( TQString("%1:%2").tqarg( *it, choice ) );
} }
vchoices.sort(); vchoices.sort();
@ -534,7 +534,7 @@ void Editor::triggerAutoComplete()
// one match, complete it for the user // one match, complete it for the user
if( choices.count()==1 ) if( choices.count()==1 )
{ {
QString str = QStringList::split( ':', choices[0] )[0]; TQString str = TQStringList::split( ':', choices[0] )[0];
// single perfect match, no need to give choices. // single perfect match, no need to give choices.
if(str == id.lower()) if(str == id.lower())
@ -554,7 +554,7 @@ void Editor::triggerAutoComplete()
d->completion->showCompletion( choices ); d->completion->showCompletion( choices );
} }
void Editor::autoComplete( const QString& item ) void Editor::autoComplete( const TQString& item )
{ {
if( !d->autoCompleteEnabled || item.isEmpty() ) if( !d->autoCompleteEnabled || item.isEmpty() )
return; return;
@ -562,7 +562,7 @@ void Editor::autoComplete( const QString& item )
int para = 0, curPos = 0; int para = 0, curPos = 0;
getCursorPosition( &para, &curPos ); getCursorPosition( &para, &curPos );
QString subtext = text().left( curPos ); TQString subtext = text().left( curPos );
Tokens tokens = Evaluator::scan( subtext ); Tokens tokens = Evaluator::scan( subtext );
if( !tokens.valid() || tokens.count() < 1 ) if( !tokens.valid() || tokens.count() < 1 )
@ -572,7 +572,7 @@ void Editor::autoComplete( const QString& item )
if( !lastToken.isIdentifier() ) if( !lastToken.isIdentifier() )
return; return;
QStringList str = QStringList::split( ':', item ); TQStringList str = TQStringList::split( ':', item );
blockSignals( true ); blockSignals( true );
setSelection( 0, lastToken.pos(), 0, lastToken.pos()+lastToken.text().length() ); setSelection( 0, lastToken.pos(), 0, lastToken.pos()+lastToken.text().length() );
@ -585,7 +585,7 @@ void Editor::autoCalc()
if( !d->autoCalcEnabled ) if( !d->autoCalcEnabled )
return; return;
QString str = Evaluator::autoFix( text() ); TQString str = Evaluator::autoFix( text() );
if( str.isEmpty() ) if( str.isEmpty() )
return; return;
@ -595,8 +595,8 @@ void Editor::autoCalc()
return; return;
// If we're using set for a function don't try. // If we're using set for a function don't try.
QRegExp setFn("\\s*set.*\\(.*="); TQRegExp setFn("\\s*set.*\\(.*=");
if( str.find(setFn) != -1 ) if( str.tqfind(setFn) != -1 )
return; return;
// strip off assignment operator, e.g. "x=1+2" becomes "1+2" only // strip off assignment operator, e.g. "x=1+2" becomes "1+2" only
@ -622,19 +622,19 @@ void Editor::autoCalc()
Abakus::number_t result = parseString(str.latin1()); Abakus::number_t result = parseString(str.latin1());
if( Result::lastResult()->type() == Result::Value ) if( Result::lastResult()->type() == Result::Value )
{ {
QString ss = QString("Result: <b>%2</b>").arg(result.toString()); TQString ss = TQString("Result: <b>%2</b>").tqarg(result.toString());
d->autoCalcLabel->setText( ss ); d->autoCalcLabel->setText( ss );
d->autoCalcLabel->adjustSize(); d->autoCalcLabel->adjustSize();
// reposition nicely // reposition nicely
QPoint pos = mapToGlobal( QPoint( 0, 0 ) ); TQPoint pos = mapToGlobal( TQPoint( 0, 0 ) );
pos.setY( pos.y() - d->autoCalcLabel->height() - 1 ); pos.setY( pos.y() - d->autoCalcLabel->height() - 1 );
d->autoCalcLabel->move( pos ); d->autoCalcLabel->move( pos );
d->autoCalcLabel->show(); d->autoCalcLabel->show();
d->autoCalcLabel->raise(); d->autoCalcLabel->raise();
// do not show it forever // do not show it forever
QTimer::singleShot( 5000, d->autoCalcLabel, SLOT( hide()) ); TQTimer::singleShot( 5000, d->autoCalcLabel, TQT_SLOT( hide()) );
} }
else else
{ {
@ -643,7 +643,7 @@ void Editor::autoCalc()
} }
} }
QString Editor::formatNumber( const Abakus::number_t &value ) const TQString Editor::formatNumber( const Abakus::number_t &value ) const
{ {
return value.toString(); return value.toString();
} }
@ -678,7 +678,7 @@ void Editor::historyForward()
ensureCursorVisible(); ensureCursorVisible();
} }
void Editor::keyPressEvent( QKeyEvent* e ) void Editor::keyPressEvent( TQKeyEvent* e )
{ {
if( e->key() == Key_Up ) if( e->key() == Key_Up )
{ {
@ -708,10 +708,10 @@ void Editor::keyPressEvent( QKeyEvent* e )
checkMatching(); checkMatching();
} }
QTextEdit::keyPressEvent( e ); TQTextEdit::keyPressEvent( e );
} }
void Editor::wheelEvent( QWheelEvent *e ) void Editor::wheelEvent( TQWheelEvent *e )
{ {
if( e->delta() > 0 ) if( e->delta() > 0 )
historyBack(); historyBack();
@ -732,7 +732,7 @@ bool Editor::isSyntaxHighlightEnabled() const
return d->syntaxHighlightEnabled; return d->syntaxHighlightEnabled;
} }
void Editor::setHighlightColor( ColorType type, QColor color ) void Editor::setHighlightColor( ColorType type, TQColor color )
{ {
d->highlightColors[ type ] = color; d->highlightColors[ type ] = color;
@ -742,26 +742,26 @@ void Editor::setHighlightColor( ColorType type, QColor color )
d->highlighter->rehighlight(); d->highlighter->rehighlight();
} }
QColor Editor::highlightColor( ColorType type ) TQColor Editor::highlightColor( ColorType type )
{ {
return d->highlightColors[ type ]; return d->highlightColors[ type ];
} }
EditorCompletion::EditorCompletion( Editor* editor ): QObject( editor ) EditorCompletion::EditorCompletion( Editor* editor ): TQObject( editor )
{ {
d = new Private; d = new Private;
d->editor = editor; d->editor = editor;
d->completionPopup = new QVBox( editor->topLevelWidget(), 0, WType_Popup ); d->completionPopup = new TQVBox( editor->tqtopLevelWidget(), 0, WType_Popup );
d->completionPopup->setFrameStyle( QFrame::Box | QFrame::Plain ); d->completionPopup->setFrameStyle( TQFrame::Box | TQFrame::Plain );
d->completionPopup->setLineWidth( 1 ); d->completionPopup->setLineWidth( 1 );
d->completionPopup->installEventFilter( this ); d->completionPopup->installEventFilter( this );
d->completionPopup->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum); d->completionPopup->tqsetSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Minimum);
d->completionListBox = new QListBox( d->completionPopup ); d->completionListBox = new TQListBox( d->completionPopup );
d->completionPopup->setFocusProxy( d->completionListBox ); d->completionPopup->setFocusProxy( d->completionListBox );
d->completionListBox->setFrameStyle( QFrame::NoFrame ); d->completionListBox->setFrameStyle( TQFrame::NoFrame );
d->completionListBox->setVariableWidth( true ); d->completionListBox->setVariableWidth( true );
d->completionListBox->installEventFilter( this ); d->completionListBox->installEventFilter( this );
} }
@ -771,14 +771,14 @@ EditorCompletion::~EditorCompletion()
delete d; delete d;
} }
bool EditorCompletion::eventFilter( QObject *obj, QEvent *ev ) bool EditorCompletion::eventFilter( TQObject *obj, TQEvent *ev )
{ {
if ( obj == d->completionPopup || obj == d->completionListBox ) if ( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(d->completionPopup) || TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(d->completionListBox) )
{ {
if ( ev->type() == QEvent::KeyPress ) if ( ev->type() == TQEvent::KeyPress )
{ {
QKeyEvent *ke = (QKeyEvent*)ev; TQKeyEvent *ke = (TQKeyEvent*)ev;
if ( ke->key() == Key_Enter || ke->key() == Key_Return ) if ( ke->key() == Key_Enter || ke->key() == Key_Return )
{ {
doneCompletion(); doneCompletion();
@ -792,11 +792,11 @@ bool EditorCompletion::eventFilter( QObject *obj, QEvent *ev )
d->completionPopup->close(); d->completionPopup->close();
d->editor->setFocus(); d->editor->setFocus();
QApplication::sendEvent( d->editor, ev ); TQApplication::sendEvent( d->editor, ev );
return true; return true;
} }
if ( ev->type() == QEvent::MouseButtonDblClick ) if ( ev->type() == TQEvent::MouseButtonDblClick )
{ {
doneCompletion(); doneCompletion();
return true; return true;
@ -814,7 +814,7 @@ void EditorCompletion::doneCompletion()
emit selectedCompletion( d->completionListBox->currentText() ); emit selectedCompletion( d->completionListBox->currentText() );
} }
void EditorCompletion::showCompletion( const QStringList &choices ) void EditorCompletion::showCompletion( const TQStringList &choices )
{ {
static bool shown = false; static bool shown = false;
if( !choices.count() ) return; if( !choices.count() ) return;
@ -838,14 +838,14 @@ void EditorCompletion::showCompletion( const QStringList &choices )
// size of the pop-up // size of the pop-up
d->completionPopup->setMaximumHeight( 120 ); d->completionPopup->setMaximumHeight( 120 );
d->completionPopup->resize( d->completionListBox->sizeHint() + d->completionPopup->resize( d->completionListBox->tqsizeHint() +
QSize( d->completionListBox->verticalScrollBar()->width() + 4, TQSize( d->completionListBox->verticalScrollBar()->width() + 4,
d->completionListBox->horizontalScrollBar()->height() + 4 ) ); d->completionListBox->horizontalScrollBar()->height() + 4 ) );
if(!shown) if(!shown)
{ {
d->completionPopup->show(); d->completionPopup->show();
QTimer::singleShot ( 0, this, SLOT(moveCompletionPopup()) ); TQTimer::singleShot ( 0, this, TQT_SLOT(moveCompletionPopup()) );
} }
else else
{ {
@ -860,14 +860,14 @@ void EditorCompletion::moveCompletionPopup()
int w = d->completionListBox->width(); int w = d->completionListBox->width();
// position, reference is editor's cursor position in global coord // position, reference is editor's cursor position in global coord
QFontMetrics fm( d->editor->font() ); TQFontMetrics fm( d->editor->font() );
int para = 0, curPos = 0; int para = 0, curPos = 0;
d->editor->getCursorPosition( &para, &curPos ); d->editor->getCursorPosition( &para, &curPos );
int pixelsOffset = fm.width( d->editor->text(), curPos ); int pixelsOffset = fm.width( d->editor->text(), curPos );
pixelsOffset -= d->editor->contentsX(); pixelsOffset -= d->editor->contentsX();
QPoint pos = d->editor->mapToGlobal( QPoint( pixelsOffset, d->editor->height() ) ); TQPoint pos = d->editor->mapToGlobal( TQPoint( pixelsOffset, d->editor->height() ) );
// if popup is partially invisible, move to other position // if popup is partially invisible, move to other position
NETRootInfo info(d->completionPopup->x11Display(), NETRootInfo info(d->completionPopup->x11Display(),
@ -876,7 +876,7 @@ void EditorCompletion::moveCompletionPopup()
info.activate(); // wtf is this needed for? info.activate(); // wtf is this needed for?
NETRect NETarea = info.workArea(info.currentDesktop()); NETRect NETarea = info.workArea(info.currentDesktop());
QRect area(NETarea.pos.x, NETarea.pos.y, NETarea.size.width, NETarea.size.height); TQRect area(NETarea.pos.x, NETarea.pos.y, NETarea.size.width, NETarea.size.height);
if( pos.y() + h > area.y() + area.height() ) if( pos.y() + h > area.y() + area.height() )
pos.setY( pos.y() - h - d->editor->height() ); pos.setY( pos.y() - h - d->editor->height() );

@ -23,20 +23,21 @@
#ifndef ABAKUS_EDITOR_H #ifndef ABAKUS_EDITOR_H
#define ABAKUS_EDITOR_H #define ABAKUS_EDITOR_H
#include <qobject.h> #include <tqobject.h>
#include <qstringlist.h> #include <tqstringlist.h>
#include <qtextedit.h> #include <tqtextedit.h>
#include "hmath.h" #include "hmath.h"
class QEvent; class TQEvent;
class QKeyEvent; class TQKeyEvent;
class QWidget; class TQWidget;
class Evaluator; class Evaluator;
class Editor : public QTextEdit class Editor : public TQTextEdit
{ {
Q_OBJECT Q_OBJECT
TQ_OBJECT
public: public:
@ -45,14 +46,14 @@ class Editor : public QTextEdit
Number, FunctionName, Variable, MatchedPar Number, FunctionName, Variable, MatchedPar
} ColorType; } ColorType;
Editor( QWidget* parent = 0, const char* name = 0 ); Editor( TQWidget* tqparent = 0, const char* name = 0 );
~Editor(); ~Editor();
QSize sizeHint() const; TQSize tqsizeHint() const;
QSize xminimumSizeHint() const; TQSize xtqminimumSizeHint() const;
QStringList history() const; TQStringList history() const;
void setHistory( const QStringList& history ); void setHistory( const TQStringList& history );
bool autoCompleteEnabled() const; bool autoCompleteEnabled() const;
void setAutoCompleteEnabled( bool enable ); void setAutoCompleteEnabled( bool enable );
@ -64,22 +65,22 @@ class Editor : public QTextEdit
void setSyntaxHighlight( bool enable ); void setSyntaxHighlight( bool enable );
bool isSyntaxHighlightEnabled() const; bool isSyntaxHighlightEnabled() const;
void setHighlightColor( ColorType type, QColor color ); void setHighlightColor( ColorType type, TQColor color );
QColor highlightColor( ColorType type ); TQColor highlightColor( ColorType type );
public slots: public slots:
void appendHistory( const QString& text ); void appendHistory( const TQString& text );
void clearHistory(); void clearHistory();
// Stop the timer from going off. // Stop the timer from going off.
void squelchNextAutoCalc(); void squelchNextAutoCalc();
void setText(const QString &txt); void setText(const TQString &txt);
protected slots: protected slots:
void checkAutoComplete(); void checkAutoComplete();
void triggerAutoComplete(); void triggerAutoComplete();
void autoComplete( const QString& item ); void autoComplete( const TQString& item );
void checkAutoCalc(); void checkAutoCalc();
void autoCalc(); void autoCalc();
void checkMatching(); void checkMatching();
@ -89,9 +90,9 @@ class Editor : public QTextEdit
void historyForward(); void historyForward();
protected: protected:
void keyPressEvent( QKeyEvent* ); void keyPressEvent( TQKeyEvent* );
void wheelEvent( QWheelEvent* ); void wheelEvent( TQWheelEvent* );
QString formatNumber( const Abakus::number_t &value ) const; TQString formatNumber( const Abakus::number_t &value ) const;
private: private:
class Private; class Private;
@ -101,23 +102,24 @@ class Editor : public QTextEdit
}; };
class EditorCompletion : public QObject class EditorCompletion : public TQObject
{ {
Q_OBJECT Q_OBJECT
TQ_OBJECT
public: public:
EditorCompletion( Editor* editor ); EditorCompletion( Editor* editor );
~EditorCompletion(); ~EditorCompletion();
bool eventFilter( QObject *o, QEvent *e ); bool eventFilter( TQObject *o, TQEvent *e );
void doneCompletion(); void doneCompletion();
void showCompletion( const QStringList &choices ); void showCompletion( const TQStringList &choices );
protected slots: protected slots:
void moveCompletionPopup(); void moveCompletionPopup();
signals: signals:
void selectedCompletion( const QString& item ); void selectedCompletion( const TQString& item );
private: private:
class Private; class Private;

@ -24,11 +24,11 @@
#include "node.h" // For parser_yacc.hpp below #include "node.h" // For parser_yacc.hpp below
#include "parser_yacc.hpp" #include "parser_yacc.hpp"
#include <qapplication.h> #include <tqapplication.h>
#include <qmap.h> #include <tqmap.h>
#include <qstring.h> #include <tqstring.h>
#include <qstringlist.h> #include <tqstringlist.h>
#include <qvaluevector.h> #include <tqvaluevector.h>
#include <kdebug.h> #include <kdebug.h>
@ -44,15 +44,15 @@ Evaluator::~Evaluator()
{ {
} }
void Evaluator::setExpression(const QString &expr) void Evaluator::setExpression(const TQString &expr)
{ {
kdError() << k_funcinfo << " not implemented.\n"; kdError() << k_funcinfo << " not implemented.\n";
} }
QString Evaluator::expression() const TQString Evaluator::expression() const
{ {
kdError() << k_funcinfo << " not implemented.\n"; kdError() << k_funcinfo << " not implemented.\n";
return QString(); return TQString();
} }
void Evaluator::clear() void Evaluator::clear()
@ -72,7 +72,7 @@ Tokens Evaluator::tokens() const
return Tokens(); return Tokens();
} }
Tokens Evaluator::scan(const QString &expr) Tokens Evaluator::scan(const TQString &expr)
{ {
Lexer l(expr); Lexer l(expr);
Tokens tokens; Tokens tokens;
@ -118,7 +118,7 @@ Tokens Evaluator::scan(const QString &expr)
return tokens; return tokens;
} }
QString Evaluator::error() const TQString Evaluator::error() const
{ {
kdError() << k_funcinfo << " not implemented.\n"; kdError() << k_funcinfo << " not implemented.\n";
return "No Error Yet"; return "No Error Yet";
@ -133,14 +133,14 @@ const Token Token::null;
// helper function: return operator of given token text // helper function: return operator of given token text
// e.g. "*" yields Operator::Asterisk, and so on // e.g. "*" yields Operator::Asterisk, and so on
static Token::Op matchOperator( const QString& text ) static Token::Op matchOperator( const TQString& text )
{ {
Token::Op result = Token::InvalidOp; Token::Op result = Token::InvalidOp;
if( text.length() == 1 ) if( text.length() == 1 )
{ {
QChar p = text[0]; TQChar p = text[0];
switch( p.unicode() ) switch( p.tqunicode() )
{ {
case '+': result = Token::Plus; break; case '+': result = Token::Plus; break;
case '-': result = Token::Minus; break; case '-': result = Token::Minus; break;
@ -165,7 +165,7 @@ static Token::Op matchOperator( const QString& text )
} }
// creates a token // creates a token
Token::Token( Type type, const QString& text, int pos ) Token::Token( Type type, const TQString& text, int pos )
{ {
m_type = type; m_type = type;
m_text = text; m_text = text;
@ -203,9 +203,9 @@ Token::Op Token::asOperator() const
else return InvalidOp; else return InvalidOp;
} }
QString Token::description() const TQString Token::description() const
{ {
QString desc; TQString desc;
switch (m_type ) switch (m_type )
{ {
@ -217,24 +217,24 @@ QString Token::description() const
while( desc.length() < 10 ) desc.prepend( ' ' ); while( desc.length() < 10 ) desc.prepend( ' ' );
desc.prepend( " " ); desc.prepend( " " );
desc.prepend( QString::number( m_pos ) ); desc.prepend( TQString::number( m_pos ) );
desc.append( " : " ).append( m_text ); desc.append( " : " ).append( m_text );
return desc; return desc;
} }
QString Evaluator::autoFix( const QString& expr ) TQString Evaluator::autoFix( const TQString& expr )
{ {
int par = 0; int par = 0;
QString result; TQString result;
// strip off all funny characters // strip off all funny characters
for( unsigned c = 0; c < expr.length(); c++ ) for( unsigned c = 0; c < expr.length(); c++ )
if( expr[c] >= QChar(32) ) if( expr[c] >= TQChar(32) )
result.append( expr[c] ); result.append( expr[c] );
// automagically close all parenthesis // automagically close all tqparenthesis
Tokens tokens = Evaluator::scan( result ); Tokens tokens = Evaluator::scan( result );
for( unsigned i=0; i<tokens.count(); i++ ) for( unsigned i=0; i<tokens.count(); i++ )
if( tokens[i].asOperator() == Token::LeftPar ) par++; if( tokens[i].asOperator() == Token::LeftPar ) par++;

@ -22,8 +22,8 @@
#ifndef ABAKUS_EVALUATOR_H #ifndef ABAKUS_EVALUATOR_H
#define ABAKUS_EVALUATOR_H #define ABAKUS_EVALUATOR_H
#include <qstring.h> #include <tqstring.h>
#include <qvaluevector.h> #include <tqvaluevector.h>
#include "numerictypes.h" #include "numerictypes.h"
@ -53,13 +53,13 @@ public:
Equal // variable assignment Equal // variable assignment
} Op; } Op;
Token( Type type = Unknown, const QString& text = QString::null, int pos = -1 ); Token( Type type = Unknown, const TQString& text = TQString(), int pos = -1 );
Token( const Token& ); Token( const Token& );
Token& operator=( const Token& ); Token& operator=( const Token& );
Type type() const { return m_type; } Type type() const { return m_type; }
QString text() const { return m_text; } TQString text() const { return m_text; }
int pos() const { return m_pos; }; int pos() const { return m_pos; };
bool isNumber() const { return m_type == Number; } bool isNumber() const { return m_type == Number; }
@ -69,21 +69,21 @@ public:
Abakus::number_t asNumber() const; Abakus::number_t asNumber() const;
Op asOperator() const; Op asOperator() const;
QString description() const; TQString description() const;
static const Token null; static const Token null;
protected: protected:
Type m_type; Type m_type;
QString m_text; TQString m_text;
int m_pos; int m_pos;
}; };
class Tokens: public QValueVector<Token> class Tokens: public TQValueVector<Token>
{ {
public: public:
Tokens(): QValueVector<Token>(), m_valid(true) {}; Tokens(): TQValueVector<Token>(), m_valid(true) {};
bool valid() const { return m_valid; } bool valid() const { return m_valid; }
void setValid( bool v ) { m_valid = v; } void setValid( bool v ) { m_valid = v; }
@ -95,7 +95,7 @@ protected:
class Variable class Variable
{ {
public: public:
QString name; TQString name;
Abakus::number_t value; Abakus::number_t value;
}; };
@ -105,20 +105,20 @@ public:
Evaluator(); Evaluator();
~Evaluator(); ~Evaluator();
void setExpression( const QString& expr ); void setExpression( const TQString& expr );
QString expression() const; TQString expression() const;
void clear(); void clear();
bool isValid() const; bool isValid() const;
Tokens tokens() const; Tokens tokens() const;
static Tokens scan( const QString& expr ); static Tokens scan( const TQString& expr );
QString error() const; TQString error() const;
// Abakus::number_t eval(); // Abakus::number_t eval();
static QString autoFix( const QString& expr ); static TQString autoFix( const TQString& expr );
private: private:
Evaluator( const Evaluator& ); Evaluator( const Evaluator& );

@ -20,9 +20,9 @@
#include <kdebug.h> #include <kdebug.h>
#include <qvaluevector.h> #include <tqvaluevector.h>
#include <qstring.h> #include <tqstring.h>
#include <qregexp.h> #include <tqregexp.h>
#include <math.h> #include <math.h>
@ -35,7 +35,7 @@
class DupFinder : public NodeFunctor class DupFinder : public NodeFunctor
{ {
public: public:
DupFinder(const QString &nameToFind) : DupFinder(const TQString &nameToFind) :
m_name(nameToFind), m_valid(true) m_name(nameToFind), m_valid(true)
{ {
} }
@ -55,7 +55,7 @@ class DupFinder : public NodeFunctor
} }
private: private:
QString m_name; TQString m_name;
bool m_valid; bool m_valid;
}; };
@ -70,27 +70,27 @@ FunctionManager *FunctionManager::instance()
return m_manager; return m_manager;
} }
FunctionManager::FunctionManager(QObject *parent, const char *name) : FunctionManager::FunctionManager(TQObject *tqparent, const char *name) :
QObject(parent, name) TQObject(tqparent, name)
{ {
m_dict.setAutoDelete(true); m_dict.setAutoDelete(true);
} }
// Dummy return value to enable static initialization in the DECL_*() // Dummy return value to enable static initialization in the DECL_*()
// macros. // macros.
bool FunctionManager::addFunction(const QString &name, function_t fn, const QString &desc) bool FunctionManager::addFunction(const TQString &name, function_t fn, const TQString &desc)
{ {
Function *newFn = new Function; Function *newFn = new Function;
QRegExp returnTrigRE("^a(cos|sin|tan)"); TQRegExp returnTrigRE("^a(cos|sin|tan)");
QRegExp needsTrigRE("^(cos|sin|tan)"); TQRegExp needsTrigRE("^(cos|sin|tan)");
QString fnName(name); TQString fnName(name);
newFn->name = name; newFn->name = name;
newFn->description = desc; newFn->description = desc;
newFn->fn = fn; newFn->fn = fn;
newFn->userDefined = false; newFn->userDefined = false;
newFn->returnsTrig = fnName.contains(returnTrigRE); newFn->returnsTrig = fnName.tqcontains(returnTrigRE);
newFn->needsTrig = fnName.contains(needsTrigRE); newFn->needsTrig = fnName.tqcontains(needsTrigRE);
m_dict.insert(name, newFn); m_dict.insert(name, newFn);
@ -135,24 +135,24 @@ DECLARE_FUNC1(floor, "Nearest lesser integer");
DECLARE_FUNC2(int, integer, "Integral part of number"); DECLARE_FUNC2(int, integer, "Integral part of number");
DECLARE_FUNC1(frac, "Fractional part of number"); DECLARE_FUNC1(frac, "Fractional part of number");
Function *FunctionManager::function(const QString &name) Function *FunctionManager::function(const TQString &name)
{ {
return m_dict[name]; return m_dict[name];
} }
// Returns true if the named identifier is a function, false otherwise. // Returns true if the named identifier is a function, false otherwise.
bool FunctionManager::isFunction(const QString &name) bool FunctionManager::isFunction(const TQString &name)
{ {
return function(name) != 0; return function(name) != 0;
} }
bool FunctionManager::isFunctionUserDefined(const QString &name) bool FunctionManager::isFunctionUserDefined(const TQString &name)
{ {
const Function *fn = function(name); const Function *fn = function(name);
return (fn != 0) && (fn->userDefined); return (fn != 0) && (fn->userDefined);
} }
bool FunctionManager::addFunction(BaseFunction *fn, const QString &dependantVar) bool FunctionManager::addFunction(BaseFunction *fn, const TQString &dependantVar)
{ {
// First see if this function is recursive // First see if this function is recursive
DupFinder dupFinder(fn->name()); DupFinder dupFinder(fn->name());
@ -168,7 +168,7 @@ bool FunctionManager::addFunction(BaseFunction *fn, const QString &dependantVar)
UserFunction *newFn = new UserFunction; UserFunction *newFn = new UserFunction;
newFn->sequenceNumber = m_dict.count(); newFn->sequenceNumber = m_dict.count();
newFn->fn = fn; newFn->fn = fn;
newFn->varName = QString(dependantVar); newFn->varName = TQString(dependantVar);
// Now setup the Function data structure that holds the information // Now setup the Function data structure that holds the information
// we need to access and call the function later. // we need to access and call the function later.
@ -179,16 +179,16 @@ bool FunctionManager::addFunction(BaseFunction *fn, const QString &dependantVar)
fnTabEntry->needsTrig = false; fnTabEntry->needsTrig = false;
fnTabEntry->userDefined = true; fnTabEntry->userDefined = true;
if(m_dict.find(fn->name())) if(m_dict.tqfind(fn->name()))
emit signalFunctionRemoved(fn->name()); emit signalFunctionRemoved(fn->name());
m_dict.replace(fn->name(), fnTabEntry); m_dict.tqreplace(fn->name(), fnTabEntry);
emit signalFunctionAdded(fn->name()); emit signalFunctionAdded(fn->name());
return true; return true;
} }
void FunctionManager::removeFunction(const QString &name) void FunctionManager::removeFunction(const TQString &name)
{ {
Function *fn = function(name); Function *fn = function(name);
@ -205,7 +205,7 @@ void FunctionManager::removeFunction(const QString &name)
fn->userFn = 0; fn->userFn = 0;
m_dict.remove(name); m_dict.remove(name);
QDictIterator<Function> it(m_dict); TQDictIterator<Function> it(m_dict);
for (; it.current(); ++it) { for (; it.current(); ++it) {
UserFunction *userFn = it.current()->userDefined ? it.current()->userFn : 0; UserFunction *userFn = it.current()->userDefined ? it.current()->userFn : 0;
if(userFn && userFn->sequenceNumber > savedSeqNum) if(userFn && userFn->sequenceNumber > savedSeqNum)
@ -214,10 +214,10 @@ void FunctionManager::removeFunction(const QString &name)
} }
} }
QStringList FunctionManager::functionList(FunctionManager::FunctionType type) TQStringList FunctionManager::functionList(FunctionManager::FunctionType type)
{ {
QDictIterator<Function> it(m_dict); TQDictIterator<Function> it(m_dict);
QStringList functions; TQStringList functions;
switch(type) { switch(type) {
case Builtin: case Builtin:
@ -230,8 +230,8 @@ QStringList FunctionManager::functionList(FunctionManager::FunctionType type)
// We want to return the function names in the order they were // We want to return the function names in the order they were
// added. // added.
{ {
QValueVector<Function *> fnTable(m_dict.count(), 0); TQValueVector<Function *> fnTable(m_dict.count(), 0);
QValueVector<int> sequenceNumberTable(m_dict.count(), -1); TQValueVector<int> sequenceNumberTable(m_dict.count(), -1);
// First find out what sequence numbers we have. // First find out what sequence numbers we have.
for(; it.current(); ++it) for(; it.current(); ++it)

@ -21,11 +21,11 @@
#include "numerictypes.h" #include "numerictypes.h"
#include <qobject.h> #include <tqobject.h>
#include <qstringlist.h> #include <tqstringlist.h>
#include <qstring.h> #include <tqstring.h>
#include <qmap.h> #include <tqmap.h>
#include <qdict.h> #include <tqdict.h>
@ -35,15 +35,15 @@ struct UserFunction
{ {
int sequenceNumber; int sequenceNumber;
BaseFunction *fn; BaseFunction *fn;
QString varName; TQString varName;
}; };
// Ugly pointer-to-member typedef ahead // Ugly pointer-to-member typedef ahead
typedef Abakus::number_t (Abakus::number_t::*function_t)() const; typedef Abakus::number_t (Abakus::number_t::*function_t)() const;
struct Function { struct Function {
QString name; TQString name;
QString description; TQString description;
// A function is either builtin or user defined, this union is // A function is either builtin or user defined, this union is
// used for both cases. // used for both cases.
@ -61,33 +61,34 @@ struct Function {
void setTrigMode(Abakus::TrigMode mode); void setTrigMode(Abakus::TrigMode mode);
Abakus::TrigMode trigMode(); Abakus::TrigMode trigMode();
class FunctionManager : public QObject class FunctionManager : public TQObject
{ {
Q_OBJECT Q_OBJECT
TQ_OBJECT
public: public:
typedef QDict<Function> functionDict; typedef TQDict<Function> functionDict;
static FunctionManager *instance(); static FunctionManager *instance();
Function *function(const QString &name); Function *function(const TQString &name);
bool isFunction(const QString &name); bool isFunction(const TQString &name);
bool isFunctionUserDefined(const QString &name); bool isFunctionUserDefined(const TQString &name);
bool addFunction(BaseFunction *fn, const QString &dependantVar); bool addFunction(BaseFunction *fn, const TQString &dependantVar);
bool addFunction(const QString &name, function_t fn, const QString &desc); bool addFunction(const TQString &name, function_t fn, const TQString &desc);
void removeFunction(const QString &name); void removeFunction(const TQString &name);
typedef enum { Builtin, UserDefined, All } FunctionType; typedef enum { Builtin, UserDefined, All } FunctionType;
QStringList functionList(FunctionType type); TQStringList functionList(FunctionType type);
signals: signals:
void signalFunctionAdded(const QString &name); void signalFunctionAdded(const TQString &name);
void signalFunctionRemoved(const QString &name); void signalFunctionRemoved(const TQString &name);
private: private:
FunctionManager(QObject *parent = 0, const char *name = "function manager"); FunctionManager(TQObject *tqparent = 0, const char *name = "function manager");
static FunctionManager *m_manager; static FunctionManager *m_manager;
functionDict m_dict; functionDict m_dict;
@ -102,7 +103,7 @@ Abakus::number_t parseString(const char *str);
class Lexer class Lexer
{ {
public: public:
Lexer(const QString &expr); Lexer(const TQString &expr);
~Lexer(); ~Lexer();
bool hasNext() const; bool hasNext() const;
@ -112,7 +113,7 @@ public:
// Can call this after nextType to find the associated string value of the // Can call this after nextType to find the associated string value of the
// token. // token.
QString tokenValue() const; TQString tokenValue() const;
private: private:
class Private; class Private;

@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <qstring.h> #include <tqstring.h>
// internal number of decimal digits // internal number of decimal digits
#define HMATH_MAX_PREC 150 #define HMATH_MAX_PREC 150
@ -224,7 +224,7 @@ static bc_num h_div( bc_num n1, bc_num n2 )
return r; return r;
} }
// find 10 raise to num // tqfind 10 raise to num
// e.g.: when num is 5, it results 100000 // e.g.: when num is 5, it results 100000
static bc_num h_raise10( int n ) static bc_num h_raise10( int n )
{ {
@ -692,10 +692,10 @@ char* HMath::formatGeneral( const HNumber& hn, int prec )
return str; return str;
} }
QString HMath::formatGenString( const HNumber &n, int prec ) TQString HMath::formatGenString( const HNumber &n, int prec )
{ {
char *foo = formatGeneral(n, prec); char *foo = formatGeneral(n, prec);
QString s(foo); TQString s(foo);
free(foo); free(foo);
return s; return s;

@ -165,7 +165,7 @@ private:
Private* d; Private* d;
}; };
class QString; class TQString;
class HMath class HMath
{ {
@ -195,7 +195,7 @@ public:
*/ */
static char* formatGeneral( const HNumber&n, int prec = -1 ); static char* formatGeneral( const HNumber&n, int prec = -1 );
static QString formatGenString( const HNumber &n, int prec = -1 ); static TQString formatGenString( const HNumber &n, int prec = -1 );
/*! /*!
* Returns the constant pi. * Returns the constant pi.

@ -146,7 +146,7 @@ public:
/* Declared in function.h, implemented here in lexer.l since this is where /* Declared in function.h, implemented here in lexer.l since this is where
* all the yy_*() functions and types are defined. * all the yy_*() functions and types are defined.
*/ */
Lexer::Lexer(const QString &expr) : Lexer::Lexer(const TQString &expr) :
m_private(new Private) m_private(new Private)
{ {
const char *exprString = expr.latin1(); const char *exprString = expr.latin1();
@ -193,7 +193,7 @@ int Lexer::nextType()
return m_private->lastToken; return m_private->lastToken;
} }
QString Lexer::tokenValue() const TQString Lexer::tokenValue() const
{ {
return m_private->lastTokenData; return m_private->lastTokenData;
} }

@ -31,12 +31,12 @@
#include <kactionclasses.h> #include <kactionclasses.h>
#include <kinputdialog.h> #include <kinputdialog.h>
#include <qlayout.h> #include <tqlayout.h>
#include <qvbox.h> #include <tqvbox.h>
#include <qhbox.h> #include <tqhbox.h>
#include <qradiobutton.h> #include <tqradiobutton.h>
#include <qbuttongroup.h> #include <tqbuttongroup.h>
#include <qsplitter.h> #include <tqsplitter.h>
#include "editor.h" #include "editor.h"
#include "evaluator.h" #include "evaluator.h"
@ -52,61 +52,61 @@
MainWindow::MainWindow() : KMainWindow(0, "abakus-mainwindow"), m_popup(0), m_insert(false) MainWindow::MainWindow() : KMainWindow(0, "abakus-mainwindow"), m_popup(0), m_insert(false)
{ {
m_mainSplitter = new QSplitter(this); m_mainSplitter = new TQSplitter(this);
QWidget *box = new QWidget(m_mainSplitter); TQWidget *box = new TQWidget(m_mainSplitter);
QVBoxLayout *layout = new QVBoxLayout(box); TQVBoxLayout *tqlayout = new TQVBoxLayout(box);
m_layout = layout; m_layout = tqlayout;
layout->setSpacing(6); tqlayout->setSpacing(6);
layout->setMargin(6); tqlayout->setMargin(6);
QWidget *configBox = new QWidget(box); TQWidget *configBox = new TQWidget(box);
layout->addWidget(configBox); tqlayout->addWidget(configBox);
QHBoxLayout *configLayout = new QHBoxLayout(configBox); TQHBoxLayout *configLayout = new TQHBoxLayout(configBox);
configLayout->addWidget(new QWidget(configBox)); configLayout->addWidget(new TQWidget(configBox));
QLabel *label = new QLabel(i18n("History: "), configBox); TQLabel *label = new TQLabel(i18n("History: "), configBox);
label->setAlignment(AlignCenter); label->tqsetAlignment(AlignCenter);
configLayout->addWidget(label); configLayout->addWidget(label);
QButtonGroup *buttonGroup = new QButtonGroup(0); TQButtonGroup *buttonGroup = new TQButtonGroup(0);
QWidget *buttonGroupBox = new QWidget(configBox); TQWidget *buttonGroupBox = new TQWidget(configBox);
QHBoxLayout *buttonGroupLayout = new QHBoxLayout(buttonGroupBox); TQHBoxLayout *buttonGroupLayout = new TQHBoxLayout(buttonGroupBox);
buttonGroupLayout->addStretch(0); buttonGroupLayout->addStretch(0);
configLayout->addWidget(buttonGroupBox); configLayout->addWidget(buttonGroupBox);
m_degrees = new QRadioButton(i18n("&Degrees"), buttonGroupBox); m_degrees = new TQRadioButton(i18n("&Degrees"), buttonGroupBox);
buttonGroup->insert(m_degrees); buttonGroup->insert(m_degrees);
buttonGroupLayout->addWidget(m_degrees); buttonGroupLayout->addWidget(m_degrees);
slotDegrees(); slotDegrees();
connect(m_degrees, SIGNAL(clicked()), SLOT(slotDegrees())); connect(m_degrees, TQT_SIGNAL(clicked()), TQT_SLOT(slotDegrees()));
m_radians = new QRadioButton(i18n("&Radians"), buttonGroupBox); m_radians = new TQRadioButton(i18n("&Radians"), buttonGroupBox);
buttonGroup->insert(m_radians); buttonGroup->insert(m_radians);
buttonGroupLayout->addWidget(m_radians); buttonGroupLayout->addWidget(m_radians);
connect(m_radians, SIGNAL(clicked()), SLOT(slotRadians())); connect(m_radians, TQT_SIGNAL(clicked()), TQT_SLOT(slotRadians()));
m_history = new QVBox(box); m_history = new TQVBox(box);
layout->addWidget(m_history); tqlayout->addWidget(m_history);
m_history->setSpacing(6); m_history->setSpacing(6);
m_history->setMargin(0); m_history->setMargin(0);
m_result = new ResultListView(m_history); m_result = new ResultListView(m_history);
m_result->setSelectionMode(QListView::NoSelection); m_result->setSelectionMode(TQListView::NoSelection);
m_result->setHScrollBarMode(ResultListView::AlwaysOff); m_result->setHScrollBarMode(ResultListView::AlwaysOff);
connect(m_result, SIGNAL(signalEntrySelected(const QString &)), connect(m_result, TQT_SIGNAL(signalEntrySelected(const TQString &)),
SLOT(slotEntrySelected(const QString &))); TQT_SLOT(slotEntrySelected(const TQString &)));
connect(m_result, SIGNAL(signalResultSelected(const QString &)), connect(m_result, TQT_SIGNAL(signalResultSelected(const TQString &)),
SLOT(slotResultSelected(const QString &))); TQT_SLOT(slotResultSelected(const TQString &)));
m_history->setStretchFactor(m_result, 1); m_history->setStretchFactor(m_result, 1);
layout->setStretchFactor(m_history, 1); tqlayout->setStretchFactor(m_history, 1);
QHBox *editBox = new QHBox(box); TQHBox *editBox = new TQHBox(box);
layout->addWidget(editBox); tqlayout->addWidget(editBox);
editBox->setSpacing(6); editBox->setSpacing(6);
m_edit = new Editor(editBox); m_edit = new Editor(editBox);
@ -115,12 +115,12 @@ MainWindow::MainWindow() : KMainWindow(0, "abakus-mainwindow"), m_popup(0), m_in
KPushButton *evalButton = new KPushButton(i18n("&Evaluate"), editBox); KPushButton *evalButton = new KPushButton(i18n("&Evaluate"), editBox);
connect(evalButton, SIGNAL(clicked()), SLOT(slotEvaluate())); connect(evalButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotEvaluate()));
connect(m_edit, SIGNAL(returnPressed()), SLOT(slotReturnPressed())); connect(m_edit, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed()));
connect(m_edit, SIGNAL(textChanged()), SLOT(slotTextChanged())); connect(m_edit, TQT_SIGNAL(textChanged()), TQT_SLOT(slotTextChanged()));
m_listSplitter = new QSplitter(Vertical, m_mainSplitter); m_listSplitter = new TQSplitter(Qt::Vertical, m_mainSplitter);
m_fnList = new FunctionListView(m_listSplitter); m_fnList = new FunctionListView(m_listSplitter);
m_fnList->addColumn("Functions"); m_fnList->addColumn("Functions");
m_fnList->addColumn("Value"); m_fnList->addColumn("Value");
@ -129,24 +129,24 @@ MainWindow::MainWindow() : KMainWindow(0, "abakus-mainwindow"), m_popup(0), m_in
m_varList->addColumn("Variables"); m_varList->addColumn("Variables");
m_varList->addColumn("Value"); m_varList->addColumn("Value");
connect(FunctionManager::instance(), SIGNAL(signalFunctionAdded(const QString &)), connect(FunctionManager::instance(), TQT_SIGNAL(signalFunctionAdded(const TQString &)),
this, SLOT(slotNewFunction(const QString &))); this, TQT_SLOT(slotNewFunction(const TQString &)));
connect(FunctionManager::instance(), SIGNAL(signalFunctionRemoved(const QString &)), connect(FunctionManager::instance(), TQT_SIGNAL(signalFunctionRemoved(const TQString &)),
this, SLOT(slotRemoveFunction(const QString &))); this, TQT_SLOT(slotRemoveFunction(const TQString &)));
connect(ValueManager::instance(), SIGNAL(signalValueAdded(const QString &, Abakus::number_t)), connect(ValueManager::instance(), TQT_SIGNAL(signalValueAdded(const TQString &, Abakus::number_t)),
this, SLOT(slotNewValue(const QString &, Abakus::number_t))); this, TQT_SLOT(slotNewValue(const TQString &, Abakus::number_t)));
connect(ValueManager::instance(), SIGNAL(signalValueChanged(const QString &, Abakus::number_t)), connect(ValueManager::instance(), TQT_SIGNAL(signalValueChanged(const TQString &, Abakus::number_t)),
this, SLOT(slotChangeValue(const QString &, Abakus::number_t))); this, TQT_SLOT(slotChangeValue(const TQString &, Abakus::number_t)));
connect(ValueManager::instance(), SIGNAL(signalValueRemoved(const QString &)), connect(ValueManager::instance(), TQT_SIGNAL(signalValueRemoved(const TQString &)),
this, SLOT(slotRemoveValue(const QString &))); this, TQT_SLOT(slotRemoveValue(const TQString &)));
setupLayout(); setupLayout();
setCentralWidget(m_mainSplitter); setCentralWidget(m_mainSplitter);
#if KDE_IS_VERSION(3,4,89) #if KDE_IS_VERSION(3,4,89)
setupGUI(QSize(450, 400), Keys | StatusBar | Save | Create); setupGUI(TQSize(450, 400), Keys | StatusBar | Save | Create);
#else #else
setupGUI(Keys | StatusBar | Save | Create); setupGUI(Keys | StatusBar | Save | Create);
#endif #endif
@ -159,7 +159,7 @@ bool MainWindow::inRPNMode() const
return action<KToggleAction>("toggleExpressionMode")->isChecked(); return action<KToggleAction>("toggleExpressionMode")->isChecked();
} }
bool MainWindow::eventFilter(QObject *o, QEvent *e) bool MainWindow::eventFilter(TQObject *o, TQEvent *e)
{ {
return KMainWindow::eventFilter(o, e); return KMainWindow::eventFilter(o, e);
} }
@ -170,7 +170,7 @@ bool MainWindow::queryExit()
return KMainWindow::queryExit(); return KMainWindow::queryExit();
} }
void MainWindow::contextMenuEvent(QContextMenuEvent *e) void MainWindow::contextMenuEvent(TQContextMenuEvent *e)
{ {
static KPopupMenu *popup = 0; static KPopupMenu *popup = 0;
@ -191,9 +191,9 @@ void MainWindow::polish()
void MainWindow::slotReturnPressed() void MainWindow::slotReturnPressed()
{ {
QString text = m_edit->text(); TQString text = m_edit->text();
text.replace("\n", ""); text.tqreplace("\n", "");
m_edit->appendHistory(text); m_edit->appendHistory(text);
@ -201,9 +201,9 @@ void MainWindow::slotReturnPressed()
ResultListViewText *after = m_result->lastItem(); ResultListViewText *after = m_result->lastItem();
// Expand $foo references. // Expand $foo references.
QString str = interpolateExpression(text, after); TQString str = interpolateExpression(text, after);
QString resultVal; TQString resultVal;
ResultListViewText *item; ResultListViewText *item;
if(str.isNull()) if(str.isNull())
@ -222,13 +222,13 @@ void MainWindow::slotReturnPressed()
} }
else { else {
m_insert = false; m_insert = false;
resultVal = i18n("Error: %1").arg(RPNParser::errorString()); resultVal = i18n("Error: %1").tqarg(RPNParser::errorString());
} }
// Skip creating list view items if in compact mode. // Skip creating list view items if in compact mode.
if(!m_history->isShown()) { if(!m_history->isShown()) {
m_edit->setText(resultVal); m_edit->setText(resultVal);
QTimer::singleShot(0, m_edit, SLOT(selectAll())); TQTimer::singleShot(0, m_edit, TQT_SLOT(selectAll()));
return; return;
} }
@ -241,7 +241,7 @@ void MainWindow::slotReturnPressed()
if(FunctionManager::instance()->isFunction(str)) if(FunctionManager::instance()->isFunction(str))
str += " ans"; str += " ans";
// Add right parentheses as needed to balance out the expression. // Add right tqparentheses as needed to balance out the expression.
int parenLevel = getParenthesesLevel(str); int parenLevel = getParenthesesLevel(str);
for(int i = 0; i < parenLevel; ++i) for(int i = 0; i < parenLevel; ++i)
str += ')'; str += ')';
@ -276,7 +276,7 @@ void MainWindow::slotReturnPressed()
// Skip creating list view items if in compact mode. // Skip creating list view items if in compact mode.
if(compact) { if(compact) {
m_edit->setText(resultVal); m_edit->setText(resultVal);
QTimer::singleShot(0, m_edit, SLOT(selectAll())); TQTimer::singleShot(0, m_edit, TQT_SLOT(selectAll()));
return; return;
} }
@ -287,12 +287,12 @@ void MainWindow::slotReturnPressed()
m_result->setCurrentItem(item); m_result->setCurrentItem(item);
m_result->ensureItemVisible(item); m_result->ensureItemVisible(item);
QTimer::singleShot(0, m_edit, SLOT(selectAll())); TQTimer::singleShot(0, m_edit, TQT_SLOT(selectAll()));
} }
void MainWindow::slotTextChanged() void MainWindow::slotTextChanged()
{ {
QString str = m_edit->text(); TQString str = m_edit->text();
if(str.length() == 1 && m_insert) { if(str.length() == 1 && m_insert) {
m_insert = false; m_insert = false;
@ -301,9 +301,9 @@ void MainWindow::slotTextChanged()
if(inRPNMode()) if(inRPNMode())
return; return;
if(str.find(QRegExp("^[-+*/^]")) != -1) { if(str.tqfind(TQRegExp("^[-+*/^]")) != -1) {
m_edit->setText("ans " + str + " "); m_edit->setText("ans " + str + " ");
m_edit->moveCursor(QTextEdit::MoveEnd, false); m_edit->moveCursor(TQTextEdit::MoveEnd, false);
} }
} }
} }
@ -315,10 +315,10 @@ void MainWindow::slotEvaluate()
void MainWindow::slotUpdateSize() void MainWindow::slotUpdateSize()
{ {
if(m_newSize != QSize(0, 0)) if(m_newSize != TQSize(0, 0))
resize(m_newSize); resize(m_newSize);
else else
resize(width(), minimumSize().height()); resize(width(), tqminimumSize().height());
} }
void MainWindow::slotDegrees() void MainWindow::slotDegrees()
@ -337,7 +337,7 @@ void MainWindow::slotRadians()
action<KToggleAction>("setRadiansMode")->setChecked(true); action<KToggleAction>("setRadiansMode")->setChecked(true);
} }
int MainWindow::getParenthesesLevel(const QString &str) int MainWindow::getParenthesesLevel(const TQString &str)
{ {
int level = 0; int level = 0;
@ -355,7 +355,7 @@ void MainWindow::loadConfig()
{ {
KConfigGroup config(KGlobal::config(), "Settings"); KConfigGroup config(KGlobal::config(), "Settings");
QString mode = config.readEntry("Trigonometric mode", "Degrees"); TQString mode = config.readEntry("Trigonometric mode", "Degrees");
if(mode == "Degrees") { if(mode == "Degrees") {
setTrigMode(Abakus::Degrees); setTrigMode(Abakus::Degrees);
m_degrees->setChecked(true); m_degrees->setChecked(true);
@ -379,9 +379,9 @@ void MainWindow::loadConfig()
{ {
KConfigGroup config(KGlobal::config(), "Variables"); KConfigGroup config(KGlobal::config(), "Variables");
QStringList list = config.readListEntry("Saved Variables"); TQStringList list = config.readListEntry("Saved Variables");
for(QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { for(TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
QStringList values = QStringList::split('=', *it); TQStringList values = TQStringList::split('=', *it);
if(values.count() != 2) { if(values.count() != 2) {
kdWarning() << "Your configuration file has somehow been corrupted!\n"; kdWarning() << "Your configuration file has somehow been corrupted!\n";
continue; continue;
@ -411,14 +411,14 @@ void MainWindow::loadConfig()
action<KToggleAction>("toggleCompactMode")->setChecked(compactMode); action<KToggleAction>("toggleCompactMode")->setChecked(compactMode);
if(compactMode) if(compactMode)
QTimer::singleShot(0, this, SLOT(slotToggleCompactMode())); TQTimer::singleShot(0, TQT_TQOBJECT(this), TQT_SLOT(slotToggleCompactMode()));
} }
{ {
KConfigGroup config(KGlobal::config(), "Functions"); KConfigGroup config(KGlobal::config(), "Functions");
QStringList fnList = config.readListEntry("FunctionList"); TQStringList fnList = config.readListEntry("FunctionList");
for(QStringList::ConstIterator it = fnList.begin(); it != fnList.end(); ++it) for(TQStringList::ConstIterator it = fnList.begin(); it != fnList.end(); ++it)
parseString(*it); // Run the function definitions through the parser parseString(*it); // Run the function definitions through the parser
} }
@ -442,9 +442,9 @@ void MainWindow::saveConfig()
{ {
KConfigGroup config(KGlobal::config(), "Variables"); KConfigGroup config(KGlobal::config(), "Variables");
QStringList list; TQStringList list;
QStringList values = ValueManager::instance()->valueNames(); TQStringList values = ValueManager::instance()->valueNames();
QStringList::ConstIterator it = values.begin(); TQStringList::ConstIterator it = values.begin();
// Set precision to max for most accuracy // Set precision to max for most accuracy
Abakus::m_prec = 75; Abakus::m_prec = 75;
@ -453,9 +453,9 @@ void MainWindow::saveConfig()
if(ValueManager::instance()->isValueReadOnly(*it)) if(ValueManager::instance()->isValueReadOnly(*it))
continue; continue;
list += QString("%1=%2") list += TQString("%1=%2")
.arg(*it) .tqarg(*it)
.arg(ValueManager::instance()->value(*it).toString()); .tqarg(ValueManager::instance()->value(*it).toString());
} }
config.writeEntry("Saved Variables", list); config.writeEntry("Saved Variables", list);
@ -484,15 +484,15 @@ void MainWindow::saveConfig()
FunctionManager *manager = FunctionManager::instance(); FunctionManager *manager = FunctionManager::instance();
QStringList userFunctions = manager->functionList(FunctionManager::UserDefined); TQStringList userFunctions = manager->functionList(FunctionManager::UserDefined);
QStringList saveList; TQStringList saveList;
for(QStringList::ConstIterator it = userFunctions.begin(); it != userFunctions.end(); ++it) { for(TQStringList::ConstIterator it = userFunctions.begin(); it != userFunctions.end(); ++it) {
UnaryFunction *fn = dynamic_cast<UnaryFunction *>(manager->function(*it)->userFn->fn); UnaryFunction *fn = dynamic_cast<UnaryFunction *>(manager->function(*it)->userFn->fn);
QString var = manager->function(*it)->userFn->varName; TQString var = manager->function(*it)->userFn->varName;
QString expr = fn->operand()->infixString(); TQString expr = fn->operand()->infixString();
saveList += QString("set %1(%2) = %3").arg(*it).arg(var).arg(expr); saveList += TQString("set %1(%2) = %3").tqarg(*it).tqarg(var).tqarg(expr);
} }
config.writeEntry("FunctionList", saveList); config.writeEntry("FunctionList", saveList);
@ -503,65 +503,65 @@ void MainWindow::setupLayout()
{ {
KActionCollection *ac = actionCollection(); KActionCollection *ac = actionCollection();
KStdAction::quit(kapp, SLOT(quit()), ac); KStdAction::quit(TQT_TQOBJECT(kapp), TQT_SLOT(quit()), ac);
KStdAction::showMenubar(this, SLOT(slotToggleMenuBar()), ac); KStdAction::showMenubar(TQT_TQOBJECT(this), TQT_SLOT(slotToggleMenuBar()), ac);
KToggleAction *ta = new KToggleAction(i18n("&Degrees"), SHIFT + ALT + Key_D, this, SLOT(slotDegrees()), ac, "setDegreesMode"); KToggleAction *ta = new KToggleAction(i18n("&Degrees"), SHIFT + ALT + Key_D, TQT_TQOBJECT(this), TQT_SLOT(slotDegrees()), ac, "setDegreesMode");
ta->setExclusiveGroup("TrigMode"); ta->setExclusiveGroup("TrigMode");
ta->setChecked(trigMode() == Abakus::Degrees); ta->setChecked(trigMode() == Abakus::Degrees);
ta = new KToggleAction(i18n("&Radians"), SHIFT + ALT + Key_R, this, SLOT(slotRadians()), ac, "setRadiansMode"); ta = new KToggleAction(i18n("&Radians"), SHIFT + ALT + Key_R, TQT_TQOBJECT(this), TQT_SLOT(slotRadians()), ac, "setRadiansMode");
ta->setExclusiveGroup("TrigMode"); ta->setExclusiveGroup("TrigMode");
ta->setChecked(trigMode() == Abakus::Radians); ta->setChecked(trigMode() == Abakus::Radians);
ta = new KToggleAction(i18n("Show &History List"), SHIFT + ALT + Key_H, this, SLOT(slotToggleHistoryList()), ac, "toggleHistoryList"); ta = new KToggleAction(i18n("Show &History List"), SHIFT + ALT + Key_H, TQT_TQOBJECT(this), TQT_SLOT(slotToggleHistoryList()), ac, "toggleHistoryList");
ta->setChecked(true); ta->setChecked(true);
ta = new KToggleAction(i18n("Show &Variables"), SHIFT + ALT + Key_V, this, SLOT(slotToggleVariableList()), ac, "toggleVariableList"); ta = new KToggleAction(i18n("Show &Variables"), SHIFT + ALT + Key_V, TQT_TQOBJECT(this), TQT_SLOT(slotToggleVariableList()), ac, "toggleVariableList");
ta->setChecked(true); ta->setChecked(true);
ta = new KToggleAction(i18n("Show &Functions"), SHIFT + ALT + Key_F, this, SLOT(slotToggleFunctionList()), ac, "toggleFunctionList"); ta = new KToggleAction(i18n("Show &Functions"), SHIFT + ALT + Key_F, TQT_TQOBJECT(this), TQT_SLOT(slotToggleFunctionList()), ac, "toggleFunctionList");
ta->setChecked(true); ta->setChecked(true);
ta = new KToggleAction(i18n("Activate &Compact Mode"), SHIFT + ALT + Key_C, this, SLOT(slotToggleCompactMode()), ac, "toggleCompactMode"); ta = new KToggleAction(i18n("Activate &Compact Mode"), SHIFT + ALT + Key_C, TQT_TQOBJECT(this), TQT_SLOT(slotToggleCompactMode()), ac, "toggleCompactMode");
ta->setChecked(false); ta->setChecked(false);
ta = new KToggleAction(i18n("Use R&PN Mode"), SHIFT + ALT + Key_P, this, SLOT(slotToggleExpressionMode()), ac, "toggleExpressionMode"); ta = new KToggleAction(i18n("Use R&PN Mode"), SHIFT + ALT + Key_P, TQT_TQOBJECT(this), TQT_SLOT(slotToggleExpressionMode()), ac, "toggleExpressionMode");
ta->setChecked(false); ta->setChecked(false);
// Precision actions. // Precision actions.
ta = new KToggleAction(i18n("&Automatic Precision"), 0, this, SLOT(slotPrecisionAuto()), ac, "precisionAuto"); ta = new KToggleAction(i18n("&Automatic Precision"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecisionAuto()), ac, "precisionAuto");
ta->setExclusiveGroup("Precision"); ta->setExclusiveGroup("Precision");
ta->setChecked(true); ta->setChecked(true);
ta = new KToggleAction(i18n("&3 Decimal Digits"), 0, this, SLOT(slotPrecision3()), ac, "precision3"); ta = new KToggleAction(i18n("&3 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision3()), ac, "precision3");
ta->setExclusiveGroup("Precision"); ta->setExclusiveGroup("Precision");
ta->setChecked(false); ta->setChecked(false);
ta = new KToggleAction(i18n("&8 Decimal Digits"), 0, this, SLOT(slotPrecision8()), ac, "precision8"); ta = new KToggleAction(i18n("&8 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision8()), ac, "precision8");
ta->setExclusiveGroup("Precision"); ta->setExclusiveGroup("Precision");
ta->setChecked(false); ta->setChecked(false);
ta = new KToggleAction(i18n("&15 Decimal Digits"), 0, this, SLOT(slotPrecision15()), ac, "precision15"); ta = new KToggleAction(i18n("&15 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision15()), ac, "precision15");
ta->setExclusiveGroup("Precision"); ta->setExclusiveGroup("Precision");
ta->setChecked(false); ta->setChecked(false);
ta = new KToggleAction(i18n("&50 Decimal Digits"), 0, this, SLOT(slotPrecision50()), ac, "precision50"); ta = new KToggleAction(i18n("&50 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision50()), ac, "precision50");
ta->setExclusiveGroup("Precision"); ta->setExclusiveGroup("Precision");
ta->setChecked(false); ta->setChecked(false);
ta = new KToggleAction(i18n("C&ustom Precision..."), 0, this, SLOT(slotPrecisionCustom()), ac, "precisionCustom"); ta = new KToggleAction(i18n("C&ustom Precision..."), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecisionCustom()), ac, "precisionCustom");
ta->setExclusiveGroup("Precision"); ta->setExclusiveGroup("Precision");
ta->setChecked(false); ta->setChecked(false);
new KAction(i18n("Clear &History"), "editclear", SHIFT + ALT + Key_L, m_result, SLOT(clear()), ac, "clearHistory"); new KAction(i18n("Clear &History"), "editclear", SHIFT + ALT + Key_L, TQT_TQOBJECT(m_result), TQT_SLOT(clear()), ac, "clearHistory");
new KAction(i18n("Select Editor"), "goto", Key_F6, m_edit, SLOT(setFocus()), ac, "select_edit"); new KAction(i18n("Select Editor"), "goto", Key_F6, TQT_TQOBJECT(m_edit), TQT_SLOT(setFocus()), ac, "select_edit");
} }
void MainWindow::populateListViews() void MainWindow::populateListViews()
{ {
QStringList values = ValueManager::instance()->valueNames(); TQStringList values = ValueManager::instance()->valueNames();
Abakus::number_t value = ValueManager::instance()->value("pi"); Abakus::number_t value = ValueManager::instance()->value("pi");
new ValueListViewItem(m_varList, "pi", value); new ValueListViewItem(m_varList, "pi", value);
@ -575,13 +575,13 @@ KAction *MainWindow::action(const char *key) const
return actionCollection()->action(key); return actionCollection()->action(key);
} }
void MainWindow::slotEntrySelected(const QString &text) void MainWindow::slotEntrySelected(const TQString &text)
{ {
m_edit->setText(text); m_edit->setText(text);
m_edit->moveCursor(QTextEdit::MoveEnd, false); m_edit->moveCursor(TQTextEdit::MoveEnd, false);
} }
void MainWindow::slotResultSelected(const QString &text) void MainWindow::slotResultSelected(const TQString &text)
{ {
m_edit->insert(text); m_edit->insert(text);
} }
@ -627,42 +627,42 @@ void MainWindow::slotToggleHistoryList()
action<KToggleAction>("toggleCompactMode")->setChecked(false); action<KToggleAction>("toggleCompactMode")->setChecked(false);
} }
void MainWindow::slotNewFunction(const QString &name) void MainWindow::slotNewFunction(const TQString &name)
{ {
UserFunction *userFn = FunctionManager::instance()->function(name)->userFn; UserFunction *userFn = FunctionManager::instance()->function(name)->userFn;
UnaryFunction *fn = dynamic_cast<UnaryFunction *>(userFn->fn); UnaryFunction *fn = dynamic_cast<UnaryFunction *>(userFn->fn);
QString fnName = QString("%1(%2)").arg(name, userFn->varName); TQString fnName = TQString("%1(%2)").tqarg(name, userFn->varName);
QString expr = fn->operand()->infixString(); TQString expr = fn->operand()->infixString();
new KListViewItem(m_fnList, fnName, expr); new KListViewItem(m_fnList, fnName, expr);
} }
void MainWindow::slotRemoveFunction(const QString &name) void MainWindow::slotRemoveFunction(const TQString &name)
{ {
UserFunction *userFn = FunctionManager::instance()->function(name)->userFn; UserFunction *userFn = FunctionManager::instance()->function(name)->userFn;
QString fnName = QString("%1(%2)").arg(name, userFn->varName); TQString fnName = TQString("%1(%2)").tqarg(name, userFn->varName);
QListViewItem *item = 0; TQListViewItem *item = 0;
while((item = m_fnList->findItem(fnName, 0)) != 0) while((item = m_fnList->tqfindItem(fnName, 0)) != 0)
delete item; delete item;
} }
void MainWindow::slotNewValue(const QString &name, Abakus::number_t value) void MainWindow::slotNewValue(const TQString &name, Abakus::number_t value)
{ {
new ValueListViewItem(m_varList, name, value); new ValueListViewItem(m_varList, name, value);
} }
void MainWindow::slotChangeValue(const QString &name, Abakus::number_t value) void MainWindow::slotChangeValue(const TQString &name, Abakus::number_t value)
{ {
ValueListViewItem *item = static_cast<ValueListViewItem *>(m_varList->findItem(name, 0)); ValueListViewItem *item = static_cast<ValueListViewItem *>(m_varList->tqfindItem(name, 0));
if(item) if(item)
item->valueChanged(value); item->valueChanged(value);
} }
void MainWindow::slotRemoveValue(const QString &name) void MainWindow::slotRemoveValue(const TQString &name)
{ {
delete m_varList->findItem(name, 0); delete m_varList->tqfindItem(name, 0);
} }
void MainWindow::slotToggleCompactMode() void MainWindow::slotToggleCompactMode()
@ -681,8 +681,8 @@ void MainWindow::slotToggleCompactMode()
action<KToggleAction>("toggleHistoryList")->setChecked(false); action<KToggleAction>("toggleHistoryList")->setChecked(false);
m_oldSize = size(); m_oldSize = size();
m_newSize = QSize(0, 0); m_newSize = TQSize(0, 0);
QTimer::singleShot(0, this, SLOT(slotUpdateSize())); TQTimer::singleShot(0, TQT_TQOBJECT(this), TQT_SLOT(slotUpdateSize()));
} }
else { else {
m_fnList->setShown(m_wasFnShown); m_fnList->setShown(m_wasFnShown);
@ -694,7 +694,7 @@ void MainWindow::slotToggleCompactMode()
action<KToggleAction>("toggleHistoryList")->setChecked(m_wasHistoryShown); action<KToggleAction>("toggleHistoryList")->setChecked(m_wasHistoryShown);
m_newSize = m_oldSize; m_newSize = m_oldSize;
QTimer::singleShot(0, this, SLOT(slotUpdateSize())); TQTimer::singleShot(0, TQT_TQOBJECT(this), TQT_SLOT(slotUpdateSize()));
} }
} }
@ -702,23 +702,23 @@ void MainWindow::slotToggleExpressionMode()
{ {
} }
QString MainWindow::interpolateExpression(const QString &text, ResultListViewText *after) TQString MainWindow::interpolateExpression(const TQString &text, ResultListViewText *after)
{ {
QString str(text); TQString str(text);
QRegExp stackRE("\\$\\d+"); TQRegExp stackRE("\\$\\d+");
int pos; int pos;
while((pos = stackRE.search(str)) != -1) { while((pos = stackRE.search(str)) != -1) {
QString stackStr = stackRE.cap(); TQString stackStr = stackRE.cap();
Abakus::number_t value; Abakus::number_t value;
unsigned numPos = stackStr.mid(1).toUInt(); unsigned numPos = stackStr.mid(1).toUInt();
if(!m_result->getStackValue(numPos, value)) { if(!m_result->getStackValue(numPos, value)) {
new ResultListViewText(m_result, text, i18n("Marker %1 isn't set").arg(stackStr), after, true); new ResultListViewText(m_result, text, i18n("Marker %1 isn't set").tqarg(stackStr), after, true);
return QString::null; return TQString();
} }
str.replace(pos, stackStr.length(), value.toString()); str.tqreplace(pos, stackStr.length(), value.toString());
} }
return str; return str;
@ -770,14 +770,14 @@ void MainWindow::slotPrecisionCustom()
void MainWindow::redrawResults() void MainWindow::redrawResults()
{ {
QListViewItemIterator it(m_result); TQListViewItemIterator it(m_result);
while(it.current()) { while(it.current()) {
static_cast<ResultListViewText *>(it.current())->precisionChanged(); static_cast<ResultListViewText *>(it.current())->precisionChanged();
++it; ++it;
} }
it = QListViewItemIterator (m_varList); it = TQListViewItemIterator (m_varList);
while(it.current()) { while(it.current()) {
static_cast<ValueListViewItem *>(it.current())->valueChanged(); static_cast<ValueListViewItem *>(it.current())->valueChanged();

@ -23,14 +23,14 @@
#include "numerictypes.h" #include "numerictypes.h"
class QPoint; class TQPoint;
class QVBox; class TQVBox;
class QCheckBox; class TQCheckBox;
class QRadioButton; class TQRadioButton;
class QBoxLayout; class TQBoxLayout;
class QListViewItem; class TQListViewItem;
class QSplitter; class TQSplitter;
class QTimer; class TQTimer;
//class KComboBox; //class KComboBox;
class Editor; class Editor;
@ -42,18 +42,19 @@ class ResultListViewText;
class AbakusIface; class AbakusIface;
// Main window class, handles events and layout and stuff // Main window class, handles events and tqlayout and stuff
class MainWindow : public KMainWindow class MainWindow : public KMainWindow
{ {
Q_OBJECT Q_OBJECT
TQ_OBJECT
public: public:
MainWindow(); MainWindow();
bool inRPNMode() const; bool inRPNMode() const;
protected: protected:
virtual void contextMenuEvent(QContextMenuEvent *e); virtual void contextMenuEvent(TQContextMenuEvent *e);
virtual bool eventFilter(QObject *o, QEvent *e); virtual bool eventFilter(TQObject *o, TQEvent *e);
virtual bool queryExit(); virtual bool queryExit();
virtual void polish(); virtual void polish();
@ -74,8 +75,8 @@ class MainWindow : public KMainWindow
void slotDegrees(); void slotDegrees();
void slotRadians(); void slotRadians();
void slotEntrySelected(const QString &text); void slotEntrySelected(const TQString &text);
void slotResultSelected(const QString &text); void slotResultSelected(const TQString &text);
void slotToggleMenuBar(); void slotToggleMenuBar();
void slotToggleFunctionList(); void slotToggleFunctionList();
@ -84,15 +85,15 @@ class MainWindow : public KMainWindow
void slotToggleCompactMode(); void slotToggleCompactMode();
void slotToggleExpressionMode(); void slotToggleExpressionMode();
void slotNewValue(const QString &name, Abakus::number_t value); void slotNewValue(const TQString &name, Abakus::number_t value);
void slotChangeValue(const QString &name, Abakus::number_t value); void slotChangeValue(const TQString &name, Abakus::number_t value);
void slotRemoveValue(const QString &name); void slotRemoveValue(const TQString &name);
void slotNewFunction(const QString &name); void slotNewFunction(const TQString &name);
void slotRemoveFunction(const QString &name); void slotRemoveFunction(const TQString &name);
private: private:
int getParenthesesLevel(const QString &str); int getParenthesesLevel(const TQString &str);
void redrawResults(); void redrawResults();
void selectCorrectPrecisionAction(); void selectCorrectPrecisionAction();
@ -101,7 +102,7 @@ class MainWindow : public KMainWindow
void saveConfig(); void saveConfig();
void setupLayout(); void setupLayout();
void populateListViews(); void populateListViews();
QString interpolateExpression(const QString &text, ResultListViewText *after); TQString interpolateExpression(const TQString &text, ResultListViewText *after);
// Donated via JuK // Donated via JuK
KAction *action(const char *key) const; KAction *action(const char *key) const;
@ -112,17 +113,17 @@ class MainWindow : public KMainWindow
} }
private: private:
QVBox *m_history; TQVBox *m_history;
QRadioButton *m_degrees; TQRadioButton *m_degrees;
QRadioButton *m_radians; TQRadioButton *m_radians;
Editor *m_edit; Editor *m_edit;
KPopupMenu *m_popup; KPopupMenu *m_popup;
ResultListView *m_result; ResultListView *m_result;
QString m_lastError; TQString m_lastError;
QBoxLayout *m_layout; TQBoxLayout *m_layout;
KListView *m_fnList, *m_varList; KListView *m_fnList, *m_varList;
QSplitter *m_mainSplitter, *m_listSplitter; TQSplitter *m_mainSplitter, *m_listSplitter;
QSize m_newSize, m_oldSize; TQSize m_newSize, m_oldSize;
AbakusIface *m_dcopInterface; AbakusIface *m_dcopInterface;

@ -62,9 +62,9 @@ void UnaryFunction::applyMap(NodeFunctor &fn) const
fn(this); fn(this);
} }
QString UnaryFunction::infixString() const TQString UnaryFunction::infixString() const
{ {
return QString("%1(%2)").arg(name(), operand()->infixString()); return TQString("%1(%2)").tqarg(name(), operand()->infixString());
} }
BuiltinFunction::BuiltinFunction(const char *name, Node *operand) : BuiltinFunction::BuiltinFunction(const char *name, Node *operand) :
@ -208,9 +208,9 @@ void DerivativeFunction::applyMap(NodeFunctor &fn) const
fn(this); fn(this);
} }
QString DerivativeFunction::infixString() const TQString DerivativeFunction::infixString() const
{ {
return QString("deriv(%1, %2)").arg(m_operand->infixString(), m_where->infixString()); return TQString("deriv(%1, %2)").tqarg(m_operand->infixString(), m_where->infixString());
} }
UnaryOperator::UnaryOperator(Type type, Node *operand) UnaryOperator::UnaryOperator(Type type, Node *operand)
@ -230,12 +230,12 @@ void UnaryOperator::applyMap(NodeFunctor &fn) const
fn(this); fn(this);
} }
QString UnaryOperator::infixString() const TQString UnaryOperator::infixString() const
{ {
if(dynamic_cast<BinaryOperator *>(operand())) if(dynamic_cast<BinaryOperator *>(operand()))
return QString("-(%1)").arg(operand()->infixString()); return TQString("-(%1)").tqarg(operand()->infixString());
return QString("-%1").arg(operand()->infixString()); return TQString("-%1").tqarg(operand()->infixString());
} }
Abakus::number_t UnaryOperator::derivative() const Abakus::number_t UnaryOperator::derivative() const
@ -283,9 +283,9 @@ void BinaryOperator::applyMap(NodeFunctor &fn) const
fn(this); fn(this);
} }
QString BinaryOperator::infixString() const TQString BinaryOperator::infixString() const
{ {
QString op; TQString op;
switch(type()) { switch(type()) {
case Addition: case Addition:
@ -312,10 +312,10 @@ QString BinaryOperator::infixString() const
op = "Error"; op = "Error";
} }
QString left = QString(isSimpleNode(leftNode()) ? "%1" : "(%1)").arg(leftNode()->infixString()); TQString left = TQString(isSimpleNode(leftNode()) ? "%1" : "(%1)").tqarg(leftNode()->infixString());
QString right = QString(isSimpleNode(rightNode()) ? "%1" : "(%1)").arg(rightNode()->infixString()); TQString right = TQString(isSimpleNode(rightNode()) ? "%1" : "(%1)").tqarg(rightNode()->infixString());
return QString("%1 %2 %3").arg(left, op, right); return TQString("%1 %2 %3").tqarg(left, op, right);
} }
Abakus::number_t BinaryOperator::derivative() const Abakus::number_t BinaryOperator::derivative() const
@ -411,7 +411,7 @@ void Identifier::applyMap(NodeFunctor &fn) const
fn(this); fn(this);
} }
QString NumericValue::infixString() const TQString NumericValue::infixString() const
{ {
return value().toString(); return value().toString();
} }

@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <qstring.h> #include <tqstring.h>
#include "numerictypes.h" #include "numerictypes.h"
@ -31,7 +31,7 @@ typedef SharedPtr<Node> NodePtr;
/** /**
* A class that operates on a Node. Called recursively on a node and all * A class that operates on a Node. Called recursively on a node and all
* of its children. * of its tqchildren.
*/ */
class NodeFunctor class NodeFunctor
{ {
@ -50,11 +50,11 @@ class Node
// typically read-only. // typically read-only.
virtual void deleteNode(Node *node); virtual void deleteNode(Node *node);
// Calls functor() on all subchildren and this. // Calls functor() on all subtqchildren and this.
virtual void applyMap(NodeFunctor &fn) const = 0; virtual void applyMap(NodeFunctor &fn) const = 0;
// Returns an infix representation of the expression. // Returns an infix representation of the expression.
virtual QString infixString() const = 0; virtual TQString infixString() const = 0;
// Returns the derivative of the node. // Returns the derivative of the node.
virtual Abakus::number_t derivative() const = 0; virtual Abakus::number_t derivative() const = 0;
@ -65,11 +65,11 @@ class BaseFunction : public Node
public: public:
BaseFunction(const char *name); BaseFunction(const char *name);
virtual QString name() const { return m_name; } virtual TQString name() const { return m_name; }
virtual const Function *function() const; virtual const Function *function() const;
private: private:
QString m_name; TQString m_name;
const Function *m_function; const Function *m_function;
}; };
@ -83,7 +83,7 @@ class UnaryFunction : public BaseFunction
virtual void setOperand(Node *operand); virtual void setOperand(Node *operand);
virtual void applyMap(NodeFunctor &fn) const; virtual void applyMap(NodeFunctor &fn) const;
virtual QString infixString() const; virtual TQString infixString() const;
private: private:
Node *m_node; Node *m_node;
@ -102,7 +102,7 @@ class DerivativeFunction : public Node
virtual void applyMap(NodeFunctor &fn) const; virtual void applyMap(NodeFunctor &fn) const;
// Returns an infix representation of the expression. // Returns an infix representation of the expression.
virtual QString infixString() const; virtual TQString infixString() const;
virtual Abakus::number_t derivative() const; virtual Abakus::number_t derivative() const;
@ -138,7 +138,7 @@ class UnaryOperator : public Node
virtual ~UnaryOperator(); virtual ~UnaryOperator();
virtual void applyMap(NodeFunctor &fn) const; virtual void applyMap(NodeFunctor &fn) const;
virtual QString infixString() const; virtual TQString infixString() const;
virtual Abakus::number_t value() const; virtual Abakus::number_t value() const;
virtual Abakus::number_t derivative() const; virtual Abakus::number_t derivative() const;
@ -160,7 +160,7 @@ class BinaryOperator : public Node
virtual ~BinaryOperator(); virtual ~BinaryOperator();
virtual void applyMap(NodeFunctor &fn) const; virtual void applyMap(NodeFunctor &fn) const;
virtual QString infixString() const; virtual TQString infixString() const;
virtual Abakus::number_t value() const; virtual Abakus::number_t value() const;
virtual Abakus::number_t derivative() const; virtual Abakus::number_t derivative() const;
@ -182,7 +182,7 @@ class Identifier : public Node
Identifier(const char *name); Identifier(const char *name);
virtual void applyMap(NodeFunctor &fn) const; virtual void applyMap(NodeFunctor &fn) const;
virtual QString infixString() const { return name(); } virtual TQString infixString() const { return name(); }
virtual Abakus::number_t value() const; virtual Abakus::number_t value() const;
virtual Abakus::number_t derivative() const virtual Abakus::number_t derivative() const
@ -193,10 +193,10 @@ class Identifier : public Node
return "0"; return "0";
} }
virtual QString name() const { return m_name; } virtual TQString name() const { return m_name; }
private: private:
QString m_name; TQString m_name;
}; };
class NumericValue : public Node class NumericValue : public Node
@ -205,7 +205,7 @@ class NumericValue : public Node
NumericValue(const Abakus::number_t value) : m_value(value) { } NumericValue(const Abakus::number_t value) : m_value(value) { }
virtual void applyMap(NodeFunctor &fn) const { fn(this); } virtual void applyMap(NodeFunctor &fn) const { fn(this); }
virtual QString infixString() const; virtual TQString infixString() const;
virtual Abakus::number_t value() const { return m_value; } virtual Abakus::number_t value() const { return m_value; }
virtual Abakus::number_t derivative() const { return "0"; } virtual Abakus::number_t derivative() const { return "0"; }

@ -938,7 +938,7 @@ _one_mult (num, size, digit, result)
/* The full division routine. This computes N1 / N2. It returns /* The full division routine. This computes N1 / N2. It returns
0 if the division is ok and the result is in QUOT. The number of 0 if the division is ok and the result is in TQUOT. The number of
digits after the decimal point is SCALE. It returns -1 if division digits after the decimal point is SCALE. It returns -1 if division
by zero is tried. The algorithm is found in Knuth Vol 2. p237. */ by zero is tried. The algorithm is found in Knuth Vol 2. p237. */
@ -1134,7 +1134,7 @@ bc_divide (n1, n2, quot, scale)
/* Division *and* modulo for numbers. This computes both NUM1 / NUM2 and /* Division *and* modulo for numbers. This computes both NUM1 / NUM2 and
NUM1 % NUM2 and puts the results in QUOT and REM, except that if QUOT NUM1 % NUM2 and puts the results in TQUOT and REM, except that if TQUOT
is NULL then that store will be omitted. is NULL then that store will be omitted.
*/ */

@ -32,13 +32,13 @@ int Abakus::m_prec = -1;
namespace Abakus namespace Abakus
{ {
QString convertToString(const mpfr_ptr &number) TQString convertToString(const mpfr_ptr &number)
{ {
char *str = 0; char *str = 0;
QRegExp zeroKiller ("0*$"); TQRegExp zeroKiller ("0*$");
mp_exp_t exp; mp_exp_t exp;
int desiredPrecision = Abakus::m_prec; int desiredPrecision = Abakus::m_prec;
QString decimalSymbol = KGlobal::locale()->decimalSymbol(); TQString decimalSymbol = KGlobal::locale()->decimalSymbol();
if(desiredPrecision < 0) if(desiredPrecision < 0)
desiredPrecision = 8; desiredPrecision = 8;
@ -54,10 +54,10 @@ QString convertToString(const mpfr_ptr &number)
if(exp < -2 || exp > desiredPrecision) if(exp < -2 || exp > desiredPrecision)
{ {
// Use exponential notation. // Use exponential notation.
QString numbers (str); TQString numbers (str);
mpfr_free_str(str); mpfr_free_str(str);
QString sign, l, r; TQString sign, l, r;
if(numbers[0] == '-') if(numbers[0] == '-')
{ {
sign = "-"; sign = "-";
@ -72,13 +72,13 @@ QString convertToString(const mpfr_ptr &number)
// Remove trailing zeroes. // Remove trailing zeroes.
if(Abakus::m_prec < 0) if(Abakus::m_prec < 0)
r.replace(zeroKiller, ""); r.tqreplace(zeroKiller, "");
// But don't display numbers like 2.e10 either. // But don't display numbers like 2.e10 either.
if(r.isEmpty()) if(r.isEmpty())
r = "0"; r = "0";
r.append(QString("e%1").arg(exp - 1)); r.append(TQString("e%1").tqarg(exp - 1));
return sign + l + decimalSymbol + r; return sign + l + decimalSymbol + r;
} }
@ -91,12 +91,12 @@ QString convertToString(const mpfr_ptr &number)
str = mpfr_get_str (0, &exp, 10, exp + desiredPrecision, number, GMP_RNDN); str = mpfr_get_str (0, &exp, 10, exp + desiredPrecision, number, GMP_RNDN);
} }
QString result = str; TQString result = str;
mpfr_free_str(str); mpfr_free_str(str);
str = 0; str = 0;
int position = exp; int position = exp;
QString l, r, sign; TQString l, r, sign;
if(position < 0) { // Number < 0.1 if(position < 0) { // Number < 0.1
l.fill('0', -position); l.fill('0', -position);
@ -124,7 +124,7 @@ QString convertToString(const mpfr_ptr &number)
} }
// Remove trailing zeroes. // Remove trailing zeroes.
r.replace(zeroKiller, ""); r.tqreplace(zeroKiller, "");
// Don't display numbers of the form .23 // Don't display numbers of the form .23
if(l.isEmpty()) if(l.isEmpty())
@ -172,25 +172,25 @@ const Abakus::number_t::value_type Abakus::number_t::E = setupExponential();
namespace Abakus namespace Abakus
{ {
QString convertToString(const HNumber &num) TQString convertToString(const HNumber &num)
{ {
QString str = HMath::formatGenString(num, m_prec); TQString str = HMath::formatGenString(num, m_prec);
QString decimalSymbol = KGlobal::locale()->decimalSymbol(); TQString decimalSymbol = KGlobal::locale()->decimalSymbol();
str.replace('.', decimalSymbol); str.tqreplace('.', decimalSymbol);
QStringList parts = QStringList::split("e", str); TQStringList parts = TQStringList::split("e", str);
QRegExp zeroKiller("(" + QRegExp::escape(decimalSymbol) + TQRegExp zeroKiller("(" + TQRegExp::escape(decimalSymbol) +
"\\d*[1-9])0*$"); // Remove trailing zeroes. "\\d*[1-9])0*$"); // Remove trailing zeroes.
QRegExp zeroKiller2("(" + QRegExp::escape(decimalSymbol) + ")0*$"); TQRegExp zeroKiller2("(" + TQRegExp::escape(decimalSymbol) + ")0*$");
str = parts[0]; str = parts[0];
str.replace(zeroKiller, "\\1"); str.tqreplace(zeroKiller, "\\1");
str.replace(zeroKiller2, "\\1"); str.tqreplace(zeroKiller2, "\\1");
if(str.endsWith(decimalSymbol)) if(str.endsWith(decimalSymbol))
str.truncate(str.length() - 1); // Remove trailing period. str.truncate(str.length() - 1); // Remove trailing period.
if(parts.count() > 1 && parts[1] != "0") if(parts.count() > 1 && parts[1] != "0")
str += QString("e%1").arg(parts[1]); str += TQString("e%1").tqarg(parts[1]);
return str; return str;
} }

@ -22,9 +22,9 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <qstring.h> #include <tqstring.h>
#include <qstringlist.h> #include <tqstringlist.h>
#include <qregexp.h> #include <tqregexp.h>
#include "hmath.h" #include "hmath.h"
#include "config.h" #include "config.h"
@ -158,7 +158,7 @@ public:
/// @return Textual representation of the number, adjusted to the user's /// @return Textual representation of the number, adjusted to the user's
/// current precision. /// current precision.
QString toString() const; TQString toString() const;
/// @return Our value. /// @return Our value.
T value() const; T value() const;
@ -209,7 +209,7 @@ inline number<T> operator/(const number<T> &l, const number<T> &r)
* @return The number converted to a string, in US Decimal format at this time. * @return The number converted to a string, in US Decimal format at this time.
* @see number<>::toString() * @see number<>::toString()
*/ */
QString convertToString(const mpfr_ptr &number); TQString convertToString(const mpfr_ptr &number);
/** /**
* This is a specialization of the number<> template for the MPFR numeric type. * This is a specialization of the number<> template for the MPFR numeric type.
@ -443,7 +443,7 @@ public:
// Note that this can be used dangerously, be careful. // Note that this can be used dangerously, be careful.
value_type value() const { return m_t; } value_type value() const { return m_t; }
QString toString() const TQString toString() const
{ {
// Move this to .cpp to avoid recompiling as I fix it. // Move this to .cpp to avoid recompiling as I fix it.
return convertToString(m_t); return convertToString(m_t);
@ -507,7 +507,7 @@ inline number<mpfr_ptr> operator/(const number<mpfr_ptr> &l, const number<mpfr_p
#else #else
// Defined in numerictypes.cpp for ease of reimplementation. // Defined in numerictypes.cpp for ease of reimplementation.
QString convertToString(const HNumber &num); TQString convertToString(const HNumber &num);
/** /**
* Specialization for internal HMath library, used if MPFR isn't usable. * Specialization for internal HMath library, used if MPFR isn't usable.
@ -664,7 +664,7 @@ public:
return HMath::raise(m_t, exponent.m_t); return HMath::raise(m_t, exponent.m_t);
} }
QString toString() const TQString toString() const
{ {
return convertToString(m_t); return convertToString(m_t);
} }

@ -100,7 +100,7 @@ S: error '=' {
// Can't assign to a function. // Can't assign to a function.
S: FUNC '=' { S: FUNC '=' {
QString s(i18n("You can't assign to function %1").arg($1->name())); TQString s(i18n("You can't assign to function %1").tqarg($1->name()));
Result::setLastResult(s); Result::setLastResult(s);
YYABORT; YYABORT;
@ -116,14 +116,14 @@ ASSIGN: '(' { --gCheckIdents; } IDENT ')' '=' {
// since normally functions and variables with the same name can coexist, but // since normally functions and variables with the same name can coexist, but
// I don't want to duplicate code all over the place. // I don't want to duplicate code all over the place.
S: SET DERIV { S: SET DERIV {
QString s(i18n("Function %1 is built-in and cannot be overridden.").arg("deriv")); TQString s(i18n("Function %1 is built-in and cannot be overridden.").tqarg("deriv"));
Result::setLastResult(s); Result::setLastResult(s);
YYABORT; YYABORT;
} }
S: DERIV '=' { S: DERIV '=' {
QString s(i18n("Function %1 is built-in and cannot be overridden.").arg("deriv")); TQString s(i18n("Function %1 is built-in and cannot be overridden.").tqarg("deriv"));
Result::setLastResult(s); Result::setLastResult(s);
YYABORT; YYABORT;
@ -134,12 +134,12 @@ S: SET FUNC ASSIGN EXP {
// We're trying to reassign an already defined function, make sure it's // We're trying to reassign an already defined function, make sure it's
// not a built-in. // not a built-in.
QString funcName = $2->name(); TQString funcName = $2->name();
QString ident = $3->name(); TQString ident = $3->name();
FunctionManager *manager = FunctionManager::instance(); FunctionManager *manager = FunctionManager::instance();
if(manager->isFunction(funcName) && !manager->isFunctionUserDefined(funcName)) { if(manager->isFunction(funcName) && !manager->isFunctionUserDefined(funcName)) {
QString s(i18n("Function %1 is built-in and cannot be overridden.").arg(funcName)); TQString s(i18n("Function %1 is built-in and cannot be overridden.").tqarg(funcName));
Result::setLastResult(s); Result::setLastResult(s);
YYABORT; YYABORT;
@ -150,7 +150,7 @@ S: SET FUNC ASSIGN EXP {
BaseFunction *newFn = new UserDefinedFunction(funcName, $4); BaseFunction *newFn = new UserDefinedFunction(funcName, $4);
if(!manager->addFunction(newFn, ident)) { if(!manager->addFunction(newFn, ident)) {
QString s(i18n("Unable to define function %1 because it is recursive.").arg(funcName)); TQString s(i18n("Unable to define function %1 because it is recursive.").tqarg(funcName));
Result::setLastResult(s); Result::setLastResult(s);
YYABORT; YYABORT;
@ -165,8 +165,8 @@ S: SET FUNC ASSIGN EXP {
S: SET IDENT ASSIGN EXP { S: SET IDENT ASSIGN EXP {
++gCheckIdents; ++gCheckIdents;
QString funcName = $2->name(); TQString funcName = $2->name();
QString ident = $3->name(); TQString ident = $3->name();
// No need to check if the function is already defined, because the // No need to check if the function is already defined, because the
// lexer checked for us before returning the IDENT token. // lexer checked for us before returning the IDENT token.
@ -188,14 +188,14 @@ S: REMOVE FUNC '(' ')' {
// Can't remove an ident using remove-func syntax. // Can't remove an ident using remove-func syntax.
S: REMOVE IDENT '(' ')' { S: REMOVE IDENT '(' ')' {
// This is an error // This is an error
Result::setLastResult(Result(i18n("Function %1 is not defined.").arg($2->name()))); Result::setLastResult(Result(i18n("Function %1 is not defined.").tqarg($2->name())));
YYABORT; YYABORT;
} }
// This happens when the user tries to remove a function that's not defined. // This happens when the user tries to remove a function that's not defined.
S: REMOVE IDENT '(' IDENT ')' { S: REMOVE IDENT '(' IDENT ')' {
// This is an error // This is an error
Result::setLastResult(Result(i18n("Function %1 is not defined.").arg($2->name()))); Result::setLastResult(Result(i18n("Function %1 is not defined.").tqarg($2->name())));
YYABORT; YYABORT;
} }
@ -209,11 +209,11 @@ S: REMOVE IDENT {
YYACCEPT; YYACCEPT;
} }
else { else {
QString s; TQString s;
if(manager->isValueSet($2->name())) if(manager->isValueSet($2->name()))
s = i18n("Can't remove predefined variable %1.").arg($2->name()); s = i18n("Can't remove predefined variable %1.").tqarg($2->name());
else else
s = i18n("Can't remove undefined variable %1.").arg($2->name()); s = i18n("Can't remove undefined variable %1.").tqarg($2->name());
Result::setLastResult(s); Result::setLastResult(s);
@ -228,7 +228,7 @@ S: SET IDENT '=' EXP {
if($2->name() == "pi" && $4->value() == Abakus::number_t("3.0")) if($2->name() == "pi" && $4->value() == Abakus::number_t("3.0"))
Result::setLastResult(i18n("This isn't Indiana, you can't just change pi")); Result::setLastResult(i18n("This isn't Indiana, you can't just change pi"));
else else
Result::setLastResult(i18n("%1 is a constant").arg($2->name())); Result::setLastResult(i18n("%1 is a constant").tqarg($2->name()));
YYABORT; YYABORT;
} }
@ -247,7 +247,7 @@ S: IDENT '=' EXP {
if($1->name() == "pi" && $3->value() == Abakus::number_t("3.0")) if($1->name() == "pi" && $3->value() == Abakus::number_t("3.0"))
Result::setLastResult(i18n("This isn't Indiana, you can't just change pi")); Result::setLastResult(i18n("This isn't Indiana, you can't just change pi"));
else else
Result::setLastResult(i18n("%1 is a constant").arg($1->name())); Result::setLastResult(i18n("%1 is a constant").tqarg($1->name()));
YYABORT; YYABORT;
} }
@ -259,13 +259,13 @@ S: IDENT '=' EXP {
} }
S: NUMBER '=' { S: NUMBER '=' {
Result::setLastResult(i18n("Can't assign to %1").arg($1->value().toString())); Result::setLastResult(i18n("Can't assign to %1").tqarg($1->value().toString()));
YYABORT; YYABORT;
} }
// Can't call this as a function. // Can't call this as a function.
TERM: IDENT '(' { TERM: IDENT '(' {
Result::setLastResult(i18n("%1 isn't a function (or operator expected)").arg($1->name())); Result::setLastResult(i18n("%1 isn't a function (or operator expected)").tqarg($1->name()));
YYABORT; YYABORT;
} }
@ -351,7 +351,7 @@ TERM: NUMBER '(' EXP ')' {
TERM: NUMBER IDENT { TERM: NUMBER IDENT {
if(gCheckIdents > 0 && !ValueManager::instance()->isValueSet($2->name())) { if(gCheckIdents > 0 && !ValueManager::instance()->isValueSet($2->name())) {
Result::setLastResult(i18n("Unknown variable %1").arg($2->name())); Result::setLastResult(i18n("Unknown variable %1").tqarg($2->name()));
YYABORT; YYABORT;
} }
@ -362,7 +362,7 @@ VALUE: IDENT {
if(gCheckIdents <= 0 || ValueManager::instance()->isValueSet($1->name())) if(gCheckIdents <= 0 || ValueManager::instance()->isValueSet($1->name()))
$$ = $1; $$ = $1;
else { else {
Result::setLastResult(i18n("Unknown variable %1").arg($1->name())); Result::setLastResult(i18n("Unknown variable %1").tqarg($1->name()));
YYABORT; YYABORT;
} }
} }

@ -20,7 +20,7 @@
Result *Result::m_lastResult = new Result; Result *Result::m_lastResult = new Result;
Result::Result(const QString &message) : m_type(Error), m_message(message) Result::Result(const TQString &message) : m_type(Error), m_message(message)
{ {
} }

@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <qstring.h> #include <tqstring.h>
#include "node.h" #include "node.h"
#include "sharedptr.h" #include "sharedptr.h"
@ -37,7 +37,7 @@ public:
/** /**
* Default constructor, which constructs a "failed" Result. * Default constructor, which constructs a "failed" Result.
*/ */
Result(const QString &message = ""); Result(const TQString &message = "");
/** /**
* Node constructor, which constructs a "succeeded" result. * Node constructor, which constructs a "succeeded" result.
@ -54,7 +54,7 @@ public:
Type type() const { return m_type; } Type type() const { return m_type; }
QString message() const { return m_message; } TQString message() const { return m_message; }
const NodePtr result() const { return m_node; } const NodePtr result() const { return m_node; }
NodePtr result() { return m_node; } NodePtr result() { return m_node; }
@ -68,7 +68,7 @@ public:
private: private:
NodePtr m_node; NodePtr m_node;
Type m_type; Type m_type;
QString m_message; TQString m_message;
static Result *m_lastResult; static Result *m_lastResult;
}; };

@ -20,12 +20,12 @@
#include <kpopupmenu.h> #include <kpopupmenu.h>
#include <klocale.h> #include <klocale.h>
#include <qclipboard.h> #include <tqclipboard.h>
#include <qapplication.h> #include <tqapplication.h>
#include <qevent.h> #include <tqevent.h>
#include <qcursor.h> #include <tqcursor.h>
#include <qdragobject.h> #include <tqdragobject.h>
#include <qheader.h> #include <tqheader.h>
#include "resultlistview.h" #include "resultlistview.h"
#include "resultlistviewtext.h" #include "resultlistviewtext.h"
@ -34,11 +34,11 @@
using DragSupport::makePixmap; using DragSupport::makePixmap;
using namespace ResultList; using namespace ResultList;
ResultListView::ResultListView(QWidget *parent, const char *name) : ResultListView::ResultListView(TQWidget *tqparent, const char *name) :
KListView(parent, name), m_itemRightClicked(0) KListView(tqparent, name), m_itemRightClicked(0)
{ {
connect(this, SIGNAL(doubleClicked(QListViewItem *, const QPoint &, int)), connect(this, TQT_SIGNAL(doubleClicked(TQListViewItem *, const TQPoint &, int)),
SLOT(slotDoubleClicked(QListViewItem *, const QPoint &, int))); TQT_SLOT(slotDoubleClicked(TQListViewItem *, const TQPoint &, int)));
addColumn(i18n("Expression")); addColumn(i18n("Expression"));
addColumn(i18n("Result")); addColumn(i18n("Result"));
@ -57,7 +57,7 @@ ResultListView::ResultListView(QWidget *parent, const char *name) :
bool ResultListView::getStackValue(unsigned stackPosition, Abakus::number_t &result) bool ResultListView::getStackValue(unsigned stackPosition, Abakus::number_t &result)
{ {
QListViewItem *it = firstChild(); TQListViewItem *it = firstChild();
for(; it; it = it->itemBelow()) { for(; it; it = it->itemBelow()) {
ResultListViewText *resultItem = dynamic_cast<ResultListViewText *>(it); ResultListViewText *resultItem = dynamic_cast<ResultListViewText *>(it);
if(!resultItem->wasError() && resultItem->stackPosition() == stackPosition) { if(!resultItem->wasError() && resultItem->stackPosition() == stackPosition) {
@ -69,20 +69,20 @@ bool ResultListView::getStackValue(unsigned stackPosition, Abakus::number_t &res
return false; return false;
} }
QDragObject *ResultListView::dragObject() TQDragObject *ResultListView::dragObject()
{ {
QPoint viewportPos = viewport()->mapFromGlobal(QCursor::pos()); TQPoint viewportPos = viewport()->mapFromGlobal(TQCursor::pos());
ResultListViewText *item = itemUnderCursor(); ResultListViewText *item = itemUnderCursor();
if(item) { if(item) {
QString text = item->resultText(); TQString text = item->resultText();
int column = header()->sectionAt(viewportPos.x()); int column = header()->sectionAt(viewportPos.x());
if(column == ExpressionColumn) if(column == ExpressionColumn)
text = item->expressionText(); text = item->expressionText();
QDragObject *drag = new QTextDrag(text, this); TQDragObject *drag = new TQTextDrag(text, this);
drag->setPixmap(makePixmap(text, font())); drag->setPixmap(makePixmap(text, font()));
return drag; return drag;
@ -91,7 +91,7 @@ QDragObject *ResultListView::dragObject()
return 0; return 0;
} }
void ResultListView::contextMenuEvent(QContextMenuEvent *e) void ResultListView::contextMenuEvent(TQContextMenuEvent *e)
{ {
m_itemRightClicked = itemUnderCursor(); m_itemRightClicked = itemUnderCursor();
KPopupMenu *menu = constructPopupMenu(m_itemRightClicked); KPopupMenu *menu = constructPopupMenu(m_itemRightClicked);
@ -99,7 +99,7 @@ void ResultListView::contextMenuEvent(QContextMenuEvent *e)
menu->popup(e->globalPos()); menu->popup(e->globalPos());
} }
void ResultListView::slotDoubleClicked(QListViewItem *item, const QPoint &, int c) void ResultListView::slotDoubleClicked(TQListViewItem *item, const TQPoint &, int c)
{ {
ResultListViewText *textItem = dynamic_cast<ResultListViewText *>(item); ResultListViewText *textItem = dynamic_cast<ResultListViewText *>(item);
if(!textItem) if(!textItem)
@ -115,9 +115,9 @@ KPopupMenu *ResultListView::constructPopupMenu(const ResultListViewText *item)
{ {
KPopupMenu *menu = new KPopupMenu(this, "list view context menu"); KPopupMenu *menu = new KPopupMenu(this, "list view context menu");
menu->insertItem(i18n("Clear &History"), this, SLOT(clear()), ALT+Key_R); menu->insertItem(i18n("Clear &History"), this, TQT_SLOT(clear()), ALT+Key_R);
int id = menu->insertItem(i18n("Copy Result to Clipboard"), this, SLOT(slotCopyResult())); int id = menu->insertItem(i18n("Copy Result to Clipboard"), this, TQT_SLOT(slotCopyResult()));
if(!item || item->wasError()) if(!item || item->wasError())
menu->setItemEnabled(id, false); menu->setItemEnabled(id, false);
@ -129,9 +129,9 @@ void ResultListView::slotCopyResult()
if(!m_itemRightClicked) if(!m_itemRightClicked)
return; return;
QClipboard *clipboard = QApplication::clipboard(); TQClipboard *clipboard = TQApplication::tqclipboard();
clipboard->setText(m_itemRightClicked->resultText(), QClipboard::Clipboard); clipboard->setText(m_itemRightClicked->resultText(), TQClipboard::Clipboard);
} }
ResultListViewText *ResultListView::lastItem() const ResultListViewText *ResultListView::lastItem() const
@ -141,8 +141,8 @@ ResultListViewText *ResultListView::lastItem() const
ResultListViewText *ResultListView::itemUnderCursor() const ResultListViewText *ResultListView::itemUnderCursor() const
{ {
QPoint viewportPos = viewport()->mapFromGlobal(QCursor::pos()); TQPoint viewportPos = viewport()->mapFromGlobal(TQCursor::pos());
QListViewItem *underCursor = itemAt(viewportPos); TQListViewItem *underCursor = itemAt(viewportPos);
return static_cast<ResultListViewText *>(underCursor); return static_cast<ResultListViewText *>(underCursor);
} }

@ -23,8 +23,8 @@
#include "numerictypes.h" #include "numerictypes.h"
class KPopupMenu; class KPopupMenu;
class QLabel; class TQLabel;
class QDragObject; class TQDragObject;
class ResultListViewText; class ResultListViewText;
namespace ResultList { namespace ResultList {
@ -34,24 +34,25 @@ namespace ResultList {
class ResultListView : public KListView class ResultListView : public KListView
{ {
Q_OBJECT Q_OBJECT
TQ_OBJECT
public: public:
ResultListView(QWidget *parent = 0, const char *name = "result list view"); ResultListView(TQWidget *tqparent = 0, const char *name = "result list view");
bool getStackValue(unsigned stackPosition, Abakus::number_t &result); bool getStackValue(unsigned stackPosition, Abakus::number_t &result);
ResultListViewText *lastItem() const; ResultListViewText *lastItem() const;
protected: protected:
virtual void contextMenuEvent(QContextMenuEvent *e); virtual void contextMenuEvent(TQContextMenuEvent *e);
virtual QDragObject *dragObject(); virtual TQDragObject *dragObject();
signals: signals:
void signalEntrySelected(const QString &text); void signalEntrySelected(const TQString &text);
void signalResultSelected(const QString &text); void signalResultSelected(const TQString &text);
private slots: private slots:
void slotDoubleClicked(QListViewItem *item, const QPoint & /* Ignored */, int c); void slotDoubleClicked(TQListViewItem *item, const TQPoint & /* Ignored */, int c);
void slotCopyResult(); void slotCopyResult();
private: private:

@ -18,19 +18,19 @@
*/ */
#include <kdebug.h> #include <kdebug.h>
#include <qregexp.h> #include <tqregexp.h>
#include <qpainter.h> #include <tqpainter.h>
#include <qfontmetrics.h> #include <tqfontmetrics.h>
#include <qfont.h> #include <tqfont.h>
#include <qpalette.h> #include <tqpalette.h>
#include "resultlistviewtext.h" #include "resultlistviewtext.h"
using namespace ResultList; using namespace ResultList;
ResultListViewText::ResultListViewText(KListView *listView, ResultListViewText::ResultListViewText(KListView *listView,
const QString &text, const TQString &text,
const QString &result, const TQString &result,
ResultListViewText *after, ResultListViewText *after,
bool isError) bool isError)
: KListViewItem(listView, after, text, result), m_text(text), : KListViewItem(listView, after, text, result), m_text(text),
@ -41,7 +41,7 @@ ResultListViewText::ResultListViewText(KListView *listView,
} }
ResultListViewText::ResultListViewText(KListView *listView, ResultListViewText::ResultListViewText(KListView *listView,
const QString &text, const TQString &text,
const Abakus::number_t &result, const Abakus::number_t &result,
ResultListViewText *after, ResultListViewText *after,
bool isError) bool isError)
@ -54,7 +54,7 @@ ResultListViewText::ResultListViewText(KListView *listView,
for (; item && item != this; item = static_cast<ResultListViewText *>(item->itemBelow())) { for (; item && item != this; item = static_cast<ResultListViewText *>(item->itemBelow())) {
if(!item->wasError()) { if(!item->wasError()) {
item->setStackPosition(item->stackPosition() + 1); item->setStackPosition(item->stackPosition() + 1);
item->repaint(); item->tqrepaint();
} }
} }
} }
@ -67,7 +67,7 @@ ResultListViewText::ResultListViewText(KListView *listView,
void ResultListViewText::setStackPosition(unsigned pos) void ResultListViewText::setStackPosition(unsigned pos)
{ {
setText(ShortcutColumn, QString("$%1").arg(pos)); setText(ShortcutColumn, TQString("$%1").tqarg(pos));
m_stackPosition = pos; m_stackPosition = pos;
} }
@ -80,51 +80,51 @@ void ResultListViewText::precisionChanged()
setText(ResultColumn, m_result); setText(ResultColumn, m_result);
} }
void ResultListViewText::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align) void ResultListViewText::paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align)
{ {
QColorGroup group(cg); TQColorGroup group(cg);
// XXX: The Qt::red may not provide good contrast with weird color schemes. // XXX: The TQt::red may not provide good contrast with weird color schemes.
// If so I apologize. // If so I apologize.
if(m_wasError && column == ResultColumn) if(m_wasError && column == ResultColumn)
group.setColor(QColorGroup::Text, m_result == "OK" ? cg.link() : Qt::red); group.setColor(TQColorGroup::Text, m_result == "OK" ? cg.link() : TQt::red);
if(column == ResultColumn) { if(column == ResultColumn) {
QFont f = p->font(); TQFont f = p->font();
f.setBold(true); f.setBold(true);
p->setFont(f); p->setFont(f);
} }
if(column == ShortcutColumn) { if(column == ShortcutColumn) {
QFont f = p->font(); TQFont f = p->font();
f.setItalic(true); f.setItalic(true);
f.setPointSize(QMIN(f.pointSize() * 9 / 11, 10)); f.setPointSize(TQMIN(f.pointSize() * 9 / 11, 10));
p->setFont(f); p->setFont(f);
} }
KListViewItem::paintCell(p, group, column, width, align); KListViewItem::paintCell(p, group, column, width, align);
} }
int ResultListViewText::width(const QFontMetrics &fm, const QListView *lv, int c) const int ResultListViewText::width(const TQFontMetrics &fm, const TQListView *lv, int c) const
{ {
// Simulate painting the text to get accurate results. // Simulate painting the text to get accurate results.
if(c == ResultColumn) { if(c == ResultColumn) {
QFont f = lv->font(); TQFont f = lv->font();
f.setBold(true); f.setBold(true);
return KListViewItem::width(QFontMetrics(f), lv, c); return KListViewItem::width(TQFontMetrics(f), lv, c);
} }
if(c == ShortcutColumn) { if(c == ShortcutColumn) {
QFont f = lv->font(); TQFont f = lv->font();
f.setItalic(true); f.setItalic(true);
f.setPointSize(QMIN(f.pointSize() * 9 / 11, 10)); f.setPointSize(TQMIN(f.pointSize() * 9 / 11, 10));
return KListViewItem::width(QFontMetrics(f), lv, c); return KListViewItem::width(TQFontMetrics(f), lv, c);
} }
return KListViewItem::width(fm, lv, c); return KListViewItem::width(fm, lv, c);
} }
void ResultListViewText::setText(int column, const QString &text) void ResultListViewText::setText(int column, const TQString &text)
{ {
if(!m_wasError && column == ResultColumn) { if(!m_wasError && column == ResultColumn) {
KListViewItem::setText(column, m_value.toString()); KListViewItem::setText(column, m_value.toString());

@ -22,28 +22,28 @@
#include "resultlistview.h" #include "resultlistview.h"
#include "numerictypes.h" #include "numerictypes.h"
class QPainter; class TQPainter;
class QColorGroup; class TQColorGroup;
class QFontMetrics; class TQFontMetrics;
// This class shows the results shown in the MainWindow result pane. // This class shows the results shown in the MainWindow result pane.
class ResultListViewText : public KListViewItem class ResultListViewText : public KListViewItem
{ {
public: public:
ResultListViewText(KListView *listView, ResultListViewText(KListView *listView,
const QString &text, const TQString &text,
const QString &result, const TQString &result,
ResultListViewText *after, ResultListViewText *after,
bool isError = false); bool isError = false);
ResultListViewText(KListView *listView, ResultListViewText(KListView *listView,
const QString &text, const TQString &text,
const Abakus::number_t &result, const Abakus::number_t &result,
ResultListViewText *after, ResultListViewText *after,
bool isError = false); bool isError = false);
QString expressionText() const { return m_text; } TQString expressionText() const { return m_text; }
QString resultText() const { return m_result; } TQString resultText() const { return m_result; }
bool wasError() const { return m_wasError; } bool wasError() const { return m_wasError; }
unsigned stackPosition() const { return m_stackPosition; } unsigned stackPosition() const { return m_stackPosition; }
@ -54,14 +54,14 @@ class ResultListViewText : public KListViewItem
void precisionChanged(); void precisionChanged();
// Reimplemented from KListViewItem // Reimplemented from KListViewItem
virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align); virtual void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align);
virtual int width(const QFontMetrics &fm, const QListView *lv, int c) const; virtual int width(const TQFontMetrics &fm, const TQListView *lv, int c) const;
// Reimplemented to remove trailing zeroes from results. // Reimplemented to remove trailing zeroes from results.
virtual void setText(int column, const QString &text); virtual void setText(int column, const TQString &text);
private: private:
QString m_text, m_result; TQString m_text, m_result;
bool m_wasError; bool m_wasError;
unsigned m_stackPosition; unsigned m_stackPosition;
Abakus::number_t m_value; Abakus::number_t m_value;

@ -21,10 +21,10 @@
#include <kdebug.h> #include <kdebug.h>
#include <klocale.h> #include <klocale.h>
#include <qvaluestack.h> #include <tqvaluestack.h>
#include <qregexp.h> #include <tqregexp.h>
#include <qstring.h> #include <tqstring.h>
#include <qstringlist.h> #include <tqstringlist.h>
#include "rpnmuncher.h" #include "rpnmuncher.h"
#include "valuemanager.h" #include "valuemanager.h"
@ -37,7 +37,7 @@ class Operand
{ {
public: public:
Operand() : m_isValue(true), m_value(0) { } Operand() : m_isValue(true), m_value(0) { }
Operand(const QString &ident) : m_isValue(false), m_text(ident) { } Operand(const TQString &ident) : m_isValue(false), m_text(ident) { }
Operand(Abakus::number_t value) : m_isValue(true), m_value(value) { } Operand(Abakus::number_t value) : m_isValue(true), m_value(value) { }
Abakus::number_t value() const Abakus::number_t value() const
@ -53,19 +53,19 @@ class Operand
return value(); return value();
} }
QString text() const { return m_text; } TQString text() const { return m_text; }
private: private:
bool m_isValue; bool m_isValue;
QString m_text; TQString m_text;
Abakus::number_t m_value; Abakus::number_t m_value;
}; };
typedef enum { Number = 256, Func, Ident, Power, Set, Remove, Pop, Clear, Unknown } Token; typedef enum { Number = 256, Func, Ident, Power, Set, Remove, Pop, Clear, Unknown } Token;
static int tokenize (const QString &token); static int tokenize (const TQString &token);
QString RPNParser::m_errorStr; TQString RPNParser::m_errorStr;
bool RPNParser::m_error(false); bool RPNParser::m_error(false);
OperandStack RPNParser::m_stack; OperandStack RPNParser::m_stack;
@ -77,9 +77,9 @@ struct Counter
} }
}; };
Abakus::number_t RPNParser::rpnParseString(const QString &text) Abakus::number_t RPNParser::rpnParseString(const TQString &text)
{ {
QStringList tokens = QStringList::split(QRegExp("\\s"), text); TQStringList tokens = TQStringList::split(TQRegExp("\\s"), text);
Counter counter; // Will update stack count when we leave proc. Counter counter; // Will update stack count when we leave proc.
(void) counter; // Avoid warnings about it being unused. (void) counter; // Avoid warnings about it being unused.
@ -89,9 +89,9 @@ Abakus::number_t RPNParser::rpnParseString(const QString &text)
Function *fn = 0; Function *fn = 0;
m_error = false; m_error = false;
m_errorStr = QString::null; m_errorStr = TQString();
for(QStringList::ConstIterator it = tokens.begin(); it != tokens.end(); ++it) { for(TQStringList::ConstIterator it = tokens.begin(); it != tokens.end(); ++it) {
switch(tokenize(*it)) switch(tokenize(*it))
{ {
case Number: case Number:
@ -115,7 +115,7 @@ Abakus::number_t RPNParser::rpnParseString(const QString &text)
case Func: case Func:
if(m_stack.count() < 1) { if(m_stack.count() < 1) {
m_error = true; m_error = true;
m_errorStr = i18n("Insufficient operands for function %1").arg(*it); m_errorStr = i18n("Insufficient operands for function %1").tqarg(*it);
return Abakus::number_t::nan(); return Abakus::number_t::nan();
} }
@ -150,7 +150,7 @@ Abakus::number_t RPNParser::rpnParseString(const QString &text)
case Unknown: case Unknown:
m_error = true; m_error = true;
m_errorStr = i18n("Unknown token %1").arg(*it); m_errorStr = i18n("Unknown token %1").tqarg(*it);
return Abakus::number_t::nan(); return Abakus::number_t::nan();
break; break;
@ -226,7 +226,7 @@ Abakus::number_t RPNParser::rpnParseString(const QString &text)
return m_stack.top(); return m_stack.top();
} }
static int tokenize (const QString &token) static int tokenize (const TQString &token)
{ {
bool isOK; bool isOK;
@ -252,13 +252,13 @@ static int tokenize (const QString &token)
if(token.lower() == "remove") if(token.lower() == "remove")
return Remove; return Remove;
if(QRegExp("^\\w+$").search(token) != -1 && if(TQRegExp("^\\w+$").search(token) != -1 &&
QRegExp("\\d").search(token) == -1) TQRegExp("\\d").search(token) == -1)
{ {
return Ident; return Ident;
} }
if(QRegExp("^[-+*/=]$").search(token) != -1) if(TQRegExp("^[-+*/=]$").search(token) != -1)
return token[0]; return token[0];
return Unknown; return Unknown;

@ -19,24 +19,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
class QString; class TQString;
class Operand; class Operand;
template<class T> class QValueStack; template<class T> class TQValueStack;
typedef QValueStack<Operand> OperandStack; typedef TQValueStack<Operand> OperandStack;
#include "numerictypes.h" #include "numerictypes.h"
class RPNParser class RPNParser
{ {
public: public:
static Abakus::number_t rpnParseString(const QString &text); static Abakus::number_t rpnParseString(const TQString &text);
static bool wasError() { return m_error; } static bool wasError() { return m_error; }
static QString errorString() { return m_errorStr; } static TQString errorString() { return m_errorStr; }
static OperandStack &stack() { return m_stack; } static OperandStack &stack() { return m_stack; }
private: private:
static QString m_errorStr; static TQString m_errorStr;
static bool m_error; static bool m_error;
static OperandStack m_stack; static OperandStack m_stack;
}; };

@ -19,7 +19,7 @@
#include <kdebug.h> #include <kdebug.h>
#include <klocale.h> #include <klocale.h>
#include <qregexp.h> #include <tqregexp.h>
#include "numerictypes.h" #include "numerictypes.h"
#include "valuemanager.h" #include "valuemanager.h"
@ -34,43 +34,43 @@ ValueManager *ValueManager::instance()
return m_manager; return m_manager;
} }
ValueManager::ValueManager(QObject *parent, const char *name) : ValueManager::ValueManager(TQObject *tqparent, const char *name) :
QObject(parent, name) TQObject(tqparent, name)
{ {
m_values.insert("pi", Abakus::number_t::PI); m_values.insert("pi", Abakus::number_t::PI);
m_values.insert("e", Abakus::number_t::E); m_values.insert("e", Abakus::number_t::E);
} }
Abakus::number_t ValueManager::value(const QString &name) const Abakus::number_t ValueManager::value(const TQString &name) const
{ {
return m_values[name]; return m_values[name];
} }
bool ValueManager::isValueSet(const QString &name) const bool ValueManager::isValueSet(const TQString &name) const
{ {
return m_values.contains(name); return m_values.tqcontains(name);
} }
bool ValueManager::isValueReadOnly(const QString &name) const bool ValueManager::isValueReadOnly(const TQString &name) const
{ {
QRegExp readOnlyValues("^(ans|pi|e|stackCount)$"); TQRegExp readOnlyValues("^(ans|pi|e|stackCount)$");
return name.find(readOnlyValues) != -1; return name.tqfind(readOnlyValues) != -1;
} }
void ValueManager::setValue(const QString &name, const Abakus::number_t value) void ValueManager::setValue(const TQString &name, const Abakus::number_t value)
{ {
if(m_values.contains(name) && this->value(name) != value) if(m_values.tqcontains(name) && this->value(name) != value)
emit signalValueChanged(name, value); emit signalValueChanged(name, value);
else if(!m_values.contains(name)) else if(!m_values.tqcontains(name))
emit signalValueAdded(name, value); emit signalValueAdded(name, value);
m_values.replace(name, value); m_values.tqreplace(name, value);
} }
void ValueManager::removeValue(const QString &name) void ValueManager::removeValue(const TQString &name)
{ {
if(m_values.contains(name)) if(m_values.tqcontains(name))
emit signalValueRemoved(name); emit signalValueRemoved(name);
m_values.remove(name); m_values.remove(name);
@ -78,26 +78,26 @@ void ValueManager::removeValue(const QString &name)
void ValueManager::slotRemoveUserVariables() void ValueManager::slotRemoveUserVariables()
{ {
QStringList vars = valueNames(); TQStringList vars = valueNames();
for(QStringList::ConstIterator var = vars.constBegin(); var != vars.constEnd(); ++var) for(TQStringList::ConstIterator var = vars.constBegin(); var != vars.constEnd(); ++var)
if(!isValueReadOnly(*var)) if(!isValueReadOnly(*var))
removeValue(*var); removeValue(*var);
} }
QStringList ValueManager::valueNames() const TQStringList ValueManager::valueNames() const
{ {
return m_values.keys(); return m_values.keys();
} }
QString ValueManager::description(const QString &valueName) TQString ValueManager::description(const TQString &valueName)
{ {
if(valueName == "e") if(valueName == "e")
return i18n("Natural exponential base - 2.7182818"); return i18n("Natural exponential base - 2.7182818");
if(valueName == "pi") if(valueName == "pi")
return i18n("pi (π) - 3.1415926"); return i18n("pi (π) - 3.1415926");
return QString(); return TQString();
} }
#include "valuemanager.moc" #include "valuemanager.moc"

@ -19,46 +19,47 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <qobject.h> #include <tqobject.h>
#include <qmap.h> #include <tqmap.h>
#include <qstring.h> #include <tqstring.h>
#include <qstringlist.h> #include <tqstringlist.h>
#include "numerictypes.h" #include "numerictypes.h"
class ValueManager : public QObject class ValueManager : public TQObject
{ {
Q_OBJECT Q_OBJECT
TQ_OBJECT
public: public:
typedef QMap<QString, Abakus::number_t> valueMap; typedef TQMap<TQString, Abakus::number_t> valueMap;
static ValueManager *instance(); static ValueManager *instance();
Abakus::number_t value(const QString &name) const; Abakus::number_t value(const TQString &name) const;
bool isValueSet(const QString &name) const; bool isValueSet(const TQString &name) const;
bool isValueReadOnly(const QString &name) const; bool isValueReadOnly(const TQString &name) const;
void setValue(const QString &name, const Abakus::number_t value); void setValue(const TQString &name, const Abakus::number_t value);
void removeValue(const QString &name); void removeValue(const TQString &name);
QStringList valueNames() const; TQStringList valueNames() const;
/** /**
* Returns a textual description of a constant built-into abakus. * Returns a textual description of a constant built-into abakus.
*/ */
static QString description(const QString &valueName); static TQString description(const TQString &valueName);
signals: signals:
void signalValueAdded(const QString &name, Abakus::number_t value); void signalValueAdded(const TQString &name, Abakus::number_t value);
void signalValueRemoved(const QString &name); void signalValueRemoved(const TQString &name);
void signalValueChanged(const QString &name, Abakus::number_t newValue); void signalValueChanged(const TQString &name, Abakus::number_t newValue);
public slots: public slots:
void slotRemoveUserVariables(); void slotRemoveUserVariables();
private: private:
ValueManager(QObject *parent = 0, const char *name = "value manager"); ValueManager(TQObject *tqparent = 0, const char *name = "value manager");
static ValueManager *m_manager; static ValueManager *m_manager;
valueMap m_values; valueMap m_values;

Loading…
Cancel
Save