예제 #1
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);
}
예제 #2
0
void KstMatrixDialog::fillFieldsForRMatrixEdit() {
  KstRMatrixPtr rmp;

  //
  // first hide/show the correct widgets...
  //

  _w->_readFromSource->setChecked(true);
  _w->_generateGradient->setChecked(false);
  _w->_dataSourceGroup->show();
  _w->_dataRangeGroup->show();
  _w->_gradientGroup->hide();
  _w->_scalingGroup->hide();

  rmp = kst_cast<KstRMatrix>(_dp);
  if (rmp) {
    rmp->readLock();
  
    //
    // fill in the list of fields...
    //

    _w->_field->clear();
/* xxx
    if (_fieldCompletion) {
      _fieldCompletion->clear();
    }
*/
    //
    // scope for iterator...
    //

    {
      KstDataSourcePtr tf;
      KstDataSourceList::iterator it;

      KST::dataSourceList.lock().readLock();
      it = KST::dataSourceList.findReusableFileName(rmp->filename());
      if (it != KST::dataSourceList.end()) {
        tf = *it;
        tf->readLock();
        _w->_field->insertItems(0, tf->matrixList());
/* xxx
        if (_fieldCompletion) {
          _fieldCompletion->insertItems(tf->matrixList());
        }
*/
        tf->unlock();
      } else {
        QStringList list;

// xxx        list = KstDataSource::matrixListForSource(_w->_fileName->url());
        _w->_field->insertItems(0, list);
/* xxx
        if (_fieldCompletion) {
          _fieldCompletion->insertItems(list);
        }
*/
      }
      KST::dataSourceList.lock().unlock();
    }

    _w->_field->setEnabled(_w->_field->count() > 0);
    _ok->setEnabled(_w->_field->isEnabled());
    _w->_field->setItemText(_w->_field->currentIndex(), rmp->field());
  
    //
    // fill in the other parameters...
    //

// xxx    _w->_fileName->setURL(rmp->filename());
  
    _w->_xStart->setValue(rmp->reqXStart());
    _w->_yStart->setValue(rmp->reqYStart());
    _w->_xNumSteps->setValue(rmp->reqXNumSteps());
    _w->_yNumSteps->setValue(rmp->reqYNumSteps());
  
    _w->_xStartCountFromEnd->setChecked(rmp->xCountFromEnd());
    _w->_yStartCountFromEnd->setChecked(rmp->yCountFromEnd());
    _w->_xNumStepsReadToEnd->setChecked(rmp->xReadToEnd());
    _w->_yNumStepsReadToEnd->setChecked(rmp->yReadToEnd());
  
    _w->_doSkip->setChecked(rmp->doSkip());
    _w->_skip->setValue(rmp->skip());
    _w->_doAve->setChecked(rmp->doAverage());
  
    rmp->unlock();
  }
}