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 KstChangeNptsDialogI::updateTimeCombo() { KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList); uint cnt = CurveList->count(); bool supportsTime = true; for (uint i = 0; i < cnt; ++i) { if (CurveList->isSelected(i)) { KstRVectorPtr vector = *(rvl.findTag(CurveList->text(i))); if (vector) { vector->readLock(); KstDataSourcePtr ds = vector->dataSource(); vector->unlock(); if (ds) { ds->readLock(); supportsTime = ds->supportsTimeConversions(); ds->unlock(); if (!supportsTime) { break; } } } } } _kstDataRange->setAllowTime(supportsTime); }
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); }