本文整理汇总了C++中KstDataSourcePtr类的典型用法代码示例。如果您正苦于以下问题:C++ KstDataSourcePtr类的具体用法?C++ KstDataSourcePtr怎么用?C++ KstDataSourcePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KstDataSourcePtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
KJS::Value KstBindDataSource::frameCount(KJS::ExecState *exec, const KJS::List& args) {
QString field;
if (args.size() == 1) {
if (args[0].type() != KJS::StringType) {
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
exec->setException(eobj);
return KJS::Number(0);
}
field = args[0].toString(exec).qstring();
} else if (args.size() != 0) {
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires at most one argument.");
exec->setException(eobj);
return KJS::Number(0);
}
KstDataSourcePtr s = makeSource(_d);
if (!s) {
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
return KJS::Number(0);
}
s->writeLock();
int rc = s->frameCount(field);
s->unlock();
return KJS::Number(rc);
}
示例2: configureSource
void KstVectorDialogI::configureSource() {
bool isNew = false;
KST::dataSourceList.lock().readLock();
KstDataSourcePtr ds = *KST::dataSourceList.findReusableFileName(_w->FileName->url());
KST::dataSourceList.lock().unlock();
if (!ds) {
isNew = true;
ds = KstDataSource::loadSource(_w->FileName->url());
if (!ds || !ds->isValid()) {
_w->_configure->setEnabled(false);
return;
}
}
assert(_configWidget);
KDialogBase *dlg = new KDialogBase(this, "Data Config Dialog", true, i18n("Configure Data Source"));
if (isNew) {
connect(dlg, SIGNAL(okClicked()), _configWidget, SLOT(save()));
connect(dlg, SIGNAL(applyClicked()), _configWidget, SLOT(save()));
} else {
connect(dlg, SIGNAL(okClicked()), this, SLOT(markSourceAndSave()));
connect(dlg, SIGNAL(applyClicked()), this, SLOT(markSourceAndSave()));
}
_configWidget->reparent(dlg, QPoint(0, 0));
dlg->setMainWidget(_configWidget);
_configWidget->setInstance(ds);
_configWidget->load();
dlg->exec();
_configWidget->reparent(0L, QPoint(0, 0));
dlg->setMainWidget(0L);
delete dlg;
updateCompletion(); // could be smarter by only running if Ok/Apply clicked
}
示例3: makeSource
KJS::Value KstBindDataSource::isValidField(KJS::ExecState *exec, const KJS::List& args) {
if (args.size() != 1) {
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly one argument.");
exec->setException(eobj);
return KJS::Boolean(false);
}
if (args[0].type() != KJS::StringType) {
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
exec->setException(eobj);
return KJS::Boolean(false);
}
KstDataSourcePtr s = makeSource(_d);
if (!s) {
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
return KJS::Boolean(false);
}
s->writeLock();
bool rc = s->isValidField(args[0].toString(exec).qstring());
s->unlock();
return KJS::Boolean(rc);
}
示例4: lastUpdateResult
KstObject::UpdateType IndirectSource::update(int u) {
if (KstObject::checkUpdateCounter(u)) {
return lastUpdateResult();
}
// recheck the indirect file for a changed filename
QFile f(_filename);
if (f.open(QIODevice::ReadOnly)) {
char* data;
if (0 < f.readLine(data,1000)) {
QString ifn(data);
KUrl url(ifn);
if (url.isLocalFile() || url.protocol().isEmpty()) {
if (QFileInfo(ifn).isRelative()) {
ifn = QFileInfo(_filename).absolutePath() + QDir::separator() + ifn;
}
}
if (!_child || ifn.trimmed() != _child->fileName()) {
_child = 0L; // release
KstDataSourcePtr p = KstDataSource::loadSource(ifn.trimmed());
if (p) {
_child = p;
_fieldList = p->fieldList();
_valid = true;
} else {
_valid = false;
}
}
}
}
return setLastUpdateResult(_child ? _child->update(u) : KstObject::NO_CHANGE);
}
示例5: assert
void KstVectorDialogI::markSourceAndSave() {
assert(_configWidget);
KstDataSourcePtr src = static_cast<KstDataSourceConfigWidget*>((QWidget*)_configWidget)->instance();
if (src) {
src->disableReuse();
}
static_cast<KstDataSourceConfigWidget*>((QWidget*)_configWidget)->save();
}
示例6: Q_UNUSED
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);
}
示例7: new_I
void KstVectorDialogI::new_I() {
KstDataSourcePtr file;
KstRVectorPtr vector;
KstRVectorList vectorList = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
QString tag_name = Select->currentText();
tag_name.replace(i18n("<New_Vector>"), Field->currentText());
KST::vectorList.lock().readLock();
int i_c = KST::vectorList.count() + 1;
KST::vectorList.lock().readUnlock();
while (KST::dataTagNameNotUnique(tag_name, false)) {
tag_name.sprintf("V%d-", i_c);
tag_name += Field->currentText();
i_c++;
}
/* 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()) {
KMessageBox::sorry(0L, i18n("The file could not be loaded."));
return;
}
if (file->frameCount() < 1) {
KMessageBox::sorry(0L, i18n("The file does not contain data."));
return;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().writeUnlock();
}
if (!file->isValidField(Field->currentText())) {
KMessageBox::sorry(0L, i18n("The requested field is not defined for the requested file."));
return;
}
/* create the vector */
vector = new KstRVector(file, Field->currentText(),
tag_name,
(CountFromEnd->isChecked() ? -1 : F0->value()),
(ReadToEnd->isChecked() ? -1 : N->value()),
Skip->value(),
DoSkip->isChecked(),
DoFilter->isChecked());
emit vectorCreated(KstVectorPtr(vector));
vector = 0L;
vectorList.clear();
emit modified();
}
示例8: markSourceAndSave
void KstChangeFileDialog::markSourceAndSave()
{
if (_configWidget) {
KstDataSourcePtr src = static_cast<KstDataSourceConfigWidget*>((QWidget*)_configWidget)->instance();
if (src) {
src->disableReuse();
}
static_cast<KstDataSourceConfigWidget*>((QWidget*)_configWidget)->save();
}
}
示例9: array
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;
}
示例10: array
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;
}
示例11: 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);
}
}
示例12: configureSource
void KstMatrixDialog::configureSource() {
KstDataSourcePtr ds;
bool isNew = false;
KST::dataSourceList.lock().readLock();
// xxx ds = *KST::dataSourceList.findReusableFileName(_w->_fileName->url());
KST::dataSourceList.lock().unlock();
if (!ds) {
isNew = true;
// xxx ds = KstDataSource::loadSource(_w->_fileName->url());
if (!ds || !ds->isValid()) {
_w->_configure->setEnabled(false);
return;
}
}
if (_configWidget) {
QDialog *dlg;
dlg = new QDialog(this);
dlg->setWindowTitle(QObject::tr("Configure Data Source"));
if (isNew) {
connect(dlg, SIGNAL(okClicked()), _configWidget, SLOT(save()));
connect(dlg, SIGNAL(applyClicked()), _configWidget, SLOT(save()));
} else {
connect(dlg, SIGNAL(okClicked()), this, SLOT(markSourceAndSave()));
connect(dlg, SIGNAL(applyClicked()), this, SLOT(markSourceAndSave()));
}
_configWidget->setParent(dlg);
// xxx dlg->setMainWidget(_configWidget);
_configWidget->setInstance(ds);
_configWidget->load();
dlg->exec();
// xxx _configWidget->reparent(0L, QPoint(0, 0));
// xxx dlg->setMainWidget(0L);
delete dlg;
}
updateCompletion(); // could be smarter by only running if Ok/Apply clicked
}
示例13: loadMatrix
QString KstIfaceImpl::loadMatrix(const QString& name, const QString& file, const QString& field,
int xStart, int yStart, int xNumSteps, int yNumSteps,
int skipFrames, bool boxcarFilter) {
KstDataSourcePtr src;
/* generate or find the kstfile */
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(file);
if (it == KST::dataSourceList.end()) {
src = KstDataSource::loadSource(file);
if (!src || !src->isValid()) {
KST::dataSourceList.lock().unlock();
return QString::null;
}
if (src->isEmpty()) {
KST::dataSourceList.lock().unlock();
return QString::null;
}
KST::dataSourceList.append(src);
} else {
src = *it;
}
src->writeLock();
KST::dataSourceList.lock().unlock();
// make sure field is valid
if (!src->isValidMatrix(field)) {
src->unlock();
return QString::null;
}
// make sure name is unique, else generate a unique one
KST::matrixList.lock().readLock();
QString matrixName;
if (name.isEmpty()) {
matrixName = "M" + QString::number(KST::matrixList.count() + 1);
} else {
matrixName = name;
}
while (KstData::self()->matrixTagNameNotUnique(matrixName, false)) {
matrixName = "M" + QString::number(KST::matrixList.count() + 1);
}
KST::matrixList.lock().unlock();
KstMatrixPtr p = new KstRMatrix(src, field, matrixName, xStart, yStart, xNumSteps, yNumSteps,
boxcarFilter, skipFrames > 0, skipFrames);
KST::addMatrixToList(p);
src->unlock();
if (p) {
_doc->forceUpdate();
_doc->setModified();
return p->tagName();
}
return QString::null;
}
示例14: KstDataSource
IndirectSource::IndirectSource(QSettings *cfg, const QString& filename, KstDataSourcePtr child)
: KstDataSource(cfg, filename, QString::null), _child(child) {
if (child) {
_valid = true;
_fieldList = child->fieldList();
} else {
_valid = false;
}
}
示例15: while
const QString& KstIfaceImpl::loadVector(const QString& file, const QString& field) {
KstDataSourcePtr src;
/* generate or find the kstfile */
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(file);
if (it == KST::dataSourceList.end()) {
src = KstDataSource::loadSource(file);
if (!src || !src->isValid()) {
KST::dataSourceList.lock().unlock();
return QString::null;
}
if (src->isEmpty()) {
KST::dataSourceList.lock().unlock();
return QString::null;
}
KST::dataSourceList.append(src);
} else {
src = *it;
}
src->writeLock();
KST::dataSourceList.lock().unlock();
KST::vectorList.lock().readLock();
QString vname = "V" + QString::number(KST::vectorList.count() + 1);
while (KstData::self()->vectorTagNameNotUnique(vname, false)) {
vname = "V" + QString::number(KST::vectorList.count() + 1);
}
KST::vectorList.lock().unlock();
KstVectorPtr p = new KstRVector(src, field, vname, 0, -1, 0, false, false);
KST::addVectorToList(p);
src->unlock();
if (p) {
_doc->forceUpdate();
_doc->setModified();
return p->tagName();
}
return QString::null;
}