bool removeTimer(int id)
    {
        if (id >= timerInfos.size())
            return false;

        WinRTTimerInfo &info = timerInfos[id];
        if (info.timerId == INVALID_TIMER_ID)
            return false;

        if (info.interval > 0 && (!timerIdToHandle.contains(id) || !timerIdToCancelHandle.contains(id)))
            return false;

        info.timerId = INVALID_TIMER_ID;

        // Remove invalid timerinfos from the vector's end, if the timer with the highest id was removed
        int lastTimer = timerInfos.size() - 1;
        while (lastTimer >= 0 && timerInfos.at(lastTimer).timerId == INVALID_TIMER_ID)
            --lastTimer;
        if (lastTimer >= 0 && lastTimer != timerInfos.size() - 1)
            timerInfos.resize(lastTimer + 1);
        timerIdToObject.remove(id);
        // ... remove handle from all lists
        if (info.interval > 0) {
            HANDLE handle = timerIdToHandle.take(id);
            timerHandleToId.remove(handle);
            SetEvent(timerIdToCancelHandle.take(id));
        }
        return true;
    }
void NotebookSyncAgent::processETags()
{

    NOTEBOOK_FUNCTION_CALL_TRACE;

    Report *report = qobject_cast<Report*>(sender());
    mRequests.remove(report);
    report->deleteLater();

    if (report->errorCode() == Buteo::SyncResults::NO_ERROR) {
        LOG_DEBUG("Process tags for server path" << mServerPath);
        QHash<QString, Reader::CalendarResource> map = report->receivedCalendarResources();

        // Incidences must be loaded with ExtendedStorage::allIncidences() rather than
        // ExtendedCalendar::incidences(), because the latter will load incidences from all
        // notebooks, rather than just the one for this report.
        // Note that storage incidence references cannot be used with ExtendedCalendar::deleteEvent()
        // etc. Those methods only work for references created by ExtendedCalendar.
        KCalCore::Incidence::List storageIncidenceList;
        if (!mStorage->allIncidences(&storageIncidenceList, mNotebook->uid())) {
            emitFinished(Buteo::SyncResults::DATABASE_FAILURE, QString("Unable to load storage incidences for notebook: %1").arg(mNotebook->uid()));
            return;
        }

        KCalCore::Incidence::List deletions;
        if (!mStorage->deletedIncidences(&deletions, KDateTime(mChangesSinceDate), mNotebook->uid())) {
            LOG_CRITICAL("mKCal::ExtendedStorage::deletedIncidences() failed");
        }

        QStringList eventIdList;

        Q_FOREACH (KCalCore::Incidence::Ptr incidence, storageIncidenceList) {
            QString uri = incidence->customProperty("buteo", "uri");
            if (uri.isEmpty()) {
                //Newly added to Local DB -- Skip this incidence
                continue;
            }
            if (!map.contains(uri)) {
                // we have an incidence that's not on the remote server, so delete it
                switch (incidence->type()) {
                case KCalCore::IncidenceBase::TypeEvent:
                case KCalCore::IncidenceBase::TypeTodo:
                case KCalCore::IncidenceBase::TypeJournal:
                    mIncidenceUidsToDelete.append(incidence->uid());
                    break;
                case KCalCore::IncidenceBase::TypeFreeBusy:
                case KCalCore::IncidenceBase::TypeUnknown:
                    break;
                }
                continue;
            } else {
                Reader::CalendarResource resource = map.take(uri);
                if (mLocalETags.value(incidence->uid()) != resource.etag) {
                    LOG_DEBUG("Will fetch update for" << resource.href
                              << "tag changed from" << mLocalETags.value(incidence->uid())
                              << "to" << resource.etag);
                    eventIdList.append(resource.href);
                }
            }
        }
Ejemplo n.º 3
0
void StatisticForRegimeFileClass::createTableVerticalHeader(QHash<QString,QStringList> hashValue){

    QStringList readDateTime = hashValue.take("date_time");

    if(!readDateTime.isEmpty()){
        ui->tableWidget->setRowCount(readDateTime.size());
        ui->tableWidget->setVerticalHeaderLabels(readDateTime);

        connect(ui->tableWidget->verticalHeader(),SIGNAL(sectionClicked(int)),this,SLOT(setActiveItemWidget(int)));

        QTableWidgetItem* ptwi = 0;
        QStringList key;
        key << "error";
        key << "print";
        key << "time";
        key << "value";

        for (int i = 0; i < key.size(); ++i){
            QStringList readValueHash = hashValue.value(key.at(i));
            for (int j = 0; j < readDateTime.size(); ++j){
                ptwi = new QTableWidgetItem(readValueHash.at(j));
                ui->tableWidget->setItem(j, i, ptwi);
            }
        }
    }
void IapAddTimer::del(QString& iap_id)
{
    if (timers.contains(iap_id)) {
	_IapAddTimer *iap = timers.take(iap_id);
	delete iap;
    }
}
Ejemplo n.º 5
0
void AppLinkProvider::update()
{
    emit aboutToBeChanged();
    QHash<QString, AppLinkItem*> newItems;
    doUpdate(mXdgMenu->xml().documentElement(), newItems);
    {
        QMutableListIterator<CommandProviderItem*> i(*this);
        while (i.hasNext()) {
            AppLinkItem *item = static_cast<AppLinkItem*>(i.next());
            AppLinkItem *newItem = newItems.take(item->command());
            if (newItem)
            {
                *(item) = *newItem;  // Copy by value, not pointer!
                delete newItem;
            }
            else
            {
                i.remove();
                delete item;
            }
        }
    }

    {
        QHashIterator<QString, AppLinkItem*> i(newItems);
        while (i.hasNext())
        {
            append(i.next().value());
        }
    }

    emit changed();
}
Ejemplo n.º 6
0
void AppLinkProvider::update()
{
    emit aboutToBeChanged();
    QHash<QString, AppLinkItem*> newItems;

#ifdef HAVE_MENU_CACHE
    // libmenu-cache is available, use it to get cached app list
    GSList* apps = menu_cache_list_all_apps(mMenuCache);
    for(GSList* l = apps; l; l = l->next)
    {
        MenuCacheApp* app = MENU_CACHE_APP(l->data);
        AppLinkItem *item = new AppLinkItem(app);
        AppLinkItem *prevItem = newItems[item->command()];
        if(prevItem)
            delete prevItem; // delete previous item;
        newItems.insert(item->command(), item);
        menu_cache_item_unref(MENU_CACHE_ITEM(app));
    }
    g_slist_free(apps);
#else
    // use libqtxdg XdgMenu to get installed apps
    doUpdate(mXdgMenu->xml().documentElement(), newItems);
#endif
    {
        QMutableListIterator<CommandProviderItem*> i(*this);
        while (i.hasNext()) {
            AppLinkItem *item = static_cast<AppLinkItem*>(i.next());
            AppLinkItem *newItem = newItems.take(item->command());
            if (newItem)
            {
                *(item) = *newItem;  // Copy by value, not pointer!
                // After the item is copied, the original "updateIcon" call queued
                // on the newItem object is never called since the object iss going to
                // be deleted. Hence we need to call it on the copied item manually.
                // Otherwise the copied item will have no icon.
                // FIXME: this is a dirty hack and it should be made cleaner later.
                if(item->icon().isNull())
                    QMetaObject::invokeMethod(item, "updateIcon", Qt::QueuedConnection);
                delete newItem;
            }
            else
            {
                i.remove();
                delete item;
            }
        }
    }

    {
        QHashIterator<QString, AppLinkItem*> i(newItems);
        while (i.hasNext())
        {
            append(i.next().value());
        }
    }

    emit changed();
}
Ejemplo n.º 7
0
//copied from tst_QMap
void tst_QHash::take()
{
    QHash<int, QString> map;

    map.insert(2, "zwei");
    map.insert(3, "drei");

    QVERIFY(map.take(3) == "drei");
    QVERIFY(!map.contains(3));
}
void QDBusConnectionManager::removeConnection(const QString &name)
{
    QDBusConnectionPrivate *d = 0;
    d = connectionHash.take(name);
    if (d && !d->ref.deref())
        d->deleteYourself();

    // Static objects may be keeping the connection open.
    // However, it is harmless to have outstanding references to a connection that is
    // closing as long as those references will be soon dropped without being used.

    // ### Output a warning if connections are being used after they have been removed.
}
Ejemplo n.º 9
0
//! [5] //! [6]
void AddressBookModel::changeItem(const QModelIndex &index, const QString &firstName, const QString &lastName, const QString &address, const QString &email)
{
    Outlook::ContactItem item(contactItems->Item(index.row() + 1));

    item.SetFirstName(firstName);
    item.SetLastName(lastName);
    item.SetHomeAddress(address);
    item.SetEmail1Address(email);

    item.Save();

    cache.take(index);
}
Ejemplo n.º 10
0
void BrowserOperation::renumber(int phase)
{
    static QHash<void*,char*> cpp;
    static QHash<void*,char*> java;
    static QHash<void*,char*> php;
    static QHash<void*,char*> python;
    char * b;

    if (phase == -1) {
        if ((b = def->get_body('c')) != 0)
            cpp.insert(this, b);

        if ((b = def->get_body('j')) != 0)
            java.insert(this, b);

        if ((b = def->get_body('p')) != 0)
            php.insert(this, b);

        if ((b = def->get_body('y')) != 0)
            python.insert(this, b);
    }
    else {
        new_ident(phase, all);
        def->renumber(phase);

        if ((b = cpp.take(this)) != 0)
            def->new_body(b, 'c');

        if ((b = java.take(this)) != 0)
            def->new_body(b, 'j');

        if ((b = php.take(this)) != 0)
            def->new_body(b, 'p');

        if ((b = python.take(this)) != 0)
            def->new_body(b, 'y');
    }
}
Ejemplo n.º 11
0
int CAD::newEntity(QString entityType)
{
    enum DPI::ETYPE type = QStringToPluginEntityType(entityType);

    if (type == DPI::UNKNOWN)
        return 0;

    Plug_Entity *pe = _doc->newEntity(type);
    QHash<int,QVariant> data;
    pe->getData(&data);

    int eid = (data.take(DPI::EID)).toInt();
    entityMap.insert(eid,pe);

    return eid;
}
Ejemplo n.º 12
0
void KGameSvgDocument::setStyleProperties(const QHash<QString, QString>& _styleProperties, const StylePropertySortOptions& options)
{
    QHash<QString, QString> styleProperties = _styleProperties;
    QString styleBuffer, property;

    d->m_inkscapeOrder << QLatin1String( "fill" ) << QLatin1String( "fill-opacity" ) << QLatin1String( "fill-rule" ) << QLatin1String( "stroke" ) << QLatin1String( "stroke-width" ) << QLatin1String( "stroke-linecap" )
                       << QLatin1String( "stroke-linejoin" ) << QLatin1String( "stroke-miterlimit" ) << QLatin1String( "stroke-dasharray" ) << QLatin1String( "stroke-opacity" );

    if (options == UseInkscapeOrder)
    {
        for (int i = 0; i < d->m_inkscapeOrder.size(); i++)
        {
            property = d->m_inkscapeOrder.at(i);
            if (styleProperties.contains(property))
            {
                styleBuffer += property + QLatin1Char( ':' ) + styleProperties.take(property) + QLatin1Char( ';' );
            }
            else
            {
                // Do Nothing
            }
        }
    }

    // Append any style properties
    if (!styleProperties.isEmpty())
    {
        QHashIterator<QString,  QString> it(styleProperties);
        while (it.hasNext())
        {
            it.next();
            styleBuffer += it.key() + QLatin1Char( ':' ) + it.value() + QLatin1Char( ';' );
        }
    }

    // Remove trailing semicolon if original didn't have one
    if (!d->styleHasTrailingSemicolon()) {styleBuffer.chop(1);}
    setStyle(styleBuffer);
}
void SignonAuthSession::destroySession(const QString &dbusService)
{
    SignonAuthSession *session = m_authSessions.take(dbusService);
    if (session != 0) session->objectUnref();
}
Ejemplo n.º 14
0
void KTreeWidgetPrivate::doLayout()
{
	Q_Q(KTreeWidget);

	if(m_itemsTree.isEmpty())
	{
		/*直接回收所有资源,并返回。*/
		QHash<qint64, QPointer<KTreeItem>> items = m_widgetItems;
		m_widgetItems.clear();
		m_indexWidgetItemBegin = 0;
		int iLeft = 0;
		for(QHash<qint64, QPointer<KTreeItem>>::iterator iter = items.begin(); iter != items.end(); iter++,iLeft++)
		{
			KTreeItem *pli = iter.value();
			if(iLeft <= 3)
			{
				m_creator->recycle(pli);
				pli->hide();
			}
			else
			{
				delete pli;
			}
		}
		return;
	}
	/*至少有一个元素。*/
	//显示在列表中的第一个Item
	//计算下边框是否隐藏为列表可见区的第一项。
	qreal itemPosVisibleFirst = -m_valueCurrentScroll;
	int itemIdxFirst = 0;
	calcLayoutFirstItem(itemIdxFirst, itemPosVisibleFirst, 0, m_itemsTree.size());
	//最后一个元素显示在列表中的。
	//计算上边框是否隐藏来判断是否为列表可见区中最后一项
	qreal itemPosVisibleLast = itemPosVisibleFirst;
	int itemIdxLast = m_itemsTree.count() - 1;
	for(int i = itemIdxFirst; i < m_itemsTree.count(); i++)
	{
		if(itemPosVisibleLast + m_heightItem > m_contentArea.bottom())
		{
			itemIdxLast = i;
			break;
		}
		else
		{
			itemPosVisibleLast += m_heightItem;
		}
	}
	QHash<qint64, QPointer<KTreeItem>> items = m_widgetItems;
	m_widgetItems.clear();
	m_indexWidgetItemBegin = itemIdxFirst;

	/*处理已经重复的对象*/
	bool bdepth = m_styleTree & KTreeWidget::HasBranch;
	qreal itemPosVisible = itemPosVisibleFirst;
	QSet<int> itemsok;
	for(int i = itemIdxFirst; !items.isEmpty() && i <= itemIdxLast; i++)
	{
		qint64 nodeid = m_itemsTree.at(i);
		KTreeItem *pli = items.take(nodeid);
		if(pli == NULL)
		{
			itemPosVisible += m_heightItem;
			continue;
		}
		QRectF itemRt;
		itemRt = QRectF(m_contentArea.left(), itemPosVisible, m_contentArea.width(), m_heightItem);
		itemPosVisible += m_heightItem;
		QMargins margins = m_itemMargins;
		if(bdepth)
		{
			int ndepth = m_model->nodeDepth(nodeid);
			ndepth *= m_depthIndentation;
			margins = QMargins(m_itemMargins.left() + ndepth, m_itemMargins.top(), m_itemMargins.right(), m_itemMargins.bottom());
		}
		pli->setMargins(margins);
		pli->setGeometry(itemRt);
		pli->setFixSize(itemRt.size());
		if(nodeid == m_nodeIdSelect)
		{
			pli->setSelected(m_variantSelected);
		}
		else if(pli->isUnderMouse())
		{
			pli->setHovered(m_variantHovered);
		}
		else
		{
			pli->setUnselected(m_variantUnselect);
		}
		pli->show();
		m_widgetItems.insert(nodeid, pli);
		itemsok.insert(i);
	}

	/*处理没有设置的对象。*/
	itemPosVisible = itemPosVisibleFirst;
	for(int i = itemIdxFirst; i <= itemIdxLast; i++)
	{
		if(itemsok.contains(i))
		{
			itemPosVisible += m_heightItem;
			continue;
		}
		qint64 nodeid = m_itemsTree.at(i);
		KTreeItem *pli = NULL;
		if(items.isEmpty())
		{
			pli = m_creator->create(q);
		}
		else
		{
			QHash<qint64, QPointer<KTreeItem>>::iterator iter = items.begin();
			pli = iter.value();
			items.erase(iter);
		}
		QRectF itemRt;
		itemRt = QRectF(m_contentArea.left(), itemPosVisible, m_contentArea.width(), m_heightItem);
		itemPosVisible += m_heightItem;
		pli->resetNodeId(nodeid);
		QMargins margins = m_itemMargins;
		if(bdepth)
		{
			int ndepth = m_model->nodeDepth(nodeid);
			ndepth *= m_depthIndentation;
			margins = QMargins(m_itemMargins.left() + ndepth, m_itemMargins.top(), m_itemMargins.right(), m_itemMargins.bottom());
		}
		pli->setMargins(margins);
		pli->setGeometry(itemRt);
		pli->setFixSize(itemRt.size());
		if(nodeid == m_nodeIdSelect)
		{
			pli->setSelected(m_variantSelected);
		}
		else if(pli->isUnderMouse())
		{
			pli->setHovered(m_variantHovered);
		}
		else
		{
			pli->setUnselected(m_variantUnselect);
		}
		pli->show();
		m_widgetItems.insert(nodeid, pli);
	}

	int iLeft = 0;
	for(QHash<qint64, QPointer<KTreeItem>>::iterator iter = items.begin(); iter != items.end(); iter++,iLeft++)
	{
		KTreeItem *pli = iter.value();
		if(iLeft <= 3)
		{
			m_creator->recycle(pli);
			pli->hide();
		}
		else
		{
			delete pli;
		}
	}
}
Ejemplo n.º 15
0
void DatabaseSynchronizer::run()
{
	QMutexLocker locker(&FMutex);
	while (!FQuit && !FStreams.isEmpty())
	{
		Jid streamJid = FStreams.dequeue();
		locker.unlock();

		Logger::startTiming(STMP_HISTORY_FILE_DATABASE_SYNC);

		bool syncFailed = false;
		QDateTime syncTime = QDateTime::currentDateTime();

		QString archivePath = FFileArchive->fileArchivePath(streamJid);
		if (!archivePath.isEmpty())
		{
			IArchiveRequest loadRequest;
			QHash<Jid, QList<QString> > databaseHeadersMap;
			QHash<QString, DatabaseArchiveHeader> databaseFileHeaders;
			DatabaseTaskLoadHeaders *loadTask = new DatabaseTaskLoadHeaders(streamJid,loadRequest,QString::null);
			if (!FDatabaseWorker->execTask(loadTask))
			{
				syncFailed = true;
				REPORT_ERROR("Failed to synchronize file archive database: Load database headers task not executed");
			}
			else if (loadTask->isFailed())
			{
				syncFailed = true;
				REPORT_ERROR("Failed to synchronize file archive database: Load database headers task failed");
			}
			else foreach(const DatabaseArchiveHeader &header, loadTask->headers())
			{
				if (header.timestamp < syncTime)
				{
					QString fileName = (FFileArchive->collectionDirName(header.with)+"/"+FFileArchive->collectionFileName(header.start)).toLower();
					databaseHeadersMap[header.with].append(fileName);
					databaseFileHeaders.insert(fileName,header);
				}
			}
			delete loadTask;


			QHash<Jid, QList<IArchiveHeader> > fileHeadersMap;
			QDirIterator bareIt(archivePath,QDir::Dirs|QDir::NoDotAndDotDot);
			while (!FQuit && !syncFailed && bareIt.hasNext())
			{
				QDirIterator filesIt(bareIt.next(), QDir::Files, QDirIterator::Subdirectories);
				
				Jid bareWith = Jid::decode(bareIt.fileName());
				bool isGated = bareWith.pDomain().endsWith(".gateway");
				int pathLength = bareIt.filePath().length()-bareIt.fileName().length();

				while (filesIt.hasNext())
				{
					filesIt.next();
					QDateTime fileLastModified = filesIt.fileInfo().lastModified();
					if (fileLastModified < syncTime)
					{
						QString fileName = filesIt.filePath().mid(pathLength).toLower();
						QHash<QString, DatabaseArchiveHeader>::iterator dbHeaderIt = databaseFileHeaders.find(fileName);
						if (dbHeaderIt==databaseFileHeaders.end() || dbHeaderIt->timestamp<fileLastModified)
						{
							IArchiveHeader header = FFileArchive->loadFileHeader(filesIt.filePath());
							if (header.with.isValid() && header.start.isValid() && !fileHeadersMap.value(header.with).contains(header))
							{
								if (!isGated && header.with.pBare()==bareWith.pBare())
									fileHeadersMap[header.with].append(header);
								else if (isGated && header.with.pNode()==bareWith.pNode())
									fileHeadersMap[header.with].append(header);
							}
						}
						else
						{
							databaseFileHeaders.erase(dbHeaderIt);
						}
					}
				}
			}


			for (QHash<Jid, QList<IArchiveHeader> >::iterator it=fileHeadersMap.begin(); !FQuit && !syncFailed && it!=fileHeadersMap.end(); ++it)
			{
				Jid with = it.key();

				QList<IArchiveHeader> newHeaders;
				QList<IArchiveHeader> difHeaders;
				QList<IArchiveHeader> oldHeaders;

				QList<IArchiveHeader> &fileHeaders = it.value();
				qSort(fileHeaders.begin(),fileHeaders.end());

				QList<IArchiveHeader> databaseHeaders;
				foreach(const QString &fileName, databaseHeadersMap.take(with))
				{
					QHash<QString, DatabaseArchiveHeader>::const_iterator dbHeaderIt = databaseFileHeaders.constFind(fileName);
					if (dbHeaderIt != databaseFileHeaders.constEnd())
						databaseHeaders.append(dbHeaderIt.value());
				}
				qSort(databaseHeaders.begin(),databaseHeaders.end());

				if (databaseHeaders.isEmpty())
				{
					newHeaders = fileHeaders;
				}
				else if (fileHeaders.isEmpty())
				{
					oldHeaders = databaseHeaders;
				}
				else while (!fileHeaders.isEmpty() || !databaseHeaders.isEmpty())
				{
					if (fileHeaders.isEmpty())
					{
						oldHeaders += databaseHeaders.takeFirst();
					}
					else if (databaseHeaders.isEmpty())
					{
						newHeaders += fileHeaders.takeFirst();
					}
					else if (fileHeaders.first() < databaseHeaders.first())
					{
						newHeaders += fileHeaders.takeFirst();
					}
					else if (databaseHeaders.first() < fileHeaders.first())
					{
						oldHeaders += databaseHeaders.takeFirst();
					}
					else if (fileHeaders.first().version != databaseHeaders.first().version)
					{
						difHeaders += fileHeaders.takeFirst();
						databaseHeaders.removeFirst();
					}
					else
					{
						fileHeaders.removeFirst();
						databaseHeaders.removeFirst();
					}
				}

				if (!syncFailed && !newHeaders.isEmpty())
				{
					QString gateType = !with.node().isEmpty() ? FFileArchive->contactGateType(with) : QString::null;
					DatabaseTaskInsertHeaders *insertTask = new DatabaseTaskInsertHeaders(streamJid,newHeaders,gateType);
					if (!FDatabaseWorker->execTask(insertTask))
					{
						syncFailed = true;
						REPORT_ERROR("Failed to synchronize file archive database: Insert new headers task not executed");
					}
					else if(insertTask->isFailed())
					{
						syncFailed = true;
						REPORT_ERROR("Failed to synchronize file archive database: Insert new headers task failed");
					}
					delete insertTask;
				}

				if (!syncFailed && !difHeaders.isEmpty())
				{
					DatabaseTaskUpdateHeaders *updateTask = new DatabaseTaskUpdateHeaders(streamJid,difHeaders);
					if (!FDatabaseWorker->execTask(updateTask))
					{
						syncFailed = true;
						REPORT_ERROR("Failed to synchronize file archive database: Update changed headers task not executed");
					}
					else if (updateTask->isFailed())
					{
						syncFailed = true;
						REPORT_ERROR("Failed to synchronize file archive database: Update changed headers task failed");
					}
					delete updateTask;
				}

				if (!syncFailed && !oldHeaders.isEmpty())
				{
					DatabaseTaskRemoveHeaders *removeTask = new DatabaseTaskRemoveHeaders(streamJid,oldHeaders);
					if (!FDatabaseWorker->execTask(removeTask))
					{
						syncFailed = true;
						REPORT_ERROR("Failed to synchronize file archive database: Remove old headers task not executed");
					}
					else if (removeTask->isFailed())
					{
						syncFailed = true;
						REPORT_ERROR("Failed to synchronize file archive database: Remove old headers task failed");
					}
					delete removeTask;
				}
			}


			for (QHash<Jid, QList<QString> >::const_iterator it=databaseHeadersMap.constBegin(); !FQuit && !syncFailed && it!=databaseHeadersMap.constEnd(); ++it)
			{
				QList<IArchiveHeader> oldHeaders;
				foreach(const QString &fileName, it.value())
				{
					QHash<QString, DatabaseArchiveHeader>::const_iterator dbHeaderIt = databaseFileHeaders.constFind(fileName);
					if (dbHeaderIt != databaseFileHeaders.constEnd())
						oldHeaders.append(dbHeaderIt.value());
				}

				if (!oldHeaders.isEmpty())
				{
					DatabaseTaskRemoveHeaders *removeTask = new DatabaseTaskRemoveHeaders(streamJid,oldHeaders);
					if (!FDatabaseWorker->execTask(removeTask))
					{
						syncFailed = true;
						REPORT_ERROR("Failed to synchronize file archive database: Remove old headers task not executed");
					}
					else if (removeTask->isFailed())
					{
						syncFailed = true;
						REPORT_ERROR("Failed to synchronize file archive database: Remove old headers task failed");
					}
					delete removeTask;
				}
			}
		}
		else
		{
Ejemplo n.º 16
0
void AccountsModelPrivate::removeAccount(Accounts::AccountId accountId)
{
    m_accIdList.removeOne(accountId);
    delete m_accHash.take(accountId);
}
Ejemplo n.º 17
0
bool Args::parse(int argc, char **argv){
    /* Simple class to parse some commandline arguments */
    QTextStream qerr(stderr, QIODevice::WriteOnly);
    QHash<QString, QString> args;

    /* to accept parameters like -f=spam-eggs */
    QRegExp short_key_value_re("-([^=-])=(.+)");
    /* to accept parameters like -f */
    QRegExp short_key_re("-([^=-]+)");
    /* to accept parameters like --foo-bar=spam-eggs */
    QRegExp key_value_re("--([^=]+)=(.+)");
    /* to accept parameters like --foo-bar */
    QRegExp key_re("--([^=]+)");
    /* to accept values for space separated parameters */
    QRegExp value_re("([^-]+.*|.)");

    /* Using argc/argv so all parameters work, not just the ones not filtered
     out by Qt */
    program = QString(argv[0]);

    for(int i=1; i<argc; i++){
        int j;

        QString key;
        QString value;
        QString tmp = QString(argv[i]);

        if(short_key_value_re.exactMatch(tmp)){
            key = short_key_value_re.cap(1);
            value = short_key_value_re.cap(2);
            if(key.length() > 1){
                qerr << "Can't have multiple short arguments with values." \
                    << endl;
                qerr << "Did you forget a '-'? Try --" << key << "=" \
                    << value << " instead" << endl;
                return false;
            }
        }else if(short_key_re.exactMatch(tmp)){
            key = short_key_re.cap(1);
            if(short_key_re.cap(1).length() != 1){
                j = short_key_re.cap(1).length();
                while(j--){
                    args.insert(QString(key[j]), value);
                }
                continue;
            }
        }else if(key_value_re.exactMatch(tmp)){
            key = key_value_re.cap(1);
            value = key_value_re.cap(2);

        }else if(key_re.exactMatch(tmp)){
            key = key_re.cap(1);
        }

        if(i+1 < argc){
            tmp = QString(argv[i+1]);
            if(value == NULL && value_re.exactMatch(tmp)){
                i++;
                value = value_re.cap(1);
            }
        }
        args.insert(key, value);
    }

    QHashIterator<QString, Arg*> j(this->args);
    while(j.hasNext()){
        j.next();
        Arg arg = *j.value();

        if(args.contains(arg.getName())){
            /* Called help, exiting to display help */
            if(arg.getName() == "help"){
                return false;
            }
            insert(arg.getName(), arg.callback(args.take(arg.getName())));
        }else if(args.contains(arg.getShortname())){
            /* Called help, exiting to display help */
            if(arg.getName() == "help"){
                return false;
            }
            insert(arg.getName(),
                arg.callback(args.take(arg.getShortname())));
        }else if(arg.getRequired()){
            qerr << "Argument '" << j.key() \
                << "' is required and not given." << endl;
            return false;
        }else{
            insert(arg.getName(), arg.getDefault());
        }
    }

    if(!args.empty()){
        qerr << "The following unsupported arguments were found:" << endl;
        QHashIterator<QString, QString> j(args);
        while(j.hasNext()){
            j.next();
            if(j.key().length() == 1){
                qerr << "\t-";
            }else{
                qerr << "\t--";
            }
            qerr << j.key();
            if(j.value() != ""){
                qerr << " with value: " << j.value();
            }
            qerr << endl;
        }
        return false;
    }
    return true;
}
Ejemplo n.º 18
0
void
UnixMakefileGenerator::processPrlFiles()
{
    QList<QMakeLocalFileName> libdirs, frameworkdirs;
    frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks"));
    const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_FRAMEWORKPATH_FLAGS", "QMAKE_LFLAGS", "QMAKE_LIBS", QString() };
    for(int i = 0; !lflags[i].isNull(); i++) {
        QStringList &l = project->values(lflags[i]);
        for(int lit = 0; lit < l.size(); ++lit) {
            QString opt = l.at(lit).trimmed();
            if(opt.startsWith("-")) {
                if(opt.startsWith("-L")) {
                    QMakeLocalFileName l(opt.right(opt.length()-2));
                    if(!libdirs.contains(l))
                       libdirs.append(l);
                } else if(opt.startsWith("-l")) {
                    QString lib = opt.right(opt.length() - 2);
                    for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) {
                        const QMakeLocalFileName &lfn = libdirs[dep_i];
                        if(!project->isActiveConfig("compile_libtool")) { //give them the .libs..
                            QString la = lfn.local() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + lib + Option::libtool_ext;
                            if(exists(la) && QFile::exists(lfn.local() + Option::dir_sep + ".libs")) {
                                QString dot_libs = lfn.real() + Option::dir_sep + ".libs";
                                l.append("-L" + dot_libs);
                                libdirs.append(QMakeLocalFileName(dot_libs));
                            }
                        }

                        QString prl = lfn.local() + Option::dir_sep + project->values("QMAKE_PREFIX_SHLIB").first() + lib;
                        if(!project->isEmpty("QMAKE_" + lib.toUpper() + "_SUFFIX"))
                            prl += project->first("QMAKE_" + lib.toUpper() + "_SUFFIX");
                        if(processPrlFile(prl)) {
                            if(prl.startsWith(lfn.local()))
                                prl.replace(0, lfn.local().length(), lfn.real());
                            opt = linkLib(prl, lib);
                            break;
                        }
                    }
                } else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-F")) {
                    QMakeLocalFileName f(opt.right(opt.length()-2));
                    if(!frameworkdirs.contains(f))
                        frameworkdirs.append(f);
                } else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-framework")) {
                    if(opt.length() > 11)
                        opt = opt.mid(11);
                    else
                        opt = l.at(++lit);
                    opt = opt.trimmed();
                    const QList<QMakeLocalFileName> dirs = frameworkdirs + libdirs;
                    for(int dep_i = 0; dep_i < dirs.size(); ++dep_i) {
                        QString prl = dirs[dep_i].local() + "/" + opt + ".framework/" + opt + Option::prl_ext;
                        if(processPrlFile(prl))
                            break;
                    }
                }
            } else if(!opt.isNull()) {
                QString lib = opt;
                processPrlFile(lib);
#if 0
                if(ret)
                    opt = linkLib(lib, "");
#endif
                if(!opt.isEmpty())
                    l.replaceInStrings(lib, opt);
            }

            QStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
            if(!prl_libs.isEmpty()) {
                for(int prl = 0; prl < prl_libs.size(); ++prl)
                    l.insert(lit+prl+1, prl_libs.at(prl));
                prl_libs.clear();
            }
        }

        //merge them into a logical order
        if(!project->isActiveConfig("no_smart_library_merge") && !project->isActiveConfig("no_lflags_merge")) {
            QHash<QString, QStringList> lflags;
            for(int lit = 0; lit < l.size(); ++lit) {
                QString arch("default");
                QString opt = l.at(lit).trimmed();
                if(opt.startsWith("-")) {
                    if (Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-Xarch")) {
                        if (opt.length() > 7) {
                            arch = opt.mid(7);
                            opt = l.at(++lit);
                        }
                    }

                    if(opt.startsWith("-L") ||
                       (Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-F"))) {
                        if(!lflags[arch].contains(opt))
                            lflags[arch].append(opt);
                    } else if(opt.startsWith("-l") || opt == "-pthread") {
                        // Make sure we keep the dependency-order of libraries
                        if (lflags[arch].contains(opt))
                            lflags[arch].removeAll(opt);
                        lflags[arch].append(opt);
                    } else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-framework")) {
                        if(opt.length() > 11)
                            opt = opt.mid(11);
                        else {
                            opt = l.at(++lit);
                            if (Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-Xarch"))
                                opt = l.at(++lit); // The user has done the right thing and prefixed each part
                        }
                        bool found = false;
                        for(int x = 0; x < lflags[arch].size(); ++x) {
                            QString xf = lflags[arch].at(x);
                            if(xf.startsWith("-framework")) {
                                QString framework;
                                if(xf.length() > 11)
                                    framework = xf.mid(11);
                                else
                                    framework = lflags[arch].at(++x);
                                if(framework == opt) {
                                    found = true;
                                    break;
                                }
                            }
                        }
                        if(!found) {
                            lflags[arch].append("-framework");
                            lflags[arch].append(opt);
                        }
                    } else {
                        lflags[arch].append(opt);
                    }
                } else if(!opt.isNull()) {
                    if(!lflags[arch].contains(opt))
                        lflags[arch].append(opt);
                }
            }

            l =  lflags.take("default");

            // Process architecture specific options (Xarch)
            QHash<QString, QStringList>::const_iterator archIterator = lflags.constBegin();
            while (archIterator != lflags.constEnd()) {
                const QStringList archOptions = archIterator.value();
                for (int i = 0; i < archOptions.size(); ++i) {
                    l.append(QLatin1String("-Xarch_") + archIterator.key());
                    l.append(archOptions.at(i));
                }
                ++archIterator;
            }
        }
    }
}
Ejemplo n.º 19
0
void Plugin_Entity::updateData(QHash<int, QVariant> *data){
    if (entity == NULL) return;
    QHash<int, QVariant> hash = *data;
    QString str;
    RS_Vector vec;
    RS_Pen epen = entity->getPen();
//    double num;
    if (hash.contains(DPI::LAYER)) {
        str = (hash.take(DPI::LAYER)).toString();
        entity->setLayer(str);
    }
    if (hash.contains(DPI::LTYPE)) {
        str = (hash.take(DPI::LTYPE)).toString();
        epen.setLineType( Converter.str2lt(str) );
    }
    if (hash.contains(DPI::LWIDTH)) {
        str = (hash.take(DPI::LWIDTH)).toString();
        epen.setWidth( Converter.str2lw(str) );
    }
    if (hash.contains(DPI::COLOR)) {
        QColor color = hash.take(DPI::COLOR).value<QColor>();
        epen.setColor(color);
    }
    entity->setPen(epen);

    RS2::EntityType et = entity->rtti();
    switch (et) {
    //atomicEntity
    case RS2::EntityLine: {
        vec = static_cast<RS_Line*>(entity)->getStartpoint();
        if (hash.contains(DPI::STARTX)) {
            vec.x = (hash.take(DPI::STARTX)).toDouble();
        }
        if (hash.contains(DPI::STARTY)) {
            vec.y = (hash.take(DPI::STARTY)).toDouble();
        }
        static_cast<RS_Line*>(entity)->setStartpoint(vec);
        vec = static_cast<RS_Line*>(entity)->getEndpoint();
        if (hash.contains(DPI::ENDX)) {
            vec.x = (hash.take(DPI::ENDX)).toDouble();
        }
        if (hash.contains(DPI::ENDY)) {
            vec.y = (hash.take(DPI::ENDY)).toDouble();
        }
        static_cast<RS_Line*>(entity)->setEndpoint(vec);
        break;}
    case RS2::EntityPoint: {
        vec = static_cast<RS_Point*>(entity)->getPos();
        if (hash.contains(DPI::STARTX)) {
            vec.x = (hash.take(DPI::STARTX)).toDouble();
        }
        if (hash.contains(DPI::STARTY)) {
            vec.y = (hash.take(DPI::STARTY)).toDouble();
        }
        static_cast<RS_Point*>(entity)->setPos(vec);
        break; }
    case RS2::EntityArc: {
        RS_Arc *arc = static_cast<RS_Arc*>(entity);
        vec = arc->getCenter();
        if (hash.contains(DPI::STARTX)) {
            vec.x = (hash.take(DPI::STARTX)).toDouble();
        }
        if (hash.contains(DPI::STARTY)) {
            vec.y = (hash.take(DPI::STARTY)).toDouble();
        }
        arc->setCenter(vec);
        if (hash.contains(DPI::RADIUS)) {
            arc->setRadius( (hash.take(DPI::RADIUS)).toDouble() );
        }
        if (hash.contains(DPI::STARTANGLE)) {
             arc->setAngle1( (hash.take(DPI::STARTANGLE)).toDouble() );
           vec.y = (hash.take(DPI::STARTANGLE)).toDouble();
        }
        if (hash.contains(DPI::ENDANGLE)) {
            arc->setAngle2( (hash.take(DPI::ENDANGLE)).toDouble() );
        }
        break;}
    case RS2::EntityCircle: {
        RS_Circle *cir = static_cast<RS_Circle*>(entity);
        vec = cir->getCenter();
        if (hash.contains(DPI::STARTX)) {
            vec.x = (hash.take(DPI::STARTX)).toDouble();
        }
        if (hash.contains(DPI::STARTY)) {
            vec.y = (hash.take(DPI::STARTY)).toDouble();
        }
        cir->setCenter(vec);
        if (hash.contains(DPI::RADIUS)) {
            cir->setRadius( (hash.take(DPI::RADIUS)).toDouble() );
        }
        break;}
    case RS2::EntityEllipse: {
        RS_Ellipse *ellipse = static_cast<RS_Ellipse*>(entity);
        vec = ellipse->getCenter();
        if (hash.contains(DPI::STARTX)) {
            vec.x = (hash.take(DPI::STARTX)).toDouble();
        }
        if (hash.contains(DPI::STARTY)) {
            vec.y = (hash.take(DPI::STARTY)).toDouble();
        }
        ellipse->setCenter(vec);

        vec = ellipse->getMajorP();
        if (hash.contains(DPI::ENDX)) {
            vec.x = (hash.take(DPI::ENDX)).toDouble();
        }
        if (hash.contains(DPI::ENDY)) {
            vec.y = (hash.take(DPI::ENDY)).toDouble();
        }
        ellipse->setMajorP(vec);

        if (hash.contains(DPI::STARTANGLE)) {
            ellipse->setAngle1((hash.take(DPI::STARTANGLE)).toDouble());
        }
        if (hash.contains(DPI::ENDANGLE)) {
            ellipse->setAngle2((hash.take(DPI::ENDANGLE)).toDouble());
        }
        if (hash.contains(DPI::HEIGHT)) {
            ellipse->setRatio((hash.take(DPI::HEIGHT)).toDouble());
        }
        if (hash.contains(DPI::REVERSED)) {
            ellipse->setReversed( (hash.take(DPI::REVERSED)).toBool());
        }
        break;}
    case RS2::EntitySolid: //TODO
        //Only used in dimensions ?
        break;
    case RS2::EntityConstructionLine:
        //Unused ?
        break;
    case RS2::EntityImage: {
        break;}
    case RS2::EntityOverlayBox:
        //Unused ?
        break;
//EntityContainer
    case RS2::EntityInsert: {
        break;}
    case RS2::EntityText: {
        RS_Text *txt = static_cast<RS_Text*>(entity);
        bool move = false;
        vec = txt->getInsertionPoint();
        if (hash.contains(DPI::STARTX)) {
            vec.x = (hash.take(DPI::STARTX)).toDouble() - vec.x;
            move = true;
        } else vec.x = 0;
        if (hash.contains(DPI::STARTY)) {
            vec.y = (hash.take(DPI::STARTY)).toDouble() - vec.y;
            move = true;
        } else vec.y = 0;
        if (move)
            txt->move(vec);
        if (hash.contains(DPI::TEXTCONTENT)) {
            txt->setText( (hash.take(DPI::TEXTCONTENT)).toString() );
        }
        if (hash.contains(DPI::STARTANGLE)) {
            txt->setAngle( (hash.take(DPI::STARTANGLE)).toDouble() );
        }
        if (hash.contains(DPI::HEIGHT)) {
            txt->setHeight( (hash.take(DPI::HEIGHT)).toDouble() );
        }
        break;}
    case RS2::EntityHatch:
        break;
    case RS2::EntitySpline:
        break;
    case RS2::EntityPolyline: {
        RS_Polyline *pl = static_cast<RS_Polyline*>(entity);
        if (hash.take(DPI::CLOSEPOLY).toBool()) {
            pl->setClosed(true);
        }else{
            pl->setClosed(false);
        }
        break;}
    case RS2::EntityVertex:
        break;
    case RS2::EntityDimAligned:
        break;
    case RS2::EntityDimLinear:
        break;
    case RS2::EntityDimRadial:
        break;
    case RS2::EntityDimDiametric:
        break;
    case RS2::EntityDimAngular:
        break;
    case RS2::EntityDimLeader:
        break;
    case RS2::EntityUnknown:
    default:
        break;
    }
    entity->update();
}
Ejemplo n.º 20
0
/// \brief  Handles each LoggingItem, generally by handing it off to
///         mythlogserver via ZeroMQ.  There is a special case for
///         thread registration and deregistration which are also included in
///         the logging queue to keep the thread names in sync with the log
///         messages.
/// \param  item    The LoggingItem to be handled
void LoggerThread::handleItem(LoggingItem *item)
{
    if (item->m_type & kRegistering)
    {
        item->m_tid = item->getThreadTid();

        QMutexLocker locker(&logThreadMutex);
        if (logThreadHash.contains(item->m_threadId))
        {
            char *threadName = logThreadHash.take(item->m_threadId);
            free(threadName);
        }
        logThreadHash[item->m_threadId] = strdup(item->m_threadName);

        if (debugRegistration)
        {
            snprintf(item->m_message, LOGLINE_MAX,
                     "Thread 0x%" PREFIX64 "X (%" PREFIX64
                     "d) registered as \'%s\'",
                     (long long unsigned int)item->m_threadId,
                     (long long int)item->m_tid,
                     logThreadHash[item->m_threadId]);
        }
    }
    else if (item->m_type & kDeregistering)
    {
        int64_t tid = 0;

        {
            QMutexLocker locker(&logThreadTidMutex);
            if( logThreadTidHash.contains(item->m_threadId) )
            {
                tid = logThreadTidHash[item->m_threadId];
                logThreadTidHash.remove(item->m_threadId);
            }
        }

        QMutexLocker locker(&logThreadMutex);
        if (logThreadHash.contains(item->m_threadId))
        {
            if (debugRegistration)
            {
                snprintf(item->m_message, LOGLINE_MAX,
                         "Thread 0x%" PREFIX64 "X (%" PREFIX64
                         "d) deregistered as \'%s\'",
                         (long long unsigned int)item->m_threadId,
                         (long long int)tid,
                         logThreadHash[item->m_threadId]);
            }
            char *threadName = logThreadHash.take(item->m_threadId);
            free(threadName);
        }
    }

    if (m_noserver)
    {
        return;
    }

    if (item->m_message[0] != '\0')
    {
#ifndef NOLOGSERVER
        // Send it to mythlogserver
        if (!logThreadFinished && m_zmqSocket)
            m_zmqSocket->sendMessage(item->toByteArray());
#else
        if (logServerThread)
        {
            QList<QByteArray> list;
            list.append(QByteArray());
            list.append(item->toByteArray());
            logServerThread->receivedMessage(list);
        }
#endif
    }
}
Ejemplo n.º 21
0
void TestClass::removeCustomProperty(const QScriptString &name)
{
    CustomProperty *prop = customProperties.take(name);
    if (prop)
        delete prop;
}
Ejemplo n.º 22
0
void KListWidgetPrivate::doLayout()
{
	Q_Q(KListWidget);

	if(m_model->isEmpty())
	{
		/*直接回收所有资源,并返回。*/
		QHash<int, QPointer<KListItem>> items = m_widgetItems;
		m_widgetItems.clear();
		m_indexWidgetItemBegin = 0;
		int iLeft = 0;
		for(QHash<int,QPointer<KListItem>>::iterator iter = items.begin(); iter != items.end(); iter++, iLeft++)
		{
			KListItem *pli = iter.value();
			if(iLeft < 3)
			{
				m_creator->recycle(pli);
				pli->hide();
			}
			else
			{
				delete pli;
			}
		}
		return;
	}
	/*至少有一个元素。*/
	//显示在列表中的第一个Item
	//计算下边框是否隐藏为列表可见区的第一项。
	qreal itemPosVisibleFirst = -m_valueCurrentScroll;
	int itemIdxFirst = 0;
#if 1
	calcLayoutFirstItem(itemIdxFirst, itemPosVisibleFirst, 0, m_model->count());
#else
	int nblock = (m_model->count() + 49) / 50;
	for(int iblock = 0; iblock < nblock; iblock++)
	{
		int height50 = m_heightUnselect * 50;
		if(iblock * 50 < m_indexSelect && m_indexSelect < (iblock+1) * 50)
		{
			height50 += m_heightSelect - m_heightUnselect;
		}
		if(itemPosVisibleFirst + height50 > m_contentArea.top())
		{
			for(int i = iblock * 50; i < m_model->count(); i++)
			{
				if(m_indexSelect == i)
				{
					if(itemPosVisibleFirst + m_heightSelect > m_contentArea.top())
					{
						itemIdxFirst = i;
						break;
					}
					else
					{
						itemPosVisibleFirst += m_heightSelect;
					}
				}
				else
				{
					if(itemPosVisibleFirst + m_heightUnselect > m_contentArea.top())
					{
						itemIdxFirst = i;
						break;
					}
					else
					{
						itemPosVisibleFirst += m_heightUnselect;
					}
				}
			}
			break;
		}
		else
		{
			itemPosVisibleFirst += height50;
		}
	}
#endif
	//最后一个元素显示在列表中的。
	//计算上边框是否隐藏来判断是否为列表可见区中最后一项
	qreal itemPosVisibleLast = itemPosVisibleFirst;
	int itemIdxLast = m_model->count() - 1;
	for(int i = itemIdxFirst; i < m_model->count(); i++)
	{
		if(m_indexSelect == i)
		{
			if(itemPosVisibleLast + m_heightSelect > m_contentArea.bottom())
			{
				itemIdxLast = i;
				break;
			}
			else
			{
				itemPosVisibleLast += m_heightSelect;
			}
		}
		else
		{
			if(itemPosVisibleLast + m_heightUnselect > m_contentArea.bottom())
			{
				itemIdxLast = i;
				break;
			}
			else
			{
				itemPosVisibleLast += m_heightUnselect;
			}
		}
	}
	QHash<int,QPointer<KListItem>> items = m_widgetItems;
	m_widgetItems.clear();
	m_indexWidgetItemBegin = itemIdxFirst;

	/*处理已经重复的对象*/
	qreal itemPosVisible = itemPosVisibleFirst;
	QSet<int> itemsok;
	for(int i = itemIdxFirst; !items.isEmpty() && i <= itemIdxLast; i++)
	{
		KListItem *pli = items.take(i);
		if(pli == NULL)
		{
			if(i == m_indexSelect)
			{
				itemPosVisible += m_heightSelect;
			}
			else
			{
				itemPosVisible += m_heightUnselect;
			}
			continue;
		}
		QRectF itemRt;
		if(i == m_indexSelect)
		{
			itemRt = QRectF(m_contentArea.left(), itemPosVisible, m_contentArea.width(), m_heightSelect);
			itemPosVisible += m_heightSelect;
		}
		else
		{
			itemRt = QRectF(m_contentArea.left(), itemPosVisible, m_contentArea.width(), m_heightUnselect);
			itemPosVisible += m_heightUnselect;
		}
		pli->setMargins(m_itemMargins);
		pli->setGeometry(itemRt);
		pli->setFixSize(itemRt.size());
		if(i == m_indexSelect)
		{
			pli->setSelected(m_variantSelected);
		}
		else if(pli->isUnderMouse())
		{
			pli->setHovered(m_variantHovered);
		}
		else
		{
			pli->setUnselected(m_variantUnselect);
		}
		pli->show();
		m_widgetItems.insert(i, pli);
		itemsok.insert(i);
	}

	/*处理没有设置的对象。*/
	itemPosVisible = itemPosVisibleFirst;
	for(int i = itemIdxFirst; i <= itemIdxLast; i++)
	{
		if(itemsok.contains(i))
		{
			if(i == m_indexSelect)
			{
				itemPosVisible += m_heightSelect;
			}
			else
			{
				itemPosVisible += m_heightUnselect;
			}
			continue;
		}
		KListItem *pli;
		if(items.isEmpty())
		{
			pli = m_creator->create(q);
		}
		else
		{
			QHash<int,QPointer<KListItem>>::iterator iter = items.begin();
			pli = iter.value();
			items.erase(iter);
		}
		QRectF itemRt;
		if(i == m_indexSelect)
		{
			itemRt = QRectF(m_contentArea.left(), itemPosVisible, m_contentArea.width(), m_heightSelect);
			itemPosVisible += m_heightSelect;
		}
		else
		{
			itemRt = QRectF(m_contentArea.left(), itemPosVisible, m_contentArea.width(), m_heightUnselect);
			itemPosVisible += m_heightUnselect;
		}
		pli->resetIndex(i);
		pli->setMargins(m_itemMargins);
		pli->setGeometry(itemRt);
		pli->setFixSize(itemRt.size());
		if(i == m_indexSelect)
		{
			pli->setSelected(m_variantSelected);
		}
		else if(pli->isUnderMouse())
		{
			pli->setHovered(m_variantHovered);
		}
		else
		{
			pli->setUnselected(m_variantUnselect);
		}
		pli->show();
		m_widgetItems.insert(i, pli);
	}
	int iLeft = 0;
	for(QHash<int,QPointer<KListItem>>::iterator iter = items.begin(); iter != items.end(); iter++, iLeft++)
	{
		KListItem *pli = iter.value();
		if(iLeft < 3)
		{
			m_creator->recycle(pli);
			pli->hide();
		}
		else
		{
			delete pli;
		}
	}
}