From f0b4144b957727a6031226a3ec84eabf53f0e0b9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 19 Apr 2010 17:18:01 +0200 Subject: this commit renames Item classes with this logic - Listitem inherited classes are TYPE + "Listitem" - QLabel inherited classes are TYPE + Label --- src/urlbar/listitem.cpp | 47 +++++++++++++++++++++++++---------------------- src/urlbar/listitem.h | 20 ++++++++++---------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index d35da547..0ecc56fe 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -75,7 +75,7 @@ ListItem::ListItem(const UrlSearchItem &item, QWidget *parent) p.setColor(QPalette::AlternateBase, QColor(247,247,247)); // TODO: choose the correct color setPalette(p); - QHBoxLayout *hLayout = new QHBoxLayout; + QHBoxLayout *hLayout = new QHBoxLayout(this); hLayout->setSpacing(4); setLayout(hLayout); @@ -156,11 +156,11 @@ void ListItem::nextItemSubChoice() // --------------------------------------------------------------- -TypeIcon::TypeIcon(int type, QWidget *parent) +TypeIconLabel::TypeIconLabel(int type, QWidget *parent) : QLabel(parent) { setMinimumWidth(40); - QHBoxLayout *hLayout = new QHBoxLayout; + QHBoxLayout *hLayout = new QHBoxLayout(this); hLayout->setMargin(0); hLayout->setAlignment(Qt::AlignRight); setLayout(hLayout); @@ -172,9 +172,9 @@ TypeIcon::TypeIcon(int type, QWidget *parent) } -QLabel *TypeIcon::getIcon(QString icon) +QLabel *TypeIconLabel::getIcon(QString icon) { - QLabel *iconLabel = new QLabel; + QLabel *iconLabel = new QLabel(this); iconLabel->setFixedSize(16,16); QPixmap pixmap = KIcon(icon).pixmap(16); iconLabel->setPixmap(pixmap); @@ -185,7 +185,7 @@ QLabel *TypeIcon::getIcon(QString icon) // --------------------------------------------------------------- -ItemIcon::ItemIcon(const QString &icon, QWidget *parent) +IconLabel::IconLabel(const QString &icon, QWidget *parent) : QLabel(parent) { QPixmap pixmapIcon = KIcon(QWebSettings::iconForUrl(icon)).pixmap(16); @@ -202,7 +202,7 @@ ItemIcon::ItemIcon(const QString &icon, QWidget *parent) // --------------------------------------------------------------- -ItemText::ItemText(const QString &text, const QString &textToPointOut, QWidget *parent) +TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget *parent) : QLabel(parent) { QString t = text; @@ -220,26 +220,26 @@ ItemText::ItemText(const QString &text, const QString &textToPointOut, QWidget * PreviewListItem::PreviewListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) : ListItem(item, parent) { - QLabel *previewLabelIcon = new QLabel; + QLabel *previewLabelIcon = new QLabel(parent); previewLabelIcon->setFixedSize(45,33); - new ItemPreview(item.url.url(), 38, 29, previewLabelIcon); - ItemIcon* icon = new ItemIcon(item.url.url(), previewLabelIcon); + new PreviewLabel(item.url.url(), 38, 29, previewLabelIcon); + IconLabel* icon = new IconLabel(item.url.url(), previewLabelIcon); icon->move(27, 16); layout()->addWidget(previewLabelIcon); - QVBoxLayout *vLayout = new QVBoxLayout; + QVBoxLayout *vLayout = new QVBoxLayout(this); vLayout->setMargin(0); ((QHBoxLayout *)layout())->addLayout(vLayout); - vLayout->addWidget(new ItemText(item.title, text)); - vLayout->addWidget(new ItemText("" + item.url.url() + "", text)); - layout()->addWidget(new TypeIcon(item.type)); + vLayout->addWidget( new TextLabel(item.title, text, this) ); + vLayout->addWidget( new TextLabel("" + item.url.url() + "", text, this) ); + layout()->addWidget( new TypeIconLabel(item.type, this) ); } // --------------------------------------------------------------- -ItemPreview::ItemPreview(const QString &url, int width, int height, QWidget *parent) +PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *parent) : QLabel(parent) { setFixedSize(width, height); @@ -269,8 +269,8 @@ SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, Q if (m_currentEngine == "") m_currentEngine = EngineBar::defaultEngine(); - m_iconLabel = new ItemIcon("edit-find", this); //TODO: get the default engine icon - m_titleLabel = new ItemText(searchItemTitle(m_currentEngine, text)); + m_iconLabel = new IconLabel("edit-find", this); //TODO: get the default engine icon + m_titleLabel = new TextLabel(searchItemTitle(m_currentEngine, text)); m_engineBar = new EngineBar(text, m_currentEngine, this); // without this it will not work :) @@ -278,9 +278,9 @@ SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, Q layout()->addWidget(m_iconLabel); layout()->addWidget(m_titleLabel); - layout()->addWidget(new QLabel("Engines: ")); + layout()->addWidget( new QLabel( i18n("Engines: "), this ) ); layout()->addWidget(m_engineBar); - layout()->addWidget(new TypeIcon(item.type)); + layout()->addWidget( new TypeIconLabel(item.type, this) ); connect(m_engineBar, SIGNAL(searchEngineChanged(QString, QString)), this, SLOT(changeSearchEngine(QString, QString))); } @@ -308,6 +308,9 @@ void SearchListItem::nextItemSubChoice() } +// ----------------------------------------------------------------------------------------------- + + EngineBar::EngineBar(const QString &text, const QString &selectedEngine, QWidget *parent) : KToolBar(parent) { @@ -431,9 +434,9 @@ BrowseListItem::BrowseListItem(const UrlSearchItem &item, const QString &text, Q : ListItem(item, parent) { QString url = text; - layout()->addWidget(new ItemIcon(item.url.url())); - layout()->addWidget(new ItemText("Browse http://" + url.remove("http://") + "")); - layout()->addWidget(new TypeIcon(item.type)); + layout()->addWidget( new IconLabel(item.url.url(), this) ); + layout()->addWidget( new TextLabel( QL1S("Browse http://") + url.remove("http://") + QL1S(""), QString(), this) ); + layout()->addWidget( new TypeIconLabel(item.type, this) ); } diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h index a9dc8213..67bfb764 100644 --- a/src/urlbar/listitem.h +++ b/src/urlbar/listitem.h @@ -82,12 +82,12 @@ protected: // ------------------------------------------------------------------------- -class TypeIcon : public QLabel +class TypeIconLabel : public QLabel { Q_OBJECT public: - TypeIcon(int type, QWidget *parent = 0); + TypeIconLabel(int type, QWidget *parent = 0); private: QLabel *getIcon(QString icon); @@ -97,24 +97,24 @@ private: // ------------------------------------------------------------------------- -class ItemIcon : public QLabel +class IconLabel : public QLabel { Q_OBJECT public: - ItemIcon(const QString &icon, QWidget *parent = 0); + IconLabel(const QString &icon, QWidget *parent = 0); }; // ------------------------------------------------------------------------- -class ItemText : public QLabel +class TextLabel : public QLabel { Q_OBJECT public: - ItemText(const QString &text, const QString &textToPointOut = QString(), QWidget *parent = 0); + TextLabel(const QString &text, const QString &textToPointOut = QString(), QWidget *parent = 0); }; @@ -164,8 +164,8 @@ private slots: private: QString searchItemTitle(QString engine, QString text); - ItemText* m_titleLabel; - ItemIcon* m_iconLabel; + TextLabel* m_titleLabel; + IconLabel* m_iconLabel; EngineBar* m_engineBar; QString m_text; @@ -188,12 +188,12 @@ public: // ------------------------------------------------------------------------- -class ItemPreview : public QLabel +class PreviewLabel : public QLabel { Q_OBJECT public: - ItemPreview(const QString &url, int width, int height, QWidget *parent = 0); + PreviewLabel(const QString &url, int width, int height, QWidget *parent = 0); }; -- cgit v1.2.1