xlsxdatavalidation.h 2.6 KB

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