newspiece.cpp 1.0 KB

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