| 5 |
|
const QString PackagePage2::PackagesCacheUrl = "http://mods.oni2.net/jsoncache/"+ZipCacheFile; |
| 6 |
|
const QString PackagePage2::CacheFile = "nodes.json"; |
| 7 |
|
|
| 8 |
< |
PackagePage2::PackagePage2(Logger *myLogger, QWidget *parent) : |
| 8 |
> |
PackagePage2::PackagePage2(QWidget *parent) : |
| 9 |
|
QWizardPage(parent), |
| 10 |
|
ui(new Ui::PackagePage2) |
| 11 |
|
{ |
| 12 |
|
ui->setupUi(this); |
| 13 |
< |
this->myLogger=myLogger; |
| 13 |
> |
|
| 14 |
|
this->setTitle("Mandatory Fields"); |
| 15 |
|
|
| 16 |
|
//Register fields to be accessible in another pages //Not using mandatory field, it would require empty verification too... |
| 37 |
|
QString description=ui->ptDescription->toPlainText(); |
| 38 |
|
QString number=ui->lePackageNumber->text(); |
| 39 |
|
|
| 40 |
< |
bool emptyContent=Util::checkEmptySpaces(QStringList()<<modName<<authors<<version<<description<<number); |
| 40 |
> |
bool emptyContent=Util::Validation::checkEmptySpaces(QStringList()<<modName<<authors<<version<<description<<number); |
| 41 |
|
|
| 42 |
|
|
| 43 |
|
if(emptyContent){ |
| 44 |
< |
Util::showErrorPopUp("You need to fill all fields first!"); |
| 44 |
> |
Util::Dialogs::showError("You need to fill all fields first!"); |
| 45 |
|
return false; |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
if(number.size()!=5){ |
| 49 |
< |
Util::showErrorPopUp("Invalid number format. It should contain 5 numbers."); |
| 49 |
> |
Util::Dialogs::showError("Invalid number format. It should contain 5 numbers."); |
| 50 |
|
return false; |
| 51 |
|
} |
| 52 |
|
|
| 53 |
< |
if(!Util::isStringInteger(number)){ |
| 54 |
< |
Util::showErrorPopUp("Number is not numeric."); |
| 53 |
> |
if(!Util::Validation::isStringInteger(number)){ |
| 54 |
> |
Util::Dialogs::showError("Number is not numeric."); |
| 55 |
|
return false; |
| 56 |
|
} |
| 57 |
|
|
| 67 |
|
{ |
| 68 |
|
QString number = ui->lePackageNumber->text(); |
| 69 |
|
|
| 70 |
< |
if(Util::checkEmptySpaces(QStringList(number))){ |
| 71 |
< |
Util::showErrorPopUp("Number is empty. Please fill it first."); |
| 70 |
> |
if(Util::Validation::checkEmptySpaces(QStringList(number))){ |
| 71 |
> |
Util::Dialogs::showError("Number is empty. Please fill it first."); |
| 72 |
|
return; |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
if(number.size()!=5){ |
| 76 |
< |
Util::showErrorPopUp("Invalid number format. It should contain 5 numeric characters."); |
| 76 |
> |
Util::Dialogs::showError("Invalid number format. It should contain 5 numeric characters."); |
| 77 |
|
return; |
| 78 |
|
} |
| 79 |
|
|
| 80 |
< |
if(Util::isStringInteger(number)){ |
| 80 |
> |
if(Util::Validation::isStringInteger(number)){ |
| 81 |
|
|
| 82 |
|
bool necessaryToRedownload=false; |
| 83 |
|
|
| 107 |
|
} |
| 108 |
|
} |
| 109 |
|
else{ |
| 110 |
< |
Util::showErrorPopUp("Number is not numeric."); |
| 110 |
> |
Util::Dialogs::showError("Number is not numeric."); |
| 111 |
|
} |
| 112 |
|
} |
| 113 |
|
|
| 123 |
|
} |
| 124 |
|
|
| 125 |
|
if(!file.open(QIODevice::WriteOnly)){ |
| 126 |
< |
UtilVago::showAndLogErrorPopUp(this->myLogger, "Error fetching package data: creating cache file."); |
| 126 |
> |
UtilVago::showAndLogErrorPopUp("Error fetching package data: creating cache file."); |
| 127 |
|
return; |
| 128 |
|
} |
| 129 |
|
file.write(result->readAll()); |
| 131 |
|
|
| 132 |
|
//Let's extract the cache data |
| 133 |
|
if(JlCompress::extractFile(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile, "/"+this->CacheFile ,GlobalVars::VagoTemporaryDir+"/"+this->CacheFile).isEmpty()){ |
| 134 |
< |
UtilVago::showAndLogErrorPopUp(this->myLogger, "An error occurred while unzipping the package data."); |
| 134 |
> |
UtilVago::showAndLogErrorPopUp("An error occurred while unzipping the package data."); |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
checkForPackagesInCache(); |
| 138 |
|
|
| 139 |
|
} |
| 140 |
|
else{ |
| 141 |
< |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error occurred checking number availability:\n\n"+result->errorString()); |
| 141 |
> |
UtilVago::showAndLogErrorPopUpLogButton("An error occurred checking number availability:\n\n"+result->errorString()); |
| 142 |
|
} |
| 143 |
|
|
| 144 |
|
result->deleteLater(); |
| 149 |
|
|
| 150 |
|
QFile file(GlobalVars::VagoTemporaryDir+"/"+this->CacheFile); //let's read the chache unzipped |
| 151 |
|
if(!file.open(QIODevice::ReadOnly)){ |
| 152 |
< |
UtilVago::showAndLogErrorPopUp(this->myLogger, "Error reading downloaded package cache data."); |
| 152 |
> |
UtilVago::showAndLogErrorPopUp("Error reading downloaded package cache data."); |
| 153 |
|
return; |
| 154 |
|
} |
| 155 |
|
//Read file cache to ram |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
if(!existingModName.isEmpty()){ |
| 179 |
< |
Util::showRichErrorPopUp("Package "+packageNumber+" is already being used by the following mod:<br/><br/>"+ |
| 179 |
> |
Util::Dialogs::showRichError("Package "+packageNumber+" is already being used by the following mod:<br/><br/>"+ |
| 180 |
|
existingModName+"<br/><br/>"+ |
| 181 |
|
"More information <a href='"+existingModUrl+"'>here</a>."); |
| 182 |
|
} |
| 183 |
|
else{ |
| 184 |
< |
Util::showPopUp("It seems that the package number " + packageNumber + " is not being used yet! :)"); |
| 184 |
> |
Util::Dialogs::showInfo("It seems that the package number " + packageNumber + " is not being used yet! :)"); |
| 185 |
|
} |
| 186 |
|
} |
| 187 |
|
|