Skip to content

Commit

Permalink
more fixes for ticket #1133
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@10790 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed May 14, 2009
1 parent abbf263 commit d796bbc
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 21 deletions.
60 changes: 46 additions & 14 deletions src/plugins/grass/qgsgrassmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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." );

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

setText( mTitle );
setToolTip ( mToolTip );
}

QStringList QgsGrassModuleFlag::options()
Expand All @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 );
}
}
43 changes: 36 additions & 7 deletions src/plugins/grass/qgsgrassmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
Expand All @@ -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

Expand All @@ -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 **********************/
Expand Down Expand Up @@ -818,4 +846,5 @@ class QgsGrassModuleFile: public QgsGrassModuleGroupBoxItem
QStringList mFilters;
};


#endif // QGSGRASSMODULE_H

0 comments on commit d796bbc

Please sign in to comment.