@@ -105,6 +105,7 @@ QgsGrassAttributes::QgsGrassAttributes ( QgsGrassEdit *edit, QgsGrassProvider *p
105105 // TODO: does not work:
106106 connect ( tabCats, SIGNAL (void currentChanged (QWidget *)), this , SLOT (tabChanged (QWidget *)));
107107
108+ resetButtons ();
108109 restorePosition ();
109110}
110111
@@ -173,6 +174,8 @@ int QgsGrassAttributes::addTab ( const QString & label )
173174 QgsGrassAttributesKeyPress *ef = new QgsGrassAttributesKeyPress ( tb );
174175 tb->installEventFilter ( ef );
175176
177+ resetButtons ();
178+
176179 return ( tabCats->count () - 1 );
177180}
178181
@@ -224,6 +227,8 @@ void QgsGrassAttributes::addAttribute ( int tab, const QString &name, const QStr
224227 // because QgsGrassProvider::attributes is using mEncoding->toUnicode()
225228 tb->setText ( row, 1 , QString::fromLocal8Bit (value) );
226229 tb->setText ( row, 2 , type );
230+
231+ resetButtons ();
227232}
228233
229234void QgsGrassAttributes::addTextRow ( int tab, const QString &text )
@@ -247,6 +252,8 @@ void QgsGrassAttributes::updateAttributes ( )
247252 std::cerr << " QgsGrassAttributes::updateAttributes()" << std::endl;
248253 #endif
249254
255+ if ( tabCats->count () == 0 ) return ;
256+
250257 Q3Table *tb = (Q3Table *) tabCats->currentPage ();
251258
252259 if ( tb->numRows () > 2 ) {
@@ -307,13 +314,16 @@ void QgsGrassAttributes::addCat ( )
307314 // Select new tab
308315 tabCats->setCurrentPage ( tabCats->count ()-1 );
309316
317+ resetButtons ();
310318}
311319
312320void QgsGrassAttributes::deleteCat ( )
313321{
314322 #ifdef QGISDEBUG
315323 std::cerr << " QgsGrassAttributes::deleteCat()" << std::endl;
316324 #endif
325+
326+ if ( tabCats->count () == 0 ) return ;
317327
318328 Q3Table *tb = (Q3Table *) tabCats->currentPage ();
319329
@@ -324,6 +334,7 @@ void QgsGrassAttributes::deleteCat ( )
324334
325335 tabCats->removePage ( tb );
326336 delete tb;
337+ resetButtons ();
327338}
328339
329340void QgsGrassAttributes::tabChanged ( QWidget *widget )
@@ -341,3 +352,17 @@ void QgsGrassAttributes::setLine ( int line )
341352{
342353 mLine = line;
343354}
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