diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-04-27 00:40:29 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-04-27 00:40:29 +0000 |
commit | 7a741e43ff09e70396a918956219b8316c48e522 (patch) | |
tree | 3d0f60eccd59786cea7236db2d5c4c1f25874515 /src/infosidebarpage.cpp | |
parent | a48487ef0c329434b58b6f920111bb0999f1109e (diff) | |
download | dolphin-7a741e43ff09e70396a918956219b8316c48e522.tar.gz dolphin-7a741e43ff09e70396a918956219b8316c48e522.zip |
TQt4 port Dolphin
This enables compilation under Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/dolphin@1229359 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/infosidebarpage.cpp')
-rw-r--r-- | src/infosidebarpage.cpp | 236 |
1 files changed, 118 insertions, 118 deletions
diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp index 3143b03..b777ac1 100644 --- a/src/infosidebarpage.cpp +++ b/src/infosidebarpage.cpp @@ -20,18 +20,18 @@ #include "infosidebarpage.h" #include <assert.h> -#include <qlayout.h> -#include <qpixmap.h> -#include <qlabel.h> -#include <qtimer.h> -#include <qpushbutton.h> -#include <qvbox.h> -#include <qvgroupbox.h> -#include <qpopupmenu.h> -#include <qpainter.h> -#include <qfontmetrics.h> -#include <qgrid.h> -#include <qhgroupbox.h> +#include <tqlayout.h> +#include <tqpixmap.h> +#include <tqlabel.h> +#include <tqtimer.h> +#include <tqpushbutton.h> +#include <tqvbox.h> +#include <tqvgroupbox.h> +#include <tqpopupmenu.h> +#include <tqpainter.h> +#include <tqfontmetrics.h> +#include <tqgrid.h> +#include <tqhgroupbox.h> #include <kbookmarkmanager.h> #include <klocale.h> @@ -46,8 +46,8 @@ #include "pixmapviewer.h" #include "dolphinsettings.h" -InfoSidebarPage::InfoSidebarPage(QWidget* parent) : - SidebarPage(parent), +InfoSidebarPage::InfoSidebarPage(TQWidget* tqparent) : + SidebarPage(tqparent), m_multipleSelection(false), m_pendingPreview(false), m_timer(0), @@ -59,12 +59,12 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) : { const int spacing = KDialog::spacingHint(); - m_timer = new QTimer(this); - connect(m_timer, SIGNAL(timeout()), - this, SLOT(slotTimeout())); + m_timer = new TQTimer(this); + connect(m_timer, TQT_SIGNAL(timeout()), + this, TQT_SLOT(slotTimeout())); - QVBoxLayout* layout = new QVBoxLayout(this); - layout->setSpacing(spacing); + TQVBoxLayout* tqlayout = new TQVBoxLayout(this); + tqlayout->setSpacing(spacing); // preview m_preview = new PixmapViewer(this); @@ -72,42 +72,42 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) : m_preview->setFixedHeight(KIcon::SizeEnormous); // name - m_name = new QLabel(this); - m_name->setTextFormat(Qt::RichText); - m_name->setAlignment(m_name->alignment() | Qt::AlignHCenter); - QFontMetrics fontMetrics(m_name->font()); + m_name = new TQLabel(this); + m_name->setTextFormat(TQt::RichText); + m_name->tqsetAlignment(m_name->tqalignment() | TQt::AlignHCenter); + TQFontMetrics fontMetrics(m_name->font()); m_name->setMinimumHeight(fontMetrics.height() * 3); - m_name->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum); + m_name->tqsetSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::Maximum); - QWidget* sep1 = new QHGroupBox(this); // TODO: check whether default widget exist for this? + TQWidget* sep1 = new TQHGroupBox(this); // TODO: check whether default widget exist for this? sep1->setFixedHeight(1); // general information - m_infoGrid = new QGrid(2, this); - m_infoGrid->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + m_infoGrid = new TQGrid(2, this); + m_infoGrid->tqsetSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed); - QWidget* sep2 = new QHGroupBox(this); // TODO: check whether default widget exist for this? + TQWidget* sep2 = new TQHGroupBox(this); // TODO: check whether default widget exist for this? sep2->setFixedHeight(1); // actions - m_actionBox = new QVBox(this); - m_actionBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + m_actionBox = new TQVBox(this); + m_actionBox->tqsetSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed); // Add a dummy widget with no restriction regarding a vertical resizing. // This assures that information is always top aligned. - QWidget* dummy = new QWidget(this); + TQWidget* dummy = new TQWidget(this); - layout->addItem(new QSpacerItem(spacing, spacing, QSizePolicy::Preferred, QSizePolicy::Fixed)); - layout->addWidget(m_preview); - layout->addWidget(m_name); - layout->addWidget(sep1); - layout->addWidget(m_infoGrid); - layout->addWidget(sep2); - layout->addWidget(m_actionBox); - layout->addWidget(dummy); + tqlayout->addItem(new TQSpacerItem(spacing, spacing, TQSizePolicy::Preferred, TQSizePolicy::Fixed)); + tqlayout->addWidget(m_preview); + tqlayout->addWidget(m_name); + tqlayout->addWidget(sep1); + tqlayout->addWidget(m_infoGrid); + tqlayout->addWidget(sep2); + tqlayout->addWidget(m_actionBox); + tqlayout->addWidget(dummy); - connect(&Dolphin::mainWin(), SIGNAL(selectionChanged()), - this, SLOT(showItemInfo())); + connect(&Dolphin::mainWin(), TQT_SIGNAL(selectionChanged()), + this, TQT_SLOT(showItemInfo())); connectToActiveView(); } @@ -156,7 +156,7 @@ void InfoSidebarPage::showItemInfo() if (m_multipleSelection) { KIconLoader iconLoader; - QPixmap icon = iconLoader.loadIcon("exec", + TQPixmap icon = iconLoader.loadIcon("exec", KIcon::NoGroup, KIcon::SizeEnormous); m_preview->setPixmap(icon); @@ -168,17 +168,17 @@ void InfoSidebarPage::showItemInfo() list.append(m_shownURL); m_pendingPreview = true; - m_preview->setPixmap(QPixmap()); + m_preview->setPixmap(TQPixmap()); KIO::PreviewJob* job = KIO::filePreview(list, m_preview->width(), KIcon::SizeEnormous); - connect(job, SIGNAL(gotPreview(const KFileItem*, const QPixmap&)), - this, SLOT(gotPreview(const KFileItem*, const QPixmap&))); - connect(job, SIGNAL(failed(const KFileItem*)), - this, SLOT(slotPreviewFailed(const KFileItem*))); + connect(job, TQT_SIGNAL(gotPreview(const KFileItem*, const TQPixmap&)), + this, TQT_SLOT(gotPreview(const KFileItem*, const TQPixmap&))); + connect(job, TQT_SIGNAL(failed(const KFileItem*)), + this, TQT_SLOT(slotPreviewFailed(const KFileItem*))); - QString text("<b>"); + TQString text("<b>"); text.append(m_shownURL.fileName()); text.append("</b>"); m_name->setText(text); @@ -203,7 +203,7 @@ void InfoSidebarPage::slotPreviewFailed(const KFileItem* item) } void InfoSidebarPage::gotPreview(const KFileItem* /* item */, - const QPixmap& pixmap) + const TQPixmap& pixmap) { if (m_pendingPreview) { m_preview->setPixmap(pixmap); @@ -228,10 +228,10 @@ void InfoSidebarPage::connectToActiveView() cancelRequest(); DolphinView* view = Dolphin::mainWin().activeView(); - connect(view, SIGNAL(signalRequestItemInfo(const KURL&)), - this, SLOT(requestDelayedItemInfo(const KURL&))); - connect(view, SIGNAL(signalURLChanged(const KURL&)), - this, SLOT(requestItemInfo(const KURL&))); + connect(view, TQT_SIGNAL(signalRequestItemInfo(const KURL&)), + this, TQT_SLOT(requestDelayedItemInfo(const KURL&))); + connect(view, TQT_SIGNAL(signalURLChanged(const KURL&)), + this, TQT_SLOT(requestItemInfo(const KURL&))); m_shownURL = view->url(); showItemInfo(); @@ -243,13 +243,13 @@ bool InfoSidebarPage::applyBookmark() KBookmark bookmark = root.first(); while (!bookmark.isNull()) { if (m_shownURL.equals(bookmark.url(), true)) { - QString text("<b>"); + TQString text("<b>"); text.append(bookmark.text()); text.append("</b>"); m_name->setText(text); KIconLoader iconLoader; - QPixmap icon = iconLoader.loadIcon(bookmark.icon(), + TQPixmap icon = iconLoader.loadIcon(bookmark.icon(), KIcon::NoGroup, KIcon::SizeEnormous); m_preview->setPixmap(icon); @@ -285,14 +285,14 @@ void InfoSidebarPage::createMetaInfo() else { addInfoLine(i18n("Type:"), fileItem.mimeComment()); - QString sizeText(KIO::convertSize(fileItem.size())); + TQString sizeText(KIO::convertSize(fileItem.size())); addInfoLine(i18n("Size:"), sizeText); addInfoLine(i18n("Modified:"), fileItem.timeString()); const KFileMetaInfo& metaInfo = fileItem.metaInfo(); if (metaInfo.isValid()) { - QStringList keys = metaInfo.supportedKeys(); - for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { + TQStringList keys = metaInfo.supportedKeys(); + for (TQStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { if (showMetaInfo(*it)) { KFileMetaInfoItem metaInfoItem = metaInfo.item(*it); addInfoLine(*it, metaInfoItem.string()); @@ -317,10 +317,10 @@ void InfoSidebarPage::endInfoLines() // remove labels which have not been used if (m_currInfoLineIdx < static_cast<int>(m_infoWidgets.count())) { - QPtrListIterator<QLabel> deleteIter(m_infoWidgets); + TQPtrListIterator<TQLabel> deleteIter(m_infoWidgets); deleteIter += m_currInfoLineIdx; - QWidget* widget = 0; + TQWidget* widget = 0; int removeCount = 0; while ((widget = deleteIter.current()) != 0) { widget->close(); @@ -334,7 +334,7 @@ void InfoSidebarPage::endInfoLines() } } -bool InfoSidebarPage::showMetaInfo(const QString& key) const +bool InfoSidebarPage::showMetaInfo(const TQString& key) const { // sorted list of keys, where it's data should be shown static const char* keys[] = { @@ -372,9 +372,9 @@ bool InfoSidebarPage::showMetaInfo(const QString& key) const return false; } -void InfoSidebarPage::addInfoLine(const QString& labelText, const QString& infoText) +void InfoSidebarPage::addInfoLine(const TQString& labelText, const TQString& infoText) { - QString labelStr("<b>"); + TQString labelStr("<b>"); labelStr.append(labelText); labelStr.append("</b> "); @@ -386,16 +386,16 @@ void InfoSidebarPage::addInfoLine(const QString& labelText, const QString& infoT } else { // no labels are available anymore, hence create 2 new ones - QLabel* label = new QLabel(labelStr, m_infoGrid); - label->setTextFormat(Qt::RichText); - label->setAlignment(Qt::AlignRight | - Qt::AlignTop); + TQLabel* label = new TQLabel(labelStr, m_infoGrid); + label->setTextFormat(TQt::RichText); + label->tqsetAlignment(TQt::AlignRight | + TQt::AlignTop); label->show(); m_infoWidgets.append(label); - QLabel* info = new QLabel(infoText, m_infoGrid); - info->setTextFormat(Qt::RichText); - info->setAlignment(Qt::AlignTop | Qt::WordBreak); + TQLabel* info = new TQLabel(infoText, m_infoGrid); + info->setTextFormat(TQt::RichText); + info->tqsetAlignment(TQt::AlignTop | TQt::WordBreak); info->show(); m_infoWidgets.append(info); @@ -406,9 +406,9 @@ void InfoSidebarPage::addInfoLine(const QString& labelText, const QString& infoT void InfoSidebarPage::insertActions() { // delete all existing action widgets - // TODO: just use children() from QObject... - QPtrListIterator<QWidget> deleteIter(m_actionWidgets); - QWidget* widget = 0; + // TODO: just use tqchildren() from TQObject... + TQPtrListIterator<TQWidget> deleteIter(m_actionWidgets); + TQWidget* widget = 0; while ((widget = deleteIter.current()) != 0) { widget->close(); widget->deleteLater(); @@ -435,17 +435,17 @@ void InfoSidebarPage::insertActions() // 'itemList' contains now all KFileItems, where an item information should be shown. // TODO: the following algorithm is quite equal to DolphinContextMenu::insertActionItems(). // It's open yet whether they should be merged or whether they have to work slightly different. - QStringList dirs = KGlobal::dirs()->findDirs("data", "d3lphin/servicemenus/"); - for (QStringList::ConstIterator dirIt = dirs.begin(); dirIt != dirs.end(); ++dirIt) { - QDir dir(*dirIt); - QStringList entries = dir.entryList("*.desktop", QDir::Files); + TQStringList dirs = KGlobal::dirs()->findDirs("data", "d3lphin/servicemenus/"); + for (TQStringList::ConstIterator dirIt = dirs.begin(); dirIt != dirs.end(); ++dirIt) { + TQDir dir(*dirIt); + TQStringList entries = dir.entryList("*.desktop", TQDir::Files); - for (QStringList::ConstIterator entryIt = entries.begin(); entryIt != entries.end(); ++entryIt) { + for (TQStringList::ConstIterator entryIt = entries.begin(); entryIt != entries.end(); ++entryIt) { KSimpleConfig cfg(*dirIt + *entryIt, true); cfg.setDesktopGroup(); if ((cfg.hasKey("Actions") || cfg.hasKey("X-KDE-GetActionMenu")) && cfg.hasKey("ServiceTypes")) { - const QStringList types = cfg.readListEntry("ServiceTypes"); - for (QStringList::ConstIterator it = types.begin(); it != types.end(); ++it) { + const TQStringList types = cfg.readListEntry("ServiceTypes"); + for (TQStringList::ConstIterator it = types.begin(); it != types.end(); ++it) { // check whether the mime type is equal or whether the // mimegroup (e. g. image/*) is supported @@ -470,37 +470,37 @@ void InfoSidebarPage::insertActions() KFileItem* item = 0; insert = true; while (insert && ((item = mimeIt.current()) != 0)) { - const QString mimeType((*mimeIt)->mimetype()); - const QString mimeGroup(mimeType.left(mimeType.find('/'))); + const TQString mimeType((*mimeIt)->mimetype()); + const TQString mimeGroup(mimeType.left(mimeType.tqfind('/'))); insert = (*it == mimeType) || ((*it).right(1) == "*") && - ((*it).left((*it).find('/')) == mimeGroup); + ((*it).left((*it).tqfind('/')) == mimeGroup); ++mimeIt; } } if (insert) { - const QString submenuName = cfg.readEntry( "X-KDE-Submenu" ); - QPopupMenu* popup = 0; + const TQString submenuName = cfg.readEntry( "X-KDE-Submenu" ); + TQPopupMenu* popup = 0; if (!submenuName.isEmpty()) { // create a sub menu containing all actions - popup = new QPopupMenu(); - connect(popup, SIGNAL(activated(int)), - this, SLOT(startService(int))); + popup = new TQPopupMenu(); + connect(popup, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(startService(int))); - QPushButton* button = new QPushButton(submenuName, m_actionBox); + TQPushButton* button = new TQPushButton(submenuName, m_actionBox); button->setFlat(true); button->setPopup(popup); button->show(); m_actionWidgets.append(button); } - QValueList<KDEDesktopMimeType::Service> userServices = + TQValueList<KDEDesktopMimeType::Service> userServices = KDEDesktopMimeType::userDefinedServices(*dirIt + *entryIt, true); // iterate through all actions and add them to a widget - QValueList<KDEDesktopMimeType::Service>::Iterator serviceIt; + TQValueList<KDEDesktopMimeType::Service>::Iterator serviceIt; for (serviceIt = userServices.begin(); serviceIt != userServices.end(); ++serviceIt) { KDEDesktopMimeType::Service service = (*serviceIt); if (popup == 0) { @@ -508,8 +508,8 @@ void InfoSidebarPage::insertActions() service.m_strName, m_actionBox, actionsIndex); - connect(button, SIGNAL(requestServiceStart(int)), - this, SLOT(startService(int))); + connect(button, TQT_SIGNAL(requestServiceStart(int)), + this, TQT_SLOT(startService(int))); m_actionWidgets.append(button); button->show(); } @@ -527,37 +527,37 @@ void InfoSidebarPage::insertActions() } } -ServiceButton::ServiceButton(const QIconSet& icon, - const QString& text, - QWidget* parent, +ServiceButton::ServiceButton(const TQIconSet& icon, + const TQString& text, + TQWidget* tqparent, int index) : - QPushButton(icon, text, parent), + TQPushButton(icon, text, tqparent), m_hover(false), m_index(index) { - setEraseColor(colorGroup().background()); - setFocusPolicy(QWidget::NoFocus); - connect(this, SIGNAL(released()), - this, SLOT(slotReleased())); + setEraseColor(tqcolorGroup().background()); + setFocusPolicy(TQ_NoFocus); + connect(this, TQT_SIGNAL(released()), + this, TQT_SLOT(slotReleased())); } ServiceButton::~ServiceButton() { } -void ServiceButton::drawButton(QPainter* painter) +void ServiceButton::drawButton(TQPainter* painter) { const int buttonWidth = width(); const int buttonHeight = height(); - QColor backgroundColor; - QColor foregroundColor; + TQColor backgroundColor; + TQColor foregroundColor; if (m_hover) { backgroundColor = KGlobalSettings::highlightColor(); foregroundColor = KGlobalSettings::highlightedTextColor(); } else { - backgroundColor = colorGroup().background(); + backgroundColor = tqcolorGroup().background(); foregroundColor = KGlobalSettings::buttonTextColor(); } @@ -571,9 +571,9 @@ void ServiceButton::drawButton(QPainter* painter) // draw icon int x = spacing; const int y = (buttonHeight - KIcon::SizeSmall) / 2; - const QIconSet* set = iconSet(); + const TQIconSet* set = iconSet(); if (set != 0) { - painter->drawPixmap(x, y, set->pixmap(QIconSet::Small, QIconSet::Normal)); + painter->drawPixmap(x, y, set->pixmap(TQIconSet::Small, TQIconSet::Normal)); } x += KIcon::SizeSmall + spacing; @@ -581,26 +581,26 @@ void ServiceButton::drawButton(QPainter* painter) painter->setPen(foregroundColor); const int textWidth = buttonWidth - x; - QFontMetrics fontMetrics(font()); + TQFontMetrics fontMetrics(font()); const bool clipped = fontMetrics.width(text()) >= textWidth; - //const int align = clipped ? Qt::AlignVCenter : Qt::AlignCenter; - painter->drawText(QRect(x, 0, textWidth, buttonHeight), Qt::AlignVCenter, text()); + //const int align = clipped ? TQt::AlignVCenter : TQt::AlignCenter; + painter->drawText(TQRect(x, 0, textWidth, buttonHeight), TQt::AlignVCenter, text()); if (clipped) { // Blend the right area of the text with the background, as the // text is clipped. - // TODO #1: use alpha blending in Qt4 instead of drawing the text that often + // TODO #1: use alpha blending in TQt4 instead of drawing the text that often // TODO #2: same code as in URLNavigatorButton::drawButton() -> provide helper class? const int blendSteps = 16; - QColor blendColor(backgroundColor); + TQColor blendColor(backgroundColor); const int redInc = (foregroundColor.red() - backgroundColor.red()) / blendSteps; const int greenInc = (foregroundColor.green() - backgroundColor.green()) / blendSteps; const int blueInc = (foregroundColor.blue() - backgroundColor.blue()) / blendSteps; for (int i = 0; i < blendSteps; ++i) { - painter->setClipRect(QRect(x + textWidth - i, 0, 1, buttonHeight)); + painter->setClipRect(TQRect(x + textWidth - i, 0, 1, buttonHeight)); painter->setPen(blendColor); - painter->drawText(QRect(x, 0, textWidth, buttonHeight), Qt::AlignVCenter, text()); + painter->drawText(TQRect(x, 0, textWidth, buttonHeight), TQt::AlignVCenter, text()); blendColor.setRgb(blendColor.red() + redInc, blendColor.green() + greenInc, @@ -609,16 +609,16 @@ void ServiceButton::drawButton(QPainter* painter) } } -void ServiceButton::enterEvent(QEvent* event) +void ServiceButton::enterEvent(TQEvent* event) { - QPushButton::enterEvent(event); + TQPushButton::enterEvent(event); m_hover = true; update(); } -void ServiceButton::leaveEvent(QEvent* event) +void ServiceButton::leaveEvent(TQEvent* event) { - QPushButton::leaveEvent(event); + TQPushButton::leaveEvent(event); m_hover = false; update(); } |