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


C++ QList::first方法代码示例

本文整理汇总了C++中QList::first方法的典型用法代码示例。如果您正苦于以下问题:C++ QList::first方法的具体用法?C++ QList::first怎么用?C++ QList::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QList的用法示例。


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

示例1: read_cprops

void qapp::read_cprops(void)  // read app defaults
{
	QString fname,cline,name,par;
	int flags;
	int apnum = 1;
	
	fname = get_cfile("appdefaults");
	
	if(fname.isNull())
		return;
	
	QFile istr(fname);
	
	if(! istr.open(IO_ReadOnly))
	{
		perror("cannot open appdefaults");
		return;
	}	
	cprops.clear();
	apclients.clear();
	
	while(! istr.atEnd())
	{
		istr.readLine(cline, 1024);
		QTextIStream si(&cline);
	
		si >> name;
		par = si.readLine();

		if(par.find("ToolBar") != -1)
		{
			apclients.insert(name, apnum++);
			continue;
		}
	
		flags = 0;	
		
		int i;
		int paf[] = { WindowListSkip,Sticky,SmallFrame,NoResize,NoTile,NoKey,NoScreen };
		char *pas[] = { "WindowListSkip","Sticky","SmallFrame","NoResize","NoTile","NoKey","NoScreen" };

		for(i=0; i < 7; i++)
		{
			if(par.find(pas[i]) != -1)
				flags |= paf[i];
		}
		
		if(flags)
			cprops.insert(name, flags);
	}
	istr.close();

	// check for clients to update
		
	xwindow *client;
		
	for(client = clients.first(); client != NULL; client = clients.next())
		client->set_pflags();
			
	tb_ap->remove();  // update clients on toolbar
}
开发者ID:nic0lae,项目名称:freebsddistro,代码行数:61,代码来源:qapp.cpp

示例2: QMainWindow


//.........这里部分代码省略.........
    action->setShortcut(Qt::CTRL + Qt::Key_S);


    menu->addSeparator();

    pixmap = QPixmap(::scan);
    action = tools->addAction(pixmap,"Scan", this, SLOT(save()));
    action->setWhatsThis(ScanText);
    action->setToolTip("scan");

    action = menu->addAction(pixmap,"S&can", this, SLOT(save()));
    action->setWhatsThis(ScanText);
    action->setToolTip("scan");
    action->setShortcut(Qt::CTRL + Qt::Key_C);



    menu->addSeparator();


    action = menu->addAction("&Quit", this, SLOT(quit()), Qt::CTRL + Qt::Key_Q);

    //menu = new QMenu(this);
    menu = menuBar()->addMenu("&Browse");

    pixmap = QPixmap(browsersearch);
    action = tools->addAction(pixmap,"Search", this, SLOT(browser_search()));
    action->setWhatsThis(SearchText);
    action->setToolTip("Search");

    action = menu->addAction(pixmap,"&Search", this, SLOT(browser_search()));
    action->setWhatsThis(SearchText);
    action->setToolTip("Search");
    action->setShortcut(Qt::CTRL + Qt::Key_S);


    pixmap = QPixmap(left_xpm);
    action = tools->addAction(pixmap,"Back", this, SLOT(historic_back()));
    action->setWhatsThis(LeftText);
    action->setToolTip("back");

    pixmap = QPixmap(right_xpm);
    action = tools->addAction(pixmap,"Forward", this, SLOT(historic_forward()));
    action->setWhatsThis(RightText);
    action->setToolTip("forward");

    action = tools->addAction(QApplication::style()->standardIcon(QStyle::SP_TitleBarContextHelpButton).pixmap(200,2000), "Whats's this?",
                               this, SLOT(whats_this()));



    //(void)QWhatsThis::whatsThisButton(tools);

    //

    //menu = new QMenu(this);
    menu = menuBar()->addMenu("&Style");

#if !defined(QT_NO_STYLE_MOTIF)
    menu->addAction("Motif", this, SLOT(motif_style()));
#endif
#if !defined(QT_NO_STYLE_MOTIFPLUS)
    menu->addAction("MotifPlus", this, SLOT(motifplus_style()));
#endif
    menu->addAction("Windows", this, SLOT(windows_style()));

    //

    menuBar()->addSeparator();
    //menu = new QMenu(this);
    menu = menuBar()->addMenu("&Help");

    menu->addAction("&About", this, SLOT(about()), Qt::Key_F1);
    menu->addAction("About&Qt", this, SLOT(aboutQt()));
    menu->addSeparator();
    menu->addAction("What's This", this, SLOT(whatsThis()), Qt::SHIFT + Qt::Key_F1);

    //

    spl = new QSplitter(Qt::Vertical, this/*, "spl"*/);

    browser = new BrowserView(spl);
    comment = new CommentView(spl);

    connect(comment, SIGNAL(refer(const QString &)),
            browser, SLOT(refer(const QString &)));

    spl->addWidget(browser);

    QList<int> lsz = spl->sizes();
    int h = lsz.first() + lsz.last();

    lsz.first() = (h * 3) / 4;
    lsz.last() = h - lsz.first();

    spl->setSizes(lsz);

    //spl->setResizeMode(comment, QSplitter::KeepSize);
    setCentralWidget(spl);
}
开发者ID:gilbertoca,项目名称:douml,代码行数:101,代码来源:JavaCatWindow.cpp

示例3: calculateStatistics


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

    statisticsFromMiddlePointTest( featureGeometry, offsetX, offsetY, nCellsX, nCellsY, cellsizeX, cellsizeY,
                                   rasterBBox, featureStats );

    if ( featureStats.count <= 1 )
    {
      //the cell resolution is probably larger than the polygon area. We switch to precise pixel - polygon intersection in this case
      statisticsFromPreciseIntersection( featureGeometry, offsetX, offsetY, nCellsX, nCellsY, cellsizeX, cellsizeY,
                                         rasterBBox, featureStats );
    }

    //write the statistics value to the vector data provider
    QgsAttributeMap changeAttributeMap;
    if ( mStatistics & QgsZonalStatistics::Count )
      changeAttributeMap.insert( countIndex, QVariant( featureStats.count ) );
    if ( mStatistics & QgsZonalStatistics::Sum )
      changeAttributeMap.insert( sumIndex, QVariant( featureStats.sum ) );
    if ( featureStats.count > 0 )
    {
      double mean = featureStats.sum / featureStats.count;
      if ( mStatistics & QgsZonalStatistics::Mean )
        changeAttributeMap.insert( meanIndex, QVariant( mean ) );
      if ( mStatistics & QgsZonalStatistics::Median )
      {
        std::sort( featureStats.values.begin(), featureStats.values.end() );
        int size =  featureStats.values.count();
        bool even = ( size % 2 ) < 1;
        double medianValue;
        if ( even )
        {
          medianValue = ( featureStats.values.at( size / 2 - 1 ) + featureStats.values.at( size / 2 ) ) / 2;
        }
        else //odd
        {
          medianValue = featureStats.values.at( ( size + 1 ) / 2 - 1 );
        }
        changeAttributeMap.insert( medianIndex, QVariant( medianValue ) );
      }
      if ( mStatistics & QgsZonalStatistics::StDev || mStatistics & QgsZonalStatistics::Variance )
      {
        double sumSquared = 0;
        for ( int i = 0; i < featureStats.values.count(); ++i )
        {
          double diff = featureStats.values.at( i ) - mean;
          sumSquared += diff * diff;
        }
        double variance = sumSquared / featureStats.values.count();
        if ( mStatistics & QgsZonalStatistics::StDev )
        {
          double stdev = std::pow( variance, 0.5 );
          changeAttributeMap.insert( stdevIndex, QVariant( stdev ) );
        }
        if ( mStatistics & QgsZonalStatistics::Variance )
          changeAttributeMap.insert( varianceIndex, QVariant( variance ) );
      }
      if ( mStatistics & QgsZonalStatistics::Min )
        changeAttributeMap.insert( minIndex, QVariant( featureStats.min ) );
      if ( mStatistics & QgsZonalStatistics::Max )
        changeAttributeMap.insert( maxIndex, QVariant( featureStats.max ) );
      if ( mStatistics & QgsZonalStatistics::Range )
        changeAttributeMap.insert( rangeIndex, QVariant( featureStats.max - featureStats.min ) );
      if ( mStatistics & QgsZonalStatistics::Minority || mStatistics & QgsZonalStatistics::Majority )
      {
        QList<int> vals = featureStats.valueCount.values();
        std::sort( vals.begin(), vals.end() );
        if ( mStatistics & QgsZonalStatistics::Minority )
        {
          float minorityKey = featureStats.valueCount.key( vals.first() );
          changeAttributeMap.insert( minorityIndex, QVariant( minorityKey ) );
        }
        if ( mStatistics & QgsZonalStatistics::Majority )
        {
          float majKey = featureStats.valueCount.key( vals.last() );
          changeAttributeMap.insert( majorityIndex, QVariant( majKey ) );
        }
      }
      if ( mStatistics & QgsZonalStatistics::Variety )
        changeAttributeMap.insert( varietyIndex, QVariant( featureStats.valueCount.count() ) );
    }

    changeMap.insert( f.id(), changeAttributeMap );
    ++featureCounter;
  }

  vectorProvider->changeAttributeValues( changeMap );

  if ( feedback )
  {
    feedback->setProgress( 100 );
  }

  mPolygonLayer->updateFields();

  if ( feedback && feedback->isCanceled() )
  {
    return 9;
  }

  return 0;
}
开发者ID:exlimit,项目名称:QGIS,代码行数:101,代码来源:qgszonalstatistics.cpp

示例4: if

QgsGraduatedSymbolRendererV2* QgsGraduatedSymbolRendererV2::createRenderer(
  QgsVectorLayer* vlayer,
  QString attrName,
  int classes,
  Mode mode,
  QgsSymbolV2* symbol,
  QgsVectorColorRampV2* ramp,
  bool inverted )
{
  if ( classes < 1 )
    return NULL;

  int attrNum = vlayer->fieldNameIndex( attrName );
  double minimum;
  double maximum;

  QScopedPointer<QgsExpression> expression;

  if ( attrNum == -1 )
  {
    // try to use expression
    expression.reset( new QgsExpression( attrName ) );
    if ( expression->hasParserError() || !expression->prepare( vlayer->pendingFields() ) )
      return 0; // should have a means to report errors

    QList<double> values;
    QgsFeatureIterator fit = vlayer->getFeatures();
    QgsFeature feature;
    while ( fit.nextFeature( feature ) )
    {
      values << expression->evaluate( feature ).toDouble();
    }
    qSort( values );
    minimum = values.first();
    maximum = values.last();
  }
  else
  {
    minimum = vlayer->minimumValue( attrNum ).toDouble();
    maximum = vlayer->maximumValue( attrNum ).toDouble();
  }

  QgsDebugMsg( QString( "min %1 // max %2" ).arg( minimum ).arg( maximum ) );
  QList<double> breaks;
  QList<int> labels;
  if ( mode == EqualInterval )
  {
    breaks = _calcEqualIntervalBreaks( minimum, maximum, classes );
  }
  else if ( mode == Pretty )
  {
    breaks = _calcPrettyBreaks( minimum, maximum, classes );
  }
  else if ( mode == Quantile || mode == Jenks || mode == StdDev )
  {
    // get values from layer
    QList<double> values;
    QgsFeature f;
    QStringList lst;
    if ( expression.isNull() )
      lst.append( attrName );
    else
      lst = expression->referencedColumns();

    QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFlags( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes( lst, vlayer->pendingFields() ) );

    // create list of non-null attribute values
    while ( fit.nextFeature( f ) )
    {
      QVariant v = expression.isNull() ? f.attribute( attrNum ) : expression->evaluate( f );
      if ( !v.isNull() )
        values.append( v.toDouble() );
    }

    // calculate the breaks
    if ( mode == Quantile )
    {
      breaks = _calcQuantileBreaks( values, classes );
    }
    else if ( mode == Jenks )
    {
      breaks = _calcJenksBreaks( values, classes, minimum, maximum );
    }
    else if ( mode == StdDev )
    {
      breaks = _calcStdDevBreaks( values, classes, labels );
    }
  }
  else
  {
    Q_ASSERT( false );
  }

  QgsRangeList ranges;
  double lower, upper = minimum;
  QString label;

  // "breaks" list contains all values at class breaks plus maximum as last break
  int i = 0;
  for ( QList<double>::iterator it = breaks.begin(); it != breaks.end(); ++it, ++i )
//.........这里部分代码省略.........
开发者ID:lusekelok,项目名称:QGIS,代码行数:101,代码来源:qgsgraduatedsymbolrendererv2.cpp

示例5: if

void K3b::DataPropertiesDialog::loadListProperties( const QList<K3b::DataItem*>& items )
{
    m_labelIcon->setPixmap( DesktopIcon( "document-multiple", KIconLoader::SizeLarge ) );

    int files = 0;
    int folders = 0;
    KIO::filesize_t size = 0;
    K3b::Msf blocks = 0;
    for ( QList<K3b::DataItem*>::iterator it = m_dataItems.begin();
          it != m_dataItems.end(); ++it ) {
        K3b::DataItem* item = *it;
        if ( item->isFile() )
            ++files;
        else if ( item->isDir() )
            ++folders;
        blocks += item->blocks();
        size += item->size();
    }
    QString s = i18np( "One Item", "%1 Items", items.count() );
    s += " - ";
    if ( files > 0 )
        s += i18np( "One File", "%1 Files", files );
    else
        s += i18n( "No Files" );
    s += " - ";
    if ( folders > 0 )
        s += i18np( "One Folder", "%1 Folders", folders );
    else
        s += i18n( "No Folders" );
    m_multiSelectionLabel->setText( s );

    m_labelSize->setText( KIO::convertSize(size) );
    m_labelBlocks->setText( QString::number(blocks.lba()) );

    // the location of all items are the same since it is not possible to
    // select items from different folders
    // FIXME: maybe better use QString::section?
    QString location = '/' + items.first()->k3bPath();
    if( location[location.length()-1] == '/' )
        location.truncate( location.length()-1 );
    location.truncate( location.lastIndexOf('/') );
    if( location.isEmpty() )
        location = '/';
    m_labelLocation->setText( location );


    m_checkHideOnJoliet->setChecked( items.first()->hideOnJoliet() );
    for ( QList<K3b::DataItem*>::iterator it = m_dataItems.begin();
          it != m_dataItems.end(); ++it ) {
        K3b::DataItem* item = *it;
        if ( m_checkHideOnJoliet->isChecked() != item->hideOnJoliet() ) {
            m_checkHideOnJoliet->setCheckState( Qt::PartiallyChecked );
            break;
        }
    }
    m_checkHideOnRockRidge->setChecked( items.first()->hideOnRockRidge() );
    for ( QList<K3b::DataItem*>::iterator it = m_dataItems.begin();
          it != m_dataItems.end(); ++it ) {
        K3b::DataItem* item = *it;
        if ( m_checkHideOnRockRidge->isChecked() != item->hideOnRockRidge() ) {
            m_checkHideOnRockRidge->setCheckState( Qt::PartiallyChecked );
            break;
        }
    }

    int weight = items.first()->sortWeight();
    for ( QList<K3b::DataItem*>::iterator it = m_dataItems.begin();
          it != m_dataItems.end(); ++it ) {
        K3b::DataItem* item = *it;
        if ( weight != item->sortWeight() ) {
            weight = 0;
            break;
        }
    }
    m_editSortWeight->setText( QString::number( weight ) );
}
开发者ID:KDE,项目名称:k3b,代码行数:76,代码来源:k3bdatapropertiesdialog.cpp

示例6: saveSettings

void PropertiesWidget::saveSettings() {
  QIniSettings settings;
  settings.setValue("TorrentProperties/Visible", state==VISIBLE);
  // Splitter sizes
  QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
  QList<int> sizes;
  if (state == VISIBLE)
    sizes = hSplitter->sizes();
  else
    sizes = slideSizes;
  qDebug("Sizes: %d", sizes.size());
  if (sizes.size() == 2) {
    settings.setValue(QString::fromUtf8("TorrentProperties/SplitterSizes"), QVariant(QString::number(sizes.first())+','+QString::number(sizes.last())));
  }
  settings.setValue("TorrentProperties/FilesListState", filesList->header()->saveState());
  // Remember current tab
  settings.setValue("TorrentProperties/CurrentTab", m_tabBar->currentIndex());
}
开发者ID:baseprotect,项目名称:qbt,代码行数:18,代码来源:propertieswidget.cpp

示例7: onEvent

bool CMindMapEventHandler::onEvent(CDiagramPrivateData *p, QEvent *evt)
{
	bool					r = false;
	CDiagram				*d = NULL;
	CDiagramItem			*item = NULL;
	CMindMapNode			*node = NULL;
	QList<CDiagramItem*>	items;
	
	if ( !p || !p->m_d || p->m_d->mode() == CDiagram::EditTextMode )
		return r;

	d = p->m_d;
	m_pdata = p;

	switch(evt->type())
	{
	case QEvent::GraphicsSceneDragEnter:
        r = dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent*>(evt));
		break;

	case QEvent::GraphicsSceneDragMove:
        r = dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent*>(evt));
		break;

	case QEvent::GraphicsSceneDrop:
        r = dropEvent(static_cast<QGraphicsSceneDragDropEvent*>(evt));
		break;

	case QEvent::GraphicsSceneMousePress:
        if (m_draggedImage->scene() == d)
            d->removeItem(m_draggedImage);
		m_pdata->m_customPressedItem = NULL;
		m_target = NULL;
		break;

	case QEvent::GraphicsSceneMouseMove:
		{
			QGraphicsSceneMouseEvent	*event = NULL;
			QPointF						endPos;
			QPointF						startPos;
			QDrag						*drag = NULL;
			QMimeData					*mime = NULL;
			QByteArray					mimeData;
			QDataStream					dataStream(&mimeData, QIODevice::WriteOnly);

			event = static_cast<QGraphicsSceneMouseEvent*>(evt);
			if (event && d->mode() == CDiagram::CursorMode)
			{
				if (event->buttons() & Qt::LeftButton )
				{
					endPos = event->scenePos();
					startPos = event->buttonDownScenePos(Qt::LeftButton);

					if (!m_pdata->m_customPressedItem)
					{
						items = d->selectedTopLevelItems();
						if (items.length() == 1)
						{
							node = dynamic_cast<CMindMapNode*>(items.first());
                            if (node && node->isMovable() && node->mapToScene( node->boundingRect() ).containsPoint(event->scenePos(), Qt::WindingFill ) )
							{
								m_pdata->m_customPressedItem = node;
							}
							else if (node && node->isRoot())
							{
								r = true;
							}
						}
						else
						{
							foreach (item, items)
							{
								node = dynamic_cast<CMindMapNode*>(item);
								if (node && node->isRoot())
								{
									r = true;
									break;
								}
							}
						}
					}

					// check whether we should start the moving action
					// using manhattanLength.
					if (m_pdata->m_customPressedItem && 
						m_draggedImage->scene() != d && 
						((startPos, endPos).manhattanLength() > QApplication::startDragDistance() ) )
					{
						((CMindMapDragImage*)m_draggedImage)->updateDraggedItemsRect(d, m_pdata->m_customPressedItem);
                        m_pdata->m_d->addItem(m_draggedImage);
						m_draggedImage->setVisible(true);
						m_draggedImageInitPos = m_draggedImage->pos();
						
						dataStream << event->buttonDownScenePos(Qt::LeftButton);
						mime = new QMimeData();
						mime->setData(DND_DRAGMINDMAPNODE, mimeData);

                        drag = new QDrag( d->getMainView() );
						drag->setMimeData(mime);
						
//.........这里部分代码省略.........
开发者ID:jetcodes,项目名称:JetMind,代码行数:101,代码来源:CMindMapEventHandler.cpp

示例8: tr

void
TrackInfoWidget::onStatsLoaded()
{
    QList< Tomahawk::PlaybackLog > history = m_query->playbackHistory( SourceList::instance()->getLocal() );
    const unsigned int trackCounter = m_query->playbackCount( SourceList::instance()->getLocal() );
    const unsigned int artistCounter = m_artist->playbackCount( SourceList::instance()->getLocal() );

    QString stats;

    if ( trackCounter )
        stats = tr( "You've listened to this track %n time(s).", "", trackCounter );
    else
        stats = tr( "You've never listened to this track before." );

    if ( history.count() )
    {
        stats += "\n" + tr( "You first listened to it on %1." ).arg( QDateTime::fromTime_t( history.first().timestamp ).toString( "dd MMM yyyy" ) );
    }

    if ( artistCounter )
        stats += "\n" + tr( "You've listened to %1 %n time(s).", "", artistCounter ).arg( m_artist->name() );
    else
        stats += "\n" + tr( "You've never listened to %1 before." ).arg( m_artist->name() );

    ui->statsLabel->setText( stats );
}
开发者ID:norrs,项目名称:tomahawk,代码行数:26,代码来源:TrackInfoWidget.cpp

示例9: mouseReleaseEvent

/*!\brief reimplementation of the mouseReleaseEvent
 *
 * ...
 */
void LaunchFileView::mouseReleaseEvent(QMouseEvent *event)
{

    if (_handScrolling) {
        _handScrolling = false;
        viewport()->setCursor(_savedCursor);

        event->accept();
        return;
    }
    if (itemAt((event->pos()))){ //else tool crashes
        if (myMode== DeleteItem && event->button() == Qt::LeftButton) {

            if (itemAt(event->pos())->type() == NodeItem::Type) {

                qgraphicsitem_cast<NodeItem *>(itemAt(event->pos()))->removeArrows();
                scene()->removeItem(itemAt(event->pos())); ///removes the Node from the scene
            } else if (itemAt(event->pos())->type() == 8){  // Don't try to kill the View
                if (itemAt(event->pos())->parentItem()->type() == NodeItem::Type){
                    qgraphicsitem_cast<NodeItem *>((itemAt(event->pos()))->parentItem())->removeArrows();
                    scene()->removeItem((itemAt(event->pos()))->parentItem()); ///removes the Node from the scene
                }else
                    scene()->removeItem((itemAt(event->pos()))->parentItem()); ///removes the Parameter

            }else if(itemAt(event->pos())->type() == GroupItem::Type) {
                QList<QGraphicsItem *> list;
                list=itemAt(event->pos())->childItems();
                //qDebug()<<"Begin group items->";

                for (int i = 0; i < list.size(); i++) {
                    if (list.at(i)->type() != 8)

                        (list.at(i))->setParentItem(0);
                  //  qDebug()<<(list.at(i)->type());
                }
                //qDebug()<<"<-End group items";
                scene()->removeItem(itemAt(event->pos()));
            }


            event->setAccepted(true);// tell the base class we are handling this event


        }
    }if (line != 0 && myMode == InsertLine) {

            QList<QGraphicsItem *> startItems = scene()->items(line->line().p1());
            if (startItems.count() && startItems.first() == line)
                startItems.removeFirst();

            QList<QGraphicsItem *> endItems = scene()->items(line->line().p2());
            if (endItems.count() && endItems.first() == line)
                endItems.removeFirst();

            if (startItems.count() &&startItems.first()->type() == 8)
                startItems.first() = startItems.first()->parentItem();
            if (endItems.count() && endItems.first()->type() == 8)
                endItems.first() = endItems.first()->parentItem();


            scene()->removeItem(line); //remove temporary line
            delete line;
            //! [11] //! [12]



            if (startItems.count() > 0 && endItems.count() > 0 &&
                    startItems.first()->type() == NodeItem::Type &&
                    endItems.first()->type() == NodeItem::Type &&
                    startItems.first() != endItems.first()) {
                NodeItem *startItem =
                        qgraphicsitem_cast<NodeItem *>(startItems.first());
                NodeItem *endItem =
                        qgraphicsitem_cast<NodeItem *>(endItems.first());


                RemapArrow *arrow = new RemapArrow(startItem, endItem);
                if (arrow->getArrowData()==true){

                    startItem->addArrow(arrow);
                    endItem->addArrow(arrow);
                    arrow->setZValue(-20);
                    scene()->addItem(arrow);
                    arrow->updatePosition();
                }
            }
        }

    //! [12] //! [13]
    line = 0;

    QGraphicsView::mouseReleaseEvent(event);
}
开发者ID:6opb6a,项目名称:rxdeveloper-ros-pkg,代码行数:97,代码来源:launchFileView.cpp

示例10: testDeleteEvent


//.........这里部分代码省略.........
     * --------
     * user1, received (6)***
     * user1, dialed   (1)
     * user1, missed   (2)
     * user1, dialed   (1)
     * user1, received (2)
     * user1, missed   (1)
     * user1, dialed   (2)
     *
     *     ||
     *     \/
     *
     * user1, dialed   (1)
     * user1, missed   (2)
     * user1, dialed   (1)
     * user1, received (2)
     * user1, missed   (1)
     * user1, dialed   (2)
     */
    // take the event
    e = model.event( model.index( 0, 0 ) );
    QVERIFY( e.isValid() );
    QCOMPARE( e.type(), Event::CallEvent );
    qDebug() << "EVENT:" << e.id() << "|" << e.remoteUid() << "|" << e.direction() << "|" << e.isMissedCall() << "|" << e.eventCount();
    QCOMPARE( e.direction(), Event::Inbound );
    QCOMPARE( e.isMissedCall(), false );
    // delete it
    QVERIFY( model.deleteEvent( e.id() ) );
    QVERIFY( watcher.waitForDeleted(6) );
    // correct test helper lists to match current situation
    foreach (TestCallItem item, testCalls) {
        qDebug() << item.remoteUid << item.callType << item.eventCount;
    }
    testCalls.takeFirst(); testCalls.takeFirst();
    foreach (TestCallItem item, testCalls) {
        qDebug() << item.remoteUid << item.callType << item.eventCount;
    }
    // test if model contains what we want it does
    testGetEvents( CallModel::SortByTime, testCalls.count(), testCalls );

    /* by time:
     * --------
     * user1, dialed   (1) <---\
     * user1, missed   (2)***   regrouping
     * user1, dialed   (1) <---/
     * user1, received (2)
     * user1, missed   (1)
     * user1, dialed   (2)
     *
     *     ||
     *     \/
     *
     * user1, dialed   (2)
     * user1, received (2)
     * user1, missed   (1)
     * user1, dialed   (2)
     */
    // take the event
    e = model.event( model.index( 1, 0 ) );
    QVERIFY( e.isValid() );
    QCOMPARE( e.type(), Event::CallEvent );
    qDebug() << "EVENT:" << e.id() << "|" << e.remoteUid() << "|" << e.direction() << "|" << e.isMissedCall() << "|" << e.eventCount();
    QCOMPARE( e.direction(), Event::Inbound );
    QCOMPARE( e.isMissedCall(), true );
    // delete it
    QVERIFY( model.deleteEvent( e.id() ) );
    QVERIFY( watcher.waitForDeleted(2) );
    // correct test helper lists to match current situation
    testCalls.takeFirst(); testCalls.takeFirst(); testCalls.first().eventCount = 2;
    // test if model contains what we want it does
    testGetEvents( CallModel::SortByTime, testCalls.count(), testCalls );


    // force change of sorting to SortByContact
    QVERIFY( model.setFilter( CallModel::SortByContact ) );
    QVERIFY(watcher.waitForModelReady());
    /* by contact:
     * -----------
     * user1, dialed (0)***
     *
     *    ||
     *    \/
     *
     * (empty)
     */
    // take the event
    e = model.event( model.index( 0, 0 ) );
    QVERIFY( e.isValid() );
    QCOMPARE( e.type(), Event::CallEvent );
    qDebug() << "EVENT:" << e.id() << "|" << e.remoteUid() << "|" << e.direction() << "|" << e.isMissedCall() << "|" << e.eventCount();
    QCOMPARE( e.direction(), Event::Outbound );
    QCOMPARE( e.isMissedCall(), false );
    // delete it
    QVERIFY( model.deleteEvent( e.id() ) );
    QVERIFY( watcher.waitForDeleted(7) );
    // correct test helper lists to match current situation
    testCalls.clear();
    // test if model contains what we want it does
    testGetEvents( CallModel::SortByContact, 0, testCalls );
}
开发者ID:jpetrell,项目名称:libcommhistory,代码行数:101,代码来源:callmodeltest.cpp

示例11: if


//.........这里部分代码省略.........
                }
                else
                {
                    prettyName = tr ( "%1 system partition (%2)" )
                                 .arg( osName.replace( 0, 1, osName.at( 0 ).toUpper() ) )
                                 .arg( partition->fileSystem().name() );
                }
                break;
            }
        }

        if ( partition->capacity() < requiredSpaceB )
        {
            updateStatus( CalamaresUtils::Fail,
                          tr( "<strong>%4</strong><br/><br/>"
                              "The partition %1 is too small for %2. Please select a partition "
                              "with capacity at least %3 GiB." )
                          .arg( partition->partitionPath() )
                          .arg( *Calamares::Branding::VersionedName )
                          .arg( requiredSpaceB / ( 1024. * 1024. * 1024. ),
                                0, 'f', 1 )
                          .arg( prettyName ) );
            setNextEnabled( false );
            return;
        }

        m_ui->bootComboBox->hide();
        m_ui->bootComboBox->clear();
        m_ui->bootStatusLabel->hide();
        m_ui->bootStatusLabel->clear();

        if ( m_isEfi )
        {
            QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions();
            if ( efiSystemPartitions.count() == 0 )
            {
                updateStatus( CalamaresUtils::Fail,
                              tr( "<strong>%2</strong><br/><br/>"
                                  "An EFI system partition cannot be found anywhere "
                                  "on this system. Please go back and use manual "
                                  "partitioning to set up %1." )
                              .arg( *Calamares::Branding::ShortProductName )
                              .arg( prettyName ) );
                setNextEnabled( false );
            }
            else if ( efiSystemPartitions.count() == 1 )
            {
                updateStatus( CalamaresUtils::PartitionPartition,
                              tr( "<strong>%3</strong><br/><br/>"
                                  "%1 will be installed on %2.<br/>"
                                  "<font color=\"red\">Warning: </font>all data on partition "
                                  "%2 will be lost.")
                                .arg( *Calamares::Branding::VersionedName )
                                .arg( partition->partitionPath() )
                                .arg( prettyName ) );
                m_ui->bootStatusLabel->show();
                m_ui->bootStatusLabel->setText(
                    tr( "The EFI system partition at %1 will be used for starting %2." )
                        .arg( efiSystemPartitions.first()->partitionPath() )
                        .arg( *Calamares::Branding::ShortProductName ) );
                setNextEnabled( true );
            }
            else
            {
                updateStatus( CalamaresUtils::PartitionPartition,
                              tr( "<strong>%3</strong><br/><br/>"
                                  "%1 will be installed on %2.<br/>"
                                  "<font color=\"red\">Warning: </font>all data on partition "
                                  "%2 will be lost.")
                                .arg( *Calamares::Branding::VersionedName )
                                .arg( partition->partitionPath() )
                                .arg( prettyName ) );
                m_ui->bootStatusLabel->show();
                m_ui->bootStatusLabel->setText( tr( "EFI system partition:" ) );
                m_ui->bootComboBox->show();
                for ( int i = 0; i < efiSystemPartitions.count(); ++i )
                {
                    Partition* efiPartition = efiSystemPartitions.at( i );
                    m_ui->bootComboBox->addItem( efiPartition->partitionPath(), i );
                    if ( efiPartition->devicePath() == partition->devicePath() &&
                         efiPartition->number() == 1 )
                        m_ui->bootComboBox->setCurrentIndex( i );
                }
                setNextEnabled( true );
            }
        }
        else
        {
            updateStatus( CalamaresUtils::PartitionPartition,
                          tr( "<strong>%3</strong><br/><br/>"
                              "%1 will be installed on %2.<br/>"
                              "<font color=\"red\">Warning: </font>all data on partition "
                              "%2 will be lost.")
                            .arg( *Calamares::Branding::VersionedName )
                            .arg( partition->partitionPath() )
                            .arg( prettyName ) );
            setNextEnabled( true );
        }
    }
}
开发者ID:shainer,项目名称:calamares,代码行数:101,代码来源:ReplaceWidget.cpp

示例12: dropEvent

void CollapsibleGroup::dropEvent(QDropEvent *event)
{
    frame->setProperty("target", false);
    frame->setStyleSheet(frame->styleSheet());
    const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
    //event->acceptProposedAction();
    QDomDocument doc;
    doc.setContent(effects, true);
    QDomElement e = doc.documentElement();
    int ix = e.attribute("kdenlive_ix").toInt();
    if (ix == 0 || e.tagName() == "effectgroup") {
	if (e.tagName() == "effectgroup") {
	    // dropped a group on another group
	    QDomNodeList pastedEffects = e.elementsByTagName("effect");
	    if (pastedEffects.isEmpty() || m_subWidgets.isEmpty()) {
		// Buggy groups, should not happen
		event->ignore();
		return;
	    }
	    QList <int> pastedEffectIndexes;
	    QList <int> currentEffectIndexes;
	    EffectInfo pasteInfo;
	    pasteInfo.fromString(pastedEffects.at(0).toElement().attribute("kdenlive_info"));
	    if (pasteInfo.groupIndex == -1) {
		// Group dropped from effects list, add effect
		e.setAttribute("kdenlive_ix", m_subWidgets.last()->effectIndex());
		emit addEffect(e);
		event->setDropAction(Qt::CopyAction);
		event->accept();
		return;
	    }
	    // Moving group
	    for (int i = 0; i < pastedEffects.count(); i++) {
		pastedEffectIndexes << pastedEffects.at(i).toElement().attribute("kdenlive_ix").toInt();
	    }
	    for (int i = 0; i < m_subWidgets.count(); i++) {
		currentEffectIndexes << m_subWidgets.at(i)->effectIndex();
	    }
	    kDebug()<<"PASTING: "<<pastedEffectIndexes<<" TO "<<currentEffectIndexes;
	    if (pastedEffectIndexes.at(0) < currentEffectIndexes.at(0)) {
		// Pasting group after current one:
		emit moveEffect(pastedEffectIndexes, currentEffectIndexes.last(), pasteInfo.groupIndex, pasteInfo.groupName);
	    }
	    else {
		// Group moved before current one
		emit moveEffect(pastedEffectIndexes, currentEffectIndexes.first(), pasteInfo.groupIndex, pasteInfo.groupName);
	    }
	    event->setDropAction(Qt::MoveAction);
	    event->accept();
	    return;
	}
	// effect dropped from effects list, add it
	e.setAttribute("kdenlive_info", m_info.toString());
	if (!m_subWidgets.isEmpty()) {
	    e.setAttribute("kdenlive_ix", m_subWidgets.at(0)->effectIndex());
	}
	emit addEffect(e);
	event->setDropAction(Qt::CopyAction);
	event->accept();
	return;
    }
    if (m_subWidgets.isEmpty()) return;
    int new_index = m_subWidgets.last()->effectIndex();
    emit moveEffect(QList <int> () <<ix, new_index, m_info.groupIndex, m_title->text());
    event->setDropAction(Qt::MoveAction);
    event->accept();
}
开发者ID:mcfrisk,项目名称:kdenlive,代码行数:67,代码来源:collapsiblegroup.cpp

示例13: testSettings

bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
{
    // Set nearest to closest settings that do work.
    // See if what is in settings will work (return value).
    int err = 0;
    snd_pcm_t* handle;
    snd_pcm_hw_params_t *params;
    QString dev = device;

    QList<QByteArray> devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput);

    if(dev.compare(QLatin1String("default")) == 0) {
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
        dev = QLatin1String(devices.first().constData());
#else
        dev = QLatin1String("hw:0,0");
#endif
    } else {
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
        dev = device;
#else
        int idx = 0;
        char *name;

        QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1);

        while(snd_card_get_name(idx,&name) == 0) {
            if(shortName.compare(QLatin1String(name)) == 0)
                break;
            idx++;
        }
        dev = QString(QLatin1String("hw:%1,0")).arg(idx);
#endif
    }
    if(mode == QAudio::AudioOutput) {
        err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0);
    } else {
        err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0);
    }
    if(err < 0) {
        handle = 0;
        return false;
    }

    bool testChannel = false;
    bool testCodec = false;
    bool testFreq = false;
    bool testType = false;
    bool testSize = false;

    int  dir = 0;

    snd_pcm_nonblock( handle, 0 );
    snd_pcm_hw_params_alloca( &params );
    snd_pcm_hw_params_any( handle, params );

    // set the values!
    snd_pcm_hw_params_set_channels(handle,params,format.channels());
    snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir);

    err = -1;

    switch(format.sampleSize()) {
        case 8:
            if(format.sampleType() == QAudioFormat::SignedInt)
                err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8);
            else if(format.sampleType() == QAudioFormat::UnSignedInt)
                err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8);
            break;
        case 16:
            if(format.sampleType() == QAudioFormat::SignedInt) {
                if(format.byteOrder() == QAudioFormat::LittleEndian)
                    err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE);
                else if(format.byteOrder() == QAudioFormat::BigEndian)
                    err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE);
            } else if(format.sampleType() == QAudioFormat::UnSignedInt) {
                if(format.byteOrder() == QAudioFormat::LittleEndian)
                    err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE);
                else if(format.byteOrder() == QAudioFormat::BigEndian)
                    err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE);
            }
            break;
        case 32:
            if(format.sampleType() == QAudioFormat::SignedInt) {
                if(format.byteOrder() == QAudioFormat::LittleEndian)
                    err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE);
                else if(format.byteOrder() == QAudioFormat::BigEndian)
                    err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE);
            } else if(format.sampleType() == QAudioFormat::UnSignedInt) {
                if(format.byteOrder() == QAudioFormat::LittleEndian)
                    err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE);
                else if(format.byteOrder() == QAudioFormat::BigEndian)
                    err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE);
            }
    }

    // For now, just accept only audio/pcm codec
    if(!format.codec().startsWith(QLatin1String("audio/pcm"))) {
        err=-1;
    } else
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例14: urlExists

bool QgsHelp::urlExists( const QString &url )
{
  QUrl helpUrl( url );
  QTcpSocket socket;

  QgsSettings settings;
  bool proxyEnabled = settings.value( QStringLiteral( "proxy/proxyEnabled" ), false ).toBool();
  if ( proxyEnabled )
  {
    QNetworkProxy proxy;
    QString proxyHost = settings.value( QStringLiteral( "proxy/proxyHost" ), QString() ).toString();
    int proxyPort = settings.value( QStringLiteral( "proxy/proxyPort" ), QString() ).toString().toInt();
    QString proxyUser = settings.value( QStringLiteral( "proxy/proxyUser" ), QString() ).toString();
    QString proxyPassword = settings.value( QStringLiteral( "proxy/proxyPassword" ), QString() ).toString();

    QString proxyTypeString = settings.value( QStringLiteral( "proxy/proxyType" ), QString() ).toString();

    if ( proxyTypeString == QLatin1String( "DefaultProxy" ) )
    {
      QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery();
      if ( !proxies.isEmpty() )
      {
        proxy = proxies.first();
      }
    }
    else
    {
      QNetworkProxy::ProxyType proxyType = QNetworkProxy::DefaultProxy;
      if ( proxyTypeString == QLatin1String( "Socks5Proxy" ) )
      {
        proxyType = QNetworkProxy::Socks5Proxy;
      }
      else if ( proxyTypeString == QLatin1String( "HttpProxy" ) )
      {
        proxyType = QNetworkProxy::HttpProxy;
      }
      else if ( proxyTypeString == QLatin1String( "HttpCachingProxy" ) )
      {
        proxyType = QNetworkProxy::HttpCachingProxy;
      }
      else if ( proxyTypeString == QLatin1String( "FtpCachingProxy" ) )
      {
        proxyType = QNetworkProxy::FtpCachingProxy;
      }
      proxy = QNetworkProxy( proxyType, proxyHost, proxyPort, proxyUser, proxyPassword );
    }
    socket.setProxy( proxy );
  }

  socket.connectToHost( helpUrl.host(), 80 );
  if ( socket.waitForConnected() )
  {
    socket.write( "HEAD " + helpUrl.path().toUtf8() + " HTTP/1.1\r\n"
                  "Host: " + helpUrl.host().toUtf8() + "\r\n\r\n" );
    if ( socket.waitForReadyRead() )
    {
      QByteArray bytes = socket.readAll();
      if ( bytes.contains( "200 OK" ) ||  bytes.contains( "302 Found" ) )
      {
        return true;
      }
    }
  }

  return false;
}
开发者ID:exlimit,项目名称:QGIS,代码行数:66,代码来源:qgshelp.cpp

示例15: decodeAddress

void ConnectionManager::decodeAddress(const QString& address, ConnectionSettings& settings,
                                      bool checkIfServerGroup)
{
    QString host;
    QString port = "6667";

    // Full-length IPv6 address with port
    // Example: RFC 2732 notation:     [2001:0DB8:0000:0000:0000:0000:1428:57ab]:6666
    // Example: Non-RFC 2732 notation: 2001:0DB8:0000:0000:0000:0000:1428:57ab:6666
    if (address.count(':')==8)
    {
        host = address.section(':',0,-2).remove('[').remove(']');
        port = address.section(':',-1);
    }
    // Full-length IPv6 address without port or not-full-length IPv6 address with port
    // Example: Without port, RFC 2732 notation:     [2001:0DB8:0000:0000:0000:0000:1428:57ab]
    // Example: Without port, Non-RFC 2732 notation: 2001:0DB8:0000:0000:0000:0000:1428:57ab
    // Example: With port, RFC 2732 notation:        [2001:0DB8::1428:57ab]:6666
    else if (address.count(':')>=4)
    {
        // Last segment does not end with ], but the next to last does;
        // Assume not-full-length IPv6 address with port
        // Example: [2001:0DB8::1428:57ab]:6666
        if (address.section(':',0,-2).endsWith(']') && !address.section(':',-1).endsWith(']'))
        {
            host = address.section(':',0,-2).remove('[').remove(']');
            port = address.section(':',-1);
        }
        else
        {
            QString addressCopy = address;
            host = addressCopy.remove('[').remove(']');
        }
    }
    // IPv4 address or ordinary hostname with port
    // Example: IPv4 address with port: 123.123.123.123:6666
    // Example: Hostname with port:     irc.bla.org:6666
    else if (address.count(':')==1)
    {
        host = address.section(':',0,-2);
        port = address.section(':',-1);
    }
    else
        host = address;

    // Try to assign server group.
    if (checkIfServerGroup && Preferences::isServerGroup(host))
    {
        // If host is found to be the name of a server group.

        int serverGroupId = Preferences::serverGroupIdsByName(host).first();

        Konversation::ServerGroupSettingsPtr serverGroup;

        serverGroup = Preferences::serverGroupById(serverGroupId);

        settings.setServerGroup(serverGroup);

        if (serverGroup->serverList().size() > 0)
            settings.setServer(serverGroup->serverList()[0]);
    }
    else
    {
        QList<Konversation::ServerGroupSettingsPtr> groups = Preferences::serverGroupsByServer(host);
        if (!groups.isEmpty())
        {
            // If the host is found to be part of a server group's server list.

            Konversation::ServerGroupSettingsPtr serverGroup = groups.first();

            settings.setServerGroup(serverGroup);
        }

        Konversation::ServerSettings server;

        server.setHost(host);
        server.setPort(port.toInt());

        settings.setServer(server);
    }
}
开发者ID:wordlet,项目名称:mykonvi,代码行数:81,代码来源:connectionmanager.cpp


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