KJS::Value KstBindDataSource::completeFieldList(KJS::ExecState *exec) const {
  Q_UNUSED(exec)
  KstDataSourcePtr s = makeSource(_d);
  if (s) {
    KstReadLocker rl(s);
    return KJS::Boolean(s->fieldListIsComplete());
  }
  return KJS::Boolean(false);
}
Beispiel #2
0
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());
}
Beispiel #3
0
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);
}