void MetadataUpdater::runQuery()
{
    m_indices.clear();
    m_resultList.clear();

    Nepomuk2::Query::Query myQuery;
    if (m_queryServiceClient) {
        m_queryServiceClient->close();
        m_queryServiceClient->deleteLater();
    }
    m_queryServiceClient = new Nepomuk2::Query::QueryServiceClient(this);

    connect(m_queryServiceClient, SIGNAL(newEntries(QList<Nepomuk2::Query::Result>)),
            this, SLOT(newEntries(QList<Nepomuk2::Query::Result>)));
//     connect(queryServiceClient, SIGNAL(entriesRemoved(QList<QUrl>)),SLOT(entriesRemoved(QList<QUrl>)));
    connect(m_queryServiceClient, SIGNAL(error(QString)), SLOT(error(QString)));
    connect(m_queryServiceClient, SIGNAL(finishedListing()), SLOT(finishedListing()));

    emit reset();
    QMutexLocker locker(&m_termMutex);
    myQuery.setTerm(m_term);

    kDebug() << "SPARQL Query " << myQuery.toSparqlQuery();
    m_queryServiceClient->query(myQuery);

    emit queryStarted();
}
Nepomuk::QueryClientWrapper::QueryClientWrapper(SearchRunner* runner, Plasma::RunnerContext* context)
    : QObject(),
      m_runner(runner),
      m_runnerContext(context)
{
    // initialize the query client
    m_queryServiceClient = new Nepomuk::Query::QueryServiceClient(this);
    connect(m_queryServiceClient, SIGNAL(newEntries(QList<Nepomuk::Query::Result>)),
             this, SLOT(slotNewEntries(QList<Nepomuk::Query::Result>)));
}
 static Type copy(const WebKit::WebVector<WebKit::WebFileSystemEntry>& entries)
 {
     WebKit::WebVector<WebKit::WebFileSystemEntry> newEntries(entries.size());
     for (size_t i = 0; i < entries.size(); ++i) {
         String name = entries[i].name;
         newEntries[i].isDirectory = entries[i].isDirectory;
         newEntries[i].name = name.isolatedCopy();
     }
     return newEntries;
 }
Exemplo n.º 4
0
Nepomuk::Utils::SearchWidget::SearchWidget(QWidget *parent)
    : QWidget(parent),
      d_ptr(new SearchWidgetPrivate())
{
    Q_D(SearchWidget);
    d->q = this;

    //query editor widget
    d->m_queryEdit = new SearchLineEdit(this);
    d->m_queryButton = new KPushButton(i18n("Search"), this);
    connect(d->m_queryEdit, SIGNAL(queryChanged(Nepomuk::Query::Query)), this, SLOT(_k_queryComponentChanged()));
    connect(d->m_queryButton, SIGNAL(clicked()), this, SLOT(_k_queryComponentChanged()));

    //item widget
    d->m_itemWidget = new QListView(this);
    d->m_resourceModel = new Utils::SimpleResourceModel(this);
    d->m_itemWidget->setModel(d->m_resourceModel);
    connect(d->m_itemWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SIGNAL(selectionChanged()));
    connect(d->m_itemWidget->selectionModel(), SIGNAL(currentChanged( const QModelIndex &,const QModelIndex&)),
            this, SLOT(_k_forwardCurrentChanged(const QModelIndex &, const QModelIndex &)));

    //facets widget
    d->m_facetWidget = new Nepomuk::Utils::FacetWidget(this);
    d->setupFacetWidget();
    connect(d->m_facetWidget, SIGNAL(queryTermChanged(Nepomuk::Query::Term)), this, SLOT(_k_queryComponentChanged()));

    //layout and config
    QSplitter* facetSplitter = new QSplitter(this);
    facetSplitter->addWidget(d->m_itemWidget);
    facetSplitter->addWidget(d->m_facetWidget);

    QGridLayout* layout = new QGridLayout( this );
    layout->setMargin(0);
    layout->addWidget( d->m_queryEdit, 0, 0 );
    layout->addWidget( d->m_queryButton, 0, 1 );
    layout->addWidget( facetSplitter, 1, 0, 1, 2 );
    layout->setRowStretch(1,1);

    // query client setup
    connect( &d->m_queryClient, SIGNAL(newEntries(QList<Nepomuk::Query::Result>)),
            d->m_resourceModel, SLOT(addResults(QList<Nepomuk::Query::Result>)) );
    connect( &d->m_queryClient, SIGNAL(finishedListing()),
            this, SLOT(_k_listingFinished()));

    setSelectionMode(QListView::ExtendedSelection);
    setConfigFlags( DefaultConfigFlags );
}
Exemplo n.º 5
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void CEmailMailbox::TObserverEventMapper::ConvertParamsL( 
        TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, 
        REmailMessageIdArray& aMessageIds, TFolderId& aFolderId )
    {
    RArray<TFSMailMsgId>* newEntries( static_cast< RArray<TFSMailMsgId>* >( aParam1 ) );
    CleanupClosePushL( *newEntries );
    TFSMailMsgId* parentFolder = static_cast<TFSMailMsgId*>( aParam2 );
    aFolderId = TFolderId( parentFolder->Id(), aMailbox );

    for ( TInt j = 0; j < newEntries->Count(); j++ ) 
        {
        TFSMailMsgId fsId(( *newEntries )[j] );
        TMessageId messageId( fsId.Id(), aFolderId.iId, aMailbox );
        aMessageIds.Append( messageId );
        }

    CleanupStack::PopAndDestroy( newEntries );
    }
void
GPMProcessList::Update()
{
	Broadcast(PrepareForUpdate());
	
	struct timeval currentTime;
	struct timezone tZone;
	gettimeofday(&currentTime, &tZone);

	const JFloat newTime = currentTime.tv_sec + (JFloat)(currentTime.tv_usec / 1000000.0);
	itsElapsedTime       = newTime - itsLastTime;
	itsLastTime          = newTime;

	JPtrArray<GPMProcessEntry> newEntries(JPtrArrayT::kForgetAll);
	newEntries.SetCompareFunction(GPMProcessEntry::CompareListPID);

#ifdef _J_HAS_PROC
	{
	if (itsDirInfo == NULL)
		{
		JBoolean ok	= JDirInfo::Create("/proc", &itsDirInfo);
		assert(ok);
		}
	else
		{
		itsDirInfo->ForceUpdate();
		}

	const JSize count = itsDirInfo->GetEntryCount();
	for (JIndex i=1; i<=count; i++)
		{
		const JDirEntry& entry	= itsDirInfo->GetEntry(i);
		if (entry.GetName().IsInteger() &&
			(!itsIsShowingUserOnly || itsUID == entry.GetUserID()))
			{
			GPMProcessEntry* pentry = new GPMProcessEntry(itsTree, entry);
			assert(pentry != NULL);
			newEntries.InsertSorted(pentry);
			}
		}
	}
#elif defined _J_HAS_SYSCTL
	{
	int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
	if (itsIsShowingUserOnly)
		{
		mib[2] = KERN_PROC_UID;
		mib[3] = itsUID;
		}

	size_t len;
	int result = sysctl(mib, 4, NULL, &len, NULL, 0);
	if (result != 0)
		{
		itsRootNode->DeleteAllChildren();
		itsEntries->RemoveAll();
		itsAlphaEntries->RemoveAll();
		}
	else
		{
		void* buf = malloc(len);
		assert( buf != NULL );

		result = sysctl(mib, 4, buf, &len, NULL, 0);
		if (result != 0)
			{
			itsRootNode->DeleteAllChildren();
			itsEntries->RemoveAll();
			itsAlphaEntries->RemoveAll();
			}
		else
			{
			kinfo_proc* list = (kinfo_proc*) buf;

			const JSize count = len / sizeof(kinfo_proc);
			for (JIndex i=0; i<count; i++)
				{
				GPMProcessEntry* pentry = new GPMProcessEntry(itsTree, list[i]);
				assert( pentry != NULL );
				newEntries.InsertSorted(pentry);
				}
			}

		free(buf);
		}
	}
#endif

	// remove dead processes from the list

	JSize count = itsEntries->GetElementCount();
	for (JIndex i=count; i>=1; i--)
		{
		GPMProcessEntry* pentry	= itsEntries->NthElement(i);
		JIndex findex;
		if (newEntries.SearchSorted(pentry, JOrderedSetT::kAnyMatch, &findex))
			{
			newEntries.DeleteElement(findex);
			}
		else
			{
			while (pentry->HasChildren())
				{
				itsRootNode->InsertSorted(pentry->GetChild(1));
				}

			itsAlphaEntries->Remove(pentry);
			itsEntries->DeleteElement(i);
			}
		}

	// update information on all pre-existing processes

	count = itsEntries->GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		(itsEntries->NthElement(i))->Update(itsElapsedTime);
		}

	itsEntries->Sort();
	itsAlphaEntries->Sort();
	itsRootNode->SortChildren(kJTrue);

	// add new processes to the list

	JOrderedSetT::CompareResult (*treeCompareFn)(JTreeNode * const &,
												 JTreeNode * const &);
	JOrderedSetT::SortOrder	treeSortOrder;
	itsRootNode->GetChildCompareFunction(&treeCompareFn, &treeSortOrder);

	count = newEntries.GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		GPMProcessEntry* pentry = newEntries.NthElement(i);
		pentry->Update(itsElapsedTime);
		itsEntries->InsertSorted(pentry);
		itsAlphaEntries->InsertSorted(pentry);

		pentry->SetChildCompareFunction(treeCompareFn, treeSortOrder, kJTrue);
		}

	// reparent all nodes

	count = itsEntries->GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		GPMProcessEntry* pentry = itsEntries->NthElement(i);
		GPMProcessEntry* parent;
		if (FindProcessEntry(pentry->GetPPID(), &parent) &&
			parent != pentry)
			{
			parent->InsertSorted(pentry);
			}
		else
			{
			itsRootNode->InsertSorted(pentry);
			}
		}

	Broadcast(ListChanged());
}