本文整理汇总了C++中KstDataSourcePtr::readLock方法的典型用法代码示例。如果您正苦于以下问题:C++ KstDataSourcePtr::readLock方法的具体用法?C++ KstDataSourcePtr::readLock怎么用?C++ KstDataSourcePtr::readLock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KstDataSourcePtr
的用法示例。
在下文中一共展示了KstDataSourcePtr::readLock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyNptsChange
void KstChangeNptsDialogI::applyNptsChange() {
KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
for (uint i = 0; i < CurveList->count(); ++i) {
if (CurveList->isSelected(i)) {
KstRVectorPtr vector = *(rvl.findTag(CurveList->text(i)));
if (vector) {
int f0, n;
vector->readLock();
KstDataSourcePtr ds = vector->dataSource();
if (_kstDataRange->isStartRelativeTime() && ds) {
ds->readLock();
f0 = ds->sampleForTime(_kstDataRange->f0Value());
ds->unlock();
} else if (_kstDataRange->isStartAbsoluteTime() && ds) {
ds->readLock();
f0 = ds->sampleForTime(_kstDataRange->f0DateTimeValue());
ds->unlock();
} else {
f0 = int(_kstDataRange->f0Value());
}
if (_kstDataRange->isRangeRelativeTime() && ds) {
ds->readLock();
double nValStored = _kstDataRange->nValue();
if (_kstDataRange->CountFromEnd->isChecked()) {
int frameCount = ds->frameCount(vector->field());
double msCount = ds->relativeTimeForSample(frameCount - 1);
n = frameCount - 1 - ds->sampleForTime(msCount - nValStored);
} else {
double fTime = ds->relativeTimeForSample(f0);
n = ds->sampleForTime(fTime + nValStored) - ds->sampleForTime(fTime);
}
ds->unlock();
} else {
n = int(_kstDataRange->nValue());
}
vector->unlock();
vector->writeLock();
vector->changeFrames(
(_kstDataRange->CountFromEnd->isChecked() ? -1 : f0),
(_kstDataRange->ReadToEnd->isChecked() ? -1 : n),
_kstDataRange->Skip->value(),
_kstDataRange->DoSkip->isChecked(),
_kstDataRange->DoFilter->isChecked());
vector->unlock();
}
}
}
_modifiedRange = false;
// avoid re-entering the dialog
QTimer::singleShot(0, this, SLOT(emitDocChanged()));
}
示例2: sourceChanged
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);
}
}
示例3: metaData
KJS::Value KstBindDataSource::metaData(KJS::ExecState *exec) const {
KJS::Object array(exec->interpreter()->builtinArray().construct(exec, 0));
KstDataSourcePtr s = makeSource(_d);
if (s) {
s->readLock();
QMap<QString,QString> data = s->metaData();
s->readUnlock();
for (QMap<QString,QString>::ConstIterator i = data.begin(); i != data.end(); ++i) {
array.put(exec, KJS::Identifier(i.key().latin1()), KJS::String(i.data()));
}
}
return array;
}
示例4: metaData
KJS::Value KstBindDataSource::metaData(KJS::ExecState *exec) const {
KJS::Object array(exec->interpreter()->builtinArray().construct(exec, 0));
KstDataSourcePtr s = makeSource(_d);
if (s) {
s->readLock();
QDict<KstString> data = s->metaData();
s->unlock();
for (QDictIterator<KstString> i(data); i.current(); ++i) {
array.put(exec, KJS::Identifier(i.currentKey().latin1()), KJS::String(i.current() ? i.current()->value() : QString::null));
}
}
return array;
}
示例5: fieldList
KJS::Value KstBindDataSource::fieldList(KJS::ExecState *exec, const KJS::List& args) {
Q_UNUSED(args)
KJS::List rc;
KstDataSourcePtr s = makeSource(_d);
if (!s) {
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
return KJS::Object(exec->interpreter()->builtinArray().construct(exec, rc));
}
s->readLock();
QStringList l = s->fieldList();
s->unlock();
for (QStringList::ConstIterator i = l.begin(); i != l.end(); ++i) {
rc.append(KJS::String(*i));
}
return KJS::Object(exec->interpreter()->builtinArray().construct(exec, rc));
}
示例6: updateCompletion
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());
}
示例7: updateTimeCombo
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);
}
示例8: applyFileChange
bool KstChangeFileDialog::applyFileChange() {
KstDataSourcePtr file;
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(_dataFile->url());
QString invalidSources;
int invalid = 0;
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(_dataFile->url());
if (!file || !file->isValid()) {
KST::dataSourceList.lock().unlock();
QMessageBox::warning(this, tr("Kst"), tr("The file could not be loaded."));
return false;
}
if (file->isEmpty()) {
KST::dataSourceList.lock().unlock();
QMessageBox::warning(this, tr("Kst"), tr("The file does not contain data."));
return false;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().unlock();
KstApp *app = KstApp::inst();
KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
KstRMatrixList rml = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
int selected = 0;
int handled = 0;
int count = (int)ChangeFileCurveList->count();
for (int i = 0; i < count; i++) {
if (ChangeFileCurveList->isSelected(i)) {
++selected;
}
}
// a map to keep track of which objects have been duplicated, and mapping
// old object -> new object
KstDataObjectDataObjectMap duplicatedMap;
QMap<KstVectorPtr, KstVectorPtr> duplicatedVectors;
QMap<KstMatrixPtr, KstMatrixPtr> duplicatedMatrices;
KstDataSourceList oldSources;
// go through the vectors
for (int i = 0; i < (int)rvl.count(); i++) {
if (ChangeFileCurveList->isSelected(i)) {
KstRVectorPtr vector = rvl[i];
vector->writeLock();
file->readLock();
bool valid = file->isValidField(vector->field());
file->unlock();
if (!valid) {
if (invalid > 0) {
invalidSources = tr("%1, %2").arg(invalidSources).arg(vector->field());
} else {
invalidSources = vector->field();
}
++invalid;
} else {
if (_duplicateSelected->isChecked()) {
// block vector updates until vector is setup properly
KST::vectorList.lock().writeLock();
// create a new vector
KstRVectorPtr newVector = vector->makeDuplicate();
if (!oldSources.contains(newVector->dataSource())) {
oldSources << newVector->dataSource();
}
newVector->changeFile(file);
KST::vectorList.lock().unlock();
// duplicate dependents
if (_duplicateDependents->isChecked()) {
duplicatedVectors.insert(KstVectorPtr(vector), KstVectorPtr(newVector));
KST::duplicateDependents(KstVectorPtr(vector), duplicatedMap, duplicatedVectors);
}
} else {
if (!oldSources.contains(vector->dataSource())) {
oldSources << vector->dataSource();
}
vector->changeFile(file);
}
}
vector->unlock();
app->slotUpdateProgress(selected, ++handled, tr("Updating vectors..."));
}
}
// go through the matrices
for (int i = (int)rvl.count(); i < (int)ChangeFileCurveList->count(); i++) {
if (ChangeFileCurveList->isSelected(i)) {
KstRMatrixPtr matrix = rml[i-rvl.count()];
matrix->writeLock();
file->readLock();
bool valid = file->isValidMatrix(matrix->field());
file->unlock();
//.........这里部分代码省略.........
示例9: applyFileChange
bool KstChangeFileDialogI::applyFileChange() {
KstDataSourcePtr file;
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(_dataFile->url());
QString invalidSources;
int invalid = 0;
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(_dataFile->url());
if (!file || !file->isValid()) {
KST::dataSourceList.lock().unlock();
KMessageBox::sorry(this, i18n("The file could not be loaded."));
return false;
}
if (file->isEmpty()) {
KST::dataSourceList.lock().unlock();
KMessageBox::sorry(this, i18n("The file does not contain data."));
return false;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().unlock();
KstApp *app = KstApp::inst();
KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
KstRMatrixList rml = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
int selected = 0;
int handled = 0;
int count = (int)ChangeFileCurveList->count();
for (int i = 0; i < count; i++) {
if (ChangeFileCurveList->isSelected(i)) {
++selected;
}
}
// a map to keep track of which objects have been duplicated, and mapping
// old object -> new object
KstDataObjectDataObjectMap duplicatedMap;
QMap<KstVectorPtr, KstVectorPtr> duplicatedVectors;
QMap<KstMatrixPtr, KstMatrixPtr> duplicatedMatrices;
KstDataSourceList oldSources;
// go through the vectors
for (int i = 0; i < (int)rvl.count(); i++) {
if (ChangeFileCurveList->isSelected(i)) {
KstRVectorPtr vector = rvl[i];
vector->writeLock();
file->readLock();
bool valid = file->isValidField(vector->field());
file->unlock();
if (!valid) {
if (invalid > 0) {
// FIXME: invalid list construction for i18n
invalidSources = i18n("%1, %2").arg(invalidSources).arg(vector->field());
} else {
invalidSources = vector->field();
}
++invalid;
} else {
if (_duplicateSelected->isChecked()) {
// block vector updates until vector is setup properly
KST::vectorList.lock().writeLock();
// create a new vector
KstRVectorPtr newVector = vector->makeDuplicate();
if (!oldSources.contains(newVector->dataSource())) {
oldSources << newVector->dataSource();
}
newVector->changeFile(file);
KST::vectorList.lock().unlock();
// duplicate dependents
if (_duplicateDependents->isChecked()) {
duplicatedVectors.insert(KstVectorPtr(vector), KstVectorPtr(newVector));
KST::duplicateDependents(KstVectorPtr(vector), duplicatedMap, duplicatedVectors);
}
} else {
if (!oldSources.contains(vector->dataSource())) {
oldSources << vector->dataSource();
}
vector->changeFile(file);
}
}
vector->unlock();
app->slotUpdateProgress(selected, ++handled, i18n("Updating vectors..."));
}
}
// go through the matrices
for (int i = (int)rvl.count(); i < (int)ChangeFileCurveList->count(); i++) {
if (ChangeFileCurveList->isSelected(i)) {
KstRMatrixPtr matrix = rml[i-rvl.count()];
matrix->writeLock();
file->readLock();
bool valid = file->isValidMatrix(matrix->field());
//.........这里部分代码省略.........
示例10: newObject
bool KstVectorDialogI::newObject() {
KstDataSourcePtr file;
QString tag_name = _tagName->text();
if (_w->_readFromSource->isChecked()) {
tag_name.replace(defaultTag, _w->Field->currentText());
tag_name = KST::suggestVectorName(tag_name);
// if there is not an active DataSource, create one
{
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(_w->FileName->url());
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(_w->FileName->url());
if (!file || !file->isValid()) {
KST::dataSourceList.lock().unlock();
KMessageBox::sorry(this, i18n("The file could not be loaded."));
return false;
}
if (file->isEmpty()) {
KST::dataSourceList.lock().unlock();
KMessageBox::sorry(this, i18n("The file does not contain data."));
return false;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().unlock();
}
file->readLock();
if (!file->isValidField(_w->Field->currentText())) {
file->unlock();
KMessageBox::sorry(this, i18n("The requested field is not defined for the requested file."));
return false;
}
int f0, n;
if (_w->_kstDataRange->isStartRelativeTime()) {
f0 = file->sampleForTime(_w->_kstDataRange->f0Value());
} else if (_w->_kstDataRange->isStartAbsoluteTime()) {
bool ok = false;
f0 = file->sampleForTime(_w->_kstDataRange->f0DateTimeValue(), &ok);
if (!ok) {
file->unlock();
KMessageBox::sorry(this, i18n("The requested field or file could not use the specified date."));
return false;
}
} else {
f0 = int(_w->_kstDataRange->f0Value());
}
if (_w->_kstDataRange->isRangeRelativeTime()) {
double nValStored = _w->_kstDataRange->nValue();
if (_w->_kstDataRange->CountFromEnd->isChecked()) {
int frameCount = file->frameCount(_w->Field->currentText());
double msCount = file->relativeTimeForSample(frameCount - 1);
n = frameCount - 1 - file->sampleForTime(msCount - nValStored);
} else {
double fTime = file->relativeTimeForSample(f0);
n = file->sampleForTime(fTime + nValStored) - file->sampleForTime(fTime);
}
} else {
n = int(_w->_kstDataRange->nValue());
}
file->unlock();
// create the vector
KstRVectorPtr vector = new KstRVector(
file, _w->Field->currentText(),
KstObjectTag(tag_name, file->tag(), false),
_w->_kstDataRange->CountFromEnd->isChecked() ? -1 : f0,
_w->_kstDataRange->ReadToEnd->isChecked() ? -1 : n,
_w->_kstDataRange->Skip->value(),
_w->_kstDataRange->DoSkip->isChecked(),
_w->_kstDataRange->DoFilter->isChecked());
emit vectorCreated(KstVectorPtr(vector));
vector = 0L;
emit modified();
} else {
double x0 = _w->_xMin->text().toDouble();
double x1 = _w->_xMax->text().toDouble();
int n = _w->_N->value();
QString tagname = _tagName->text();
if (tagname == defaultTag) {
tagname = KST::suggestVectorName(QString("(%1..%2)").arg(x0).arg(x1));
}
KstSVectorPtr svector = new KstSVector(x0, x1, n, KstObjectTag(tagname, KstObjectTag::globalTagContext));
emit vectorCreated(KstVectorPtr(svector));
svector = 0L;
emit modified();
}
return true;
}
示例11: fillFieldsForRVEdit
void KstVectorDialogI::fillFieldsForRVEdit() {
KstRVectorPtr rvp = kst_cast<KstRVector>(_dp);
rvp->readLock();
_w->_readFromSource->setChecked(true);
_w->_rvectorGroup->show();
_w->_kstDataRange->show();
_w->_kstDataRange->setEnabled(true);
_w->_svectorGroup->hide();
_w->_svectorGroup->setEnabled(false);
_w->sourceGroup->hide();
_tagName->setText(rvp->tagName());
_w->Field->clear();
if (_fieldCompletion) {
_fieldCompletion->clear();
}
{
KstDataSourcePtr tf;
KST::dataSourceList.lock().readLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(rvp->filename());
if (it != KST::dataSourceList.end()) {
tf = *it;
tf->readLock();
_w->Field->insertStringList(tf->fieldList());
if (_fieldCompletion) {
_fieldCompletion->insertItems(tf->fieldList());
}
tf->unlock();
} else {
QStringList list = KstDataSource::fieldListForSource(_w->FileName->url());
_w->Field->insertStringList(list);
if (_fieldCompletion) {
_fieldCompletion->insertItems(list);
}
}
KST::dataSourceList.lock().unlock();
}
_w->Field->setEnabled(_w->Field->count() > 0);
_ok->setEnabled(_w->Field->isEnabled());
_w->Field->setCurrentText(rvp->field());
// select the proper file
_w->FileName->setURL(rvp->filename());
// fill the vector range entries
_w->_kstDataRange->CountFromEnd->setChecked(rvp->countFromEOF());
_w->_kstDataRange->setF0Value(rvp->reqStartFrame());
// fill number of frames entries
_w->_kstDataRange->ReadToEnd->setChecked(rvp->readToEOF());
_w->_kstDataRange->setNValue(rvp->reqNumFrames());
// fill in frames to skip box
_w->_kstDataRange->Skip->setValue(rvp->skip());
_w->_kstDataRange->DoSkip->setChecked(rvp->doSkip());
_w->_kstDataRange->DoFilter->setChecked(rvp->doAve());
_w->_kstDataRange->updateEnables();
rvp->unlock();
}
示例12: updateCompletion
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);
}
示例13: new_I
bool KstVectorDialogI::new_I() {
KstDataSourcePtr file;
KstRVectorList vectorList = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
QString tag_name = _tagName->text();
tag_name.replace("<New_Vector>", Field->currentText());
KST::vectorList.lock().readLock();
int i_c = KST::vectorList.count() + 1;
KST::vectorList.lock().readUnlock();
while (KST::vectorTagNameNotUnique(tag_name, false)) {
tag_name.sprintf("V%d-", i_c);
tag_name += Field->currentText();
i_c++;
}
vectorList.clear();
/* if there is not an active DataSource, create one */
{
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findFileName(FileName->url());
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(FileName->url());
if (!file || !file->isValid()) {
KST::dataSourceList.lock().writeUnlock();
KMessageBox::sorry(this, i18n("The file could not be loaded."));
return false;
}
if (file->isEmpty()) {
KST::dataSourceList.lock().writeUnlock();
KMessageBox::sorry(this, i18n("The file does not contain data."));
return false;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().writeUnlock();
}
file->readLock();
if (!file->isValidField(Field->currentText())) {
file->readUnlock();
KMessageBox::sorry(this, i18n("The requested field is not defined for the requested file."));
return false;
}
file->readUnlock();
int f0, n;
if (_kstDataRange->isTime()) {
file->readLock();
f0 = file->sampleForTime(_kstDataRange->f0Value());
n = file->sampleForTime(_kstDataRange->nValue());
file->readUnlock();
} else {
f0 = _kstDataRange->f0Value();
n = _kstDataRange->nValue();
}
/* create the vector */
KstRVectorPtr vector = new KstRVector(
file, Field->currentText(),
tag_name,
(_kstDataRange->CountFromEnd->isChecked() ? -1 : f0),
(_kstDataRange->ReadToEnd->isChecked() ? -1 : n),
_kstDataRange->Skip->value(),
_kstDataRange->DoSkip->isChecked(),
_kstDataRange->DoFilter->isChecked());
KST::addVectorToList(KstVectorPtr(vector));
emit vectorCreated(KstVectorPtr(vector));
vector = 0L;
emit modified();
return true;
}
示例14: edit_I
bool KstVectorDialogI::edit_I() {
KstDataSourcePtr file;
KstRVectorList vectorList = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
/* verify that the vector name is unique */
DP->readLock();
if (_tagName->text() != DP->tagName() && KST::vectorTagNameNotUnique(_tagName->text())) {
DP->readUnlock();
return false;
}
DP->readUnlock();
/* if there is not an active KstFile, create one */
{
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it =
KST::dataSourceList.findFileName(FileName->url());
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(FileName->url());
if (!file || !file->isValid()) {
KST::dataSourceList.lock().writeUnlock();
KMessageBox::sorry(this, i18n("The file could not be opened."));
return false;
}
if (file->isEmpty()) {
KST::dataSourceList.lock().writeUnlock();
KMessageBox::sorry(this, i18n("The file does not contain data."));
return false;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().writeUnlock();
}
file->readLock();
if (!file->isValidField(Field->currentText())) {
file->readUnlock();
KMessageBox::sorry(this, i18n("The requested field is not defined for "
"the requested file\n"));
return false;
}
file->readUnlock();
int f0, n;
if (_kstDataRange->isTime()) {
file->readLock();
f0 = file->sampleForTime(_kstDataRange->f0Value());
n = file->sampleForTime(_kstDataRange->nValue());
file->readUnlock();
} else {
f0 = _kstDataRange->f0Value();
n = _kstDataRange->nValue();
}
/* change the vector */
DP->writeLock();
DP->change(file, Field->currentText(),
_tagName->text(),
(_kstDataRange->CountFromEnd->isChecked() ? -1 : f0),
(_kstDataRange->ReadToEnd->isChecked() ? -1 : n),
_kstDataRange->Skip->value(),
_kstDataRange->DoSkip->isChecked(),
_kstDataRange->DoFilter->isChecked());
DP->writeUnlock();
vectorList.clear();
emit modified();
return true;
}
示例15: fillFieldsForRMatrixEdit
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();
}
}