vdoublerowitemwidget.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "vdoublerowitemwidget.h"
  2. #include <QVariant>
  3. #include <QLabel>
  4. #include <QVBoxLayout>
  5. VDoubleRowItemWidget::VDoubleRowItemWidget(QWidget *p_parent)
  6. : QWidget(p_parent)
  7. {
  8. m_firstLabel = new QLabel(this);
  9. m_firstLabel->setProperty("FirstRowLabel", true);
  10. m_secondLabel = new QLabel(this);
  11. m_secondLabel->setProperty("SecondRowLabel", true);
  12. QVBoxLayout *layout = new QVBoxLayout();
  13. layout->addWidget(m_firstLabel);
  14. layout->addWidget(m_secondLabel);
  15. layout->addStretch();
  16. layout->setContentsMargins(3, 0, 0, 0);
  17. layout->setSpacing(0);
  18. setLayout(layout);
  19. }
  20. void VDoubleRowItemWidget::setText(const QString &p_firstText,
  21. const QString &p_secondText)
  22. {
  23. m_firstLabel->setText(p_firstText);
  24. if (!p_secondText.isEmpty()) {
  25. m_secondLabel->setText(p_secondText);
  26. m_secondLabel->show();
  27. } else {
  28. m_secondLabel->hide();
  29. }
  30. }
  31. VDoubleRowItemWidget *VDoubleRowItemWidget::cloneWidget(VDoubleRowItemWidget *p_widget,
  32. QWidget *p_parent)
  33. {
  34. VDoubleRowItemWidget *widget = new VDoubleRowItemWidget(p_parent);
  35. widget->setText(p_widget->m_firstLabel->text(), p_widget->m_secondLabel->text());
  36. return widget;
  37. }