| 1 | 
 #include "packagepage4.h" | 
 
 
 
 
 
 | 2 | 
 #include "ui_packagepage4.h" | 
 
 
 
 
 
 | 3 | 
  | 
 
 
 
 
 
 | 4 | 
 PackagePage4::PackagePage4(QWidget *parent) : | 
 
 
 
 
 
 | 5 | 
     QWizardPage(parent), | 
 
 
 
 
 
 | 6 | 
     ui(new Ui::PackagePage4) | 
 
 
 
 
 
 | 7 | 
 { | 
 
 
 
 
 
 | 8 | 
     ui->setupUi(this); | 
 
 
 
 
 
 | 9 | 
     this->setTitle("Package Files"); | 
 
 
 
 
 
 | 10 | 
     this->setSubTitle("Add here the resources to the correspondent plataform for your package."); | 
 
 
 
 
 
 | 11 | 
  | 
 
 
 
 
 
 | 12 | 
     commonTable=ui->twCommon; | 
 
 
 
 
 
 | 13 | 
     windowsTable=ui->twWindows; | 
 
 
 
 
 
 | 14 | 
     macTable=ui->twMac; | 
 
 
 
 
 
 | 15 | 
  | 
 
 
 
 
 
 | 16 | 
     //Setup package resources tables | 
 
 
 
 
 
 | 17 | 
     QStringList headers = QStringList()<<"Folder"<<"Type"<<"Full Path"; | 
 
 
 
 
 
 | 18 | 
     ui->twCommon->setHorizontalHeaderLabels(headers); | 
 
 
 
 
 
 | 19 | 
     ui->twCommon->setColumnWidth(1,75); //set size for type | 
 
 
 
 
 
 | 20 | 
     ui->twWindows->setHorizontalHeaderLabels(headers); | 
 
 
 
 
 
 | 21 | 
     ui->twWindows->setColumnWidth(1,75); | 
 
 
 
 
 
 | 22 | 
     ui->twMac->setHorizontalHeaderLabels(headers); | 
 
 
 
 
 
 | 23 | 
     ui->twMac->setColumnWidth(1,75); | 
 
 
 
 
 
 | 24 | 
     // | 
 
 
 
 
 
 | 25 | 
  | 
 
 
 
 
 
 | 26 | 
     //Set +- tooltips | 
 
 
 
 
 
 | 27 | 
     on_pbSwitchFiles_clicked(); | 
 
 
 
 
 
 | 28 | 
  | 
 
 
 
 
 
 | 29 | 
     ui->tbCommonMinus->setToolTip("Remove the selected common OS folders"); | 
 
 
 
 
 
 | 30 | 
     ui->tbWindowsMinus->setToolTip("Remove the selected Windows OS folders"); | 
 
 
 
 
 
 | 31 | 
     ui->tbMacMinus->setToolTip("Remove the selected Mac OS folders"); | 
 
 
 
 
 
 | 32 | 
  | 
 
 
 
 
 
 | 33 | 
     connectSlots(); | 
 
 
 
 
 
 | 34 | 
 } | 
 
 
 
 
 
 | 35 | 
  | 
 
 
 
 
 
 | 36 | 
 PackagePage4::~PackagePage4() | 
 
 
 
 
 
 | 37 | 
 { | 
 
 
 
 
 
 | 38 | 
     delete ui; | 
 
 
 
 
 
 | 39 | 
 } | 
 
 
 
 
 
 | 40 | 
  | 
 
 
 
 
 
 | 41 | 
 void PackagePage4::on_pbSwitchFiles_clicked() | 
 
 
 
 
 
 | 42 | 
 { | 
 
 
 
 
 
 | 43 | 
     if(ui->pbSwitchFiles->text()==".oni files"){ | 
 
 
 
 
 
 | 44 | 
         ui->pbSwitchFiles->setText(".bsl files"); | 
 
 
 
 
 
 | 45 | 
         ui->pbSwitchFiles->setToolTip("Click to add folders with .oni-patch files instead"); | 
 
 
 
 
 
 | 46 | 
     } | 
 
 
 
 
 
 | 47 | 
     else if(ui->pbSwitchFiles->text()==".bsl files"){ | 
 
 
 
 
 
 | 48 | 
         ui->pbSwitchFiles->setText(".oni-patch files"); | 
 
 
 
 
 
 | 49 | 
         ui->pbSwitchFiles->setToolTip("Click to add folders with .oni files instead"); | 
 
 
 
 
 
 | 50 | 
     } | 
 
 
 
 
 
 | 51 | 
     else{ | 
 
 
 
 
 
 | 52 | 
         ui->pbSwitchFiles->setText(".oni files"); | 
 
 
 
 
 
 | 53 | 
         ui->pbSwitchFiles->setToolTip("Click to add folders with .bsl files files instead"); | 
 
 
 
 
 
 | 54 | 
     } | 
 
 
 
 
 
 | 55 | 
  | 
 
 
 
 
 
 | 56 | 
     ui->tbCommonPlus->setToolTip("Add common OS folders with "+ui->pbSwitchFiles->text()); | 
 
 
 
 
 
 | 57 | 
     ui->tbWindowsPlus->setToolTip("Add Windows OS folders with "+ui->pbSwitchFiles->text()); | 
 
 
 
 
 
 | 58 | 
     ui->tbMacPlus->setToolTip("Add Mac OS folders with "+ui->pbSwitchFiles->text()); | 
 
 
 
 
 
 | 59 | 
 } | 
 
 
 
 
 
 | 60 | 
  | 
 
 
 
 
 
 | 61 | 
  | 
 
 
 
 
 
 | 62 | 
 void PackagePage4::addResourcesPackage(DropTableWidget *myTable, QStringList resources){ | 
 
 
 
 
 
 | 63 | 
  | 
 
 
 
 
 
 | 64 | 
     //Pre-processing (check if received only folders) | 
 
 
 
 
 
 | 65 | 
     foreach(QString myFile, resources){ | 
 
 
 
 
 
 | 66 | 
         if(!QDir(myFile).exists()){ | 
 
 
 
 
 
 | 67 | 
             Util::showErrorPopUp("Only folders are allowed for this operation."); | 
 
 
 
 
 
 | 68 | 
             return; | 
 
 
 
 
 
 | 69 | 
         } | 
 
 
 
 
 
 | 70 | 
     } | 
 
 
 
 
 
 | 71 | 
  | 
 
 
 
 
 
 | 72 | 
     QString type=ui->pbSwitchFiles->text().replace(" files",""); | 
 
 
 
 
 
 | 73 | 
  | 
 
 
 
 
 
 | 74 | 
     foreach(QString currentFolder, resources){ | 
 
 
 
 
 
 | 75 | 
  | 
 
 
 
 
 
 | 76 | 
         currentFolder=Util::normalizePath(currentFolder); //normalize path | 
 
 
 
 
 
 | 77 | 
  | 
 
 
 
 
 
 | 78 | 
         //Get actual number rows | 
 
 
 
 
 
 | 79 | 
         int twSize=myTable->rowCount(); | 
 
 
 
 
 
 | 80 | 
  | 
 
 
 
 
 
 | 81 | 
         //increase the rows for the new item | 
 
 
 
 
 
 | 82 | 
         myTable->setRowCount(twSize+1); | 
 
 
 
 
 
 | 83 | 
  | 
 
 
 
 
 
 | 84 | 
         //Add to table and list to | 
 
 
 
 
 
 | 85 | 
         QTableWidgetItem *newFolder = new QTableWidgetItem(Util::cutName(currentFolder)); | 
 
 
 
 
 
 | 86 | 
         QTableWidgetItem *newType = new QTableWidgetItem(type); | 
 
 
 
 
 
 | 87 | 
         QTableWidgetItem *newFullPath = new QTableWidgetItem(currentFolder); | 
 
 
 
 
 
 | 88 | 
  | 
 
 
 
 
 
 | 89 | 
         myTable->setItem(twSize,0,newFolder); | 
 
 
 
 
 
 | 90 | 
         myTable->setItem(twSize,1,newType); | 
 
 
 
 
 
 | 91 | 
         myTable->setItem(twSize,2,newFullPath); | 
 
 
 
 
 
 | 92 | 
         myTable->updateTableToolTips(twSize); //Update tool tips | 
 
 
 
 
 
 | 93 | 
     } | 
 
 
 
 
 
 | 94 | 
 } | 
 
 
 
 
 
 | 95 | 
  | 
 
 
 
 
 
 | 96 | 
 void PackagePage4::connectSlots(){ | 
 
 
 
 
 
 | 97 | 
     //Drop signal for Packages table | 
 
 
 
 
 
 | 98 | 
     connect(ui->twCommon, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addResourcesPackage(DropTableWidget*,QStringList))); | 
 
 
 
 
 
 | 99 | 
     connect(ui->twWindows, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addResourcesPackage(DropTableWidget*,QStringList))); | 
 
 
 
 
 
 | 100 | 
     connect(ui->twMac, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addResourcesPackage(DropTableWidget*,QStringList))); | 
 
 
 
 
 
 | 101 | 
 } | 
 
 
 
 
 
 | 102 | 
  | 
 
 
 
 
 
 | 103 | 
 void PackagePage4::on_tbCommonPlus_clicked() | 
 
 
 
 
 
 | 104 | 
 { | 
 
 
 
 
 
 | 105 | 
    addTableContents(ui->twCommon); | 
 
 
 
 
 
 | 106 | 
 } | 
 
 
 
 
 
 | 107 | 
  | 
 
 
 
 
 
 | 108 | 
 void PackagePage4::on_tbCommonMinus_clicked() | 
 
 
 
 
 
 | 109 | 
 { | 
 
 
 
 
 
 | 110 | 
     removeTableContents(ui->twCommon); | 
 
 
 
 
 
 | 111 | 
 } | 
 
 
 
 
 
 | 112 | 
  | 
 
 
 
 
 
 | 113 | 
 void PackagePage4::on_tbWindowsPlus_clicked() | 
 
 
 
 
 
 | 114 | 
 { | 
 
 
 
 
 
 | 115 | 
      addTableContents(ui->twWindows); | 
 
 
 
 
 
 | 116 | 
 } | 
 
 
 
 
 
 | 117 | 
  | 
 
 
 
 
 
 | 118 | 
 void PackagePage4::on_tbWindowsMinus_clicked() | 
 
 
 
 
 
 | 119 | 
 { | 
 
 
 
 
 
 | 120 | 
     removeTableContents(ui->twWindows); | 
 
 
 
 
 
 | 121 | 
 } | 
 
 
 
 
 
 | 122 | 
  | 
 
 
 
 
 
 | 123 | 
 void PackagePage4::on_tbMacPlus_clicked() | 
 
 
 
 
 
 | 124 | 
 { | 
 
 
 
 
 
 | 125 | 
     addTableContents(ui->twMac); | 
 
 
 
 
 
 | 126 | 
 } | 
 
 
 
 
 
 | 127 | 
  | 
 
 
 
 
 
 | 128 | 
 void PackagePage4::on_tbMacMinus_clicked() | 
 
 
 
 
 
 | 129 | 
 { | 
 
 
 
 
 
 | 130 | 
     removeTableContents(ui->twMac); | 
 
 
 
 
 
 | 131 | 
 } | 
 
 
 
 
 
 | 132 | 
  | 
 
 
 
 
 
 | 133 | 
 void PackagePage4::addTableContents(DropTableWidget *myTable){ | 
 
 
 
 
 
 | 134 | 
     if(ui->pbSwitchFiles->text()==".oni files"){ | 
 
 
 
 
 
 | 135 | 
         addResourcesPackage(myTable,Util::multipleDirDialog("Choose folders with .oni files...")); | 
 
 
 
 
 
 | 136 | 
     } | 
 
 
 
 
 
 | 137 | 
     else if(ui->pbSwitchFiles->text()==".bsl files"){ | 
 
 
 
 
 
 | 138 | 
         addResourcesPackage(myTable,Util::multipleDirDialog("Choose folders with .bsl files...")); | 
 
 
 
 
 
 | 139 | 
     } | 
 
 
 
 
 
 | 140 | 
     else{ | 
 
 
 
 
 
 | 141 | 
         addResourcesPackage(myTable,Util::multipleDirDialog("Choose folders with .oni-patch files...")); | 
 
 
 
 
 
 | 142 | 
     } | 
 
 
 
 
 
 | 143 | 
 } | 
 
 
 
 
 
 | 144 | 
  | 
 
 
 
 
 
 | 145 | 
 void PackagePage4::removeTableContents(DropTableWidget *myTable){ | 
 
 
 
 
 
 | 146 | 
     int size = myTable->selectionModel()->selectedRows().size(); | 
 
 
 
 
 
 | 147 | 
  | 
 
 
 
 
 
 | 148 | 
     if(size==0){ | 
 
 
 
 
 
 | 149 | 
         Util::showPopUp("Select a row first."); | 
 
 
 
 
 
 | 150 | 
         return; | 
 
 
 
 
 
 | 151 | 
     } | 
 
 
 
 
 
 | 152 | 
  | 
 
 
 
 
 
 | 153 | 
     if(Util::showQuestionPopUp(this,"Are you sure you want to delete the selected rows?")){ | 
 
 
 
 
 
 | 154 | 
         for(int i=0; i<size; i++){ | 
 
 
 
 
 
 | 155 | 
             myTable->removeRow(myTable->selectionModel()->selectedRows().at(size-i-1).row()); | 
 
 
 
 
 
 | 156 | 
         } | 
 
 
 
 
 
 | 157 | 
     } | 
 
 
 
 
 
 | 158 | 
 } | 
 
 
 
 
 
 | 159 | 
  | 
 
 
 
 
 
 | 160 | 
 bool PackagePage4::validatePage(){ | 
 
 
 
 
 
 | 161 | 
     if(ui->twCommon->rowCount()==0 && ui->twWindows->rowCount()==0 && ui->twMac->rowCount()==0){ | 
 
 
 
 
 
 | 162 | 
         Util::showErrorPopUp("You need to add some folders with resources first!"); | 
 
 
 
 
 
 | 163 | 
         return false; | 
 
 
 
 
 
 | 164 | 
     } | 
 
 
 
 
 
 | 165 | 
  | 
 
 
 
 
 
 | 166 | 
     return true; | 
 
 
 
 
 
 | 167 | 
 } |