add first/last buttons

This commit is contained in:
Denis Rouzaud 2019-05-14 15:09:03 -05:00
parent f680466bf7
commit c0a0f7d6c9
9 changed files with 289 additions and 56 deletions

View File

@ -751,6 +751,8 @@
<file>themes/default/mIconDataDefineColor.svg</file> <file>themes/default/mIconDataDefineColor.svg</file>
<file>themes/default/mIconDataDefineColorOn.svg</file> <file>themes/default/mIconDataDefineColorOn.svg</file>
<file>themes/default/mActionNewVirtualLayer.svg</file> <file>themes/default/mActionNewVirtualLayer.svg</file>
<file>themes/default/mActionDoubleArrowRight.svg</file>
<file>themes/default/mActionDoubleArrowLeft.svg</file>
</qresource> </qresource>
<qresource prefix="/images/tips"> <qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file> <file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="16"
viewBox="0 0 4.2333332 4.2333335"
width="16"
version="1.1"
id="svg8"
sodipodi:docname="mActionDoubleArrowLeft.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06">
<metadata
id="metadata14">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs12" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1280"
inkscape:window-height="938"
id="namedview10"
showgrid="false"
inkscape:zoom="20.85965"
inkscape:cx="8.5803974"
inkscape:cy="4.1339743"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg8" />
<g
transform="rotate(90,148.23542,148.23542)"
id="g6"
style="fill-rule:evenodd">
<path
d="M 2.1166581,296.07395 0.39686386,293.42811 H 3.8364709 Z"
id="path2"
inkscape:connector-curvature="0"
style="fill:#6d97c4;stroke:#415a75;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round" />
<path
d="m 2.1127601,295.83164 -1.4731694,-2.27117 0.23030714,-7e-5 1.35909406,2.0991 z"
id="path4"
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:0.52906979" />
</g>
<g
style="fill-rule:evenodd"
transform="rotate(90,148.63229,148.63229)"
id="g6-7">
<path
style="fill:#6d97c4;stroke:#415a75;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round"
inkscape:connector-curvature="0"
d="M 2.1166581,296.07395 0.39686386,293.42811 H 3.8364709 Z"
id="path2-9" />
<path
style="fill:#ffffff;fill-opacity:0.52906979"
inkscape:connector-curvature="0"
d="m 2.1127601,295.83164 -1.4731694,-2.27117 0.23030714,-7e-5 1.35909406,2.0991 z"
id="path4-3" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="16"
viewBox="0 0 4.2333332 4.2333335"
width="16"
version="1.1"
id="svg8"
sodipodi:docname="mActionDoubleArrowRight.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06">
<metadata
id="metadata14">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs12" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1280"
inkscape:window-height="938"
id="namedview10"
showgrid="false"
inkscape:zoom="20.85965"
inkscape:cx="8.5803974"
inkscape:cy="4.1339743"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg8" />
<g
transform="rotate(-90,-144.39894,148.63228)"
id="g6"
style="fill-rule:evenodd">
<path
d="M 2.1166581,296.07395 0.39686386,293.42811 H 3.8364709 Z"
id="path2"
inkscape:connector-curvature="0"
style="fill:#6d97c4;stroke:#415a75;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round" />
<path
d="m 2.1127601,295.83164 -1.4731694,-2.27117 0.23030714,-7e-5 1.35909406,2.0991 z"
id="path4"
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:0.52906979" />
</g>
<g
style="fill-rule:evenodd"
transform="rotate(-90,-144.00207,148.23541)"
id="g6-7">
<path
style="fill:#6d97c4;stroke:#415a75;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round"
inkscape:connector-curvature="0"
d="M 2.1166581,296.07395 0.39686386,293.42811 H 3.8364709 Z"
id="path2-9" />
<path
style="fill:#ffffff;fill-opacity:0.52906979"
inkscape:connector-curvature="0"
d="m 2.1127601,295.83164 -1.4731694,-2.27117 0.23030714,-7e-5 1.35909406,2.0991 z"
id="path4-3" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -172,20 +172,36 @@ Select all currently visible features
void repaintRequested( const QModelIndexList &indexes ); void repaintRequested( const QModelIndexList &indexes );
void repaintRequested(); void repaintRequested();
void editFirstFeature();
%Docstring
editFirstFeature will try to edit the first feature of the list
.. versionadded:: 3.8
%End
void editNextFeature(); void editNextFeature();
%Docstring %Docstring
editNextFeature will try to edit next feature in form editNextFeature will try to edit next feature of the list
.. versionadded:: 3.8 .. versionadded:: 3.8
%End %End
void editPreviousFeature(); void editPreviousFeature();
%Docstring %Docstring
editPreviousFeature will try to edit previous feature in form editPreviousFeature will try to edit previous feature of the list
.. versionadded:: 3.8 .. versionadded:: 3.8
%End %End
void editLastFeature();
%Docstring
editLastFeature will try to edit the last feature of the list
.. versionadded:: 3.8
%End
}; };
/************************************************************************ /************************************************************************

View File

@ -64,6 +64,8 @@ QgsDualView::QgsDualView( QWidget *parent )
connect( mNextFeatureButton, &QToolButton::clicked, mFeatureListView, &QgsFeatureListView::editNextFeature ); connect( mNextFeatureButton, &QToolButton::clicked, mFeatureListView, &QgsFeatureListView::editNextFeature );
connect( mPreviousFeatureButton, &QToolButton::clicked, mFeatureListView, &QgsFeatureListView::editPreviousFeature ); connect( mPreviousFeatureButton, &QToolButton::clicked, mFeatureListView, &QgsFeatureListView::editPreviousFeature );
connect( mFirstFeatureButton, &QToolButton::clicked, mFeatureListView, &QgsFeatureListView::editFirstFeature );
connect( mLastFeatureButton, &QToolButton::clicked, mFeatureListView, &QgsFeatureListView::editLastFeature );
QButtonGroup *buttonGroup = new QButtonGroup( this ); QButtonGroup *buttonGroup = new QButtonGroup( this );
buttonGroup->setExclusive( false ); buttonGroup->setExclusive( false );
@ -423,10 +425,14 @@ void QgsDualView::updateEditSelectionProgress( int progress, int count )
mProgressCount->setText( QStringLiteral( "%1 / %2" ).arg( progress + 1 ).arg( count ) ); mProgressCount->setText( QStringLiteral( "%1 / %2" ).arg( progress + 1 ).arg( count ) );
mPreviousFeatureButton->setEnabled( progress > 0 ); mPreviousFeatureButton->setEnabled( progress > 0 );
mNextFeatureButton->setEnabled( progress + 1 < count ); mNextFeatureButton->setEnabled( progress + 1 < count );
mFirstFeatureButton->setEnabled( progress > 0 );
mLastFeatureButton->setEnabled( progress + 1 < count );
} }
void QgsDualView::panOrZoomToFeature( const QgsFeatureIds &featureset ) void QgsDualView::panOrZoomToFeature( const QgsFeatureIds &featureset )
{ {
//QgsDebugMsg("hey");
QgsMapCanvas *canvas = mFilterModel->mapCanvas(); QgsMapCanvas *canvas = mFilterModel->mapCanvas();
if ( canvas ) if ( canvas )
{ {

View File

@ -264,11 +264,11 @@ void QgsFeatureListView::keyPressEvent( QKeyEvent *event )
switch ( event->key() ) switch ( event->key() )
{ {
case Qt::Key_Up: case Qt::Key_Up:
editNextOrPreviousFeature( Previous ); editOtherFeature( Previous );
break; break;
case Qt::Key_Down: case Qt::Key_Down:
editNextOrPreviousFeature( Next ); editOtherFeature( Next );
break; break;
default: default:
@ -276,7 +276,7 @@ void QgsFeatureListView::keyPressEvent( QKeyEvent *event )
} }
} }
void QgsFeatureListView::editNextOrPreviousFeature( QgsFeatureListView::NextOrPrevious nextOrPrevious ) void QgsFeatureListView::editOtherFeature( QgsFeatureListView::PositionInList positionInList )
{ {
int currentRow = 0; int currentRow = 0;
if ( 0 != mCurrentEditSelectionModel->selectedIndexes().count() ) if ( 0 != mCurrentEditSelectionModel->selectedIndexes().count() )
@ -288,29 +288,31 @@ void QgsFeatureListView::editNextOrPreviousFeature( QgsFeatureListView::NextOrPr
QModelIndex newLocalIndex; QModelIndex newLocalIndex;
QModelIndex newIndex; QModelIndex newIndex;
switch ( nextOrPrevious ) switch ( positionInList )
{ {
case First:
newLocalIndex = mModel->index( 0, 0 );
break;
case Previous: case Previous:
newLocalIndex = mModel->index( currentRow - 1, 0 ); newLocalIndex = mModel->index( currentRow - 1, 0 );
newIndex = mModel->mapToMaster( newLocalIndex );
if ( newIndex.isValid() )
{
setEditSelection( newIndex, QItemSelectionModel::ClearAndSelect );
scrollTo( newLocalIndex );
}
break; break;
case Next: case Next:
newLocalIndex = mModel->index( currentRow + 1, 0 ); newLocalIndex = mModel->index( currentRow + 1, 0 );
newIndex = mModel->mapToMaster( newLocalIndex ); break;
if ( newIndex.isValid() )
{ case Last:
setEditSelection( newIndex, QItemSelectionModel::ClearAndSelect ); newLocalIndex = mModel->index( mModel->rowCount() - 1, 0 );
scrollTo( newLocalIndex );
}
break; break;
} }
newIndex = mModel->mapToMaster( newLocalIndex );
if ( newIndex.isValid() )
{
setEditSelection( newIndex, QItemSelectionModel::ClearAndSelect );
scrollTo( newLocalIndex );
}
} }
void QgsFeatureListView::contextMenuEvent( QContextMenuEvent *event ) void QgsFeatureListView::contextMenuEvent( QContextMenuEvent *event )

View File

@ -186,16 +186,30 @@ class GUI_EXPORT QgsFeatureListView : public QListView
void repaintRequested(); void repaintRequested();
/** /**
* editNextFeature will try to edit next feature in form * editFirstFeature will try to edit the first feature of the list
* \since QGIS 3.8 * \since QGIS 3.8
*/ */
void editNextFeature() {editNextOrPreviousFeature( Next );} void editFirstFeature() {editOtherFeature( First );}
/** /**
* editPreviousFeature will try to edit previous feature in form * editNextFeature will try to edit next feature of the list
* \since QGIS 3.8 * \since QGIS 3.8
*/ */
void editPreviousFeature() {editNextOrPreviousFeature( Previous );} void editNextFeature() {editOtherFeature( Next );}
/**
* editPreviousFeature will try to edit previous feature of the list
* \since QGIS 3.8
*/
void editPreviousFeature() {editOtherFeature( Previous );}
/**
* editLastFeature will try to edit the last feature of the list
* \since QGIS 3.8
*/
void editLastFeature() {editOtherFeature( Last );}
private slots: private slots:
void editSelectionChanged( const QItemSelection &deselected, const QItemSelection &selected ); void editSelectionChanged( const QItemSelection &deselected, const QItemSelection &selected );
@ -211,13 +225,15 @@ class GUI_EXPORT QgsFeatureListView : public QListView
private: private:
void selectRow( const QModelIndex &index, bool anchor ); void selectRow( const QModelIndex &index, bool anchor );
enum NextOrPrevious enum PositionInList
{ {
First,
Next, Next,
Previous Previous,
Last
}; };
void editNextOrPreviousFeature( NextOrPrevious nextOrPrevious ); void editOtherFeature( PositionInList positionInList );
QgsFeatureListModel *mModel = nullptr; QgsFeatureListModel *mModel = nullptr;

View File

@ -214,10 +214,10 @@
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="autoRaise"> <property name="checked">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked"> <property name="autoRaise">
<bool>true</bool> <bool>true</bool>
</property> </property>
<attribute name="buttonGroup"> <attribute name="buttonGroup">
@ -693,35 +693,6 @@
</tabstops> </tabstops>
<resources> <resources>
<include location="../../images/images.qrc"/> <include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>

View File

@ -134,8 +134,34 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item>
<widget class="QPushButton" name="mFirstFeatureButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionDoubleArrowLeft.svg</normaloff>:/images/themes/default/mActionDoubleArrowLeft.svg</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="mPreviousFeatureButton"> <widget class="QPushButton" name="mPreviousFeatureButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -241,6 +267,18 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="mNextFeatureButton"> <widget class="QPushButton" name="mNextFeatureButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -253,6 +291,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="mLastFeatureButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionDoubleArrowRight.svg</normaloff>:/images/themes/default/mActionDoubleArrowRight.svg</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>