Changeset View
Changeset View
Standalone View
Standalone View
shell/projectsourcepage.cpp
Show First 20 Lines • Show All 215 Lines • ▼ Show 20 Line(s) | 215 | if (m_ui->sources->currentIndex() == FROM_FILESYSTEM_SOURCE_INDEX) { | |||
---|---|---|---|---|---|
216 | emit isCorrect(dir.exists()); | 216 | emit isCorrect(dir.exists()); | ||
217 | return; | 217 | return; | ||
218 | } | 218 | } | ||
219 | 219 | | |||
220 | // all other cases where remote locations need to be specified | 220 | // all other cases where remote locations need to be specified | ||
221 | bool correct=!cwd.isRelative() && (!cwd.isLocalFile() || QDir(cwd.adjusted(QUrl::RemoveFilename).toLocalFile()).exists()); | 221 | bool correct=!cwd.isRelative() && (!cwd.isLocalFile() || QDir(cwd.adjusted(QUrl::RemoveFilename).toLocalFile()).exists()); | ||
222 | emit isCorrect(correct && m_ui->creationProgress->value() == m_ui->creationProgress->maximum()); | 222 | emit isCorrect(correct && m_ui->creationProgress->value() == m_ui->creationProgress->maximum()); | ||
223 | 223 | | |||
224 | bool validWidget = ((m_locationWidget && m_locationWidget->isCorrect()) || | 224 | const bool validWidget = ((m_locationWidget && m_locationWidget->isCorrect()) || | ||
225 | (m_providerWidget && m_providerWidget->isCorrect())); | 225 | (m_providerWidget && m_providerWidget->isCorrect())); | ||
226 | bool validToCheckout = correct && validWidget; //To checkout, if it exists, it should be an empty dir | 226 | const bool isFolderEmpty = (correct && cwd.isLocalFile() && dir.exists() && dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty()); | ||
kfunk: Same here, fwiw. Could you change that as well? | |||||
227 | if (validToCheckout && cwd.isLocalFile() && dir.exists()) { | 227 | const bool validToCheckout = correct && validWidget && (!dir.exists() || isFolderEmpty); | ||
kfunk: This doesn't need a ternary operation :)
Hint: `a ? b : false` => `a && b` | |||||
228 | validToCheckout = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty(); | | |||
229 | } | | |||
230 | 228 | | |||
231 | m_ui->get->setEnabled(validToCheckout); | 229 | m_ui->get->setEnabled(validToCheckout); | ||
Could be initialized properly in one expression (no need for another if-statement) kfunk: Could be initialized properly in one expression (no need for another if-statement) | |||||
232 | m_ui->creationProgress->setEnabled(validToCheckout); | 230 | m_ui->creationProgress->setEnabled(validToCheckout); | ||
233 | 231 | | |||
234 | if(!correct) | 232 | if(!correct) | ||
235 | setStatus(i18n("You need to specify a valid or nonexistent directory to check out a project")); | 233 | setStatus(i18n("You need to specify a valid or nonexistent directory to check out a project")); | ||
236 | else if(!m_ui->get->isEnabled() && m_ui->workingDir->isEnabled()) | 234 | else if(!m_ui->get->isEnabled() && m_ui->workingDir->isEnabled() && !validWidget) | ||
237 | setStatus(i18n("You need to specify a valid project location")); | 235 | setStatus(i18n("You need to specify the source for your remote project")); | ||
236 | else if(!m_ui->get->isEnabled() && m_ui->workingDir->isEnabled() && !isFolderEmpty) | ||||
237 | setStatus(i18n("You need to specify an empty folder as your project destination")); | ||||
238 | else | 238 | else | ||
239 | clearStatus(); | 239 | clearStatus(); | ||
240 | } | 240 | } | ||
241 | 241 | | |||
242 | void ProjectSourcePage::locationChanged() | 242 | void ProjectSourcePage::locationChanged() | ||
243 | { | 243 | { | ||
244 | Q_ASSERT(m_locationWidget); | 244 | Q_ASSERT(m_locationWidget); | ||
245 | if(m_locationWidget->isCorrect()) { | 245 | if(m_locationWidget->isCorrect()) { | ||
Show All 35 Lines |
Same here, fwiw. Could you change that as well?