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 | ui->lbCommon->setText("<html><b>Common</b></html>"); // Don't use rich text in qtdesigner because it generates platform dependent code
|
---|
34 | ui->lbWindowsOnly->setText("<html><b>Windows Only</b></html>");
|
---|
35 | ui->lbMacOnly->setText("<html><b>Mac OS Only</b></html>");
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 | connectSlots();
|
---|
40 | }
|
---|
41 |
|
---|
42 | PackagePage4::~PackagePage4()
|
---|
43 | {
|
---|
44 | delete ui;
|
---|
45 | }
|
---|
46 |
|
---|
47 | void PackagePage4::on_pbSwitchFiles_clicked()
|
---|
48 | {
|
---|
49 | if(ui->pbSwitchFiles->text()==".oni files"){
|
---|
50 | ui->pbSwitchFiles->setText(".bsl files");
|
---|
51 | ui->pbSwitchFiles->setToolTip("Click to add folders with .oni-patch files instead");
|
---|
52 | }
|
---|
53 | else if(ui->pbSwitchFiles->text()==".bsl files"){
|
---|
54 | ui->pbSwitchFiles->setText(".oni-patch files");
|
---|
55 | ui->pbSwitchFiles->setToolTip("Click to add folders with .oni files instead");
|
---|
56 | }
|
---|
57 | else{
|
---|
58 | ui->pbSwitchFiles->setText(".oni files");
|
---|
59 | ui->pbSwitchFiles->setToolTip("Click to add folders with .bsl files files instead");
|
---|
60 | }
|
---|
61 |
|
---|
62 | ui->tbCommonPlus->setToolTip("Add common OS folders with "+ui->pbSwitchFiles->text());
|
---|
63 | ui->tbWindowsPlus->setToolTip("Add Windows OS folders with "+ui->pbSwitchFiles->text());
|
---|
64 | ui->tbMacPlus->setToolTip("Add Mac OS folders with "+ui->pbSwitchFiles->text());
|
---|
65 | }
|
---|
66 |
|
---|
67 |
|
---|
68 | void PackagePage4::addResourcesPackage(DropTableWidget *myTable, QStringList resources){
|
---|
69 |
|
---|
70 | //Pre-processing (check if received only folders)
|
---|
71 | foreach(QString myFile, resources){
|
---|
72 | if(!QDir(myFile).exists()){
|
---|
73 | Util::showErrorPopUp("Only folders are allowed for this operation.");
|
---|
74 | return;
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | QString type=ui->pbSwitchFiles->text().replace(" files","");
|
---|
79 |
|
---|
80 | foreach(QString currentFolder, resources){
|
---|
81 |
|
---|
82 | currentFolder=Util::normalizePath(currentFolder); //normalize path
|
---|
83 |
|
---|
84 | //Get actual number rows
|
---|
85 | int twSize=myTable->rowCount();
|
---|
86 |
|
---|
87 | //increase the rows for the new item
|
---|
88 | myTable->setRowCount(twSize+1);
|
---|
89 |
|
---|
90 | //Add to table and list to
|
---|
91 | QTableWidgetItem *newFolder = new QTableWidgetItem(Util::cutName(currentFolder));
|
---|
92 | QTableWidgetItem *newType = new QTableWidgetItem(type);
|
---|
93 | QTableWidgetItem *newFullPath = new QTableWidgetItem(currentFolder);
|
---|
94 |
|
---|
95 | myTable->setItem(twSize,0,newFolder);
|
---|
96 | myTable->setItem(twSize,1,newType);
|
---|
97 | myTable->setItem(twSize,2,newFullPath);
|
---|
98 | myTable->updateTableToolTips(twSize); //Update tool tips
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | void PackagePage4::connectSlots(){
|
---|
103 | //Drop signal for Packages table
|
---|
104 | connect(ui->twCommon, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addResourcesPackage(DropTableWidget*,QStringList)));
|
---|
105 | connect(ui->twWindows, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addResourcesPackage(DropTableWidget*,QStringList)));
|
---|
106 | connect(ui->twMac, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addResourcesPackage(DropTableWidget*,QStringList)));
|
---|
107 | }
|
---|
108 |
|
---|
109 | void PackagePage4::on_tbCommonPlus_clicked()
|
---|
110 | {
|
---|
111 | addTableContents(ui->twCommon);
|
---|
112 | }
|
---|
113 |
|
---|
114 | void PackagePage4::on_tbCommonMinus_clicked()
|
---|
115 | {
|
---|
116 | removeTableContents(ui->twCommon);
|
---|
117 | }
|
---|
118 |
|
---|
119 | void PackagePage4::on_tbWindowsPlus_clicked()
|
---|
120 | {
|
---|
121 | addTableContents(ui->twWindows);
|
---|
122 | }
|
---|
123 |
|
---|
124 | void PackagePage4::on_tbWindowsMinus_clicked()
|
---|
125 | {
|
---|
126 | removeTableContents(ui->twWindows);
|
---|
127 | }
|
---|
128 |
|
---|
129 | void PackagePage4::on_tbMacPlus_clicked()
|
---|
130 | {
|
---|
131 | addTableContents(ui->twMac);
|
---|
132 | }
|
---|
133 |
|
---|
134 | void PackagePage4::on_tbMacMinus_clicked()
|
---|
135 | {
|
---|
136 | removeTableContents(ui->twMac);
|
---|
137 | }
|
---|
138 |
|
---|
139 | void PackagePage4::addTableContents(DropTableWidget *myTable){
|
---|
140 | if(ui->pbSwitchFiles->text()==".oni files"){
|
---|
141 | addResourcesPackage(myTable,Util::multipleDirDialog("Choose folders with .oni files..."));
|
---|
142 | }
|
---|
143 | else if(ui->pbSwitchFiles->text()==".bsl files"){
|
---|
144 | addResourcesPackage(myTable,Util::multipleDirDialog("Choose folders with .bsl files..."));
|
---|
145 | }
|
---|
146 | else{
|
---|
147 | addResourcesPackage(myTable,Util::multipleDirDialog("Choose folders with .oni-patch files..."));
|
---|
148 | }
|
---|
149 | }
|
---|
150 |
|
---|
151 | void PackagePage4::removeTableContents(DropTableWidget *myTable){
|
---|
152 | int size = myTable->selectionModel()->selectedRows().size();
|
---|
153 |
|
---|
154 | if(size==0){
|
---|
155 | Util::showPopUp("Select a row first.");
|
---|
156 | return;
|
---|
157 | }
|
---|
158 |
|
---|
159 | if(Util::showQuestionPopUp(this,"Are you sure you want to delete the selected rows?")){
|
---|
160 | for(int i=0; i<size; i++){
|
---|
161 | myTable->removeRow(myTable->selectionModel()->selectedRows().at(size-i-1).row());
|
---|
162 | }
|
---|
163 | }
|
---|
164 | }
|
---|
165 |
|
---|
166 | bool PackagePage4::validatePage(){
|
---|
167 | if(ui->twCommon->rowCount()==0 && ui->twWindows->rowCount()==0 && ui->twMac->rowCount()==0){
|
---|
168 | Util::showErrorPopUp("You need to add some folders with resources first!");
|
---|
169 | return false;
|
---|
170 | }
|
---|
171 |
|
---|
172 | return true;
|
---|
173 | }
|
---|