newspiece.cpp 826 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "newspiece.h"
  2. #include "ui_newspiece.h"
  3. #include <QDebug>
  4. NewsPiece::NewsPiece(QWidget *parent) :
  5. QWidget(parent),
  6. ui(new Ui::NewsPiece)
  7. {
  8. ui->setupUi(this);
  9. }
  10. void NewsPiece::setTitle(const QString &title, const QString &url)
  11. {
  12. _title = title;
  13. _url = url;
  14. ui->news_title->setText("<a style=\"color: #cfa644; text-decoration:none;\" href = '" + QString(url).remove("\n") + "'>" + QString(title).remove("\n") + "</a>");
  15. resize(sizeHint());
  16. }
  17. void NewsPiece::setDate(const QString &date)
  18. {
  19. ui->news_date->setText(QString(date).remove("\n"));
  20. resize(sizeHint());
  21. }
  22. QString NewsPiece::getTitle()
  23. {
  24. return _title;
  25. }
  26. QString NewsPiece::getUrl()
  27. {
  28. return _url;
  29. }
  30. QString NewsPiece::getDate()
  31. {
  32. return ui->news_date->text();
  33. }
  34. NewsPiece::~NewsPiece()
  35. {
  36. delete ui;
  37. }