mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Fixed wrong automatic selection of te first table row/ ctrl-button can now be used to select features in the map canvas
git-svn-id: http://svn.osgeo.org/qgis/trunk@243 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
53f88c2015
commit
46f4945c00
@ -464,7 +464,6 @@ void QgisApp::attributeTable()
|
|||||||
|
|
||||||
void QgisApp::select()
|
void QgisApp::select()
|
||||||
{
|
{
|
||||||
std::cout << "bin in select" << std::endl;
|
|
||||||
mapCanvas->setMapTool(QGis::Select);
|
mapCanvas->setMapTool(QGis::Select);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,6 @@ void QgsAttributeTable::keyReleaseEvent(QKeyEvent* ev)
|
|||||||
|
|
||||||
void QgsAttributeTable::handleChangedSelections()
|
void QgsAttributeTable::handleChangedSelections()
|
||||||
{
|
{
|
||||||
std::cout << "bin in QgsAttributeTable::handleChangedSelection" << std::endl;
|
|
||||||
QTableSelection cselection;
|
QTableSelection cselection;
|
||||||
if(lockKeyPressed==false)
|
if(lockKeyPressed==false)
|
||||||
{
|
{
|
||||||
@ -75,7 +74,6 @@ void QgsAttributeTable::handleChangedSelections()
|
|||||||
//if there is no current selection, there is nothing to do
|
//if there is no current selection, there is nothing to do
|
||||||
if(currentSelection()==-1)
|
if(currentSelection()==-1)
|
||||||
{
|
{
|
||||||
std::cout << "No current selection" << std::endl;
|
|
||||||
emit repaintRequested();
|
emit repaintRequested();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -84,14 +82,9 @@ void QgsAttributeTable::handleChangedSelections()
|
|||||||
|
|
||||||
for(int index=cselection.topRow();index<=cselection.bottomRow();index++)
|
for(int index=cselection.topRow();index<=cselection.bottomRow();index++)
|
||||||
{
|
{
|
||||||
std::cout << "topRow: " << cselection.topRow() << std::endl;
|
|
||||||
std::cout << "bottomRow: " << cselection.bottomRow() << std::endl;
|
|
||||||
std::cout << "index: " << index << std::endl;
|
|
||||||
emit selected(text(index,0).toInt());
|
emit selected(text(index,0).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::cout << "emit QgsAttributeTable::repaintRequested" << std::endl;
|
|
||||||
emit repaintRequested();
|
emit repaintRequested();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -99,7 +92,7 @@ void QgsAttributeTable::handleChangedSelections()
|
|||||||
|
|
||||||
void QgsAttributeTable::selectRowWithId(int id)
|
void QgsAttributeTable::selectRowWithId(int id)
|
||||||
{
|
{
|
||||||
//brute force approach
|
//brute force approach, add a solution with a hash table or a search tree later (and rebuild this structure every time the table is sorted)
|
||||||
for(int i=0;i<numRows();i++)
|
for(int i=0;i<numRows();i++)
|
||||||
{
|
{
|
||||||
if(text(i,0).toInt()==id)
|
if(text(i,0).toInt()==id)
|
||||||
|
@ -45,7 +45,6 @@ QgsMapCanvas::QgsMapCanvas(QWidget * parent, const char *name)
|
|||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
drawing = false;
|
drawing = false;
|
||||||
dirty = true;
|
dirty = true;
|
||||||
ctrlPressed=false;
|
|
||||||
pmCanvas = new QPixmap(width(),height());
|
pmCanvas = new QPixmap(width(),height());
|
||||||
setFocusPolicy(QWidget::StrongFocus);
|
setFocusPolicy(QWidget::StrongFocus);
|
||||||
}
|
}
|
||||||
@ -447,7 +446,14 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
|
|||||||
ur = coordXForm->toMapCoordinates(zoomBox.right(), zoomBox.top());
|
ur = coordXForm->toMapCoordinates(zoomBox.right(), zoomBox.top());
|
||||||
|
|
||||||
QgsRect* search= new QgsRect(ll.x(),ll.y(),ur.x(),ur.y());
|
QgsRect* search= new QgsRect(ll.x(),ll.y(),ur.x(),ur.y());
|
||||||
lyr->select(search,ctrlPressed);
|
if(e->state()==513)
|
||||||
|
{
|
||||||
|
lyr->select(search,true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lyr->select(search,false);
|
||||||
|
}
|
||||||
delete search;
|
delete search;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -489,7 +495,7 @@ void QgsMapCanvas::resizeEvent(QResizeEvent *e){
|
|||||||
}
|
}
|
||||||
void QgsMapCanvas::mouseMoveEvent(QMouseEvent * e)
|
void QgsMapCanvas::mouseMoveEvent(QMouseEvent * e)
|
||||||
{
|
{
|
||||||
if (e->state() == Qt::LeftButton) {
|
if (e->state() == Qt::LeftButton || e->state()==513) {
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
QPainter paint;
|
QPainter paint;
|
||||||
QPen pen(Qt::gray);
|
QPen pen(Qt::gray);
|
||||||
@ -629,21 +635,3 @@ void QgsMapCanvas::removeAll(){
|
|||||||
zOrder.clear();
|
zOrder.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsMapCanvas::keyPressEvent(QKeyEvent* ev)
|
|
||||||
{
|
|
||||||
if(ev->key()==Qt::Key_Control)
|
|
||||||
{
|
|
||||||
std::cout << "ctrlPressed = true" << std::endl;
|
|
||||||
ctrlPressed=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QgsMapCanvas::keyReleaseEvent(QKeyEvent* ev)
|
|
||||||
{
|
|
||||||
if(ev->key()==Qt::Key_Control)
|
|
||||||
{
|
|
||||||
std::cout << "ctrlPressed = false" << std::endl;
|
|
||||||
ctrlPressed=false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -91,8 +91,6 @@ public slots:
|
|||||||
signals:
|
signals:
|
||||||
void xyCoordinates(QgsPoint &p);
|
void xyCoordinates(QgsPoint &p);
|
||||||
private:
|
private:
|
||||||
void keyPressEvent(QKeyEvent* ev);
|
|
||||||
void keyReleaseEvent(QKeyEvent* ev);
|
|
||||||
void mouseMoveEvent(QMouseEvent *e);
|
void mouseMoveEvent(QMouseEvent *e);
|
||||||
void mousePressEvent(QMouseEvent *e);
|
void mousePressEvent(QMouseEvent *e);
|
||||||
void mouseReleaseEvent(QMouseEvent *e);
|
void mouseReleaseEvent(QMouseEvent *e);
|
||||||
@ -143,9 +141,6 @@ public slots:
|
|||||||
* when no real change has occurred
|
* when no real change has occurred
|
||||||
*/
|
*/
|
||||||
bool dirty;
|
bool dirty;
|
||||||
/**Flag which tells if the ctrl-button is pressed*/
|
|
||||||
bool ctrlPressed;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -434,6 +434,7 @@ void QgsShapeFileLayer::table()
|
|||||||
|
|
||||||
tabledisplay->setTitle("Tabledisplaytribute table - " + name());
|
tabledisplay->setTitle("Tabledisplaytribute table - " + name());
|
||||||
tabledisplay->show();
|
tabledisplay->show();
|
||||||
|
tabledisplay->table()->clearSelection();//deselect the first row
|
||||||
|
|
||||||
//select the rows of the already selected features
|
//select the rows of the already selected features
|
||||||
QObject::disconnect(tabledisplay->table(),SIGNAL(selectionChanged()),tabledisplay->table(),SLOT(handleChangedSelections()));
|
QObject::disconnect(tabledisplay->table(),SIGNAL(selectionChanged()),tabledisplay->table(),SLOT(handleChangedSelections()));
|
||||||
@ -456,7 +457,6 @@ void QgsShapeFileLayer::table()
|
|||||||
|
|
||||||
void QgsShapeFileLayer::select(int number)
|
void QgsShapeFileLayer::select(int number)
|
||||||
{
|
{
|
||||||
std::cout << "bin in QgsShapeFileLayer::select(int) " << number << std::endl;
|
|
||||||
(*selected)[number]=true;
|
(*selected)[number]=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,9 +467,7 @@ void QgsShapeFileLayer::select(QgsRect* rect, bool lock)
|
|||||||
{
|
{
|
||||||
QObject::disconnect(tabledisplay->table(),SIGNAL(selectionChanged()),tabledisplay->table(),SLOT(handleChangedSelections()));
|
QObject::disconnect(tabledisplay->table(),SIGNAL(selectionChanged()),tabledisplay->table(),SLOT(handleChangedSelections()));
|
||||||
QObject::disconnect(tabledisplay->table(),SIGNAL(selected(int)),this,SLOT(select(int)));//disconnecting because of performance reason
|
QObject::disconnect(tabledisplay->table(),SIGNAL(selected(int)),this,SLOT(select(int)));//disconnecting because of performance reason
|
||||||
tabledisplay->raise();
|
|
||||||
}
|
}
|
||||||
std::cout << "bin in QgsShapeFileLayer::select(QgsRect)" << std::endl;
|
|
||||||
|
|
||||||
if(lock==false)
|
if(lock==false)
|
||||||
{
|
{
|
||||||
@ -496,7 +494,6 @@ void QgsShapeFileLayer::select(QgsRect* rect, bool lock)
|
|||||||
if(fet)
|
if(fet)
|
||||||
{
|
{
|
||||||
select(fet->GetFID());
|
select(fet->GetFID());
|
||||||
std::cout << "rufe die Methode selectRow auf" << fet->GetFID() << std::endl;
|
|
||||||
if(tabledisplay)
|
if(tabledisplay)
|
||||||
{
|
{
|
||||||
tabledisplay->table()->selectRowWithId(fet->GetFID());
|
tabledisplay->table()->selectRowWithId(fet->GetFID());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user