xlsxcellreference.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // xlsxcellreference.h
  2. #ifndef QXLSX_XLSXCELLREFERENCE_H
  3. #define QXLSX_XLSXCELLREFERENCE_H
  4. #include "xlsxglobal.h"
  5. QT_BEGIN_NAMESPACE_XLSX
  6. class QXLSX_EXPORT CellReference
  7. {
  8. public:
  9. CellReference();
  10. /*!
  11. Constructs the Reference from the given \a row, and \a column.
  12. */
  13. constexpr CellReference(int row, int column)
  14. : _row(row)
  15. , _column(column)
  16. {
  17. }
  18. CellReference(const QString &cell);
  19. CellReference(const char *cell);
  20. CellReference(const CellReference &other);
  21. ~CellReference();
  22. QString toString(bool row_abs = false, bool col_abs = false) const;
  23. bool isValid() const;
  24. inline void setRow(int row) { _row = row; }
  25. inline void setColumn(int col) { _column = col; }
  26. inline int row() const { return _row; }
  27. inline int column() const { return _column; }
  28. inline bool operator==(const CellReference &other) const
  29. {
  30. return _row == other._row && _column == other._column;
  31. }
  32. inline bool operator!=(const CellReference &other) const
  33. {
  34. return _row != other._row || _column != other._column;
  35. }
  36. inline bool operator>(const CellReference &other) const
  37. {
  38. return _row > other._row || _column != other._column;
  39. }
  40. private:
  41. void init(const QString &cell);
  42. int _row{-1};
  43. int _column{-1};
  44. };
  45. QT_END_NAMESPACE_XLSX
  46. Q_DECLARE_TYPEINFO(QXlsx::CellReference, Q_MOVABLE_TYPE);
  47. #endif // QXLSX_XLSXCELLREFERENCE_H