#ifndef SEARCHMARCH_H
#define SEARCHMARCH_H

#include <QList>
#include <QObject>
#include <QThread>
#include "global/corevar.h"
#include "controller/core/errorreact.h"
class SearchMarch;

class SearchThread : public QThread
{
    Q_OBJECT

public:
    explicit SearchThread(SearchMarch *parent);
    ~SearchThread() {}

    //从文件china-city-list.csv中查找子串，并将城市数据保存在LocationData结构体中
    void run() Q_DECL_OVERRIDE;
};


class SearchMarch : public QObject
{
    Q_OBJECT
public:
    explicit SearchMarch(QObject *parent = 0);
    ~SearchMarch();
    QString setAutomaticCity(const QString &cityName); //定位当前城市
    QString matchCityName(const QString &cityId); //定位当前城市
    //将匹配到的每个城市加入一个列表中
    QList<LocationData> exactMatchCity(const QString &inputText) const;
    QList<LocationData> m_locatonList;

private:
    friend class WorkerThread;

    SearchThread *m_workerThread = nullptr;
};

#endif // LOCATIONWORKER_H
