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); } }
KJS::Value KstBindDataSource::fileType(KJS::ExecState *exec) const { Q_UNUSED(exec) KstDataSourcePtr s = makeSource(_d); if (s) { KstReadLocker rl(s); return KJS::String(s->fileType()); } return KJS::String(); }