Commit 3681143f authored by Christian Mollekopf's avatar Christian Mollekopf Committed by Sandro Knauß
Browse files

KOrganizer: show all personal folder when searching for *

(cherry picked from commit 3ae28f4648eb1cb9c8cdee778fd25aac0408bf25)
parent abae7c3a
......@@ -569,7 +569,7 @@ AkonadiCollectionView::AkonadiCollectionView( CalendarView *view, bool hasContex
filterTreeViewModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
// filterTreeViewModel->setObjectName( "Recursive filtering, for the search bar" );
connect( searchCol, SIGNAL(textChanged(QString)),
filterTreeViewModel, SLOT(setFilterFixedString(QString)) );
filterTreeViewModel, SLOT(setFilterWildcard(QString)) );
SortProxyModel *searchSortProxy = new SortProxyModel( this );
searchSortProxy->setSourceModel(filterTreeViewModel);
......
......@@ -318,43 +318,44 @@ void Controller::setSearchString(const QString &searchString)
//TODO: Delay and abort when results are found
mSearchModel->clear();
emit searchIsActive(!searchString.isEmpty());
if (searchString.size() < 2) {
const bool showAllPersonalFolders = (searchString == QLatin1String("*"));
if (searchString.size() < 2 && !showAllPersonalFolders) {
emit searching(false);
return;
}
emit searching(true);
if (!showAllPersonalFolders) {
emit searching(true);
mPersonSearchJob = new PersonSearchJob(searchString, this);
connect(mPersonSearchJob, SIGNAL(personsFound(QList<Person>)), this, SLOT(onPersonsFound(QList<Person>)));
connect(mPersonSearchJob, SIGNAL(personUpdate(Person)), this, SLOT(onPersonUpdate(Person)));
connect(mPersonSearchJob, SIGNAL(result(KJob*)), this, SLOT(onPersonsFound(KJob*)));
mPersonSearchJob->start();
mPersonSearchJob = new PersonSearchJob(searchString, this);
connect(mPersonSearchJob, SIGNAL(personsFound(QList<Person>)), this, SLOT(onPersonsFound(QList<Person>)));
connect(mPersonSearchJob, SIGNAL(personUpdate(Person)), this, SLOT(onPersonUpdate(Person)));
connect(mPersonSearchJob, SIGNAL(result(KJob*)), this, SLOT(onPersonsFound(KJob*)));
mPersonSearchJob->start();
}
mCollectionSearchJob = new CollectionSearchJob(searchString, QStringList(), this);
mCollectionSearchJob = new CollectionSearchJob(searchString, QStringList() << QLatin1String("text/calendar"), this);
connect(mCollectionSearchJob, SIGNAL(result(KJob*)), this, SLOT(onCollectionsFound(KJob*)));
mCollectionSearchJob->start();
}
void Controller::onCollectionsFound(KJob* job)
{
mCollectionSearchJob = 0;
if (!mPersonSearchJob) {
emit searching(false);
}
if (job->error()) {
kWarning() << job->errorString();
mCollectionSearchJob = 0;
return;
}
Q_ASSERT(mCollectionSearchJob == static_cast<CollectionSearchJob*>(job));
Q_FOREACH(const Akonadi::Collection &col, mCollectionSearchJob->matchingCollections()) {
Q_FOREACH(const Akonadi::Collection &col, static_cast<CollectionSearchJob*>(job)->matchingCollections()) {
CollectionNode *collectionNode = new CollectionNode(*mSearchModel, col);
collectionNode->isSearchNode = true;
//toggled by the checkbox, results in collection getting monitored
// connect(&collectionNode->emitter, SIGNAL(enabled(bool, Akonadi::Collection)), this, SLOT(onCollectionEnabled(bool, Akonadi::Collection)));
mSearchModel->addNode(ReparentingModel::Node::Ptr(collectionNode));
}
mCollectionSearchJob = 0;
}
void Controller::onPersonsFound(const QList<Person> &persons)
......@@ -377,15 +378,14 @@ void Controller::onPersonUpdate(const Person &person)
void Controller::onPersonsFound(KJob* job)
{
mPersonSearchJob = 0;
if (!mCollectionSearchJob) {
emit searching(false);
}
if (job->error()) {
kWarning() << job->errorString();
mPersonSearchJob = 0;
return;
}
mPersonSearchJob = 0;
}
static Akonadi::EntityTreeModel *findEtm(QAbstractItemModel *model)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment