bool AbView::contactCompare( const Opie::OPimContact &cnt, int category ) { // odebug << "bool AbView::contactCompare( const Opie::OPimContact &cnt, " // << category << " )" << oendl; bool returnMe; QArray<int> cats; cats = cnt.categories(); // odebug << "Number of categories: " << cats.count() << oendl; returnMe = false; if ( cats.count() == 0 && category == -1 ) // Contacts with no category will just shown on "All" and "Unfiled" returnMe = true; else { int i; for ( i = 0; i < int(cats.count()); i++ ) { //odebug << "Comparing " << cats[i] << " with " << category << oendl; if ( cats[i] == category ) { returnMe = true; break; } } } // odebug << "Return: " << returnMe << oendl; return returnMe; }
void WSpacePlot::setSelecIndexList(QArray<int> &list) { clearSelection(); for (unsigned int i=0; i<list.count(); i++) cellData[list[i]].attr|=selected; selecIndexList=list; }
void QGLIndexBufferPrivate::append (const QGLIndexBufferPrivate *other, uint offset, int start) { if (elementType == GL_UNSIGNED_SHORT && other->elementType == GL_UNSIGNED_SHORT) { // Both buffers are ushort. const ushort *data = other->indexesShort.constData() + start; int count = other->indexesShort.count() - start; indexesShort.reserve(indexesShort.count() + count); indexCount += count; while (count-- > 0) indexesShort.append(ushort(*data++ + offset)); } else if (elementType == GL_UNSIGNED_SHORT) { // Only first buffer is ushort: convert it to int first. const ushort *indexes = indexesShort.constData(); int count = indexesShort.count(); indexesInt.reserve(count + other->indexesInt.count()); while (count-- > 0) indexesInt.append(*indexes++); indexesShort = QArray<ushort>(); elementType = GL_UNSIGNED_INT; const uint *data = other->indexesInt.constData() + start; count = other->indexesInt.count() - start; indexCount += count; while (count-- > 0) indexesInt.append(*data++ + offset); } else if (other->elementType == GL_UNSIGNED_SHORT) { // Only second buffer is ushort. const ushort *data = other->indexesShort.constData() + start; int count = other->indexesShort.count() - start; indexesInt.reserve(indexesInt.count() + count); indexCount += count; while (count-- > 0) indexesInt.append(*data++ + offset); } else { // Neither buffer is ushort. const uint *data = other->indexesInt.constData() + start; int count = other->indexesInt.count() - start; indexesInt.reserve(indexesInt.count() + count); indexCount += count; while (count-- > 0) indexesInt.append(*data++ + offset); } }
void updateCatListFromArray() { Categories cat( 0 ); cat.load( categoryFileName() ); // we need to update the names for the mCat... to mCatList mCatList.clear(); for (uint i = 0; i < mCat.count(); i++ ) mCatList << cat.label("Document View", mCat[i] ); }
OEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats() { QArray<int> rawRepUids = rawRepeats(); OEvent::ValueList list; for (uint i = 0; i < rawRepUids.count(); ++i ){ list.append( find( rawRepUids[i] ) ); } return list; }
/*! Returns a list of all labels associated with the \a catids */ QStringList CategoryGroup::labels(const QArray<int> &catids ) const { QStringList labels; if ( catids.count() == 0 ) return labels; for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); it != mIdLabelMap.end(); ++it ) if ( catids.find( it.key() ) != -1 ) labels += *it; return labels; }
/*! Adds the color array \a value to this vertex bundle as the data for \a attribute. \sa upload() */ void QGLVertexBundle::addAttribute (QGL::VertexAttribute attribute, const QArray<QColor4ub>& value) { Q_D(QGLVertexBundle); if (!d->buffer.isCreated()) { d->attributeSet.insert(attribute); d->attributes += new QGLVertexBundleColorAttribute(attribute, value); d->vertexCount = qMax(d->vertexCount, value.count()); } }
UIDArray ODateBookAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, int filter, const QArray<int>& categories )const { odebug << "Using Unaccelerated ODateBookAccessBackend sorted Implementation" << oendl; Internal::OPimEventSortVector vector( ar.count(), asc, sortOrder ); int item = 0; for ( uint i = 0; i < ar.count(); ++i ){ OPimEvent event = find( ar[i], ar, i, Frontend::Forward ); if ( event.isEmpty() ) continue; bool catPassed = true; if ( filter & ODateBookAccess::FilterCategory ){ catPassed = false; // Filter Categories for ( uint cat_idx = 0; cat_idx < categories.count(); ++cat_idx ){ int cat = categories[cat_idx]; if ( cat == -1 || cat == 0 ){ // Unfiled. Check next category if list is not empty. // Else: take it as we will not filter unfiled events.. if ( !event.categories().isEmpty() ) continue; else catPassed = true; } else { if ( !event.categories().contains( cat ) ) continue; else{ catPassed = true; break; } } } } // Continue to next event if the category filter removed this item if ( !catPassed ) continue; vector.insert( item++, event ); } // Now sort the vector and return the list of UID's vector.resize( item ); vector.sort(); UIDArray array( vector.count() ); for ( uint i= 0; i < vector.count(); i++ ) array[i] = vector.uidAt( i ); return array; }
// Exporting Event data to map. Using the same // encoding as ODateBookAccessBackend_xml does.. // Thus, we could remove the stuff there and use this // for it and for all other places.. // Encoding should happen at one place, only ! (eilers) QMap<int, QString> OEvent::toMap()const { QMap<int, QString> retMap; retMap.insert( OEvent::FUid, QString::number( uid() ) ); retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) )); retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) ); retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) ); retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" ); OPimAlarm alarm = notifiers().alarms()[0]; retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); retMap.insert( OEvent::FSound, (alarm.sound() == OPimAlarm::Loud) ? "loud" : "silent" ); OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) ); retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) ); retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) ); retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); if( parent() ) retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); if( children().count() ){ QArray<int> childr = children(); QString buf; for ( uint i = 0; i < childr.count(); i++ ) { if ( i != 0 ) buf += " "; buf += QString::number( childr[i] ); } retMap.insert( OEvent::FRecChildren, buf ); } // Add recurrence stuff if( hasRecurrence() ){ ORecur recur = recurrence(); QMap<int, QString> recFields = recur.toMap(); retMap.insert( OEvent::FRType, recFields[ORecur::RType] ); retMap.insert( OEvent::FRWeekdays, recFields[ORecur::RWeekdays] ); retMap.insert( OEvent::FRPosition, recFields[ORecur::RPosition] ); retMap.insert( OEvent::FRFreq, recFields[ORecur::RFreq] ); retMap.insert( OEvent::FRHasEndDate, recFields[ORecur::RHasEndDate] ); retMap.insert( OEvent::FREndDate, recFields[ORecur::EndDate] ); retMap.insert( OEvent::FRCreated, recFields[ORecur::Created] ); retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] ); } else { ORecur recur = recurrence(); QMap<int, QString> recFields = recur.toMap(); retMap.insert( OEvent::FRType, recFields[ORecur::RType] ); } return retMap; }
void ensureCatArray() { if ( mCat.count() > 0 || mCatList.count()==0 ) return; Categories cat( 0 ); cat.load( categoryFileName() ); mCat.resize( mCatList.count() ); int i; QStringList::ConstIterator it; for ( i = 0, it = mCatList.begin(); it != mCatList.end(); ++it, i++ ) { bool number; int id = (*it).toInt( &number ); if ( !number ) { id = cat.id( "Document View", *it ); if ( id == 0 ) id = cat.addCategory( "Document View", *it ); } mCat[i] = id; } }
void Converter::start_conversion() { // Creating backends to the requested databases.. OPimBase* sourceDB; OPimBase* destDB; odebug << "SourceFormat: " << m_selectedSourceFormat << oendl; odebug << "DestFormat: " << m_selectedDestFormat << oendl; if ( m_selectedSourceFormat == m_selectedDestFormat ) { QMessageBox::warning( this, tr("PimConverter"), tr( "<qt>It is not a good idea to use" "the same source and destformat !</qt>")); return; } switch( m_selectedSourceFormat ) { case XML: odebug << "XMLSourceDB = " << m_selectedDatabase << "" << oendl; switch( m_selectedDatabase ) { case ADDRESSBOOK: { sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); } break; case TODOLIST: { sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); } break; case DATEBOOK: { sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); } break; case NOTES: { sourceDB = OPimAccessFactory<OPimMemoAccess>::create( OPimGlobal::NOTES, OPimGlobal::TEXT, "converter" ); } break; default: owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; return; } break; case SQL: odebug << "SQLSourceDB = " << m_selectedDatabase << "" << oendl; switch( m_selectedDatabase ) { case ADDRESSBOOK: { sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); } break; case TODOLIST: { sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); } break; case DATEBOOK: { sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); } break; case NOTES: { sourceDB = OPimAccessFactory<OPimMemoAccess>::create( OPimGlobal::NOTES, OPimGlobal::SQL, "converter" ); } break; default: owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; return; } break; default: owarn << "Unknown source format selected (" << m_selectedSourceFormat << ") !!" << oendl; return; } switch ( m_selectedDestFormat ) { case XML: odebug << "XMLDestDB = " << m_selectedDatabase << "" << oendl; switch( m_selectedDatabase ) { case ADDRESSBOOK: { destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); } break; case TODOLIST: { destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); } break; case DATEBOOK: { destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); } break; case NOTES: { destDB = OPimAccessFactory<OPimMemoAccess>::create( OPimGlobal::NOTES, OPimGlobal::TEXT, "converter" ); } break; default: owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; return; } break; case SQL: odebug << "SQLDestDB = " << m_selectedDatabase << "" << oendl; switch( m_selectedDatabase ) { case ADDRESSBOOK: { destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); } break; case TODOLIST: { destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); } break; case DATEBOOK: { destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); } break; case NOTES: { destDB = OPimAccessFactory<OPimMemoAccess>::create( OPimGlobal::NOTES, OPimGlobal::SQL, "converter" ); } break; default: owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; return; } break; default: owarn << "Unknown destination format selected (" << m_selectedDestFormat << ")!!" << oendl; return; } if ( !sourceDB || !destDB ) return; m_criticalState = true; sourceDB -> load(); destDB -> load(); QTime t; t.start(); // Clean the dest-database if requested (isChecked) if ( m_eraseDB -> isChecked() ) { odebug << "Clearing destination database!" << oendl; destDB -> clear(); } // Now transmit every pim-item from the source database to the destination -database QArray<int> uidList = sourceDB->records(); odebug << "Try to move data for addressbook.. (" << uidList.count() << " items) " << oendl; m_progressBar->setTotalSteps( uidList.count() ); int count = 0; for ( uint i = 0; i < uidList.count(); ++i ) { odebug << "Adding uid: " << uidList[i] << "" << oendl; OPimRecord* rec = sourceDB -> record( uidList[i] ); destDB -> add( rec ); m_progressBar->setProgress( ++count ); } // Now commit data.. destDB -> save(); m_criticalState = false; // Delete the frontends. Backends will be deleted automatically, too ! // We have to cast them back to delete them properly ! switch( m_selectedDatabase ) { case ADDRESSBOOK: delete static_cast<OPimContactAccess*> (sourceDB); delete static_cast<OPimContactAccess*> (destDB); break; case TODOLIST: delete static_cast<OPimTodoAccess*> (sourceDB); delete static_cast<OPimTodoAccess*> (destDB); break; case DATEBOOK: delete static_cast<ODateBookAccess*> (sourceDB); delete static_cast<ODateBookAccess*> (destDB); break; case NOTES: delete static_cast<OPimMemoAccess*> (sourceDB); delete static_cast<OPimMemoAccess*> (destDB); break; default: owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; return; } owarn << "Conversion is finished and needed " << t.elapsed() << " ms !" << oendl; }