提交 1cbcaffa 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

1. replace geomarker's send_event to post_event.

2. individually update tableView instead of at one time.
上级 ec59f4e4
......@@ -123,7 +123,10 @@ namespace QTVP_GEOMARKER{
QList<geoItemBase *> geoGraphicsScene::geo_items()
{
return m_map_items.values();
return std::move(m_map_items.values());
}
QList<QString> geoGraphicsScene::geo_item_names()
{
return std::move(m_map_items.keys());
}
}
......@@ -59,15 +59,16 @@ namespace QTVP_GEOMARKER{
void removeItem(QGraphicsItem * item){return QGraphicsScene::removeItem(item);}
public :
//for many items, we just change level coords in timer, batch mode.
bool deal_level_queue();
double progress_queue(){return 1-m_queue_level_change.size()*1.0 / m_map_items.size();}
bool deal_level_queue();
double progress_queue() {return 1-m_queue_level_change.size()*1.0 / m_map_items.size();}
//For mutithread opertaions, you should call lock_scene first, and call unlock scene when over
bool addItem(geoItemBase *item,int /*reserved*/);
void removeItem(geoItemBase * item, int /*reserved*/);
geoItemBase * geoitem_by_name(const QString & name);
void adjust_item_coords(int currentLevel);
QList<geoItemBase *> geo_items();
int total_items() {return m_map_items.count();}
bool addItem(geoItemBase *item,int /*reserved*/);
void removeItem(geoItemBase * item, int /*reserved*/);
geoItemBase * geoitem_by_name(const QString & name);
void adjust_item_coords(int currentLevel);
QList<geoItemBase *> geo_items();
QList<QString> geo_item_names();
int total_items() {return m_map_items.count();}
};
}
#endif // GEOGRAPHICSSCENE_H
......@@ -356,7 +356,8 @@ bool qtvplugin_geomarker::cb_mouseDoubleClickEvent(QMouseEvent * e)
if (m_bVisible && pwig && too_many_items()==false)
{
// Convert and deliver the mouse event to the scene.
QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseDoubleClick);
QGraphicsSceneMouseEvent * pmouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseDoubleClick);
QGraphicsSceneMouseEvent & mouseEvent = * pmouseEvent;
mouseEvent.setWidget(pwig);
mouseEvent.setButtonDownScenePos(mouse_button, mouse_scene_pt);
mouseEvent.setButtonDownScreenPos(mouse_button, mouse_screen_pt);
......@@ -368,10 +369,8 @@ bool qtvplugin_geomarker::cb_mouseDoubleClickEvent(QMouseEvent * e)
mouseEvent.setButton(e->button());
mouseEvent.setModifiers(e->modifiers());
mouseEvent.setAccepted(false);
QApplication::sendEvent(m_pScene, &mouseEvent);
bool isAccepted = mouseEvent.isAccepted();
e->setAccepted(isAccepted);
return isAccepted;
QApplication::postEvent(m_pScene, &mouseEvent);
scheduleUpdateMap();
}
return false;
}
......@@ -405,7 +404,8 @@ bool qtvplugin_geomarker::cb_mousePressEvent(QMouseEvent * e)
if (m_bVisible && pwig && too_many_items()==false)
{
// Convert and deliver the mouse event to the scene.
QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMousePress);
QGraphicsSceneMouseEvent * pmouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseDoubleClick);
QGraphicsSceneMouseEvent & mouseEvent = * pmouseEvent;
mouseEvent.setWidget(pwig);
mouseEvent.setButtonDownScenePos(mouse_button, mouse_scene_pt);
mouseEvent.setButtonDownScreenPos(mouse_button, mouse_screen_pt);
......@@ -417,11 +417,8 @@ bool qtvplugin_geomarker::cb_mousePressEvent(QMouseEvent * e)
mouseEvent.setButton(e->button());
mouseEvent.setModifiers(e->modifiers());
mouseEvent.setAccepted(false);
QApplication::sendEvent(m_pScene, &mouseEvent);
bool isAccepted = mouseEvent.isAccepted();
e->setAccepted(isAccepted);
//return isAccepted;
return true;
QApplication::postEvent(m_pScene, &mouseEvent);
scheduleUpdateMap();
}
return false;
......@@ -472,6 +469,7 @@ void qtvplugin_geomarker::scheduleRefreshMarks()
//BAD performence will arise if so.
//We will set a flag and refresh the ui in timerEvent Instead.
m_bNeedRefresh = true;
m_items_to_insert.clear();
}
void qtvplugin_geomarker::scheduleUpdateMap()
{
......
......@@ -110,14 +110,16 @@ private:
//UI refreshing functions
private:
void scheduleRefreshMarks();
void scheduleUpdateMap();
void refreshItemUI(QString markname);
void refreshProps(QTVP_GEOMARKER::geoItemBase * itm);
QColor string2color(const QString & s);
QString color2string(const QColor & c);
void refreshIconModel();
QList<QString> m_items_to_insert;
void scheduleRefreshMarks();
void scheduleUpdateMap();
void refreshItemUI(QString markname);
void refreshProps(QTVP_GEOMARKER::geoItemBase * itm);
QColor string2color(const QString & s);
QString color2string(const QColor & c);
void refreshIconModel();
void loadTranslations();
bool too_many_items();
//Geo mark updating functions
private:
//update methopd for UI
......@@ -166,10 +168,8 @@ protected:
bool cb_mouseDoubleClickEvent(QMouseEvent *);
bool cb_event(const QMap<QString, QVariant>);
void timerEvent(QTimerEvent * e);
void timerEvent(QTimerEvent * e);
QMap<QString, QVariant> call_func(const QMap<QString, QVariant> & /*paras*/);
void loadTranslations();
bool too_many_items();
//ui slots
protected slots:
void on_pushButton_update_clicked();
......
......@@ -18,50 +18,38 @@ void qtvplugin_geomarker::timerEvent(QTimerEvent * e)
{
if (e->timerId()==m_nTimerID_refreshUI && m_bNeedRefresh)
{
m_bNeedRefresh = false;
killTimer(m_nTimerID_refreshUI);
m_nTimerID_refreshUI = -1;
if (m_items_to_insert.empty()==true)
{
m_items_to_insert = m_pScene->geo_item_names();
m_pGeoItemModel->clear();
}
//refersh
int rowCount = m_pGeoItemModel->rowCount();
QList<QTVP_GEOMARKER::geoItemBase *> items = m_pScene->geo_items();
int c = 0;
foreach (QTVP_GEOMARKER::geoItemBase * item, items)
int ct = 0;
//we do not use geoItemsBase pointer, because a geoItemsBase pointer may be invalid when delayed ipdate approach is taking place.
while (++ct < 2048 && m_items_to_insert.empty()==false)
{
if (c < rowCount)
{
m_pGeoItemModel->setData(
m_pGeoItemModel->index(c,0),
item->item_name()
);
m_pGeoItemModel->setData(
m_pGeoItemModel->index(c,1),
QTVP_GEOMARKER::item_name_by_enum(item->item_type())
);
m_pGeoItemModel->setData(
m_pGeoItemModel->index(c,2),
item->prop_counts()
);
}
else
{
m_pGeoItemModel->appendRow(new QStandardItem(item->item_name()));
m_pGeoItemModel->setData(
m_pGeoItemModel->index(c,1),
QTVP_GEOMARKER::item_name_by_enum(item->item_type())
);
m_pGeoItemModel->setData(
m_pGeoItemModel->index(c,2),
item->prop_counts()
);
QString keyname = m_items_to_insert.first();
m_items_to_insert.pop_front();
QTVP_GEOMARKER::geoItemBase * item = m_pScene->geoitem_by_name(keyname);
if (!item)
continue;
int c = m_pGeoItemModel->rowCount();
m_pGeoItemModel->appendRow(new QStandardItem(item->item_name()));
m_pGeoItemModel->setData(
m_pGeoItemModel->index(c,1),
QTVP_GEOMARKER::item_name_by_enum(item->item_type())
);
m_pGeoItemModel->setData(
m_pGeoItemModel->index(c,2),
item->prop_counts()
);
}
++c;
}
if (c< rowCount)
m_pGeoItemModel->removeRows(c, rowCount - c);
m_nTimerID_refreshUI = startTimer(2000);
if (m_items_to_insert.empty()==true)
m_bNeedRefresh = false;
m_nTimerID_refreshUI = startTimer(217);
}
else if (m_nTimerID_refreshMap==e->timerId() && m_bNeedUpdateView==true)
{
......@@ -69,7 +57,7 @@ void qtvplugin_geomarker::timerEvent(QTimerEvent * e)
killTimer(m_nTimerID_refreshMap);
m_nTimerID_refreshMap = -1;
m_pVi->UpdateWindow();
m_nTimerID_refreshMap = startTimer(100);
m_nTimerID_refreshMap = startTimer(97);
}
else if (m_nTimerID_levelQueue == e->timerId())
{
......@@ -82,7 +70,7 @@ void qtvplugin_geomarker::timerEvent(QTimerEvent * e)
if (m_pScene->progress_queue()<0.999)
m_pVi->UpdateWindow();
}
m_nTimerID_levelQueue = startTimer(100);
m_nTimerID_levelQueue = startTimer(119);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册