void KstChangeFileDialog::sourceChanged(const QString& text) { delete _configWidget; _configWidget = 0L; _configureSource->setEnabled(false); _file = QString::null; if (!text.isEmpty() && text != "stdin" && text != "-") { KUrl url; QString txt = _dataFile->completionObject()->replacedPath(text); if (QFile::exists(txt) && QFileInfo(txt).isRelative()) { url.setPath(txt); } else { url = KUrl::fromPathOrURL(txt); } if (!url.isLocalFile() && url.protocol() != "file" && !url.protocol().isEmpty()) { _fileType->setText(QString::null); return; } if (!url.isValid()) { _fileType->setText(QString::null); return; } QString file = txt; KstDataSourcePtr ds = *KST::dataSourceList.findReusableFileName(file); QStringList fl; QString fileType; if (ds) { ds->readLock(); fl = ds->fieldList(); fileType = ds->fileType(); ds->unlock(); ds = 0L; } else { bool complete = false; fl = KstDataSource::fieldListForSource(file, QString::null, &fileType, &complete); } if (!fl.isEmpty() && !fileType.isEmpty()) { if (ds) { ds->writeLock(); _configWidget = ds->configWidget(); ds->unlock(); } else { _configWidget = KstDataSource::configWidgetForSource(file, fileType); } } _configureSource->setEnabled(_configWidget); _file = file; _fileType->setText(fileType.isEmpty() ? QString::null : tr("Data source of type: %1").arg(fileType)); } else { _fileType->setText(QString::null); } }
void KstVectorDialogI::updateCompletion() { QString current_text = Field->currentText(); Field->clear(); /* update filename list and ll axes combo boxes */ KST::dataSourceList.lock().readLock(); KstDataSourcePtr ds = *KST::dataSourceList.findFileName(FileName->url()); KST::dataSourceList.lock().readUnlock(); delete _configWidget; // FIXME: very inefficient!!!! _configWidget = 0L; QStringList list; if (ds) { ds->readLock(); list = ds->fieldList(); Field->setEditable(!ds->fieldListIsComplete()); _configWidget = ds->configWidget(); ds->readUnlock(); } else { QString type; bool complete = false; list = KstDataSource::fieldListForSource(FileName->url(), QString::null, &type, &complete); Field->setEditable(!complete); if (!list.isEmpty() && !type.isEmpty()) { _configWidget = KstDataSource::configWidgetForSource(FileName->url(), type); } } _configure->setEnabled(_configWidget); _fieldCompletion = Field->completionObject(); Field->insertStringList(list); if (_fieldCompletion) { _fieldCompletion->clear(); _fieldCompletion->insertItems(list); } if (!current_text.isEmpty() && (list.contains(current_text) || Field->editable())) { Field->setCurrentText(current_text); } _kstDataRange->setAllowTime(ds && ds->supportsTimeConversions()); }
void KstMatrixDialog::updateCompletion() { KstDataSourcePtr ds; QString current_text = _w->_field->currentText(); QStringList list; _w->_field->clear(); // // update filename list and ll axes combo boxes... // KST::dataSourceList.lock().readLock(); // xxx ds = *KST::dataSourceList.findReusableFileName(_w->_fileName->url()); KST::dataSourceList.lock().unlock(); delete _configWidget; _configWidget = 0L; if (ds) { ds->readLock(); list = ds->matrixList(); _w->_field->setEditable(!ds->fieldListIsComplete()); _configWidget = ds->configWidget(); ds->unlock(); _w->_field->setEnabled(true); _w->_connect->hide(); // _kstDataRange->setAllowTime(ds->supportsTimeConversions()); } else { bool complete = false; QString u; QString type; /* xxx u = _w->_fileName->url(); if (QFile::exists(u) && QFileInfo(u).isRelative()) { url.setPath(u); } else { url = QUrl(u); } if (!_inTest && !url.scheme()=="file" && url.scheme() != "file" && !url.isRelative()) { _w->_connect->show(); } else if (url.isValid()) { list = KstDataSource::matrixListForSource(u, QString::null, &type, &complete); // // pretend we're getting the full field list... // if (list.isEmpty()) { QStringList fullList = KstDataSource::fieldListForSource(u, QString::null, &type, &complete); } if (!_inTest || (_inTest && !list.isEmpty())) { _w->_connect->hide(); } } */ _w->_field->setEditable(!complete); _w->_field->setEnabled(!list.isEmpty()); if (!type.isEmpty()) { _configWidget = KstDataSource::configWidgetForSource(u, type); } // _kstDataRange->setAllowTime(KstDataSource::supportsTime(u, type)); } _w->_configure->setEnabled(_configWidget); // xxx _fieldCompletion = _w->_field->completionObject(); _w->_field->insertItems(0, list); /* xxx if (_fieldCompletion) { _fieldCompletion->clear(); _fieldCompletion->insertItems(list); } */ if (!current_text.isEmpty() && (list.contains(current_text) || _w->_field->isEditable())) { _w->_field->setItemText(_w->_field->currentIndex(), current_text); } _ok->setEnabled(_w->_field->isEnabled() || _editMultipleMode); }
void KstVectorDialogI::updateCompletion() { QString current_text = _w->Field->currentText(); _w->Field->clear(); // update filename list and ll axes combo boxes KST::dataSourceList.lock().readLock(); KstDataSourcePtr ds = *KST::dataSourceList.findReusableFileName(_w->FileName->url()); KST::dataSourceList.lock().unlock(); delete _configWidget; _configWidget = 0L; QStringList list; if (ds) { ds->readLock(); list = ds->fieldList(); _w->Field->setEditable(!ds->fieldListIsComplete()); _configWidget = ds->configWidget(); ds->unlock(); _w->Field->setEnabled(true); _w->_connect->hide(); _w->_kstDataRange->setAllowTime(ds->supportsTimeConversions()); } else { QString type; bool complete = false; QString u = _w->FileName->url(); KURL url; if (QFile::exists(u) && QFileInfo(u).isRelative()) { url.setPath(u); } else { url = KURL::fromPathOrURL(u); } if (!_inTest && !url.isLocalFile() && url.protocol() != "file" && !url.protocol().isEmpty()) { _w->_connect->show(); } else if (url.isValid()) { list = KstDataSource::fieldListForSource(u, QString::null, &type, &complete); if (!_inTest || (_inTest && !list.isEmpty())) { _w->_connect->hide(); } } _w->Field->setEditable(!complete); _w->Field->setEnabled(!list.isEmpty()); if (!list.isEmpty() && !type.isEmpty()) { _configWidget = KstDataSource::configWidgetForSource(u, type); } _w->_kstDataRange->setAllowTime(KstDataSource::supportsTime(u, type)); } _w->_configure->setEnabled(_configWidget); _fieldCompletion = _w->Field->completionObject(); _w->Field->insertStringList(list); if (_fieldCompletion) { _fieldCompletion->clear(); _fieldCompletion->insertItems(list); } if (!current_text.isEmpty() && (list.contains(current_text) || _w->Field->editable())) { _w->Field->setCurrentText(current_text); } _ok->setEnabled(_w->Field->isEnabled() || _editMultipleMode); }