summaryrefslogtreecommitdiff
path: root/inputmethods/pickboard
Side-by-side diff
Diffstat (limited to 'inputmethods/pickboard') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/pickboard/pickboardcfg.cpp10
-rw-r--r--inputmethods/pickboard/pickboardcfg.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/inputmethods/pickboard/pickboardcfg.cpp b/inputmethods/pickboard/pickboardcfg.cpp
index e8b47cb..d500266 100644
--- a/inputmethods/pickboard/pickboardcfg.cpp
+++ b/inputmethods/pickboard/pickboardcfg.cpp
@@ -65,196 +65,196 @@ void PickboardConfig::updateRows(int from, int to)
void PickboardConfig::updateItem(int r, int)
{
updateRows(r,r);
}
void PickboardConfig::changeMode(int m)
{
parent->setMode(m);
}
void PickboardConfig::generateText(const QString& s)
{
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
for (int i=0; i<(int)s.length(); i++) {
parent->emitKey(s[i].unicode(), 0, 0, true, false);
parent->emitKey(s[i].unicode(), 0, 0, false, false);
}
#endif
}
void PickboardConfig::generateKey( int k )
{
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
parent->emitKey(0, k, 0, true, false);
parent->emitKey(0, k, 0, false, false);
#endif
}
void PickboardConfig::pickPoint(const QPoint& p, bool press)
{
if ( press ) {
int ls=parent->height()/nrows;
int y=0;
pressx = -1;
for (int r=0; r<nrows; r++) {
if ( p.y() >= y && p.y() < y+ls ) {
pressrow = r;
pressx = p.x();
pickInRow( pressrow, pressx, TRUE );
return;
}
y += ls;
}
} else if ( pressx >= 0 ) {
pickInRow( pressrow, pressx, FALSE );
pressx = -1;
}
}
void PickboardConfig::fillMenu(QPopupMenu& menu)
{
menu.insertItem("Reset",100);
menu.insertSeparator();
menu.insertItem("Help",1);
}
void PickboardConfig::doMenu(int i)
{
switch (i) {
case 100:
if ( parent->currentMode() ) {
changeMode(0);
updateRows(0,1);
}
break;
case 1: {
QMessageBox help("Pickboard Help", pickboard_help,
QMessageBox::NoIcon, 1, 0, 0);
help.showMaximized();
help.exec();
}
}
}
void StringConfig::draw(QPainter* p)
{
QFontMetrics fm = p->fontMetrics();
for (int r=0; r<nrows; r++) {
p->translate(0,fm.lineSpacing());
p->setPen(rowColor(r));
int tw=0;
QString s;
int i=0;
for (; !(s=text(r,i)).isNull(); ++i) {
int w = fm.width(s);
tw += w;
}
bool spread = spreadRow(r);// && parent->width() > tw;
int xw = spread ? (parent->width()-tw)/(i-1) : 3;
int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2;
i=0;
for (; !(s=text(r,i)).isNull(); ++i) {
int w = fm.width(s)+xw;
if ( highlight(r,i) ) {
- p->fillRect(x-xw/2,1+fm.descent()-fm.lineSpacing(),w,fm.lineSpacing(),Qt::black);
- p->setPen(Qt::white);
+ p->fillRect(x-xw/2,1+fm.descent()-fm.lineSpacing(),w,fm.lineSpacing(),::Qt::black);
+ p->setPen(::Qt::white);
}else{
- p->setPen(Qt::black);
+ p->setPen(::Qt::black);
}
p->drawText(x,-fm.descent()-1,s);
x += w;
}
}
}
void StringConfig::pickInRow(int r, int xpos, bool press)
{
QFontMetrics fm = parent->fontMetrics();
int tw=0;
QString s;
int i=0;
for (; !(s=text(r,i)).isNull(); ++i) {
int w = fm.width(s);
tw += w;
}
bool spread = spreadRow(r) && parent->width() > tw;
int xw = spread ? (parent->width()-tw)/(i-1) : 3;
int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2;
i=0;
for (; !(s=text(r,i)).isNull(); ++i) {
int x2 = x + fm.width(s)+xw;
if ( xpos >= x && xpos < x2 ) {
pick(press, r, i);
return;
}
x = x2;
}
}
void StringConfig::updateItem(int r, int item)
{
QFontMetrics fm = parent->fontMetrics();
int y = r * fm.lineSpacing();
int tw=0;
QString s;
int i=0;
for (; !(s=text(r,i)).isNull(); ++i) {
int w = fm.width(s);
tw += w;
}
bool spread = spreadRow(r) && parent->width() > tw;
int xw = spread ? (parent->width()-tw)/(i-1) : 3;
int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2;
i=0;
for (; !(s=text(r,i)).isNull(); ++i) {
int w = fm.width(s)+xw;
if ( i == item ) {
parent->update(QRect(x-xw/2,y+1+fm.descent(),w,fm.lineSpacing()));
return;
}
x += w;
}
}
bool StringConfig::highlight(int,int) const
{
return FALSE;
}
LetterButton::LetterButton(const QChar& letter, QWidget* parent) :
QPushButton(letter,parent)
{
setToggleButton(TRUE);
setAutoDefault(FALSE);
connect(this,SIGNAL(clicked()),this,SLOT(toggleCase()));
skip=TRUE;
}
void LetterButton::toggleCase()
{
if ( skip ) {
// Don't toggle case the first time
skip=FALSE;
return;
}
QChar ch = text()[0];
QChar nch = ch.lower();
if ( ch == nch )
nch = ch.upper();
setText(nch);
}
LetterChoice::LetterChoice(QWidget* parent, const QString& set) :
QButtonGroup(parent)
{
QHBoxLayout *l = new QHBoxLayout(this);
setFrameStyle(0);
setExclusive(TRUE);
@@ -338,196 +338,196 @@ void PickboardAdd::checkAllDone()
}
void DictFilterConfig::doMenu(int i)
{
switch (i) {
case 300:
if ( input.count() == 0 ) {
QMessageBox::information(0, "Adding Words",
"To add words, pick the letters,\nthen "
"open the Add dialog. In that\ndialog, tap "
"the correct letters\nfrom the list "
"(tap twice for\ncapitals).");
} else {
PickboardAdd add(parent,capitalize(input));
if ( add.exec() )
generateText(add.word());
input.clear();
matches.clear();
updateRows(0,0);
}
break;
case 100:
if ( !input.isEmpty() ) {
input.clear();
matches.clear();
StringConfig::doMenu(i);
updateRows(0,1);
break;
} // else fall through
default:
StringConfig::doMenu(i);
}
shift = 0;
lit0 = -1;
}
QString DictFilterConfig::text(int r, int i)
{
QStringList l = r ? sets : input.isEmpty() ? othermodes : matches;
return i < (int)l.count() ?
(input.isEmpty() ? l[i] : capitalize(l[i]))
: QString::null;
}
bool DictFilterConfig::spreadRow(int r)
{
return r ? TRUE : input.isEmpty() ? TRUE : FALSE;
}
QStringList DictFilterConfig::capitalize(const QStringList& l)
{
switch ( shift ) {
case 1: {
QStringList r;
QStringList::ConstIterator it = l.begin();
r.append((*it).upper());
for (++it; it != l.end(); ++it)
r.append(*it);
return r;
} case 2: {
QStringList r;
for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it)
r.append((*it).upper());
return r;
}
}
return l;
}
QString DictFilterConfig::capitalize(const QString& s)
{
switch ( shift ) {
case 1: {
QString u = s;
u[0] = u[0].upper();
return u;
break;
} case 2:
return s.upper();
break;
}
return s;
}
void DictFilterConfig::pick(bool press, int row, int item)
{
if ( row == 0 ) {
if ( press ) {
if ( input.isEmpty() ) {
lit0 = item;
if ( othermodes[item] == "Space" ) {
updateItem(row,item);
generateText(" ");
} else if ( othermodes[item] == "Back" ) {
updateItem(row,item);
- generateKey(Qt::Key_Backspace);
+ generateKey(::Qt::Key_Backspace);
} else if ( othermodes[item] == "Enter" ) {
updateItem(row,item);
- generateKey(Qt::Key_Return);
+ generateKey(::Qt::Key_Return);
} else if ( othermodes[item] == "Shift" ) {
updateItem(row,item);
shift = (shift+1)%3;
}
}
} else {
if ( !input.isEmpty() ) {
input.clear();
if ( item>=0 ) {
generateText(capitalize(matches[item]));
}
shift = 0;
matches.clear();
updateRows(0,0);
} else if ( item < 3 ) {
lit0 = -1;
changeMode(item+1); // I'm mode 0! ####
updateRows(0,1);
}
if ( lit0 >= 0 ) {
if ( !shift || othermodes[lit0] != "Shift" ) {
updateItem(0,lit0);
lit0 = -1;
}
}
}
} else {
lit0 = -1;
if ( press && item >= 0 ) {
lit1 = item;
add(sets[item]);
updateItem(1,item);
updateRows(0,0);
} else {
updateItem(1,lit1);
lit1 = -1;
}
}
}
bool DictFilterConfig::scanMatch(const QString& set, const QChar& l) const
{
return set == "?" || set == "*" || set.contains(l);
}
//static int visit=0;
//static int lvisit=0;
void DictFilterConfig::scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend)
{
if ( n ) {
do {
//visit++;
bool pastend = ipos >= (int)input.count();
if ( pastend && extend || !pastend && scanMatch(input[ipos],n->letter().lower()) ) {
if ( length>1 ) {
if ( !pastend && input[ipos] == "*" ) {
scan(n->jump(),ipos+1,str+n->letter(),length-1,FALSE);
scan(n->jump(),ipos,str+n->letter(),length,FALSE);
} else {
scan(n->jump(),ipos+1,str+n->letter(),length-1,extend);
}
} else {
if ( n->isWord() ) {
matches.append(str+n->letter());
}
}
}
n = n->next();
} while (n);
}
}
void DictFilterConfig::scanLengths(const QDawg::Node* n, int ipos, int& length_bitarray)
{
if ( n ) {
do {
//lvisit++;
bool pastend = ipos >= (int)input.count();
if ( pastend || scanMatch(input[ipos],n->letter().lower()) ) {
scanLengths(n->jump(),ipos+1,length_bitarray);
if ( n->isWord() )
length_bitarray |= (1<<(ipos+1));
}
n = n->next();
} while (n);
}
}
void DictFilterConfig::add(const QString& set)
{
QFontMetrics fm = parent->fontMetrics();
input.append(set.lower());
matches.clear();
//visit=0;
//lvisit=0;
diff --git a/inputmethods/pickboard/pickboardcfg.h b/inputmethods/pickboard/pickboardcfg.h
index e0dc0dd..b1913df 100644
--- a/inputmethods/pickboard/pickboardcfg.h
+++ b/inputmethods/pickboard/pickboardcfg.h
@@ -19,193 +19,193 @@
**********************************************************************/
#ifndef PICKBOARDCFG_H
#define PICKBOARDCFG_H
#include <qpe/qdawg.h>
#include <qpushbutton.h>
#include <qhbuttongroup.h>
#include <qdialog.h>
#include <qlist.h>
// Internal stuff...
class PickboardPicks;
class LetterButton : public QPushButton {
Q_OBJECT
public:
LetterButton(const QChar& letter, QWidget* parent);
private slots:
void toggleCase();
private:
bool skip;
};
class LetterChoice : public QButtonGroup {
Q_OBJECT
public:
LetterChoice(QWidget* parent, const QString& set);
QChar choice() { return ch; }
signals:
void changed();
private slots:
void change();
private:
QChar ch;
};
class PickboardAdd : public QDialog {
Q_OBJECT
public:
PickboardAdd(QWidget* owner, const QStringList& setlist);
~PickboardAdd();
QString word() const;
bool exec();
private slots:
void checkAllDone();
private:
QPushButton *yes;
LetterChoice **lc;
int nlc;
};
class PickboardConfig : QObject {
public:
PickboardConfig(PickboardPicks* p) : parent(p), nrows(2), pressx(-1) { }
virtual ~PickboardConfig();
virtual void pickPoint(const QPoint& p, bool press);
virtual void draw(QPainter*)=0;
virtual void fillMenu(QPopupMenu&);
virtual void doMenu(int);
protected:
void updateRows(int from, int to);
virtual void updateItem(int r, int i);
virtual void pickInRow(int r, int xpos, bool press)=0;
void changeMode(int m);
virtual void generateText(const QString& s);
void generateKey( int k );
virtual void pick(bool press, int row, int item)=0;
protected:
PickboardPicks* parent;
int nrows;
private:
int pressrow, pressx;
};
class StringConfig : public PickboardConfig {
public:
StringConfig(PickboardPicks* p) : PickboardConfig(p) { }
void draw(QPainter* p);
protected:
virtual QString text(int r, int i)=0;
virtual bool spreadRow(int i)=0;
- virtual QColor rowColor(int) { return Qt::black; }
+ virtual QColor rowColor(int) { return ::Qt::black; }
virtual void pickInRow(int r, int xpos, bool press);
virtual void updateItem(int r, int i);
virtual bool highlight(int,int) const;
};
class CharStringConfig : public StringConfig {
QString input;
QStringList chars;
public:
CharStringConfig(PickboardPicks* p) : StringConfig(p) { }
void addChar(const QString& s);
virtual void doMenu(int);
protected:
QString text(int r, int i);
bool spreadRow(int i);
void pick(bool press, int row, int item);
};
class DictFilterConfig : public StringConfig {
QStringList matches;
QStringList sets;
QStringList othermodes;
int lit0;
int lit1;
int shift;
QString capitalize(const QString& s);
QStringList capitalize(const QStringList& s);
public:
QStringList input;
DictFilterConfig(PickboardPicks* p) : StringConfig(p)
{
shift = 0;
lit0 = -1;
lit1 = -1;
}
void addSet(const QString& s);
void addMode(const QString& s);
void fillMenu(QPopupMenu& menu);
void doMenu(int i);
void add(const QString& set);
protected:
QString text(int r, int i);
bool spreadRow(int i);
void pick(bool press, int row, int item);
bool scanMatch(const QString& set, const QChar& l) const;
void scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend);
void scanLengths(const QDawg::Node* n, int ipos, int& bitarray);
bool highlight(int r,int c) const;
};
class CharConfig : public StringConfig {
QStringList chars1;
QStringList chars2;
public:
CharConfig(PickboardPicks* p) : StringConfig(p) { }
void addChar(int r, const QString& s);
protected:
QString text(int r, int i);
bool spreadRow(int);
void pick(bool press, int row, int item);
};
class KeycodeConfig : public PickboardConfig {
QValueList<int> keys1;
QValueList<int> keys2;
QValueList<QPixmap> keypm1;
QValueList<QPixmap> keypm2;
static const int xw = 8;
static const int xmarg = 8;
public:
KeycodeConfig(PickboardPicks* p) : PickboardConfig(p) { }
void addKey(int r, const QPixmap& pm, int code);
void addGap(int r, int w);
void draw(QPainter* p);
protected:
void pickInRow(int r, int xpos, bool press);
QValueList<QPixmap> row(int i);
void pick(bool press, int row, int item);
};