xlsxcellrange.h 2.2 KB

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