Commit c1623c73 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Welcome page: Polishing (memory leaks, slot names).

parent 3c6b49d2
......@@ -33,7 +33,7 @@
#include "utils_global.h"
#include <QObject>
#include <QtCore/QObject>
namespace Utils {
......
......@@ -33,7 +33,6 @@
#include <QtGui/QPixmap>
#include <QtGui/QAction>
#include <QtGui/QVBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QMouseEvent>
#include <QtGui/QResizeEvent>
#include <QtGui/QImage>
......@@ -45,6 +44,15 @@ enum { leftContentsMargin = 2,
namespace Utils {
WelcomeModeLabel::WelcomeModeLabel(QWidget *parent) :
QLabel(parent)
{
}
WelcomeModeLabel::~WelcomeModeLabel()
{
}
void WelcomeModeLabel::setStyledText(const QString &text)
{
QString rc = QLatin1String(
......@@ -255,9 +263,9 @@ void WelcomeModeTreeWidget::addItem(const QString &label, const QString &data, c
addItemWidget(new WelcomeModeItemWidget(m_d->bullet, label, toolTip, data));
}
void WelcomeModeTreeWidget::slotAddNewsItem(const QString &title,
const QString &description,
const QString &link)
void WelcomeModeTreeWidget::addNewsItem(const QString &title,
const QString &description,
const QString &link)
{
addItemWidget(new WelcomeModeItemWidget(m_d->bullet, title, description, link, link));
}
......@@ -270,9 +278,13 @@ void WelcomeModeTreeWidget::addItemWidget(WelcomeModeItemWidget *w)
void WelcomeModeTreeWidget::clear()
{
for (int i = m_d->itemLayout->count() - 1; i >= 0; i--)
delete m_d->itemLayout->takeAt(i)->widget();
for (int i = m_d->itemLayout->count() - 1; i >= 0; i--) {
QLayoutItem *item = m_d->itemLayout->takeAt(i);
delete item->widget();
delete item;
}
}
} // namespace Utils
#include "welcomemodetreewidget.moc"
......@@ -35,8 +35,6 @@
#include <QtGui/QTreeWidget>
#include <QtGui/QLabel>
QT_FORWARD_DECLARE_CLASS(QHBoxLayout)
namespace Utils {
struct WelcomeModeTreeWidgetPrivate;
......@@ -47,11 +45,16 @@ class QTCREATOR_UTILS_EXPORT WelcomeModeLabel : public QLabel
{
Q_OBJECT
public:
WelcomeModeLabel(QWidget *parent) : QLabel(parent) {};
explicit WelcomeModeLabel(QWidget *parent = 0);
virtual ~WelcomeModeLabel();
void setStyledText(const QString &text);
private:
WelcomeModeLabelPrivate *m_d;
};
// WelcomeModeTreeWidget: Show an itemized list with arrows and emits a signal on click.
class QTCREATOR_UTILS_EXPORT WelcomeModeTreeWidget : public QWidget
{
Q_OBJECT
......@@ -59,10 +62,11 @@ public:
explicit WelcomeModeTreeWidget(QWidget *parent = 0);
virtual ~WelcomeModeTreeWidget();
void addItem(const QString &label, const QString &data,const QString &toolTip = QString::null);
public slots:
void slotAddNewsItem(const QString &title, const QString &description, const QString &link);
void addItem(const QString &label, const QString &data,const QString &toolTip = QString());
// Add a 'News' item as two lines of "<bold>Breaking news!</bold>\nElided Start of article...."
void addNewsItem(const QString &title, const QString &description, const QString &link);
void clear();
signals:
......@@ -74,6 +78,5 @@ private:
WelcomeModeTreeWidgetPrivate *m_d;
};
}
} // namespace Utils
#endif // WELCOMEMODETREEWIDGET_H
......@@ -93,7 +93,7 @@ CommunityWelcomePageWidget::CommunityWelcomePageWidget(QWidget *parent) :
connect(ui->supportSitesTreeWidget, SIGNAL(activated(QString)), SLOT(slotUrlClicked(QString)));
connect(m_rssFetcher, SIGNAL(newsItemReady(QString, QString, QString)),
ui->newsTreeWidget, SLOT(slotAddNewsItem(QString, QString, QString)));
ui->newsTreeWidget, SLOT(addNewsItem(QString, QString, QString)));
//: Add localized feed here only if one exists
m_rssFetcher->fetch(QUrl(tr("http://labs.trolltech.com/blogs/feed")));
......
......@@ -237,9 +237,9 @@ WelcomePageWidget_CW::WelcomePageWidget_CW(QObject *parent) :
QWidget *WelcomePageWidget_CW::createWidget(QWidget *parent)
{
Utils::WelcomeModeTreeWidget *rc = new Utils::WelcomeModeTreeWidget(parent);
rc->slotAddNewsItem(QLatin1String("Breaking news"),
rc->addNewsItem(QLatin1String("Breaking news"),
QLatin1String("Bla bla bla"), QLatin1String("qt.nokia.com"));
rc->slotAddNewsItem(QLatin1String("Yesterday's breaking news"),
rc->addNewsItem(QLatin1String("Yesterday's breaking news"),
QLatin1String("Blub blub blub"), QLatin1String("qt.nokia.com"));
return rc;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment