Skip to content

Commit 5854768

Browse files
author
rblazek
committed
enable/disable buttons according to number of tabs
git-svn-id: http://svn.osgeo.org/qgis/trunk@5094 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e1ee8d4 commit 5854768

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/plugins/grass/qgsgrassattributes.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -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

229234
void 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

312320
void 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

329340
void 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

Comments
 (0)