1 /***************************************************************************
2 * Copyright (C) 2006 by Pino Toscano, toscano.pino@tiscali.it *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
23 #include "kalziumdataobject.h"
26 : m_isActive( false ), m_searchKind( Search::SearchAll
)
30 QString
Search::searchText() const
35 Search::SearchKind
Search::searchKind() const
40 bool Search::isActive() const
45 const QList
<Element
*>& Search::foundElements() const
47 return m_foundElements
;
50 bool Search::matches( Element
* e
) const
52 return m_foundElements
.contains( e
);
55 void Search::doSearch( const QString
& text
, SearchKind kind
)
60 QList
<Element
*> newresults
;
61 foreach( Element
* e
, KalziumDataObject::instance()->ElementList
)
64 if ( !found
&& e
->dataAsString( ChemicalDataObject::name
).contains( text
, Qt::CaseInsensitive
) ) found
= true;
65 if ( !found
&& e
->dataAsString( ChemicalDataObject::symbol
).contains( text
, Qt::CaseInsensitive
) ) found
= true;
69 if ( newresults
!= m_foundElements
)
71 m_foundElements
= newresults
;
76 void Search::resetSearch()
78 if ( !m_isActive
) return;
80 m_foundElements
.clear();