1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #include "newspiece.h"
- #include "ui_newspiece.h"
- #include <QDebug>
- NewsPiece::NewsPiece(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::NewsPiece)
- {
- ui->setupUi(this);
- }
- void NewsPiece::setTitle(const QString &title, const QString &url)
- {
- _title = title;
- _url = url;
- ui->news_head_small->setText("<a style=\"color: #cfa644; text-decoration:none;\" href = '" + QString(url).remove("\n") + "'>" + QString(title).remove("\n") + "</a>");
- resize(sizeHint());
- }
- void NewsPiece::setDate(const QString &date)
- {
- ui->news_date_small->setText(QString(date).remove("\n"));
- resize(sizeHint());
- }
- void NewsPiece::setContents(const QString &contents)
- {
- ui->news_content_common->setText(QString(contents).remove("\n"));
- resize(sizeHint());
- }
- void NewsPiece::setIcon(const QPixmap &pixmap)
- {
- ui->news_icon->setPixmap(pixmap.scaled(ui->news_icon->sizeHint()));
- }
- QString NewsPiece::getTitle()
- {
- return _title;
- }
- QString NewsPiece::getUrl()
- {
- return _url;
- }
- QString NewsPiece::getDate()
- {
- return ui->news_date_small->text();
- }
- QString NewsPiece::getContents()
- {
- return ui->news_content_common->text();
- }
- QPixmap NewsPiece::getIcon()
- {
- return *ui->news_icon->pixmap();
- }
- NewsPiece::~NewsPiece()
- {
- delete ui;
- }
|