author | brad <brad> | 2004-04-05 13:42:55 (UTC) |
---|---|---|
committer | brad <brad> | 2004-04-05 13:42:55 (UTC) |
commit | 997a521a3ee84f614e2781a663911096ffb4a91a (patch) (side-by-side diff) | |
tree | b54102f944af07bb0a8f3930ef856cbeff5f4899 /inputmethods | |
parent | f31cf618522b8b8855c5905c20754f7d5a762be3 (diff) | |
download | opie-997a521a3ee84f614e2781a663911096ffb4a91a.zip opie-997a521a3ee84f614e2781a663911096ffb4a91a.tar.gz opie-997a521a3ee84f614e2781a663911096ffb4a91a.tar.bz2 |
Missed qWarning and deps
-rw-r--r-- | inputmethods/handwriting/config.in | 2 | ||||
-rw-r--r-- | inputmethods/handwriting/handwriting.pro | 2 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpenchar.cpp | 4 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpensetup.cpp | 3 |
4 files changed, 6 insertions, 5 deletions
diff --git a/inputmethods/handwriting/config.in b/inputmethods/handwriting/config.in index 3a5fddb..b4acc9a 100644 --- a/inputmethods/handwriting/config.in +++ b/inputmethods/handwriting/config.in @@ -1,8 +1,8 @@ config HANDWRITING boolean "opie-handwriting (Handwriting recognition)" default "y" - depends ( LIBQPE || LIBQPE-X11 ) + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE comment "opie-handwriting-classicset automatically selected" depends HANDWRITING comment "opie-handwriting-graffitiset automatically selected" depends HANDWRITING diff --git a/inputmethods/handwriting/handwriting.pro b/inputmethods/handwriting/handwriting.pro index 3800381..e6f3b3f 100644 --- a/inputmethods/handwriting/handwriting.pro +++ b/inputmethods/handwriting/handwriting.pro @@ -1,34 +1,34 @@ TEMPLATE = lib CONFIG += qt plugin warn_on release HEADERS = qimpenchar.h \ qimpenprofile.h \ qimpencombining.h \ qimpenhelp.h \ qimpeninput.h \ qimpenmatch.h \ qimpensetup.h \ qimpenstroke.h \ qimpenwidget.h \ qimpenwordpick.h \ handwritingimpl.h SOURCES = qimpenchar.cpp \ qimpenprofile.cpp \ qimpencombining.cpp \ qimpenhelp.cpp \ qimpeninput.cpp \ qimpenmatch.cpp \ qimpensetup.cpp \ qimpenstroke.cpp \ qimpenwidget.cpp \ qimpenwordpick.cpp \ handwritingimpl.cpp INTERFACES = qimpenprefbase.ui TARGET = qhandwriting DESTDIR = ../../plugins/inputmethods INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += ../$(OPIEDIR)/include ../../launcher -LIBS += -lqpe +LIBS += -lqpe -lopiecore2 VERSION = 1.0.0 include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/inputmethods diff --git a/inputmethods/handwriting/qimpenchar.cpp b/inputmethods/handwriting/qimpenchar.cpp index db5d135..b83b2a4 100644 --- a/inputmethods/handwriting/qimpenchar.cpp +++ b/inputmethods/handwriting/qimpenchar.cpp @@ -11,502 +11,502 @@ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qfile.h> #include <qtl.h> #include <math.h> #include <limits.h> #include <errno.h> #include <qdatastream.h> #include "qimpencombining.h" #include "qimpenchar.h" #include "opie2/odebug.h" #define QIMPEN_MATCH_THRESHOLD 200000 const QIMPenSpecialKeys qimpen_specialKeys[] = { { Qt::Key_Escape, "[Esc]" }, { Qt::Key_Tab, "[Tab]" }, { Qt::Key_Backspace, "[BackSpace]" }, { Qt::Key_Return, "[Return]" }, { QIMPenChar::Caps, "[Uppercase]" }, { QIMPenChar::CapsLock, "[Caps Lock]" }, { QIMPenChar::Shortcut, "[Shortcut]" }, { QIMPenChar::Punctuation, "[Punctuation]" }, { QIMPenChar::Symbol, "[Symbol]" }, { QIMPenChar::Extended, "[Extended]" }, { Qt::Key_unknown, 0 } }; /*! \class QIMPenChar qimpenchar.h Handles a single character. Can calculate closeness of match to another character. */ QIMPenChar::QIMPenChar() { flags = 0; strokes.setAutoDelete( TRUE ); } QIMPenChar::QIMPenChar( const QIMPenChar &chr ) { strokes.setAutoDelete( TRUE ); ch = chr.ch; flags = chr.flags; d = chr.d; QIMPenStrokeIterator it( chr.strokes ); while ( it.current() ) { strokes.append( new QIMPenStroke( *it.current() ) ); ++it; } } QIMPenChar &QIMPenChar::operator=( const QIMPenChar &chr ) { strokes.clear(); ch = chr.ch; flags = chr.flags; d = chr.d; QIMPenStrokeIterator it( chr.strokes ); while ( it.current() ) { strokes.append( new QIMPenStroke( *it.current() ) ); ++it; } return *this; } QString QIMPenChar::name() const { QString n; if ( (ch & 0x0000FFFF) == 0 ) { int code = ch >> 16; for ( int i = 0; qimpen_specialKeys[i].code != Qt::Key_unknown; i++ ) { if ( qimpen_specialKeys[i].code == code ) { n = qimpen_specialKeys[i].name; break; } } } else { n = QChar( ch & 0x0000FFFF ); } return n; } void QIMPenChar::clear() { ch = 0; flags = 0; d = QString::null; strokes.clear(); } unsigned int QIMPenChar::strokeLength( int s ) const { QIMPenStrokeIterator it( strokes ); while ( it.current() && s ) { ++it; --s; } if ( it.current() ) return it.current()->length(); return 0; } /*! Add a stroke to the character */ void QIMPenChar::addStroke( QIMPenStroke *st ) { QIMPenStroke *stroke = new QIMPenStroke( *st ); strokes.append( stroke ); } /*! Return an indicator of the closeness of this character to \a pen. Lower value is better. */ int QIMPenChar::match( QIMPenChar *pen ) { /* if ( strokes.count() > pen->strokes.count() ) return INT_MAX; */ int err = 0; int maxErr = 0; int diff = 0; QIMPenStrokeIterator it1( strokes ); QIMPenStrokeIterator it2( pen->strokes ); err = it1.current()->match( it2.current() ); if ( err > maxErr ) maxErr = err; ++it1; ++it2; while ( err < 400000 && it1.current() && it2.current() ) { QPoint p1 = it1.current()->boundingRect().center() - strokes.getFirst()->boundingRect().center(); QPoint p2 = it2.current()->boundingRect().center() - pen->strokes.getFirst()->boundingRect().center(); int xdiff = QABS( p1.x() - p2.x() ) - 6; int ydiff = QABS( p1.y() - p2.y() ) - 5; if ( xdiff < 0 ) xdiff = 0; if ( ydiff < 0 ) ydiff = 0; if ( xdiff > 10 || ydiff > 10 ) { // not a chance #ifdef DEBUG_QIMPEN odebug << "char " << pen->ch <<", stroke starting pt diff excessive" << oendl; #endif return INT_MAX; } diff += xdiff*xdiff + ydiff*ydiff; err = it1.current()->match( it2.current() ); if ( err > maxErr ) maxErr = err; ++it1; ++it2; } maxErr += diff * diff * 6; // magic weighting :) #ifdef DEBUG_QIMPEN odebug << "char: " << pen->ch << ", maxErr " << maxErr << ", diff " << diff << ", " << strokes.count() << oendl; #endif return maxErr; } /*! Return the bounding rect of this character. It may have sides with negative coords since its origin is where the user started drawing the character. */ QRect QIMPenChar::boundingRect() { QRect br; QIMPenStroke *st = strokes.first(); while ( st ) { br |= st->boundingRect(); st = strokes.next(); } return br; } /*! Write the character's data to the stream. */ QDataStream &operator<< (QDataStream &s, const QIMPenChar &ws) { s << ws.ch; s << ws.flags; if ( ws.flags & QIMPenChar::Data ) s << ws.d; s << ws.strokes.count(); QIMPenStrokeIterator it( ws.strokes ); while ( it.current() ) { s << *it.current(); ++it; } return s; } /*! Read the character's data from the stream. */ QDataStream &operator>> (QDataStream &s, QIMPenChar &ws) { s >> ws.ch; s >> ws.flags; if ( ws.flags & QIMPenChar::Data ) s >> ws.d; unsigned size; s >> size; for ( unsigned i = 0; i < size; i++ ) { QIMPenStroke *st = new QIMPenStroke(); s >> *st; ws.strokes.append( st ); } return s; } //=========================================================================== bool QIMPenCharMatch::operator>( const QIMPenCharMatch &m ) { return error > m.error; } bool QIMPenCharMatch::operator<( const QIMPenCharMatch &m ) { return error < m.error; } bool QIMPenCharMatch::operator<=( const QIMPenCharMatch &m ) { return error <= m.error; } //=========================================================================== /*! \class QIMPenCharSet qimpenchar.h Maintains a set of related characters. */ QIMPenCharSet::QIMPenCharSet() { chars.setAutoDelete( TRUE ); desc = "Unnamed"; csTitle = "abc"; csType = Unknown; maxStrokes = 0; } /*! Construct and load a characters set from file \a fn. */ QIMPenCharSet::QIMPenCharSet( const QString &fn ) { chars.setAutoDelete( TRUE ); desc = "Unnamed"; csTitle = "abc"; csType = Unknown; maxStrokes = 0; load( fn, System ); } const QString &QIMPenCharSet::filename( Domain d ) const { if ( d == System ) return sysFilename; else return userFilename; } void QIMPenCharSet::setFilename( const QString &fn, Domain d ) { if ( d == System ) sysFilename = fn; else if ( d == User ) userFilename = fn; } /*! Load a character set from file \a fn. */ bool QIMPenCharSet::load( const QString &fn, Domain d ) { setFilename( fn, d ); bool ok = FALSE; QFile file( fn ); if ( file.open( IO_ReadOnly ) ) { QDataStream ds( &file ); QString version; ds >> version; ds >> csTitle; ds >> desc; int major = version.mid( 4, 1 ).toInt(); int minor = version.mid( 6 ).toInt(); if ( major >= 1 && minor > 0 ) { ds >> (Q_INT8 &)csType; } else { if ( csTitle == "abc" ) csType = Lower; else if ( csTitle == "ABC" ) csType = Upper; else if ( csTitle == "123" ) csType = Numeric; else if ( fn == "Combining" ) csType = Combining; } while ( !ds.atEnd() ) { QIMPenChar *pc = new QIMPenChar; ds >> *pc; if ( d == User ) markDeleted( pc->character() ); // override system addChar( pc ); } if ( file.status() == IO_Ok ) ok = TRUE; } setHidden ( false ); return ok; } /*! Save this character set. */ bool QIMPenCharSet::save( Domain d ) { if ( filename( d ).isEmpty() ) return FALSE; if ( hidden() ) return TRUE; bool ok = FALSE; QString fn = filename( d ); QString tmpFn = fn + ".new"; QFile file( tmpFn ); if ( file.open( IO_WriteOnly|IO_Raw ) ) { QByteArray buf; QDataStream ds( buf, IO_WriteOnly ); ds << QString( "QPT 1.1" ); ds << csTitle; ds << desc; ds << (Q_INT8)csType; QIMPenCharIterator ci( chars ); for ( ; ci.current(); ++ci ) { QIMPenChar *pc = ci.current(); if ( ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) || ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) && ( !pc->testFlag (QIMPenChar::Combined ) ) ) { ds << *pc; } } file.writeBlock( buf ); file.close(); if ( file.status() == IO_Ok ) ok = TRUE; } if ( ok ) { if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) { - qWarning( "problem renaming file %s to %s, errno: %d", - tmpFn.latin1(), fn.latin1(), errno ); + owarn << "problem renaming file " <<tmpFn.latin1() << " to "<< fn.latin1() + << ", errno: " << errno << oendl; // remove the tmp file, otherwise, it will just lay around... QFile::remove( tmpFn.latin1() ); ok = FALSE; } } return ok; } QIMPenChar *QIMPenCharSet::at( int i ) { return chars.at(i); } void QIMPenCharSet::markDeleted( uint ch ) { QIMPenCharIterator ci( chars ); for ( ; ci.current(); ++ci ) { QIMPenChar *pc = ci.current(); if ( pc->character() == ch && pc->testFlag( QIMPenChar::System ) ) pc->setFlag( QIMPenChar::Deleted ); } } /*! Find the best matches for \a ch in this character set. */ QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch ) { QIMPenCharMatchList matches; QIMPenCharIterator ci( chars ); for ( ; ci.current(); ++ci ) { QIMPenChar *tmplChar = ci.current(); if ( tmplChar->testFlag( QIMPenChar::Deleted ) ) { continue; } int err; if ( ch->penStrokes().count() <= tmplChar->penStrokes().count() ) { err = ch->match( tmplChar ); if ( err <= QIMPEN_MATCH_THRESHOLD ) { if (tmplChar->penStrokes().count() != ch->penStrokes().count()) err = QMIN(err*3, QIMPEN_MATCH_THRESHOLD); QIMPenCharMatchList::Iterator it; for ( it = matches.begin(); it != matches.end(); ++it ) { if ( (*it).penChar->character() == tmplChar->character() && (*it).penChar->penStrokes().count() == tmplChar->penStrokes().count() ) { if ( (*it).error > err ) (*it).error = err; break; } } if ( it == matches.end() ) { QIMPenCharMatch m; m.error = err; m.penChar = tmplChar; matches.append( m ); } } } } qHeapSort( matches ); /* QIMPenCharMatchList::Iterator it; for ( it = matches.begin(); it != matches.end(); ++it ) { odebug << "Match: \'" << (*it).penChar->character() "\', error " << (*it).error ", strokes " <<(*it).penChar->penStrokes().count() << oendl; } */ return matches; } /*! Add a character \a ch to this set. QIMPenCharSet will delete this character when it is no longer needed. */ void QIMPenCharSet::addChar( QIMPenChar *ch ) { if ( ch->penStrokes().count() > maxStrokes ) maxStrokes = ch->penStrokes().count(); chars.append( ch ); } /*! Remove a character by reference \a ch from this set. QIMPenCharSet will delete this character. */ void QIMPenCharSet::removeChar( QIMPenChar *ch ) { chars.remove( ch ); } /*! Move the character up the list of characters. */ void QIMPenCharSet::up( QIMPenChar *ch ) { int idx = chars.findRef( ch ); if ( idx > 0 ) { chars.take(); chars.insert( idx - 1, ch ); } } /*! Move the character down the list of characters. */ void QIMPenCharSet::down( QIMPenChar *ch ) { int idx = chars.findRef( ch ); if ( idx >= 0 && idx < (int)chars.count() - 1 ) { chars.take(); chars.insert( idx + 1, ch ); } } diff --git a/inputmethods/handwriting/qimpensetup.cpp b/inputmethods/handwriting/qimpensetup.cpp index 3f4841d..564b6ba 100644 --- a/inputmethods/handwriting/qimpensetup.cpp +++ b/inputmethods/handwriting/qimpensetup.cpp @@ -1,495 +1,496 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "qimpenwidget.h" #include "qimpenprefbase.h" #include "qimpensetup.h" #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qcombobox.h> #include <qlistbox.h> #include <qlabel.h> #include <qpushbutton.h> #include <qlayout.h> #include <qpixmap.h> #include <qbuttongroup.h> #include <qslider.h> #include <qtabwidget.h> #include <qdir.h> #include <qmessagebox.h> +#include <opie2/odebug.h> /* XPM */ static const char * const left_xpm[] = { "16 16 2 1", " c None", ". c #000000", " ", " ", " ", " . ", " .. ", " ... ", " .... ", " ..... ", " ...... ", " ..... ", " .... ", " ... ", " .. ", " . ", " ", " "}; /* XPM */ static const char * const right_xpm[] = { "16 16 2 1", " c None", ". c #000000", " ", " ", " ", " . ", " .. ", " ... ", " .... ", " ..... ", " ...... ", " ..... ", " .... ", " ... ", " .. ", " . ", " ", " "}; QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent, const char *name, bool modal, int WFlags ) : QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p) { setCaption( tr("Setup Handwriting Input") ); QVBoxLayout *vb = new QVBoxLayout( this ); #define MULTIPROFILE #ifdef MULTIPROFILE profileList.setAutoDelete( true ); QHBoxLayout *hb = new QHBoxLayout( vb ); hb->setMargin( 6 ); QLabel *l = new QLabel( tr("Character Profile:"), this ); hb->addWidget( l ); profileCombo = new QComboBox( this ); connect( profileCombo, SIGNAL(activated(const QString&)), this, SLOT(selectProfile(const QString&)) ); hb->addWidget( profileCombo ); #else profileList.append( profile ); #endif - qWarning("profiles: %d", profileList.count()); + owarn << "profiles: " << profileList.count() << oendl; QTabWidget *tw = new QTabWidget( this ); vb->addWidget( tw ); pref = new QIMPenPrefBase( this ); tw->addTab( pref, tr("Preferences") ); pref->inputStyle->setExclusive( TRUE ); style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; pref->inputStyle->setButton( style ); connect( pref->inputStyle, SIGNAL(clicked(int)), this, SLOT(styleClicked(int)) ); pref->inputStyle->setEnabled( profile->canSelectStyle() ); multiTimeout = profile->multiStrokeTimeout(); pref->multiStrokeSlider->setValue( multiTimeout ); multiTimeoutChanged( multiTimeout ); connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)), this, SLOT(multiTimeoutChanged(int)) ); edit = new QIMPenEdit( p, tw ); tw->addTab( edit, tr("Customize") ); #ifdef MULTIPROFILE loadProfiles(); #endif } void QIMPenSetup::loadProfiles() { QString path = QPEApplication::qpeDir() + "etc/qimpen"; QDir dir( path, "*.conf" ); QStringList list = dir.entryList(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); profileList.append( p ); profileCombo->insertItem( p->name() ); if ( p->name() == profile->name() ) { profileCombo->setCurrentItem( profileCombo->count()-1 ); profile = p; edit->setProfile( profile ); } } } void QIMPenSetup::styleClicked( int id ) { style = id; } void QIMPenSetup::multiTimeoutChanged( int v ) { multiTimeout = v; pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) ); } void QIMPenSetup::selectProfile( const QString &p ) { if ( p == profile->name() ) return; profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); profile->setMultiStrokeTimeout( multiTimeout ); for ( int i = 0; i < (int)profileList.count(); i++ ) { if ( profileList.at(i)->name() == p ) { profile = profileList.at(i); style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; pref->inputStyle->setButton( style ); pref->inputStyle->setEnabled( profile->canSelectStyle() ); multiTimeout = profile->multiStrokeTimeout(); pref->multiStrokeSlider->setValue( multiTimeout ); multiTimeoutChanged( multiTimeout ); edit->setProfile( profile ); break; } } } void QIMPenSetup::accept() { profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); profile->setMultiStrokeTimeout( multiTimeout ); // Save current profile if ( profileCombo ) { Config config( "handwriting" ); config.setGroup( "Settings" ); config.writeEntry( "Profile", profileCombo->currentText() ); } // Save charsets bool ok = TRUE; for ( int i = 0; i < (int)profileList.count(); i++ ) { QIMPenProfile *prof = profileList.at(i); QIMPenCharSetIterator it(prof->charSets()); for ( ; it.current(); ++it ) { if ( !(it.current()->save( QIMPenCharSet::User )) ) { ok = FALSE; break; } } } if ( !ok ) { if ( QMessageBox::critical( 0, tr( "Out of space" ), tr("Unable to save information.\n" "Free up some space\n" "and try again.\n" "\nQuit anyway?"), QMessageBox::Yes|QMessageBox::Escape, QMessageBox::No|QMessageBox::Default ) != QMessageBox::No ) { QDialog::accept(); } } else { QDialog::accept(); } } //--------------------------------------------------------------------------- QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name, bool modal, int WFlags) : QDialog( parent, name, modal, WFlags ) { setCaption( tr("Enter new character") ); uni = 0; QVBoxLayout *vb = new QVBoxLayout( this, 10 ); QHBoxLayout *hb = new QHBoxLayout(); vb->addLayout( hb ); QLabel *label = new QLabel( tr("Character:"), this ); hb->addWidget( label ); QComboBox *cb = new QComboBox( TRUE, this ); connect( cb, SIGNAL(activated(int)), SLOT(setSpecial(int)) ); connect( cb, SIGNAL(textChanged(const QString&)), SLOT(setCharacter(const QString&)) ); addSpecial( cb ); cb->setEditText( "" ); hb->addWidget( cb ); hb = new QHBoxLayout(); vb->addLayout( hb ); QPushButton *pb = new QPushButton( "OK", this ); connect( pb, SIGNAL(clicked()), SLOT(accept())); hb->addWidget( pb ); pb = new QPushButton( "Cancel", this ); connect( pb, SIGNAL(clicked()), SLOT(reject())); hb->addWidget( pb ); cb->setFocus(); } void QIMPenInputCharDlg::addSpecial( QComboBox *cb ) { int i = 0; while ( qimpen_specialKeys[i].code != Key_unknown ) { cb->insertItem( qimpen_specialKeys[i].name ); i++; } } void QIMPenInputCharDlg::setSpecial( int sp ) { uni = qimpen_specialKeys[sp].code << 16; } void QIMPenInputCharDlg::setCharacter( const QString &string ) { uni = string[0].unicode(); } //--------------------------------------------------------------------------- class CharListItem : public QListBoxText { public: CharListItem( const QString &text, uint c ) : QListBoxText( text ) { _code = c; } uint code() const { return _code; } protected: uint _code; }; /*! \class QIMPenEdit qimpensetup.h Class to allow users to input totally useless character definitions which could match any number of the default set. */ QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, const char *name ) : QWidget( parent, name ), profile(p) { currentChar = 0; currentCode = 0; inputChar = new QIMPenChar(); QVBoxLayout *tvb = new QVBoxLayout( this, 5 ); QGridLayout *gl = new QGridLayout( tvb, 4, 2 ); gl->setRowStretch( 1, 1 ); gl->addRowSpacing( 2, 35 ); gl->addRowSpacing( 3, 35 ); charSetCombo = new QComboBox( this ); gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSetVisible(int))); QIMPenCharSetIterator it( profile->charSets() ); for ( ; it.current(); ++it ) { charSetCombo->insertItem( it.current()->description() ); } charList = new QListBox( this ); charList->setMinimumHeight( charList->sizeHint().height() ); connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) ); gl->addWidget( charList, 1, 0 ); pw = new QIMPenWidget( this ); pw->setFixedHeight( 75 ); gl->addMultiCellWidget( pw, 2, 3, 0, 0 ); connect( pw, SIGNAL(stroke(QIMPenStroke*)), SLOT(newStroke(QIMPenStroke*)) ); QVBoxLayout *vb = new QVBoxLayout(); gl->addLayout( vb, 1, 1 ); newBtn = new QPushButton( tr("New..."), this ); connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) ); vb->addWidget( newBtn ); addBtn = new QPushButton( tr("Add"), this ); connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) ); vb->addWidget( addBtn ); removeBtn = new QPushButton( tr("Remove"), this ); connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) ); vb->addWidget( removeBtn ); QPushButton *pb = new QPushButton( tr("Default"), this ); connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) ); vb->addWidget( pb ); QHBoxLayout *hb = new QHBoxLayout(); gl->addLayout( hb, 2, 1 ); prevBtn = new QPushButton( this ); prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); hb->addWidget( prevBtn ); nextBtn = new QPushButton( this ); nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); hb->addWidget( nextBtn ); pb = new QPushButton( tr("Clear"), this ); connect( pb, SIGNAL(clicked()), SLOT(clearChar()) ); gl->addWidget( pb, 3, 1 ); //-- #if !defined(Q_WS_QWS) hb = new QHBoxLayout( tvb ); pb = new QPushButton( tr("OK"), this ); connect( pb, SIGNAL(clicked()), SLOT(accept()) ); hb->addWidget( pb ); pb = new QPushButton( tr("Cancel"), this ); connect( pb, SIGNAL(clicked()), SLOT(reject()) ); hb->addWidget( pb ); #endif selectCharSetVisible( 0 ); charList->setFocus(); resize( minimumSize() ); enableButtons(); } void QIMPenEdit::setProfile( QIMPenProfile *p ) { profile = p; charSetCombo->clear(); QIMPenCharSetIterator it( profile->charSets() ); for ( ; it.current(); ++it ) { if ( ! it.current()->hidden() ) charSetCombo->insertItem( it.current()->description() ); } selectCharSetVisible( 0 ); charList->setFocus(); enableButtons(); } void QIMPenEdit::selectCharSet( QIMPenCharSet *c ) { int i = 0; QIMPenCharSetIterator it( profile->charSets() ); for ( ; it.current(); ++it, i++ ) { if ( it.current() == c ) { charSetCombo->setCurrentItem( i ); selectCharSet( i ); } } } /*! Fill the character list box with the characters. Duplicates are not inserted. */ void QIMPenEdit::fillCharList() { charList->clear(); QIMPenCharIterator it( currentSet->characters() ); CharListItem *li = 0; for ( ; it.current(); ++it ) { uint ch = it.current()->character(); QString n = it.current()->name(); if ( !n.isEmpty() ) li = new CharListItem( n, ch ); if ( li ) { CharListItem *i = (CharListItem *)charList->findItem( li->text() ); if ( !i || i->code() != ch ) { charList->insertItem( li ); } else { delete li; li = 0; } } } currentChar = 0; } void QIMPenEdit::enableButtons() { bool add = !inputChar->isEmpty(); newBtn->setEnabled( add ); addBtn->setEnabled( add ); removeBtn->setEnabled( currentChar ); } /*! Find the previous character with the same code as the current one. returns 0 if there is no previous character. */ QIMPenChar *QIMPenEdit::findPrev() { if ( !currentChar ) return 0; QIMPenCharIterator it( currentSet->characters() ); bool found = FALSE; for ( it.toLast(); it.current(); --it ) { if ( !found && it.current() == currentChar ) found = TRUE; else if ( found && it.current()->character() == currentCode && !it.current()->testFlag( QIMPenChar::Deleted ) ) { return it.current(); } } return 0; } /*! Find the next character with the same code as the current one. returns 0 if there is no next character. */ QIMPenChar *QIMPenEdit::findNext() { if ( !currentChar ) return 0; QIMPenCharIterator it( currentSet->characters() ); bool found = FALSE; for ( ; it.current(); ++it ) { if ( !found && it.current() == currentChar ) found = TRUE; else if ( found && it.current()->character() == currentCode && |