qsplistbox.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef QSPLISTBOX_H
  2. #define QSPLISTBOX_H
  3. #include <QWidget>
  4. #include <QListWidget>
  5. #include <QString>
  6. #include <QStringList>
  7. #include <QFont>
  8. #include <QColor>
  9. #include <QResizeEvent>
  10. #include <QMouseEvent>
  11. namespace Ui {
  12. class QspListBox;
  13. }
  14. class QspListBox : public QListWidget
  15. {
  16. Q_OBJECT
  17. signals:
  18. void SelectionChange(int selection);
  19. public:
  20. explicit QspListBox(QWidget *parent = 0);
  21. ~QspListBox();
  22. // Methods
  23. void RefreshUI();
  24. void BeginItems();
  25. void AddItem(const QString& image, const QString& desc);
  26. void EndItems();
  27. // Accessors
  28. void SetIsHtml(bool isHtml);
  29. void SetIsShowNums(bool isShow);
  30. void SetTextFont(const QFont& new_font);
  31. QFont GetTextFont() const { return m_font; }
  32. bool SetLinkColor(const QColor &color);
  33. QColor GetLinkColor();
  34. QColor GetBackgroundColor();
  35. QColor GetForegroundColor(); //text color
  36. bool SetBackgroundColor(const QColor& color);
  37. bool SetForegroundColor(const QColor& color);
  38. void SetGamePath(const QString& path) { m_path = path; }
  39. void SetSelection(int selection);
  40. int GetSelection() { return oldSelection; }
  41. void SetShowPlainText(bool isPlain);
  42. void SetMouseTracking(bool trackMouse);
  43. private:
  44. // Internal methods
  45. void createList();
  46. QString formatItem(int itemIndex);
  47. void resizeEvent(QResizeEvent *e);
  48. void mouseMoveEvent(QMouseEvent *event);
  49. // Fields
  50. QString m_outFormat;
  51. QString m_outFormatNums;
  52. QString m_outFormatImage;
  53. QString m_outFormatImageNums;
  54. bool m_isUseHtml;
  55. bool m_isShowNums;
  56. QString m_path;
  57. QFont m_font;
  58. QStringList m_images;
  59. QStringList m_descs;
  60. QStringList m_newImages;
  61. QStringList m_newDescs;
  62. QColor m_linkColor;
  63. QColor m_textColor;
  64. QColor m_backgroundColor;
  65. QColor m_selectionColor;
  66. bool m_mouseTracking;
  67. bool showPlainText;
  68. int oldSelection;
  69. };
  70. #endif // QSPLISTBOX_H