/usr/include/qgis/qgsdualview.h is in libqgis-dev 2.18.17+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | /***************************************************************************
qgsdualview.h
--------------------------------------
Date : 10.2.2013
Copyright : (C) 2013 Matthias Kuhn
Email : matthias at opengis dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSDUALVIEW_H
#define QGSDUALVIEW_H
#include <QStackedWidget>
#include "ui_qgsdualviewbase.h"
#include "qgsfieldconditionalformatwidget.h"
#include "qgsattributeeditorcontext.h"
#include "qgsattributetablefiltermodel.h"
#include "qgscachedfeatureiterator.h"
#include "qgsdistancearea.h"
#include "qgsattributeform.h"
class QgsAttributeForm;
class QgsFeatureRequest;
class QSignalMapper;
class QgsMapLayerAction;
class QScrollArea;
/** \ingroup gui
* This widget is used to show the attributes of a set of features of a {@link QgsVectorLayer}.
* The attributes can be edited.
* It supports two different layouts: the table layout, in which the attributes for the features
* are shown in a table and the editor layout, where the features are shown as a selectable list
* and the attributes for the currently selected feature are shown in a form.
*/
class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
{
Q_OBJECT
Q_ENUMS( ViewMode )
public:
/**
* The view modes, in which this widget can present information.
* Relates to the QStackedWidget stacks.
*
*/
enum ViewMode
{
/**
* Shows the features and attributes in a table layout
*/
AttributeTable = 0,
/**
* Show a list of the features, where one can be chosen
* and the according attribute dialog will be presented
* in the neighbouring frame.
*/
AttributeEditor = 1
};
/**
* @brief Constructor
* @param parent The parent widget
*/
explicit QgsDualView( QWidget* parent = nullptr );
/**
* Has to be called to initialize the dual view.
*
* @param layer The layer which should be used to fetch features
* @param mapCanvas The mapCanvas (used for the FilterMode
* {@link QgsAttributeTableFilterModel::ShowVisible}
* @param request Use a modified request to limit the shown features
* @param context The context in which this view is shown
* @param loadFeatures whether to initially load all features into the view. If set to
* false, limited features can later be loaded using setFilterMode()
*/
void init( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request = QgsFeatureRequest(), const QgsAttributeEditorContext &context = QgsAttributeEditorContext(),
bool loadFeatures = true );
/**
* Change the current view mode.
*
* @param view The view mode to set
* @see view()
*/
void setView( ViewMode view );
/**
* Returns the current view mode.
* @see setView()
* @note added in QGIS 2.16
*/
ViewMode view() const;
/**
* Set the filter mode
*
* @param filterMode
*/
void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
/**
* Get the filter mode
*
* @return the filter mode
*/
QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
/**
* Toggle the selectedOnTop flag. If enabled, selected features will be moved to top.
*
* @param selectedOnTop True: Show selected features on top.
* False: Use defined sorting column.
*/
void setSelectedOnTop( bool selectedOnTop );
/**
* Returns the number of features on the layer.
*
* @return Number of features
*/
int featureCount();
/**
* Returns the number of features which are currently visible, according to the
* filter restrictions
*
* @return Number of features
*/
int filteredFeatureCount();
/**
* Set a list of currently visible features
*
* @param filteredFeatures A list of feature ids
*
*/
void setFilteredFeatures( const QgsFeatureIds& filteredFeatures );
/**
* Get a list of currently visible feature ids.
*/
QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
/**
* Returns the model which has the information about all features (not only filtered)
*
* @return The master model
*/
QgsAttributeTableModel* masterModel() const { return mMasterModel; }
/**
* Set the request
*
* @param request The request
*/
void setRequest( const QgsFeatureRequest& request );
/**
* Set the feature selection model
*
* @param featureSelectionManager the feature selection model
*/
void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
/**
* Returns the table view
*
* @return The table view
*/
QgsAttributeTableView* tableView() { return mTableView; }
/**
* Set the attribute table config which should be used to control
* the appearance of the attribute table.
*/
void setAttributeTableConfig( const QgsAttributeTableConfig& config );
/**
* Set the expression used for sorting the table and feature list.
*/
void setSortExpression( const QString& sortExpression , Qt::SortOrder sortOrder = Qt::AscendingOrder );
/**
* Get the expression used for sorting the table and feature list.
*/
QString sortExpression() const;
protected:
/**
* Initializes widgets which depend on the attributes of this layer
*/
void columnBoxInit();
public slots:
/**
* @brief Set the current edit selection in the {@link AttributeEditor} mode.
*
* @param fids A list of edited features (Currently only one at a time is supported)
*/
void setCurrentEditSelection( const QgsFeatureIds& fids );
/**
* @brief saveEditChanges
*
* @return true if the saving was ok. false is possible due to connected
* validation logic.
*/
bool saveEditChanges();
void openConditionalStyles();
/** Sets whether multi edit mode is enabled.
* @note added in QGIS 2.16
*/
void setMultiEditEnabled( bool enabled );
/** Toggles whether search mode should be enabled in the form.
* @param enabled set to true to switch on search mode
* @note added in QGIS 2.16
*/
void toggleSearchMode( bool enabled );
/**
* Copy the content of the selected cell in the clipboard.
* @note added in QGIS 1.16
*/
void copyCellContent() const;
signals:
/**
* Is emitted, whenever the display expression is successfully changed
* @param expression The expression that was applied
*/
void displayExpressionChanged( const QString& expression );
/**
* Is emitted, whenever the filter changes
*/
void filterChanged();
/** Is emitted when a filter expression is set using the view.
* @param expression filter expression
* @param type filter type
* @note added in QGIS 2.16
*/
void filterExpressionSet( const QString& expression, QgsAttributeForm::FilterType type );
/** Emitted when the form changes mode.
* @param mode new mode
*/
void formModeChanged( QgsAttributeForm::Mode mode );
private slots:
void on_mFeatureList_aboutToChangeEditSelection( bool& ok );
/**
* Changes the currently visible feature within the attribute editor
*
* @param feat The newly visible feature
*/
void on_mFeatureList_currentEditSelectionChanged( const QgsFeature& feat );
void previewExpressionBuilder();
void previewColumnChanged( QObject* previewAction );
void viewWillShowContextMenu( QMenu* menu, const QModelIndex& atIndex );
void showViewHeaderMenu( QPoint point );
void organizeColumns();
void tableColumnResized( int column, int width );
void hideColumn();
void resizeColumn();
void autosizeColumn();
void modifySort();
void previewExpressionChanged( const QString& expression );
void onSortColumnChanged();
void sortByPreviewExpression();
void updateSelectedFeatures();
void extentChanged();
/**
* Will be called whenever the currently shown feature form changes.
* Will forward this signal to the feature list to visually represent
* that there has been an edit event.
*/
void featureFormAttributeChanged();
/**
* Will be called periodically, when loading layers from slow data providers.
*
* @param i The number of features already loaded
* @param cancel Set to true to cancel
*/
virtual void progress( int i, bool &cancel );
/**
* Will be called, once all the features are loaded.
* Use e.g. to close a dialog created from progress( int i, bool &cancel )
*/
virtual void finished();
/** Zooms to the active feature*/
void zoomToCurrentFeature();
void rebuildFullLayerCache();
private:
void initLayerCache( bool cacheGeometry );
void initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request, bool loadFeatures );
QgsAttributeEditorContext mEditorContext;
QgsAttributeTableModel* mMasterModel;
QgsAttributeTableFilterModel* mFilterModel;
QgsFeatureListModel* mFeatureListModel;
QgsAttributeForm* mAttributeForm;
QSignalMapper* mPreviewActionMapper;
QMenu* mPreviewColumnsMenu;
QMenu* mHorizontalHeaderMenu;
QgsVectorLayerCache* mLayerCache;
QgsVectorLayer *mLayer;
QProgressDialog* mProgressDlg;
QgsIFeatureSelectionManager* mFeatureSelectionManager;
QgsDistanceArea mDistanceArea;
QString mDisplayExpression;
QgsAttributeTableConfig mConfig;
QScrollArea* mAttributeEditorScrollArea;
QgsMapCanvas *mMapCanvas;
friend class TestQgsDualView;
friend class TestQgsAttributeTable;
};
/** \ingroup gui
* \class QgsAttributeTableAction
*/
class GUI_EXPORT QgsAttributeTableAction : public QAction
{
Q_OBJECT
public:
QgsAttributeTableAction( const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx )
: QAction( name, dualView )
, mDualView( dualView )
, mAction( action )
, mFieldIdx( fieldIdx )
{}
public slots:
void execute();
void featureForm();
private:
QgsDualView* mDualView;
int mAction;
QModelIndex mFieldIdx;
};
/** \ingroup gui
* \class QgsAttributeTableMapLayerAction
*/
class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
{
Q_OBJECT
public:
QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction* action, const QModelIndex &fieldIdx )
: QAction( name, dualView )
, mDualView( dualView )
, mAction( action )
, mFieldIdx( fieldIdx )
{}
public slots:
void execute();
private:
QgsDualView* mDualView;
QgsMapLayerAction* mAction;
QModelIndex mFieldIdx;
};
Q_DECLARE_METATYPE( QModelIndex );
#endif // QGSDUALVIEW_H
|