| 71 ui->fname->setFocus(); |
71 ui->fname->setFocus(); |
| 72 ui->progress->horizontalHeader()->setResizeMode (PartLabelColumn, QHeaderView::Stretch); |
72 ui->progress->horizontalHeader()->setResizeMode (PartLabelColumn, QHeaderView::Stretch); |
| 73 |
73 |
| 74 m_downloadButton = new QPushButton (tr ("Download")); |
74 m_downloadButton = new QPushButton (tr ("Download")); |
| 75 ui->buttonBox->addButton (m_downloadButton, QDialogButtonBox::ActionRole); |
75 ui->buttonBox->addButton (m_downloadButton, QDialogButtonBox::ActionRole); |
| 76 ui->buttonBox->button (QDialogButtonBox::Abort)->setEnabled (false); |
76 getButton (Abort)->setEnabled (false); |
| 77 |
77 |
| 78 connect (ui->source, SIGNAL (currentIndexChanged (int)), this, SLOT (sourceChanged (int))); |
78 connect (ui->source, SIGNAL (currentIndexChanged (int)), this, SLOT (sourceChanged (int))); |
| 79 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)), this, SLOT (buttonClicked (QAbstractButton*))); |
79 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)), this, SLOT (buttonClicked (QAbstractButton*))); |
| 80 } |
80 } |
| 81 |
81 |
| 114 if (net_guesspaths == false) |
114 if (net_guesspaths == false) |
| 115 return; |
115 return; |
| 116 |
116 |
| 117 // Ensure .dat extension |
117 // Ensure .dat extension |
| 118 if (dest.right (4) != ".dat") { |
118 if (dest.right (4) != ".dat") { |
| 119 // Remove the existing extension, if any. It may be we're here over a |
119 /* Remove the existing extension, if any. It may be we're here over a |
| 120 // typo in the .dat extension. |
120 typo in the .dat extension. */ |
| 121 const int dotpos = dest.lastIndexOf ("."); |
121 const int dotpos = dest.lastIndexOf ("."); |
| 122 if (dotpos != -1 && dotpos >= dest.length() - 4) |
122 if (dotpos != -1 && dotpos >= dest.length() - 4) |
| 123 dest.chop (dest.length() - dotpos); |
123 dest.chop (dest.length() - dotpos); |
| 124 |
124 |
| 125 dest += ".dat"; |
125 dest += ".dat"; |
| 126 } |
126 } |
| 127 |
127 |
| 128 // If the part starts with s\ or s/, then use parts/s/. Same goes with |
128 /* If the part starts with s\ or s/, then use parts/s/. Same goes with |
| 129 // 48\ and p/48/. |
129 48\ and p/48/. */ |
| 130 if (dest.left (2) == "s\\" || dest.left (2) == "s/") { |
130 if (dest.left (2) == "s\\" || dest.left (2) == "s/") { |
| 131 dest.remove (0, 2); |
131 dest.remove (0, 2); |
| 132 dest.prepend ("parts/s/"); |
132 dest.prepend ("parts/s/"); |
| 133 } elif (dest.left (3) == "48\\" || dest.left (3) == "48/") { |
133 } elif (dest.left (3) == "48\\" || dest.left (3) == "48/") { |
| 134 dest.remove (0, 3); |
134 dest.remove (0, 3); |
| 135 dest.prepend ("p/48/"); |
135 dest.prepend ("p/48/"); |
| 136 } |
136 } |
| 137 |
137 |
| 138 /* Try determine where to put this part. We have four directories: |
138 /* Try determine where to put this part. We have four directories: |
| 139 * parts/, parts/s/, p/, and p/48/. If we haven't already specified |
139 parts/, parts/s/, p/, and p/48/. If we haven't already specified |
| 140 * either parts/ or p/, we need to add it automatically. Part files |
140 either parts/ or p/, we need to add it automatically. Part files |
| 141 * are numbers which can be followed by: |
141 are numbers wit a possible u prefix for parts with unknown number |
| 142 * - c** (composites) |
142 which can be followed by any of: |
| 143 * - d** (formed stickers) |
143 - c** (composites) |
| 144 * - a lowercase alphabetic letter for variants |
144 - d** (formed stickers) |
| 145 * |
145 - p** (patterns) |
| 146 * Subfiles have an s** prefix, in which case we use parts/s/. Note that |
146 - a lowercase alphabetic letter for variants |
| 147 * the regex starts with a '^' so it won't catch already fully given part |
147 |
| 148 * file names. |
148 Subfiles (usually) have an s** prefix, in which case we use parts/s/. |
| 149 */ |
149 Note that the regex starts with a '^' so it won't catch already fully |
| 150 { |
150 given part file names. */ |
| 151 str partRegex = "^u?[0-9]+(c[0-9][0-9]+)*(d[0-9][0-9]+)*[a-z]?(p[0-9a-z][0-9a-z]+)*"; |
151 str partRegex = "^u?[0-9]+(c[0-9][0-9]+)*(d[0-9][0-9]+)*[a-z]?(p[0-9a-z][0-9a-z]+)*"; |
| 152 str subpartRegex = partRegex + "s[0-9][0-9]+"; |
152 str subpartRegex = partRegex + "s[0-9][0-9]+"; |
| 153 |
153 |
| 154 partRegex += "\\.dat$"; |
154 partRegex += "\\.dat$"; |
| 155 subpartRegex += "\\.dat$"; |
155 subpartRegex += "\\.dat$"; |
| 156 |
156 |
| 157 if (QRegExp (subpartRegex).exactMatch (dest)) |
157 if (QRegExp (subpartRegex).exactMatch (dest)) |
| 158 dest.prepend ("parts/s/"); |
158 dest.prepend ("parts/s/"); |
| 159 elif (QRegExp (partRegex).exactMatch (dest)) |
159 elif (QRegExp (partRegex).exactMatch (dest)) |
| 160 dest.prepend ("parts/"); |
160 dest.prepend ("parts/"); |
| 161 elif (dest.left (6) != "parts/" && dest.left (2) != "p/") |
161 elif (dest.left (6) != "parts/" && dest.left (2) != "p/") |
| 162 dest.prepend ("p/"); |
162 dest.prepend ("p/"); |
| 163 } |
|
| 164 } |
163 } |
| 165 |
164 |
| 166 // ============================================================================= |
165 // ============================================================================= |
| 167 // ----------------------------------------------------------------------------- |
166 // ----------------------------------------------------------------------------- |
| 168 PartDownloader::Source PartDownloader::getSource() const { |
167 PartDownloader::Source PartDownloader::getSource() const { |