本文整理汇总了C++中QList::at方法的典型用法代码示例。如果您正苦于以下问题:C++ QList::at方法的具体用法?C++ QList::at怎么用?C++ QList::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QList
的用法示例。
在下文中一共展示了QList::at方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: col
QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* parent )
: QWidget( parent )
{
mLayer = layer;
if ( !layer )
{
return;
}
setupUi( this );
mBackgroundColorButton->setColorDialogTitle( tr( "Background color" ) );
mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mDiagramPenColorButton->setColorDialogTitle( tr( "Pen color" ) );
mDiagramPenColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mValueLineEdit->setValidator( new QDoubleValidator( mValueLineEdit ) );
mMinimumDiagramScaleLineEdit->setValidator( new QDoubleValidator( mMinimumDiagramScaleLineEdit ) );
mMaximumDiagramScaleLineEdit->setValidator( new QDoubleValidator( mMaximumDiagramScaleLineEdit ) );
mDiagramUnitComboBox->insertItem( 0, tr( "mm" ), QgsDiagramSettings::MM );
mDiagramUnitComboBox->insertItem( 1, tr( "Map units" ), QgsDiagramSettings::MapUnits );
QGis::GeometryType layerType = layer->geometryType();
if ( layerType == QGis::UnknownGeometry || layerType == QGis::NoGeometry )
{
mDisplayDiagramsGroupBox->setChecked( false );
mDisplayDiagramsGroupBox->setEnabled( false );
}
//insert placement options
if ( layerType == QGis::Point || layerType == QGis::Polygon )
{
mPlacementComboBox->addItem( tr( "Around Point" ), QgsDiagramLayerSettings::AroundPoint );
mPlacementComboBox->addItem( tr( "Over Point" ), QgsDiagramLayerSettings::OverPoint );
}
if ( layerType == QGis::Line || layerType == QGis::Polygon )
{
mPlacementComboBox->addItem( tr( "Line" ), QgsDiagramLayerSettings::Line );
mPlacementComboBox->addItem( tr( "Horizontal" ), QgsDiagramLayerSettings::Horizontal );
}
if ( layerType == QGis::Polygon )
{
mPlacementComboBox->addItem( tr( "Free" ), QgsDiagramLayerSettings::Free );
}
if ( layerType == QGis::Line )
{
mLineOptionsComboBox->addItem( tr( "On line" ), QgsDiagramLayerSettings::OnLine );
mLineOptionsComboBox->addItem( tr( "Above line" ), QgsDiagramLayerSettings::AboveLine );
mLineOptionsComboBox->addItem( tr( "Below Line" ), QgsDiagramLayerSettings::BelowLine );
mLineOptionsComboBox->addItem( tr( "Map orientation" ), QgsDiagramLayerSettings::MapOrientation );
}
else
{
mLineOptionsComboBox->setVisible( false );
mLineOptionsLabel->setVisible( false );
}
QPixmap pix = QgsApplication::getThemePixmap( "pie-chart" );
mDiagramTypeComboBox->addItem( pix, tr( "Pie chart" ), DIAGRAM_NAME_PIE );
pix = QgsApplication::getThemePixmap( "text" );
mDiagramTypeComboBox->addItem( pix, tr( "Text diagram" ), DIAGRAM_NAME_TEXT );
pix = QgsApplication::getThemePixmap( "histogram" );
mDiagramTypeComboBox->addItem( pix, tr( "Histogram" ), DIAGRAM_NAME_HISTOGRAM );
mLabelPlacementComboBox->addItem( tr( "Height" ), QgsDiagramSettings::Height );
mLabelPlacementComboBox->addItem( tr( "x-height" ), QgsDiagramSettings::XHeight );
mScaleDependencyComboBox->addItem( tr( "Area" ), true );
mScaleDependencyComboBox->addItem( tr( "Diameter" ), false );
mDataDefinedXComboBox->addItem( tr( "None" ), -1 );
mDataDefinedYComboBox->addItem( tr( "None" ), -1 );
//insert all attributes into the combo boxes
const QgsFields& layerFields = layer->pendingFields();
for ( int idx = 0; idx < layerFields.count(); ++idx )
{
QTreeWidgetItem *newItem = new QTreeWidgetItem( mAttributesTreeWidget );
newItem->setText( 0, layerFields[idx].name() );
newItem->setData( 0, Qt::UserRole, idx );
newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );
if ( layerFields[idx].type() != QVariant::String )
{
mSizeAttributeComboBox->addItem( layerFields[idx].name(), idx );
}
mDataDefinedXComboBox->addItem( layerFields[idx].name(), idx );
mDataDefinedYComboBox->addItem( layerFields[idx].name(), idx );
}
const QgsDiagramRendererV2* dr = layer->diagramRenderer();
if ( !dr ) //no diagram renderer yet, insert reasonable default
{
//.........这里部分代码省略.........
示例2:
QList<Nepomuk2::Query::Term> PassDateValues::run(const QList<Nepomuk2::Query::Term> &match) const
{
QList<Nepomuk2::Query::Term> rs;
bool valid_input = true;
bool progress = false;
static const PassDatePeriods::Period periods[7] = {
PassDatePeriods::Year, PassDatePeriods::Month, PassDatePeriods::Day,
PassDatePeriods::DayOfWeek, PassDatePeriods::Hour, PassDatePeriods::Minute,
PassDatePeriods::Second
};
// Conservative minimum values (not every calendar already reached year 2000+)
static const int min_values[7] = {
0 /* Y */, 1 /* M */, 1 /* D */, 1 /* DW */, 0 /* H */, 0 /* M */, 0 /* S */
};
// Conservative maximum values (some calendars may have months of 100+ days)
static const int max_values[7] = {
1<<30 /* Y */, 60 /* M */, 500 /* D */, 7 /* DW */, 24 /* H */, 60 /* M */, 60 /* S */
};
// See if a match sets a value for any period
for (int i=0; i<7; ++i) {
PassDatePeriods::Period period = periods[i];
if (i < match.count() && match.at(i).isValid()) {
const Nepomuk2::Query::Term &term = match.at(i);
int value;
if (!termIntValue(term, value)) {
// The term is not a literal integer, but may be a typed comparison
// (month or day names)
if (!term.isComparisonTerm()) {
valid_input = false;
break;
}
Nepomuk2::Query::ComparisonTerm comparison = term.toComparisonTerm();
if (comparison.property().uri() != PassDatePeriods::propertyUrl(period, false)) {
valid_input = false;
break;
}
// Keep the comparison, it is already good. No need to extract
// its value only to build a new comparison exactly the same.
rs.append(comparison);
continue;
}
if (value < min_values[i] || value > max_values[i]) {
valid_input = false;
break;
}
if (period == PassDatePeriods::Hour && pm) {
value += 12;
}
// Build a comparison of the right type
Nepomuk2::Query::LiteralTerm value_term(value);
progress = true;
value_term.setPosition(term);
rs.append(Nepomuk2::Query::ComparisonTerm(
PassDatePeriods::propertyUrl(period, false),
value_term,
Nepomuk2::Query::ComparisonTerm::Equal
));
rs.last().setPosition(term);
}
}
if (!valid_input || !progress) {
rs.clear();
}
return rs;
}
示例3: parseIconCommands
void StereotypeDefinitionParser::parseIconCommands(StereotypeIcon *stereotypeIcon)
{
Token token;
bool loop = true;
IconShape iconShape;
QList<ShapeValueF> parameters;
typedef QList<IconCommandParameter> Parameters;
static const IconCommandParameter SCALED(ShapeValueF::UnitScaled);
static const IconCommandParameter FIX(ShapeValueF::UnitRelative);
static const IconCommandParameter ABSOLUTE(ShapeValueF::UnitAbsolute);
while (loop) {
token = readNextToken();
if (token.type() != Token::TokenKeyword) {
loop = false;
} else {
switch (token.subtype()) {
case KEYWORD_CIRCLE:
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED);
iconShape.addCircle(ShapePointF(parameters.at(0), parameters.at(1)), parameters.at(2));
expectSemicolonOrEndOfLine();
break;
case KEYWORD_ELLIPSE:
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
iconShape.addEllipse(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)));
expectSemicolonOrEndOfLine();
break;
case KEYWORD_LINE:
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
iconShape.addLine(ShapePointF(parameters.at(0), parameters.at(1)),
ShapePointF(parameters.at(2), parameters.at(3)));
expectSemicolonOrEndOfLine();
break;
case KEYWORD_RECT:
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
iconShape.addRect(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)));
expectSemicolonOrEndOfLine();
break;
case KEYWORD_ROUNDEDRECT:
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << FIX);
iconShape.addRoundedRect(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)), parameters.at(4));
expectSemicolonOrEndOfLine();
break;
case KEYWORD_ARC:
{
parameters = parseIconCommandParameters(
Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE << ABSOLUTE);
qreal startAngle = expectAbsoluteValue(parameters.at(4), d->m_scanner->sourcePos());
qreal spanAngle = expectAbsoluteValue(parameters.at(5), d->m_scanner->sourcePos());
iconShape.addArc(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)), startAngle, spanAngle);
expectSemicolonOrEndOfLine();
break;
}
case KEYWORD_MOVETO:
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED);
iconShape.moveTo(ShapePointF(parameters.at(0), parameters.at(1)));
expectSemicolonOrEndOfLine();
break;
case KEYWORD_LINETO:
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED);
iconShape.lineTo(ShapePointF(parameters.at(0), parameters.at(1)));
expectSemicolonOrEndOfLine();
break;
case KEYWORD_ARCMOVETO:
{
parameters = parseIconCommandParameters(
Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE);
qreal angle = expectAbsoluteValue(parameters.at(4), d->m_scanner->sourcePos());
iconShape.arcMoveTo(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)), angle);
expectSemicolonOrEndOfLine();
break;
}
case KEYWORD_ARCTO:
{
parameters = parseIconCommandParameters(
Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE << ABSOLUTE);
qreal startAngle = expectAbsoluteValue(parameters.at(4), d->m_scanner->sourcePos());
qreal sweepLength = expectAbsoluteValue(parameters.at(5), d->m_scanner->sourcePos());
iconShape.arcTo(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)), startAngle, sweepLength);
expectSemicolonOrEndOfLine();
break;
}
case KEYWORD_CLOSE:
iconShape.closePath();
expectSemicolonOrEndOfLine();
break;
default:
loop = false;
break;
}
}
}
stereotypeIcon->setIconShape(iconShape);
//.........这里部分代码省略.........
示例4: SetNodeColorStyle
void VisualClusterTree::SetNodeColorStyle(const QString& style, const QColor& color)
{
Log::Inst().Debug("VisualClusterTree::SetNodeColorStyle(...)");
if(!m_activeSystem || !m_tree)
return;
if(style == "Single colour")
{
m_nodeColorStyle = VisualNode::SINGLE_COLOR;
SetNodeColor(color);
return;
}
else if(style == "Propogate continuous")
m_nodeColorStyle = VisualNode::PROPOGATE_CONTINUOUS_COLOR;
else if(style == "Propogate weighted")
m_nodeColorStyle = VisualNode::PROPOGATE_WEIGHTED_COLOR;
else if(style == "Propogate discrete")
m_nodeColorStyle = VisualNode::PROPOGATE_DISCRETE_COLOR;
// set node colors
QList<VisualNode*> postOrderNodes = m_tree->PostOrder();
if(postOrderNodes.size() == 1)
return; // there is only a root node
foreach(VisualNode* node, postOrderNodes)
{
QColor nodeColor;
if(node->IsLeaf())
{
// set color of node based on legend
Sample sample;
if(!m_activeSystem->GetSamples()->GetSample(node->GetName(), sample))
Log::Inst().Error("Invalid sample specified setting node colour: " + node->GetName());
nodeColor = sample.GetColor();
}
else
{
// set color of node based on color of children
QList<VisualNode*> children = node->GetChildren();
if(m_nodeColorStyle == VisualNode::PROPOGATE_DISCRETE_COLOR)
{
nodeColor = children.at(0)->GetColor();
for(int j = 0; j < children.size(); ++j)
{
if(children.at(j)->GetColor() != nodeColor)
nodeColor = Qt::black;
}
}
else if(m_nodeColorStyle == VisualNode::PROPOGATE_CONTINUOUS_COLOR)
{
float red = 0.0f, green = 0.0f, blue = 0.0f;
for(int j = 0; j < children.size(); ++j)
{
QColor color = children.at(j)->GetColor();
red += color.redF();
green += color.greenF();
blue += color.blueF();
}
nodeColor.setRedF(red / children.size());
nodeColor.setGreenF(green / children.size());
nodeColor.setBlueF(blue / children.size());
}
else // m_nodeColorStyle == VisualNode::PROPOGATE_WEIGHTED_COLOR
{
float red = 0.0f, green = 0.0f, blue = 0.0f;
uint totalWeight = 0;
for(int j = 0; j < children.size(); ++j)
{
uint weight = children.at(j)->GetWeightedNumberOfSeqs();
totalWeight += weight;
QColor color = children.at(j)->GetColor();
red += color.redF() * weight;
green += color.greenF() * weight;
blue += color.blueF() * weight;
}
nodeColor.setRedF(red / totalWeight);
nodeColor.setGreenF(green / totalWeight);
nodeColor.setBlueF(blue / totalWeight);
}
}
node->SetColor(nodeColor);
node->update();
}
示例5: QDialog
ShapePropertiesDialog::ShapePropertiesDialog(ShapeAnnotation *pShapeAnnotation, MainWindow *pMainWindow)
: QDialog(pMainWindow, Qt::WindowTitleHint)
{
mpShapeAnnotation = pShapeAnnotation;
mpLineAnnotation = dynamic_cast<LineAnnotation*>(mpShapeAnnotation);
mpPolygonAnnotation = dynamic_cast<PolygonAnnotation*>(mpShapeAnnotation);
mpRectangleAnnotation = dynamic_cast<RectangleAnnotation*>(mpShapeAnnotation);
mpEllipseAnnotation = dynamic_cast<EllipseAnnotation*>(mpShapeAnnotation);
mpTextAnnotation = dynamic_cast<TextAnnotation*>(mpShapeAnnotation);
mpBitmapAnnotation = dynamic_cast<BitmapAnnotation*>(mpShapeAnnotation);
mpMainWindow = pMainWindow;
QString title = getTitle();
setWindowTitle(QString(Helper::applicationName).append(" - ").append(title).append(" ").append(Helper::properties));
setAttribute(Qt::WA_DeleteOnClose);
// heading label
mpShapePropertiesHeading = new Label(QString(title).append(" ").append(Helper::properties));
mpShapePropertiesHeading->setFont(QFont(Helper::systemFontInfo.family(), Helper::headingFontSize));
mpShapePropertiesHeading->setAlignment(Qt::AlignTop);
// set seperator line
mHorizontalLine = new QFrame();
mHorizontalLine->setFrameShape(QFrame::HLine);
mHorizontalLine->setFrameShadow(QFrame::Sunken);
// Transformations Group Box
mpTransformationGroupBox = new QGroupBox(tr("Transformation"));
mpOriginXLabel = new Label(Helper::originX);
mpOriginXSpinBox = new DoubleSpinBox;
mpOriginXSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
mpOriginXSpinBox->setValue(mpShapeAnnotation->getOrigin().x());
mpOriginXSpinBox->setSingleStep(1);
mpOriginYLabel = new Label(Helper::originY);
mpOriginYSpinBox = new DoubleSpinBox;
mpOriginYSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
mpOriginYSpinBox->setValue(mpShapeAnnotation->getOrigin().y());
mpOriginYSpinBox->setSingleStep(1);
mpRotationLabel = new Label(Helper::rotation);
mpRotationSpinBox = new DoubleSpinBox;
mpRotationSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
mpRotationSpinBox->setValue(mpShapeAnnotation->getRotation());
mpRotationSpinBox->setSingleStep(90);
// set the Transformations Group Box layout
QGridLayout *pTransformationGridLayout = new QGridLayout;
pTransformationGridLayout->setColumnStretch(1, 1);
pTransformationGridLayout->setColumnStretch(3, 1);
pTransformationGridLayout->setColumnStretch(5, 1);
pTransformationGridLayout->addWidget(mpOriginXLabel, 0, 0);
pTransformationGridLayout->addWidget(mpOriginXSpinBox, 0, 1);
pTransformationGridLayout->addWidget(mpOriginYLabel, 0, 2);
pTransformationGridLayout->addWidget(mpOriginYSpinBox, 0, 3);
pTransformationGridLayout->addWidget(mpRotationLabel, 0, 4);
pTransformationGridLayout->addWidget(mpRotationSpinBox, 0, 5);
mpTransformationGroupBox->setLayout(pTransformationGridLayout);
// Extent Group Box
mpExtentGroupBox = new QGroupBox(Helper::extent);
// Extent1X
QList<QPointF> extents = mpShapeAnnotation->getExtents();
mpExtent1XLabel = new Label(Helper::extent1X);
mpExtent1XSpinBox = new DoubleSpinBox;
mpExtent1XSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
mpExtent1XSpinBox->setValue(extents.size() > 0 ? extents.at(0).x() : 0);
mpExtent1XSpinBox->setSingleStep(10);
mpExtent1YLabel = new Label(Helper::extent1Y);
mpExtent1YSpinBox = new DoubleSpinBox;
mpExtent1YSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
mpExtent1YSpinBox->setValue(extents.size() > 0 ? extents.at(0).y() : 0);
mpExtent1YSpinBox->setSingleStep(10);
mpExtent2XLabel = new Label(Helper::extent2X);
mpExtent2XSpinBox = new DoubleSpinBox;
mpExtent2XSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
mpExtent2XSpinBox->setValue(extents.size() > 0 ? extents.at(1).x() : 0);
mpExtent2XSpinBox->setSingleStep(10);
mpExtent2YLabel = new Label(Helper::extent2Y);
mpExtent2YSpinBox = new DoubleSpinBox;
mpExtent2YSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
mpExtent2YSpinBox->setValue(extents.size() > 0 ? extents.at(1).y() : 0);
mpExtent2YSpinBox->setSingleStep(10);
// set the extents Group Box layout
QGridLayout *pExtentGroupBoxLayout = new QGridLayout;
pExtentGroupBoxLayout->setColumnStretch(1, 1);
pExtentGroupBoxLayout->setColumnStretch(3, 1);
pExtentGroupBoxLayout->addWidget(mpExtent1XLabel, 0, 0);
pExtentGroupBoxLayout->addWidget(mpExtent1XSpinBox, 0, 1);
pExtentGroupBoxLayout->addWidget(mpExtent1YLabel, 0, 2);
pExtentGroupBoxLayout->addWidget(mpExtent1YSpinBox, 0, 3);
pExtentGroupBoxLayout->addWidget(mpExtent2XLabel, 1, 0);
pExtentGroupBoxLayout->addWidget(mpExtent2XSpinBox, 1, 1);
pExtentGroupBoxLayout->addWidget(mpExtent2YLabel, 1, 2);
pExtentGroupBoxLayout->addWidget(mpExtent2YSpinBox, 1, 3);
mpExtentGroupBox->setLayout(pExtentGroupBoxLayout);
// Border style Group Box
mpBorderStyleGroupBox = new QGroupBox(tr("Border Style"));
// border pattern
mpBorderPatternLabel = new Label(Helper::pattern);
mpBorderPatternComboBox = new QComboBox;
mpBorderPatternComboBox->addItem(StringHandler::getBorderPatternString(StringHandler::BorderNone));
mpBorderPatternComboBox->addItem(StringHandler::getBorderPatternString(StringHandler::BorderRaised));
mpBorderPatternComboBox->addItem(StringHandler::getBorderPatternString(StringHandler::BorderSunken));
mpBorderPatternComboBox->addItem(StringHandler::getBorderPatternString(StringHandler::BorderEngraved));
int currentIndex = mpBorderPatternComboBox->findText(StringHandler::getBorderPatternString(mpShapeAnnotation->getBorderPattern()), Qt::MatchExactly);
if (currentIndex > -1)
mpBorderPatternComboBox->setCurrentIndex(currentIndex);
//.........这里部分代码省略.........
示例6: populateDiagramsList
void ExoplanetsDialog::populateDiagramsList()
{
Q_ASSERT(ui->comboAxisX);
Q_ASSERT(ui->comboAxisY);
QColor axisColor(Qt::white);
QPen axisPen(axisColor, 1);
ui->customPlot->setBackground(QBrush(QColor(86, 87, 90)));
ui->customPlot->xAxis->setLabelColor(axisColor);
ui->customPlot->xAxis->setTickLabelColor(axisColor);
ui->customPlot->xAxis->setBasePen(axisPen);
ui->customPlot->xAxis->setTickPen(axisPen);
ui->customPlot->xAxis->setSubTickPen(axisPen);
ui->customPlot->yAxis->setLabelColor(axisColor);
ui->customPlot->yAxis->setTickLabelColor(axisColor);
ui->customPlot->yAxis->setBasePen(axisPen);
ui->customPlot->yAxis->setTickPen(axisPen);
ui->customPlot->yAxis->setSubTickPen(axisPen);
QComboBox* axisX = ui->comboAxisX;
QComboBox* axisY = ui->comboAxisY;
//Save the current selection to be restored later
axisX->blockSignals(true);
axisY->blockSignals(true);
int indexX = axisX->currentIndex();
int indexY = axisY->currentIndex();
QVariant selectedAxisX = axisX->itemData(indexX);
QVariant selectedAxisY = axisY->itemData(indexY);
axisX->clear();
axisY->clear();
QList<axisPair> axis;
axis.append(qMakePair(q_("Orbital Eccentricity"), 0));
axis.append(qMakePair(q_("Orbit Semi-Major Axis, AU"), 1));
axis.append(qMakePair(q_("Planetary Mass, Mjup"), 2));
axis.append(qMakePair(q_("Planetary Radius, Rjup"), 3));
axis.append(qMakePair(q_("Orbital Period, days"), 4));
axis.append(qMakePair(q_("Angular Distance, arcsec"), 5));
axis.append(qMakePair(q_("Effective temperature of host star, K"), 6));
axis.append(qMakePair(q_("Year of Discovery"), 7));
axis.append(qMakePair(q_("Metallicity of host star"), 8));
axis.append(qMakePair(q_("V magnitude of host star, mag"), 9));
axis.append(qMakePair(q_("RA (J2000) of star, deg"), 10));
axis.append(qMakePair(q_("Dec (J2000) of star, deg"), 11));
axis.append(qMakePair(q_("Distance to star, pc"), 12));
axis.append(qMakePair(q_("Mass of host star, Msol"), 13));
axis.append(qMakePair(q_("Radius of host star, Rsol"), 14));
for(int i=0; i<axis.size(); ++i)
{
axisX->addItem(axis.at(i).first, axis.at(i).second);
axisY->addItem(axis.at(i).first, axis.at(i).second);
}
//Restore the selection
indexX = axisX->findData(selectedAxisX, Qt::UserRole, Qt::MatchCaseSensitive);
if (indexX<0)
indexX = 1;
indexY = axisY->findData(selectedAxisY, Qt::UserRole, Qt::MatchCaseSensitive);
if (indexY<0)
indexY = 0;
axisX->setCurrentIndex(indexX);
axisY->setCurrentIndex(indexY);
axisX->blockSignals(false);
axisY->blockSignals(false);
}
示例7: generateInterfaceXml
static QString generateInterfaceXml(const QMetaObject *mo, int flags, int methodOffset, int propOffset)
{
QString retval;
// start with properties:
if (flags & (QDBusConnection::ExportScriptableProperties |
QDBusConnection::ExportNonScriptableProperties)) {
for (int i = propOffset; i < mo->propertyCount(); ++i) {
static const char *accessvalues[] = {0, "read", "write", "readwrite"};
QMetaProperty mp = mo->property(i);
if (!((mp.isScriptable() && (flags & QDBusConnection::ExportScriptableProperties)) ||
(!mp.isScriptable() && (flags & QDBusConnection::ExportNonScriptableProperties))))
continue;
int access = 0;
if (mp.isReadable())
access |= 1;
if (mp.isWritable())
access |= 2;
int typeId = qDBusNameToTypeId(mp.typeName());
if (!typeId)
continue;
const char *signature = QDBusMetaType::typeToSignature(typeId);
if (!signature)
continue;
retval += QString::fromLatin1(" <property name=\"%1\" type=\"%2\" access=\"%3\"")
.arg(QLatin1String(mp.name()))
.arg(QLatin1String(signature))
.arg(QLatin1String(accessvalues[access]));
if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) {
const char *typeName = QVariant::typeToName(QVariant::Type(typeId));
retval += QString::fromLatin1(">\n <annotation name=\"com.trolltech.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n")
.arg(typeNameToXml(typeName));
} else {
retval += QLatin1String("/>\n");
}
}
}
// now add methods:
for (int i = methodOffset; i < mo->methodCount(); ++i) {
QMetaMethod mm = mo->method(i);
QByteArray signature = mm.signature();
int paren = signature.indexOf('(');
bool isSignal;
if (mm.methodType() == QMetaMethod::Signal)
// adding a signal
isSignal = true;
else if (mm.access() == QMetaMethod::Public && (mm.methodType() == QMetaMethod::Slot || mm.methodType() == QMetaMethod::Method))
isSignal = false;
else
continue; // neither signal nor public slot
if (isSignal && !(flags & (QDBusConnection::ExportScriptableSignals |
QDBusConnection::ExportNonScriptableSignals)))
continue; // we're not exporting any signals
if (!isSignal && (!(flags & (QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots)) &&
!(flags & (QDBusConnection::ExportScriptableInvokables | QDBusConnection::ExportNonScriptableInvokables))))
continue; // we're not exporting any slots or invokables
QString xml = QString::fromLatin1(" <%1 name=\"%2\">\n")
.arg(isSignal ? QLatin1String("signal") : QLatin1String("method"))
.arg(QLatin1String(signature.left(paren)));
// check the return type first
int typeId = qDBusNameToTypeId(mm.typeName());
if (typeId) {
const char *typeName = QDBusMetaType::typeToSignature(typeId);
if (typeName) {
xml += QString::fromLatin1(" <arg type=\"%1\" direction=\"out\"/>\n")
.arg(typeNameToXml(typeName));
// do we need to describe this argument?
if (QDBusMetaType::signatureToType(typeName) == QVariant::Invalid)
xml += QString::fromLatin1(" <annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n")
.arg(typeNameToXml(QVariant::typeToName(QVariant::Type(typeId))));
} else
continue;
}
else if (*mm.typeName())
continue; // wasn't a valid type
QList<QByteArray> names = mm.parameterNames();
QList<int> types;
int inputCount = qDBusParametersForMethod(mm, types);
if (inputCount == -1)
continue; // invalid form
if (isSignal && inputCount + 1 != types.count())
continue; // signal with output arguments?
if (isSignal && types.at(inputCount) == QDBusMetaTypeId::message)
continue; // signal with QDBusMessage argument?
if (isSignal && mm.attributes() & QMetaMethod::Cloned)
continue; // cloned signal?
//.........这里部分代码省略.........
示例8: onReport
void Statistic::onReport()
{
ui.curOperationLabel->setText(trUtf8("Анализ отчета..."));
setCursor(Qt::WaitCursor);
CXSettings* settings = CXSettings::inst();
settings->setValue(E_StartDate, QDateTime(ui.mStartDateEdit->date(), ui.mStartTimeEdit->time()));
settings->setValue(E_EndDate, QDateTime(ui.mEndDateEdit->date(), ui.mEndTimeEdit->time()));
QStringList xmlFiles;
#ifdef DEBUG_VER
QString tmp = "D:/CNC_stat";
#else
QString tmp = QApplication::applicationDirPath();
#endif
QDir logsDir(tmp + "/" + LOG_PATH);
//QDir logsDir(QApplication::applicationDirPath() + "/" + LOG_PATH);
QString tempFileName;
QStringList dirs = logsDir.entryList(QDir::Dirs);
for (int i = 0; i < dirs.count(); ++i)
{
tempFileName = logsDir.path() + "/" + dirs.at(i) + "/report.xml";
if (QFile::exists(tempFileName)) xmlFiles.append(tempFileName);
}
QList <SXReportError> errorList = Engine::generateReport(xmlFiles, settings->value(E_StartDate).toDateTime(), settings->value(E_EndDate).toDateTime());
//#ifndef QT_NO_DEBUG
// ui.mErrorTree->clear();
//
// QTreeWidgetItem* newItem = NULL;
// QTreeWidgetItem* childItem = NULL;
// QString lastFilename = "";
//
// for (int i = 0; i < errorList.count(); ++i)
// {
// const SXReportError& curErrorData = errorList.at(i);
//
// if ((newItem == NULL) || ((newItem != NULL) && (lastFilename != curErrorData.mFileName)))
// {
// newItem = new QTreeWidgetItem(ui.mErrorTree);
// lastFilename = curErrorData.mFileName;
// newItem->setText(0, lastFilename);
// }
//
// childItem = new QTreeWidgetItem(newItem);
// childItem->setForeground(0, Qt::red);
// childItem->setText(0, curErrorData.mError);
//
// ui.mErrorTree->addTopLevelItem(newItem);
// }
//#else
QFile errorLog("errors.log");
errorLog.open(QIODevice::WriteOnly);
QTextStream textStream(&errorLog);
textStream.setCodec(QTextCodec::codecForName("UTF-8"));
for (int i = 0; i < errorList.count(); ++i)
{
const SXReportError& curErrorData = errorList.at(i);
textStream << curErrorData.mFileName << "\t-\t";
textStream << curErrorData.mError << "\n";
}
//#endif
ui.mReportView->setHtml(Engine::getReportText());
ui.curOperationLabel->setText(trUtf8("Нет текущих операций"));
setCursor(Qt::ArrowCursor);
}
示例9: checkAppt
mresult ApptModel::checkAppt(const QList<inf_appt> &listAppt)
{
qint64 now = QDateTime::currentMSecsSinceEpoch();
QList <inf_appt> toRemove;
QList <inf_appt> toRemoveBlack;
QList <inf_appt> toAppend;
inf_appt A,B;
qint64 start = 0,end = 0,alarm = 0;
for (int i = 0; i < black.size(); ++i) {
A = black.at(i);
start = A.getmalarmInstStart().toLongLong();
end = start + A.getmdur().toLongLong();
if(!listAppt.contains(A)) {
if (now > end) {
toRemoveBlack.append(A);
}
}
}
for (int i = 0; i < listAppt.size(); ++i) {
A = listAppt.at(i);
start = A.getmalarmInstStart().toLongLong();
end = start + A.getmdur().toLongLong();
alarm = A.getmnextAlarm().toLongLong();
if (black.contains(A)) {
toRemove.append(A);
continue;
}
if(alarm > now) {
toRemove.append(A);
} else {
if(alarm > now) {
toAppend.append(A);
}
if((alarm == 0) &&
((now < start) || (now > end))) {
toRemove.append(A);
} else {
toAppend.append(A);
}
}
}
for (int i = 0; i < Appt.size(); ++i) {
A = Appt.at(i);
if (!listAppt.contains(A)) {
toRemove.append(A);
}
}
for (int i = 0; i < toRemove.size(); ++i) {
inf_appt rm = toRemove.at(i);
if(Appt.contains(rm)) {
int ind = Appt.indexOf(rm);
beginRemoveRows(QModelIndex(), ind, ind);
Appt.removeAll(rm);
endRemoveRows();
}
}
int k = 0;
for (int i = 0; i < toAppend.size(); ++i) {
A = toAppend.at(i);
k = 0;
if(!Appt.contains(A)) {
for ( int j = 0; j < Appt.size(); ++j) {
B = Appt.at(j);
//qDebug() << A.getmname() <<A.getmalarmInstStart() << B.getmalarmInstStart()<< B.getmname();
if(A.getmalarmInstStart().toLongLong() < B.getmalarmInstStart().toLongLong()) {
k = j + 1;
}
}
beginInsertRows(QModelIndex(), k, k );
//qDebug() << k<< A.getmname();
Appt.insert(k,A);
endInsertRows();
}
}
// for (int i = 0; i < toAppend.size(); ++i) {
// inf in = toAppend.at(i);
// if(!Appt.contains(in)){
// beginInsertRows(QModelIndex(), Appt.size() + 1, Appt.size() +1 );
// Appt.append(in);
// endInsertRows();
// }
// }
for (int i = 0; i < toRemoveBlack.size(); ++i) {
inf_appt rm = toRemoveBlack.at(i);
black.removeAll(rm);
}
//qDebug() <<toAppend.size()<<toRemove.size()<<black.size() << Appt.size();
mresult r;
r.setresult(Appt.size(),toAppend.size(),toRemove.size(),black.size());
return r;
}
示例10: SetupDevices
bool SlimServerInfo::SetupDevices( void )
{
DEBUGF("");
QByteArray response;
QList<QByteArray> respList;
QByteArray cmd;
cli->EmitCliInfo( "Analyzing Attached Players" );
// int loopCounter = 0;
// while(loopCounter++ < 5 ) {
if( playerCount <= 0 ) { // we have a problem
DEBUGF( "NO DEVICES" );
return false;
}
DEBUGF("player count is:" << playerCount);
for( int i = 0; i < playerCount; i++ ) {
cmd = QString( "player id %1 ?\n" ).arg( i ).toAscii();
if( !cli->SendBlockingCommand( cmd ) )
return false;
response = cli->GetResponse();
DEBUGF(response);
respList.clear();
respList = response.split( ' ' );
QString thisId;
if( respList.at( 3 ).contains( ':' ) )
thisId = respList.at( 3 ).toLower().toPercentEncoding(); // escape encode the MAC address if necessary
else
thisId = respList.at( 3 ).toLower();
cmd = QString( "player name %1 ?\n" ).arg( i ).toAscii();
if( !cli->SendBlockingCommand( cmd ) )
return false;
response = cli->GetResponse();
respList.clear();
respList = response.split( ' ' );
DEBUGF(response);
QString thisName = respList.at( 3 );
// GetDeviceNameList().insert( thisName, thisId ); // insert hash of key=Devicename value=MAC address
cmd = QString( "player ip %1 ?\n" ).arg( i ).toAscii();
if( !cli->SendBlockingCommand( cmd ) )
return false;
response = cli->GetResponse();
DEBUGF(response);
respList.clear();
respList = response.split( ' ' );
QString deviceIP = respList.at( 3 );
deviceIP = deviceIP.section( QString( "%3A" ), 0, 0 );
DEBUGF( thisId.toAscii() << " | " << thisName.toAscii() << " | " << deviceIP.toAscii() << " | " << i );
deviceList.insert( thisId, new SlimDevice( thisId.toAscii(), thisName.toAscii(), deviceIP.toAscii(), QByteArray::number( i ) ) );
}
if(!deviceList.contains( cli->GetMACAddress().toLower()))
return false;
else
return true;
}
示例11: doCollision
void Ball::doCollision()
{
if(!stopped){
if(birdDeadCounter>0)
{
--birdDeadCounter;
if(birdDeadCounter<=0)
{
scene()->removeItem(removeBird);
}
}
//check ob es eine Kollision gibt
QList<QGraphicsItem*> collideList = scene()->collidingItems(this);
//if(!(collideList.isEmpty()))
for(int i=0; i<collideList.size(); ++i)
{
//finde Typ des kollidierenden Objectes heraus (BorderLine oder GroundMaterial)
int sw = collideList.at(i)->type();
switch(sw)
{
case CourtElement::borderline_type: //Kollision mit Spielfeldrand, abprallen
{
//Jetzt weis man, dass es eine Borderline ist, also caste QGraphicsItem* in BorderLine*
BorderLine* borderline = static_cast<BorderLine*>(collideList.at(i));
int angle = borderline->getAngle();
if(canCollide<=0)
{
emit soundPlay(SoundEngine::borderCollisionSound);
//angle ist relativ zu 3 Uhr (Uhrzeigersinn), rotation ist relativ zu 12 Uhr (Uhrzeigersinn)
setRotation(2*(angle+90.0-rotation()) + rotation());
speed = speed * borderline->getReflectionCoefficient();
canCollide = 3;
}
}
break;
case CourtElement::groundmaterial_type:
{
GroundMaterial* groundmaterial = static_cast<GroundMaterial*>(collideList.at(i));
double maxspeed = groundmaterial->getMaxSpeed();
double minspeed = groundmaterial->getMinSpeed();
double friction = groundmaterial->getFrictionCoefficient();
switch(groundmaterial->getMaterial())
{
case GroundMaterial::water_material:
{
emit soundPlay(SoundEngine::waterSound);
speed -= friction*speed;
if(speed<minspeed)
{
speed = 0.0;
emit ballInWater();
}
}
break;
case GroundMaterial::nonNewtonian_material:
if(speed > minspeed)
{
speed -= speed*friction;
}
else if(speed<minspeed)
{
speed = 0.0;
emit soundPlay(SoundEngine::lavaSound);
emit ballInWater(); //Ist ja im Prinzip das gleiche wie bei Wasser
}
break;
case GroundMaterial::hole_material:
if(speed<maxspeed)
{
emit soundPlay(SoundEngine::cheeringSound);
speed = 0.0;
stopped=true;
emit ballInHole();
}
break;
case GroundMaterial::grass_material:
{
speed -= friction;
//.........这里部分代码省略.........
示例12: importStart
bool CSVToolWindow::importStart()
{
QString mapname = atlasWindow()->map();
CSVAtlas *atlas = _atlasWindow->getAtlas();
if (mapname.isEmpty())
{
QStringList mList = atlas->mapList();
if(mList.isEmpty())
{
_msghandler->message(QtWarningMsg, tr("No Maps Loaded"),
tr("<p>There are no maps loaded to select from. "
"Either load an atlas that contains maps or "
"create a new one before continuing."));
return false;
}
mList.sort();
bool valid;
mapname = QInputDialog::getItem(this, tr("Select Map"), tr("Select Map:"),
mList, 0, FALSE, &valid);
if (!valid)
return false;
}
CSVMap map = atlas->map(mapname);
map.simplify();
QList<CSVMapField> fields = map.fields();
if (map.name() != mapname || fields.isEmpty())
{
_msghandler->message(QtWarningMsg, tr("Invalid Map"),
tr("<p>The selected map does not appear to be valid."));
return false;
}
CSVMap::Action action = map.action();
if (action != CSVMap::Insert)
{
_msghandler->message(QtWarningMsg, tr("Action not implemented"),
tr("<p>The action %1 for this map is not supported.")
.arg(CSVMap::actionToName(action)));
return false;
}
if (!_data || _data->rows() < 1)
{
_msghandler->message(QtWarningMsg, tr("No data"),
tr("<p>There are no data to process. "
"Load a CSV file before continuing."));
return false;
}
int total = _data->rows();
int current = 0, error = 0, ignored = 0;
if (! _log)
_log = new LogWindow(this);
if(usetransaction) QSqlQuery begin("BEGIN;");
QString errMsg;
if(!map.sqlPre().trimmed().isEmpty())
{
if(usetransaction) QSqlQuery savepoint("SAVEPOINT presql;");
QSqlQuery pre;
if(!pre.exec(map.sqlPre()))
{
errMsg = QString("ERROR Running Pre SQL query: %1").arg(pre.lastError().text());
_log->_log->append("\n\n----------------------\n");
_log->_log->append(errMsg);
_log->show();
_log->raise();
if(map.sqlPreContinueOnError())
{
_log->_log->append(tr("\n\nContinuing with rest of import\n\n"));
if(usetransaction) QSqlQuery sprollback("ROLLBACK TO SAVEPOINT presql;");
if(usetransaction) QSqlQuery savepoint("RELEASE SAVEPOINT presql;");
}
else
{
if(usetransaction) QSqlQuery rollback("ROLLBACK;");
_msghandler->message(QtWarningMsg, tr("Error"),
tr("<p>There was an error running the Pre SQL "
"query. Please see the log for more details. "
"Aborting transaction."));
return false;
}
}
}
QString progresstext(tr("Importing %1: %2 rows out of %3"));
int expected = total;
QProgressDialog *progress = new QProgressDialog(progresstext
.arg(map.name()).arg(0).arg(expected),
tr("Cancel"), 0, expected, this);
progress->setWindowModality(Qt::WindowModal);
bool userCanceled = false;
//.........这里部分代码省略.........
示例13: resumeDataFromZip
//恢复数据
int CardDoc::resumeDataFromZip(const QString &zipPath)
{
// removeTempFile();
QDir dir;
bool exist = dir.exists("tmp1");
if (!exist)
{
//创建tmp文件夹
dir.mkdir("tmp1");
}
try
{
ACUnZip(zipPath.toStdString(), "tmp1\\");
QFile file("tmp1\\paperSet.dat");
if (!file.open(QIODevice::ReadOnly))
{
file.close();
removeTempFile("tmp1");
return 0;
}
QDataStream data;
data.setDevice(&file);
data.setVersion(QDataStream::Qt_4_8);
quint32 magic;
data >> magic;
//判断是否为可识别格式
if (magic != (quint32)PAPERSET_MAGIC_NUM)
{
file.close();
removeTempFile("tmp1");
return 0;
}
quint32 version;
data >> version;
//判断是否为可识别版本
if (version != (quint32)VERSION)
{
file.close();
removeTempFile("tmp1");
return 0;
}
int type;
data >> type;
if (type != m_acType)
{
removeTempFile("tmp1");
return 0;
}
//m_acType = type;
QString courseName;
data >> courseName;
vector<PaperSet> paperSet;
QList<QString> setId;
QList<int> dpi;
QList<int> pageCount;
QList<QString> pageId;
QList<bool> isPositive;
int setSize;
int pageIdx = 0;
data >> setSize >> setId >> dpi
>> pageCount >> pageId >> isPositive;
for (int i = 0; i < setSize; ++i)
{
PaperSet set;
set.setId = setId.at(i);
set.dpi = dpi.at(i);
for (int j = 0; j < pageCount.at(i); ++j, ++pageIdx)
{
PaperPage page;
page.pageId = pageId.at(pageIdx);
page.isPositive = isPositive.at(pageIdx);
set.page.push_back(page);
}
paperSet.push_back(set);
}
int find = isCourseExist(courseName);
if (find > -1)
{
m_course.at(find).set.clear();
m_course.at(find).set = paperSet;
//.........这里部分代码省略.........
示例14: sendMemoEMail
bool Global::sendMemoEMail(const QString mailPrefixMessage, const QList<RepoChanges> & repoChanges) {
QStringList attachments;
const QString tmpPath = QString(BOXIT_STATUS_TMP) + "/" + QString::number(qrand()) + "_" + QDateTime::currentDateTime().toString(Qt::ISODate);
bool success = true;
// Create working folder
if (QDir(tmpPath).exists() && !Global::rmDir(tmpPath)) {
cerr << "error: failed to remove folder '" << tmpPath.toUtf8().data() << "'" << endl;
return false;
}
if (!QDir().mkpath(tmpPath)) {
cerr << "error: failed to create folder '" << tmpPath.toUtf8().data() << "'" << endl;
return false;
}
QString message = mailPrefixMessage;
for (int i = 0; i < repoChanges.size(); ++i) {
const RepoChanges *repo = &repoChanges.at(i);
message += QString(" - %1 %2 %3: %4 new and %5 removed package(s)\n").arg(repo->branchName, repo->repoName, repo->repoArchitecture,
QString::number(repo->addedPackages.size()),
QString::number(repo->removedPackages.size()));
// Create attachment file
QFile file(QString(tmpPath) + "/" + repo->branchName + "_" + repo->repoName + "_" + repo->repoArchitecture);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
success = false;
goto remove_tmp_dir;
}
QTextStream out(&file);
if (!repo->addedPackages.isEmpty()) {
out << "[New Packages]\n" << repo->addedPackages.join("\n");
if (!repo->removedPackages.isEmpty())
out << "\n\n\n";
}
if (!repo->removedPackages.isEmpty())
out << "[Removed Packages]\n" << repo->removedPackages.join("\n");
file.close();
// Add to list
attachments.append(file.fileName());
}
// Send e-mail
if (!Global::sendMemoEMail(message, attachments)) {
cerr << "error: failed to send e-mail!" << endl;
success = false;
goto remove_tmp_dir;
}
remove_tmp_dir:
// Remove working folder again
if (QDir(tmpPath).exists() && !Global::rmDir(tmpPath))
cerr << "error: failed to remove folder '" << tmpPath.toUtf8().data() << "'" << endl;
return success;
}
示例15: enqueue
void MediaObject::enqueue(const QList<MediaSource> &sources)
{
for (int i = 0; i < sources.count(); ++i) {
enqueue(sources.at(i));
}
}