source: s10k/Vago/packageWizard/packagepage4.cpp@ 1095

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

Vago 1.4

File size: 5.8 KB
RevLine 
[771]1#include "packagepage4.h"
2#include "ui_packagepage4.h"
3
4PackagePage4::PackagePage4(QWidget *parent) :
5 QWizardPage(parent),
6 ui(new Ui::PackagePage4)
7{
8 ui->setupUi(this);
9 this->setTitle("Package Files");
[799]10 this->setSubTitle("Add the resources to the corresponding platform for your package.");
[771]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
[790]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
[771]39 connectSlots();
40}
41
42PackagePage4::~PackagePage4()
43{
44 delete ui;
45}
46
47void 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
68void PackagePage4::addResourcesPackage(DropTableWidget *myTable, QStringList resources){
69
70 //Pre-processing (check if received only folders)
[1093]71 for(const QString &myFile : resources){
[771]72 if(!QDir(myFile).exists()){
[1093]73 Util::Dialogs::showError("Only folders are allowed for this operation.");
[771]74 return;
75 }
76 }
77
78 QString type=ui->pbSwitchFiles->text().replace(" files","");
79
[1093]80 for(QString currentFolder: resources){
[771]81
[1093]82 currentFolder=Util::FileSystem::normalizePath(currentFolder); //normalize path
[771]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
[1093]91 QTableWidgetItem *newFolder = new QTableWidgetItem(Util::FileSystem::cutName(currentFolder));
[771]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
102void 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
109void PackagePage4::on_tbCommonPlus_clicked()
110{
111 addTableContents(ui->twCommon);
112}
113
114void PackagePage4::on_tbCommonMinus_clicked()
115{
116 removeTableContents(ui->twCommon);
117}
118
119void PackagePage4::on_tbWindowsPlus_clicked()
120{
121 addTableContents(ui->twWindows);
122}
123
124void PackagePage4::on_tbWindowsMinus_clicked()
125{
126 removeTableContents(ui->twWindows);
127}
128
129void PackagePage4::on_tbMacPlus_clicked()
130{
131 addTableContents(ui->twMac);
132}
133
134void PackagePage4::on_tbMacMinus_clicked()
135{
136 removeTableContents(ui->twMac);
137}
138
139void PackagePage4::addTableContents(DropTableWidget *myTable){
140 if(ui->pbSwitchFiles->text()==".oni files"){
[1093]141 addResourcesPackage(myTable,Util::Dialogs::multipleDirSelection("Choose folders with .oni files..."));
[771]142 }
143 else if(ui->pbSwitchFiles->text()==".bsl files"){
[1093]144 addResourcesPackage(myTable,Util::Dialogs::multipleDirSelection("Choose folders with .bsl files..."));
[771]145 }
146 else{
[1093]147 addResourcesPackage(myTable,Util::Dialogs::multipleDirSelection("Choose folders with .oni-patch files..."));
[771]148 }
149}
150
151void PackagePage4::removeTableContents(DropTableWidget *myTable){
152 int size = myTable->selectionModel()->selectedRows().size();
153
154 if(size==0){
[1093]155 Util::Dialogs::showInfo("Select a row first.");
[771]156 return;
157 }
158
[1093]159 if(Util::Dialogs::showQuestion(this,"Are you sure you want to delete the selected rows?")){
[771]160 for(int i=0; i<size; i++){
161 myTable->removeRow(myTable->selectionModel()->selectedRows().at(size-i-1).row());
162 }
163 }
164}
165
166bool PackagePage4::validatePage(){
167 if(ui->twCommon->rowCount()==0 && ui->twWindows->rowCount()==0 && ui->twMac->rowCount()==0){
[1093]168 Util::Dialogs::showError("You need to add some folders with resources first!");
[771]169 return false;
170 }
171
172 return true;
173}
Note: See TracBrowser for help on using the repository browser.