Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[composer] New QSortFilterProxyModel for filtering items by type
and new widget QgsComposerItemComboBox for showing matching composer items. Swap existing comboboxes to use the new widget, which removes a lot of fragile code designed to allow selection of items. Additionally the combobox now show the correct item id rather than always showing "Map 0/1/..."
- Loading branch information
Showing
with
733 additions
and 599 deletions.
- +77 −0 python/core/composer/qgscomposermodel.sip
- +1 −0 python/gui/gui.sip
- +72 −0 python/gui/qgscomposeritemcombobox.sip
- +8 −64 src/app/composer/qgscomposerattributetablewidget.cpp
- +1 −5 src/app/composer/qgscomposerattributetablewidget.h
- +12 −72 src/app/composer/qgscomposerlegendwidget.cpp
- +1 −6 src/app/composer/qgscomposerlegendwidget.h
- +11 −96 src/app/composer/qgscomposermapwidget.cpp
- +1 −5 src/app/composer/qgscomposermapwidget.h
- +19 −80 src/app/composer/qgscomposerpicturewidget.cpp
- +1 −4 src/app/composer/qgscomposerpicturewidget.h
- +28 −101 src/app/composer/qgscomposerscalebarwidget.cpp
- +2 −5 src/app/composer/qgscomposerscalebarwidget.h
- +8 −66 src/app/composer/qgscompositionwidget.cpp
- +1 −5 src/app/composer/qgscompositionwidget.h
- +82 −4 src/core/composer/qgscomposermodel.cpp
- +84 −15 src/core/composer/qgscomposermodel.h
- +2 −0 src/gui/CMakeLists.txt
- +120 −0 src/gui/qgscomposeritemcombobox.cpp
- +102 −0 src/gui/qgscomposeritemcombobox.h
- +9 −4 src/ui/composer/qgscomposerattributetablewidgetbase.ui
- +9 −4 src/ui/composer/qgscomposerlegendwidgetbase.ui
- +19 −5 src/ui/composer/qgscomposermapwidgetbase.ui
- +14 −9 src/ui/composer/qgscomposerpicturewidgetbase.ui
- +26 −31 src/ui/composer/qgscomposerscalebarwidgetbase.ui
- +23 −18 src/ui/composer/qgscompositionwidgetbase.ui
@@ -0,0 +1,72 @@ | ||
/** | ||
* /class QgsComposerItemComboBox | ||
* /ingroup gui | ||
* /brief The QgsComposerItemComboBox class is a combo box which displays items of | ||
* a matching type from a composition. | ||
* /note added in 2.16 | ||
*/ | ||
class QgsComposerItemComboBox : QComboBox | ||
{ | ||
%TypeHeaderCode | ||
#include "qgscomposeritemcombobox.h" | ||
%End | ||
|
||
public: | ||
/** | ||
* QgsComposerItemComboBox creates a combo box to display a list of items in a | ||
* composition. The items can optionally be filtered by type. | ||
* @param parent parent widget | ||
* @param composition composition to show items from. If not set, no items will be shown | ||
* until setComposition() is called | ||
*/ | ||
explicit QgsComposerItemComboBox( QWidget* parent /TransferThis/ = nullptr, QgsComposition* composition = nullptr ); | ||
|
||
/** Sets the composition containing the items to list in the combo box. | ||
*/ | ||
void setComposition( QgsComposition* composition ); | ||
|
||
/** Sets a filter for the item type to show in the combo box. | ||
* @param itemType type of items to show. Set to QgsComposerItem::ComposerItem to | ||
* show all items. | ||
* @see itemType() | ||
*/ | ||
void setItemType( QgsComposerItem::ItemType itemType ); | ||
|
||
/** Returns the filter for the item types to show in the combo box. | ||
* @see setItemType() | ||
*/ | ||
QgsComposerItem::ItemType itemType() const; | ||
|
||
/** Sets a list of specific items to exclude from the combo box. | ||
* @param exceptList list of items to exclude | ||
* @see exceptedItemList() | ||
*/ | ||
void setExceptedItemList( const QList< QgsComposerItem* >& exceptList ); | ||
|
||
/** Returns the list of specific items excluded from the combo box. | ||
* @see setExceptedItemList() | ||
*/ | ||
QList< QgsComposerItem* > exceptedItemList() const; | ||
|
||
/** Return the item currently shown at the specified index within the combo box. | ||
* @param index position of item to return | ||
* @see currentItem() | ||
*/ | ||
const QgsComposerItem* item( int index ) const; | ||
|
||
/** Returns the item currently selected in the combo box. | ||
*/ | ||
const QgsComposerItem* currentItem() const; | ||
|
||
public slots: | ||
/** Sets the currently selected item in the combo box. | ||
* @param item selected item | ||
*/ | ||
void setItem( const QgsComposerItem* item ); | ||
|
||
signals: | ||
|
||
//! Emitted whenever the currently selected item changes | ||
void itemChanged( QgsComposerItem* item ); | ||
|
||
}; |
Oops, something went wrong.