Skip to content

Commit 2acb822

Browse files
author
timlinux
committedMar 26, 2009

File tree

3 files changed

+202
-82
lines changed

3 files changed

+202
-82
lines changed
 

‎src/app/attributetable/BeataDialog.cpp

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -79,38 +79,31 @@ BeataDialog::BeataDialog(QgsVectorLayer *theLayer, QWidget *parent, Qt::WindowFl
7979

8080
setWindowTitle( tr( "Attribute table - %1" ).arg( mLayer->name() ) );
8181

82-
mMenuActions = new QMenu();
83-
mMenuActions->addAction(tr("Advanced search"), this, SLOT(advancedSearch()));
84-
mMenuActions->addSeparator();
85-
mMenuActions->addAction(getThemeIcon( "/mActionCopySelected.png" ), tr("Copy selected rows"), this, SLOT(copySelectedRowsToClipboard()));
86-
mMenuActions->addAction(getThemeIcon( "/mActionZoomToSelected.png" ), tr("Zoom to selected"), this, SLOT(zoomMapToSelectedRows()));
87-
mMenuActions->addAction(getThemeIcon( "/mActionSelectedToTop.png" ), tr("Move selected to top"), this, SLOT(selectedToTop()));
88-
mMenuActions->addAction(getThemeIcon( "/mActionUnselectAttributes.png" ), tr("Clear selection"), this, SLOT(removeSelection()));
89-
mMenuActions->addAction(getThemeIcon( "/mActionInvertSelection.png" ), tr("Invert selection"), this, SLOT(invertSelection()));
90-
mMenuActions->addSeparator();
91-
82+
mRemoveSelectionButton->setIcon(getThemeIcon( "/mActionUnselectAttributes.png" ));
83+
mSelectedToTopButton->setIcon(getThemeIcon( "/mActionSelectedToTop.png" ));
84+
mCopySelectedRowsButton->setIcon(getThemeIcon( "/mActionCopySelected.png" ));
85+
mZoomMapToSelectedRowsButton->setIcon(getThemeIcon( "/mActionZoomToSelected.png" ) );
86+
mInvertSelectionButton->setIcon(getThemeIcon( "/mActionInvertSelection.png" ) );
87+
mToggleEditingButton->setIcon(getThemeIcon( "/mActionToggleEditing.png" ) );
9288
// toggle editing
93-
mActionToggleEditing = mMenuActions->addAction(getThemeIcon( "/mActionToggleEditing.png" ), tr("Toggle editing"), this, SLOT(toggleEditing()));
94-
mActionToggleEditing->setCheckable( true );
95-
mActionToggleEditing->setEnabled( mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues );
89+
mToggleEditingButton->setCheckable( true );
90+
mToggleEditingButton->setEnabled( mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues );
91+
9692
// info from table to application
9793
connect( this, SIGNAL( editingToggled( QgsMapLayer * ) ), QgisApp::instance(), SLOT( toggleEditing( QgsMapLayer * ) ) );
9894
// info from layer to table
9995
connect( mLayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
10096
connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
10197

102-
connect(btnShowAll, SIGNAL(clicked()), this, SLOT(clickedShowAll()));
103-
connect(btnShowSelected, SIGNAL(clicked()), this, SLOT(clickedShowSelected()));
104-
10598
connect(searchButton, SIGNAL(clicked()), this, SLOT(search()));
106-
connect(actionsButton, SIGNAL(clicked()), this, SLOT(showAdvanced()));
10799

108100
connect(mLayer, SIGNAL(selectionChanged()), this, SLOT(updateSelectionFromLayer()));
109101
connect(mLayer, SIGNAL(layerDeleted()), this, SLOT( close()));
110102
connect(mView->verticalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(updateRowSelection(int)));
111103
connect(mModel, SIGNAL(modelChanged()), this, SLOT(updateSelection()));
112104

113-
clickedShowAll(); // make sure the show all button is checked
105+
//make sure to show all recs on first load
106+
on_cbxShowSelectedOnly_toggled( false );
114107

115108
mLastClickedHeaderIndex = 0;
116109
mSelectionModel = new QItemSelectionModel(mFilterModel);
@@ -160,7 +153,7 @@ void BeataDialog::showAdvanced()
160153
mMenuActions->exec(QCursor::pos());
161154
}
162155

163-
void BeataDialog::selectedToTop()
156+
void BeataDialog::on_mSelectedToTopButton_clicked()
164157
{
165158
int freeIndex = 0;
166159

@@ -200,55 +193,34 @@ void BeataDialog::selectedToTop()
200193
updateSelection();
201194
}
202195

203-
void BeataDialog::copySelectedRowsToClipboard()
196+
void BeataDialog::on_mCopySelectedRowsButton_clicked()
204197
{
205198
QgisApp::instance()->editCopy(mLayer);
206199
}
207200

208-
void BeataDialog::zoomMapToSelectedRows()
201+
void BeataDialog::on_mZoomMapToSelectedRowsButton_clicked()
209202
{
210203
QgisApp::instance()->zoomToSelected();
211204
}
212205

213-
void BeataDialog::invertSelection()
206+
void BeataDialog::on_mInvertSelectionButton_clicked()
214207
{
215208
mLayer->invertSelection();
216209
}
217210

218-
void BeataDialog::removeSelection()
211+
void BeataDialog::on_mRemoveSelectionButton_clicked()
219212
{
220213
mLayer->removeSelection();
221214
}
222215

223-
void BeataDialog::clickedShowAll()
216+
void BeataDialog::on_cbxShowSelectedOnly_toggled( bool theFlag )
224217
{
225-
// the button can't be unchecked by clicking it
226-
// gets unchecked when show selected is clicked
227-
if (!btnShowAll->isChecked())
228-
{
229-
btnShowAll->setChecked(true);
230-
}
231-
btnShowSelected->setChecked(false);
232-
233-
mFilterModel->mHideUnselected = false;
218+
mFilterModel->mHideUnselected = theFlag;
234219
mFilterModel->invalidate();
235220
//TODO: weird
236221
//mModel->changeLayout();
237222
}
238223

239-
void BeataDialog::clickedShowSelected()
240-
{
241-
if (!btnShowSelected->isChecked())
242-
{
243-
btnShowSelected->setChecked(true);
244-
}
245-
btnShowAll->setChecked(false);
246-
247-
mFilterModel->mHideUnselected = true;
248-
mFilterModel->invalidate();
249-
//mModel->changeLayout();
250-
}
251-
252224
void BeataDialog::columnBoxInit()
253225
{
254226
QgsFieldMap fieldMap = mLayer->dataProvider()->fields();
@@ -502,7 +474,7 @@ void BeataDialog::search()
502474
doSearch(str);
503475
}
504476

505-
void BeataDialog::advancedSearch()
477+
void BeataDialog::on_mAdvancedSearchButton_clicked()
506478
{
507479
QgsSearchQueryBuilder dlg(mLayer, this);
508480
dlg.setSearchString(mQuery->displayText());
@@ -511,14 +483,14 @@ void BeataDialog::advancedSearch()
511483
doSearch(dlg.searchString());
512484
}
513485

514-
void BeataDialog::toggleEditing()
486+
void BeataDialog::on_mToggleEditingButton_toggled()
515487
{
516488
emit editingToggled( mLayer );
517489
}
518490

519491
void BeataDialog::editingToggled()
520492
{
521-
mActionToggleEditing->setChecked( mLayer->isEditable() );
493+
mToggleEditingButton->setChecked( mLayer->isEditable() );
522494

523495
// (probably reload data if user stopped editing - possible revert)
524496
mModel->reload(mModel->index(0,0), mModel->index(mModel->rowCount(), mModel->columnCount()));

‎src/app/attributetable/BeataDialog.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,22 @@ private slots:
5656
void submit();
5757
void revert();
5858
void search();
59-
void advancedSearch();
59+
void on_mAdvancedSearchButton_clicked();
6060
void updateSelection();
6161
void updateSelectionFromLayer();
6262
void updateRowSelection(int index);
6363
void updateRowSelection(int first, int last, bool startNewSelection);
6464

65-
void clickedShowAll();
66-
void clickedShowSelected();
65+
void on_cbxShowSelectedOnly_toggled( bool theFlag );
66+
void on_mCopySelectedRowsButton_clicked();
6767

68-
void startEditing();
69-
void invertSelection();
70-
void removeSelection();
71-
void copySelectedRowsToClipboard();
72-
void zoomMapToSelectedRows();
73-
void selectedToTop();
68+
void on_mToggleEditingButton_toggled();
69+
void on_mInvertSelectionButton_clicked();
70+
void on_mRemoveSelectionButton_clicked();
71+
void on_mZoomMapToSelectedRowsButton_clicked();
72+
void on_mSelectedToTopButton_clicked();
7473
void showAdvanced();
75-
void toggleEditing();
74+
void startEditing();
7675

7776
signals:
7877
void editingToggled( QgsMapLayer * );

‎src/ui/BeataGui.ui

Lines changed: 172 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<number>0</number>
2727
</property>
2828
<property name="horizontalSpacing" >
29-
<number>0</number>
29+
<number>2</number>
3030
</property>
3131
<property name="verticalSpacing" >
3232
<number>0</number>
@@ -41,16 +41,150 @@
4141
<item row="1" column="0" >
4242
<layout class="QHBoxLayout" >
4343
<item>
44-
<widget class="QPushButton" name="searchButton" >
44+
<widget class="QToolButton" name="mRemoveSelectionButton" >
45+
<property name="toolTip" >
46+
<string>Remove selection</string>
47+
</property>
4548
<property name="text" >
46-
<string>&amp;Search</string>
49+
<string/>
50+
</property>
51+
<property name="icon" >
52+
<iconset>../../images/themes/default/mActionUnselectAttributes.png</iconset>
53+
</property>
54+
<property name="iconSize" >
55+
<size>
56+
<width>18</width>
57+
<height>18</height>
58+
</size>
59+
</property>
60+
<property name="shortcut" >
61+
<string/>
62+
</property>
63+
</widget>
64+
</item>
65+
<item>
66+
<widget class="QToolButton" name="mSelectedToTopButton" >
67+
<property name="toolTip" >
68+
<string>Move selected to top</string>
69+
</property>
70+
<property name="text" >
71+
<string/>
72+
</property>
73+
<property name="icon" >
74+
<iconset>../../images/themes/default/mActionSelectedToTop.png</iconset>
75+
</property>
76+
<property name="iconSize" >
77+
<size>
78+
<width>18</width>
79+
<height>18</height>
80+
</size>
81+
</property>
82+
<property name="shortcut" >
83+
<string>Ctrl+T</string>
84+
</property>
85+
</widget>
86+
</item>
87+
<item>
88+
<widget class="QToolButton" name="mInvertSelectionButton" >
89+
<property name="toolTip" >
90+
<string>Invert selection</string>
91+
</property>
92+
<property name="text" >
93+
<string/>
94+
</property>
95+
<property name="icon" >
96+
<iconset>../../images/themes/default/mActionInvertSelection.png</iconset>
97+
</property>
98+
<property name="iconSize" >
99+
<size>
100+
<width>18</width>
101+
<height>18</height>
102+
</size>
103+
</property>
104+
<property name="shortcut" >
105+
<string>Ctrl+S</string>
106+
</property>
107+
</widget>
108+
</item>
109+
<item>
110+
<widget class="QToolButton" name="mCopySelectedRowsButton" >
111+
<property name="toolTip" >
112+
<string>Copy selected rows to clipboard (Ctrl+C)</string>
113+
</property>
114+
<property name="whatsThis" >
115+
<string>Copies the selected rows to the clipboard</string>
116+
</property>
117+
<property name="text" >
118+
<string/>
119+
</property>
120+
<property name="icon" >
121+
<iconset>../../images/themes/default/mActionEditCopy.png</iconset>
122+
</property>
123+
<property name="iconSize" >
124+
<size>
125+
<width>18</width>
126+
<height>18</height>
127+
</size>
128+
</property>
129+
<property name="shortcut" >
130+
<string>Ctrl+C</string>
131+
</property>
132+
</widget>
133+
</item>
134+
<item>
135+
<widget class="QToolButton" name="mZoomMapToSelectedRowsButton" >
136+
<property name="toolTip" >
137+
<string>Zoom map to the selected rows (Ctrl-J)</string>
138+
</property>
139+
<property name="whatsThis" >
140+
<string>Zoom map to the selected rows</string>
141+
</property>
142+
<property name="text" >
143+
<string/>
144+
</property>
145+
<property name="icon" >
146+
<iconset>../../images/themes/default/mActionZoomToSelected.png</iconset>
147+
</property>
148+
<property name="iconSize" >
149+
<size>
150+
<width>18</width>
151+
<height>18</height>
152+
</size>
153+
</property>
154+
<property name="shortcut" >
155+
<string>Ctrl+J</string>
156+
</property>
157+
</widget>
158+
</item>
159+
<item>
160+
<widget class="QToolButton" name="mToggleEditingButton" >
161+
<property name="toolTip" >
162+
<string>Toggle editing mode</string>
163+
</property>
164+
<property name="whatsThis" >
165+
<string>Click to toggle table editing</string>
166+
</property>
167+
<property name="text" >
168+
<string/>
169+
</property>
170+
<property name="icon" >
171+
<iconset>../../images/themes/default/mActionToggleEditing.png</iconset>
172+
</property>
173+
<property name="iconSize" >
174+
<size>
175+
<width>18</width>
176+
<height>18</height>
177+
</size>
178+
</property>
179+
<property name="checkable" >
180+
<bool>true</bool>
47181
</property>
48182
</widget>
49183
</item>
50184
<item>
51185
<widget class="QLabel" name="searchFor" >
52186
<property name="text" >
53-
<string>for</string>
187+
<string>Look for</string>
54188
</property>
55189
</widget>
56190
</item>
@@ -68,35 +202,53 @@
68202
<widget class="QComboBox" name="columnBox" />
69203
</item>
70204
<item>
71-
<widget class="QPushButton" name="btnShowAll" >
72-
<property name="focusPolicy" >
73-
<enum>Qt::NoFocus</enum>
74-
</property>
205+
<widget class="QPushButton" name="searchButton" >
75206
<property name="text" >
76-
<string>&amp;All</string>
207+
<string>&amp;Search</string>
77208
</property>
78-
<property name="checkable" >
79-
<bool>true</bool>
209+
</widget>
210+
</item>
211+
</layout>
212+
</item>
213+
<item row="2" column="0" >
214+
<layout class="QHBoxLayout" >
215+
<item>
216+
<widget class="QCheckBox" name="cbxShowSelectedOnly" >
217+
<property name="text" >
218+
<string>Show selected records only</string>
80219
</property>
81220
</widget>
82221
</item>
83222
<item>
84-
<widget class="QPushButton" name="btnShowSelected" >
85-
<property name="focusPolicy" >
86-
<enum>Qt::NoFocus</enum>
223+
<spacer>
224+
<property name="orientation" >
225+
<enum>Qt::Horizontal</enum>
87226
</property>
88-
<property name="text" >
89-
<string>S&amp;elected</string>
227+
<property name="sizeHint" >
228+
<size>
229+
<width>40</width>
230+
<height>20</height>
231+
</size>
90232
</property>
91-
<property name="checkable" >
92-
<bool>true</bool>
233+
</spacer>
234+
</item>
235+
<item>
236+
<widget class="QLabel" name="label" >
237+
<property name="text" >
238+
<string>Advanced search</string>
93239
</property>
94240
</widget>
95241
</item>
96242
<item>
97-
<widget class="QPushButton" name="actionsButton" >
243+
<widget class="QToolButton" name="mAdvancedSearchButton" >
98244
<property name="text" >
99-
<string>Actions...</string>
245+
<string>...</string>
246+
</property>
247+
<property name="iconSize" >
248+
<size>
249+
<width>12</width>
250+
<height>12</height>
251+
</size>
100252
</property>
101253
</widget>
102254
</item>
@@ -116,9 +268,6 @@
116268
<tabstop>searchButton</tabstop>
117269
<tabstop>query</tabstop>
118270
<tabstop>columnBox</tabstop>
119-
<tabstop>btnShowAll</tabstop>
120-
<tabstop>btnShowSelected</tabstop>
121-
<tabstop>actionsButton</tabstop>
122271
</tabstops>
123272
<resources/>
124273
<connections/>

0 commit comments

Comments
 (0)
Please sign in to comment.