diff options
author | Slávek Banko <[email protected]> | 2016-04-09 20:52:09 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2016-04-09 20:52:09 +0200 |
commit | 91d2d7482c36e67cb36df9d1dcdbd989911e4ceb (patch) | |
tree | c842adfbb1a172d9b61241d7dde70354e821bb75 /src/qalculateexpressionedit.cpp | |
parent | 4870c0c8c53d3df6ba954b2b4d8ebd87a8c43060 (diff) | |
download | qalculate-tde-91d2d7482c36e67cb36df9d1dcdbd989911e4ceb.tar.gz qalculate-tde-91d2d7482c36e67cb36df9d1dcdbd989911e4ceb.zip |
Initial TQt conversion
Signed-off-by: Slávek Banko <[email protected]>
Diffstat (limited to 'src/qalculateexpressionedit.cpp')
-rw-r--r-- | src/qalculateexpressionedit.cpp | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/src/qalculateexpressionedit.cpp b/src/qalculateexpressionedit.cpp index f6d8156..ab6a2cf 100644 --- a/src/qalculateexpressionedit.cpp +++ b/src/qalculateexpressionedit.cpp @@ -23,17 +23,17 @@ #include "kqalculate.h" #include <kdeversion.h> #include <kcursor.h> -#include <qstyle.h> -#include <qpainter.h> -#include <qapplication.h> -#include <qfontmetrics.h> +#include <tqstyle.h> +#include <tqpainter.h> +#include <tqapplication.h> +#include <tqfontmetrics.h> #include <kstringhandler.h> #include <kpopupmenu.h> #include <kxmlguifactory.h> #include <kxmlguiclient.h> #include <kaction.h> #include <klocale.h> -#include <qsimplerichtext.h> +#include <tqsimplerichtext.h> extern vector<mode_struct> modes; @@ -44,15 +44,15 @@ extern bool rpn_mode, rpn_keypad_only; extern tree_struct function_cats, unit_cats, variable_cats; extern vector<void*> ia_units, ia_variables, ia_functions; -class QalculateExpressionEditListBoxItem : public QListBoxItem { +class QalculateExpressionEditListBoxItem : public TQListBoxItem { public: QalculateExpressionEditListBoxItem(ExpressionItem *eitem); virtual ~QalculateExpressionEditListBoxItem(); - int height(const QListBox*) const; - int width(const QListBox*) const; + int height(const TQListBox*) const; + int width(const TQListBox*) const; bool reuse(ExpressionItem *newItem); @@ -60,17 +60,17 @@ public: protected: - void paint(QPainter*); + void paint(TQPainter*); private: - QString title; + TQString title; int italic_index; bool rich_text; }; -QalculateExpressionEdit::QalculateExpressionEdit(bool connected_to_main_win, QWidget *parent, const char *name) : KLineEdit(parent, name) { +QalculateExpressionEdit::QalculateExpressionEdit(bool connected_to_main_win, TQWidget *parent, const char *name) : KLineEdit(parent, name) { qalculateCompletionBox = new QalculateExpressionEditCompletionBox(this); qalculateCompletion = new KCompletion(); @@ -91,15 +91,15 @@ QalculateExpressionEdit::QalculateExpressionEdit(bool connected_to_main_win, QWi prev_position = 0; pos_timer = startTimer(50); - connect(qalculateCompletionBox, SIGNAL(highlighted(QListBoxItem*)), this, SLOT(insertCompletion(QListBoxItem*))); - connect(qalculateCompletionBox, SIGNAL(userCancelled(const QString&)), this, SLOT(cancelCompletion(const QString&))); - connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); + connect(qalculateCompletionBox, SIGNAL(highlighted(TQListBoxItem*)), this, SLOT(insertCompletion(TQListBoxItem*))); + connect(qalculateCompletionBox, SIGNAL(userCancelled(const TQString&)), this, SLOT(cancelCompletion(const TQString&))); + connect(this, SIGNAL(textChanged(const TQString&)), this, SLOT(onTextChanged(const TQString&))); } QalculateExpressionEdit::~QalculateExpressionEdit() {} -void QalculateExpressionEdit::timerEvent(QTimerEvent *event) { +void QalculateExpressionEdit::timerEvent(TQTimerEvent *event) { if(event->timerId() == pos_timer) { if(cursorPosition() != prev_position) { prev_position = cursorPosition(); @@ -110,7 +110,7 @@ void QalculateExpressionEdit::timerEvent(QTimerEvent *event) { } } -void QalculateExpressionEdit::onTextChanged(const QString &str) { +void QalculateExpressionEdit::onTextChanged(const TQString &str) { if(str.isEmpty()) { if(qalculateCompletionBox) { qalculateCompletionBox->hide(); @@ -121,7 +121,7 @@ void QalculateExpressionEdit::onTextChanged(const QString &str) { prev_position = cursorPosition(); } -void QalculateExpressionEdit::cancelCompletion(const QString &str) { +void QalculateExpressionEdit::cancelCompletion(const TQString &str) { int new_pos = pos_before_completion; setText(str); setCursorPosition(new_pos); @@ -137,10 +137,10 @@ bool QalculateExpressionEdit::completionEnabled() const { return completionMode() == KGlobalSettings::CompletionPopup; } -QPopupMenu *QalculateExpressionEdit::createPopupMenu() { +TQPopupMenu *QalculateExpressionEdit::createPopupMenu() { setCompletionObject(NULL); - QPopupMenu *menu = KLineEdit::createPopupMenu(); + TQPopupMenu *menu = KLineEdit::createPopupMenu(); setCompletionObject(qalculateCompletion); menu->insertSeparator(); if(completionMode() == KGlobalSettings::CompletionPopup) menu->insertItem(i18n("Disable Completion"), this, SLOT(disableCompletion())); @@ -150,8 +150,8 @@ QPopupMenu *QalculateExpressionEdit::createPopupMenu() { mainWin->ActionReadPrecision->plug(menu); mainWin->ActionLimitImplicitMultiplication->plug(menu); mainWin->ActionRPNMode->plug(menu); - QPopupMenu *modes_menu = new QPopupMenu(menu); - QObject::connect(modes_menu, SIGNAL(activated(int)), mainWin, SLOT(loadMode(int))); + TQPopupMenu *modes_menu = new TQPopupMenu(menu); + TQObject::connect(modes_menu, SIGNAL(activated(int)), mainWin, SLOT(loadMode(int))); for(size_t i = 0; i < modes.size(); i++) { modes_menu->insertItem(modes[i].name, i, i); } @@ -167,15 +167,15 @@ QPopupMenu *QalculateExpressionEdit::createPopupMenu() { } -#if QT_VERSION >= 0x030200 +#if TQT_VERSION >= 0x030200 #define GET_SELECTION int start = selectionStart(), end = -1; if(start >= 0) end = start + selectedText().length(); #else #define GET_SELECTION int start = -1, end = -1; getSelection(&start, &end); #endif #define RESTORE_SELECTION if(start > 0) setSelection(start, end - start); -void QalculateExpressionEdit::addToHistory(const QString &str) { - for(QStringList::Iterator it = expression_history.begin(); it != expression_history.end(); ++it) { +void QalculateExpressionEdit::addToHistory(const TQString &str) { + for(TQStringList::Iterator it = expression_history.begin(); it != expression_history.end(); ++it) { if(*it == str) { expression_history.erase(it); break; @@ -193,13 +193,13 @@ void QalculateExpressionEdit::setAfterCompletionPosition() { setCursorPosition(cpos_ac); } -void QalculateExpressionEdit::insertCompletion(QListBoxItem *li) { +void QalculateExpressionEdit::insertCompletion(TQListBoxItem *li) { ExpressionItem *item = ((QalculateExpressionEditListBoxItem*) li)->item; setSelection(cstart, cend - cstart + 1); - QString str = completed_text; + TQString str = completed_text; const ExpressionName *ename = NULL, *ename_r = NULL; ename_r = &item->preferredInputName(false, printops.use_unicode_signs, false, false, &can_display_unicode_string_function, (void*) this); for(size_t name_i = 0; name_i <= item->countNames() && !ename; name_i++) { @@ -265,7 +265,7 @@ void QalculateExpressionEdit::insertCompletion(QListBoxItem *li) { } -bool matchesExpressionItem(const QString &str, ExpressionItem *item) { +bool matchesExpressionItem(const TQString &str, ExpressionItem *item) { bool b_match = false; for(size_t name_i = 1; !b_match && name_i <= item->countNames(); name_i++) { const ExpressionName *ename = &item->getName(name_i); @@ -282,7 +282,7 @@ bool matchesExpressionItem(const QString &str, ExpressionItem *item) { return b_match; } -void QalculateExpressionEdit::makeCompletion(const QString &str) { +void QalculateExpressionEdit::makeCompletion(const TQString &str) { if(cursorPosition() <= 0 || str.isEmpty()) { if(qalculateCompletionBox) { qalculateCompletionBox->hide(); @@ -292,7 +292,7 @@ void QalculateExpressionEdit::makeCompletion(const QString &str) { } uint start = (uint) cursorPosition(); cend = (int) start - 1; - QString str2 = str; + TQString str2 = str; str2.truncate(start); const char *cstr = str2.ascii(); bool non_number_before = false; @@ -385,7 +385,7 @@ void QalculateExpressionEdit::wrapSelection() { } } -void QalculateExpressionEdit::keyPressEvent(QKeyEvent *e) { +void QalculateExpressionEdit::keyPressEvent(TQKeyEvent *e) { if(e->key() == Key_Enter || e->key() == Key_Return) { if(b_main) { mainWin->execute(); @@ -626,10 +626,10 @@ void QalculateExpressionEdit::keyPressEvent(QKeyEvent *e) { KLineEdit::keyPressEvent(e); } -bool QalculateExpressionEdit::eventFilter(QObject *o, QEvent *ev) { - if(o == this && ev->type() == QEvent::KeyPress) { - QKeyEvent *e = static_cast<QKeyEvent *>(ev); - if((e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && qalculateCompletionBox && qalculateCompletionBox->isVisible()) { +bool QalculateExpressionEdit::eventFilter(TQObject *o, TQEvent *ev) { + if(o == this && ev->type() == TQEvent::KeyPress) { + TQKeyEvent *e = static_cast<TQKeyEvent *>(ev); + if((e->key() == TQt::Key_Return || e->key() == TQt::Key_Enter) && qalculateCompletionBox && qalculateCompletionBox->isVisible()) { if(qalculateCompletionBox->selectedItem()) { KCursor::autoHideEventFilter(this, ev); e->accept(); @@ -646,7 +646,7 @@ bool QalculateExpressionEdit::eventFilter(QObject *o, QEvent *ev) { } -void set_title(ExpressionItem *item, QString &title) { +void set_title(ExpressionItem *item, TQString &title) { if(item->type() != TYPE_VARIABLE || !item->title(false).empty()) { title = item->title().c_str(); } else { @@ -748,7 +748,7 @@ string sub_suffix(const ExpressionName *ename) { return str; } -QString makeListName(ExpressionItem *item, QWidget *w, int *italic_index, bool *rich_text) { +TQString makeListName(ExpressionItem *item, TQWidget *w, int *italic_index, bool *rich_text) { string str; const ExpressionName *ename, *ename_r; *rich_text = false; @@ -783,7 +783,7 @@ QString makeListName(ExpressionItem *item, QWidget *w, int *italic_index, bool * return str.c_str(); } -QalculateExpressionEditListBoxItem::QalculateExpressionEditListBoxItem(ExpressionItem *eitem) : QListBoxItem() { +QalculateExpressionEditListBoxItem::QalculateExpressionEditListBoxItem(ExpressionItem *eitem) : TQListBoxItem() { item = eitem; italic_index = -1; setText(makeListName(item, listBox(), &italic_index, &rich_text)); @@ -793,13 +793,13 @@ QalculateExpressionEditListBoxItem::~QalculateExpressionEditListBoxItem() { } #if KDE_VERSION_MAJOR < 4 && KDE_VERSION_MINOR < 2 -QString rPixelSqueeze(const QString& name, const QFontMetrics& fontMetrics, uint maxPixels) +TQString rPixelSqueeze(const TQString& name, const TQFontMetrics& fontMetrics, uint maxPixels) { uint nameWidth = fontMetrics.width(name); if (maxPixels < nameWidth) { - QString tmp = name; + TQString tmp = name; const uint em = fontMetrics.maxWidth(); maxPixels -= fontMetrics.width("..."); @@ -822,18 +822,18 @@ QString rPixelSqueeze(const QString& name, const QFontMetrics& fontMetrics, uint } #endif -void QalculateExpressionEditListBoxItem::paint(QPainter *painter) { +void QalculateExpressionEditListBoxItem::paint(TQPainter *painter) { int itemHeight = height(listBox()); - int entryWidth = listBox()->width() - listBox()->style().pixelMetric(QStyle::PM_ScrollBarExtent) - 2 * listBox()->style().pixelMetric(QStyle::PM_DefaultFrameWidth); + int entryWidth = listBox()->width() - listBox()->style().pixelMetric(TQStyle::PM_ScrollBarExtent) - 2 * listBox()->style().pixelMetric(TQStyle::PM_DefaultFrameWidth); int titleWidth = (entryWidth / 2) - 1; int nameWidth = entryWidth - titleWidth - 2; if(!text().isEmpty()) { - QString squeezedText; + TQString squeezedText; if(rich_text) { - QSimpleRichText rt(text(), painter->font()); + TQSimpleRichText rt(text(), painter->font()); rt.setWidth(entryWidth); if(rt.widthUsed() > nameWidth - 1) { squeezedText = text(); @@ -843,11 +843,11 @@ void QalculateExpressionEditListBoxItem::paint(QPainter *painter) { #else squeezedText = KStringHandler::rPixelSqueeze(squeezedText, listBox()->fontMetrics(), nameWidth); #endif - painter->drawText(0, 0, nameWidth, itemHeight, Qt::AlignLeft | Qt::AlignVCenter, squeezedText); + painter->drawText(0, 0, nameWidth, itemHeight, TQt::AlignLeft | TQt::AlignVCenter, squeezedText); } else { - QColorGroup cg = listBox()->colorGroup(); - cg.setColor(QColorGroup::Text, painter->pen().color()); - rt.draw(painter, 1, 0, QRect(0, 0, nameWidth - 1, itemHeight), cg, &painter->brush()); + TQColorGroup cg = listBox()->colorGroup(); + cg.setColor(TQColorGroup::Text, painter->pen().color()); + rt.draw(painter, 1, 0, TQRect(0, 0, nameWidth - 1, itemHeight), cg, &painter->brush()); } } else { #if KDE_VERSION_MAJOR < 4 && KDE_VERSION_MINOR < 2 @@ -855,29 +855,29 @@ void QalculateExpressionEditListBoxItem::paint(QPainter *painter) { #else squeezedText = KStringHandler::rPixelSqueeze(text(), listBox()->fontMetrics(), nameWidth); #endif - painter->drawText(0, 0, nameWidth, itemHeight, Qt::AlignLeft | Qt::AlignVCenter, squeezedText); + painter->drawText(0, 0, nameWidth, itemHeight, TQt::AlignLeft | TQt::AlignVCenter, squeezedText); } #if KDE_VERSION_MAJOR < 4 && KDE_VERSION_MINOR < 2 squeezedText = rPixelSqueeze(title, listBox()->fontMetrics(), titleWidth); #else squeezedText = KStringHandler::rPixelSqueeze(title, listBox()->fontMetrics(), titleWidth); #endif - QFont font = painter->font(); + TQFont font = painter->font(); font.setItalic(true); painter->setFont(font); - painter->drawText(entryWidth - titleWidth, 0, titleWidth, itemHeight, Qt::AlignLeft | Qt::AlignVCenter, squeezedText); + painter->drawText(entryWidth - titleWidth, 0, titleWidth, itemHeight, TQt::AlignLeft | TQt::AlignVCenter, squeezedText); } } -int QalculateExpressionEditListBoxItem::height(const QListBox *lb) const { +int QalculateExpressionEditListBoxItem::height(const TQListBox *lb) const { int h; h = lb->fontMetrics().lineSpacing() + 4; - return QMAX(h, QApplication::globalStrut().height()); + return TQMAX(h, TQApplication::globalStrut().height()); } -int QalculateExpressionEditListBoxItem::width(const QListBox *lb) const { - return QMAX(lb->fontMetrics().width(text()) + 6, QApplication::globalStrut().width()); +int QalculateExpressionEditListBoxItem::width(const TQListBox *lb) const { + return TQMAX(lb->fontMetrics().width(text()) + 6, TQApplication::globalStrut().width()); } bool QalculateExpressionEditListBoxItem::reuse(ExpressionItem *newItem) { if(item == newItem) return false; @@ -888,17 +888,17 @@ bool QalculateExpressionEditListBoxItem::reuse(ExpressionItem *newItem) { return true; } -QalculateExpressionEditCompletionBox::QalculateExpressionEditCompletionBox(QWidget *parent, const char *name) : KCompletionBox(parent, name) { +QalculateExpressionEditCompletionBox::QalculateExpressionEditCompletionBox(TQWidget *parent, const char *name) : KCompletionBox(parent, name) { } QalculateExpressionEditCompletionBox::~QalculateExpressionEditCompletionBox() { } -void QalculateExpressionEditCompletionBox::setItems(const QValueVector<ExpressionItem*>& items) { +void QalculateExpressionEditCompletionBox::setItems(const TQValueVector<ExpressionItem*>& items) { bool block = signalsBlocked(); blockSignals(true); - QListBoxItem* item = firstItem(); + TQListBoxItem* item = firstItem(); if(!item) { insertItemList(items); } else { @@ -907,12 +907,12 @@ void QalculateExpressionEditCompletionBox::setItems(const QValueVector<Expressio //to reduce flicker bool dirty = false; -#if QT_VERSION >= 0x030200 - QValueVector<ExpressionItem*>::ConstIterator it = items.constBegin(); - const QValueVector<ExpressionItem*>::ConstIterator itEnd = items.constEnd(); +#if TQT_VERSION >= 0x030200 + TQValueVector<ExpressionItem*>::ConstIterator it = items.constBegin(); + const TQValueVector<ExpressionItem*>::ConstIterator itEnd = items.constEnd(); #else - QValueVector<ExpressionItem*>::ConstIterator it = items.begin(); - const QValueVector<ExpressionItem*>::ConstIterator itEnd = items.end(); + TQValueVector<ExpressionItem*>::ConstIterator it = items.begin(); + const TQValueVector<ExpressionItem*>::ConstIterator itEnd = items.end(); #endif for (; it != itEnd; ++it) { @@ -930,7 +930,7 @@ void QalculateExpressionEditCompletionBox::setItems(const QValueVector<Expressio //If there is an unused item, mark as dirty -> less items now if(item) dirty = true; - QListBoxItem* tmp = item; + TQListBoxItem* tmp = item; while((item = tmp)) { tmp = item->next(); delete item; @@ -952,21 +952,21 @@ void QalculateExpressionEditCompletionBox::setItems(const QValueVector<Expressio blockSignals(block); // Trigger d->down_workaround = true within KCompletionBox - QStringList dummy; + TQStringList dummy; KCompletionBox::insertItems(dummy, 1); } -void QalculateExpressionEditCompletionBox::insertItemList(const QValueVector<ExpressionItem*> & list, int index) { +void QalculateExpressionEditCompletionBox::insertItemList(const TQValueVector<ExpressionItem*> & list, int index) { if(index < 0) index = count(); - for(QValueVector<ExpressionItem*>::ConstIterator it = list.begin(); it != list.end(); ++it) { + for(TQValueVector<ExpressionItem*>::ConstIterator it = list.begin(); it != list.end(); ++it) { insertItem(new QalculateExpressionEditListBoxItem(*it), index++); } } void QalculateExpressionEdit::setCompletedItems() { - QString txt; + TQString txt; if(qalculateCompletionBox && qalculateCompletionBox->isVisible()) { // The popup is visible already - do the matching on the initial string, // not on the currently selected one. @@ -979,9 +979,9 @@ void QalculateExpressionEdit::setCompletedItems() { if(qalculateCompletionBox->isVisible()) { bool wasSelected = qalculateCompletionBox->isSelected(qalculateCompletionBox->currentItem()); - const QString currentSelection = qalculateCompletionBox->currentText(); + const TQString currentSelection = qalculateCompletionBox->currentText(); qalculateCompletionBox->setItems(matched_items); - QListBoxItem* item = qalculateCompletionBox->findItem(currentSelection, Qt::ExactMatch); + TQListBoxItem* item = qalculateCompletionBox->findItem(currentSelection, TQt::ExactMatch); // If no item is selected, that means the listbox hasn't been manipulated by the user yet, // because it's not possible otherwise to have no selected item. In such case make // always the first item current and unselected, so that the current item doesn't jump. @@ -1011,7 +1011,7 @@ void QalculateExpressionEdit::setCompletedItems() { } -void QalculateExpressionEditCompletionBox::hideEvent(QHideEvent*) { +void QalculateExpressionEditCompletionBox::hideEvent(TQHideEvent*) { emit hidden(); } |