@@ -105,6 +105,7 @@ QgsGrassAttributes::QgsGrassAttributes ( QgsGrassEdit *edit, QgsGrassProvider *p
105
105
// TODO: does not work:
106
106
connect ( tabCats, SIGNAL (void currentChanged (QWidget *)), this , SLOT (tabChanged (QWidget *)));
107
107
108
+ resetButtons ();
108
109
restorePosition ();
109
110
}
110
111
@@ -173,6 +174,8 @@ int QgsGrassAttributes::addTab ( const QString & label )
173
174
QgsGrassAttributesKeyPress *ef = new QgsGrassAttributesKeyPress ( tb );
174
175
tb->installEventFilter ( ef );
175
176
177
+ resetButtons ();
178
+
176
179
return ( tabCats->count () - 1 );
177
180
}
178
181
@@ -224,6 +227,8 @@ void QgsGrassAttributes::addAttribute ( int tab, const QString &name, const QStr
224
227
// because QgsGrassProvider::attributes is using mEncoding->toUnicode()
225
228
tb->setText ( row, 1 , QString::fromLocal8Bit (value) );
226
229
tb->setText ( row, 2 , type );
230
+
231
+ resetButtons ();
227
232
}
228
233
229
234
void QgsGrassAttributes::addTextRow ( int tab, const QString &text )
@@ -247,6 +252,8 @@ void QgsGrassAttributes::updateAttributes ( )
247
252
std::cerr << " QgsGrassAttributes::updateAttributes()" << std::endl;
248
253
#endif
249
254
255
+ if ( tabCats->count () == 0 ) return ;
256
+
250
257
Q3Table *tb = (Q3Table *) tabCats->currentPage ();
251
258
252
259
if ( tb->numRows () > 2 ) {
@@ -307,13 +314,16 @@ void QgsGrassAttributes::addCat ( )
307
314
// Select new tab
308
315
tabCats->setCurrentPage ( tabCats->count ()-1 );
309
316
317
+ resetButtons ();
310
318
}
311
319
312
320
void QgsGrassAttributes::deleteCat ( )
313
321
{
314
322
#ifdef QGISDEBUG
315
323
std::cerr << " QgsGrassAttributes::deleteCat()" << std::endl;
316
324
#endif
325
+
326
+ if ( tabCats->count () == 0 ) return ;
317
327
318
328
Q3Table *tb = (Q3Table *) tabCats->currentPage ();
319
329
@@ -324,6 +334,7 @@ void QgsGrassAttributes::deleteCat ( )
324
334
325
335
tabCats->removePage ( tb );
326
336
delete tb;
337
+ resetButtons ();
327
338
}
328
339
329
340
void QgsGrassAttributes::tabChanged ( QWidget *widget )
@@ -341,3 +352,17 @@ void QgsGrassAttributes::setLine ( int line )
341
352
{
342
353
mLine = line;
343
354
}
355
+
356
+ void QgsGrassAttributes::resetButtons ( )
357
+ {
358
+ if ( tabCats->count () == 0 )
359
+ {
360
+ deleteButton->setEnabled (false );
361
+ updateButton->setEnabled (false );
362
+ }
363
+ else
364
+ {
365
+ deleteButton->setEnabled (true );
366
+ updateButton->setEnabled (true );
367
+ }
368
+ }
0 commit comments