Skip to content

Commit

Permalink
enable/disable buttons according to number of tabs
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5094 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Mar 24, 2006
1 parent 5ca2143 commit 525ca15
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/plugins/grass/qgsgrassattributes.cpp
Expand Up @@ -105,6 +105,7 @@ QgsGrassAttributes::QgsGrassAttributes ( QgsGrassEdit *edit, QgsGrassProvider *p
// TODO: does not work:
connect( tabCats, SIGNAL(void currentChanged(QWidget *)), this, SLOT(tabChanged(QWidget *)));

resetButtons();
restorePosition();
}

Expand Down Expand Up @@ -173,6 +174,8 @@ int QgsGrassAttributes::addTab ( const QString & label )
QgsGrassAttributesKeyPress *ef = new QgsGrassAttributesKeyPress ( tb );
tb->installEventFilter( ef );

resetButtons();

return ( tabCats->count() - 1 );
}

Expand Down Expand Up @@ -224,6 +227,8 @@ void QgsGrassAttributes::addAttribute ( int tab, const QString &name, const QStr
// because QgsGrassProvider::attributes is using mEncoding->toUnicode()
tb->setText ( row, 1, QString::fromLocal8Bit(value) );
tb->setText ( row, 2, type );

resetButtons();
}

void QgsGrassAttributes::addTextRow ( int tab, const QString &text )
Expand All @@ -247,6 +252,8 @@ void QgsGrassAttributes::updateAttributes ( )
std::cerr << "QgsGrassAttributes::updateAttributes()" << std::endl;
#endif

if ( tabCats->count() == 0 ) return;

Q3Table *tb = (Q3Table *) tabCats->currentPage();

if ( tb->numRows() > 2 ) {
Expand Down Expand Up @@ -307,13 +314,16 @@ void QgsGrassAttributes::addCat ( )
// Select new tab
tabCats->setCurrentPage( tabCats->count()-1 );

resetButtons();
}

void QgsGrassAttributes::deleteCat ( )
{
#ifdef QGISDEBUG
std::cerr << "QgsGrassAttributes::deleteCat()" << std::endl;
#endif

if ( tabCats->count() == 0 ) return;

Q3Table *tb = (Q3Table *) tabCats->currentPage();

Expand All @@ -324,6 +334,7 @@ void QgsGrassAttributes::deleteCat ( )

tabCats->removePage( tb );
delete tb;
resetButtons();
}

void QgsGrassAttributes::tabChanged ( QWidget *widget )
Expand All @@ -341,3 +352,17 @@ void QgsGrassAttributes::setLine ( int line )
{
mLine = line;
}

void QgsGrassAttributes::resetButtons ( )
{
if ( tabCats->count() == 0 )
{
deleteButton->setEnabled(false);
updateButton->setEnabled(false);
}
else
{
deleteButton->setEnabled(true);
updateButton->setEnabled(true);
}
}

0 comments on commit 525ca15

Please sign in to comment.