source: s10k/Vago/packageWizard/packagepage3.cpp@ 1163

Last change on this file since 1163 was 1093, checked in by s10k, 7 years ago

Vago 1.4

File size: 1.9 KB
Line 
1#include "packagepage3.h"
2#include "ui_packagepage3.h"
3
4PackagePage3::PackagePage3(QWidget *parent) :
5 QWizardPage(parent),
6 ui(new Ui::PackagePage3)
7{
8 ui->setupUi(this);
9 this->setTitle("Optional Fields");
10 this->setSubTitle("Separate multiple elements by commas.");
11
12 //Register fields
13 registerField("leDependentPackages", ui->leDependent);
14 registerField("leIncompatiblePackages", ui->leIncompatible);
15 registerField("leUnlockLevels", ui->leUnlockLevels);
16}
17
18bool PackagePage3::validatePage(){
19 QString dependentPackages=ui->leDependent->text().trimmed();
20 QString incompatiblePackages=ui->leIncompatible->text().trimmed();
21 QString unlockLevels=ui->leUnlockLevels->text().trimmed();
22
23 if(!validateField(dependentPackages) || !validateField(incompatiblePackages)
24 || !validateField(unlockLevels,true)){
25 return false;
26 }
27
28 return true;
29}
30
31bool PackagePage3::validateField(QString &field, bool isLevels){
32 //Check if the numbers are correct and correctly separated
33 if(!field.isEmpty()){
34
35 QStringList list =Util::String::substring(field,",");
36
37 for(int i=0; i<list.size(); i++){
38
39 if(list.at(i).isEmpty()){
40 Util::Dialogs::showError("There are commas without numbers in their sides.");
41 return false;
42 }
43
44 if(!Util::Validation::isStringInteger(list.at(i))){
45 Util::Dialogs::showError("Number is not numeric.");
46 return false;
47 }
48
49 if(!isLevels){
50 if(list.at(i).size()!=5){
51 Util::Dialogs::showError("You have invalid packages numbers. Each number must have 5 digits.");
52 return false;
53 }
54 }
55 }
56 }
57
58 return true;
59}
60
61PackagePage3::~PackagePage3()
62{
63 delete ui;
64}
Note: See TracBrowser for help on using the repository browser.