Changeset View
Changeset View
Standalone View
Standalone View
shell/projectsourcepage.cpp
Show First 20 Lines • Show All 216 Lines • ▼ Show 20 Line(s) | 215 | if (m_ui->sources->currentIndex() == FROM_FILESYSTEM_SOURCE_INDEX) { | |||
---|---|---|---|---|---|
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 | 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 | bool validToCheckout = (correct && validWidget && cwd.isLocalFile() && dir.exists()) ? dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty() : correct && validWidget ; | ||
kfunk: Same here, fwiw. Could you change that as well? | |||||
kfunk: This doesn't need a ternary operation :)
Hint: `a ? b : false` => `a && b` | |||||
227 | if (validToCheckout && cwd.isLocalFile() && dir.exists()) { | 227 | | ||
228 | validToCheckout = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty(); | 228 | bool isFolderEmpty = (correct && cwd.isLocalFile() && dir.exists()) ? dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty() : false; | ||
229 | } | | |||
230 | 229 | | |||
231 | m_ui->get->setEnabled(validToCheckout); | 230 | 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); | 231 | m_ui->creationProgress->setEnabled(validToCheckout); | ||
233 | 232 | | |||
234 | if(!correct) | 233 | if(!correct) | ||
235 | setStatus(i18n("You need to specify a valid or nonexistent directory to check out a project")); | 234 | 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()) | 235 | else if(!m_ui->get->isEnabled() && m_ui->workingDir->isEnabled() && !validWidget) | ||
237 | setStatus(i18n("You need to specify a valid project location")); | 236 | setStatus(i18n("You need to specify the source for your remote project")); | ||
237 | else if(!m_ui->get->isEnabled() && m_ui->workingDir->isEnabled() && !isFolderEmpty) | ||||
238 | setStatus(i18n("You need to specify an empty folder as your project destination")); | ||||
238 | else | 239 | else | ||
239 | clearStatus(); | 240 | clearStatus(); | ||
240 | } | 241 | } | ||
241 | 242 | | |||
242 | void ProjectSourcePage::locationChanged() | 243 | void ProjectSourcePage::locationChanged() | ||
243 | { | 244 | { | ||
244 | Q_ASSERT(m_locationWidget); | 245 | Q_ASSERT(m_locationWidget); | ||
245 | if(m_locationWidget->isCorrect()) { | 246 | if(m_locationWidget->isCorrect()) { | ||
Show All 35 Lines |
Same here, fwiw. Could you change that as well?