/* Remove a character set from the list. */ void QIMPenSettingsWidget::removeCharSet( int pos ) { if ( pos >= 0 && pos < (int)charSets.count() ) { charSets.removeAt( pos ); currCharSet = 0; if ( charSets.count() ) { emit changeCharSet( currCharSet ); emit changeCharSet( charSets.at(currCharSet)->cs ); } totalStretch = 0; CharSetEntryIterator it = charSets.begin(); for ( ; it != charSets.end(); ++it ) totalStretch += (*it)->stretch; update(); } }
/*! Remove a character set from the list. */ void QIMPenWidget::removeCharSet( int pos ) { if ( pos >= 0 && pos < (int)charSets.count() ) { charSets.remove( pos ); currCharSet = 0; if ( charSets.count() ) { emit changeCharSet( currCharSet ); emit changeCharSet( charSets.at(currCharSet)->cs ); } totalStretch = 0; CharSetEntryIterator it( charSets ); for ( ; it.current(); ++it ) totalStretch += it.current()->stretch; update(); } }
/* Insert a character set into the list. */ void QIMPenSettingsWidget::insertCharSet( QIMPenCharSet *cs, int stretch, int pos ) { CharSetEntry *e = new CharSetEntry; e->cs = cs; e->stretch = stretch; if ( pos < 0 ) pos = charSets.count(); charSets.insert( pos, e ); currCharSet = 0; emit changeCharSet( currCharSet ); emit changeCharSet( charSets.at(currCharSet)->cs ); totalStretch = 0; CharSetEntryIterator it = charSets.begin(); for ( ; it != charSets.end(); ++it ) totalStretch += (*it)->stretch; update(); }
/*! If the point \a p is over one of the character set titles, switch to the set and return true. */ bool QIMPenSettingsWidget::selectSet( QPoint p ) { if ( charSets.count() ) { CharSetEntryIterator it = charSets.begin(); int spos = 0; int idx = 0; for ( ; it != charSets.end(); ++it, idx++ ) { int setWidth = width() * (*it)->stretch / totalStretch; spos += setWidth; if ( p.x() < spos ) { if ( idx != currCharSet ) { currCharSet = idx; update( 0, 0, width(), 12 ); emit changeCharSet( currCharSet ); emit changeCharSet( charSets.at(currCharSet)->cs ); } break; } } } return false; }
void QIMPenSettingsWidget::changeCharSet( QIMPenCharSet *cs, int pos ) { if ( pos >= 0 && pos < (int)charSets.count() ) { CharSetEntry *e = new CharSetEntry; e->cs = cs; e->stretch = charSets.at(pos)->stretch; delete charSets.takeAt( pos ); charSets.insert( pos, e ); if ( pos == currCharSet ) { emit changeCharSet( charSets.at(currCharSet)->cs ); } update(); } }