xlsxcellrange.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // xlsxcellrange.h
  2. #ifndef QXLSX_XLSXCELLRANGE_H
  3. #define QXLSX_XLSXCELLRANGE_H
  4. #include "xlsxcellreference.h"
  5. #include "xlsxglobal.h"
  6. #include <QObject>
  7. QT_BEGIN_NAMESPACE_XLSX
  8. // dev57
  9. class QXLSX_EXPORT CellRange
  10. {
  11. public:
  12. CellRange();
  13. CellRange(int firstRow, int firstColumn, int lastRow, int lastColumn);
  14. CellRange(const CellReference &topLeft, const CellReference &bottomRight);
  15. CellRange(const QString &range);
  16. CellRange(const char *range);
  17. CellRange(const CellRange &other);
  18. ~CellRange();
  19. QString toString(bool row_abs = false, bool col_abs = false) const;
  20. bool isValid() const;
  21. inline void setFirstRow(int row) { top = row; }
  22. inline void setLastRow(int row) { bottom = row; }
  23. inline void setFirstColumn(int col) { left = col; }
  24. inline void setLastColumn(int col) { right = col; }
  25. inline int firstRow() const { return top; }
  26. inline int lastRow() const { return bottom; }
  27. inline int firstColumn() const { return left; }
  28. inline int lastColumn() const { return right; }
  29. inline int rowCount() const { return bottom - top + 1; }
  30. inline int columnCount() const { return right - left + 1; }
  31. inline CellReference topLeft() const { return CellReference(top, left); }
  32. inline CellReference topRight() const { return CellReference(top, right); }
  33. inline CellReference bottomLeft() const { return CellReference(bottom, left); }
  34. inline CellReference bottomRight() const { return CellReference(bottom, right); }
  35. inline void operator=(const CellRange &other)
  36. {
  37. top = other.top;
  38. bottom = other.bottom;
  39. left = other.left;
  40. right = other.right;
  41. }
  42. inline bool operator==(const CellRange &other) const
  43. {
  44. return top == other.top && bottom == other.bottom && left == other.left &&
  45. right == other.right;
  46. }
  47. inline bool operator!=(const CellRange &other) const
  48. {
  49. return top != other.top || bottom != other.bottom || left != other.left ||
  50. right != other.right;
  51. }
  52. private:
  53. void init(const QString &range);
  54. int top;
  55. int left;
  56. int bottom;
  57. int right;
  58. };
  59. QT_END_NAMESPACE_XLSX
  60. Q_DECLARE_TYPEINFO(QXlsx::CellRange, Q_MOVABLE_TYPE);
  61. #endif // QXLSX_XLSXCELLRANGE_H