本文整理汇总了C++中KstStringPtr::readLock方法的典型用法代码示例。如果您正苦于以下问题:C++ KstStringPtr::readLock方法的具体用法?C++ KstStringPtr::readLock怎么用?C++ KstStringPtr::readLock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KstStringPtr
的用法示例。
在下文中一共展示了KstStringPtr::readLock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateEntries
void KstPluginDialogI::generateEntries(bool input, int& cnt, QWidget *parent, QGridLayout *grid, const QValueList<Plugin::Data::IOValue>& table) {
QString scalarLabelTemplate, vectorLabelTemplate, stringLabelTemplate;
if (input) {
stringLabelTemplate = i18n("Input string - %1:");
scalarLabelTemplate = i18n("Input scalar - %1:");
vectorLabelTemplate = i18n("Input vector - %1:");
} else {
stringLabelTemplate = i18n("Output string - %1:");
scalarLabelTemplate = i18n("Output scalar - %1:");
vectorLabelTemplate = i18n("Output vector - %1:");
}
for (QValueList<Plugin::Data::IOValue>::ConstIterator it = table.begin(); it != table.end(); ++it) {
QString labellabel;
bool scalar = false;
bool string = false;
switch ((*it)._type) {
case Plugin::Data::IOValue::PidType:
continue;
case Plugin::Data::IOValue::StringType:
labellabel = stringLabelTemplate.arg((*it)._name);
string = true;
break;
case Plugin::Data::IOValue::FloatType:
labellabel = scalarLabelTemplate.arg((*it)._name);
scalar = true;
break;
case Plugin::Data::IOValue::TableType:
if ((*it)._subType == Plugin::Data::IOValue::FloatSubType ||
(*it)._subType == Plugin::Data::IOValue::FloatNonVectorSubType) {
labellabel = vectorLabelTemplate.arg((*it)._name);
} else {
// unsupported
continue;
}
break;
default:
// unsupported
continue;
}
QLabel *label = new QLabel(labellabel, parent, input ? "Input label" : "Output label");
QWidget *widget = 0L;
if (input) {
if (scalar) {
ScalarSelector *w = new ScalarSelector(parent, (*it)._name.latin1());
widget = w;
connect(w->_scalar, SIGNAL(activated(const QString&)), this, SLOT(updateScalarTooltip(const QString&)));
connect(widget, SIGNAL(newScalarCreated()), this, SIGNAL(modified()));
if (!(*it)._default.isEmpty()) {
w->_scalar->insertItem((*it)._default);
w->_scalar->setCurrentText((*it)._default);
}
KstScalarPtr p = *KST::scalarList.findTag(w->_scalar->currentText());
w->allowDirectEntry(true);
if (p) {
p->readLock();
QToolTip::remove(w->_scalar);
QToolTip::add(w->_scalar, QString::number(p->value()));
p->unlock();
}
} else if (string) {
StringSelector *w = new StringSelector(parent, (*it)._name.latin1());
widget = w;
connect(w->_string, SIGNAL(activated(const QString&)), this, SLOT(updateStringTooltip(const QString&)));
connect(widget, SIGNAL(newStringCreated()), this, SIGNAL(modified()));
if (!(*it)._default.isEmpty()) {
w->_string->insertItem((*it)._default);
w->_string->setCurrentText((*it)._default);
}
KstStringPtr p = *KST::stringList.findTag(w->_string->currentText());
w->allowDirectEntry(true);
if (p) {
p->readLock();
QToolTip::remove(w->_string);
QToolTip::add(w->_string, p->value());
p->unlock();
}
} else {
widget = new VectorSelector(parent, (*it)._name.latin1());
connect(widget, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified()));
}
} else {
示例2: renderLabel
void renderLabel(RenderContext& rc, Label::Chunk *fi) {
// FIXME: RTL support
int oldSize = rc.size;
int oldY = rc.y;
int oldX = rc.x;
while (fi) {
if (fi->vOffset != Label::Chunk::None) {
if (fi->vOffset == Label::Chunk::Up) {
rc.y -= int(0.4 * rc.fontHeight());
} else { // Down
rc.y += int(0.4 * rc.fontHeight());
}
if (rc.size > 5) {
rc.size = (rc.size*2)/3;
}
}
QFont f = rc.font();
if (rc.fontSize() != rc.size) {
f.setPointSize(rc.size);
}
f.setBold(fi->attributes.bold);
f.setItalic(fi->attributes.italic);
f.setUnderline(fi->attributes.underline);
if (rc.p && fi->attributes.color.isValid()) {
rc.p->setPen(fi->attributes.color);
} else if (rc.p) {
rc.p->setPen(rc.pen);
}
rc.setFont(f);
if (fi->linebreak) {
rc.x = oldX;
rc.y += rc.fontAscent() + rc.fontDescent() + 1;
fi = fi->next;
continue;
}
if (!rc.substitute && (fi->scalar || fi->vector)) {
QString txt = QString("[") + fi->text + "]";
if (rc.p) {
rc.p->drawText(rc.x, rc.y, txt);
}
rc.x += rc.fontWidth(txt);
} else if (fi->scalar) {
// do scalar/string/fit substitution
QString txt;
if (!fi->text.isEmpty() && fi->text[0] == '=') {
// Parse and evaluate as an equation
bool ok = false;
const double eqResult(Equation::interpret(fi->text.mid(1).latin1(), &ok));
txt = QString::number(eqResult, 'g', rc.precision);
if (rc._cache) {
rc._cache->append(DataRef(DataRef::DRExpression, fi->text, QString::null, 0.0, QVariant(eqResult)));
}
} else {
KST::scalarList.lock().readLock();
KstScalarPtr scp = *KST::scalarList.findTag(fi->text);
KST::scalarList.lock().unlock();
if (scp) {
scp->readLock();
txt = QString::number(scp->value(), 'g', rc.precision);
if (rc._cache) {
rc._cache->append(DataRef(DataRef::DRScalar, fi->text, QString::null, 0.0, QVariant(scp->value())));
}
scp->unlock();
} else {
KST::stringList.lock().readLock();
KstStringPtr stp = *KST::stringList.findTag(fi->text);
KST::stringList.lock().unlock();
if (stp) {
stp->readLock();
txt = stp->value();
if (rc._cache) {
rc._cache->append(DataRef(DataRef::DRString, fi->text, QString::null, 0.0, QVariant(stp->value())));
}
stp->unlock();
} else {
KST::dataObjectList.lock().readLock();
KstDataObjectList::Iterator oi = KST::dataObjectList.findTag(fi->text);
KST::dataObjectList.lock().unlock();
if (oi != KST::dataObjectList.end()) {
KstPluginPtr fit = kst_cast<KstPlugin>(*oi);
if (fit) {
fit->readLock();
const QString txtAll = fit->label(rc.precision);
fit->unlock();
const QValueList<QString> strList = QStringList::split('\n', txtAll);
QValueListConstIterator<QString> last = --(strList.end());
for (QValueListConstIterator<QString> iter = strList.begin(); iter != strList.end(); ++iter) {
txt = (*iter);
if (iter != last) {
if (rc.p) {
rc.p->drawText(rc.x, rc.y, txt);
} else {
rc.ascent = kMax(rc.ascent, -rc.y + rc.fontAscent());
//.........这里部分代码省略.........
示例3: switch
void KstViewLabel::DataCache::update() {
for (QValueVector<DataRef>::ConstIterator i = data.begin(); valid && i != data.end(); ++i) {
switch ((*i).type) {
case DataRef::DataRef::DRScalar:
{
KST::scalarList.lock().readLock();
KstScalarPtr p = *KST::scalarList.findTag((*i).name);
KST::scalarList.lock().unlock();
if (p) {
p->readLock();
if (QVariant(p->value()) != (*i).value) {
valid = false;
}
p->unlock();
}
}
break;
case DataRef::DRString:
{
KST::stringList.lock().readLock();
KstStringPtr p = *KST::stringList.findTag((*i).name);
KST::stringList.lock().unlock();
if (p) {
p->readLock();
if (QVariant(p->value()) != (*i).value) {
valid = false;
}
p->unlock();
}
}
break;
case DataRef::DRExpression:
{
bool ok = false;
const double val = Equation::interpret((*i).name.latin1(), &ok, (*i).name.length());
if (QVariant(val) != (*i).value) {
valid = false;
}
}
break;
case DataRef::DRVector:
{
bool ok = false;
const double idx = Equation::interpret((*i).index.latin1(), &ok, (*i).index.length());
if (idx != (*i).indexValue) {
valid = false;
break;
}
KST::vectorList.lock().readLock();
KstVectorPtr p = *KST::vectorList.findTag((*i).name);
KST::vectorList.lock().unlock();
if (p) {
p->readLock();
if (QVariant(p->value(int((*i).indexValue))) != (*i).value) {
valid = false;
}
p->unlock();
}
}
break;
case DataRef::DataRef::DRFit:
{
KST::dataObjectList.lock().readLock();
KstDataObjectList::Iterator oi = KST::dataObjectList.findTag((*i).name);
KST::dataObjectList.lock().unlock();
if (oi != KST::dataObjectList.end()) {
KstCPluginPtr fit = kst_cast<KstCPlugin>(*oi);
if (fit) {
fit->readLock();
if (fit->label((int)((*i).indexValue)) != (*i).index) {
valid = false;
}
fit->unlock();
}
}
}
break;
}
}
}