Skip to content
Permalink
Browse files

enable/disable buttons according to number of tabs

git-svn-id: http://svn.osgeo.org/qgis/trunk@5094 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Mar 24, 2006
1 parent e1ee8d4 commit 5854768e674d41a1fb79f01e81e2603754197b3e
Showing with 25 additions and 0 deletions.
  1. +25 −0 src/plugins/grass/qgsgrassattributes.cpp
@@ -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();
}

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

resetButtons();

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

@@ -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 )
@@ -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 ) {
@@ -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();

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

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

void QgsGrassAttributes::tabChanged ( QWidget *widget )
@@ -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 5854768

Please sign in to comment.
You can’t perform that action at this time.