Root/
| 1 | /* |
| 2 | Copyright 2010 Christian Vetter veaac.fdirct@gmail.com |
| 3 | |
| 4 | This file is part of MoNav. |
| 5 | |
| 6 | MoNav is free software: you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation, either version 3 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | MoNav is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with MoNav. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #ifndef UNICODETOURNAMENTTRIECLIENT_H |
| 21 | #define UNICODETOURNAMENTTRIECLIENT_H |
| 22 | |
| 23 | #include <QObject> |
| 24 | #include <QtPlugin> |
| 25 | #include <QFile> |
| 26 | #include "interfaces/iaddresslookup.h" |
| 27 | #include "trie.h" |
| 28 | |
| 29 | class UnicodeTournamentTrieClient : public QObject, public IAddressLookup |
| 30 | { |
| 31 | Q_OBJECT |
| 32 | Q_INTERFACES( IAddressLookup ) |
| 33 | public: |
| 34 | |
| 35 | explicit UnicodeTournamentTrieClient(); |
| 36 | ~UnicodeTournamentTrieClient(); |
| 37 | |
| 38 | virtual QString GetName(); |
| 39 | virtual void SetInputDirectory( const QString& dir ); |
| 40 | virtual void ShowSettings(); |
| 41 | virtual bool LoadData(); |
| 42 | virtual bool GetPlaceSuggestions( const QString& input, int amount, QStringList* suggestions, QStringList* inputSuggestions ); |
| 43 | virtual bool GetStreetSuggestions( const QString& input, int amount, QStringList* suggestions, QStringList* inputSuggestions ); |
| 44 | virtual bool SelectPlace( int placeID ); |
| 45 | virtual bool GetPlaceData( QString input, QVector< int >* placeIDs, QVector< UnsignedCoordinate >* placeCoordinates ); |
| 46 | virtual bool GetStreetData( QString input, QVector< int >* segmentLength, QVector< UnsignedCoordinate >* coordinates ); |
| 47 | |
| 48 | signals: |
| 49 | |
| 50 | public slots: |
| 51 | |
| 52 | protected: |
| 53 | |
| 54 | struct Suggestion { |
| 55 | unsigned importance; |
| 56 | unsigned index; |
| 57 | QString prefix; |
| 58 | |
| 59 | bool operator<( const Suggestion& right ) const { |
| 60 | return importance > right.importance; |
| 61 | } |
| 62 | }; |
| 63 | |
| 64 | void unload(); |
| 65 | bool find( const char* trie, unsigned* resultNode, QString* missingPrefix, QString prefix ); |
| 66 | int getSuggestion( const char* trie, QStringList* resultNames, unsigned node, int count, const QString prefix ); |
| 67 | |
| 68 | QString directory; |
| 69 | QFile* trieFile; |
| 70 | QFile* subTrieFile; |
| 71 | QFile* dataFile; |
| 72 | const char* trieData; |
| 73 | const char* subTrieData; |
| 74 | |
| 75 | int placeID; |
| 76 | |
| 77 | }; |
| 78 | |
| 79 | #endif // UNICODETOURNAMENTTRIECLIENT_H |
| 80 |
Branches:
master
