diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:42:31 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:42:31 +0000 |
commit | 576eb4299a00bc053db35414406f46372a0f70f2 (patch) | |
tree | 4c030922d533821db464af566188e7d40cc8848c /libkdegames/kchatbase.cpp | |
parent | 0718336b6017d1a4fc1d626544180a5a2a29ddec (diff) | |
download | tdegames-576eb4299a00bc053db35414406f46372a0f70f2.tar.gz tdegames-576eb4299a00bc053db35414406f46372a0f70f2.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1157643 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkdegames/kchatbase.cpp')
-rw-r--r-- | libkdegames/kchatbase.cpp | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/libkdegames/kchatbase.cpp b/libkdegames/kchatbase.cpp index 4ccd7b08..421e0224 100644 --- a/libkdegames/kchatbase.cpp +++ b/libkdegames/kchatbase.cpp @@ -26,9 +26,9 @@ #include <kapplication.h> #include <kdebug.h> -#include <qlayout.h> -#include <qcombobox.h> -#include <qpainter.h> +#include <tqlayout.h> +#include <tqcombobox.h> +#include <tqpainter.h> class KChatBaseTextPrivate { @@ -39,22 +39,22 @@ public: mMessageFont = 0; } - QString mName; - QString mMessage; + TQString mName; + TQString mMessage; - const QFont* mNameFont; - const QFont* mMessageFont; + const TQFont* mNameFont; + const TQFont* mMessageFont; }; -KChatBaseText::KChatBaseText(const QString& name, const QString& message) : QListBoxText() +KChatBaseText::KChatBaseText(const TQString& name, const TQString& message) : TQListBoxText() { init(); setName(name); setMessage(message); } -KChatBaseText::KChatBaseText(const QString& message) : QListBoxText() +KChatBaseText::KChatBaseText(const TQString& message) : TQListBoxText() { init(); setMessage(message); @@ -70,88 +70,88 @@ void KChatBaseText::init() d = new KChatBaseTextPrivate; } -void KChatBaseText::setName(const QString& n) +void KChatBaseText::setName(const TQString& n) { // d->mName = n; - d->mName = QString("%1: ").arg(n); - setText(QString("%1: %2").arg(name()).arg(message())); // esp. for sorting + d->mName = TQString("%1: ").arg(n); + setText(TQString("%1: %2").arg(name()).arg(message())); // esp. for sorting } -void KChatBaseText::setMessage(const QString& m) +void KChatBaseText::setMessage(const TQString& m) { d->mMessage = m; - setText(QString("%1: %2").arg(name()).arg(message())); // esp. for sorting + setText(TQString("%1: %2").arg(name()).arg(message())); // esp. for sorting } -const QString& KChatBaseText::name() const +const TQString& KChatBaseText::name() const { return d->mName; } -const QString& KChatBaseText::message() const +const TQString& KChatBaseText::message() const { return d->mMessage; } -QFont KChatBaseText::nameFont() const +TQFont KChatBaseText::nameFont() const { if (d->mNameFont) { return *d->mNameFont; } else if (listBox()) { return listBox()->font(); } else { - return QFont(); + return TQFont(); } } -QFont KChatBaseText::messageFont() const +TQFont KChatBaseText::messageFont() const { if (d->mMessageFont) { return *d->mMessageFont; } else if (listBox()) { return listBox()->font(); } else { - return QFont(); + return TQFont(); } } -void KChatBaseText::setNameFont(const QFont* f) +void KChatBaseText::setNameFont(const TQFont* f) { d->mNameFont = f; } -void KChatBaseText::setMessageFont(const QFont* f) +void KChatBaseText::setMessageFont(const TQFont* f) { d->mMessageFont = f; } -void KChatBaseText::paint(QPainter* painter) +void KChatBaseText::paint(TQPainter* painter) { - QFontMetrics fm = painter->fontMetrics(); + TQFontMetrics fm = painter->fontMetrics(); painter->setFont(nameFont()); painter->drawText(3, fm.ascent() + fm.leading()/2, name()); painter->setFont(messageFont()); - painter->drawText(3 + QFontMetrics(nameFont()).width(name()), fm.ascent() + fm.leading()/2, message()); + painter->drawText(3 + TQFontMetrics(nameFont()).width(name()), fm.ascent() + fm.leading()/2, message()); } -int KChatBaseText::width(QListBox* lb) const +int KChatBaseText::width(TQListBox* lb) const { int w = 0; if (lb) { w += 6; - w += QFontMetrics(nameFont()).width(name()); - w += QFontMetrics(messageFont()).width(message()); + w += TQFontMetrics(nameFont()).width(name()); + w += TQFontMetrics(messageFont()).width(message()); } // int w = lb ? lb->fontMetrics().width( text() ) + 6 : 0; // QT orig - return QMAX(w, QApplication::globalStrut().width()); + return QMAX(w, TQApplication::globalStrut().width()); } -int KChatBaseText::height(QListBox* lb) const +int KChatBaseText::height(TQListBox* lb) const { int h = 0; if (lb) { h += 2; // AB: is lineSpacing still correct? - if (QFontMetrics(nameFont()).lineSpacing() > QFontMetrics(messageFont()).lineSpacing()) { - h += QFontMetrics(nameFont()).lineSpacing(); + if (TQFontMetrics(nameFont()).lineSpacing() > TQFontMetrics(messageFont()).lineSpacing()) { + h += TQFontMetrics(nameFont()).lineSpacing(); } else { - h += QFontMetrics(messageFont()).lineSpacing(); + h += TQFontMetrics(messageFont()).lineSpacing(); } } // int h = lb ? lb->fontMetrics().lineSpacing() + 2 : 0; // QT orig - return QMAX(h, QApplication::globalStrut().height()); + return QMAX(h, TQApplication::globalStrut().height()); } @@ -168,21 +168,21 @@ public: mAcceptMessage = true; mMaxItems = -1; } - QListBox* mBox; + TQListBox* mBox; KLineEdit* mEdit; - QComboBox* mCombo; + TQComboBox* mCombo; bool mAcceptMessage; int mMaxItems; - QValueList<int> mIndex2Id; + TQValueList<int> mIndex2Id; - QFont mNameFont; - QFont mMessageFont; - QFont mSystemNameFont; - QFont mSystemMessageFont; + TQFont mNameFont; + TQFont mMessageFont; + TQFont mSystemNameFont; + TQFont mSystemMessageFont; }; -KChatBase::KChatBase(QWidget* parent, bool noComboBox) : QFrame(parent) +KChatBase::KChatBase(TQWidget* parent, bool noComboBox) : TQFrame(parent) { init(noComboBox); } @@ -203,31 +203,31 @@ void KChatBase::init(bool noComboBox) setMinimumWidth(100); setMinimumHeight(150); - QVBoxLayout* l = new QVBoxLayout(this); + TQVBoxLayout* l = new TQVBoxLayout(this); - d->mBox = new QListBox(this); - connect(d->mBox, SIGNAL(rightButtonClicked(QListBoxItem*, const QPoint&)), - this, SIGNAL(rightButtonClicked(QListBoxItem*, const QPoint&))); + d->mBox = new TQListBox(this); + connect(d->mBox, TQT_SIGNAL(rightButtonClicked(TQListBoxItem*, const TQPoint&)), + this, TQT_SIGNAL(rightButtonClicked(TQListBoxItem*, const TQPoint&))); l->addWidget(d->mBox); - d->mBox->setVScrollBarMode(QScrollView::AlwaysOn); - d->mBox->setHScrollBarMode(QScrollView::AlwaysOff); - d->mBox->setFocusPolicy(QWidget::NoFocus); -// d->mBox->setSelectionMode(QListBox::NoSelection); - d->mBox->setSelectionMode(QListBox::Single); + d->mBox->setVScrollBarMode(TQScrollView::AlwaysOn); + d->mBox->setHScrollBarMode(TQScrollView::AlwaysOff); + d->mBox->setFocusPolicy(TQWidget::NoFocus); +// d->mBox->setSelectionMode(TQListBox::NoSelection); + d->mBox->setSelectionMode(TQListBox::Single); l->addSpacing(5); - QHBoxLayout* h = new QHBoxLayout(l); + TQHBoxLayout* h = new TQHBoxLayout(l); d->mEdit = new KLineEdit(this); d->mEdit->setHandleSignals(false); d->mEdit->setTrapReturnKey(true); d->mEdit->completionObject(); // add the completion object d->mEdit->setCompletionMode(KGlobalSettings::CompletionNone); - connect(d->mEdit, SIGNAL(returnPressed(const QString&)), this, SLOT(slotReturnPressed(const QString&))); + connect(d->mEdit, TQT_SIGNAL(returnPressed(const TQString&)), this, TQT_SLOT(slotReturnPressed(const TQString&))); h->addWidget(d->mEdit); if (!noComboBox) { - d->mCombo = new QComboBox(this); + d->mCombo = new TQComboBox(this); h->addWidget(d->mCombo); addSendingEntry(i18n("Send to All Players"), SendToAll);//FIXME: where to put the id? } @@ -247,7 +247,7 @@ bool KChatBase::acceptMessage() const void KChatBase::setAcceptMessage(bool a) { d->mAcceptMessage = a; } -bool KChatBase::addSendingEntry(const QString& text, int id) +bool KChatBase::addSendingEntry(const TQString& text, int id) { //FIXME: is ID used correctly? // do we need ID at all? @@ -256,7 +256,7 @@ bool KChatBase::addSendingEntry(const QString& text, int id) return insertSendingEntry(text, id); } -bool KChatBase::insertSendingEntry(const QString& text, int id, int index) +bool KChatBase::insertSendingEntry(const TQString& text, int id, int index) { if (!d->mCombo) { kdWarning(11000) << "KChatBase: Cannot add an entry to the combo box" << endl; @@ -303,7 +303,7 @@ void KChatBase::removeSendingEntry(int id) d->mIndex2Id.remove(id); } -void KChatBase::changeSendingEntry(const QString& text, int id) +void KChatBase::changeSendingEntry(const TQString& text, int id) { if (!d->mCombo) { kdWarning(11000) << "KChatBase: Cannot change an entry in the combo box" << endl; @@ -336,7 +336,7 @@ int KChatBase::nextId() const return i; } -void KChatBase::addItem(const QListBoxItem* text) +void KChatBase::addItem(const TQListBoxItem* text) { d->mBox->insertItem(text); int index = d->mBox->count() -1; @@ -346,40 +346,40 @@ void KChatBase::addItem(const QListBoxItem* text) } } -void KChatBase::addMessage(const QString& fromName, const QString& text) +void KChatBase::addMessage(const TQString& fromName, const TQString& text) { //maybe "%1 says: %2" or so addItem(layoutMessage(fromName, text)); } -void KChatBase::addSystemMessage(const QString& fromName, const QString& text) +void KChatBase::addSystemMessage(const TQString& fromName, const TQString& text) { addItem(layoutSystemMessage(fromName, text)); } -QListBoxItem* KChatBase::layoutMessage(const QString& fromName, const QString& text) +TQListBoxItem* KChatBase::layoutMessage(const TQString& fromName, const TQString& text) { //TODO: KChatBaseConfigure? - e.g. color - QListBoxItem* message; + TQListBoxItem* message; if (text.startsWith("/me ")) { // replace "/me" by a nice star. leave one space after the star - QPixmap pix; - pix.load(locate("data", QString::fromLatin1("kdegames/pics/star.png"))); + TQPixmap pix; + pix.load(locate("data", TQString::fromLatin1("kdegames/pics/star.png"))); //TODO KChatBasePixmap? Should change the font here! - message = (QListBoxItem*)new QListBoxPixmap(pix, i18n("%1 %2").arg(fromName).arg(text.mid(3))); + message = (TQListBoxItem*)new TQListBoxPixmap(pix, i18n("%1 %2").arg(fromName).arg(text.mid(3))); } else { // the text is not edited in any way. just return an item KChatBaseText* m = new KChatBaseText(fromName, text); m->setNameFont(&d->mNameFont); m->setMessageFont(&d->mMessageFont); - message = (QListBoxItem*)m; + message = (TQListBoxItem*)m; } return message; } -QListBoxItem* KChatBase::layoutSystemMessage(const QString& fromName, const QString& text) +TQListBoxItem* KChatBase::layoutSystemMessage(const TQString& fromName, const TQString& text) { //TODO: KChatBaseConfigure? - e.g. color @@ -387,10 +387,10 @@ QListBoxItem* KChatBase::layoutSystemMessage(const QString& fromName, const QStr KChatBaseText* m = new KChatBaseText(i18n("--- %1").arg(fromName), text); m->setNameFont(&d->mSystemNameFont); m->setMessageFont(&d->mSystemMessageFont); - return (QListBoxItem*)m; + return (TQListBoxItem*)m; } -void KChatBase::slotReturnPressed(const QString& text) +void KChatBase::slotReturnPressed(const TQString& text) { if (text.length() <= 0) { // no text entered - probably hit return by accident @@ -399,12 +399,12 @@ void KChatBase::slotReturnPressed(const QString& text) return; } d->mEdit->completionObject()->addItem(text); -// connect(d->mEdit, SIGNAL(returnPressed(const QString&)), comp, SLOT(addItem(const QString&))); +// connect(d->mEdit, TQT_SIGNAL(returnPressed(const TQString&)), comp, TQT_SLOT(addItem(const TQString&))); d->mEdit->clear(); returnPressed(text); } -QString KChatBase::comboBoxItem(const QString& name) const +TQString KChatBase::comboBoxItem(const TQString& name) const { // TODO: such a function for "send to all" and "send to my group" return i18n("Send to %1").arg(name); } @@ -417,57 +417,57 @@ void KChatBase::slotClear() void KChatBase::setCompletionMode(KGlobalSettings::Completion mode) { d->mEdit->setCompletionMode(mode); } -void KChatBase::setNameFont(const QFont& font) +void KChatBase::setNameFont(const TQFont& font) { d->mNameFont = font; d->mBox->triggerUpdate(false); } -void KChatBase::setMessageFont(const QFont& font) +void KChatBase::setMessageFont(const TQFont& font) { d->mMessageFont = font; d->mBox->triggerUpdate(false); } -void KChatBase::setBothFont(const QFont& font) +void KChatBase::setBothFont(const TQFont& font) { setNameFont(font); setMessageFont(font); } -const QFont& KChatBase::nameFont() const +const TQFont& KChatBase::nameFont() const { return d->mNameFont; } -const QFont& KChatBase::messageFont() const +const TQFont& KChatBase::messageFont() const { return d->mMessageFont; } -void KChatBase::setSystemNameFont(const QFont& font) +void KChatBase::setSystemNameFont(const TQFont& font) { d->mSystemNameFont = font; d->mBox->triggerUpdate(false); } -void KChatBase::setSystemMessageFont(const QFont& font) +void KChatBase::setSystemMessageFont(const TQFont& font) { d->mSystemMessageFont = font; d->mBox->triggerUpdate(false); } -void KChatBase::setSystemBothFont(const QFont& font) +void KChatBase::setSystemBothFont(const TQFont& font) { setSystemNameFont(font); setSystemMessageFont(font); } -const QFont& KChatBase::systemNameFont() const +const TQFont& KChatBase::systemNameFont() const { return d->mSystemNameFont; } -const QFont& KChatBase::systemMessageFont() const +const TQFont& KChatBase::systemMessageFont() const { return d->mSystemMessageFont; } void KChatBase::saveConfig(KConfig* conf) { - QString oldGroup; + TQString oldGroup; if (!conf) { conf = kapp->config(); oldGroup = conf->group(); @@ -487,7 +487,7 @@ void KChatBase::saveConfig(KConfig* conf) void KChatBase::readConfig(KConfig* conf) { - QString oldGroup; + TQString oldGroup; if (!conf) { conf = kapp->config(); oldGroup = conf->group(); |