ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/Vago/packageWizard/packagepage2.cpp
(Generate patch)

Comparing Vago/trunk/Vago/packageWizard/packagepage2.cpp (file contents):
Revision 771 by s10k, Sun Mar 31 19:02:16 2013 UTC vs.
Revision 1047 by s10k, Fri Sep 16 22:51:26 2016 UTC

# Line 20 | Line 20 | PackagePage2::PackagePage2(Logger *myLog
20      registerField("ptDescription", ui->ptDescription,"plainText");
21      registerField("lePackageNumber", ui->lePackageNumber);
22      registerField("rbReplace", ui->rbReplace);
23 +
24 +    ui->lbFieldsReadOnly->setText("<html><span style='color:#0000ff;'>* Fields read only  by AEI2 when the package "
25 +            "isn't at the mod depot.</span></html>"); // Don't use rich text in qtdesigner because it generates platform dependent code
26 +    QString htmlAsterisk="<html><span style='color:#0000ff;'>*</span></html>";
27 +    ui->lbAsteriscAuthors->setText(htmlAsterisk);
28 +    ui->lbAsteriscModName->setText(htmlAsterisk);
29 +    ui->lbAsteriscVersion->setText(htmlAsterisk);
30 +    ui->lbAsteriscDescription->setText(htmlAsterisk);
31   }
32  
33   bool PackagePage2::validatePage(){
# Line 65 | Line 73 | void PackagePage2::on_pbCheck_clicked()
73      }
74  
75      if(number.size()!=5){
76 <        Util::showErrorPopUp("Invalid number format. It should contain 5 numbers.");
76 >        Util::showErrorPopUp("Invalid number format. It should contain 5 numeric characters.");
77          return;
78      }
79  
# Line 73 | Line 81 | void PackagePage2::on_pbCheck_clicked()
81  
82          bool necessaryToRedownload=false;
83  
84 <        QFile *file = new QFile(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile);
84 >        QFile file(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile);
85  
86 <        if(!file->exists()){
86 >        if(!file.exists()){
87              necessaryToRedownload=true; //File doesn't exist yet, necessary to download
88          }
89 <        else if (QDateTime::currentDateTime().toTime_t()-QFileInfo(*file).lastModified().toTime_t() > 150){ //checks between 2 minutes (give more 30 seconds due to zip extraction)
89 >        else if (QDateTime::currentDateTime().toTime_t()-QFileInfo(file).lastModified().toTime_t() > 150){ //checks between 2 minutes (give more 30 seconds due to zip extraction)
90              necessaryToRedownload=true; //File already exists but already expired (+2 mins without update)
91          }
84        delete file;
92  
93          if(necessaryToRedownload){
94              //let's start the search in the web, so we make sure it doesn't exists yet
# Line 108 | Line 115 | void PackagePage2::downloadPackagesCache
115  
116      if(result->error()==QNetworkReply::NoError){
117  
118 <        QFile *file = new QFile(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile);
118 >        QFile file(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile);
119  
120          // Create temp folder if it doesn't exist
121          if(!QDir(GlobalVars::VagoTemporaryDir).exists()){
122              QDir().mkdir(GlobalVars::VagoTemporaryDir);
123          }
124  
125 <        if(!file->open(QIODevice::WriteOnly)){
126 <            const QString error="Error fetching package data: creating cache file.";
120 <            this->myLogger->writeString(error);
121 <            Util::showErrorPopUp(error);
125 >        if(!file.open(QIODevice::WriteOnly)){
126 >            UtilVago::showAndLogErrorPopUp(this->myLogger, "Error fetching package data: creating cache file.");
127              return;
128          }
129 <        file->write(result->readAll());
130 <        file->close();
129 >        file.write(result->readAll());
130 >        file.close();
131  
132          //Let's extract the cache data
133 <        UnZip uz;
134 <        UnZip::ErrorCode ec = uz.openArchive(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile);
135 <        checkForUnzipError(ec);
131 <
132 <        //Extract the cache files
133 <        ec = uz.extractAll(GlobalVars::VagoTemporaryDir);
134 <        checkForUnzipError(ec);
135 <
136 <        //Close zip archive
137 <        uz.closeArchive();
138 <
139 <        delete file;
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.");
135 >        }
136  
137          checkForPackagesInCache();
138  
139      }
140      else{
141 <        const QString error="An error occurred checking number availability:\n\n"+result->errorString();
146 <        this->myLogger->writeString(error);
147 <        Util::showErrorLogPopUp(error);
141 >        UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error occurred checking number availability:\n\n"+result->errorString());
142      }
143  
144      result->deleteLater();
# Line 153 | Line 147 | void PackagePage2::downloadPackagesCache
147   void PackagePage2::checkForPackagesInCache(){
148      QString packageNumber=ui->lePackageNumber->text();
149  
150 <    QFile *file = new QFile(GlobalVars::VagoTemporaryDir+"/"+this->CacheFile); //let's read the chache unzipped
151 <    if(!file->open(QIODevice::ReadOnly)){
152 <        const QString error="Error reading downloaded package cache data.";
159 <        this->myLogger->writeString(error);
160 <        Util::showErrorPopUp(error);
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.");
153          return;
154      }
155      //Read file cache to ram
156 <    QString data=file->readAll();
156 >    QString data=file.readAll();
157  
158  
159      //Let's play with json engine
# Line 189 | Line 181 | void PackagePage2::checkForPackagesInCac
181                                   "More information <a href='"+existingModUrl+"'>here</a>.");
182      }
183      else{
184 <        Util::showPopUp("Package "+packageNumber+" seems it's not being used yet! :)");
184 >        Util::showPopUp("It seems that the package number " + packageNumber + " is not being used yet! :)");
185      }
194
195    delete file;
186   }
187  
188   void PackagePage2::on_cbType_currentIndexChanged(int index)
189   {
190 <    ui->lePackageNumber->setText(QString().setNum(index+1)+"000X");
201 < }
202 <
203 < void PackagePage2::checkForUnzipError(UnZip::ErrorCode ec){
204 <    if (ec != UnZip::Ok){
205 <        const QString error="Error found while unzipping the package data. Error number = "+QString::number(ec);
206 <        Util::showErrorPopUp(error);
207 <        this->myLogger->writeString(error);
208 <    }
190 >    ui->lePackageNumber->setText(QString().setNum(index+1)+"XXXX");
191   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)