diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-05-17 08:20:48 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-05-17 08:20:48 +0000 |
commit | aa0726b20f398264f0a2abc60215be044b106f9c (patch) | |
tree | 070fdbc19a1106cfdd7f651a8ce76bb1b89a513d /src/tag.cpp | |
parent | d3cf5b3e75aadc3b02d0b56f030d4c3f8c2c749d (diff) | |
download | basket-aa0726b20f398264f0a2abc60215be044b106f9c.tar.gz basket-aa0726b20f398264f0a2abc60215be044b106f9c.zip |
TQt4 port basket
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/basket@1232416 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/tag.cpp')
-rw-r--r-- | src/tag.cpp | 308 |
1 files changed, 154 insertions, 154 deletions
diff --git a/src/tag.cpp b/src/tag.cpp index a4ed7e6..0532d37 100644 --- a/src/tag.cpp +++ b/src/tag.cpp @@ -21,10 +21,10 @@ #include <kapplication.h> #include <kstyle.h> #include <kiconloader.h> -#include <qpainter.h> -#include <qfont.h> -#include <qdom.h> -#include <qdir.h> +#include <tqpainter.h> +#include <tqfont.h> +#include <tqdom.h> +#include <tqdir.h> #include <kglobalsettings.h> #include <klocale.h> @@ -40,7 +40,7 @@ /** class State: */ -State::State(const QString &id, Tag *tag) +State::State(const TQString &id, Tag *tag) : m_id(id), m_name(), m_emblem(), m_bold(false), m_italic(false), m_underline(false), m_strikeOut(false), m_textColor(), m_fontName(), m_fontSize(-1), m_backgroundColor(), m_textEquivalent(), m_onAllTextLines(false), m_parentTag(tag) { @@ -52,10 +52,10 @@ State::~State() State* State::nextState(bool cycle /*= true*/) { - if (!parentTag()) + if (!tqparentTag()) return 0; - List states = parentTag()->states(); + List states = tqparentTag()->states(); // The tag contains only one state: if (states.count() == 1) return 0; @@ -73,14 +73,14 @@ State* State::nextState(bool cycle /*= true*/) return 0; } -QString State::fullName() +TQString State::fullName() { - if (!parentTag() || parentTag()->states().count() == 1) - return (name().isEmpty() && parentTag() ? parentTag()->name() : name()); - return QString(i18n("%1: %2")).arg(parentTag()->name(), name()); + if (!tqparentTag() || tqparentTag()->states().count() == 1) + return (name().isEmpty() && tqparentTag() ? tqparentTag()->name() : name()); + return TQString(i18n("%1: %2")).tqarg(tqparentTag()->name(), name()); } -QFont State::font(QFont base) +TQFont State::font(TQFont base) { if (bold()) base.setBold(true); @@ -97,9 +97,9 @@ QFont State::font(QFont base) return base; } -QString State::toCSS(const QString &gradientFolderPath, const QString &gradientFolderName, const QFont &baseFont) +TQString State::toCSS(const TQString &gradientFolderPath, const TQString &gradientFolderName, const TQFont &baseFont) { - QString css; + TQString css; if (bold()) css += " font-weight: bold;"; if (italic()) @@ -113,18 +113,18 @@ QString State::toCSS(const QString &gradientFolderPath, const QString &gradientF if (textColor().isValid()) css += " color: " + textColor().name() + ";"; if (!fontName().isEmpty()) { - QString fontFamily = Tools::cssFontDefinition(fontName(), /*onlyFontFamily=*/true); + TQString fontFamily = Tools::cssFontDefinition(fontName(), /*onlyFontFamily=*/true); css += " font-family: " + fontFamily + ";"; } if (fontSize() > 0) - css += " font-size: " + QString::number(fontSize()) + "px;"; + css += " font-size: " + TQString::number(fontSize()) + "px;"; if (backgroundColor().isValid()) { // Get the colors of the gradient and the border: - QColor topBgColor; - QColor bottomBgColor; + TQColor topBgColor; + TQColor bottomBgColor; Note::getGradientColors(backgroundColor(), &topBgColor, &bottomBgColor); // Produce the CSS code: - QString gradientFileName = Basket::saveGradientBackground(backgroundColor(), font(baseFont), gradientFolderPath); + TQString gradientFileName = Basket::saveGradientBackground(backgroundColor(), font(baseFont), gradientFolderPath); css += " background: " + bottomBgColor.name() + " url('" + gradientFolderName + gradientFileName + "') repeat-x;"; css += " border-top: solid " + topBgColor.name() + " 1px;"; css += " border-bottom: solid " + Tools::mixColor(topBgColor, bottomBgColor).name() + " 1px;"; @@ -136,7 +136,7 @@ QString State::toCSS(const QString &gradientFolderPath, const QString &gradientF return " .tag_" + id() + " {" + css + " }\n"; } -void State::merge(const List &states, State *result, int *emblemsCount, bool *haveInvisibleTags, const QColor &backgroundColor) +void State::merge(const List &states, State *result, int *emblemsCount, bool *haveInvisibleTags, const TQColor &backgroundColor) { *result = State(); // Reset to default values. *emblemsCount = 0; @@ -222,8 +222,8 @@ Tag::Tag() { static int tagNumber = 0; ++tagNumber; - QString sAction = "tag_shortcut_number_" + QString::number(tagNumber); - m_action = new KAction("FAKE TEXT", "FAKE ICON", KShortcut(), Global::bnpView, SLOT(activatedTagShortcut()), Global::bnpView->actionCollection(), sAction); + TQString sAction = "tag_shortcut_number_" + TQString::number(tagNumber); + m_action = new KAction("FAKE TEXT", "FAKE ICON", KShortcut(), TQT_TQOBJECT(Global::bnpView), TQT_SLOT(activatedTagShortcut()), Global::bnpView->actionCollection(), sAction); m_action->setShortcutConfigurable(false); // We do it in the tag properties dialog m_inheritedBySiblings = false; @@ -234,13 +234,13 @@ Tag::~Tag() delete m_action; } -void Tag::setName(const QString &name) +void Tag::setName(const TQString &name) { m_name = name; m_action->setText("TAG SHORTCUT: " + name); // TODO: i18n (for debug purpose only by now). } -State* Tag::stateForId(const QString &id) +State* Tag::stateForId(const TQString &id) { for (List::iterator it = all.begin(); it != all.end(); ++it) for (State::List::iterator it2 = (*it)->states().begin(); it2 != (*it)->states().end(); ++it2) @@ -257,15 +257,15 @@ Tag* Tag::tagForKAction(KAction *action) return 0; } -QMap<QString, QString> Tag::loadTags(const QString &path/* = QString()*//*, bool merge = false*/) +TQMap<TQString, TQString> Tag::loadTags(const TQString &path/* = TQString()*//*, bool merge = false*/) { - QMap<QString, QString> mergedStates; + TQMap<TQString, TQString> mergedStates; bool merge = !path.isEmpty(); - QString fullPath = (merge ? path : Global::savesFolder() + "tags.xml"); - QString doctype = "basketTags"; + TQString fullPath = (merge ? path : Global::savesFolder() + "tags.xml"); + TQString doctype = "basketTags"; - QDir dir; + TQDir dir; if (!dir.exists(fullPath)) { if (merge) return mergedStates; @@ -273,50 +273,50 @@ QMap<QString, QString> Tag::loadTags(const QString &path/* = QString()*//*, bool createDefaultTagsSet(fullPath); } - QDomDocument *document = XMLWork::openFile(doctype, fullPath); + TQDomDocument *document = XMLWork::openFile(doctype, fullPath); if (!document) { DEBUG_WIN << "<font color=red>FAILED to read the tags file</font>"; return mergedStates; } - QDomElement docElem = document->documentElement(); + TQDomElement docElem = document->documentElement(); if (!merge) - nextStateUid = docElem.attribute("nextStateUid", QString::number(nextStateUid)).toLong(); + nextStateUid = docElem.attribute("nextStateUid", TQString::number(nextStateUid)).toLong(); - QDomNode node = docElem.firstChild(); + TQDomNode node = docElem.firstChild(); while (!node.isNull()) { - QDomElement element = node.toElement(); + TQDomElement element = node.toElement(); if ( (!element.isNull()) && element.tagName() == "tag" ) { Tag *tag = new Tag(); // Load properties: - QString name = XMLWork::getElementText(element, "name"); - QString shortcut = XMLWork::getElementText(element, "shortcut"); - QString inherited = XMLWork::getElementText(element, "inherited", "false"); + TQString name = XMLWork::getElementText(element, "name"); + TQString shortcut = XMLWork::getElementText(element, "shortcut"); + TQString inherited = XMLWork::getElementText(element, "inherited", "false"); tag->setName(name); tag->setShortcut(KShortcut(shortcut)); tag->setInheritedBySiblings(XMLWork::trueOrFalse(inherited)); // Load states: - QDomNode subNode = element.firstChild(); + TQDomNode subNode = element.firstChild(); while (!subNode.isNull()) { - QDomElement subElement = subNode.toElement(); + TQDomElement subElement = subNode.toElement(); if ( (!subElement.isNull()) && subElement.tagName() == "state" ) { State *state = new State(subElement.attribute("id"), tag); state->setName( XMLWork::getElementText(subElement, "name") ); state->setEmblem( XMLWork::getElementText(subElement, "emblem") ); - QDomElement textElement = XMLWork::getElement(subElement, "text"); + TQDomElement textElement = XMLWork::getElement(subElement, "text"); state->setBold( XMLWork::trueOrFalse(textElement.attribute("bold", "false")) ); state->setItalic( XMLWork::trueOrFalse(textElement.attribute("italic", "false")) ); state->setUnderline( XMLWork::trueOrFalse(textElement.attribute("underline", "false")) ); state->setStrikeOut( XMLWork::trueOrFalse(textElement.attribute("strikeOut", "false")) ); - QString textColor = textElement.attribute("color", ""); - state->setTextColor(textColor.isEmpty() ? QColor() : QColor(textColor)); - QDomElement fontElement = XMLWork::getElement(subElement, "font"); + TQString textColor = textElement.attribute("color", ""); + state->setTextColor(textColor.isEmpty() ? TQColor() : TQColor(textColor)); + TQDomElement fontElement = XMLWork::getElement(subElement, "font"); state->setFontName(fontElement.attribute("name", "")); - QString fontSize = fontElement.attribute("size", ""); + TQString fontSize = fontElement.attribute("size", ""); state->setFontSize(fontSize.isEmpty() ? -1 : fontSize.toInt()); - QString backgroundColor = XMLWork::getElementText(subElement, "backgroundColor", ""); - state->setBackgroundColor(backgroundColor.isEmpty() ? QColor() : QColor(backgroundColor)); - QDomElement textEquivalentElement = XMLWork::getElement(subElement, "textEquivalent"); + TQString backgroundColor = XMLWork::getElementText(subElement, "backgroundColor", ""); + state->setBackgroundColor(backgroundColor.isEmpty() ? TQColor() : TQColor(backgroundColor)); + TQDomElement textEquivalentElement = XMLWork::getElement(subElement, "textEquivalent"); state->setTextEquivalent( textEquivalentElement.attribute("string", "") ); state->setOnAllTextLines( XMLWork::trueOrFalse(textEquivalentElement.attribute("onAllTextLines", "false")) ); tag->appendState(state); @@ -341,8 +341,8 @@ QMap<QString, QString> Tag::loadTags(const QString &path/* = QString()*//*, bool // We are merging the new states, so we should choose new and unique (on that computer) ids for those states: for (State::List::iterator it = tag->states().begin(); it != tag->states().end(); ++it) { State *state = *it; - QString uid = state->id(); - QString newUid = "tag_state_" + QString::number(getNextStateUid()); + TQString uid = state->id(); + TQString newUid = "tag_state_" + TQString::number(getNextStateUid()); state->setId(newUid); mergedStates[uid] = newUid; } @@ -354,8 +354,8 @@ QMap<QString, QString> Tag::loadTags(const QString &path/* = QString()*//*, bool for (State::List::iterator it = tag->states().begin(); it != tag->states().end(); ++it, ++it2) { State *state = *it; State *similarState = *it2; - QString uid = state->id(); - QString newUid = similarState->id(); + TQString uid = state->id(); + TQString newUid = similarState->id(); if (uid != newUid) mergedStates[uid] = newUid; } @@ -422,11 +422,11 @@ void Tag::saveTags() saveTagsTo(all, Global::savesFolder() + "tags.xml"); } -void Tag::saveTagsTo(QValueList<Tag*> &list, const QString &fullPath) +void Tag::saveTagsTo(TQValueList<Tag*> &list, const TQString &fullPath) { // Create Document: - QDomDocument document(/*doctype=*/"basketTags"); - QDomElement root = document.createElement("basketTags"); + TQDomDocument document(/*doctype=*/"basketTags"); + TQDomElement root = document.createElement("basketTags"); root.setAttribute("nextStateUid", nextStateUid); document.appendChild(root); @@ -434,7 +434,7 @@ void Tag::saveTagsTo(QValueList<Tag*> &list, const QString &fullPath) for (List::iterator it = list.begin(); it != list.end(); ++it) { Tag *tag = *it; // Create tag node: - QDomElement tagNode = document.createElement("tag"); + TQDomElement tagNode = document.createElement("tag"); root.appendChild(tagNode); // Save tag properties: XMLWork::addElement( document, tagNode, "name", tag->name() ); @@ -444,27 +444,27 @@ void Tag::saveTagsTo(QValueList<Tag*> &list, const QString &fullPath) for (State::List::iterator it2 = (*it)->states().begin(); it2 != (*it)->states().end(); ++it2) { State *state = *it2; // Create state node: - QDomElement stateNode = document.createElement("state"); + TQDomElement stateNode = document.createElement("state"); tagNode.appendChild(stateNode); // Save state properties: stateNode.setAttribute("id", state->id()); XMLWork::addElement( document, stateNode, "name", state->name() ); XMLWork::addElement( document, stateNode, "emblem", state->emblem() ); - QDomElement textNode = document.createElement("text"); + TQDomElement textNode = document.createElement("text"); stateNode.appendChild(textNode); - QString textColor = (state->textColor().isValid() ? state->textColor().name() : ""); + TQString textColor = (state->textColor().isValid() ? state->textColor().name() : ""); textNode.setAttribute( "bold", XMLWork::trueOrFalse(state->bold()) ); textNode.setAttribute( "italic", XMLWork::trueOrFalse(state->italic()) ); textNode.setAttribute( "underline", XMLWork::trueOrFalse(state->underline()) ); textNode.setAttribute( "strikeOut", XMLWork::trueOrFalse(state->strikeOut()) ); textNode.setAttribute( "color", textColor ); - QDomElement fontNode = document.createElement("font"); + TQDomElement fontNode = document.createElement("font"); stateNode.appendChild(fontNode); fontNode.setAttribute( "name", state->fontName() ); fontNode.setAttribute( "size", state->fontSize() ); - QString backgroundColor = (state->backgroundColor().isValid() ? state->backgroundColor().name() : ""); + TQString backgroundColor = (state->backgroundColor().isValid() ? state->backgroundColor().name() : ""); XMLWork::addElement( document, stateNode, "backgroundColor", backgroundColor ); - QDomElement textEquivalentNode = document.createElement("textEquivalent"); + TQDomElement textEquivalentNode = document.createElement("textEquivalent"); stateNode.appendChild(textEquivalentNode); textEquivalentNode.setAttribute( "string", state->textEquivalent() ); textEquivalentNode.setAttribute( "onAllTextLines", XMLWork::trueOrFalse(state->onAllTextLines()) ); @@ -483,9 +483,9 @@ void Tag::copyTo(Tag *other) other->m_inheritedBySiblings = m_inheritedBySiblings; } -void Tag::createDefaultTagsSet(const QString &fullPath) +void Tag::createDefaultTagsSet(const TQString &fullPath) { - QString xml = QString( + TQString xml = TQString( "<!DOCTYPE basketTags>\n" "<basketTags>\n" " <tag>\n" @@ -541,10 +541,10 @@ void Tag::createDefaultTagsSet(const QString &fullPath) " </state>\n" " </tag>\n" "\n") - .arg( i18n("To Do"), i18n("Unchecked"), i18n("Done") ) // %1 %2 %3 - .arg( i18n("Progress"), i18n("0 %"), i18n("25 %") ) // %4 %5 %6 - .arg( i18n("50 %"), i18n("75 %"), i18n("100 %") ) // %7 %8 %9 - + QString( + .tqarg( i18n("To Do"), i18n("Unchecked"), i18n("Done") ) // %1 %2 %3 + .tqarg( i18n("Progress"), i18n("0 %"), i18n("25 %") ) // %4 %5 %6 + .tqarg( i18n("50 %"), i18n("75 %"), i18n("100 %") ) // %7 %8 %9 + + TQString( " <tag>\n" " <name>%1</name>\n" // "Priority" " <shortcut>Ctrl+3</shortcut>\n" @@ -596,10 +596,10 @@ void Tag::createDefaultTagsSet(const QString &fullPath) " </state>\n" " </tag>\n" "\n") - .arg( i18n("Priority"), i18n("Low"), i18n("Medium") ) // %1 %2 %3 - .arg( i18n("High"), i18n("Preference"), i18n("Bad") ) // %4 %5 %6 - .arg( i18n("Good"), i18n("Excellent"), i18n("Highlight") ) // %7 %8 %9 - + QString( + .tqarg( i18n("Priority"), i18n("Low"), i18n("Medium") ) // %1 %2 %3 + .tqarg( i18n("High"), i18n("Preference"), i18n("Bad") ) // %4 %5 %6 + .tqarg( i18n("Good"), i18n("Excellent"), i18n("Highlight") ) // %7 %8 %9 + + TQString( " <tag>\n" " <name>%1</name>\n" // "Important" " <shortcut>Ctrl+6</shortcut>\n" @@ -664,10 +664,10 @@ void Tag::createDefaultTagsSet(const QString &fullPath) " </state>\n" " </tag>""\n" "\n") - .arg( i18n("Important"), i18n("Very Important"), i18n("Information") ) // %1 %2 %3 - .arg( i18n("Idea"), i18n("The initial of 'Idea'", "I."), i18n("Title") ) // %4 %5 %6 - .arg( i18n("Code"), i18n("Work"), i18n("The initial of 'Work'", "W.") ) // %7 %8 %9 - + QString( + .tqarg( i18n("Important"), i18n("Very Important"), i18n("Information") ) // %1 %2 %3 + .tqarg( i18n("Idea"), i18n("The initial of 'Idea'", "I."), i18n("Title") ) // %4 %5 %6 + .tqarg( i18n("Code"), i18n("Work"), i18n("The initial of 'Work'", "W.") ) // %7 %8 %9 + + TQString( " <tag>\n" " <state id=\"personal\">\n" " <name>%1</name>\n" // "Personal" @@ -684,13 +684,13 @@ void Tag::createDefaultTagsSet(const QString &fullPath) " </tag>\n" "</basketTags>\n" "") - .arg( i18n("Personal"), i18n("The initial of 'Personal'", "P."), i18n("Funny") ); // %1 %2 %3 + .tqarg( i18n("Personal"), i18n("The initial of 'Personal'", "P."), i18n("Funny") ); // %1 %2 %3 // Write to Disk: - QFile file(fullPath); + TQFile file(fullPath); if (file.open(IO_WriteOnly)) { - QTextStream stream(&file); - stream.setEncoding(QTextStream::UnicodeUTF8); + TQTextStream stream(&file); + stream.setEncoding(TQTextStream::UnicodeUTF8); stream << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; stream << xml; file.close(); @@ -699,18 +699,18 @@ void Tag::createDefaultTagsSet(const QString &fullPath) } #include <kapplication.h> -#include <qrect.h> -#include <qstyle.h> -#include <qcheckbox.h> -#include <qbitmap.h> +#include <tqrect.h> +#include <tqstyle.h> +#include <tqcheckbox.h> +#include <tqbitmap.h> #include <kglobalsettings.h> -#include <qimage.h> -#include <qradiobutton.h> +#include <tqimage.h> +#include <tqradiobutton.h> #include <kiconeffect.h> /** class IndentedMenuItem: */ -IndentedMenuItem::IndentedMenuItem(const QString &text, const QString &icon, const QString &shortcut) +IndentedMenuItem::IndentedMenuItem(const TQString &text, const TQString &icon, const TQString &shortcut) : m_text(text), m_icon(icon), m_shortcut(shortcut) { } @@ -719,10 +719,10 @@ IndentedMenuItem::~IndentedMenuItem() { } -void IndentedMenuItem::paint(QPainter *painter, const QColorGroup &cg, bool active, bool enabled, int x, int y, int w, int h) +void IndentedMenuItem::paint(TQPainter *painter, const TQColorGroup &cg, bool active, bool enabled, int x, int y, int w, int h) { - QPen pen = painter->pen(); - QFont font = painter->font(); + TQPen pen = painter->pen(); + TQFont font = painter->font(); int iconSize = KIcon::SizeSmall; int iconMargin = StateMenuItem::iconMargin(); @@ -736,14 +736,14 @@ void IndentedMenuItem::paint(QPainter *painter, const QColorGroup &cg, bool acti */ bool drawingEtchedText = !enabled && !active && painter->pen().color() != cg.mid()/*== cg.foreground()*/; if (drawingEtchedText) { - QString styleName = kapp->style().name(); + TQString styleName = kapp->tqstyle().name(); if (styleName == "plastik" || styleName == "lipstik") painter->setPen(cg.light()); drawingEtchedText = !enabled && !active && painter->pen().color() != cg.foreground(); } else drawingEtchedText = !enabled && !active && painter->pen().color() == cg.light(); if (!m_icon.isEmpty() && !drawingEtchedText) { - QPixmap icon = kapp->iconLoader()->loadIcon(m_icon, KIcon::Small, iconSize, + TQPixmap icon = kapp->iconLoader()->loadIcon(m_icon, KIcon::Small, iconSize, (enabled ? (active ? KIcon::ActiveState : KIcon::DefaultState) : KIcon::DisabledState), /*path_store=*/0L, /*canReturnNull=*/true); painter->drawPixmap(x, y + (h-iconSize)/2, icon); @@ -768,30 +768,30 @@ void IndentedMenuItem::paint(QPainter *painter, const QColorGroup &cg, bool acti } } -QSize IndentedMenuItem::sizeHint() +TQSize IndentedMenuItem::tqsizeHint() { int iconSize = KIcon::SizeSmall; int iconMargin = StateMenuItem::iconMargin(); - QSize textSize = QFontMetrics(KGlobalSettings::menuFont()).size( AlignLeft | AlignVCenter | ShowPrefix | DontClip, m_text ); - return QSize(iconSize + iconMargin + textSize.width(), textSize.height()); + TQSize textSize = TQFontMetrics(KGlobalSettings::menuFont()).size( AlignLeft | AlignVCenter | ShowPrefix | DontClip, m_text ); + return TQSize(iconSize + iconMargin + textSize.width(), textSize.height()); } /** class StateMenuItem: */ -StateMenuItem::StateMenuItem(State *state, const QString &shortcut, bool withTagName) +StateMenuItem::StateMenuItem(State *state, const TQString &shortcut, bool withTagName) : m_state(state), m_shortcut(shortcut) { - m_name = (withTagName && m_state->parentTag() ? m_state->parentTag()->name() : m_state->name()); + m_name = (withTagName && m_state->tqparentTag() ? m_state->tqparentTag()->name() : m_state->name()); } StateMenuItem::~StateMenuItem() { } -void StateMenuItem::paint(QPainter *painter, const QColorGroup &cg, bool active, bool enabled, int x, int y, int w, int h) +void StateMenuItem::paint(TQPainter *painter, const TQColorGroup &cg, bool active, bool enabled, int x, int y, int w, int h) { - QPen pen = painter->pen(); - QFont font = painter->font(); + TQPen pen = painter->pen(); + TQFont font = painter->font(); int iconSize = 16; // We use 16 instead of KIcon::SizeSmall (the size of icons in menus) because tags will always be 16*16 icons @@ -806,14 +806,14 @@ void StateMenuItem::paint(QPainter *painter, const QColorGroup &cg, bool active, */ bool drawingEtchedText = !enabled && !active && painter->pen().color() != cg.mid()/*== cg.foreground()*/; if (drawingEtchedText) { - QString styleName = kapp->style().name(); + TQString styleName = kapp->tqstyle().name(); if (styleName == "plastik" || styleName == "lipstik") painter->setPen(cg.light()); drawingEtchedText = !enabled && !active && painter->pen().color() != cg.foreground(); } else drawingEtchedText = !enabled && !active && painter->pen().color() == cg.light(); if (!m_state->emblem().isEmpty() && !drawingEtchedText) { - QPixmap icon = kapp->iconLoader()->loadIcon(m_state->emblem(), KIcon::Small, iconSize, + TQPixmap icon = kapp->iconLoader()->loadIcon(m_state->emblem(), KIcon::Small, iconSize, (enabled ? (active ? KIcon::ActiveState : KIcon::DefaultState) : KIcon::DisabledState), /*path_store=*/0L, /*canReturnNull=*/true); painter->drawPixmap(x, y + (h-iconSize)/2, icon); @@ -841,94 +841,94 @@ void StateMenuItem::paint(QPainter *painter, const QColorGroup &cg, bool active, } } -QSize StateMenuItem::sizeHint() +TQSize StateMenuItem::tqsizeHint() { int iconSize = 16; // We use 16 instead of KIcon::SizeSmall (the size of icons in menus) because tags will always be 16*16 icons - QFont theFont = m_state->font(KGlobalSettings::menuFont()); - QSize textSize = QFontMetrics(theFont).size( AlignLeft | AlignVCenter | ShowPrefix | DontClip, m_name ); - return QSize(iconSize + iconMargin() + textSize.width(), textSize.height()); + TQFont theFont = m_state->font(KGlobalSettings::menuFont()); + TQSize textSize = TQFontMetrics(theFont).size( AlignLeft | AlignVCenter | ShowPrefix | DontClip, m_name ); + return TQSize(iconSize + iconMargin() + textSize.width(), textSize.height()); } -QIconSet StateMenuItem::checkBoxIconSet(bool checked, QColorGroup cg) +TQIconSet StateMenuItem::checkBoxIconSet(bool checked, TQColorGroup cg) { - int width = kapp->style().pixelMetric(QStyle::PM_IndicatorWidth, 0); - int height = kapp->style().pixelMetric(QStyle::PM_IndicatorHeight, 0); - QRect rect(0, 0, width, height); + int width = kapp->tqstyle().tqpixelMetric(TQStyle::PM_IndicatorWidth, 0); + int height = kapp->tqstyle().tqpixelMetric(TQStyle::PM_IndicatorHeight, 0); + TQRect rect(0, 0, width, height); - QColor menuBackgroundColor = (dynamic_cast<KStyle*>(&(kapp->style())) == NULL ? cg.background() : cg.background().light(103)); + TQColor menuBackgroundColor = (dynamic_cast<KStyle*>(&(kapp->tqstyle())) == NULL ? TQColor(cg.background()) : cg.background().light(103)); // Enabled, Not hovering - QPixmap pixmap(width, height); - pixmap.fill(menuBackgroundColor); // In case the pixelMetric() haven't returned a bigger rectangle than what drawPrimitive() draws - QPainter painter(&pixmap); - int style = QStyle::Style_Enabled | QStyle::Style_Active | (checked ? QStyle::Style_On : QStyle::Style_Off); - QColor background = cg.color(QColorGroup::Background); - kapp->style().drawPrimitive(QStyle::PE_Indicator, &painter, rect, cg, style); + TQPixmap pixmap(width, height); + pixmap.fill(menuBackgroundColor); // In case the tqpixelMetric() haven't returned a bigger rectangle than what drawPrimitive() draws + TQPainter painter(&pixmap); + int style = TQStyle::Style_Enabled | TQStyle::Style_Active | (checked ? TQStyle::Style_On : TQStyle::Style_Off); + TQColor background = cg.color(TQColorGroup::Background); + kapp->tqstyle().tqdrawPrimitive(TQStyle::PE_Indicator, &painter, rect, cg, style); painter.end(); // Enabled, Hovering - QPixmap pixmapHover(width, height); - pixmapHover.fill(menuBackgroundColor); // In case the pixelMetric() haven't returned a bigger rectangle than what drawPrimitive() draws + TQPixmap pixmapHover(width, height); + pixmapHover.fill(menuBackgroundColor); // In case the tqpixelMetric() haven't returned a bigger rectangle than what drawPrimitive() draws painter.begin(&pixmapHover); - style |= QStyle::Style_MouseOver; - cg.setColor(QColorGroup::Background, KGlobalSettings::highlightColor()); - kapp->style().drawPrimitive(QStyle::PE_Indicator, &painter, rect, cg, style); + style |= TQStyle::Style_MouseOver; + cg.setColor(TQColorGroup::Background, KGlobalSettings::highlightColor()); + kapp->tqstyle().tqdrawPrimitive(TQStyle::PE_Indicator, &painter, rect, cg, style); painter.end(); // Disabled - QPixmap pixmapDisabled(width, height); - pixmapDisabled.fill(menuBackgroundColor); // In case the pixelMetric() haven't returned a bigger rectangle than what drawPrimitive() draws + TQPixmap pixmapDisabled(width, height); + pixmapDisabled.fill(menuBackgroundColor); // In case the tqpixelMetric() haven't returned a bigger rectangle than what drawPrimitive() draws painter.begin(&pixmapDisabled); - style = /*QStyle::Style_Enabled | */QStyle::Style_Active | (checked ? QStyle::Style_On : QStyle::Style_Off); - cg.setColor(QColorGroup::Background, background); - kapp->style().drawPrimitive(QStyle::PE_Indicator, &painter, rect, cg, style); + style = /*TQStyle::Style_Enabled | */TQStyle::Style_Active | (checked ? TQStyle::Style_On : TQStyle::Style_Off); + cg.setColor(TQColorGroup::Background, background); + kapp->tqstyle().tqdrawPrimitive(TQStyle::PE_Indicator, &painter, rect, cg, style); painter.end(); - QIconSet iconSet(pixmap); - iconSet.setPixmap(pixmapHover, QIconSet::Automatic, QIconSet::Active); - iconSet.setPixmap(pixmapDisabled, QIconSet::Automatic, QIconSet::Disabled); + TQIconSet iconSet(pixmap); + iconSet.setPixmap(pixmapHover, TQIconSet::Automatic, TQIconSet::Active); + iconSet.setPixmap(pixmapDisabled, TQIconSet::Automatic, TQIconSet::Disabled); return iconSet; } -QIconSet StateMenuItem::radioButtonIconSet(bool checked, QColorGroup cg) +TQIconSet StateMenuItem::radioButtonIconSet(bool checked, TQColorGroup cg) { - int width = kapp->style().pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, 0); - int height = kapp->style().pixelMetric(QStyle::PM_ExclusiveIndicatorHeight, 0); - QRect rect(0, 0, width, height); + int width = kapp->tqstyle().tqpixelMetric(TQStyle::PM_ExclusiveIndicatorWidth, 0); + int height = kapp->tqstyle().tqpixelMetric(TQStyle::PM_ExclusiveIndicatorHeight, 0); + TQRect rect(0, 0, width, height); - int style = QStyle::Style_Default | QStyle::Style_Enabled | (checked ? QStyle::Style_On : QStyle::Style_Off); + int style = TQStyle::Style_Default | TQStyle::Style_Enabled | (checked ? TQStyle::Style_On : TQStyle::Style_Off); - QPixmap pixmap(width, height); - pixmap.fill(Qt::red); - QPainter painter(&pixmap); + TQPixmap pixmap(width, height); + pixmap.fill(TQt::red); + TQPainter painter(&pixmap); /* We can't use that line of code (like for checkboxes): - * //kapp->style().drawPrimitive(QStyle::PE_ExclusiveIndicator, &painter, rect, cg, style); - * because Plastik (and derived styles) don't care of the QStyle::Style_On flag and will ALWAYS draw an unchecked radiobutton. + * //kapp->tqstyle().tqdrawPrimitive(TQStyle::PE_ExclusiveIndicator, &painter, rect, cg, style); + * because Plastik (and derived styles) don't care of the TQStyle::Style_On flag and will ALWAYS draw an unchecked radiobutton. * So, we use another method: */ - QRadioButton rb(0); + TQRadioButton rb(0); rb.setChecked(checked); - kapp->style().drawControl(QStyle::CE_RadioButton, &painter, &rb, rect, cg, style); + kapp->tqstyle().tqdrawControl(TQStyle::CE_RadioButton, &painter, &rb, rect, cg, style); painter.end(); - /* Some styles like Plastik (and derived ones) have QStyle::PE_ExclusiveIndicator drawing a radiobutton disc, as wanted, - * and leave pixels ouside it untouched, BUT QStyle::PE_ExclusiveIndicatorMask is a fully black square. - * So, we can't apply the mask to make the radiobutton circle transparent outside. - * We're using an hack by filling the pixmap in Qt::red, drawing the radiobutton and then creating an heuristic mask. - * The heuristic mask is created using the 4 edge pixels (that are red) and by making transparent every pixels that are of this color: + /* Some styles like Plastik (and derived ones) have TQStyle::PE_ExclusiveIndicator drawing a radiobutton disc, as wanted, + * and leave pixels ouside it untouched, BUT TQStyle::PE_ExclusiveIndicatorMask is a fully black square. + * So, we can't apply the tqmask to make the radiobutton circle transparent outside. + * We're using an hack by filling the pixmap in TQt::red, drawing the radiobutton and then creating an heuristic tqmask. + * The heuristic tqmask is created using the 4 edge pixels (that are red) and by making transparent every pixels that are of this color: */ pixmap.setMask(pixmap.createHeuristicMask()); - QPixmap pixmapHover(width, height); - pixmapHover.fill(Qt::red); + TQPixmap pixmapHover(width, height); + pixmapHover.fill(TQt::red); painter.begin(&pixmapHover); - //kapp->style().drawPrimitive(QStyle::PE_ExclusiveIndicator, &painter, rect, cg, style); - style |= QStyle::Style_MouseOver; - cg.setColor(QColorGroup::Background, KGlobalSettings::highlightColor()); - kapp->style().drawControl(QStyle::CE_RadioButton, &painter, &rb, rect, cg, style); + //kapp->tqstyle().tqdrawPrimitive(TQStyle::PE_ExclusiveIndicator, &painter, rect, cg, style); + style |= TQStyle::Style_MouseOver; + cg.setColor(TQColorGroup::Background, KGlobalSettings::highlightColor()); + kapp->tqstyle().tqdrawControl(TQStyle::CE_RadioButton, &painter, &rb, rect, cg, style); painter.end(); pixmapHover.setMask(pixmapHover.createHeuristicMask()); - QIconSet iconSet(pixmap); - iconSet.setPixmap(pixmapHover, QIconSet::Automatic, QIconSet::Active); + TQIconSet iconSet(pixmap); + iconSet.setPixmap(pixmapHover, TQIconSet::Automatic, TQIconSet::Active); return iconSet; } |