Mercurial > retraceit
comparison src/folderselectdialog.cpp @ 79:ca8d3cfe8ba1 1.0.0
Do not check path existence while typing
Checking if a path exists can be expensive especially
for network paths. So we only do this now once the
user hits "Go"
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 16 Jun 2015 12:36:37 +0200 |
parents | de148cd023a1 |
children | 90c297a2a3dd |
comparison
equal
deleted
inserted
replaced
78:6965fb5db4b7 | 79:ca8d3cfe8ba1 |
---|---|
77 mGoButton = new QPushButton(tr("Go")); | 77 mGoButton = new QPushButton(tr("Go")); |
78 mGoButton->setEnabled(false); | 78 mGoButton->setEnabled(false); |
79 folderChangeArea->addWidget(mGoButton); | 79 folderChangeArea->addWidget(mGoButton); |
80 connect(mGoButton, &QPushButton::clicked, this, | 80 connect(mGoButton, &QPushButton::clicked, this, |
81 &FolderSelectDialog::goClicked); | 81 &FolderSelectDialog::goClicked); |
82 connect(mPathLineEdit, &QLineEdit::returnPressed, this, | |
83 &FolderSelectDialog::goClicked); | |
82 } | 84 } |
83 | 85 |
84 mFilterWidget = new FilterWidget(mSortModel); | 86 mFilterWidget = new FilterWidget(mSortModel); |
85 base->addWidget(mFilterWidget); | 87 base->addWidget(mFilterWidget); |
86 | 88 |
116 mOkButton->setEnabled(!selected.indexes().isEmpty()); | 118 mOkButton->setEnabled(!selected.indexes().isEmpty()); |
117 } | 119 } |
118 | 120 |
119 void FolderSelectDialog::pathLineChanged() { | 121 void FolderSelectDialog::pathLineChanged() { |
120 const QString path = mPathLineEdit->text(); | 122 const QString path = mPathLineEdit->text(); |
121 qDebug() << "path: " << path; | |
122 if (path.isEmpty()) { | 123 if (path.isEmpty()) { |
123 mGoButton->setEnabled(false); | 124 mGoButton->setEnabled(false); |
124 return; | 125 return; |
125 } | 126 } |
127 mGoButton->setEnabled(true); | |
128 } | |
129 | |
130 | |
131 void FolderSelectDialog::goClicked() { | |
132 const QString path = mPathLineEdit->text(); | |
126 QDir dir(path); | 133 QDir dir(path); |
127 if (dir.exists()) { | 134 if (!dir.exists()) { |
128 mGoButton->setEnabled(true); | 135 QMessageBox::warning(this, tr("Error!"), tr("Failed to access directory: '%1'").arg(path)); |
129 return; | 136 mGoButton->setEnabled(false); |
130 } | 137 return; |
131 mGoButton->setEnabled(false); | 138 } |
132 } | |
133 | |
134 | |
135 void FolderSelectDialog::goClicked() { | |
136 setFolder(mPathLineEdit->text()); | 139 setFolder(mPathLineEdit->text()); |
137 QSettings settings; | 140 QSettings settings; |
138 /* assuming go is only available in root folder mode */ | 141 /* assuming go is only available in root folder mode */ |
139 settings.setValue(ROOT_FOLDER_KEY, mPathLineEdit->text()); | 142 settings.setValue(ROOT_FOLDER_KEY, mPathLineEdit->text()); |
140 } | 143 } |