xlsxdatavalidation.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // xlsxvalidation.h
  2. #ifndef QXLSX_XLSXDATAVALIDATION_H
  3. #define QXLSX_XLSXDATAVALIDATION_H
  4. #include "xlsxglobal.h"
  5. #include <QList>
  6. #include <QSharedDataPointer>
  7. #include <QString>
  8. #include <QXmlStreamReader>
  9. #include <QXmlStreamWriter>
  10. class QXmlStreamReader;
  11. class QXmlStreamWriter;
  12. QT_BEGIN_NAMESPACE_XLSX
  13. class Worksheet;
  14. class CellRange;
  15. class CellReference;
  16. class DataValidationPrivate;
  17. class QXLSX_EXPORT DataValidation
  18. {
  19. public:
  20. enum ValidationType { None, Whole, Decimal, List, Date, Time, TextLength, Custom };
  21. enum ValidationOperator {
  22. Between,
  23. NotBetween,
  24. Equal,
  25. NotEqual,
  26. LessThan,
  27. LessThanOrEqual,
  28. GreaterThan,
  29. GreaterThanOrEqual
  30. };
  31. enum ErrorStyle { Stop, Warning, Information };
  32. DataValidation();
  33. DataValidation(ValidationType type,
  34. ValidationOperator op = Between,
  35. const QString &formula1 = QString(),
  36. const QString &formula2 = QString(),
  37. bool allowBlank = false);
  38. DataValidation(const DataValidation &other);
  39. ~DataValidation();
  40. ValidationType validationType() const;
  41. ValidationOperator validationOperator() const;
  42. ErrorStyle errorStyle() const;
  43. QString formula1() const;
  44. QString formula2() const;
  45. bool allowBlank() const;
  46. QString errorMessage() const;
  47. QString errorMessageTitle() const;
  48. QString promptMessage() const;
  49. QString promptMessageTitle() const;
  50. bool isPromptMessageVisible() const;
  51. bool isErrorMessageVisible() const;
  52. QList<CellRange> ranges() const;
  53. void setValidationType(ValidationType type);
  54. void setValidationOperator(ValidationOperator op);
  55. void setErrorStyle(ErrorStyle es);
  56. void setFormula1(const QString &formula);
  57. void setFormula2(const QString &formula);
  58. void setErrorMessage(const QString &error, const QString &title = QString());
  59. void setPromptMessage(const QString &prompt, const QString &title = QString());
  60. void setAllowBlank(bool enable);
  61. void setPromptMessageVisible(bool visible);
  62. void setErrorMessageVisible(bool visible);
  63. void addCell(const CellReference &cell);
  64. void addCell(int row, int col);
  65. void addRange(int firstRow, int firstCol, int lastRow, int lastCol);
  66. void addRange(const CellRange &range);
  67. DataValidation &operator=(const DataValidation &other);
  68. bool saveToXml(QXmlStreamWriter &writer) const;
  69. static DataValidation loadFromXml(QXmlStreamReader &reader);
  70. private:
  71. QSharedDataPointer<DataValidationPrivate> d;
  72. };
  73. QT_END_NAMESPACE_XLSX
  74. #endif // QXLSX_XLSXDATAVALIDATION_H