Scrolls the list of items when a picking is performed.

This commit is contained in:
Maxime Gimeno 2015-12-16 12:58:53 +01:00
parent 0c917c5880
commit 0167571c6e
4 changed files with 29 additions and 1 deletions

View File

@ -194,6 +194,9 @@ MainWindow::MainWindow(QWidget* parent)
connect(scene, SIGNAL(selectionChanged(int)),
this, SLOT(selectSceneItem(int)));
connect(scene, SIGNAL(itemPicked(const QModelIndex &)),
this, SLOT(recenterSceneView(const QModelIndex &)));
connect(sceneView->selectionModel(),
SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & ) ),
this, SLOT(updateInfo()));
@ -1726,3 +1729,14 @@ void MainWindow::make_new_group()
Scene_group_item * group = new Scene_group_item("New group");
scene->add_group(group);
}
void MainWindow::recenterSceneView(const QModelIndex &id)
{
if(id.isValid())
{
// mapFromSource is necessary to convert the QModelIndex received
// from the Scene into a valid QModelIndex in the view, beacuse of
// the proxymodel
sceneView->scrollTo(proxyModel->mapFromSource(id));
}
}

View File

@ -14,7 +14,6 @@
#include <QFileInfo>
#include <QStringList>
#include <QSet>
class Scene;
class Viewer;
class QTreeView;
@ -211,6 +210,9 @@ protected Q_SLOTS:
* frame of the viewer to the new selected item's and calls updateGL().
*/
void selectionChanged();
//! Scrolls to the new selected item.
void recenterSceneView(const QModelIndex &id);
/*!
* Invoques a context menu for the currently selected item at the requested
* position.

View File

@ -43,6 +43,7 @@ Scene::Scene(QObject* parent)
if(ms_splatting==0)
ms_splatting = new GlSplat::SplatRenderer();
ms_splattingCounter++;
picked = false;
}
@ -480,6 +481,15 @@ glDepthFunc(GL_LEQUAL);
ms_splatting->finalize();
}
//scrolls the sceneView to the selected item's line.
if(picked)
Q_EMIT(itemPicked(index_map.key(mainSelectionIndex())));
if(with_names)
picked = true;
else
picked = false;
}
// workaround for Qt-4.2 (see above)

View File

@ -233,6 +233,7 @@ public Q_SLOTS:
Q_SIGNALS:
//generated automatically by moc
void itemPicked(const QModelIndex &);
void newItem(int);
void updated_bbox();
void updated();
@ -270,6 +271,7 @@ private:
int item_A;
//!Index of the item_B.
int item_B;
bool picked;
static GlSplat::SplatRenderer* ms_splatting;
static int ms_splattingCounter;
QMap<QModelIndex, int> index_map;