本文整理汇总了C++中KstRMatrixPtr::changeFile方法的典型用法代码示例。如果您正苦于以下问题:C++ KstRMatrixPtr::changeFile方法的具体用法?C++ KstRMatrixPtr::changeFile怎么用?C++ KstRMatrixPtr::changeFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KstRMatrixPtr
的用法示例。
在下文中一共展示了KstRMatrixPtr::changeFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
//.........这里部分代码省略.........
示例2: 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());
//.........这里部分代码省略.........