当前位置: 首页>>代码示例>>C++>>正文


C++ qSort函数代码示例

本文整理汇总了C++中qSort函数的典型用法代码示例。如果您正苦于以下问题:C++ qSort函数的具体用法?C++ qSort怎么用?C++ qSort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了qSort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: foreach

void DiscoInfoWindow::updateWindow()
{
	IDiscoInfo dinfo = FDiscovery->discoInfo(FStreamJid,FContactJid,FNode);

	int row = 0;
	ui.twtIdentity->clearContents();
	foreach(const IDiscoIdentity &identity, dinfo.identity)
	{
		ui.twtIdentity->setRowCount(row+1);
		ui.twtIdentity->setItem(row,0,new QTableWidgetItem(identity.category));
		ui.twtIdentity->setItem(row,1,new QTableWidgetItem(identity.type));
		ui.twtIdentity->setItem(row,2,new QTableWidgetItem(identity.name));
		row++;
	}
	ui.twtIdentity->verticalHeader()->resizeSections(QHeaderView::ResizeToContents);

	qSort(dinfo.features);
	ui.lwtFearures->clear();
	foreach(const QString &featureVar, dinfo.features)
	{
		IDiscoFeature dfeature = FDiscovery->discoFeature(featureVar);
		dfeature.var = featureVar;
		QListWidgetItem *listItem = new QListWidgetItem;
		listItem->setIcon(dfeature.icon);
		listItem->setText(dfeature.name.isEmpty() ? dfeature.var : dfeature.name);
		if (FDiscovery->hasFeatureHandler(featureVar))
		{
			QFont font = ui.lwtFearures->font();
			font.setBold(true);
			listItem->setData(Qt::FontRole,font);
		}
		listItem->setData(Qt::UserRole,dfeature.var);
		listItem->setData(Qt::UserRole+1,dfeature.description);
		ui.lwtFearures->addItem(listItem);
	}
	onCurrentFeatureChanged(ui.lwtFearures->currentItem(), NULL);

	if (FDataForms)
	{
		if (FFormMenu)
		{
			FFormMenu->deleteLater();
			FFormMenu = NULL;
		}
		if (!dinfo.extensions.isEmpty())
		{
			FFormMenu = new Menu(ui.pbtExtensions);
			for (int index=0; index<dinfo.extensions.count(); index++)
			{
				IDataForm form = FDataForms->localizeForm(dinfo.extensions.at(index));
				Action *action = new Action(FFormMenu);
				action->setData(ADR_FORM_INDEX,index);
				action->setText(!form.title.isEmpty() ? form.title : FDataForms->fieldValue("FORM_TYPE",form.fields).toString());
				connect(action,SIGNAL(triggered(bool)),SLOT(onShowExtensionForm(bool)));
				FFormMenu->addAction(action);
			}
		}
		ui.pbtExtensions->setMenu(FFormMenu);
		ui.pbtExtensions->setEnabled(FFormMenu!=NULL);
	}

	if (!dinfo.error.isNull())
	{
		ui.lblError->setText(tr("Error: %1").arg(dinfo.error.errorMessage()));
		ui.twtIdentity->setEnabled(false);
		ui.lwtFearures->setEnabled(false);
		ui.lblError->setVisible(true);
	}
	else
	{
		ui.twtIdentity->setEnabled(true);
		ui.lwtFearures->setEnabled(true);
		ui.lblError->setVisible(false);
	}

	ui.twtIdentity->horizontalHeader()->setResizeMode(0,QHeaderView::ResizeToContents);
	ui.twtIdentity->horizontalHeader()->setResizeMode(1,QHeaderView::ResizeToContents);
	ui.twtIdentity->horizontalHeader()->setResizeMode(2,QHeaderView::Stretch);

	ui.pbtUpdate->setEnabled(true);
}
开发者ID:sanchay160887,项目名称:vacuum-im,代码行数:81,代码来源:discoinfowindow.cpp

示例2: scaleDraw

/*!
   Redraw the liquid in thermometer pipe.
   \param painter Painter
   \param pipeRect Bounding rectangle of the pipe without borders
*/
void QwtThermo::drawLiquid( 
    QPainter *painter, const QRect &pipeRect ) const
{
    painter->save();
    painter->setClipRect( pipeRect, Qt::IntersectClip );
    painter->setPen( Qt::NoPen );

    const QwtScaleMap scaleMap = scaleDraw()->scaleMap();

    QRect liquidRect = fillRect( pipeRect );

    if ( d_data->colorMap != NULL )
    {
        const QwtInterval interval = scaleDiv().interval().normalized();

        // Because the positions of the ticks are rounded
        // we calculate the colors for the rounded tick values

        QVector<double> values = qwtTickList( scaleDraw()->scaleDiv() );

        if ( scaleMap.isInverting() )
            qSort( values.begin(), values.end(), qGreater<double>() );
        else
            qSort( values.begin(), values.end(), qLess<double>() );

        int from;
        if ( !values.isEmpty() )
        {
            from = qRound( scaleMap.transform( values[0] ) );
            qwtDrawLine( painter, from,
                d_data->colorMap->color( interval, values[0] ),
                pipeRect, liquidRect, d_data->orientation );
        }

        for ( int i = 1; i < values.size(); i++ )
        {
            const int to = qRound( scaleMap.transform( values[i] ) );

            for ( int pos = from + 1; pos < to; pos++ )
            {
                const double v = scaleMap.invTransform( pos );

                qwtDrawLine( painter, pos, 
                    d_data->colorMap->color( interval, v ),
                    pipeRect, liquidRect, d_data->orientation );
            }

            qwtDrawLine( painter, to,
                d_data->colorMap->color( interval, values[i] ),
                pipeRect, liquidRect, d_data->orientation );

            from = to;
        }
    }
    else
    {
        if ( !liquidRect.isEmpty() && d_data->alarmEnabled )
        {
            const QRect r = alarmRect( liquidRect );
            if ( !r.isEmpty() )
            {
                painter->fillRect( r, palette().brush( QPalette::Highlight ) );
                liquidRect = QRegion( liquidRect ).subtracted( r ).boundingRect();
            }
        }

        painter->fillRect( liquidRect, palette().brush( QPalette::ButtonText ) );
    }

    painter->restore();
}
开发者ID:151706061,项目名称:sofa,代码行数:76,代码来源:qwt_thermo.cpp

示例3: interval

/*
  This is the main workhorse of the QGridLayout. It portions out
  available space to the chain's children.

  The calculation is done in fixed point: "fixed" variables are
  scaled by a factor of 256.

  If the layout runs "backwards" (i.e. RightToLeft or Up) the layout
  is computed mirror-reversed, and it's the caller's responsibility
  do reverse the values before use.

  chain contains input and output parameters describing the geometry.
  count is the count of items in the chain; pos and space give the
  interval (relative to parentWidget topLeft).
*/
void qGeomCalc(QVector<QLayoutStruct> &chain, int start, int count,
               int pos, int space, int spacer)
{
    int cHint = 0;
    int cMin = 0;
    int cMax = 0;
    int sumStretch = 0;
    int sumSpacing = 0;

    bool wannaGrow = false; // anyone who really wants to grow?
    //    bool canShrink = false; // anyone who could be persuaded to shrink?

    bool allEmptyNonstretch = true;
    int pendingSpacing = -1;
    int spacerCount = 0;
    int i;

    for (i = start; i < start + count; i++) {
        QLayoutStruct *data = &chain[i];

        data->done = false;
        cHint += data->smartSizeHint();
        cMin += data->minimumSize;
        cMax += data->maximumSize;
        sumStretch += data->stretch;
        if (!data->empty) {
            /*
                Using pendingSpacing, we ensure that the spacing for the last
                (non-empty) item is ignored.
            */
            if (pendingSpacing >= 0) {
                sumSpacing += pendingSpacing;
                ++spacerCount;
            }
            pendingSpacing = data->effectiveSpacer(spacer);
        }
        wannaGrow = wannaGrow || data->expansive || data->stretch > 0;
        allEmptyNonstretch = allEmptyNonstretch && !wannaGrow && data->empty;
    }

    int extraspace = 0;

    if (space < cMin + sumSpacing) {
        /*
          Less space than minimumSize; take from the biggest first
        */

        int minSize = cMin + sumSpacing;

        // shrink the spacers proportionally
        if (spacer >= 0) {
            spacer = minSize > 0 ? spacer * space / minSize : 0;
            sumSpacing = spacer * spacerCount;
        }

        QList<int> list;

        for (i = start; i < start + count; i++)
            list << chain.at(i).minimumSize;

        qSort(list);

        int space_left = space - sumSpacing;

        int sum = 0;
        int idx = 0;
        int space_used=0;
        int current = 0;
        while (idx < count && space_used < space_left) {
            current = list.at(idx);
            space_used = sum + current * (count - idx);
            sum += current;
            ++idx;
        }
        --idx;
        int deficit = space_used - space_left;

        int items = count - idx;
        /*
         * If we truncate all items to "current", we would get "deficit" too many pixels. Therefore, we have to remove
         * deficit/items from each item bigger than maxval. The actual value to remove is deficitPerItem + remainder/items
         * "rest" is the accumulated error from using integer arithmetic.
        */
        int deficitPerItem = deficit/items;
        int remainder = deficit % items;
//.........这里部分代码省略.........
开发者ID:crobertd,项目名称:qtbase,代码行数:101,代码来源:qlayoutengine.cpp

示例4: QMainWindow

ReportList::ReportList(BoxType type, bool sortByScore, QWidget *parent)
    : QMainWindow(parent)
{
    this->sort = sortByScore;
    printAction = new QAction("&Print...", this);
    QMenu* fileMenu = menuBar()->addMenu("&File");
    fileMenu->addAction(printAction);
    connect(printAction, SIGNAL(triggered()), this, SLOT(print()));

    QWidget* central = new QWidget();
    this->setCentralWidget(central);

    QHBoxLayout* mainLayout = new QHBoxLayout();
    central->setLayout(mainLayout);

    this->reports = new QStackedWidget();
    int size = 0;

    if(type == employee)
    {
        employeeData = DataInterface::getEmployees();
        if(sortByScore)
        {
            this->setWindowTitle("Employee View - Sorted By Average Score");
            qSort(employeeData.begin(), employeeData.end());
        } else
        {
            this->setWindowTitle("Employee View");
        }

        size = employeeData.size();
        for(int i = 0; i < size; i++)
        {
            EmployeeReportBox* box = new EmployeeReportBox(employeeData.at(i), i, size);
            reports->addWidget(box);
        }
    } else if(type == employer)
    {
        this->setWindowTitle("Employer View");
        employerData = DataInterface::getEmployers();
        size = employerData.size();
        for(int i = 0; i < size; i++)
        {
            EmployerReportBox* box = new EmployerReportBox(employerData.at(i), i, size);
            reports->addWidget(box);
        }
    } else
    {
        QMessageBox::information(this, "Failed To Read Data", "Failed to read the data from the file.");
        return;
    }


    QScrollBar *scrollBar = new QScrollBar(Qt::Vertical);
    scrollBar->setRange(0, size - 1);
    scrollBar->setValue(0);
    scrollBar->setFocusPolicy(Qt::WheelFocus);


    connect(scrollBar, SIGNAL(valueChanged(int)), this, SLOT(moveToBox(int)));

    this->setFixedHeight(370);

    reports->setCurrentIndex(0);

    mainLayout->addWidget(reports);
    mainLayout->addWidget(scrollBar);

}
开发者ID:noahgolmant,项目名称:Employee-Evaluation,代码行数:69,代码来源:reportlist.cpp

示例5: scopedLocker

bool OsmAnd::MapRenderer::prePrepareFrame()
{
    if(!_isRenderingInitialized)
        return false;

    // If we have current configuration invalidated, we need to update it
    // and invalidate frame
    if(_currentConfigurationInvalidatedMask)
    {
        {
            QReadLocker scopedLocker(&_configurationLock);

            _currentConfiguration = _requestedConfiguration;
        }

        bool ok = updateCurrentConfiguration();
        if(ok)
            _currentConfigurationInvalidatedMask = 0;

        invalidateFrame();

        // If configuration is still invalidated, abort processing
        if(_currentConfigurationInvalidatedMask)
            return false;
    }

    // If we have current state invalidated, we need to update it
    // and invalidate frame
    if(_currentStateInvalidated)
    {
        {
            QReadLocker scopedLocker(&_stateLock);

            _currentState = _requestedState;
        }

        bool ok = updateCurrentState();
        if(ok)
            _currentStateInvalidated = false;

        invalidateFrame();

        // If state is still invalidated, abort processing
        if(_currentStateInvalidated)
            return false;
    }

    // If we have invalidated resources, purge them
    if(_invalidatedRasterLayerResourcesMask)
    {
        QReadLocker scopedLocker(&_invalidatedRasterLayerResourcesMaskLock);

        for(int layerId = 0; layerId < RasterMapLayersCount; layerId++)
        {
            if((_invalidatedRasterLayerResourcesMask & (1 << layerId)) == 0)
                continue;

            validateRasterLayerResources(static_cast<RasterMapLayerId>(layerId));

            _invalidatedRasterLayerResourcesMask &= ~(1 << layerId);
        }
    }
    if(_invalidatedElevationDataResources)
    {
        validateElevationDataResources();
        _invalidatedElevationDataResources = false;
    }

    // Sort visible tiles by distance from target
    qSort(_visibleTiles.begin(), _visibleTiles.end(), [this](const TileId& l, const TileId& r) -> bool
    {
        const auto lx = l.x - _targetTileId.x;
        const auto ly = l.y - _targetTileId.y;

        const auto rx = r.x - _targetTileId.x;
        const auto ry = r.y - _targetTileId.y;

        return (lx*lx + ly*ly) > (rx*rx + ry*ry);
    });

    // Get set of tiles that are unique: visible tiles may contain same tiles, but wrapped
    _uniqueTiles.clear();
    for(auto itTileId = _visibleTiles.begin(); itTileId != _visibleTiles.end(); ++itTileId)
    {
        const auto& tileId = *itTileId;
        _uniqueTiles.insert(Utilities::normalizeTileId(tileId, _currentState.zoomBase));
    }

    //TODO: Keep cache fresh and throw away outdated tiles

    return true;
}
开发者ID:BathoryPeter,项目名称:OsmAnd-core,代码行数:92,代码来源:MapRenderer.cpp

示例6: file

bool Parser::process(int parsingMode)
{
  m_parsingMode = parsingMode;
  ngrt4n::clearCoreData(*m_cdata);

  m_dotContent.clear();
  QDomDocument xmlDoc;
  QDomElement xmlRoot;


  QFile file(m_descriptionFile);
  if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
    m_lastErrorMsg = QObject::tr("Unable to open the file %1").arg(m_descriptionFile);
    Q_EMIT errorOccurred(m_lastErrorMsg);
    file.close();
    return false;
  }

  if (!xmlDoc.setContent(&file)) {
    file.close();
    m_lastErrorMsg = QObject::tr("Error while parsing the file %1").arg(m_descriptionFile);
    Q_EMIT errorOccurred(m_lastErrorMsg);
    return false;
  }
  file.close(); // The content of the file is already in memory

  xmlRoot = xmlDoc.documentElement();
  m_cdata->monitor = xmlRoot.attribute("monitor").toInt();
  m_cdata->format_version = xmlRoot.attribute("compat").toDouble();
  QDomNodeList services = xmlRoot.elementsByTagName("Service");

  NodeT node;
  qint32 serviceCount = services.length();
  for (qint32 srv = 0; srv < serviceCount; ++srv) {
    QDomElement service = services.item(srv).toElement();
    node.parent.clear();
    node.monitored = false;
    node.id = service.attribute("id").trimmed();
    node.type = service.attribute("type").toInt();
    node.sev = node.sev_prop = ngrt4n::Unknown;
    node.sev_crule = service.attribute("statusCalcRule").toInt();
    node.sev_prule = service.attribute("statusPropRule").toInt();
    node.icon = service.firstChildElement("Icon").text().trimmed();
    node.name = service.firstChildElement("Name").text().trimmed();
    node.description = service.firstChildElement("Description").text().trimmed();
    node.alarm_msg = service.firstChildElement("AlarmMsg").text().trimmed();
    node.notification_msg = service.firstChildElement("NotificationMsg").text().trimmed();
    node.child_nodes = service.firstChildElement("SubServices").text().trimmed();
    node.weight = (m_cdata->format_version >= 3.1) ? service.attribute("weight").toDouble() : ngrt4n::WEIGHT_UNIT;

    if (node.sev_crule == CalcRules::WeightedAverageWithThresholds) {
      QString thdata = service.firstChildElement("Thresholds").text().trimmed();
      node.thresholdLimits = ThresholdHelper::dataToList(thdata);
      qSort(node.thresholdLimits.begin(), node.thresholdLimits.end(), ThresholdLessthanFnt());
    }

    node.check.status = -1;
    if (node.icon.isEmpty()) node.icon = ngrt4n::DEFAULT_ICON;

    switch(node.type) {
      case NodeType::BusinessService:
        insertBusinessServiceNode(node);
        break;
      case NodeType::ITService:
        insertITServiceNode(node);
        break;
      case NodeType::ExternalService:
        insertExternalServiceNode(node);
        break;
      default:
        break;
    }
  }

  updateNodeHierachy();
  saveCoordinatesFile();

  if (m_parsingMode == ParsingModeDashboard)
    return parseDotResult();

  return true;
}
开发者ID:RealOpInsightLabs,项目名称:realopinsight-workstation,代码行数:82,代码来源:Parser.cpp

示例7: qSort

void NemoCalendarAgendaModel::doRefresh(bool reset)
{
    mKCal::ExtendedCalendar::Ptr calendar = NemoCalendarDb::calendar();

    QDate endDate = mEndDate.isValid()?mEndDate:mStartDate;

    mKCal::ExtendedCalendar::ExpandedIncidenceList newEvents =
        calendar->rawExpandedEvents(mStartDate, endDate, false, false, KDateTime::Spec(KDateTime::LocalZone));

    // Filter out excluded notebooks
    for (int ii = 0; ii < newEvents.count(); ++ii) {
        if (!NemoCalendarEventCache::instance()->mNotebooks.contains(NemoCalendarDb::calendar()->notebook(newEvents.at(ii).second))) {
            newEvents.remove(ii);
            --ii;
        }
    }

    qSort(newEvents.begin(), newEvents.end(), eventsLessThan);

    int oldEventCount = mEvents.count();

    if (reset) {
        beginResetModel();
        qDeleteAll(mEvents);
        mEvents.clear();
    }

    QList<NemoCalendarEventOccurrence *> events = mEvents;

    int newEventsCounter = 0;
    int eventsCounter = 0;

    int mEventsIndex = 0;

    while (newEventsCounter < newEvents.count() || eventsCounter < events.count()) {
        // Remove old events
        int removeCount = 0;
        while ((eventsCounter + removeCount) < events.count() &&
               (newEventsCounter >= newEvents.count() ||
                eventsLessThan(events.at(eventsCounter + removeCount)->expandedEvent(),
                               newEvents.at(newEventsCounter))))
            removeCount++;

        if (removeCount) {
            Q_ASSERT(false == reset);
            beginRemoveRows(QModelIndex(), mEventsIndex, mEventsIndex + removeCount - 1);
            mEvents.erase(mEvents.begin() + mEventsIndex, mEvents.begin() + mEventsIndex + removeCount);
            endRemoveRows();
            for (int ii = eventsCounter; ii < eventsCounter + removeCount; ++ii)
                delete events.at(ii);
            eventsCounter += removeCount;
        }

        // Skip matching events
        while (eventsCounter < events.count() && newEventsCounter < newEvents.count() &&
               eventsEqual(newEvents.at(newEventsCounter), events.at(eventsCounter)->expandedEvent())) {
            Q_ASSERT(false == reset);
            eventsCounter++;
            newEventsCounter++;
            mEventsIndex++;
        }

        // Insert new events
        int insertCount = 0;
        while ((newEventsCounter + insertCount) < newEvents.count() && 
               (eventsCounter >= events.count() ||
                eventsLessThan(newEvents.at(newEventsCounter + insertCount),
                               events.at(eventsCounter)->expandedEvent())))
            insertCount++;

        if (insertCount) {
            if (!reset) beginInsertRows(QModelIndex(), mEventsIndex, mEventsIndex + insertCount - 1);
            for (int ii = 0; ii < insertCount; ++ii) {
                NemoCalendarEventOccurrence *event = 
                    new NemoCalendarEventOccurrence(newEvents.at(newEventsCounter + ii));
                mEvents.insert(mEventsIndex++, event);
            }
            newEventsCounter += insertCount;
            if (!reset) endInsertRows();
        }
    }

    if (reset)
        endResetModel();

    if (oldEventCount != mEvents.count())
        emit countChanged();
}
开发者ID:blammit,项目名称:nemo-qml-plugin-calendar,代码行数:88,代码来源:calendaragendamodel.cpp

示例8: q_

void HelpDialog::updateHelpText(void) const
{
	QString htmlText = "<html><head><title>";
	htmlText += q_("Stellarium Help").toHtmlEscaped();
	htmlText += "</title></head><body>\n";

	// WARNING! Section titles are re-used below!
	htmlText += "<p align=\"center\"><a href=\"#keys\">" +
		    q_("Keys").toHtmlEscaped() +
		    "</a> &bull; <a href=\"#links\">" +
		    q_("Further Reading").toHtmlEscaped() +
		    "</a></p>\n";

	htmlText += "<h2 id='keys'>" + q_("Keys").toHtmlEscaped() + "</h2>\n";
	htmlText += "<table cellpadding=\"10%\">\n";
	// Describe keys for those keys which do not have actions.
	// navigate
	htmlText += "<tr><td>" + q_("Pan view around the sky").toHtmlEscaped() + "</td>";
	htmlText += "<td><b>" + q_("Arrow keys & left mouse drag").toHtmlEscaped() + "</b></td></tr>\n";
	// zoom in/out
	htmlText += "<tr><td rowspan='2'>" + q_("Zoom in/out").toHtmlEscaped() +
		    "</td>";
	htmlText += "<td><b>" + q_("Page Up/Down").toHtmlEscaped() +
		    "</b></td></tr>\n";
	htmlText += "<tr><td><b>" + q_("Ctrl+Up/Down").toHtmlEscaped() +
		    "</b></td></tr>\n";
	// time dragging/scrolling
	htmlText += "<tr><td>" + q_("Time dragging").toHtmlEscaped() + "</td><td><b>" +
			q_("Ctrl & left mouse drag").toHtmlEscaped() + "</b></td></tr>";
	htmlText += "<tr><td>" + q_("Time scrolling: minutes").toHtmlEscaped() + "</td><td><b>" +
			q_("Ctrl & mouse wheel").toHtmlEscaped() + "</b></td></tr>";
	htmlText += "<tr><td>" + q_("Time scrolling: hours").toHtmlEscaped() + "</td><td><b>" +
			q_("Ctrl+Shift & mouse wheel").toHtmlEscaped() + "</b></td></tr>";
	htmlText += "<tr><td>" + q_("Time scrolling: days").toHtmlEscaped() + "</td><td><b>" +
			q_("Ctrl+Alt & mouse wheel").toHtmlEscaped() + "</b></td></tr>";
	htmlText += "<tr><td>" + q_("Time scrolling: years").toHtmlEscaped() + "</td><td><b>" +
			q_("Ctrl+Alt+Shift & mouse wheel").toHtmlEscaped() + "</b></td></tr>";

	// select object
	htmlText += "<tr><td>" + q_("Select object").toHtmlEscaped() + "</td>";
	htmlText += "<td><b>" + q_("Left click").toHtmlEscaped() + "</b></td></tr>\n";
	// clear selection
	htmlText += "<tr><td>";
	htmlText += q_("Clear selection").toHtmlEscaped() + "</td>";
#ifdef Q_OS_MAC
	htmlText += "<td><b>" + q_("Ctrl & left click").toHtmlEscaped() + "</b></td></tr>\n";
#else
	htmlText += "<td><b>" + q_("Right click").toHtmlEscaped() + "</b></td></tr>\n";
#endif
	// add custom marker
	htmlText += "<tr><td>" + q_("Add custom marker").toHtmlEscaped() + "</td>";
	htmlText += "<td><b>" + q_("Shift & left click").toHtmlEscaped() + "</b></td></tr>\n";
	// delete one custom marker
	htmlText += "<tr><td>" + q_("Delete marker closest to mouse cursor").toHtmlEscaped() + "</td>";
	htmlText += "<td><b>" + q_("Shift & right click").toHtmlEscaped() + "</b></td></tr>\n";
	// delete all custom markers
	htmlText += "<tr><td>" + q_("Delete all custom markers").toHtmlEscaped() + "</td>";
	htmlText += "<td><b>" + q_("Shift & Alt & right click").toHtmlEscaped() + "</b></td></tr>\n";

	htmlText += "</table>\n<p>" +
			q_("Below are listed only the actions with assigned keys. Further actions may be available via the \"%1\" button.")
			.arg(ui->editShortcutsButton->text()).toHtmlEscaped() +
		    "</p><table cellpadding=\"10%\">\n";

	// Append all StelAction shortcuts.
	StelActionMgr* actionMgr = StelApp::getInstance().getStelActionManager();
	typedef QPair<QString, QString> KeyDescription;
	for (auto group : actionMgr->getGroupList())
	{
		QList<KeyDescription> descriptions;
		for (auto* action : actionMgr->getActionList(group))
		{
			if (action->getShortcut().isEmpty())
				continue;
			QString text = action->getText();
			QString key =  action->getShortcut().toString(QKeySequence::NativeText);
			descriptions.append(KeyDescription(text, key));
		}
		qSort(descriptions);
		htmlText += "<tr></tr><tr><td><b><u>" + q_(group) +
			    ":</u></b></td></tr>\n";
		for (const auto& desc : descriptions)
		{
			htmlText += "<tr><td>" + desc.first.toHtmlEscaped() + "</td>";
			htmlText += "<td><b>" + desc.second.toHtmlEscaped() +
				    "</b></td></tr>\n";
		}
	}

	htmlText += "<tr></tr><tr><td><b><u>" + q_("Text User Interface (TUI)") +
		    ":</u></b></td></tr>\n";
	htmlText += "<tr><td>" + q_("Activate TUI") + "</td>";
	htmlText += "<td><b>Alt+T</b></td></tr>\n";
	htmlText += "</table>";

	// Regexp to replace {text} with an HTML link.
	QRegExp a_rx = QRegExp("[{]([^{]*)[}]");

	// WARNING! Section titles are re-used above!
	htmlText += "<h2 id=\"links\">" + q_("Further Reading").toHtmlEscaped() + "</h2>\n";
//.........这里部分代码省略.........
开发者ID:Stellarium,项目名称:stellarium,代码行数:101,代码来源:HelpDialog.cpp

示例9: qDebug

void AbstractPort::updatePacketListSequential()
{
    long    sec = 0; 
    long    nsec = 0;

    qDebug("In %s", __FUNCTION__);

    // First sort the streams by ordinalValue
    qSort(streamList_.begin(), streamList_.end(), StreamBase::StreamLessThan);

    clearPacketList();

    for (int i = 0; i < streamList_.size(); i++)
    {
        if (streamList_[i]->isEnabled())
        {
            int len = 0;
            ulong n, x, y;
            ulong burstSize;
            double ibg = 0;
            quint64 ibg1 = 0, ibg2 = 0;
            quint64 nb1 = 0, nb2 = 0;
            double ipg = 0;
            quint64 ipg1 = 0, ipg2 = 0;
            quint64 npx1 = 0, npx2 = 0;
            quint64 npy1 = 0, npy2 = 0;
            quint64 loopDelay;
            ulong frameVariableCount = streamList_[i]->frameVariableCount();

            // We derive n, x, y such that
            // n * x + y = total number of packets to be sent

            switch (streamList_[i]->sendUnit())
            {
            case OstProto::StreamControl::e_su_bursts:
                burstSize = streamList_[i]->burstSize();
                x = AbstractProtocol::lcm(frameVariableCount, burstSize);
                n = ulong(burstSize * streamList_[i]->numBursts()) / x;
                y = ulong(burstSize * streamList_[i]->numBursts()) % x;
                if (streamList_[i]->burstRate() > 0)
                {
                    ibg = 1e9/double(streamList_[i]->burstRate());
                    ibg1 = quint64(ceil(ibg));
                    ibg2 = quint64(floor(ibg));
                    nb1  = quint64((ibg - double(ibg2)) * double(x));
                    nb2  = x - nb1;
                }
                loopDelay = ibg2;
                break;
            case OstProto::StreamControl::e_su_packets:
                x = frameVariableCount;
                n = 2;
                while (x < minPacketSetSize_) 
                    x = frameVariableCount*n++;
                n = streamList_[i]->numPackets() / x;
                y = streamList_[i]->numPackets() % x;
                burstSize = x + y;
                if (streamList_[i]->packetRate() > 0)
                {
                    ipg = 1e9/double(streamList_[i]->packetRate());
                    ipg1 = quint64(ceil(ipg));
                    ipg2 = quint64(floor(ipg));
                    npx1  = quint64((ipg - double(ipg2)) * double(x));
                    npx2  = x - npx1;
                    npy1  = quint64((ipg - double(ipg2)) * double(y));
                    npy2  = y - npy1;
                }
                loopDelay = ipg2;
                break;
            default:
                qWarning("Unhandled stream control unit %d",
                    streamList_[i]->sendUnit());
                continue;
            }

            qDebug("\nframeVariableCount = %lu", frameVariableCount);
            qDebug("n = %lu, x = %lu, y = %lu, burstSize = %lu",
                    n, x, y, burstSize);

            qDebug("ibg  = %g", ibg);
            qDebug("ibg1 = %" PRIu64, ibg1);
            qDebug("nb1  = %" PRIu64, nb1);
            qDebug("ibg2 = %" PRIu64, ibg2);
            qDebug("nb2  = %" PRIu64 "\n", nb2);

            qDebug("ipg  = %g", ipg);
            qDebug("ipg1 = %" PRIu64, ipg1);
            qDebug("npx1 = %" PRIu64, npx1);
            qDebug("npy1 = %" PRIu64, npy1);
            qDebug("ipg2 = %" PRIu64, ipg2);
            qDebug("npx2 = %" PRIu64, npx2);
            qDebug("npy2 = %" PRIu64 "\n", npy2);

            if (n > 1)
                loopNextPacketSet(x, n, 0, loopDelay);
            else if (n == 0)
                x = 0;

            for (uint j = 0; j < (x+y); j++)
            {
//.........这里部分代码省略.........
开发者ID:anju61188,项目名称:ostinato,代码行数:101,代码来源:abstractport.cpp

示例10: quint64

void AbstractPort::updatePacketListInterleaved()
{
    int numStreams = 0;
    quint64 minGap = ULLONG_MAX;
    quint64 duration = quint64(1e9);
    QList<quint64> ibg1, ibg2;
    QList<quint64> nb1, nb2;
    QList<quint64> ipg1, ipg2;
    QList<quint64> np1, np2;
    QList<ulong> schedSec, schedNsec;
    QList<ulong> pktCount, burstCount;
    QList<ulong> burstSize;
    QList<bool> isVariable;
    QList<QByteArray> pktBuf;
    QList<ulong> pktLen;

    qDebug("In %s", __FUNCTION__);

    // First sort the streams by ordinalValue
    qSort(streamList_.begin(), streamList_.end(), StreamBase::StreamLessThan);

    clearPacketList();

    for (int i = 0; i < streamList_.size(); i++)
    {
        if (!streamList_[i]->isEnabled())
            continue;

        double numBursts = 0;
        double numPackets = 0;

        quint64 _burstSize = 0;
        double ibg = 0;
        quint64 _ibg1 = 0, _ibg2 = 0;
        quint64 _nb1 = 0, _nb2 = 0;
        double ipg = 0;
        quint64 _ipg1 = 0, _ipg2 = 0;
        quint64 _np1 = 0, _np2 = 0;

        switch (streamList_[i]->sendUnit())
        {
        case OstProto::StreamControl::e_su_bursts:
            numBursts = streamList_[i]->burstRate();
            if (streamList_[i]->burstRate() > 0)
            {
                ibg = 1e9/double(streamList_[i]->burstRate());
                _ibg1 = quint64(ceil(ibg));
                _ibg2 = quint64(floor(ibg));
                _nb1 = quint64((ibg - double(_ibg2)) * double(numBursts));
                _nb2 = quint64(numBursts) - _nb1;
                _burstSize = streamList_[i]->burstSize();
            }
            break;
        case OstProto::StreamControl::e_su_packets:
            numPackets = streamList_[i]->packetRate();
            if (streamList_[i]->packetRate() > 0)
            {
                ipg = 1e9/double(streamList_[i]->packetRate());
                _ipg1 = llrint(ceil(ipg));
                _ipg2 = quint64(floor(ipg));
                _np1 = quint64((ipg - double(_ipg2)) * double(numPackets));
                _np2 = quint64(numPackets) - _np1;
                _burstSize = 1;
            }
            break;
        default:
            qWarning("Unhandled stream control unit %d",
                streamList_[i]->sendUnit());
            continue;
        }
        qDebug("numBursts = %g, numPackets = %g\n", numBursts, numPackets);

        qDebug("ibg  = %g", ibg);
        qDebug("ibg1 = %" PRIu64, _ibg1);
        qDebug("nb1  = %" PRIu64, _nb1);
        qDebug("ibg2 = %" PRIu64, _ibg2);
        qDebug("nb2  = %" PRIu64 "\n", _nb2);

        qDebug("ipg  = %g", ipg);
        qDebug("ipg1 = %" PRIu64, _ipg1);
        qDebug("np1  = %" PRIu64, _np1);
        qDebug("ipg2 = %" PRIu64, _ipg2);
        qDebug("np2  = %" PRIu64 "\n", _np2);


        if (_ibg2 && (_ibg2 < minGap))
            minGap = _ibg2;

        if (_ibg1 && (_ibg1 > duration))
            duration = _ibg1;

        ibg1.append(_ibg1);
        ibg2.append(_ibg2);

        nb1.append(_nb1);
        nb2.append(_nb1);

        burstSize.append(_burstSize);

        if (_ipg2 && (_ipg2 < minGap))
//.........这里部分代码省略.........
开发者ID:anju61188,项目名称:ostinato,代码行数:101,代码来源:abstractport.cpp

示例11: clearFilter

void KexiFileWidget::updateFilters()
{
    if (d->filtersUpdated)
        return;
    d->filtersUpdated = true;

    d->lastFileName.clear();
// m_lastUrl = KUrl();

    clearFilter();

    QString filter;
    KMimeType::Ptr mime;
    QStringList allfilters;

    const bool normalOpeningMode = d->mode & Opening && !(d->mode & Custom);
    const bool normalSavingMode = d->mode & SavingFileBasedDB && !(d->mode & Custom);

    if (normalOpeningMode || normalSavingMode) {
        mime = KMimeType::mimeType(KexiDB::defaultFileBasedDriverMimeType());
        if (mime && !d->excludedMimeTypes.contains(mime->name().toLower())) {
            filter += KexiUtils::fileDialogFilterString(mime);
            allfilters += mime->patterns();
        }
    }
    if (normalOpeningMode || d->mode & SavingServerBasedDB) {
        mime = KMimeType::mimeType("application/x-kexiproject-shortcut");
        if (mime && !d->excludedMimeTypes.contains(mime->name().toLower())) {
            filter += KexiUtils::fileDialogFilterString(mime);
            allfilters += mime->patterns();
        }
    }
    if (normalOpeningMode || d->mode & SavingServerBasedDB) {
        mime = KMimeType::mimeType("application/x-kexi-connectiondata");
        if (mime && !d->excludedMimeTypes.contains(mime->name().toLower())) {
            filter += KexiUtils::fileDialogFilterString(mime);
            allfilters += mime->patterns();
        }
    }

//! @todo hardcoded for MSA:
    if (normalOpeningMode) {
        mime = KMimeType::mimeType("application/vnd.ms-access");
        if (mime && !d->excludedMimeTypes.contains(mime->name().toLower())) {
            filter += KexiUtils::fileDialogFilterString(mime);
            allfilters += mime->patterns();
        }
    }

    foreach(const QString& mimeName, d->additionalMimeTypes) {
        if (mimeName == "all/allfiles")
            continue;
        if (d->excludedMimeTypes.contains(mimeName.toLower()))
            continue;
        filter += KexiUtils::fileDialogFilterString(mimeName);
        mime = KMimeType::mimeType(mimeName);
        allfilters += mime->patterns();
    }

    if (!d->excludedMimeTypes.contains("all/allfiles"))
        filter += KexiUtils::fileDialogFilterString("all/allfiles");
// mime = KMimeType::mimeType("all/allfiles");
// if (mime) {
//  filter += QString(mime->patterns().isEmpty() ? "*" : mime->patterns().join(" "))
//   + "|" + mime->comment()+ " (*)\n";
// }
    //remove duplicates made because upper- and lower-case extenstions are used:
    QStringList allfiltersUnique = allfilters.toSet().toList();
    qSort(allfiltersUnique);

    if (allfiltersUnique.count() > 1) {//prepend "all supoported files" entry
        filter.prepend(allfilters.join(" ") + "|"
                       + i18n("All Supported Files (%1)", allfiltersUnique.join(", ")) + "\n");
    }

    if (filter.right(1) == "\n")
        filter.truncate(filter.length() - 1);
    setFilter(filter);

    if (d->mode & Opening) {
        KFileWidget::setMode(KFile::ExistingOnly | KFile::LocalOnly | KFile::File);
        setOperationMode(KFileWidget::Opening);
    } else {
        KFileWidget::setMode(KFile::LocalOnly | KFile::File);
        setOperationMode(KFileWidget::Saving);
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:87,代码来源:KexiFileWidget.cpp

示例12: QLatin1Char

bool KArchiveDirectory::copyTo(const QString &dest, bool recursiveCopy) const
{
    QDir root;

    QList<const KArchiveFile *> fileList;
    QMap<qint64, QString> fileToDir;

    // placeholders for iterated items
    QStack<const KArchiveDirectory *> dirStack;
    QStack<QString> dirNameStack;

    dirStack.push(this);       // init stack at current directory
    dirNameStack.push(dest);   // ... with given path
    do {
        const KArchiveDirectory *curDir = dirStack.pop();
        const QString curDirName = dirNameStack.pop();
        if (!root.mkpath(curDirName)) {
            return false;
        }

        const QStringList dirEntries = curDir->entries();
        for (QStringList::const_iterator it = dirEntries.begin(); it != dirEntries.end(); ++it) {
            const KArchiveEntry *curEntry = curDir->entry(*it);
            if (!curEntry->symLinkTarget().isEmpty()) {
                QString linkName = curDirName + QLatin1Char('/') + curEntry->name();
                // To create a valid link on Windows, linkName must have a .lnk file extension.
#ifdef Q_OS_WIN
                if (!linkName.endsWith(QStringLiteral(".lnk"))) {
                    linkName += QStringLiteral(".lnk");
                }
#endif
                QFile symLinkTarget(curEntry->symLinkTarget());
                if (!symLinkTarget.link(linkName)) {
                    //qDebug() << "symlink(" << curEntry->symLinkTarget() << ',' << linkName << ") failed:" << strerror(errno);
                }
            } else {
                if (curEntry->isFile()) {
                    const KArchiveFile *curFile = dynamic_cast<const KArchiveFile *>(curEntry);
                    if (curFile) {
                        fileList.append(curFile);
                        fileToDir.insert(curFile->position(), curDirName);
                    }
                }

                if (curEntry->isDirectory() && recursiveCopy) {
                    const KArchiveDirectory *ad = dynamic_cast<const KArchiveDirectory *>(curEntry);
                    if (ad) {
                        dirStack.push(ad);
                        dirNameStack.push(curDirName + QLatin1Char('/') + curEntry->name());
                    }
                }
            }
        }
    } while (!dirStack.isEmpty());

    qSort(fileList.begin(), fileList.end(), sortByPosition);    // sort on d->pos, so we have a linear access

    for (QList<const KArchiveFile *>::const_iterator it = fileList.constBegin(), end = fileList.constEnd();
            it != end; ++it) {
        const KArchiveFile *f = *it;
        qint64 pos = f->position();
        if (!f->copyTo(fileToDir[pos])) {
            return false;
        }
    }
    return true;
}
开发者ID:parulina,项目名称:parupaint,代码行数:67,代码来源:karchive.cpp

示例13: main

int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);
    QTextCodec *big5 = QTextCodec::codecForName("Big5-hkscs");

#if 0
    QFile f("/home/lars/dev/qt-4.0/util/unicode/data/big5-eten.txt");
    f.open(QFile::ReadOnly);

    while (!f.atEnd()) {
        QByteArray line = f.readLine();
        if (line.startsWith("#"))
            continue;
        line.replace("0x", "");
        line.replace("U+", "");
        line.replace("\t", " ");
        line = line.simplified();
        QList<QByteArray> split = line.split(' ');
        bool ok;
        int b5 = split.at(0).toInt(&ok, 16);
        Q_ASSERT(ok);
        int uc = split.at(1).toInt(&ok, 16);
        Q_ASSERT(ok);
        if (b5 < 0x100)
            continue;
#else
    QFile f(":/BIG5");
    f.open(QFile::ReadOnly);

    while (!f.atEnd()) {
        QByteArray line = f.readLine();
        if (line.startsWith("CHARMAP"))
            break;
    }
    QSet<uint> b5_ok;
    QSet<uint> uc_ok;
    QList<Map> b5_to_uc_map;
    QList<Map> uc_to_b5_map;
    while (!f.atEnd()) {
        QByteArray line = f.readLine();
        if (line.startsWith("%"))
            continue;
        if (line.startsWith("END CHARMAP"))
            break;
        line.replace("/x", "");
        line.replace("<U", "");
        line.replace(">", "");
        line.replace("\t", " ");
        line = line.simplified();
        QList<QByteArray> split = line.split(' ');
        bool ok;
        int b5 = split.at(1).toInt(&ok, 16);
        Q_ASSERT(ok);
        int uc = split.at(0).toInt(&ok, 16);
        Q_ASSERT(ok);
        if (b5 < 0x100 || uc > 0xffff)
            continue;
#endif

//         qDebug() << hex << "testing: '" << b5 << "' - '" << uc << "'";
        QByteArray ba;

        ba += (char)(uchar)(b5 >> 8);
        ba += (char)(uchar)(b5 & 0xff);

        QString s = big5->toUnicode(ba);
        Q_ASSERT(s.length() == 1);
        QString s2;
        s2 = QChar(uc);
        ba = big5->fromUnicode(s2);
        Q_ASSERT(ba.length() <= 2);
        int round;
        if (ba.length() == 1)
            round = (int)(uchar)ba[0];
        else
            round = ((int)(uchar)ba[0] << 8) + (int)(uchar)ba[1];
        if (b5 != round)
            uc_to_b5_map += Map(uc, b5);
        else
            b5_ok.insert(b5);

        if (s[0].unicode() != uc)
            b5_to_uc_map += Map(uc, b5);
        else
            uc_ok.insert(uc);
    };

    QList<QByteArray> list;
    foreach(Map m, b5_to_uc_map) {
        if (!uc_ok.contains(m.b5))
            list += QByteArray("    { 0x" + QByteArray::number(m.b5, 16) + ", 0x" + QByteArray::number(m.uc, 16) + " }\n");;
    }
    QByteArray ba;
    qSort(list);
    foreach(QByteArray a, list)
        ba += a;
    qDebug() << "struct B5Map b5_to_uc_map = {\n" << ba + "\n};";

    list = QList<QByteArray>();
    foreach(Map m, uc_to_b5_map)
//.........这里部分代码省略.........
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:101,代码来源:main.cpp

示例14: in


//.........这里部分代码省略.........

        query.append( " ( articoli.id in ( " ) ;
        query.append( " select idarticolo from articoli_autori where " ) ;

        for ( QStringList::iterator it = lista_autori.begin() ; it < lista_autori.end() ; it++ )
        {
            query.append( " ( idautore in ( " ) ;
            query.append( " select id from autori where Autore like \"" ) ;
            query.append( *it ) ;
            query.append( "\" ) ) " ) ;
            if ( it < lista_autori.end() - 1 )
            {
                query.append( " OR " ) ;
            }
        }

        query.append( " ) ) " ) ;
        prevq = true ;
    }

    if ( anno && lista_anni.size() > 0 )
    {
        if ( prevq )
        {
            query.append( logical_global ) ;
            prevq = false ;
        }

        typedef QPair<int,int> yearsInterval ;
        QList<yearsInterval> years ;

        int a1 , a2 ;

        qSort( lista_anni.begin() , lista_anni.end() , StrIntLessThan ) ;

        for ( QStringList::iterator it = lista_anni.begin() ; it < lista_anni.end() ; it++ )
        {
            qDebug() << *it ;

            a1 = (*it).toInt() ;

            if ( it+1 < lista_anni.end() )
                a2 = (*(it+1)).toInt() ;
            else
                a2 = a1 ;

            if ( ( a2 - a1 ) == 1  )
            {
                int a3 = a1 ;
                int a4 ;
                QStringList::iterator it_b ;
                for ( it_b = it + 1 ; it_b < lista_anni.end() ; it_b++ )
                {
                    a4 = (*it_b).toInt() ;
                    if ( a4 - a3 == 1 )
                        a3 = a4 ;
                    else
                        break ;
                }
                yearsInterval y_int ;
                y_int.first = a1 ;
                y_int.second = a3 ;
                years.append( y_int );

                it = it_b-1 ;
开发者ID:simon-r,项目名称:-Archivio---LeScienze500,代码行数:66,代码来源:querydb_mainq.cpp

示例15: parentView

void LocalScene::populateTopRatedArtist(int YPos)
{
    int artistRow  = 0;
    int Column     = 0;
    item_count = (parentView()->width()/160 > 2) ? parentView()->width()/160 : 2;
    int char_entry = 0;

    CategorieGraphicItem *category = new CategorieGraphicItem(qobject_cast<QGraphicsView*> (parentView())->viewport());
    category->m_name = QString(tr("Top rated artists"));
    category->setPos(0 ,YPos);
    addItem(category);

    //! get artists List from LocalTrackModel
    QList<MEDIA::ArtistPtr> artists;
    for (int i=0 ; i < m_localTrackModel->rootItem()->childCount(); i++ ) {
       artists << MEDIA::ArtistPtr::staticCast(m_localTrackModel->rootItem()->child(i));
     }

    //! sort
    qSort(artists.begin(), artists.end(), MEDIA::compareArtistItemRating);

    //! loop over artist MediaItem
    foreach(MEDIA::ArtistPtr artist, artists)
    {
      if(artist->rating == 0.0 || char_entry == MAX_CHART_ENTRY) break;

      if( !m_localTrackModel->isMediaMatch(artist) ) continue;

      ArtistGraphicItem_v3 *artist_item = new ArtistGraphicItem_v3();
      artist_item->media = artist;
      artist_item->setPos(4+160*Column, YPos + 35 + artistRow*190);

      addItem(artist_item);
      char_entry++;

      /* ALBUM COVER LOOP */
        artist_item->albums_covers.clear();
        for(int j = artist->childCount()-1 ; j >= 0; j--) {
          if(!m_localTrackModel->isMediaMatch(artist->child(j)) ) continue;
          MEDIA::AlbumPtr album = MEDIA::AlbumPtr::staticCast(artist->child(j));

          artist_item->albums_covers.prepend(album);

          /* WARNING limite de l'affichage à 6 cover max */
          if(artist_item->albums_covers.size() >=6) break;
        }

      if(Column < (item_count-1)) {
        Column++;
      }
      else {
        Column = 0;
        artistRow++;
      }
    }

    //! si liste vide --> message
    if(char_entry==0) {
      InfoGraphicItem *info = new InfoGraphicItem(qobject_cast<QGraphicsView*> (parentView())->viewport());
      info->_text = tr("No entry found");
      info->setPos( 0 , YPos + 50);
      addItem(info);
    }
}
开发者ID:kehugter,项目名称:Yarock,代码行数:64,代码来源:local_scene_dashboard.cpp


注:本文中的qSort函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。