Skip to content
Permalink
Browse files

more fixes for ticket #1133

git-svn-id: http://svn.osgeo.org/qgis/trunk@10790 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed May 14, 2009
1 parent abbf263 commit d796bbc5bd1a6da0a89f6f73ba644f02aedeed07
Showing with 82 additions and 21 deletions.
  1. +46 −14 src/plugins/grass/qgsgrassmodule.cpp
  2. +36 −7 src/plugins/grass/qgsgrassmodule.h
@@ -1660,7 +1660,7 @@ QgsGrassModuleOption::QgsGrassModuleOption( QgsGrassModule *module, QString key,
}
else
{
QCheckBox *cb = new QCheckBox( desc, this );
QgsGrassModuleCheckBox *cb = new QgsGrassModuleCheckBox( desc, this );
mCheckBoxes.push_back( cb );
mLayout->addWidget( cb );
}
@@ -1944,7 +1944,7 @@ QgsGrassModuleOption::~QgsGrassModuleOption()
QgsGrassModuleFlag::QgsGrassModuleFlag( QgsGrassModule *module, QString key,
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
QWidget * parent )
: QCheckBox( parent ), QgsGrassModuleItem( module, key, qdesc, gdesc, gnode )
: QgsGrassModuleCheckBox( "", parent ), QgsGrassModuleItem( module, key, qdesc, gdesc, gnode )
{
QgsDebugMsg( "called." );

@@ -1956,6 +1956,7 @@ QgsGrassModuleFlag::QgsGrassModuleFlag( QgsGrassModule *module, QString key,
setChecked( false );

setText( mTitle );
setToolTip ( mToolTip );
}

QStringList QgsGrassModuleFlag::options()
@@ -1972,18 +1973,6 @@ QgsGrassModuleFlag::~QgsGrassModuleFlag()
{
}

void QgsGrassModuleFlag::resizeEvent ( QResizeEvent * event )
{
adjustText();
}

void QgsGrassModuleFlag::adjustText()
{
QString t = fontMetrics().elidedText ( mTitle , Qt::ElideRight, width() - iconSize().width() - 20 );

setText( t );
}

/************************** QgsGrassModuleInput ***************************/

QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,
@@ -2925,7 +2914,9 @@ QgsGrassModuleSelection::QgsGrassModuleSelection(
connect( mLayerInput, SIGNAL( valueChanged() ), this, SLOT( updateSelection() ) );
}

QHBoxLayout *l = new QHBoxLayout( this );
mLineEdit = new QLineEdit( this );
l->addWidget( mLineEdit );

// Fill in layer current fields
updateSelection();
@@ -3127,3 +3118,44 @@ QString QgsGrassModuleFile::ready()
QgsGrassModuleFile::~QgsGrassModuleFile()
{
}

/***************************** QgsGrassModuleCheckBox *********************************/

QgsGrassModuleCheckBox::QgsGrassModuleCheckBox( const QString & text, QWidget * parent )
: QCheckBox( text, parent ), mText(text)
{
QgsDebugMsg( "called." );
adjustText();
}

QgsGrassModuleCheckBox::~QgsGrassModuleCheckBox()
{
}

void QgsGrassModuleCheckBox::resizeEvent ( QResizeEvent * event )
{
adjustText();
}
void QgsGrassModuleCheckBox::setText ( const QString & text )
{
mText = text;
adjustText();
}
void QgsGrassModuleCheckBox::setToolTip ( const QString & text )
{
mTip = text;
QWidget::setToolTip ( text );
}
void QgsGrassModuleCheckBox::adjustText()
{
QString t = fontMetrics().elidedText ( mText , Qt::ElideRight, width() - iconSize().width() - 20 );
QCheckBox::setText( t );

if ( mTip.isEmpty() ) {
QString tt;
if ( t != mText ) {
tt = mText;
}
QWidget::setToolTip ( tt );
}
}
@@ -281,6 +281,39 @@ class QgsGrassModuleStandardOptions: public QgsGrassModuleOptions, QWidget
bool mUsesRegion;
};

/****************** QgsGrassModuleGroupBoxItem ************************/

/*! \class QgsGrassModuleCheckBox
* \brief Checkbox with elided text
*/
class QgsGrassModuleCheckBox: public QCheckBox
{
Q_OBJECT

public:
/*! \brief Constructor
*/
QgsGrassModuleCheckBox( const QString & text, QWidget * parent = 0 );

//! Destructor
virtual ~QgsGrassModuleCheckBox ();

void resizeEvent ( QResizeEvent * event );

public slots:
void setText ( const QString & text );

void setToolTip ( const QString & text );

//! Adjust title size, called on resize
void adjustText();

private:
QString mText;

QString mTip;
};

/*! \class QgsGrassModuleItem
* \brief GRASS module option
*/
@@ -455,7 +488,7 @@ class QgsGrassModuleOption: public QgsGrassModuleGroupBoxItem
std::vector<QString> mValues;

//! Check boxes
std::vector<QCheckBox*> mCheckBoxes;
std::vector<QgsGrassModuleCheckBox*> mCheckBoxes;

//! Line
std::vector<QLineEdit*> mLineEdits;
@@ -479,7 +512,7 @@ class QgsGrassModuleOption: public QgsGrassModuleGroupBoxItem
/*! \class QgsGrassModuleFlag
* \brief GRASS flag
*/
class QgsGrassModuleFlag: public QCheckBox, public QgsGrassModuleItem
class QgsGrassModuleFlag: public QgsGrassModuleCheckBox, public QgsGrassModuleItem
{
Q_OBJECT

@@ -498,11 +531,6 @@ class QgsGrassModuleFlag: public QCheckBox, public QgsGrassModuleItem
//! Retruns list of options which will be passed to module
virtual QStringList options();

void resizeEvent ( QResizeEvent * event );

public slots:
//! Adjust title size, called on resize
void adjustText();
};

/************************ QgsGrassModuleInput **********************/
@@ -818,4 +846,5 @@ class QgsGrassModuleFile: public QgsGrassModuleGroupBoxItem
QStringList mFilters;
};


#endif // QGSGRASSMODULE_H

0 comments on commit d796bbc

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