author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/apps/checkbook/listedit.cpp | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/apps/checkbook/listedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/listedit.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp index 37f05f0..d00e305 100644 --- a/noncore/apps/checkbook/listedit.cpp +++ b/noncore/apps/checkbook/listedit.cpp | |||
@@ -1,168 +1,168 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "listedit.h" | 29 | #include "listedit.h" |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qlistview.h> | 32 | #include <qlistview.h> |
33 | #include <qwidgetstack.h> | 33 | #include <qwidgetstack.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
37 | 37 | ||
38 | 38 | ||
39 | // --- ListEdit --------------------------------------------------------------- | 39 | // --- ListEdit --------------------------------------------------------------- |
40 | ListEdit::ListEdit( QWidget *parent, const char *sName ) | 40 | ListEdit::ListEdit( QWidget *parent, const char *sName ) |
41 | : QWidget(parent, sName), TableDef(sName) | 41 | : QWidget(parent, sName), TableDef(sName) |
42 | { | 42 | { |
43 | // get font height | 43 | // get font height |
44 | int fh = fontMetrics().height(); | 44 | int fh = fontMetrics().height(); |
45 | 45 | ||
46 | // create layout | 46 | // create layout |
47 | QGridLayout *layout=new QGridLayout(this); | 47 | QGridLayout *layout=new QGridLayout(this); |
48 | layout->setSpacing( 2 ); | 48 | layout->setSpacing( 2 ); |
49 | layout->setMargin( 4 ); | 49 | layout->setMargin( 4 ); |
50 | 50 | ||
51 | // type table | 51 | // type table |
52 | _typeTable = new QListView( this ); | 52 | _typeTable = new QListView( this ); |
53 | ColumnDef *def=first(); | 53 | ColumnDef *def=first(); |
54 | while( def ) { | 54 | while( def ) { |
55 | _typeTable->addColumn( def->getName() ); | 55 | _typeTable->addColumn( def->getName() ); |
56 | def=next(); | 56 | def=next(); |
57 | } | 57 | } |
58 | connect( _typeTable, SIGNAL( clicked(QListViewItem *, const QPoint &, int) ), this, SLOT( slotClick(QListViewItem *, const QPoint &, int ) ) ); | 58 | connect( _typeTable, SIGNAL( clicked(QListViewItem*,const QPoint&,int) ), this, SLOT( slotClick(QListViewItem*,const QPoint&,int) ) ); |
59 | layout->addMultiCellWidget(_typeTable, 0,4,0,4); | 59 | layout->addMultiCellWidget(_typeTable, 0,4,0,4); |
60 | _currentItem=NULL; | 60 | _currentItem=NULL; |
61 | 61 | ||
62 | // edit field | 62 | // edit field |
63 | _stack=new QWidgetStack( this ); | 63 | _stack=new QWidgetStack( this ); |
64 | _stack->setMaximumHeight(fh+5); | 64 | _stack->setMaximumHeight(fh+5); |
65 | layout->addMultiCellWidget(_stack, 5,5,0,2); | 65 | layout->addMultiCellWidget(_stack, 5,5,0,2); |
66 | _typeEdit = new QLineEdit( _stack ); | 66 | _typeEdit = new QLineEdit( _stack ); |
67 | _stack->raiseWidget(_typeEdit ); | 67 | _stack->raiseWidget(_typeEdit ); |
68 | connect( _typeEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotEditChanged(const QString &) ) ); | 68 | connect( _typeEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotEditChanged(const QString&) ) ); |
69 | 69 | ||
70 | // combo box | 70 | // combo box |
71 | _box=new QComboBox( _stack ); | 71 | _box=new QComboBox( _stack ); |
72 | connect( _box, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) ); | 72 | connect( _box, SIGNAL( activated(const QString&) ), this, SLOT( slotActivated(const QString&) ) ); |
73 | 73 | ||
74 | 74 | ||
75 | // add button | 75 | // add button |
76 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this ); | 76 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this ); |
77 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); | 77 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); |
78 | layout->addWidget( btn, 5, 3 ); | 78 | layout->addWidget( btn, 5, 3 ); |
79 | 79 | ||
80 | // delete button | 80 | // delete button |
81 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); | 81 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); |
82 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) ); | 82 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) ); |
83 | layout->addWidget( btn, 5, 4 ); | 83 | layout->addWidget( btn, 5, 4 ); |
84 | } | 84 | } |
85 | 85 | ||
86 | // --- ~ListEdit -------------------------------------------------------------- | 86 | // --- ~ListEdit -------------------------------------------------------------- |
87 | ListEdit::~ListEdit() | 87 | ListEdit::~ListEdit() |
88 | { | 88 | { |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | // --- slotEditTypeChanged ---------------------------------------------------- | 92 | // --- slotEditTypeChanged ---------------------------------------------------- |
93 | void ListEdit::slotEditChanged(const QString &str) | 93 | void ListEdit::slotEditChanged(const QString &str) |
94 | { | 94 | { |
95 | if( !_currentItem || _currentColumn<0 ) return; | 95 | if( !_currentItem || _currentColumn<0 ) return; |
96 | _currentItem->setText(_currentColumn, str); | 96 | _currentItem->setText(_currentColumn, str); |
97 | } | 97 | } |
98 | 98 | ||
99 | // --- slotAddType ------------------------------------------------------------ | 99 | // --- slotAddType ------------------------------------------------------------ |
100 | void ListEdit::slotAdd() | 100 | void ListEdit::slotAdd() |
101 | { | 101 | { |
102 | // construct new row | 102 | // construct new row |
103 | QString args[8]; | 103 | QString args[8]; |
104 | ColumnDef *pCol=this->first(); | 104 | ColumnDef *pCol=this->first(); |
105 | int i=0; | 105 | int i=0; |
106 | while( pCol && i<8 ) { | 106 | while( pCol && i<8 ) { |
107 | args[i++]=pCol->getNewValue(); | 107 | args[i++]=pCol->getNewValue(); |
108 | pCol=this->next(); | 108 | pCol=this->next(); |
109 | } | 109 | } |
110 | _currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); | 110 | _currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); |
111 | 111 | ||
112 | // fix uniques | 112 | // fix uniques |
113 | fixTypes(); | 113 | fixTypes(); |
114 | 114 | ||
115 | // display col 0 of new value | 115 | // display col 0 of new value |
116 | QPoint pnt; | 116 | QPoint pnt; |
117 | slotClick(_currentItem, pnt, 0); | 117 | slotClick(_currentItem, pnt, 0); |
118 | _typeTable->setSelected( _currentItem, true ); | 118 | _typeTable->setSelected( _currentItem, true ); |
119 | 119 | ||
120 | // make it selected | 120 | // make it selected |
121 | _typeEdit->setCursorPosition(0); | 121 | _typeEdit->setCursorPosition(0); |
122 | _typeEdit->setSelection(0, _typeEdit->text().length() ); | 122 | _typeEdit->setSelection(0, _typeEdit->text().length() ); |
123 | } | 123 | } |
124 | 124 | ||
125 | // --- slotDel ------------------------------------------------------------- | 125 | // --- slotDel ------------------------------------------------------------- |
126 | void ListEdit::slotDel() | 126 | void ListEdit::slotDel() |
127 | { | 127 | { |
128 | if( !_currentItem ) return; | 128 | if( !_currentItem ) return; |
129 | delete _currentItem; | 129 | delete _currentItem; |
130 | _currentItem=NULL; | 130 | _currentItem=NULL; |
131 | _typeEdit->setText(""); | 131 | _typeEdit->setText(""); |
132 | _stack->raiseWidget(_typeEdit); | 132 | _stack->raiseWidget(_typeEdit); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | // --- fixTypes ---------------------------------------------------------------- | 136 | // --- fixTypes ---------------------------------------------------------------- |
137 | // Makes sure all entries have a unique name and empty entries are replaced | 137 | // Makes sure all entries have a unique name and empty entries are replaced |
138 | // by a generic string. The first version performs the operation on a particular | 138 | // by a generic string. The first version performs the operation on a particular |
139 | // column, whereas the 2nd does it for all unique columns. | 139 | // column, whereas the 2nd does it for all unique columns. |
140 | class ColMap { | 140 | class ColMap { |
141 | public: | 141 | public: |
142 | ColMap(QString sValue, QListViewItem *pEntry) { | 142 | ColMap(QString sValue, QListViewItem *pEntry) { |
143 | _sValue=sValue; | 143 | _sValue=sValue; |
144 | _pEntry=pEntry; | 144 | _pEntry=pEntry; |
145 | } | 145 | } |
146 | QString &getValue() { return(_sValue); } | 146 | QString &getValue() { return(_sValue); } |
147 | QListViewItem *getItem() { return(_pEntry); } | 147 | QListViewItem *getItem() { return(_pEntry); } |
148 | 148 | ||
149 | protected: | 149 | protected: |
150 | QString _sValue; | 150 | QString _sValue; |
151 | QListViewItem *_pEntry; | 151 | QListViewItem *_pEntry; |
152 | }; | 152 | }; |
153 | 153 | ||
154 | class ColList : public QList<QString> | 154 | class ColList : public QList<QString> |
155 | { | 155 | { |
156 | public: | 156 | public: |
157 | ColList() : QList<QString>() { } | 157 | ColList() : QList<QString>() { } |
158 | 158 | ||
159 | protected: | 159 | protected: |
160 | int compareItems(QCollection::Item, QCollection::Item); | 160 | int compareItems(QCollection::Item, QCollection::Item); |
161 | }; | 161 | }; |
162 | 162 | ||
163 | int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) { | 163 | int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) { |
164 | return( ((QString *)i1)->compare(*(QString *)i2) ); | 164 | return( ((QString *)i1)->compare(*(QString *)i2) ); |
165 | } | 165 | } |
166 | 166 | ||
167 | void ListEdit::fixTypes(int iColumn) | 167 | void ListEdit::fixTypes(int iColumn) |
168 | { | 168 | { |