3339.patch
src/app/CMakeLists.txt (working copy) | ||
---|---|---|
103 | 103 |
composer/qgscomposershapewidget.cpp |
104 | 104 |
composer/qgscomposertablewidget.cpp |
105 | 105 |
composer/qgscomposerlegenditemdialog.cpp |
106 |
composer/qgscomposerlegendlayersdialog.cpp |
|
106 | 107 |
composer/qgscomposerlegendwidget.cpp |
107 | 108 |
composer/qgscompositionwidget.cpp |
108 | 109 |
composer/qgsitempositiondialog.cpp |
src/app/composer/qgscomposerlegendlayersdialog.cpp (revision 0) | ||
---|---|---|
1 |
/*************************************************************************** |
|
2 |
qgscomposerlegendlayersdialog.cpp |
|
3 |
------------------------------- |
|
4 |
***************************************************************************/ |
|
5 | ||
6 |
/*************************************************************************** |
|
7 |
* * |
|
8 |
* This program is free software; you can redistribute it and/or modify * |
|
9 |
* it under the terms of the GNU General Public License as published by * |
|
10 |
* the Free Software Foundation; either version 2 of the License, or * |
|
11 |
* (at your option) any later version. * |
|
12 |
* * |
|
13 |
***************************************************************************/ |
|
14 | ||
15 |
#include "qgscomposerlegendlayersdialog.h" |
|
16 | ||
17 |
#include <QStandardItem> |
|
18 | ||
19 |
QgsComposerLegendLayersDialog::QgsComposerLegendLayersDialog( QList<QgsMapLayer*> layers, QWidget* parent ): QDialog( parent ) |
|
20 |
{ |
|
21 |
setupUi( this ); |
|
22 | ||
23 |
QList<QgsMapLayer*>::iterator layerIt = layers.begin(); |
|
24 |
for (; layerIt != layers.end(); ++layerIt ) |
|
25 |
{ |
|
26 |
QListWidgetItem* item = new QListWidgetItem(( *layerIt )->name(), listMapLayers ); |
|
27 |
mItemLayerMap.insert( item, *layerIt ); |
|
28 |
} |
|
29 |
} |
|
30 | ||
31 |
QgsComposerLegendLayersDialog::QgsComposerLegendLayersDialog(): QDialog( 0 ) |
|
32 |
{ |
|
33 | ||
34 |
} |
|
35 | ||
36 |
QgsComposerLegendLayersDialog::~QgsComposerLegendLayersDialog() |
|
37 |
{ |
|
38 | ||
39 |
} |
|
40 | ||
41 |
QgsMapLayer* QgsComposerLegendLayersDialog::selectedLayer() |
|
42 |
{ |
|
43 |
QListWidgetItem* item = listMapLayers->currentItem(); |
|
44 |
if ( !item ) |
|
45 |
{ |
|
46 |
return 0; |
|
47 |
} |
|
48 | ||
49 |
QMap<QListWidgetItem*, QgsMapLayer*>::iterator it = mItemLayerMap.find( item ); |
|
50 |
QgsMapLayer* c = 0; |
|
51 |
c = it.value(); |
|
52 |
return c; |
|
53 |
} |
src/app/composer/qgscomposerlegendlayersdialog.h (revision 0) | ||
---|---|---|
1 |
/*************************************************************************** |
|
2 |
qgscomposerlegenditemdialog.h |
|
3 |
----------------------------- |
|
4 |
***************************************************************************/ |
|
5 | ||
6 |
/*************************************************************************** |
|
7 |
* * |
|
8 |
* This program is free software; you can redistribute it and/or modify * |
|
9 |
* it under the terms of the GNU General Public License as published by * |
|
10 |
* the Free Software Foundation; either version 2 of the License, or * |
|
11 |
* (at your option) any later version. * |
|
12 |
* * |
|
13 |
***************************************************************************/ |
|
14 | ||
15 |
#ifndef QGSCOMPOSERLEGENDLAYERSDIALOG_H |
|
16 |
#define QGSCOMPOSERLEGENDLAYERSDIALOG_H |
|
17 | ||
18 |
#include "ui_qgscomposerlegendlayersdialogbase.h" |
|
19 |
#include "qgsmaplayer.h" |
|
20 | ||
21 |
/** \ingroup MapComposer |
|
22 |
* A dialog to add new layers to the legend. |
|
23 |
* */ |
|
24 |
class QgsComposerLegendLayersDialog: private Ui::QgsComposerLegendLayersDialogBase, public QDialog |
|
25 |
{ |
|
26 |
public: |
|
27 |
QgsComposerLegendLayersDialog( QList<QgsMapLayer*> layers, QWidget* parent = 0 ); |
|
28 |
~QgsComposerLegendLayersDialog(); |
|
29 |
QgsMapLayer* selectedLayer(); |
|
30 | ||
31 |
private: |
|
32 |
QgsComposerLegendLayersDialog(); //forbidden |
|
33 | ||
34 |
/**Stores the relation between items and map layer pointers. */ |
|
35 |
QMap<QListWidgetItem*, QgsMapLayer*> mItemLayerMap; |
|
36 |
}; |
|
37 | ||
38 |
#endif //QGSCOMPOSERLEGENDITEMDIALOG_H |
src/app/composer/qgscomposerlegendwidget.cpp (working copy) | ||
---|---|---|
18 | 18 |
#include "qgscomposerlegendwidget.h" |
19 | 19 |
#include "qgscomposerlegend.h" |
20 | 20 |
#include "qgscomposerlegenditemdialog.h" |
21 |
#include "qgscomposerlegendlayersdialog.h" |
|
21 | 22 |
#include "qgscomposeritemwidget.h" |
22 | 23 |
#include <QFontDialog> |
23 | 24 | |
... | ... | |
25 | 26 |
#include "qgisapp.h" |
26 | 27 |
#include "qgsmapcanvas.h" |
27 | 28 |
#include "qgsmaprenderer.h" |
29 |
#include "qgsapplication.h" |
|
28 | 30 | |
31 |
#include <QMessageBox> |
|
32 | ||
29 | 33 |
QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend* legend ): mLegend( legend ) |
30 | 34 |
{ |
31 | 35 |
setupUi( this ); |
32 | 36 | |
37 |
// setup icons |
|
38 |
mAddToolButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.png" ) ) ); |
|
39 |
mEditPushButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyEdit.png" ) ) ); |
|
40 |
mRemoveToolButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.png" ) ) ); |
|
41 |
mMoveUpToolButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.png" ) ) ); |
|
42 |
mMoveDownToolButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.png" ) ) ); |
|
43 | ||
33 | 44 |
//add widget for item properties |
34 | 45 |
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, legend ); |
35 | 46 |
toolBox->addItem( itemPropertiesWidget, tr( "Item Options" ) ); |
... | ... | |
77 | 88 |
blockSignals( false ); |
78 | 89 |
} |
79 | 90 | |
80 | ||
81 | 91 |
void QgsComposerLegendWidget::on_mTitleLineEdit_textChanged( const QString& text ) |
82 | 92 |
{ |
83 | 93 |
if ( mLegend ) |
... | ... | |
360 | 370 |
mLegend->endCommand(); |
361 | 371 |
} |
362 | 372 | |
373 |
void QgsComposerLegendWidget::on_mCheckBoxAutoUpdate_stateChanged ( int state ) |
|
374 |
{ |
|
375 |
if ( state == Qt::Checked ) |
|
376 |
{ |
|
377 |
mLegend->model()->setAutoUpdate( true ); |
|
378 |
} |
|
379 |
else |
|
380 |
{ |
|
381 |
mLegend->model()->setAutoUpdate( false ); |
|
382 |
} |
|
383 |
} |
|
384 | ||
385 |
void QgsComposerLegendWidget::on_mAddToolButton_clicked() |
|
386 |
{ |
|
387 |
if ( !mLegend ) |
|
388 |
{ |
|
389 |
return; |
|
390 |
} |
|
391 | ||
392 |
QStandardItemModel* itemModel = qobject_cast<QStandardItemModel *>( mItemTreeView->model() ); |
|
393 |
if ( !itemModel ) |
|
394 |
{ |
|
395 |
return; |
|
396 |
} |
|
397 | ||
398 |
QgisApp* app = QgisApp::instance(); |
|
399 |
if ( !app ) |
|
400 |
{ |
|
401 |
return; |
|
402 |
} |
|
403 | ||
404 |
QgsMapCanvas* canvas = app->mapCanvas(); |
|
405 |
if ( canvas ) |
|
406 |
{ |
|
407 |
QList<QgsMapLayer*> layers = canvas->layers(); |
|
408 | ||
409 |
QgsComposerLegendLayersDialog addDialog( layers ); |
|
410 |
if ( addDialog.exec() == QDialog::Accepted ) |
|
411 |
{ |
|
412 |
QgsMapLayer* layer = addDialog.selectedLayer(); |
|
413 |
if ( layer ) |
|
414 |
{ |
|
415 |
mLegend->beginCommand( "Legend item added" ); |
|
416 |
mLegend->model()->addLayer( layer ); |
|
417 |
mLegend->endCommand(); |
|
418 |
} |
|
419 |
} |
|
420 |
} |
|
421 |
} |
|
422 | ||
363 | 423 |
void QgsComposerLegendWidget::on_mRemoveToolButton_clicked() |
364 | 424 |
{ |
365 | 425 |
if ( !mLegend ) |
src/app/composer/qgscomposerlegendwidget.h (working copy) | ||
---|---|---|
50 | 50 |
void on_mLayerFontButton_clicked(); |
51 | 51 |
void on_mItemFontButton_clicked(); |
52 | 52 |
void on_mBoxSpaceSpinBox_valueChanged( double d ); |
53 |
void on_mCheckBoxAutoUpdate_stateChanged (int state ); |
|
53 | 54 | |
54 | 55 |
//item manipulation |
55 | 56 |
void on_mMoveDownToolButton_clicked(); |
56 | 57 |
void on_mMoveUpToolButton_clicked(); |
57 | 58 |
void on_mRemoveToolButton_clicked(); |
59 |
void on_mAddToolButton_clicked(); |
|
58 | 60 |
void on_mEditPushButton_clicked(); |
59 | 61 |
void on_mUpdatePushButton_clicked(); |
60 | 62 |
void on_mUpdateAllPushButton_clicked(); |
src/core/composer/qgslegendmodel.cpp (working copy) | ||
---|---|---|
32 | 32 |
#include <QDomElement> |
33 | 33 |
#include <QMimeData> |
34 | 34 |
#include <QSettings> |
35 |
#include <QMessageBox> |
|
35 | 36 | |
36 | 37 |
QgsLegendModel::QgsLegendModel(): QStandardItemModel() |
37 | 38 |
{ |
... | ... | |
40 | 41 |
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); |
41 | 42 |
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( addLayer( QgsMapLayer* ) ) ); |
42 | 43 |
} |
44 | ||
43 | 45 |
setItemPrototype( new QgsComposerSymbolItem() ); |
44 | 46 | |
45 | 47 |
QWidgetList topLevelWidgets = QApplication::topLevelWidgets(); |
... | ... | |
674 | 676 |
emit layersChanged(); |
675 | 677 |
return true; |
676 | 678 |
} |
679 | ||
680 |
void QgsLegendModel::setAutoUpdate(bool autoUpdate) |
|
681 |
{ |
|
682 |
mAutoUpdate = autoUpdate; |
|
683 |
if ( autoUpdate ) |
|
684 |
{ |
|
685 |
if ( QgsMapLayerRegistry::instance() ) |
|
686 |
{ |
|
687 |
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); |
|
688 |
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( addLayer( QgsMapLayer* ) ) ); |
|
689 |
} |
|
690 |
} |
|
691 |
else |
|
692 |
{ |
|
693 |
if ( QgsMapLayerRegistry::instance() ) |
|
694 |
{ |
|
695 |
disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); |
|
696 |
disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( addLayer( QgsMapLayer* ) ) ); |
|
697 |
} |
|
698 |
} |
|
699 |
} |
src/core/composer/qgslegendmodel.h (working copy) | ||
---|---|---|
84 | 84 |
/**Implements the drop operation*/ |
85 | 85 |
bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ); |
86 | 86 | |
87 |
void setAutoUpdate( bool autoUpdate ); |
|
88 |
bool AutoUpdaet() { return mAutoUpdate; } |
|
87 | 89 | |
88 | 90 |
public slots: |
89 | 91 |
void removeLayer( const QString& layerId ); |
... | ... | |
112 | 114 |
/**True if this application has toplevel windows (normally true). If this is false, this means that the application |
113 | 115 |
might not have a running x-server on unix systems and so QPixmap and QIcon cannot be used*/ |
114 | 116 |
bool mHasTopLevelWindow; |
117 | ||
118 |
/**True if the legend is auto updated when layers are added or removed from the map canvas */ |
|
119 |
bool mAutoUpdate; |
|
115 | 120 |
}; |
116 | 121 | |
117 | 122 |
#endif |
src/ui/qgscomposerlegendlayersdialogbase.ui (revision 0) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
3 |
<class>QgsComposerLegendLayersDialogBase</class> |
|
4 |
<widget class="QDialog" name="QgsComposerLegendLayersDialogBase"> |
|
5 |
<property name="geometry"> |
|
6 |
<rect> |
|
7 |
<x>0</x> |
|
8 |
<y>0</y> |
|
9 |
<width>252</width> |
|
10 |
<height>194</height> |
|
11 |
</rect> |
|
12 |
</property> |
|
13 |
<property name="windowTitle"> |
|
14 |
<string>Add layer to legend</string> |
|
15 |
</property> |
|
16 |
<layout class="QGridLayout" name="gridLayout"> |
|
17 |
<item row="0" column="0"> |
|
18 |
<widget class="QListWidget" name="listMapLayers"/> |
|
19 |
</item> |
|
20 |
<item row="1" column="0"> |
|
21 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
22 |
<property name="orientation"> |
|
23 |
<enum>Qt::Horizontal</enum> |
|
24 |
</property> |
|
25 |
<property name="standardButtons"> |
|
26 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
27 |
</property> |
|
28 |
</widget> |
|
29 |
</item> |
|
30 |
</layout> |
|
31 |
</widget> |
|
32 |
<resources/> |
|
33 |
<connections> |
|
34 |
<connection> |
|
35 |
<sender>buttonBox</sender> |
|
36 |
<signal>accepted()</signal> |
|
37 |
<receiver>QgsComposerLegendLayersDialogBase</receiver> |
|
38 |
<slot>accept()</slot> |
|
39 |
<hints> |
|
40 |
<hint type="sourcelabel"> |
|
41 |
<x>248</x> |
|
42 |
<y>254</y> |
|
43 |
</hint> |
|
44 |
<hint type="destinationlabel"> |
|
45 |
<x>157</x> |
|
46 |
<y>274</y> |
|
47 |
</hint> |
|
48 |
</hints> |
|
49 |
</connection> |
|
50 |
<connection> |
|
51 |
<sender>buttonBox</sender> |
|
52 |
<signal>rejected()</signal> |
|
53 |
<receiver>QgsComposerLegendLayersDialogBase</receiver> |
|
54 |
<slot>reject()</slot> |
|
55 |
<hints> |
|
56 |
<hint type="sourcelabel"> |
|
57 |
<x>316</x> |
|
58 |
<y>260</y> |
|
59 |
</hint> |
|
60 |
<hint type="destinationlabel"> |
|
61 |
<x>286</x> |
|
62 |
<y>274</y> |
|
63 |
</hint> |
|
64 |
</hints> |
|
65 |
</connection> |
|
66 |
</connections> |
|
67 |
</ui> |
src/ui/qgscomposerlegendwidgetbase.ui (working copy) | ||
---|---|---|
6 | 6 |
<rect> |
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 |
<width>369</width>
|
|
10 |
<height>471</height>
|
|
9 |
<width>371</width>
|
|
10 |
<height>476</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="sizePolicy"> |
... | ... | |
34 | 34 |
<x>0</x> |
35 | 35 |
<y>0</y> |
36 | 36 |
<width>367</width> |
37 |
<height>469</height>
|
|
37 |
<height>472</height>
|
|
38 | 38 |
</rect> |
39 | 39 |
</property> |
40 | 40 |
<layout class="QGridLayout" name="gridLayout_3"> |
... | ... | |
49 | 49 |
<x>0</x> |
50 | 50 |
<y>0</y> |
51 | 51 |
<width>349</width> |
52 |
<height>397</height>
|
|
52 |
<height>398</height>
|
|
53 | 53 |
</rect> |
54 | 54 |
</property> |
55 | 55 |
<attribute name="label"> |
... | ... | |
184 | 184 |
<x>0</x> |
185 | 185 |
<y>0</y> |
186 | 186 |
<width>349</width> |
187 |
<height>397</height>
|
|
187 |
<height>398</height>
|
|
188 | 188 |
</rect> |
189 | 189 |
</property> |
190 | 190 |
<attribute name="label"> |
191 | 191 |
<string>Legend items</string> |
192 | 192 |
</attribute> |
193 | 193 |
<layout class="QGridLayout" name="gridLayout_2"> |
194 |
<item row="0" column="0" colspan="7">
|
|
194 |
<item row="1" column="0" colspan="8">
|
|
195 | 195 |
<widget class="QTreeView" name="mItemTreeView"> |
196 | 196 |
<property name="sizePolicy"> |
197 | 197 |
<sizepolicy hsizetype="Minimum" vsizetype="Expanding"> |
... | ... | |
199 | 199 |
<verstretch>0</verstretch> |
200 | 200 |
</sizepolicy> |
201 | 201 |
</property> |
202 |
<property name="wordWrap"> |
|
203 |
<bool>false</bool> |
|
204 |
</property> |
|
202 | 205 |
<property name="headerHidden"> |
203 | 206 |
<bool>true</bool> |
204 | 207 |
</property> |
208 |
<attribute name="headerVisible"> |
|
209 |
<bool>false</bool> |
|
210 |
</attribute> |
|
211 |
<attribute name="headerVisible"> |
|
212 |
<bool>false</bool> |
|
213 |
</attribute> |
|
205 | 214 |
</widget> |
206 | 215 |
</item> |
207 |
<item row="1" column="0">
|
|
216 |
<item row="2" column="0">
|
|
208 | 217 |
<widget class="QToolButton" name="mMoveDownToolButton"> |
209 | 218 |
<property name="text"> |
210 |
<string>v</string>
|
|
219 |
<string/>
|
|
211 | 220 |
</property> |
212 | 221 |
</widget> |
213 | 222 |
</item> |
214 |
<item row="1" column="1">
|
|
223 |
<item row="2" column="1">
|
|
215 | 224 |
<widget class="QToolButton" name="mMoveUpToolButton"> |
216 | 225 |
<property name="text"> |
217 |
<string>^</string>
|
|
226 |
<string/>
|
|
218 | 227 |
</property> |
219 | 228 |
</widget> |
220 | 229 |
</item> |
221 |
<item row="1" column="2"> |
|
230 |
<item row="2" column="2"> |
|
231 |
<widget class="QToolButton" name="mAddToolButton"> |
|
232 |
<property name="text"> |
|
233 |
<string/> |
|
234 |
</property> |
|
235 |
</widget> |
|
236 |
</item> |
|
237 |
<item row="2" column="3"> |
|
222 | 238 |
<widget class="QToolButton" name="mRemoveToolButton"> |
223 | 239 |
<property name="text"> |
224 |
<string>X</string>
|
|
240 |
<string/>
|
|
225 | 241 |
</property> |
226 | 242 |
</widget> |
227 | 243 |
</item> |
228 |
<item row="1" column="3">
|
|
244 |
<item row="2" column="4">
|
|
229 | 245 |
<widget class="QToolButton" name="mEditPushButton"> |
230 | 246 |
<property name="text"> |
231 |
<string>Edit</string>
|
|
247 |
<string/>
|
|
232 | 248 |
</property> |
233 | 249 |
</widget> |
234 | 250 |
</item> |
235 |
<item row="1" column="4">
|
|
251 |
<item row="2" column="5">
|
|
236 | 252 |
<widget class="QToolButton" name="mUpdatePushButton"> |
237 | 253 |
<property name="text"> |
238 | 254 |
<string>Update</string> |
239 | 255 |
</property> |
240 | 256 |
</widget> |
241 | 257 |
</item> |
242 |
<item row="1" column="5">
|
|
258 |
<item row="2" column="6">
|
|
243 | 259 |
<widget class="QToolButton" name="mUpdateAllPushButton"> |
244 | 260 |
<property name="text"> |
245 | 261 |
<string>All</string> |
246 | 262 |
</property> |
247 | 263 |
</widget> |
248 | 264 |
</item> |
249 |
<item row="1" column="6">
|
|
265 |
<item row="2" column="7">
|
|
250 | 266 |
<widget class="QToolButton" name="mAddGroupButton"> |
251 | 267 |
<property name="text"> |
252 | 268 |
<string>Add group</string> |
253 | 269 |
</property> |
254 | 270 |
</widget> |
255 | 271 |
</item> |
272 |
<item row="0" column="0" colspan="3"> |
|
273 |
<widget class="QCheckBox" name="mCheckBoxAutoUpdate"> |
|
274 |
<property name="sizePolicy"> |
|
275 |
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> |
|
276 |
<horstretch>0</horstretch> |
|
277 |
<verstretch>0</verstretch> |
|
278 |
</sizepolicy> |
|
279 |
</property> |
|
280 |
<property name="text"> |
|
281 |
<string>Auto Update</string> |
|
282 |
</property> |
|
283 |
<property name="checked"> |
|
284 |
<bool>true</bool> |
|
285 |
</property> |
|
286 |
</widget> |
|
287 |
</item> |
|
256 | 288 |
</layout> |
257 | 289 |
</widget> |
258 | 290 |
</widget> |