本文整理汇总了C++中QValueList::find方法的典型用法代码示例。如果您正苦于以下问题:C++ QValueList::find方法的具体用法?C++ QValueList::find怎么用?C++ QValueList::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QValueList
的用法示例。
在下文中一共展示了QValueList::find方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: O
void
QueueManager::addItems( QListViewItem *after )
{
/*
HACK!!!!! We can know which items where dragged since they should still be selected
I do this, because:
- Dragging items from the playlist provides urls
- Providing urls, requires iterating through the entire list in order to find which
item was selected. Possibly a very expensive task - worst case: O(n)
- After a drag, those items are still selected in the playlist, so we can find out
which PlaylistItems were dragged by selectedItems();
*/
if( !after )
after = m_listview->lastChild();
QPtrList<QListViewItem> list = Playlist::instance()->selectedItems();
for( QListViewItem *item = list.first(); item; item = list.next() )
{
#define item static_cast<PlaylistItem*>(item)
QValueList<PlaylistItem*> current = m_map.values();
if( current.find( item ) == current.end() ) //avoid duplication
{
QString title = i18n("%1 - %2").arg( item->artist(), item->title() );
after = new QueueItem( m_listview, after, title );
m_map[ after ] = item;
}
#undef item
}
}
示例2: addHandler
void OKeyFilterPrivate::addHandler(QWSServer::KeyboardFilter*aF)
{
if (!aF) return;
if (filterList.find(aF)!=filterList.end()) {
return;
}
odebug << "adding a keyboard filter handler"<<oendl;
filterList.append(aF);
}
示例3: addPreHandler
void OKeyFilterPrivate::addPreHandler(QWSServer::KeyboardFilter*aF)
{
if (!aF) return;
if (preFilterList.find(aF)!=preFilterList.end()) {
return;
}
odebug << "adding a preferred keyboard filter handler"<<oendl;
preFilterList.append(aF);
}
示例4: remHandler
void OKeyFilterPrivate::remHandler(QWSServer::KeyboardFilter*aF)
{
if (!aF) return;
QValueList<QWSServer::KeyboardFilter*>::Iterator iter;
if ( (iter=filterList.find(aF))==filterList.end() ) {
return;
}
odebug << "removing a keyboard filter handler"<<oendl;
filterList.remove(iter);
}
示例5: QueueItem
void
QueueManager::addQueuedItem( PlaylistItem *item )
{
Playlist *pl = Playlist::instance();
if( !pl ) return; //should never happen
const int index = pl->m_nextTracks.findRef( item );
QListViewItem *after;
if( !index ) after = 0;
else
{
int find = m_listview->childCount();
if( index - 1 <= find )
find = index - 1;
after = m_listview->itemAtIndex( find );
}
QValueList<PlaylistItem*> current = m_map.values();
QValueListIterator<PlaylistItem*> newItem = current.find( item );
QString title = i18n("%1 - %2").arg( item->artist(), item->title() );
if( newItem == current.end() ) //avoid duplication
{
after = new QueueItem( m_listview, after, title );
m_map[ after ] = item;
}
else //track is in the queue, remove it.
{
QListViewItem *removableItem = m_listview->findItem( title, 0 );
if( removableItem )
{
//Remove the key from the map, so we can re-queue the item
QMapIterator<QListViewItem*, PlaylistItem*> end( m_map.end() );
for( QMapIterator<QListViewItem*, PlaylistItem*> it = m_map.begin(); it != end; ++it )
{
if( it.data() == item )
{
m_map.remove( it );
//Remove the item from the queuelist
m_listview->takeItem( removableItem );
delete removableItem;
return;
}
}
}
}
}
示例6: checkAlarms
/******************************************************************************
* Check if any alarms are pending for a specified calendar, and display the
* pending alarms.
*/
void AlarmDaemon::checkAlarms(ADCalendar *cal)
{
kdDebug(5901) << "AlarmDaemons::checkAlarms(" << cal->urlString() << ")" << endl;
if(!cal->loaded() || !cal->enabled())
return;
QDateTime now = QDateTime::currentDateTime();
kdDebug(5901) << " To: " << now.toString() << endl;
QValueList<KCal::Alarm *> alarms = cal->alarmsTo(now);
if(!alarms.count())
return;
QValueList<KCal::Event *> eventsDone;
for(QValueList<KCal::Alarm *>::ConstIterator it = alarms.begin(); it != alarms.end(); ++it)
{
KCal::Event *event = dynamic_cast<KCal::Event *>((*it)->parent());
if(!event || eventsDone.find(event) != eventsDone.end())
continue; // either not an event, or the event has already been processed
eventsDone += event;
const QString &eventID = event->uid();
kdDebug(5901) << "AlarmDaemon::checkAlarms(): event " << eventID << endl;
// Check which of the alarms for this event are due.
// The times in 'alarmtimes' corresponding to due alarms are set.
// The times for non-due alarms are set invalid in 'alarmtimes'.
bool recurs = event->doesRecur();
const QStringList cats = event->categories();
bool floats = (cats.find(QString::fromLatin1("DATE")) != cats.end());
QDateTime nextDateTime = event->dtStart();
if(recurs)
{
QString prop = event->customProperty("KALARM", "NEXTRECUR");
if(prop.length() >= 8)
{
// The next due recurrence time is specified
QDate d(prop.left(4).toInt(), prop.mid(4, 2).toInt(), prop.mid(6, 2).toInt());
if(d.isValid())
{
if(floats && prop.length() == 8)
nextDateTime = d;
else if(!floats && prop.length() == 15 && prop[8] == QChar('T'))
{
QTime t(prop.mid(9, 2).toInt(), prop.mid(11, 2).toInt(), prop.mid(13, 2).toInt());
if(t.isValid())
nextDateTime = QDateTime(d, t);
}
}
}
}
if(floats)
nextDateTime.setTime(mStartOfDay);
QValueList<QDateTime> alarmtimes;
KCal::Alarm::List alarms = event->alarms();
for(KCal::Alarm::List::ConstIterator al = alarms.begin(); al != alarms.end(); ++al)
{
KCal::Alarm *alarm = *al;
QDateTime dt;
if(alarm->enabled())
{
QDateTime dt1;
if(!alarm->hasTime())
{
// Find the latest recurrence for the alarm.
// Need to do this for alarms with offsets in order to detect
// reminders due for recurrences.
int offset = alarm->hasStartOffset() ? alarm->startOffset().asSeconds()
: alarm->endOffset().asSeconds() + event->dtStart().secsTo(event->dtEnd());
if(offset)
{
dt1 = nextDateTime.addSecs(floats ? (offset / SECS_PER_DAY) * SECS_PER_DAY : offset);
if(dt1 > now)
dt1 = QDateTime();
}
}
// Get latest due repetition, or the recurrence time if none
dt = nextDateTime;
if(nextDateTime <= now && alarm->repeatCount() > 0)
{
int snoozeSecs = alarm->snoozeTime() * 60;
int offset = alarm->repeatCount() * snoozeSecs;
QDateTime lastRepetition = nextDateTime.addSecs(floats ? (offset / SECS_PER_DAY) * SECS_PER_DAY : offset);
if(lastRepetition <= now)
dt = lastRepetition;
else
{
int repetition = nextDateTime.secsTo(now) / snoozeSecs;
int offset = repetition * snoozeSecs;
dt = nextDateTime.addSecs(floats ? (offset / SECS_PER_DAY) * SECS_PER_DAY : offset);
}
}
if(!dt.isValid() || dt > now
|| dt1.isValid() && dt1 > dt) // already tested dt1 <= now
dt = dt1;
}
alarmtimes.append(dt);
}
if(!cal->eventHandled(event, alarmtimes))
//.........这里部分代码省略.........
示例7: paintData
/**
Paints the actual data area.
\param painter the QPainter onto which the chart should be painted
\param data the data that will be displayed as a chart
\param paint2nd specifies whether the main chart or the additional chart is to be drawn now
\param regions a pointer to a list of regions that will be filled
with regions representing the data segments, if not null
*/
void KDChartPiePainter::paintData( QPainter* painter,
KDChartTableDataBase* data,
bool paint2nd,
KDChartDataRegionList* regions )
{
//bHelp=true;
uint chart = paint2nd ? 1 : 0;
QRect ourClipRect( _dataRect );
ourClipRect.addCoords( -1,-1,1,1 );
const QWMatrix & world = painter->worldMatrix();
ourClipRect =
#if COMPAT_QT_VERSION >= 0x030000
world.mapRect( ourClipRect );
#else
world.map( ourClipRect );
#endif
painter->setClipRect( ourClipRect );
// find which dataset to paint
uint dataset;
if ( !params()->findDataset( KDChartParams::DataEntry
,
dataset, dataset ) ) {
return ; // nothing to draw
}
if ( dataset == KDCHART_ALL_DATASETS )
// setChartSourceMode() has not been used (or all datasets have been
// configured to be used); use the first dataset by
// default
dataset = 0;
// Number of values: If -1, use all values, otherwise use the
// specified number of values.
if ( params()->numValues() != -1 )
_numValues = params()->numValues();
else
_numValues = data->usedCols();
_startAngles.resize( _numValues );
_angleLens.resize( _numValues );
// compute position
_size = QMIN( _dataRect.width(), _dataRect.height() ); // initial size
// if the pies explode, we need to give them additional space =>
// make the basic size smaller
if ( params()->explode() ) {
double doubleSize = ( double ) _size;
doubleSize /= ( 1.0 + params()->explodeFactor() * 2 );
_size = ( int ) doubleSize;
}
int sizeFor3DEffect = 0;
if ( !params()->threeDPies() ) {
int x = ( _dataRect.width() == _size ) ? 0 : ( ( _dataRect.width() - _size ) / 2 );
int y = ( _dataRect.height() == _size ) ? 0 : ( ( _dataRect.height() - _size ) / 2 );
_position = QRect( x, y, _size, _size );
_position.moveBy( _dataRect.left(), _dataRect.top() );
} else {
// threeD: width is the maximum possible width; height is 1/2 of that
int x = ( _dataRect.width() == _size ) ? 0 : ( ( _dataRect.width() - _size ) / 2 );
int height = _size;
// make sure that the height plus the threeDheight is not more than the
// available size
if ( params()->threeDPieHeight() >= 0 ) {
// positive pie height: absolute value
sizeFor3DEffect = params()->threeDPieHeight();
height = _size - sizeFor3DEffect;
} else {
// negative pie height: relative value
sizeFor3DEffect = -( int ) ( ( ( double ) params()->threeDPieHeight() / 100.0 ) * ( double ) height );
height = _size - sizeFor3DEffect;
}
int y = ( _dataRect.height() == height ) ? 0 : ( ( _dataRect.height() - height - sizeFor3DEffect ) / 2 );
_position = QRect( _dataRect.left() + x, _dataRect.top() + y,
_size, height );
// _position.moveBy( _dataRect.left(), _dataRect.top() );
}
double sum = data->rowAbsSum( dataset );
if( sum==0 ) //nothing to draw
return;
double sectorsPerValue = 5760.0 / sum; // 5760 == 16*360, number of sections in Qt circle
int currentValue = params()->pieStart() * 16;
//.........这里部分代码省略.........
示例8: drawOnePie
/**
Internal method that draws one of the pies in a pie chart.
\param painter the QPainter to draw in
\param dataset the dataset to draw the pie for
\param pie the pie to draw
\param the chart to draw the pie in
\param regions a pointer to a list of regions that will be filled
with regions representing the data segments, if not null
*/
void KDChartPiePainter::drawOnePie( QPainter* painter,
KDChartTableDataBase* /*data*/,
uint dataset, uint pie, uint chart,
uint threeDPieHeight,
KDChartDataRegionList* regions )
{
// Is there anything to draw at all?
int angleLen = _angleLens[ ( int ) pie ];
if ( angleLen ) {
int startAngle = _startAngles[ ( int ) pie ];
KDChartDataRegion* datReg = 0;
QRegion* region = 0;
bool mustDeleteRegion = false;
if ( regions ){
region = new QRegion();
mustDeleteRegion = true;
}
QRect drawPosition = _position;
if ( params()->explode() ) {
// need to compute a new position for each or some of the pie
QValueList<int> explodeList = params()->explodeValues();
if( explodeList.count() == 0 || // nothing on list, explode all
explodeList.find( pie ) != explodeList.end() ) {
double explodeAngle = ( startAngle + angleLen / 2 ) / 16;
double explodeAngleRad = DEGTORAD( explodeAngle );
double cosAngle = cos( explodeAngleRad );
double sinAngle = -sin( explodeAngleRad );
// find the explode factor for this particular pie
double explodeFactor = 0.0;
QMap<int,double> explodeFactors = params()->explodeFactors();
if( !explodeFactors.contains( pie ) ) // not on factors list, use default
explodeFactor = params()->explodeFactor();
else // on factors list, use segment-specific value
explodeFactor = explodeFactors[pie];
double explodeX = explodeFactor * _size * cosAngle;
double explodeY = explodeFactor * _size * sinAngle;
drawPosition.moveBy( static_cast<int>( explodeX ), static_cast<int>( explodeY ) );
} else
drawPosition = _position;
} else
drawPosition = _position;
// The 3D effect needs to be drawn first because it could
// otherwise partly hide the pie itself.
if ( params()->threeDPies() ) {
draw3DEffect( painter, drawPosition, dataset, pie, chart,
threeDPieHeight,
params()->explode(), region );
}
painter->setBrush( params()->dataColor( pie ) );
if ( angleLen == 5760 ) {
// full circle, avoid nasty line in the middle
painter->drawEllipse( drawPosition );
if ( regions ) {
QPointArray hitregion;
hitregion.makeEllipse( drawPosition.x(), drawPosition.y(),
drawPosition.width(),
drawPosition.height() );
datReg = new KDChartDataRegion( region->unite( QRegion( hitregion ) ),
dataset,
pie,
chart );
datReg->points[ KDChartEnums::PosCenter ]
= drawPosition.center();
datReg->points[ KDChartEnums::PosCenterRight ]
= pointOnCircle( drawPosition, 0 );
datReg->points[ KDChartEnums::PosTopRight ]
= pointOnCircle( drawPosition, 720 );
datReg->points[ KDChartEnums::PosTopCenter ]
= pointOnCircle( drawPosition, 1440 );
datReg->points[ KDChartEnums::PosTopLeft ]
= pointOnCircle( drawPosition, 2160 );
datReg->points[ KDChartEnums::PosCenterLeft ]
= pointOnCircle( drawPosition, 2880 );
datReg->points[ KDChartEnums::PosBottomLeft ]
= pointOnCircle( drawPosition, 3600 );
datReg->points[ KDChartEnums::PosBottomCenter ]
= pointOnCircle( drawPosition, 4320 );
datReg->points[ KDChartEnums::PosBottomRight ]
= pointOnCircle( drawPosition, 5040 );
datReg->startAngle = 2880;
datReg->angleLen = 5760;
regions->append( datReg );
}
} else {
//.........这里部分代码省略.........
示例9: doObjectCompletion
bool CppEditorCompletion::doObjectCompletion( const QString &objName )
{
if ( !ths )
return FALSE;
QString object( objName );
int i = -1;
if ( ( i = object.findRev( "->" ) ) != -1 )
object = object.mid( i + 2 );
if ( ( i = object.findRev( "." ) ) != -1 )
object = object.mid( i + 1 );
object = object.simplifyWhiteSpace();
QObject *obj = 0;
if ( ths->name() == object || object == "this" ) {
obj = ths;
} else {
obj = ths->child( object );
}
if ( !obj )
return FALSE;
QValueList<CompletionEntry> lst;
if ( obj->children() ) {
for ( QObjectListIt cit( *obj->children() ); cit.current(); ++cit ) {
QString s( cit.current()->name() );
if ( s.find( " " ) == -1 && s.find( "qt_" ) == -1 && s.find( "unnamed" ) == -1 ) {
CompletionEntry c;
c.type = "variable";
c.text = s;
c.prefix = "";
lst << c;
}
}
}
QStrList props = obj->metaObject()->propertyNames( TRUE );
for ( QPtrListIterator<char> pit( props ); pit.current(); ++pit ) {
QString f( pit.current() );
QChar c = f[ 0 ];
f.remove( (uint)0, 1 );
f.prepend( c.upper() );
f.prepend( "set" );
CompletionEntry ce;
ce.type = "property";
ce.text = f;
ce.postfix = "()";
if ( lst.find( ce ) == lst.end() )
lst << ce;
}
QStrList slts = obj->metaObject()->slotNames( TRUE );
for ( QPtrListIterator<char> sit( slts ); sit.current(); ++sit ) {
QString f( sit.current() );
f = f.left( f.find( "(" ) );
CompletionEntry c;
c.type = "slot";
c.text = f;
c.postfix = "()";
if ( lst.find( c ) == lst.end() )
lst << c;
}
if ( lst.isEmpty() )
return FALSE;
showCompletion( lst );
return TRUE;
}