dialogsaveoutput.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #include "dialogsaveoutput.h"
  2. #include "ui_dialogsaveoutput.h"
  3. DialogSaveOutput::DialogSaveOutput(QWidget *parent) :
  4. QDialog(parent),
  5. ui(new Ui::DialogSaveOutput)
  6. {
  7. ui->setupUi(this);
  8. ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("^[1-9]\\d{0,6}"), this));
  9. ui->buttonBox->button(QDialogButtonBox::Ok)->setText("È·¶¨");
  10. ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("È¡Ïû");
  11. ui->checkBox->setVisible(false);
  12. }
  13. DialogSaveOutput::~DialogSaveOutput()
  14. {
  15. delete ui;
  16. }
  17. NumberExportType DialogSaveOutput::getExportType()
  18. {
  19. if(ui->radioButtonAll->isChecked())
  20. return ExportByAll;
  21. if(ui->radioButtonCity->isChecked())
  22. return ExportByRegion;
  23. if(ui->radioButtonProvince->isChecked())
  24. return ExportByRegion;
  25. if(ui->radioButtonCorp->isChecked())
  26. return ExportByCorp;
  27. if(ui->radioButtonGroup->isChecked())
  28. return ExportByBatch;
  29. if(ui->radioButtonSeg->isChecked())
  30. return ExportBySegment;
  31. if(ui->radioButtonSame->isChecked())
  32. return ExportByDuplicate;
  33. }
  34. int DialogSaveOutput::getSegLength()
  35. {
  36. return this->ui->spinBoxSeg->value();
  37. }
  38. int DialogSaveOutput::getBatchSize()
  39. {
  40. if(this->ui->lineEdit->text().isEmpty())
  41. return 1000;
  42. else
  43. return this->ui->lineEdit->text().toInt();
  44. }
  45. bool DialogSaveOutput::getIsAll()
  46. {
  47. return this->ui->checkBox->isChecked();
  48. }
  49. bool DialogSaveOutput::getRegionType()
  50. {
  51. if(this->ui->radioButtonCity->isChecked())
  52. return true;
  53. else
  54. return false;
  55. }
  56. void DialogSaveOutput::setOkButtonState()
  57. {
  58. if(ui->radioButtonAll->isChecked() || ui->radioButtonSame->isChecked()||
  59. ui->radioButtonCorp->isChecked()||ui->radioButtonCity->isChecked()||
  60. ui->radioButtonProvince->isChecked())
  61. {
  62. ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
  63. ui->spinBoxSeg->setEnabled(false);
  64. ui->checkBox->setEnabled(false);
  65. ui->lineEdit->setEnabled(false);
  66. }
  67. else if(ui->radioButtonSeg->isChecked())
  68. {
  69. ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
  70. ui->spinBoxSeg->setEnabled(true);
  71. ui->checkBox->setEnabled(false);
  72. ui->lineEdit->setEnabled(false);
  73. }
  74. else
  75. {
  76. ui->spinBoxSeg->setEnabled(false);
  77. ui->checkBox->setEnabled(true);
  78. ui->lineEdit->setEnabled(true);
  79. if(ui->lineEdit->hasAcceptableInput())
  80. ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
  81. else
  82. ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
  83. }
  84. }
  85. void DialogSaveOutput::on_lineEdit_textChanged(const QString &arg1)
  86. {
  87. ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ui->lineEdit->hasAcceptableInput());
  88. }
  89. void DialogSaveOutput::on_radioButtonAll_clicked()
  90. {
  91. setOkButtonState();
  92. }
  93. void DialogSaveOutput::on_radioButtonSeg_clicked()
  94. {
  95. setOkButtonState();
  96. }
  97. void DialogSaveOutput::on_radioButtonSame_clicked()
  98. {
  99. setOkButtonState();
  100. }
  101. void DialogSaveOutput::on_radioButtonCorp_clicked()
  102. {
  103. setOkButtonState();
  104. }
  105. void DialogSaveOutput::on_radioButtonGroup_clicked()
  106. {
  107. setOkButtonState();
  108. }
  109. void DialogSaveOutput::on_radioButtonProvince_clicked()
  110. {
  111. setOkButtonState();
  112. }
  113. void DialogSaveOutput::on_radioButtonCity_clicked()
  114. {
  115. setOkButtonState();
  116. }