添加缓存功能
This commit is contained in:
@@ -26,22 +26,22 @@
|
||||
*/
|
||||
#include "mapripper.h"
|
||||
namespace mapcontrol {
|
||||
MapRipper::MapRipper(internals::Core *core, const internals::RectLatLng & rect) : sleep(100), cancel(false), progressForm(0), core(core), yesToAll(false)
|
||||
MapRipper::MapRipper(internals::Core *core, const internals::RectLatLng & rect,int const & maxz) : sleep(100), cancel(false), core(core), yesToAll(true)
|
||||
{
|
||||
if (!rect.IsEmpty()) {
|
||||
type = core->GetMapType();
|
||||
progressForm = new MapRipForm;
|
||||
connect(progressForm, SIGNAL(cancelRequest()), this, SLOT(stopFetching()));
|
||||
//progressForm = new MapRipForm;
|
||||
//connect(progressForm, SIGNAL(cancelRequest()), this, SLOT(stopFetching()));
|
||||
area = rect;
|
||||
zoom = core->Zoom();
|
||||
maxzoom = core->MaxZoom();
|
||||
setMaxZoom(maxz);
|
||||
points = core->Projection()->GetAreaTileList(area, zoom, 0);
|
||||
this->start();
|
||||
cancel = false;
|
||||
progressForm->show();
|
||||
connect(this, SIGNAL(percentageChanged(int)), progressForm, SLOT(SetPercentage(int)));
|
||||
connect(this, SIGNAL(numberOfTilesChanged(int, int)), progressForm, SLOT(SetNumberOfTiles(int, int)));
|
||||
connect(this, SIGNAL(providerChanged(QString, int)), progressForm, SLOT(SetProvider(QString, int)));
|
||||
//progressForm->show();
|
||||
//connect(this, SIGNAL(percentageChanged(int)), progressForm, SLOT(SetPercentage(int)));
|
||||
//connect(this, SIGNAL(numberOfTilesChanged(int, int)), progressForm, SLOT(SetNumberOfTiles(int, int)));
|
||||
//connect(this, SIGNAL(providerChanged(QString, int)), progressForm, SLOT(SetProvider(QString, int)));
|
||||
connect(this, SIGNAL(finished()), this, SLOT(finish()));
|
||||
emit numberOfTilesChanged(0, 0);
|
||||
} else
|
||||
@@ -53,9 +53,10 @@ MapRipper::MapRipper(internals::Core *core, const internals::RectLatLng & rect)
|
||||
}
|
||||
void MapRipper::finish()
|
||||
{
|
||||
|
||||
if (zoom < maxzoom && !cancel) {
|
||||
++zoom;
|
||||
int ret;
|
||||
int ret = QMessageBox::Yes;
|
||||
if (!yesToAll) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString(tr("Continue Ripping at zoom level %1?")).arg(zoom));
|
||||
@@ -66,24 +67,34 @@ void MapRipper::finish()
|
||||
} else {
|
||||
ret = QMessageBox::Yes;
|
||||
}
|
||||
|
||||
if (ret == QMessageBox::Yes) {
|
||||
points.clear();
|
||||
points = core->Projection()->GetAreaTileList(area, zoom, 0);
|
||||
//qDebug() << zoom << maxzoom << ret;
|
||||
|
||||
this->start();
|
||||
} else if (ret == QMessageBox::YesAll) {
|
||||
yesToAll = true;
|
||||
points.clear();
|
||||
points = core->Projection()->GetAreaTileList(area, zoom, 0);
|
||||
this->start();
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
progressForm->close();
|
||||
delete progressForm;
|
||||
//progressForm->close();
|
||||
//delete progressForm;
|
||||
|
||||
emit ripfinished();
|
||||
this->deleteLater();
|
||||
}
|
||||
} else {
|
||||
yesToAll = false;
|
||||
progressForm->close();
|
||||
delete progressForm;
|
||||
//yesToAll = false;
|
||||
//progressForm->close();
|
||||
//delete progressForm;
|
||||
|
||||
emit ripfinished();
|
||||
this->deleteLater();
|
||||
}
|
||||
}
|
||||
@@ -105,11 +116,13 @@ void MapRipper::run()
|
||||
|
||||
core::Point p = points[i];
|
||||
{
|
||||
// qDebug()<<"offline fetching:"<<p.ToString();
|
||||
//qDebug()<<"offline fetching:"<<p.ToString();
|
||||
foreach(core::MapType::Types type, types) {
|
||||
emit providerChanged(core::MapType::StrByType(type), zoom);
|
||||
QByteArray img = OPMaps::Instance()->GetImageFrom(type, p, zoom);
|
||||
|
||||
//qDebug() << img;
|
||||
|
||||
if (img.length() != 0) {
|
||||
goodtile = true;
|
||||
img = NULL;
|
||||
@@ -138,4 +151,17 @@ void MapRipper::stopFetching()
|
||||
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
void MapRipper::setMaxZoom(int const & zoom)
|
||||
{
|
||||
if(zoom <= core->MaxZoom())
|
||||
{
|
||||
maxzoom = zoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxzoom = core->MaxZoom();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class MapRipper : public QThread {
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
MapRipper(internals::Core *, internals::RectLatLng const &);
|
||||
MapRipper(internals::Core *, internals::RectLatLng const &,int const & maxz);
|
||||
void run();
|
||||
private:
|
||||
QList<core::Point> points;
|
||||
@@ -63,10 +63,13 @@ signals:
|
||||
void numberOfTilesChanged(int const & total, int const & actual);
|
||||
void providerChanged(QString const & prov, int const & zoom);
|
||||
|
||||
void ripfinished();
|
||||
|
||||
public slots:
|
||||
void stopFetching();
|
||||
void finish();
|
||||
void setMaxZoom(int const & zoom);
|
||||
|
||||
};
|
||||
}
|
||||
#endif // MAPRIPPER_H
|
||||
|
||||
@@ -1650,9 +1650,44 @@ void OPMapWidget::SetRotate(qreal const & value)
|
||||
compass->setRotation(value);
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapWidget::userRipMap(bool start, qreal lat_l, qreal lng_l, qreal lat_r, qreal lng_r, qint8 zoom)
|
||||
{
|
||||
internals::RectLatLng rect(lat_l,lng_l,lat_r - lat_l,lng_r - lng_l);
|
||||
|
||||
if(start == true)
|
||||
{
|
||||
|
||||
|
||||
MapRipper * mapRipper = new MapRipper(core, rect,zoom);
|
||||
|
||||
connect(mapRipper,SIGNAL(percentageChanged(int)),
|
||||
this,SIGNAL(percentageChanged(int)));
|
||||
|
||||
connect(mapRipper,SIGNAL(numberOfTilesChanged(int,int)),
|
||||
this,SIGNAL(numberOfTilesChanged(int,int)));
|
||||
|
||||
connect(mapRipper,SIGNAL(providerChanged(QString,int)),
|
||||
this,SIGNAL(providerChanged(QString,int)));
|
||||
|
||||
connect(this, SIGNAL(cancelRequest()),
|
||||
mapRipper, SLOT(stopFetching()));
|
||||
|
||||
connect(mapRipper,SIGNAL(ripfinished()),
|
||||
this,SIGNAL(ripfinished()));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
emit cancelRequest();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OPMapWidget::RipMap()
|
||||
{
|
||||
new MapRipper(core, map->SelectedArea());
|
||||
new MapRipper(core, map->SelectedArea(),core->MaxZoom());
|
||||
}
|
||||
|
||||
void OPMapWidget::setSelectedWP(QList<WayPointItem * >list)
|
||||
|
||||
@@ -503,7 +503,7 @@ private:
|
||||
|
||||
QTimer *NoOperationTimer = nullptr;
|
||||
|
||||
|
||||
//MapRipper * mapRipper = nullptr;
|
||||
|
||||
|
||||
internals::PointLatLng point_begin;
|
||||
@@ -536,6 +536,12 @@ protected:
|
||||
// private slots:
|
||||
signals:
|
||||
|
||||
void cancelRequest();
|
||||
void percentageChanged(int const & perc);
|
||||
void numberOfTilesChanged(int const & total, int const & actual);
|
||||
void providerChanged(QString const & prov, int const & zoom);
|
||||
void ripfinished();
|
||||
|
||||
void settableClicked(void);
|
||||
|
||||
void showMessage(const QString &message,int TimeOut = 0);
|
||||
@@ -762,6 +768,9 @@ public slots:
|
||||
|
||||
void getCurrentPoint(int group);
|
||||
|
||||
|
||||
void userRipMap(bool start,qreal lat_l,qreal lng_l,qreal lat_r,qreal lng_r,qint8 zoom);
|
||||
|
||||
};
|
||||
}
|
||||
#endif // OPMAPWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user