46 files changed, 336 insertions, 367 deletions
diff --git a/noncore/apps/advancedfm/filePermissions.cpp b/noncore/apps/advancedfm/filePermissions.cpp index c06f14f..4de6d12 100644 --- a/noncore/apps/advancedfm/filePermissions.cpp +++ b/noncore/apps/advancedfm/filePermissions.cpp | |||
@@ -1,274 +1,270 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2002 ljp ljp@llornkcor.com | 2 | ** copyright 2002 ljp ljp@llornkcor.com |
3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter | 3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <qfile.h> | ||
17 | #include <qfileinfo.h> | 16 | #include <qfileinfo.h> |
18 | 17 | ||
19 | #include <qcheckbox.h> | 18 | #include <qcheckbox.h> |
20 | #include <qlabel.h> | 19 | #include <qlabel.h> |
21 | #include <qlineedit.h> | 20 | #include <qlineedit.h> |
22 | #include <qlayout.h> | ||
23 | #include <qvariant.h> | ||
24 | #include <qtooltip.h> | ||
25 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
26 | 22 | ||
27 | #include <unistd.h> | 23 | #include <unistd.h> |
28 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
29 | #include <stdlib.h> | 25 | #include <stdlib.h> |
30 | #include <sys/types.h> | 26 | #include <sys/types.h> |
31 | #include <pwd.h> | 27 | #include <pwd.h> |
32 | #include <grp.h> | 28 | #include <grp.h> |
33 | 29 | ||
34 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) | 30 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) |
35 | : QDialog( parent, name, modal, fl ) | 31 | : QDialog( parent, name, modal, fl ) |
36 | { | 32 | { |
37 | if ( !name ) | 33 | if ( !name ) |
38 | setName( "filePermissions" ); | 34 | setName( "filePermissions" ); |
39 | // qDebug("FilePermissions "+fileName); | 35 | // qDebug("FilePermissions "+fileName); |
40 | /* resize( 236, 210 ); | 36 | /* resize( 236, 210 ); |
41 | setMaximumSize( QSize( 236, 210 ) ); | 37 | setMaximumSize( QSize( 236, 210 ) ); |
42 | */ setCaption( tr( "Set File Permissions" ) ); | 38 | */ setCaption( tr( "Set File Permissions" ) ); |
43 | 39 | ||
44 | TextLabel1 = new QLabel( this, "TextLabel1" ); | 40 | TextLabel1 = new QLabel( this, "TextLabel1" ); |
45 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); | 41 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); |
46 | TextLabel1->setText( tr( "Set file permissions for:" ) ); | 42 | TextLabel1->setText( tr( "Set file permissions for:" ) ); |
47 | 43 | ||
48 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 44 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
49 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); | 45 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); |
50 | LineEdit1->setReadOnly(true); | 46 | LineEdit1->setReadOnly(true); |
51 | 47 | ||
52 | TextLabel4 = new QLabel( this, "TextLabel4" ); | 48 | TextLabel4 = new QLabel( this, "TextLabel4" ); |
53 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); | 49 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); |
54 | TextLabel4->setText( tr( "owner" ) ); | 50 | TextLabel4->setText( tr( "owner" ) ); |
55 | 51 | ||
56 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); | 52 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); |
57 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); | 53 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); |
58 | TextLabel4_2->setText( tr( "group" ) ); | 54 | TextLabel4_2->setText( tr( "group" ) ); |
59 | 55 | ||
60 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); | 56 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); |
61 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); | 57 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); |
62 | TextLabel4_3->setText( tr( "others" ) ); | 58 | TextLabel4_3->setText( tr( "others" ) ); |
63 | 59 | ||
64 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); | 60 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); |
65 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); | 61 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); |
66 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); | 62 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); |
67 | 63 | ||
68 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); | 64 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); |
69 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); | 65 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); |
70 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); | 66 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); |
71 | 67 | ||
72 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); | 68 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); |
73 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); | 69 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); |
74 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); | 70 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); |
75 | 71 | ||
76 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); | 72 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); |
77 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); | 73 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); |
78 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); | 74 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); |
79 | 75 | ||
80 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); | 76 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); |
81 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); | 77 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); |
82 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); | 78 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); |
83 | 79 | ||
84 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); | 80 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); |
85 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); | 81 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); |
86 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); | 82 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); |
87 | 83 | ||
88 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); | 84 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); |
89 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); | 85 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); |
90 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); | 86 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); |
91 | 87 | ||
92 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); | 88 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); |
93 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); | 89 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); |
94 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); | 90 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); |
95 | 91 | ||
96 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); | 92 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); |
97 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); | 93 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); |
98 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); | 94 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); |
99 | 95 | ||
100 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); | 96 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); |
101 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); | 97 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); |
102 | 98 | ||
103 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); | 99 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); |
104 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); | 100 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); |
105 | 101 | ||
106 | TextLabel5 = new QLabel( this, "TextLabel5" ); | 102 | TextLabel5 = new QLabel( this, "TextLabel5" ); |
107 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); | 103 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); |
108 | TextLabel5->setText( tr( "Owner" ) ); | 104 | TextLabel5->setText( tr( "Owner" ) ); |
109 | 105 | ||
110 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); | 106 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); |
111 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); | 107 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); |
112 | TextLabel5_2->setText( tr( "Group" ) ); | 108 | TextLabel5_2->setText( tr( "Group" ) ); |
113 | 109 | ||
114 | ModeLine = new QLineEdit( this, "TextLabelMode" ); | 110 | ModeLine = new QLineEdit( this, "TextLabelMode" ); |
115 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); | 111 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); |
116 | 112 | ||
117 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); | 113 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); |
118 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); | 114 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); |
119 | TextLabel3_2->setText( tr( "read" ) ); | 115 | TextLabel3_2->setText( tr( "read" ) ); |
120 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 116 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
121 | 117 | ||
122 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); | 118 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); |
123 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); | 119 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); |
124 | TextLabel3_2_2->setText( tr( "write" ) ); | 120 | TextLabel3_2_2->setText( tr( "write" ) ); |
125 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 121 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
126 | 122 | ||
127 | TextLabel3 = new QLabel( this, "TextLabel3" ); | 123 | TextLabel3 = new QLabel( this, "TextLabel3" ); |
128 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); | 124 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); |
129 | TextLabel3->setText( tr( "execute" ) ); | 125 | TextLabel3->setText( tr( "execute" ) ); |
130 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 126 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
131 | 127 | ||
132 | struct stat buf; | 128 | struct stat buf; |
133 | mode_t mode; | 129 | mode_t mode; |
134 | file = fileName; | 130 | file = fileName; |
135 | QFileInfo fi(file); | 131 | QFileInfo fi(file); |
136 | 132 | ||
137 | LineEdit1->setText( file); | 133 | LineEdit1->setText( file); |
138 | OwnerLineEdit->setText( fi.owner()); | 134 | OwnerLineEdit->setText( fi.owner()); |
139 | GroupLineEdit->setText( fi.group()); | 135 | GroupLineEdit->setText( fi.group()); |
140 | 136 | ||
141 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } | 137 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } |
142 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } | 138 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } |
143 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } | 139 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } |
144 | 140 | ||
145 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } | 141 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } |
146 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } | 142 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } |
147 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } | 143 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } |
148 | 144 | ||
149 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } | 145 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } |
150 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } | 146 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } |
151 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } | 147 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } |
152 | 148 | ||
153 | stat(file.latin1(), &buf); | 149 | stat(file.latin1(), &buf); |
154 | mode = buf.st_mode; | 150 | mode = buf.st_mode; |
155 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); | 151 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); |
156 | ModeLine->setText(modeStr); | 152 | ModeLine->setText(modeStr); |
157 | bool ok; | 153 | bool ok; |
158 | i_mode = modeStr.toInt(&ok,10); | 154 | i_mode = modeStr.toInt(&ok,10); |
159 | 155 | ||
160 | } | 156 | } |
161 | 157 | ||
162 | /* | 158 | /* |
163 | * Destroys the object and frees any allocated resources | 159 | * Destroys the object and frees any allocated resources |
164 | */ | 160 | */ |
165 | filePermissions::~filePermissions() | 161 | filePermissions::~filePermissions() |
166 | { | 162 | { |
167 | } | 163 | } |
168 | 164 | ||
169 | 165 | ||
170 | // might this be better as a callback routine??? | 166 | // might this be better as a callback routine??? |
171 | void filePermissions::ownReadCheck() { | 167 | void filePermissions::ownReadCheck() { |
172 | if(CheckBox1->isChecked()) { i_mode +=400; } | 168 | if(CheckBox1->isChecked()) { i_mode +=400; } |
173 | else i_mode -=400; | 169 | else i_mode -=400; |
174 | modeStr.sprintf("0%d",i_mode); | 170 | modeStr.sprintf("0%d",i_mode); |
175 | ModeLine->setText( modeStr); | 171 | ModeLine->setText( modeStr); |
176 | // 0400 | 172 | // 0400 |
177 | } | 173 | } |
178 | 174 | ||
179 | void filePermissions::ownWriteCheck() { | 175 | void filePermissions::ownWriteCheck() { |
180 | if(CheckBox1_2->isChecked()) { i_mode +=200; } | 176 | if(CheckBox1_2->isChecked()) { i_mode +=200; } |
181 | else i_mode -=200; | 177 | else i_mode -=200; |
182 | modeStr.sprintf("0%d",i_mode); | 178 | modeStr.sprintf("0%d",i_mode); |
183 | ModeLine->setText(modeStr); | 179 | ModeLine->setText(modeStr); |
184 | // 0200 | 180 | // 0200 |
185 | } | 181 | } |
186 | 182 | ||
187 | void filePermissions::ownExeCheck() { | 183 | void filePermissions::ownExeCheck() { |
188 | if(CheckBox1_3->isChecked()) { i_mode +=100; } | 184 | if(CheckBox1_3->isChecked()) { i_mode +=100; } |
189 | else i_mode -=100; | 185 | else i_mode -=100; |
190 | modeStr.sprintf("0%d",i_mode); | 186 | modeStr.sprintf("0%d",i_mode); |
191 | ModeLine->setText(modeStr); | 187 | ModeLine->setText(modeStr); |
192 | // 0100 | 188 | // 0100 |
193 | } | 189 | } |
194 | 190 | ||
195 | void filePermissions::grpReadCheck() { | 191 | void filePermissions::grpReadCheck() { |
196 | if(CheckBox1_4->isChecked()) { i_mode +=40; } | 192 | if(CheckBox1_4->isChecked()) { i_mode +=40; } |
197 | else i_mode -=40; | 193 | else i_mode -=40; |
198 | modeStr.sprintf("0%d",i_mode); | 194 | modeStr.sprintf("0%d",i_mode); |
199 | ModeLine->setText(modeStr); | 195 | ModeLine->setText(modeStr); |
200 | // 0040 | 196 | // 0040 |
201 | } | 197 | } |
202 | 198 | ||
203 | void filePermissions::grpWriteCheck() { | 199 | void filePermissions::grpWriteCheck() { |
204 | if(CheckBox1_5->isChecked()) { i_mode +=20; } | 200 | if(CheckBox1_5->isChecked()) { i_mode +=20; } |
205 | else i_mode -=20; | 201 | else i_mode -=20; |
206 | modeStr.sprintf("0%d",i_mode); | 202 | modeStr.sprintf("0%d",i_mode); |
207 | ModeLine->setText(modeStr); | 203 | ModeLine->setText(modeStr); |
208 | // 0020 | 204 | // 0020 |
209 | } | 205 | } |
210 | 206 | ||
211 | void filePermissions::grpExeCheck() { | 207 | void filePermissions::grpExeCheck() { |
212 | if(CheckBox1_6->isChecked()) { i_mode +=10; } | 208 | if(CheckBox1_6->isChecked()) { i_mode +=10; } |
213 | else i_mode -=10; | 209 | else i_mode -=10; |
214 | modeStr.sprintf("0%d",i_mode); | 210 | modeStr.sprintf("0%d",i_mode); |
215 | ModeLine->setText(modeStr); | 211 | ModeLine->setText(modeStr); |
216 | // 0010 | 212 | // 0010 |
217 | } | 213 | } |
218 | 214 | ||
219 | void filePermissions::wrldReadCheck() { | 215 | void filePermissions::wrldReadCheck() { |
220 | if(CheckBox1_7->isChecked()) { i_mode +=4; } | 216 | if(CheckBox1_7->isChecked()) { i_mode +=4; } |
221 | else i_mode -=4; | 217 | else i_mode -=4; |
222 | modeStr.sprintf("0%d",i_mode); | 218 | modeStr.sprintf("0%d",i_mode); |
223 | ModeLine->setText(modeStr); | 219 | ModeLine->setText(modeStr); |
224 | // 0004 | 220 | // 0004 |
225 | } | 221 | } |
226 | 222 | ||
227 | void filePermissions::wrldWriteCheck() { | 223 | void filePermissions::wrldWriteCheck() { |
228 | if(CheckBox1_8->isChecked()) { i_mode +=2; } | 224 | if(CheckBox1_8->isChecked()) { i_mode +=2; } |
229 | else i_mode -=2; | 225 | else i_mode -=2; |
230 | modeStr.sprintf("0%d",i_mode); | 226 | modeStr.sprintf("0%d",i_mode); |
231 | ModeLine->setText(modeStr); | 227 | ModeLine->setText(modeStr); |
232 | // 0002 | 228 | // 0002 |
233 | } | 229 | } |
234 | 230 | ||
235 | void filePermissions::wrldExeCheck() { | 231 | void filePermissions::wrldExeCheck() { |
236 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } | 232 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } |
237 | else i_mode -=1; | 233 | else i_mode -=1; |
238 | modeStr.sprintf("0%d",i_mode); | 234 | modeStr.sprintf("0%d",i_mode); |
239 | ModeLine->setText(modeStr); | 235 | ModeLine->setText(modeStr); |
240 | // 0001 | 236 | // 0001 |
241 | } | 237 | } |
242 | 238 | ||
243 | void filePermissions::accept() { | 239 | void filePermissions::accept() { |
244 | 240 | ||
245 | QFileInfo fi(file); | 241 | QFileInfo fi(file); |
246 | struct passwd *pwd=0; | 242 | struct passwd *pwd=0; |
247 | struct group *grp=0; | 243 | struct group *grp=0; |
248 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); | 244 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); |
249 | if(pwd == NULL) { | 245 | if(pwd == NULL) { |
250 | perror("getpwnam"); | 246 | perror("getpwnam"); |
251 | QMessageBox::warning(this,"Warning","Error- no user"); | 247 | QMessageBox::warning(this,tr("Warning"),tr("Error- no user") ); |
252 | return; | 248 | return; |
253 | } else { | 249 | } else { |
254 | grp = getgrnam(GroupLineEdit->text().latin1()); | 250 | grp = getgrnam(GroupLineEdit->text().latin1()); |
255 | if(grp==NULL) { | 251 | if(grp==NULL) { |
256 | perror("getgrnam"); | 252 | perror("getgrnam"); |
257 | QMessageBox::warning(this,"Warning","Error- no group"); | 253 | QMessageBox::warning(this,tr("Warning"),tr("Error- no group")); |
258 | return; | 254 | return; |
259 | } | 255 | } |
260 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { | 256 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { |
261 | perror("chown"); | 257 | perror("chown"); |
262 | QMessageBox::warning(this,"Warning","Error setting ownership or group"); | 258 | QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group") ); |
263 | return; | 259 | return; |
264 | } | 260 | } |
265 | bool ok; | 261 | bool ok; |
266 | uint moder = modeStr.toUInt(&ok,8); | 262 | uint moder = modeStr.toUInt(&ok,8); |
267 | if( chmod( file.latin1(), moder) < 0) { | 263 | if( chmod( file.latin1(), moder) < 0) { |
268 | perror("chmod"); | 264 | perror("chmod"); |
269 | QMessageBox::warning(this,"Warning","Error setting mode"); | 265 | QMessageBox::warning(this,tr("Warning"),tr("Error setting mode") ); |
270 | return; | 266 | return; |
271 | } | 267 | } |
272 | } | 268 | } |
273 | close(); | 269 | close(); |
274 | } | 270 | } |
diff --git a/noncore/apps/advancedfm/main.cpp b/noncore/apps/advancedfm/main.cpp index a0401e8..8cacc4a 100644 --- a/noncore/apps/advancedfm/main.cpp +++ b/noncore/apps/advancedfm/main.cpp | |||
@@ -1,31 +1,27 @@ | |||
1 | 1 | ||
2 | /*************************************************************************** | 2 | /*************************************************************************** |
3 | main.cpp - description | 3 | main.cpp - description |
4 | ------------------- | 4 | ------------------- |
5 | begin : March 10, 2002 | 5 | begin : March 10, 2002 |
6 | copyright : (C) 2002 by llornkcor | 6 | copyright : (C) 2002 by llornkcor |
7 | email : ljp@llornkcor.com | 7 | email : ljp@llornkcor.com |
8 | * This program is free software; you can redistribute it and/or modify * | 8 | * This program is free software; you can redistribute it and/or modify * |
9 | * it under the terms of the GNU General Public License as published by * | 9 | * it under the terms of the GNU General Public License as published by * |
10 | * the Free Software Foundation; either version 2 of the License, or * | 10 | * the Free Software Foundation; either version 2 of the License, or * |
11 | * (at your option) any later version. * | 11 | * (at your option) any later version. * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | #include <qpe/qcopenvelope_qws.h> | ||
15 | #include <qpe/config.h> | ||
16 | #include <qstring.h> | ||
17 | #include <qstringlist.h> | ||
18 | 14 | ||
19 | 15 | ||
20 | 16 | ||
21 | #include "advancedfm.h" | 17 | #include "advancedfm.h" |
22 | 18 | ||
23 | int main(int argc, char *argv[]) | 19 | int main(int argc, char *argv[]) |
24 | { | 20 | { |
25 | QPEApplication a(argc, argv); | 21 | QPEApplication a(argc, argv); |
26 | 22 | ||
27 | AdvancedFm advencedFm; | 23 | AdvancedFm advencedFm; |
28 | a.showMainWidget( &advencedFm); | 24 | a.showMainWidget( &advencedFm); |
29 | return a.exec(); | 25 | return a.exec(); |
30 | } | 26 | } |
31 | 27 | ||
diff --git a/noncore/apps/advancedfm/opie-advancedfm.control b/noncore/apps/advancedfm/opie-advancedfm.control index f17c590..1e0f9ec 100644 --- a/noncore/apps/advancedfm/opie-advancedfm.control +++ b/noncore/apps/advancedfm/opie-advancedfm.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-advancedfm | 1 | Package: opie-advancedfm |
2 | Files: bin/advancedfm apps/Applications/advancedfm.desktop pics/advancedfm | 2 | Files: bin/advancedfm apps/Applications/advancedfm.desktop pics/advancedfm |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: L.J. Potter <ljp@llornkcor.com> | 5 | Maintainer: L.J. Potter <ljp@llornkcor.com> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal | 7 | Depends: task-opie-minimal |
9 | Description: Advanced File Manager | 8 | Description: Advanced File Manager |
10 | The advanced file manager for the Opie environment. | 9 | The advanced file manager for the Opie environment. |
10 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index a60cea6..33abdfc 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp | |||
@@ -1,284 +1,278 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** outputEdit.cpp | 2 | ** outputEdit.cpp |
3 | ** | 3 | ** |
4 | ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> | 4 | ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> |
5 | ****************************************************************************/ | 5 | ****************************************************************************/ |
6 | #include "output.h" | 6 | #include "output.h" |
7 | 7 | ||
8 | #include <opie/oprocess.h> | 8 | #include <opie/oprocess.h> |
9 | 9 | ||
10 | #include <qpe/filemanager.h> | ||
11 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
12 | #include <qpe/applnk.h> | 11 | #include <qpe/applnk.h> |
13 | 12 | ||
14 | #include <qmessagebox.h> | ||
15 | #include <qstringlist.h> | ||
16 | #include <qfile.h> | 13 | #include <qfile.h> |
17 | #include <qcstring.h> | ||
18 | #include <qlineedit.h> | ||
19 | #include <qmultilineedit.h> | 14 | #include <qmultilineedit.h> |
20 | #include <qpushbutton.h> | 15 | #include <qpushbutton.h> |
21 | #include <qlayout.h> | 16 | #include <qlayout.h> |
22 | #include <qvariant.h> | ||
23 | 17 | ||
24 | #include <errno.h> | 18 | #include <errno.h> |
25 | 19 | ||
26 | /* XPM */ | 20 | /* XPM */ |
27 | static char * filesave_xpm[] = { | 21 | static char * filesave_xpm[] = { |
28 | "16 16 78 1", | 22 | "16 16 78 1", |
29 | " c None", | 23 | " c None", |
30 | ". c #343434", | 24 | ". c #343434", |
31 | "+ c #A0A0A0", | 25 | "+ c #A0A0A0", |
32 | "@ c #565656", | 26 | "@ c #565656", |
33 | "# c #9E9E9E", | 27 | "# c #9E9E9E", |
34 | "$ c #525252", | 28 | "$ c #525252", |
35 | "% c #929292", | 29 | "% c #929292", |
36 | "& c #676767", | 30 | "& c #676767", |
37 | "* c #848484", | 31 | "* c #848484", |
38 | "= c #666666", | 32 | "= c #666666", |
39 | "- c #D8D8D8", | 33 | "- c #D8D8D8", |
40 | "; c #FFFFFF", | 34 | "; c #FFFFFF", |
41 | "> c #DBDBDB", | 35 | "> c #DBDBDB", |
42 | ", c #636363", | 36 | ", c #636363", |
43 | "' c #989898", | 37 | "' c #989898", |
44 | ") c #2D2D2D", | 38 | ") c #2D2D2D", |
45 | "! c #909090", | 39 | "! c #909090", |
46 | "~ c #AEAEAE", | 40 | "~ c #AEAEAE", |
47 | "{ c #EAEAEA", | 41 | "{ c #EAEAEA", |
48 | "] c #575757", | 42 | "] c #575757", |
49 | "^ c #585858", | 43 | "^ c #585858", |
50 | "/ c #8A8A8A", | 44 | "/ c #8A8A8A", |
51 | "( c #828282", | 45 | "( c #828282", |
52 | "_ c #6F6F6F", | 46 | "_ c #6F6F6F", |
53 | ": c #C9C9C9", | 47 | ": c #C9C9C9", |
54 | "< c #050505", | 48 | "< c #050505", |
55 | "[ c #292929", | 49 | "[ c #292929", |
56 | "} c #777777", | 50 | "} c #777777", |
57 | "| c #616161", | 51 | "| c #616161", |
58 | "1 c #3A3A3A", | 52 | "1 c #3A3A3A", |
59 | "2 c #BEBEBE", | 53 | "2 c #BEBEBE", |
60 | "3 c #2C2C2C", | 54 | "3 c #2C2C2C", |
61 | "4 c #7C7C7C", | 55 | "4 c #7C7C7C", |
62 | "5 c #F6F6F6", | 56 | "5 c #F6F6F6", |
63 | "6 c #FCFCFC", | 57 | "6 c #FCFCFC", |
64 | "7 c #6B6B6B", | 58 | "7 c #6B6B6B", |
65 | "8 c #959595", | 59 | "8 c #959595", |
66 | "9 c #4F4F4F", | 60 | "9 c #4F4F4F", |
67 | "0 c #808080", | 61 | "0 c #808080", |
68 | "a c #767676", | 62 | "a c #767676", |
69 | "b c #818181", | 63 | "b c #818181", |
70 | "c c #B8B8B8", | 64 | "c c #B8B8B8", |
71 | "d c #FBFBFB", | 65 | "d c #FBFBFB", |
72 | "e c #F9F9F9", | 66 | "e c #F9F9F9", |
73 | "f c #CCCCCC", | 67 | "f c #CCCCCC", |
74 | "g c #030303", | 68 | "g c #030303", |
75 | "h c #737373", | 69 | "h c #737373", |
76 | "i c #7A7A7A", | 70 | "i c #7A7A7A", |
77 | "j c #7E7E7E", | 71 | "j c #7E7E7E", |
78 | "k c #6A6A6A", | 72 | "k c #6A6A6A", |
79 | "l c #FAFAFA", | 73 | "l c #FAFAFA", |
80 | "m c #505050", | 74 | "m c #505050", |
81 | "n c #9D9D9D", | 75 | "n c #9D9D9D", |
82 | "o c #333333", | 76 | "o c #333333", |
83 | "p c #7B7B7B", | 77 | "p c #7B7B7B", |
84 | "q c #787878", | 78 | "q c #787878", |
85 | "r c #696969", | 79 | "r c #696969", |
86 | "s c #494949", | 80 | "s c #494949", |
87 | "t c #555555", | 81 | "t c #555555", |
88 | "u c #949494", | 82 | "u c #949494", |
89 | "v c #E6E6E6", | 83 | "v c #E6E6E6", |
90 | "w c #424242", | 84 | "w c #424242", |
91 | "x c #515151", | 85 | "x c #515151", |
92 | "y c #535353", | 86 | "y c #535353", |
93 | "z c #3E3E3E", | 87 | "z c #3E3E3E", |
94 | "A c #D4D4D4", | 88 | "A c #D4D4D4", |
95 | "B c #0C0C0C", | 89 | "B c #0C0C0C", |
96 | "C c #353535", | 90 | "C c #353535", |
97 | "D c #474747", | 91 | "D c #474747", |
98 | "E c #ECECEC", | 92 | "E c #ECECEC", |
99 | "F c #919191", | 93 | "F c #919191", |
100 | "G c #7D7D7D", | 94 | "G c #7D7D7D", |
101 | "H c #000000", | 95 | "H c #000000", |
102 | "I c #404040", | 96 | "I c #404040", |
103 | "J c #858585", | 97 | "J c #858585", |
104 | "K c #323232", | 98 | "K c #323232", |
105 | "L c #D0D0D0", | 99 | "L c #D0D0D0", |
106 | "M c #1C1C1C", | 100 | "M c #1C1C1C", |
107 | " ...+ ", | 101 | " ...+ ", |
108 | " @#$%&..+ ", | 102 | " @#$%&..+ ", |
109 | " .*=-;;>,..+ ", | 103 | " .*=-;;>,..+ ", |
110 | " ')!~;;;;;;{]..", | 104 | " ')!~;;;;;;{]..", |
111 | " ^/(-;;;;;;;_:<", | 105 | " ^/(-;;;;;;;_:<", |
112 | " [}|;;;;;;;{12$", | 106 | " [}|;;;;;;;{12$", |
113 | " #34-55;;;;678$+", | 107 | " #34-55;;;;678$+", |
114 | " 90ab=c;dd;e1fg ", | 108 | " 90ab=c;dd;e1fg ", |
115 | " [ahij((kbl0mn$ ", | 109 | " [ahij((kbl0mn$ ", |
116 | " op^q^^7r&]s/$+ ", | 110 | " op^q^^7r&]s/$+ ", |
117 | "@btu;vbwxy]zAB ", | 111 | "@btu;vbwxy]zAB ", |
118 | "CzDEvEv;;DssF$ ", | 112 | "CzDEvEv;;DssF$ ", |
119 | "G.H{E{E{IxsJ$+ ", | 113 | "G.H{E{E{IxsJ$+ ", |
120 | " +...vEKxzLM ", | 114 | " +...vEKxzLM ", |
121 | " +...z]n$ ", | 115 | " +...z]n$ ", |
122 | " +... "}; | 116 | " +... "}; |
123 | 117 | ||
124 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) | 118 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) |
125 | : QDialog( parent, name, modal, fl ) | 119 | : QDialog( parent, name, modal, fl ) |
126 | { | 120 | { |
127 | QStringList cmmds; | 121 | QStringList cmmds; |
128 | // cmmds=QStringList::split( " ", commands, false); | 122 | // cmmds=QStringList::split( " ", commands, false); |
129 | cmmds=commands; | 123 | cmmds=commands; |
130 | // qDebug("count %d", cmmds.count()); | 124 | // qDebug("count %d", cmmds.count()); |
131 | if ( !name ) | 125 | if ( !name ) |
132 | setName( tr("Output")); | 126 | setName( tr("Output")); |
133 | resize( 196, 269 ); | 127 | resize( 196, 269 ); |
134 | setCaption( name ); | 128 | setCaption( name ); |
135 | 129 | ||
136 | OutputLayout = new QGridLayout( this ); | 130 | OutputLayout = new QGridLayout( this ); |
137 | OutputLayout->setSpacing( 2); | 131 | OutputLayout->setSpacing( 2); |
138 | OutputLayout->setMargin( 2); | 132 | OutputLayout->setMargin( 2); |
139 | 133 | ||
140 | QPushButton *docButton; | 134 | QPushButton *docButton; |
141 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); | 135 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); |
142 | docButton->setFixedSize( QSize( 20, 20 ) ); | 136 | docButton->setFixedSize( QSize( 20, 20 ) ); |
143 | connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); | 137 | connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); |
144 | // docButton->setFlat(TRUE); | 138 | // docButton->setFlat(TRUE); |
145 | OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); | 139 | OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); |
146 | 140 | ||
147 | OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); | 141 | OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); |
148 | OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); | 142 | OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); |
149 | 143 | ||
150 | proc = new OProcess(); | 144 | proc = new OProcess(); |
151 | 145 | ||
152 | connect(proc, SIGNAL(processExited(OProcess *)), | 146 | connect(proc, SIGNAL(processExited(OProcess *)), |
153 | this, SLOT( processFinished())); | 147 | this, SLOT( processFinished())); |
154 | 148 | ||
155 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), | 149 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), |
156 | this, SLOT(commandStdout(OProcess *, char *, int))); | 150 | this, SLOT(commandStdout(OProcess *, char *, int))); |
157 | 151 | ||
158 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), | 152 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), |
159 | this, SLOT(commandStderr(OProcess *, char *, int))); | 153 | this, SLOT(commandStderr(OProcess *, char *, int))); |
160 | 154 | ||
161 | // connect( , SIGNAL(received(const QByteArray &)), | 155 | // connect( , SIGNAL(received(const QByteArray &)), |
162 | // this, SLOT(commandStdin(const QByteArray &))); | 156 | // this, SLOT(commandStdin(const QByteArray &))); |
163 | 157 | ||
164 | // * proc << commands.latin1(); | 158 | // * proc << commands.latin1(); |
165 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { | 159 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { |
166 | qDebug( "%s", (*it).latin1() ); | 160 | qDebug( "%s", (*it).latin1() ); |
167 | * proc << (*it).latin1(); | 161 | * proc << (*it).latin1(); |
168 | } | 162 | } |
169 | 163 | ||
170 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { | 164 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { |
171 | 165 | ||
172 | OutputEdit->append("Process could not start"); | 166 | OutputEdit->append(tr("Process could not start") ); |
173 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 167 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
174 | perror("Error: "); | 168 | perror("Error: "); |
175 | QString errorMsg="Error\n"+(QString)strerror(errno); | 169 | QString errorMsg=tr("Error\n")+(QString)strerror(errno); |
176 | OutputEdit->append( errorMsg); | 170 | OutputEdit->append( errorMsg); |
177 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 171 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
178 | } | 172 | } |
179 | } | 173 | } |
180 | 174 | ||
181 | Output::~Output() { | 175 | Output::~Output() { |
182 | } | 176 | } |
183 | 177 | ||
184 | void Output::saveOutput() { | 178 | void Output::saveOutput() { |
185 | 179 | ||
186 | InputDialog *fileDlg; | 180 | InputDialog *fileDlg; |
187 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); | 181 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); |
188 | fileDlg->exec(); | 182 | fileDlg->exec(); |
189 | if( fileDlg->result() == 1 ) { | 183 | if( fileDlg->result() == 1 ) { |
190 | QString filename = QPEApplication::documentDir(); | 184 | QString filename = QPEApplication::documentDir(); |
191 | if(filename.right(1).find('/') == -1) | 185 | if(filename.right(1).find('/') == -1) |
192 | filename+="/"; | 186 | filename+="/"; |
193 | QString name = fileDlg->LineEdit1->text(); | 187 | QString name = fileDlg->LineEdit1->text(); |
194 | filename+="text/plain/"+name; | 188 | filename+="text/plain/"+name; |
195 | qDebug(filename); | 189 | qDebug(filename); |
196 | 190 | ||
197 | QFile f(filename); | 191 | QFile f(filename); |
198 | f.open( IO_WriteOnly); | 192 | f.open( IO_WriteOnly); |
199 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { | 193 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { |
200 | DocLnk lnk; | 194 | DocLnk lnk; |
201 | lnk.setName(name); //sets file name | 195 | lnk.setName(name); //sets file name |
202 | lnk.setFile(filename); //sets File property | 196 | lnk.setFile(filename); //sets File property |
203 | lnk.setType("text/plain"); | 197 | lnk.setType("text/plain"); |
204 | if(!lnk.writeLink()) { | 198 | if(!lnk.writeLink()) { |
205 | qDebug("Writing doclink did not work"); | 199 | qDebug("Writing doclink did not work"); |
206 | } | 200 | } |
207 | } else | 201 | } else |
208 | qWarning("Could not write file"); | 202 | qWarning("Could not write file"); |
209 | f.close(); | 203 | f.close(); |
210 | } | 204 | } |
211 | } | 205 | } |
212 | 206 | ||
213 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { | 207 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { |
214 | qWarning("received stdout %d bytes", buflen); | 208 | qWarning("received stdout %d bytes", buflen); |
215 | 209 | ||
216 | // QByteArray data(buflen); | 210 | // QByteArray data(buflen); |
217 | // data.fill(*buffer, buflen); | 211 | // data.fill(*buffer, buflen); |
218 | // for (uint i = 0; i < data.count(); i++ ) { | 212 | // for (uint i = 0; i < data.count(); i++ ) { |
219 | // printf("%c", buffer[i] ); | 213 | // printf("%c", buffer[i] ); |
220 | // } | 214 | // } |
221 | // printf("\n"); | 215 | // printf("\n"); |
222 | 216 | ||
223 | QString lineStr = buffer; | 217 | QString lineStr = buffer; |
224 | lineStr=lineStr.left(lineStr.length()-1); | 218 | lineStr=lineStr.left(lineStr.length()-1); |
225 | OutputEdit->append(lineStr); | 219 | OutputEdit->append(lineStr); |
226 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 220 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
227 | } | 221 | } |
228 | 222 | ||
229 | 223 | ||
230 | void Output::commandStdin( const QByteArray &data) { | 224 | void Output::commandStdin( const QByteArray &data) { |
231 | qWarning("received stdin %d bytes", data.size()); | 225 | qWarning("received stdin %d bytes", data.size()); |
232 | // recieved data from the io layer goes to sz | 226 | // recieved data from the io layer goes to sz |
233 | proc->writeStdin(data.data(), data.size()); | 227 | proc->writeStdin(data.data(), data.size()); |
234 | } | 228 | } |
235 | 229 | ||
236 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { | 230 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { |
237 | qWarning("received stderrt %d bytes", buflen); | 231 | qWarning("received stderrt %d bytes", buflen); |
238 | 232 | ||
239 | QString lineStr = buffer; | 233 | QString lineStr = buffer; |
240 | // lineStr=lineStr.left(lineStr.length()-1); | 234 | // lineStr=lineStr.left(lineStr.length()-1); |
241 | OutputEdit->append(lineStr); | 235 | OutputEdit->append(lineStr); |
242 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 236 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
243 | } | 237 | } |
244 | 238 | ||
245 | void Output::processFinished() { | 239 | void Output::processFinished() { |
246 | 240 | ||
247 | delete proc; | 241 | delete proc; |
248 | OutputEdit->append( "\nFinished\n"); | 242 | OutputEdit->append( tr("\nFinished\n") ); |
249 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 243 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
250 | // close(); | 244 | // close(); |
251 | // disconnect( layer(), SIGNAL(received(const QByteArray &)), | 245 | // disconnect( layer(), SIGNAL(received(const QByteArray &)), |
252 | // this, SLOT(commandStdin(const QByteArray &))); | 246 | // this, SLOT(commandStdin(const QByteArray &))); |
253 | } | 247 | } |
254 | 248 | ||
255 | //============================== | 249 | //============================== |
256 | 250 | ||
257 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 251 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
258 | : QDialog( parent, name, modal, fl ) | 252 | : QDialog( parent, name, modal, fl ) |
259 | { | 253 | { |
260 | if ( !name ) | 254 | if ( !name ) |
261 | setName( "InputDialog" ); | 255 | setName( "InputDialog" ); |
262 | resize( 234, 50 ); | 256 | resize( 234, 50 ); |
263 | setMaximumSize( QSize( 240, 50 ) ); | 257 | setMaximumSize( QSize( 240, 50 ) ); |
264 | setCaption( tr(name ) ); | 258 | setCaption( tr(name ) ); |
265 | 259 | ||
266 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 260 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
267 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); | 261 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); |
268 | LineEdit1->setFocus(); | 262 | LineEdit1->setFocus(); |
269 | LineEdit1->setFocus(); | 263 | LineEdit1->setFocus(); |
270 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); | 264 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); |
271 | } | 265 | } |
272 | 266 | ||
273 | InputDialog::~InputDialog() { | 267 | InputDialog::~InputDialog() { |
274 | inputText = LineEdit1->text(); | 268 | inputText = LineEdit1->text(); |
275 | } | 269 | } |
276 | 270 | ||
277 | void InputDialog::setInputText(const QString &string) { | 271 | void InputDialog::setInputText(const QString &string) { |
278 | LineEdit1->setText( string); | 272 | LineEdit1->setText( string); |
279 | } | 273 | } |
280 | 274 | ||
281 | void InputDialog::returned() { | 275 | void InputDialog::returned() { |
282 | inputText = LineEdit1->text(); | 276 | inputText = LineEdit1->text(); |
283 | this->accept(); | 277 | this->accept(); |
284 | } | 278 | } |
diff --git a/noncore/apps/checkbook/opie-checkbook.control b/noncore/apps/checkbook/opie-checkbook.control index c0061e5..78f303c 100644 --- a/noncore/apps/checkbook/opie-checkbook.control +++ b/noncore/apps/checkbook/opie-checkbook.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-checkbook | 1 | Package: opie-checkbook |
2 | Files: bin/checkbook apps/Applications/checkbook.desktop pics/checkbook | 2 | Files: bin/checkbook apps/Applications/checkbook.desktop pics/checkbook |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: applications | 4 | Section: applications |
5 | Maintainer: Dan Williams <drw@handhelds.org> | 5 | Maintainer: Dan Williams <drw@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal, libopie1 | 7 | Depends: task-opie-minimal, libopie1 |
9 | Description: Checkbook keeping program. | 8 | Description: Checkbook keeping program. |
10 | The checkbook accounting program for the Opie environment. | 9 | The checkbook accounting program for the Opie environment. |
10 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/opie-console/configdialog.cpp b/noncore/apps/opie-console/configdialog.cpp index 0bc6588..53b3853 100644 --- a/noncore/apps/opie-console/configdialog.cpp +++ b/noncore/apps/opie-console/configdialog.cpp | |||
@@ -1,114 +1,114 @@ | |||
1 | #include <qdialog.h> | 1 | #include <qdialog.h> |
2 | #include <qlistview.h> | 2 | #include <qlistview.h> |
3 | 3 | ||
4 | 4 | ||
5 | #include "profile.h" | 5 | #include "profile.h" |
6 | #include "configdialog.h" | 6 | #include "configdialog.h" |
7 | #include "metafactory.h" | 7 | #include "metafactory.h" |
8 | #include "profileeditordialog.h" | 8 | #include "profileeditordialog.h" |
9 | 9 | ||
10 | class ConfigListItem : public QListViewItem { | 10 | class ConfigListItem : public QListViewItem { |
11 | public: | 11 | public: |
12 | ConfigListItem( QListView* item, const Profile& ); | 12 | ConfigListItem( QListView* item, const Profile& ); |
13 | ~ConfigListItem(); | 13 | ~ConfigListItem(); |
14 | Profile profile()const; | 14 | Profile profile()const; |
15 | 15 | ||
16 | private: | 16 | private: |
17 | Profile m_prof; | 17 | Profile m_prof; |
18 | }; | 18 | }; |
19 | ConfigListItem::ConfigListItem( QListView* item, const Profile& prof ) | 19 | ConfigListItem::ConfigListItem( QListView* item, const Profile& prof ) |
20 | : QListViewItem( item ), m_prof( prof ) | 20 | : QListViewItem( item ), m_prof( prof ) |
21 | { | 21 | { |
22 | setText(0, prof.name() ); | 22 | setText(0, prof.name() ); |
23 | } | 23 | } |
24 | ConfigListItem::~ConfigListItem() { | 24 | ConfigListItem::~ConfigListItem() { |
25 | 25 | ||
26 | } | 26 | } |
27 | Profile ConfigListItem::profile()const { | 27 | Profile ConfigListItem::profile()const { |
28 | return m_prof; | 28 | return m_prof; |
29 | } | 29 | } |
30 | 30 | ||
31 | /* Dialog */ | 31 | /* Dialog */ |
32 | 32 | ||
33 | ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa, | 33 | ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa, |
34 | QWidget* parent ) | 34 | QWidget* parent ) |
35 | : ConfigureBase( parent, 0, TRUE ), m_fact( fa ) | 35 | : ConfigureBase( parent, 0, TRUE ), m_fact( fa ) |
36 | { | 36 | { |
37 | //init(); | 37 | //init(); |
38 | { | 38 | { |
39 | Profile::ValueList::ConstIterator it; | 39 | Profile::ValueList::ConstIterator it; |
40 | for (it = lis.begin(); it != lis.end(); ++it ) { | 40 | for (it = lis.begin(); it != lis.end(); ++it ) { |
41 | new ConfigListItem( lstView, (*it) ); | 41 | new ConfigListItem( lstView, (*it) ); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | } | 44 | } |
45 | ConfigDialog::~ConfigDialog() { | 45 | ConfigDialog::~ConfigDialog() { |
46 | 46 | ||
47 | } | 47 | } |
48 | Profile::ValueList ConfigDialog::list()const { | 48 | Profile::ValueList ConfigDialog::list()const { |
49 | /* iterate over the list */ | 49 | /* iterate over the list */ |
50 | Profile::ValueList lst; | 50 | Profile::ValueList lst; |
51 | QListViewItemIterator it(lstView); | 51 | QListViewItemIterator it(lstView); |
52 | for ( ; it.current(); ++it ) { | 52 | for ( ; it.current(); ++it ) { |
53 | ConfigListItem* item = (ConfigListItem*)it.current(); | 53 | ConfigListItem* item = (ConfigListItem*)it.current(); |
54 | lst.append( item->profile() ); | 54 | lst.append( item->profile() ); |
55 | } | 55 | } |
56 | return lst; | 56 | return lst; |
57 | } | 57 | } |
58 | /* our slots */ | 58 | /* our slots */ |
59 | void ConfigDialog::slotRemove() { | 59 | void ConfigDialog::slotRemove() { |
60 | ConfigListItem* item = (ConfigListItem*)lstView->currentItem(); | 60 | ConfigListItem* item = (ConfigListItem*)lstView->currentItem(); |
61 | if (!item ) | 61 | if (!item ) |
62 | return; | 62 | return; |
63 | 63 | ||
64 | lstView->takeItem( item ); | 64 | lstView->takeItem( item ); |
65 | delete item; | 65 | delete item; |
66 | } | 66 | } |
67 | 67 | ||
68 | void ConfigDialog::slotEdit() { | 68 | void ConfigDialog::slotEdit() { |
69 | Profile p; | 69 | Profile p; |
70 | 70 | ||
71 | if(!lstView->currentItem()) return; | 71 | if(!lstView->currentItem()) return; |
72 | 72 | ||
73 | // Load profile | 73 | // Load profile |
74 | p = ((ConfigListItem*)lstView->currentItem())->profile(); | 74 | p = ((ConfigListItem*)lstView->currentItem())->profile(); |
75 | 75 | ||
76 | ProfileEditorDialog dlg(m_fact, p); | 76 | ProfileEditorDialog dlg(m_fact, p); |
77 | 77 | ||
78 | dlg.setCaption("Edit Connection Profile"); | 78 | dlg.setCaption(tr("Edit Connection Profile")); |
79 | dlg.showMaximized(); | 79 | dlg.showMaximized(); |
80 | int ret = dlg.exec(); | 80 | int ret = dlg.exec(); |
81 | 81 | ||
82 | if(ret == QDialog::Accepted) | 82 | if(ret == QDialog::Accepted) |
83 | { | 83 | { |
84 | if(lstView->currentItem()) delete lstView->currentItem(); | 84 | if(lstView->currentItem()) delete lstView->currentItem(); |
85 | 85 | ||
86 | // use dlg.terminal()! | 86 | // use dlg.terminal()! |
87 | Profile p = dlg.profile(); | 87 | Profile p = dlg.profile(); |
88 | 88 | ||
89 | new ConfigListItem(lstView, p); | 89 | new ConfigListItem(lstView, p); |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | void ConfigDialog::slotAdd() { | 94 | void ConfigDialog::slotAdd() { |
95 | ProfileEditorDialog dlg(m_fact); | 95 | ProfileEditorDialog dlg(m_fact); |
96 | 96 | ||
97 | dlg.setCaption("New Connection"); | 97 | dlg.setCaption(tr("New Connection")); |
98 | dlg.showMaximized(); | 98 | dlg.showMaximized(); |
99 | int ret = dlg.exec(); | 99 | int ret = dlg.exec(); |
100 | 100 | ||
101 | if(ret == QDialog::Accepted) | 101 | if(ret == QDialog::Accepted) |
102 | { | 102 | { |
103 | // TODO: Move into general profile save part | 103 | // TODO: Move into general profile save part |
104 | // assignments | 104 | // assignments |
105 | //QString type = dlg.term_type(); | 105 | //QString type = dlg.term_type(); |
106 | //if(type == "VT102") profile = Profile::VT102; | 106 | //if(type == "VT102") profile = Profile::VT102; |
107 | 107 | ||
108 | // get profile from editor | 108 | // get profile from editor |
109 | Profile p = dlg.profile(); | 109 | Profile p = dlg.profile(); |
110 | 110 | ||
111 | new ConfigListItem(lstView, p); | 111 | new ConfigListItem(lstView, p); |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
diff --git a/noncore/apps/opie-console/consoleconfigwidget.cpp b/noncore/apps/opie-console/consoleconfigwidget.cpp index 3f2d154..faedc58 100644 --- a/noncore/apps/opie-console/consoleconfigwidget.cpp +++ b/noncore/apps/opie-console/consoleconfigwidget.cpp | |||
@@ -1,100 +1,111 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qcombobox.h> | 3 | #include <qcombobox.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
6 | #include <qlistview.h> | 6 | #include <qlistview.h> |
7 | #include <qhbox.h> | 7 | #include <qhbox.h> |
8 | #include <qregexp.h> | 8 | #include <qregexp.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
10 | 10 | ||
11 | #include <pwd.h> | ||
12 | #include <sys/types.h> | ||
13 | |||
14 | |||
11 | #include "consoleconfigwidget.h" | 15 | #include "consoleconfigwidget.h" |
12 | 16 | ||
13 | ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent, | 17 | ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent, |
14 | const char* na ) | 18 | const char* na ) |
15 | : ProfileDialogConnectionWidget( name, parent, na ) { | 19 | : ProfileDialogConnectionWidget( name, parent, na ) { |
16 | m_lay = new QVBoxLayout( this ); | 20 | m_lay = new QVBoxLayout( this ); |
17 | QLabel *label = new QLabel(tr("Command to execute"), this); | 21 | QLabel *label = new QLabel(tr("Command to execute"), this); |
18 | m_lay->addWidget(label); | 22 | m_lay->addWidget(label); |
19 | m_cmd = new QLineEdit(this); | 23 | m_cmd = new QLineEdit(this); |
20 | m_lay->addWidget(m_cmd); | 24 | m_lay->addWidget(m_cmd); |
21 | label = new QLabel(tr("Environment Variables"), this); | 25 | label = new QLabel(tr("Environment Variables"), this); |
22 | m_lay->addWidget(label); | 26 | m_lay->addWidget(label); |
23 | m_env = new QListView(this); | 27 | m_env = new QListView(this); |
24 | m_env->addColumn(tr("Name")); | 28 | m_env->addColumn(tr("Name")); |
25 | m_env->addColumn(tr("Value")); | 29 | m_env->addColumn(tr("Value")); |
26 | m_lay->addWidget(m_env); | 30 | m_lay->addWidget(m_env); |
27 | 31 | ||
28 | QHBox *hbox = new QHBox(this); | 32 | QHBox *hbox = new QHBox(this); |
29 | label = new QLabel(tr("Name :"), hbox); | 33 | label = new QLabel(tr("Name :"), hbox); |
30 | m_name = new QLineEdit(hbox); | 34 | m_name = new QLineEdit(hbox); |
31 | m_lay->addWidget(hbox); | 35 | m_lay->addWidget(hbox); |
32 | 36 | ||
33 | hbox = new QHBox(this); | 37 | hbox = new QHBox(this); |
34 | label = new QLabel(tr("Value :"), hbox); | 38 | label = new QLabel(tr("Value :"), hbox); |
35 | m_value = new QLineEdit(hbox); | 39 | m_value = new QLineEdit(hbox); |
36 | m_lay->addWidget(hbox); | 40 | m_lay->addWidget(hbox); |
37 | 41 | ||
38 | hbox = new QHBox(this); | 42 | hbox = new QHBox(this); |
39 | hbox->setSpacing(10); | 43 | hbox->setSpacing(10); |
40 | m_remove = new QPushButton(tr("Remove"), hbox); | 44 | m_remove = new QPushButton(tr("Remove"), hbox); |
41 | connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove())); | 45 | connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove())); |
42 | m_add = new QPushButton(tr("Add"), hbox); | 46 | m_add = new QPushButton(tr("Add"), hbox); |
43 | connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd())); | 47 | connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd())); |
44 | m_lay->addWidget(hbox); | 48 | m_lay->addWidget(hbox); |
45 | } | 49 | } |
46 | 50 | ||
47 | void ConsoleConfigWidget::slotAdd() { | 51 | void ConsoleConfigWidget::slotAdd() { |
48 | if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) { | 52 | if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) { |
49 | QListViewItem *item = new QListViewItem(m_env); | 53 | QListViewItem *item = new QListViewItem(m_env); |
50 | item->setText(0, m_name->text()); | 54 | item->setText(0, m_name->text()); |
51 | item->setText(1, m_value->text()); | 55 | item->setText(1, m_value->text()); |
52 | m_env->insertItem(item); | 56 | m_env->insertItem(item); |
53 | } | 57 | } |
54 | } | 58 | } |
55 | 59 | ||
56 | void ConsoleConfigWidget::slotRemove() { | 60 | void ConsoleConfigWidget::slotRemove() { |
57 | QListViewItem *item = m_env->currentItem(); | 61 | QListViewItem *item = m_env->currentItem(); |
58 | if (item) { | 62 | if (item) { |
59 | m_env->takeItem(item); | 63 | m_env->takeItem(item); |
60 | } | 64 | } |
61 | } | 65 | } |
62 | 66 | ||
63 | ConsoleConfigWidget::~ConsoleConfigWidget() { | 67 | ConsoleConfigWidget::~ConsoleConfigWidget() { |
64 | } | 68 | } |
65 | 69 | ||
66 | void ConsoleConfigWidget::load( const Profile& prof ) { | 70 | void ConsoleConfigWidget::load( const Profile& prof ) { |
67 | /* | 71 | /* |
68 | * we will use /bin/bash as default | 72 | * default to the users default shell |
69 | * but will fallback in MyPty to /bin/sh | ||
70 | * if necessary | ||
71 | */ | 73 | */ |
72 | m_cmd->setText(prof.readEntry("Command", "/bin/bash")); | 74 | struct passwd *ent = 0; |
75 | char *shell = "/bin/sh"; | ||
76 | |||
77 | while ( (ent = getpwent()) != 0 ) { | ||
78 | if (ent->pw_shell != "") { | ||
79 | shell = ent->pw_shell; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | m_cmd->setText(prof.readEntry("Command", shell )); | ||
73 | int envcount = prof.readNumEntry("EnvVars", 0); | 84 | int envcount = prof.readNumEntry("EnvVars", 0); |
74 | for (int i=0; i<envcount; i++) { | 85 | for (int i=0; i<envcount; i++) { |
75 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); | 86 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); |
76 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); | 87 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); |
77 | if (!(name.isEmpty() || value.isEmpty())) { | 88 | if (!(name.isEmpty() || value.isEmpty())) { |
78 | QListViewItem *item = new QListViewItem(m_env); | 89 | QListViewItem *item = new QListViewItem(m_env); |
79 | item->setText(0, name); | 90 | item->setText(0, name); |
80 | item->setText(1, value); | 91 | item->setText(1, value); |
81 | m_env->insertItem(item); | 92 | m_env->insertItem(item); |
82 | } | 93 | } |
83 | } | 94 | } |
84 | } | 95 | } |
85 | 96 | ||
86 | void ConsoleConfigWidget::save( Profile& prof ) { | 97 | void ConsoleConfigWidget::save( Profile& prof ) { |
87 | prof.writeEntry( "Command", m_cmd->text()); | 98 | prof.writeEntry( "Command", m_cmd->text()); |
88 | QListViewItem *item = m_env->firstChild(); | 99 | QListViewItem *item = m_env->firstChild(); |
89 | int counter = 0; | 100 | int counter = 0; |
90 | while (item) { | 101 | while (item) { |
91 | QString name = item->text(0); | 102 | QString name = item->text(0); |
92 | QString value = item->text(1); | 103 | QString value = item->text(1); |
93 | prof.writeEntry("Env_Name_" + QString::number(counter), name); | 104 | prof.writeEntry("Env_Name_" + QString::number(counter), name); |
94 | prof.writeEntry("Env_Value_" + QString::number(counter), value); | 105 | prof.writeEntry("Env_Value_" + QString::number(counter), value); |
95 | item = item->nextSibling(); | 106 | item = item->nextSibling(); |
96 | counter++; | 107 | counter++; |
97 | } | 108 | } |
98 | prof.writeEntry("EnvVars", QString::number(counter)); | 109 | prof.writeEntry("EnvVars", QString::number(counter)); |
99 | } | 110 | } |
100 | 111 | ||
diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp index b17f8e8..228db57 100644 --- a/noncore/apps/opie-console/main.cpp +++ b/noncore/apps/opie-console/main.cpp | |||
@@ -1,114 +1,111 @@ | |||
1 | #include <sys/types.h> | 1 | #include <sys/types.h> |
2 | 2 | ||
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include <signal.h> | 5 | #include <signal.h> |
6 | 6 | ||
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | 8 | ||
9 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
10 | 10 | ||
11 | #include "mainwindow.h" | 11 | #include "mainwindow.h" |
12 | 12 | ||
13 | //#define FSCKED_DISTRIBUTION 1 | 13 | //#define FSCKED_DISTRIBUTION 1 |
14 | #ifdef FSCKED_DISTRIBUTION | 14 | #ifdef FSCKED_DISTRIBUTION |
15 | /* | 15 | /* |
16 | * The Zaurus rom | 16 | * The Zaurus rom |
17 | */ | 17 | */ |
18 | class FixIt { | 18 | class FixIt { |
19 | public: | 19 | public: |
20 | FixIt(); | 20 | FixIt(); |
21 | ~FixIt(); | 21 | ~FixIt(); |
22 | void fixIt(); | 22 | void fixIt(); |
23 | /* no real interested in implementing it */ | 23 | /* no real interested in implementing it */ |
24 | void breakIt() { | 24 | void breakIt() { |
25 | 25 | ||
26 | }; | 26 | }; |
27 | char* m_file; | 27 | char* m_file; |
28 | }; | 28 | }; |
29 | 29 | ||
30 | FixIt::FixIt() { | 30 | FixIt::FixIt() { |
31 | /* the new inittab */ | 31 | /* the new inittab */ |
32 | m_file = "#\n# /etc/inittab | 32 | m_file = "#\n# /etc/inittab" |
33 | # | 33 | "#" |
34 | 34 | "" | |
35 | # 0 - halt (Do NOT set initdefault to this) | 35 | "# 0 - halt (Do NOT set initdefault to this)" |
36 | # 1 - Single user mode | 36 | "# 1 - Single user mode" |
37 | # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) | 37 | "# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)" |
38 | # 3 - Full multiuser mode | 38 | "# 3 - Full multiuser mode" |
39 | # 4 - JavaVM(Intent) developer mode | 39 | "# 4 - JavaVM(Intent) developer mode" |
40 | # 5 - JavaVM(Intent) | 40 | "# 5 - JavaVM(Intent)" |
41 | # 6 - reboot (Do NOT set initdefault to this) | 41 | "# 6 - reboot (Do NOT set initdefault to this)" |
42 | # | 42 | "#" |
43 | id:5:initdefault: | 43 | "id:5:initdefault:" |
44 | 44 | "" | |
45 | # Specify things to do when starting | 45 | "# Specify things to do when starting" |
46 | si::sysinit:/etc/rc.d/rc.sysinit | 46 | "si::sysinit:/etc/rc.d/rc.sysinit" |
47 | 47 | "" | |
48 | l0:0:wait:/root/etc/rc.d/rc 0 | 48 | "l0:0:wait:/root/etc/rc.d/rc 0" |
49 | l1:1:wait:/etc/rc.d/rc 1 | 49 | "l1:1:wait:/etc/rc.d/rc 1" |
50 | l2:2:wait:/etc/rc.d/rc 2 | 50 | "l2:2:wait:/etc/rc.d/rc 2" |
51 | l3:3:wait:/etc/rc.d/rc 3 | 51 | "l3:3:wait:/etc/rc.d/rc 3" |
52 | l4:4:wait:/etc/rc.d/rc 4 | 52 | "l4:4:wait:/etc/rc.d/rc 4" |
53 | l5:5:wait:/etc/rc.d/rc 5 | 53 | "l5:5:wait:/etc/rc.d/rc 5" |
54 | l6:6:wait:/root/etc/rc.d/rc 6 | 54 | "l6:6:wait:/root/etc/rc.d/rc 6" |
55 | 55 | "" | |
56 | # Specify things to do before rebooting | 56 | "# Specify things to do before rebooting" |
57 | um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1 | 57 | "um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1" |
58 | sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1 | 58 | "sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1" |
59 | 59 | "" | |
60 | # Specify program to run on ttyS0 | 60 | "# Specify program to run on ttyS0" |
61 | s0:24:respawn:/sbin/getty 9600 ttyS0 | 61 | "s0:24:respawn:/sbin/getty 9600 ttyS0" |
62 | #pd:5:respawn:/etc/sync/serialctl | 62 | "#pd:5:respawn:/etc/sync/serialctl" |
63 | 63 | "" | |
64 | # Specify program to run on tty1 | 64 | "# Specify program to run on tty1" |
65 | 1:2:respawn:/sbin/getty 9600 tty1 | 65 | "1:2:respawn:/sbin/getty 9600 tty1" |
66 | ln:345:respawn:survive -l 6 /sbin/launch | 66 | "ln:345:respawn:survive -l 6 /sbin/launch" |
67 | #qt:5:respawn:/sbin/qt | 67 | "#qt:5:respawn:/sbin/qt" |
68 | 68 | "" | |
69 | # collie sp. | 69 | "# collie sp." |
70 | sy::respawn:/sbin/shsync\n"; | 70 | "sy::respawn:/sbin/shsync\n"; |
71 | |||
72 | |||
73 | } | 71 | } |
74 | FixIt::~FixIt() { | 72 | FixIt::~FixIt() { |
75 | } | 73 | } |
76 | /* | 74 | /* |
77 | * the retail Zaurus is broken in many ways | 75 | * the retail Zaurus is broken in many ways |
78 | * one is that pppd is listening on our port... | 76 | * one is that pppd is listening on our port... |
79 | * we've to stop it from that and then do kill(SIGHUP,1); | 77 | * we've to stop it from that and then do kill(SIGHUP,1); |
80 | */ | 78 | */ |
81 | void FixIt::fixIt() { | 79 | void FixIt::fixIt() { |
82 | ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" ); | 80 | ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" ); |
83 | QFile file( "/etc/inittab" ); | 81 | QFile file( "/etc/inittab" ); |
84 | if ( file.open(IO_WriteOnly | IO_Raw ) ) { | 82 | if ( file.open(IO_WriteOnly | IO_Raw ) ) { |
85 | file.writeBlock(m_file,strlen(m_file) ); | 83 | file.writeBlock(m_file,strlen(m_file) ); |
86 | } | 84 | } |
87 | file.close(); | 85 | file.close(); |
88 | ::kill( SIGHUP, 1 ); | 86 | ::kill( SIGHUP, 1 ); |
89 | } | 87 | } |
90 | #endif | 88 | #endif |
91 | 89 | ||
92 | |||
93 | int main(int argc, char **argv) { | 90 | int main(int argc, char **argv) { |
94 | // too bad this gives us trouble the taskbar... argv[0]="embeddedkonsole"; | 91 | // too bad this gives us trouble the taskbar... argv[0]="embeddedkonsole"; |
95 | QPEApplication app( argc, argv ); | 92 | QPEApplication app( argc, argv ); |
96 | 93 | ||
97 | #ifdef FSCKED_DISTRIBUTION | 94 | #ifdef FSCKED_DISTRIBUTION |
98 | qWarning("fscked"); | 95 | qWarning("fscked"); |
99 | FixIt it; | 96 | FixIt it; |
100 | it.fixIt(); | 97 | it.fixIt(); |
101 | #endif | 98 | #endif |
102 | 99 | ||
103 | MainWindow mw; | 100 | MainWindow mw; |
104 | mw.setCaption(QObject::tr("Opie Console") ); | 101 | mw.setCaption(QObject::tr("Opie Console") ); |
105 | app.showMainWidget( &mw ); | 102 | app.showMainWidget( &mw ); |
106 | 103 | ||
107 | int ap = app.exec(); | 104 | int ap = app.exec(); |
108 | 105 | ||
109 | #ifdef FSCKED_DISTRIBUTION | 106 | #ifdef FSCKED_DISTRIBUTION |
110 | /* should add a signal handler too */ | 107 | /* should add a signal handler too */ |
111 | it.breakIt(); | 108 | it.breakIt(); |
112 | #endif | 109 | #endif |
113 | return ap; | 110 | return ap; |
114 | } | 111 | } |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index c48116d..3c9603c 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,738 +1,739 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | #include <qfileinfo.h> | 11 | #include <qfileinfo.h> |
12 | #include <qtextstream.h> | 12 | #include <qtextstream.h> |
13 | 13 | ||
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | #include <qpe/filemanager.h> | 16 | #include <qpe/filemanager.h> |
17 | #include <qpe/mimetype.h> | 17 | #include <qpe/mimetype.h> |
18 | 18 | ||
19 | #include <opie/ofiledialog.h> | 19 | #include <opie/ofiledialog.h> |
20 | 20 | ||
21 | #include "TEmulation.h" | 21 | #include "TEmulation.h" |
22 | #include "keytrans.h" | 22 | #include "keytrans.h" |
23 | #include "profileeditordialog.h" | 23 | #include "profileeditordialog.h" |
24 | #include "configdialog.h" | 24 | #include "configdialog.h" |
25 | #include "default.h" | 25 | #include "default.h" |
26 | #include "metafactory.h" | 26 | #include "metafactory.h" |
27 | #include "profile.h" | 27 | #include "profile.h" |
28 | #include "profilemanager.h" | 28 | #include "profilemanager.h" |
29 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "tabwidget.h" | 30 | #include "tabwidget.h" |
31 | #include "transferdialog.h" | 31 | #include "transferdialog.h" |
32 | #include "function_keyboard.h" | 32 | #include "function_keyboard.h" |
33 | #include "emulation_handler.h" | 33 | #include "emulation_handler.h" |
34 | #include "script.h" | 34 | #include "script.h" |
35 | 35 | ||
36 | 36 | ||
37 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 37 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
38 | KeyTrans::loadAll(); | 38 | KeyTrans::loadAll(); |
39 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 39 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
40 | KeyTrans* s = KeyTrans::find(i ); | 40 | KeyTrans* s = KeyTrans::find(i ); |
41 | assert( s ); | 41 | assert( s ); |
42 | } | 42 | } |
43 | m_factory = new MetaFactory(); | 43 | m_factory = new MetaFactory(); |
44 | Default def(m_factory); | 44 | Default def(m_factory); |
45 | m_sessions.setAutoDelete( TRUE ); | 45 | m_sessions.setAutoDelete( TRUE ); |
46 | m_curSession = 0; | 46 | m_curSession = 0; |
47 | m_manager = new ProfileManager( m_factory ); | 47 | m_manager = new ProfileManager( m_factory ); |
48 | m_manager->load(); | 48 | m_manager->load(); |
49 | m_scriptsData.setAutoDelete(TRUE); | 49 | m_scriptsData.setAutoDelete(TRUE); |
50 | 50 | ||
51 | initUI(); | 51 | initUI(); |
52 | populateProfiles(); | 52 | populateProfiles(); |
53 | populateScripts(); | 53 | populateScripts(); |
54 | } | 54 | } |
55 | 55 | ||
56 | void MainWindow::initUI() { | 56 | void MainWindow::initUI() { |
57 | 57 | ||
58 | setToolBarsMovable( FALSE ); | 58 | setToolBarsMovable( FALSE ); |
59 | 59 | ||
60 | /* tool bar for the menu */ | 60 | /* tool bar for the menu */ |
61 | m_tool = new QToolBar( this ); | 61 | m_tool = new QToolBar( this ); |
62 | m_tool->setHorizontalStretchable( TRUE ); | 62 | m_tool->setHorizontalStretchable( TRUE ); |
63 | 63 | ||
64 | m_bar = new QMenuBar( m_tool ); | 64 | m_bar = new QMenuBar( m_tool ); |
65 | m_console = new QPopupMenu( this ); | 65 | m_console = new QPopupMenu( this ); |
66 | m_scripts = new QPopupMenu( this ); | 66 | m_scripts = new QPopupMenu( this ); |
67 | m_sessionsPop= new QPopupMenu( this ); | 67 | m_sessionsPop= new QPopupMenu( this ); |
68 | m_scriptsPop = new QPopupMenu( this ); | 68 | m_scriptsPop = new QPopupMenu( this ); |
69 | 69 | ||
70 | /* add a toolbar for icons */ | 70 | /* add a toolbar for icons */ |
71 | m_icons = new QToolBar(this); | 71 | m_icons = new QToolBar(this); |
72 | 72 | ||
73 | /* | 73 | /* |
74 | * the settings action | 74 | * the settings action |
75 | */ | 75 | */ |
76 | m_setProfiles = new QAction(tr("Configure Profiles"), | 76 | m_setProfiles = new QAction(tr("Configure Profiles"), |
77 | Resource::loadPixmap( "SettingsIcon" ), | 77 | Resource::loadPixmap( "SettingsIcon" ), |
78 | QString::null, 0, this, 0); | 78 | QString::null, 0, this, 0); |
79 | m_setProfiles->addTo( m_console ); | 79 | m_setProfiles->addTo( m_console ); |
80 | connect( m_setProfiles, SIGNAL(activated() ), | 80 | connect( m_setProfiles, SIGNAL(activated() ), |
81 | this, SLOT(slotConfigure() ) ); | 81 | this, SLOT(slotConfigure() ) ); |
82 | 82 | ||
83 | m_console->insertSeparator(); | 83 | m_console->insertSeparator(); |
84 | /* | 84 | /* |
85 | * new Action for new sessions | 85 | * new Action for new sessions |
86 | */ | 86 | */ |
87 | QAction* newCon = new QAction(tr("New Connection"), | 87 | QAction* newCon = new QAction(tr("New Profile"), |
88 | Resource::loadPixmap( "new" ), | 88 | Resource::loadPixmap( "new" ), |
89 | QString::null, 0, this, 0); | 89 | QString::null, 0, this, 0); |
90 | newCon->addTo( m_console ); | 90 | newCon->addTo( m_console ); |
91 | connect( newCon, SIGNAL(activated() ), | 91 | connect( newCon, SIGNAL(activated() ), |
92 | this, SLOT(slotNew() ) ); | 92 | this, SLOT(slotNew() ) ); |
93 | 93 | ||
94 | m_console->insertSeparator(); | 94 | m_console->insertSeparator(); |
95 | 95 | ||
96 | QAction *saveCon = new QAction(tr("Save Connection"), | 96 | QAction *saveCon = new QAction( tr("Save Profile" ), |
97 | Resource::loadPixmap( "save" ), QString::null, | 97 | Resource::loadPixmap( "save" ), QString::null, |
98 | 0, this, 0 ); | 98 | 0, this, 0 ); |
99 | saveCon->addTo( m_console ); | 99 | saveCon->addTo( m_console ); |
100 | connect( saveCon, SIGNAL(activated() ), | 100 | connect( saveCon, SIGNAL(activated() ), |
101 | this, SLOT(slotSaveSession() ) ); | 101 | this, SLOT(slotSaveSession() ) ); |
102 | m_console->insertSeparator(); | 102 | m_console->insertSeparator(); |
103 | 103 | ||
104 | /* | 104 | /* |
105 | * connect action | 105 | * connect action |
106 | */ | 106 | */ |
107 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), | 107 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), |
108 | QString::null, 0, this, 0 ); | 108 | QString::null, 0, this, 0 ); |
109 | m_connect->addTo( m_console ); | 109 | m_connect->addTo( m_console ); |
110 | connect(m_connect, SIGNAL(activated() ), | 110 | connect(m_connect, SIGNAL(activated() ), |
111 | this, SLOT(slotConnect() ) ); | 111 | this, SLOT(slotConnect() ) ); |
112 | 112 | ||
113 | /* | 113 | /* |
114 | * disconnect action | 114 | * disconnect action |
115 | */ | 115 | */ |
116 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), | 116 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), |
117 | QString::null, 0, this, 0 ); | 117 | QString::null, 0, this, 0 ); |
118 | m_disconnect->addTo( m_console ); | 118 | m_disconnect->addTo( m_console ); |
119 | connect(m_disconnect, SIGNAL(activated() ), | 119 | connect(m_disconnect, SIGNAL(activated() ), |
120 | this, SLOT(slotDisconnect() ) ); | 120 | this, SLOT(slotDisconnect() ) ); |
121 | 121 | ||
122 | m_console->insertSeparator(); | 122 | m_console->insertSeparator(); |
123 | 123 | ||
124 | 124 | ||
125 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); | 125 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); |
126 | m_quickLaunch->addTo( m_icons ); | 126 | m_quickLaunch->addTo( m_icons ); |
127 | connect( m_quickLaunch, SIGNAL( activated() ), | 127 | connect( m_quickLaunch, SIGNAL( activated() ), |
128 | this, SLOT( slotQuickLaunch() ) ); | 128 | this, SLOT( slotQuickLaunch() ) ); |
129 | 129 | ||
130 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); | 130 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); |
131 | 131 | ||
132 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 132 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
133 | 0, this, 0 ); | 133 | 0, this, 0 ); |
134 | m_transfer->addTo( m_console ); | 134 | m_transfer->addTo( m_console ); |
135 | connect(m_transfer, SIGNAL(activated() ), | 135 | connect(m_transfer, SIGNAL(activated() ), |
136 | this, SLOT(slotTransfer() ) ); | 136 | this, SLOT(slotTransfer() ) ); |
137 | 137 | ||
138 | 138 | ||
139 | 139 | ||
140 | /* | 140 | /* |
141 | * immediate change of line wrap policy | 141 | * immediate change of line wrap policy |
142 | */ | 142 | */ |
143 | m_isWrapped = false; | 143 | m_isWrapped = false; |
144 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); | 144 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); |
145 | m_wrap->addTo( m_console ); | 145 | m_wrap->addTo( m_console ); |
146 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); | 146 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); |
147 | 147 | ||
148 | /* | 148 | /* |
149 | * fullscreen | 149 | * fullscreen |
150 | */ | 150 | */ |
151 | m_isFullscreen = false; | 151 | m_isFullscreen = false; |
152 | 152 | ||
153 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 153 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
154 | , QString::null, 0, this, 0); | 154 | , QString::null, 0, this, 0); |
155 | m_fullscreen->addTo( m_console ); | 155 | m_fullscreen->addTo( m_console ); |
156 | connect( m_fullscreen, SIGNAL( activated() ), | 156 | connect( m_fullscreen, SIGNAL( activated() ), |
157 | this, SLOT( slotFullscreen() ) ); | 157 | this, SLOT( slotFullscreen() ) ); |
158 | 158 | ||
159 | m_console->insertSeparator(); | 159 | m_console->insertSeparator(); |
160 | 160 | ||
161 | QAction *a = new QAction(); | 161 | QAction *a = new QAction(); |
162 | a->setText( tr("Save history") ); | 162 | a->setText( tr("Save history") ); |
163 | a->addTo( m_console ); | 163 | a->addTo( m_console ); |
164 | connect(a, SIGNAL(activated() ), | 164 | connect(a, SIGNAL(activated() ), |
165 | this, SLOT(slotSaveHistory() ) ); | 165 | this, SLOT(slotSaveHistory() ) ); |
166 | /* | 166 | /* |
167 | * terminate action | 167 | * terminate action |
168 | */ | 168 | */ |
169 | m_terminate = new QAction(); | 169 | m_terminate = new QAction(); |
170 | m_terminate->setText( tr("Terminate") ); | 170 | m_terminate->setText( tr("Terminate") ); |
171 | m_terminate->addTo( m_console ); | 171 | m_terminate->addTo( m_console ); |
172 | connect(m_terminate, SIGNAL(activated() ), | 172 | connect(m_terminate, SIGNAL(activated() ), |
173 | this, SLOT(slotTerminate() ) ); | 173 | this, SLOT(slotTerminate() ) ); |
174 | 174 | ||
175 | m_closewindow = new QAction(); | 175 | m_closewindow = new QAction(); |
176 | m_closewindow->setText( tr("Close Window") ); | 176 | m_closewindow->setText( tr("Close Window") ); |
177 | m_closewindow->addTo( m_console ); | 177 | m_closewindow->addTo( m_console ); |
178 | connect( m_closewindow, SIGNAL(activated() ), | 178 | connect( m_closewindow, SIGNAL(activated() ), |
179 | this, SLOT(slotClose() ) ); | 179 | this, SLOT(slotClose() ) ); |
180 | 180 | ||
181 | 181 | ||
182 | /* | 182 | /* |
183 | * script actions | 183 | * script actions |
184 | */ | 184 | */ |
185 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 185 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
186 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 186 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
187 | 187 | ||
188 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 188 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
189 | m_recordScript->addTo(m_scripts); | 189 | m_recordScript->addTo(m_scripts); |
190 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 190 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
191 | 191 | ||
192 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 192 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
193 | m_saveScript->addTo(m_scripts); | 193 | m_saveScript->addTo(m_scripts); |
194 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 194 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
195 | 195 | ||
196 | 196 | ||
197 | /* | 197 | /* |
198 | * action that open/closes the keyboard | 198 | * action that open/closes the keyboard |
199 | */ | 199 | */ |
200 | m_openKeys = new QAction (tr("Open Keyboard..."), | 200 | m_openKeys = new QAction (tr("Open Keyboard..."), |
201 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 201 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
202 | QString::null, 0, this, 0); | 202 | QString::null, 0, this, 0); |
203 | m_openKeys->setToggleAction(true); | 203 | m_openKeys->setToggleAction(true); |
204 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 204 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
205 | 205 | ||
206 | /* insert the submenu */ | 206 | /* insert the submenu */ |
207 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 207 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
208 | -1, 0); | 208 | -1, 0); |
209 | 209 | ||
210 | /* insert the connection menu */ | 210 | /* insert the connection menu */ |
211 | m_bar->insertItem( tr("Connection"), m_console ); | 211 | m_bar->insertItem( tr("Connection"), m_console ); |
212 | 212 | ||
213 | /* the scripts menu */ | 213 | /* the scripts menu */ |
214 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 214 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
215 | 215 | ||
216 | /* and the keyboard */ | 216 | /* and the keyboard */ |
217 | m_keyBar = new QToolBar(this); | 217 | m_keyBar = new QToolBar(this); |
218 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 218 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
219 | m_keyBar->setHorizontalStretchable( TRUE ); | 219 | m_keyBar->setHorizontalStretchable( TRUE ); |
220 | m_keyBar->hide(); | 220 | m_keyBar->hide(); |
221 | 221 | ||
222 | m_kb = new FunctionKeyboard(m_keyBar); | 222 | m_kb = new FunctionKeyboard(m_keyBar); |
223 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 223 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
224 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 224 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
225 | 225 | ||
226 | 226 | ||
227 | a = new QAction(tr("Copy"), | 227 | a = new QAction(tr("Copy"), |
228 | Resource::loadPixmap("copy"), QString::null, | 228 | Resource::loadPixmap("copy"), QString::null, |
229 | 0, this, 0 ); | 229 | 0, this, 0 ); |
230 | //a->addTo( m_icons ); | 230 | //a->addTo( m_icons ); |
231 | connect( a, SIGNAL(activated() ), | 231 | connect( a, SIGNAL(activated() ), |
232 | this, SLOT(slotCopy() ) ); | 232 | this, SLOT(slotCopy() ) ); |
233 | 233 | ||
234 | QAction *paste = new QAction(tr("Paste"), | 234 | QAction *paste = new QAction(tr("Paste"), |
235 | Resource::loadPixmap("paste"), QString::null, | 235 | Resource::loadPixmap("paste"), QString::null, |
236 | 0, this, 0 ); | 236 | 0, this, 0 ); |
237 | connect( paste, SIGNAL(activated() ), | 237 | connect( paste, SIGNAL(activated() ), |
238 | this, SLOT(slotPaste() ) ); | 238 | this, SLOT(slotPaste() ) ); |
239 | 239 | ||
240 | 240 | ||
241 | newCon->addTo( m_icons ); | 241 | newCon->addTo( m_icons ); |
242 | //m_setProfiles->addTo( m_icons ); | 242 | //m_setProfiles->addTo( m_icons ); |
243 | paste->addTo( m_icons ); | 243 | paste->addTo( m_icons ); |
244 | m_openKeys->addTo(m_icons); | 244 | m_openKeys->addTo(m_icons); |
245 | m_fullscreen->addTo( m_icons ); | 245 | m_fullscreen->addTo( m_icons ); |
246 | 246 | ||
247 | m_connect->setEnabled( false ); | 247 | m_connect->setEnabled( false ); |
248 | m_disconnect->setEnabled( false ); | 248 | m_disconnect->setEnabled( false ); |
249 | m_terminate->setEnabled( false ); | 249 | m_terminate->setEnabled( false ); |
250 | m_transfer->setEnabled( false ); | 250 | m_transfer->setEnabled( false ); |
251 | m_scripts->setItemEnabled(m_runScript_id, false); | 251 | m_scripts->setItemEnabled(m_runScript_id, false); |
252 | m_recordScript->setEnabled( false ); | 252 | m_recordScript->setEnabled( false ); |
253 | m_saveScript->setEnabled( false ); | 253 | m_saveScript->setEnabled( false ); |
254 | m_fullscreen->setEnabled( false ); | 254 | m_fullscreen->setEnabled( false ); |
255 | m_closewindow->setEnabled( false ); | 255 | m_closewindow->setEnabled( false ); |
256 | m_wrap->setEnabled( false ); | 256 | m_wrap->setEnabled( false ); |
257 | 257 | ||
258 | /* | 258 | /* |
259 | * connect to the menu activation | 259 | * connect to the menu activation |
260 | */ | 260 | */ |
261 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 261 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
262 | this, SLOT(slotProfile( int ) ) ); | 262 | this, SLOT(slotProfile( int ) ) ); |
263 | 263 | ||
264 | m_consoleWindow = new TabWidget( this, "blah"); | 264 | m_consoleWindow = new TabWidget( this, "blah"); |
265 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 265 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
266 | this, SLOT(slotSessionChanged(Session*) ) ); | 266 | this, SLOT(slotSessionChanged(Session*) ) ); |
267 | setCentralWidget( m_consoleWindow ); | 267 | setCentralWidget( m_consoleWindow ); |
268 | 268 | ||
269 | slotQuickLaunch(); | 269 | slotQuickLaunch(); |
270 | } | 270 | } |
271 | 271 | ||
272 | ProfileManager* MainWindow::manager() { | 272 | ProfileManager* MainWindow::manager() { |
273 | return m_manager; | 273 | return m_manager; |
274 | } | 274 | } |
275 | TabWidget* MainWindow::tabWidget() { | 275 | TabWidget* MainWindow::tabWidget() { |
276 | return m_consoleWindow; | 276 | return m_consoleWindow; |
277 | } | 277 | } |
278 | void MainWindow::populateProfiles() { | 278 | void MainWindow::populateProfiles() { |
279 | m_sessionsPop->clear(); | 279 | m_sessionsPop->clear(); |
280 | Profile::ValueList list = manager()->all(); | 280 | Profile::ValueList list = manager()->all(); |
281 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 281 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
282 | m_sessionsPop->insertItem( (*it).name() ); | 282 | m_sessionsPop->insertItem( (*it).name() ); |
283 | } | 283 | } |
284 | 284 | ||
285 | } | 285 | } |
286 | 286 | ||
287 | void MainWindow::populateScripts() { | 287 | void MainWindow::populateScripts() { |
288 | m_scriptsPop->clear(); | 288 | m_scriptsPop->clear(); |
289 | m_scriptsData.clear(); | 289 | m_scriptsData.clear(); |
290 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 290 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
291 | QListIterator<DocLnk> dit(files.children()); | 291 | QListIterator<DocLnk> dit(files.children()); |
292 | for (; dit.current(); ++dit) { | 292 | for (; dit.current(); ++dit) { |
293 | if (*dit && (*dit)->name().length()>0) { | 293 | if (*dit && (*dit)->name().length()>0) { |
294 | QFileInfo info((*dit)->file()); | 294 | QFileInfo info((*dit)->file()); |
295 | if (info.extension(false) == "script") { | 295 | if (info.extension(false) == "script") { |
296 | m_scriptsData.append(new DocLnk(**dit)); | 296 | m_scriptsData.append(new DocLnk(**dit)); |
297 | m_scriptsPop->insertItem((*dit)->name()); | 297 | m_scriptsPop->insertItem((*dit)->name()); |
298 | } | 298 | } |
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | } | 302 | } |
303 | 303 | ||
304 | MainWindow::~MainWindow() { | 304 | MainWindow::~MainWindow() { |
305 | delete m_factory; | 305 | delete m_factory; |
306 | manager()->save(); | 306 | manager()->save(); |
307 | } | 307 | } |
308 | 308 | ||
309 | MetaFactory* MainWindow::factory() { | 309 | MetaFactory* MainWindow::factory() { |
310 | return m_factory; | 310 | return m_factory; |
311 | } | 311 | } |
312 | 312 | ||
313 | Session* MainWindow::currentSession() { | 313 | Session* MainWindow::currentSession() { |
314 | return m_curSession; | 314 | return m_curSession; |
315 | } | 315 | } |
316 | 316 | ||
317 | QList<Session> MainWindow::sessions() { | 317 | QList<Session> MainWindow::sessions() { |
318 | return m_sessions; | 318 | return m_sessions; |
319 | } | 319 | } |
320 | 320 | ||
321 | void MainWindow::slotNew() { | 321 | void MainWindow::slotNew() { |
322 | ProfileEditorDialog dlg(factory() ); | 322 | ProfileEditorDialog dlg(factory() ); |
323 | dlg.showMaximized(); | 323 | dlg.showMaximized(); |
324 | dlg.setCaption( tr("New Connection") ); | 324 | dlg.setCaption( tr("New Connection") ); |
325 | int ret = dlg.exec(); | 325 | int ret = dlg.exec(); |
326 | 326 | ||
327 | if ( ret == QDialog::Accepted ) { | 327 | if ( ret == QDialog::Accepted ) { |
328 | create( dlg.profile() ); | 328 | create( dlg.profile() ); |
329 | } | 329 | } |
330 | } | 330 | } |
331 | 331 | ||
332 | void MainWindow::slotRecordScript() { | 332 | void MainWindow::slotRecordScript() { |
333 | if (currentSession()) { | 333 | if (currentSession()) { |
334 | currentSession()->emulationHandler()->startRecording(); | 334 | currentSession()->emulationHandler()->startRecording(); |
335 | m_saveScript->setEnabled(true); | 335 | m_saveScript->setEnabled(true); |
336 | m_recordScript->setEnabled(false); | 336 | m_recordScript->setEnabled(false); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | void MainWindow::slotSaveScript() { | 340 | void MainWindow::slotSaveScript() { |
341 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 341 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
342 | QMap<QString, QStringList> map; | 342 | QMap<QString, QStringList> map; |
343 | QStringList text; | 343 | QStringList text; |
344 | text << "text/plain"; | 344 | text << "text/plain"; |
345 | map.insert(tr("Script"), text ); | 345 | map.insert(tr("Script"), text ); |
346 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 346 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
347 | if (!filename.isEmpty()) { | 347 | if (!filename.isEmpty()) { |
348 | QFileInfo info(filename); | 348 | QFileInfo info(filename); |
349 | if (info.extension(FALSE) != "script") | 349 | if (info.extension(FALSE) != "script") |
350 | filename += ".script"; | 350 | filename += ".script"; |
351 | DocLnk nf; | 351 | DocLnk nf; |
352 | nf.setType("text/plain"); | 352 | nf.setType("text/plain"); |
353 | nf.setFile(filename); | 353 | nf.setFile(filename); |
354 | nf.setName(info.fileName()); | 354 | nf.setName(info.fileName()); |
355 | FileManager fm; | 355 | FileManager fm; |
356 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 356 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
357 | currentSession()->emulationHandler()->clearScript(); | 357 | currentSession()->emulationHandler()->clearScript(); |
358 | m_saveScript->setEnabled(false); | 358 | m_saveScript->setEnabled(false); |
359 | m_recordScript->setEnabled(true); | 359 | m_recordScript->setEnabled(true); |
360 | populateScripts(); | 360 | populateScripts(); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | void MainWindow::slotRunScript(int id) { | 365 | void MainWindow::slotRunScript(int id) { |
366 | if (currentSession()) { | 366 | if (currentSession()) { |
367 | int index = m_scriptsPop->indexOf(id); | 367 | int index = m_scriptsPop->indexOf(id); |
368 | DocLnk *lnk = m_scriptsData.at(index); | 368 | DocLnk *lnk = m_scriptsData.at(index); |
369 | QString filePath = lnk->file(); | 369 | QString filePath = lnk->file(); |
370 | Script script(filePath); | 370 | Script script(filePath); |
371 | currentSession()->emulationHandler()->runScript(&script); | 371 | currentSession()->emulationHandler()->runScript(&script); |
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | void MainWindow::slotConnect() { | 375 | void MainWindow::slotConnect() { |
376 | if ( currentSession() ) { | 376 | if ( currentSession() ) { |
377 | bool ret = currentSession()->layer()->open(); | 377 | bool ret = currentSession()->layer()->open(); |
378 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 378 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
379 | QObject::tr("Failed"), | 379 | QObject::tr("Failed"), |
380 | QObject::tr("Connecting failed for this session.")); | 380 | QObject::tr("Connecting failed for this session.")); |
381 | else { | 381 | else { |
382 | m_connect->setEnabled( false ); | 382 | m_connect->setEnabled( false ); |
383 | m_disconnect->setEnabled( true ); | 383 | m_disconnect->setEnabled( true ); |
384 | 384 | ||
385 | // if it does not support file transfer, disable the menu entry | 385 | // if it does not support file transfer, disable the menu entry |
386 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 386 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
387 | m_transfer->setEnabled( false ); | 387 | m_transfer->setEnabled( false ); |
388 | } else { | 388 | } else { |
389 | m_transfer->setEnabled( true ); | 389 | m_transfer->setEnabled( true ); |
390 | } | 390 | } |
391 | 391 | ||
392 | m_recordScript->setEnabled( true ); | 392 | m_recordScript->setEnabled( true ); |
393 | m_scripts->setItemEnabled(m_runScript_id, true); | 393 | m_scripts->setItemEnabled(m_runScript_id, true); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | void MainWindow::slotDisconnect() { | 398 | void MainWindow::slotDisconnect() { |
399 | if ( currentSession() ) { | 399 | if ( currentSession() ) { |
400 | currentSession()->layer()->close(); | 400 | currentSession()->layer()->close(); |
401 | m_connect->setEnabled( true ); | 401 | m_connect->setEnabled( true ); |
402 | m_disconnect->setEnabled( false ); | 402 | m_disconnect->setEnabled( false ); |
403 | m_transfer->setEnabled( false ); | 403 | m_transfer->setEnabled( false ); |
404 | m_recordScript->setEnabled( false); | 404 | m_recordScript->setEnabled( false); |
405 | m_saveScript->setEnabled( false ); | 405 | m_saveScript->setEnabled( false ); |
406 | m_scripts->setItemEnabled(m_runScript_id, false); | 406 | m_scripts->setItemEnabled(m_runScript_id, false); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | 409 | ||
410 | void MainWindow::slotTerminate() { | 410 | void MainWindow::slotTerminate() { |
411 | if ( currentSession() ) | 411 | if ( currentSession() ) |
412 | currentSession()->layer()->close(); | 412 | currentSession()->layer()->close(); |
413 | 413 | ||
414 | slotClose(); | 414 | slotClose(); |
415 | /* FIXME move to the next session */ | 415 | /* FIXME move to the next session */ |
416 | } | 416 | } |
417 | 417 | ||
418 | 418 | ||
419 | 419 | ||
420 | 420 | ||
421 | 421 | ||
422 | 422 | ||
423 | void MainWindow::slotQuickLaunch() { | 423 | void MainWindow::slotQuickLaunch() { |
424 | Profile prof = manager()->profile( "default" ); | 424 | Profile prof = manager()->profile( "default" ); |
425 | if ( prof.name() == "default" ) { | 425 | if ( prof.name() == "default" ) { |
426 | create( prof ); | 426 | create( prof ); |
427 | } else { | 427 | } else { |
428 | Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); | 428 | Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); |
429 | newProf.setAutoConnect( true ); | 429 | newProf.setAutoConnect( true ); |
430 | create( newProf ); | 430 | create( newProf ); |
431 | slotSaveSession(); | ||
431 | } | 432 | } |
432 | 433 | ||
433 | } | 434 | } |
434 | 435 | ||
435 | void MainWindow::slotConfigure() { | 436 | void MainWindow::slotConfigure() { |
436 | ConfigDialog conf( manager()->all(), factory() ); | 437 | ConfigDialog conf( manager()->all(), factory() ); |
437 | conf.showMaximized(); | 438 | conf.showMaximized(); |
438 | 439 | ||
439 | int ret = conf.exec(); | 440 | int ret = conf.exec(); |
440 | 441 | ||
441 | if ( QDialog::Accepted == ret ) { | 442 | if ( QDialog::Accepted == ret ) { |
442 | manager()->setProfiles( conf.list() ); | 443 | manager()->setProfiles( conf.list() ); |
443 | manager()->save(); | 444 | manager()->save(); |
444 | populateProfiles(); | 445 | populateProfiles(); |
445 | } | 446 | } |
446 | } | 447 | } |
447 | /* | 448 | /* |
448 | * we will remove | 449 | * we will remove |
449 | * this window from the tabwidget | 450 | * this window from the tabwidget |
450 | * remove it from the list | 451 | * remove it from the list |
451 | * delete it | 452 | * delete it |
452 | * and set the currentSession() | 453 | * and set the currentSession() |
453 | */ | 454 | */ |
454 | void MainWindow::slotClose() { | 455 | void MainWindow::slotClose() { |
455 | if (!currentSession() ) | 456 | if (!currentSession() ) |
456 | return; | 457 | return; |
457 | 458 | ||
458 | Session* ses = currentSession(); | 459 | Session* ses = currentSession(); |
459 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 460 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
460 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 461 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
461 | m_curSession = NULL; | 462 | m_curSession = NULL; |
462 | tabWidget()->remove( /*currentSession()*/ses ); | 463 | tabWidget()->remove( /*currentSession()*/ses ); |
463 | /*it's autodelete */ | 464 | /*it's autodelete */ |
464 | m_sessions.remove( ses ); | 465 | m_sessions.remove( ses ); |
465 | qWarning("after remove!!"); | 466 | qWarning("after remove!!"); |
466 | 467 | ||
467 | if (!currentSession() ) { | 468 | if (!currentSession() ) { |
468 | m_connect->setEnabled( false ); | 469 | m_connect->setEnabled( false ); |
469 | m_disconnect->setEnabled( false ); | 470 | m_disconnect->setEnabled( false ); |
470 | m_terminate->setEnabled( false ); | 471 | m_terminate->setEnabled( false ); |
471 | m_transfer->setEnabled( false ); | 472 | m_transfer->setEnabled( false ); |
472 | m_recordScript->setEnabled( false ); | 473 | m_recordScript->setEnabled( false ); |
473 | m_saveScript->setEnabled( false ); | 474 | m_saveScript->setEnabled( false ); |
474 | m_scripts->setItemEnabled(m_runScript_id, false); | 475 | m_scripts->setItemEnabled(m_runScript_id, false); |
475 | m_fullscreen->setEnabled( false ); | 476 | m_fullscreen->setEnabled( false ); |
476 | m_wrap->setEnabled( false ); | 477 | m_wrap->setEnabled( false ); |
477 | m_closewindow->setEnabled( false ); | 478 | m_closewindow->setEnabled( false ); |
478 | } | 479 | } |
479 | 480 | ||
480 | m_kb->loadDefaults(); | 481 | m_kb->loadDefaults(); |
481 | } | 482 | } |
482 | 483 | ||
483 | /* | 484 | /* |
484 | * We will get the name | 485 | * We will get the name |
485 | * Then the profile | 486 | * Then the profile |
486 | * and then we will make a profile | 487 | * and then we will make a profile |
487 | */ | 488 | */ |
488 | void MainWindow::slotProfile( int id) { | 489 | void MainWindow::slotProfile( int id) { |
489 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 490 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
490 | create( prof ); | 491 | create( prof ); |
491 | } | 492 | } |
492 | 493 | ||
493 | 494 | ||
494 | 495 | ||
495 | void MainWindow::create( const Profile& prof ) { | 496 | void MainWindow::create( const Profile& prof ) { |
496 | if(m_curSession) | 497 | if(m_curSession) |
497 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 498 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
498 | 499 | ||
499 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 500 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
500 | 501 | ||
501 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 502 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
502 | { | 503 | { |
503 | QMessageBox::warning(this, | 504 | QMessageBox::warning(this, |
504 | QObject::tr("Session failed"), | 505 | QObject::tr("Session failed"), |
505 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 506 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
506 | //if(ses) delete ses; | 507 | //if(ses) delete ses; |
507 | return; | 508 | return; |
508 | } | 509 | } |
509 | 510 | ||
510 | m_sessions.append( ses ); | 511 | m_sessions.append( ses ); |
511 | tabWidget()->add( ses ); | 512 | tabWidget()->add( ses ); |
512 | tabWidget()->repaint(); | 513 | tabWidget()->repaint(); |
513 | m_curSession = ses; | 514 | m_curSession = ses; |
514 | 515 | ||
515 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 516 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
516 | m_connect->setEnabled( true ); | 517 | m_connect->setEnabled( true ); |
517 | m_disconnect->setEnabled( false ); | 518 | m_disconnect->setEnabled( false ); |
518 | m_terminate->setEnabled( true ); | 519 | m_terminate->setEnabled( true ); |
519 | m_fullscreen->setEnabled( true ); | 520 | m_fullscreen->setEnabled( true ); |
520 | m_wrap->setEnabled( true ); | 521 | m_wrap->setEnabled( true ); |
521 | m_closewindow->setEnabled( true ); | 522 | m_closewindow->setEnabled( true ); |
522 | m_transfer->setEnabled( false ); | 523 | m_transfer->setEnabled( false ); |
523 | m_recordScript->setEnabled( false ); | 524 | m_recordScript->setEnabled( false ); |
524 | m_saveScript->setEnabled( false ); | 525 | m_saveScript->setEnabled( false ); |
525 | m_scripts->setItemEnabled(m_runScript_id, false); | 526 | m_scripts->setItemEnabled(m_runScript_id, false); |
526 | 527 | ||
527 | // is io_layer wants direct connection, then autoconnect | 528 | // is io_layer wants direct connection, then autoconnect |
528 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 529 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
529 | if (prof.autoConnect()) { | 530 | if (prof.autoConnect()) { |
530 | slotConnect(); | 531 | slotConnect(); |
531 | } | 532 | } |
532 | 533 | ||
533 | 534 | ||
534 | QWidget *w = currentSession()->widget(); | 535 | QWidget *w = currentSession()->widget(); |
535 | if(w) w->setFocus(); | 536 | if(w) w->setFocus(); |
536 | 537 | ||
537 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 538 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
538 | m_isWrapped = true; | 539 | m_isWrapped = true; |
539 | } else { | 540 | } else { |
540 | m_isWrapped = false; | 541 | m_isWrapped = false; |
541 | } | 542 | } |
542 | 543 | ||
543 | m_kb->load(currentSession()->profile()); | 544 | m_kb->load(currentSession()->profile()); |
544 | } | 545 | } |
545 | 546 | ||
546 | void MainWindow::slotTransfer() | 547 | void MainWindow::slotTransfer() |
547 | { | 548 | { |
548 | if ( currentSession() ) { | 549 | if ( currentSession() ) { |
549 | Session *mysession = currentSession(); | 550 | Session *mysession = currentSession(); |
550 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); | 551 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); |
551 | mysession->setTransferDialog(&dlg); | 552 | mysession->setTransferDialog(&dlg); |
552 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); | 553 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); |
553 | //dlg.showMaximized(); | 554 | //dlg.showMaximized(); |
554 | currentSession()->widgetStack()->addWidget(&dlg, -1); | 555 | currentSession()->widgetStack()->addWidget(&dlg, -1); |
555 | dlg.show(); | 556 | dlg.show(); |
556 | //dlg.exec(); | 557 | //dlg.exec(); |
557 | while(dlg.isRunning()) qApp->processEvents(); | 558 | while(dlg.isRunning()) qApp->processEvents(); |
558 | mysession->setTransferDialog(0l); | 559 | mysession->setTransferDialog(0l); |
559 | } | 560 | } |
560 | } | 561 | } |
561 | 562 | ||
562 | 563 | ||
563 | void MainWindow::slotOpenKeb(bool state) { | 564 | void MainWindow::slotOpenKeb(bool state) { |
564 | 565 | ||
565 | if (state) m_keyBar->show(); | 566 | if (state) m_keyBar->show(); |
566 | else m_keyBar->hide(); | 567 | else m_keyBar->hide(); |
567 | 568 | ||
568 | } | 569 | } |
569 | 570 | ||
570 | 571 | ||
571 | void MainWindow::slotOpenButtons( bool state ) { | 572 | void MainWindow::slotOpenButtons( bool state ) { |
572 | 573 | ||
573 | if ( state ) { | 574 | if ( state ) { |
574 | m_buttonBar->show(); | 575 | m_buttonBar->show(); |
575 | } else { | 576 | } else { |
576 | m_buttonBar->hide(); | 577 | m_buttonBar->hide(); |
577 | } | 578 | } |
578 | } | 579 | } |
579 | 580 | ||
580 | 581 | ||
581 | 582 | ||
582 | void MainWindow::slotSessionChanged( Session* ses ) { | 583 | void MainWindow::slotSessionChanged( Session* ses ) { |
583 | qWarning("changed!"); | 584 | qWarning("changed!"); |
584 | 585 | ||
585 | if(m_curSession) | 586 | if(m_curSession) |
586 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 587 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
587 | if(ses) | 588 | if(ses) |
588 | if(ses->transferDialog()) ses->transferDialog()->show(); | 589 | if(ses->transferDialog()) ses->transferDialog()->show(); |
589 | 590 | ||
590 | if ( ses ) { | 591 | if ( ses ) { |
591 | m_curSession = ses; | 592 | m_curSession = ses; |
592 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 593 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
593 | if ( m_curSession->layer()->isConnected() ) { | 594 | if ( m_curSession->layer()->isConnected() ) { |
594 | m_connect->setEnabled( false ); | 595 | m_connect->setEnabled( false ); |
595 | m_disconnect->setEnabled( true ); | 596 | m_disconnect->setEnabled( true ); |
596 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); | 597 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
597 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); | 598 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
598 | m_scripts->setItemEnabled(m_runScript_id, true); | 599 | m_scripts->setItemEnabled(m_runScript_id, true); |
599 | } else { | 600 | } else { |
600 | m_connect->setEnabled( true ); | 601 | m_connect->setEnabled( true ); |
601 | m_disconnect->setEnabled( false ); | 602 | m_disconnect->setEnabled( false ); |
602 | m_recordScript->setEnabled( false ); | 603 | m_recordScript->setEnabled( false ); |
603 | m_saveScript->setEnabled( false ); | 604 | m_saveScript->setEnabled( false ); |
604 | m_scripts->setItemEnabled(m_runScript_id, false); | 605 | m_scripts->setItemEnabled(m_runScript_id, false); |
605 | } | 606 | } |
606 | 607 | ||
607 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 608 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
608 | m_transfer->setEnabled( false ); | 609 | m_transfer->setEnabled( false ); |
609 | } else { | 610 | } else { |
610 | m_transfer->setEnabled( true ); | 611 | m_transfer->setEnabled( true ); |
611 | } | 612 | } |
612 | 613 | ||
613 | QWidget *w = m_curSession->widget(); | 614 | QWidget *w = m_curSession->widget(); |
614 | if(w) w->setFocus(); | 615 | if(w) w->setFocus(); |
615 | 616 | ||
616 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 617 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
617 | m_isWrapped = true; | 618 | m_isWrapped = true; |
618 | } else { | 619 | } else { |
619 | m_isWrapped = false; | 620 | m_isWrapped = false; |
620 | } | 621 | } |
621 | 622 | ||
622 | m_kb->load(currentSession()->profile()); | 623 | m_kb->load(currentSession()->profile()); |
623 | } | 624 | } |
624 | } | 625 | } |
625 | 626 | ||
626 | void MainWindow::slotWrap() | 627 | void MainWindow::slotWrap() |
627 | { | 628 | { |
628 | if(m_curSession) | 629 | if(m_curSession) |
629 | { | 630 | { |
630 | EmulationHandler *e = m_curSession->emulationHandler(); | 631 | EmulationHandler *e = m_curSession->emulationHandler(); |
631 | if(e) | 632 | if(e) |
632 | { | 633 | { |
633 | if(m_isWrapped) | 634 | if(m_isWrapped) |
634 | { | 635 | { |
635 | e->setWrap(80); | 636 | e->setWrap(80); |
636 | m_isWrapped = false; | 637 | m_isWrapped = false; |
637 | } | 638 | } |
638 | else | 639 | else |
639 | { | 640 | { |
640 | e->setWrap(0); | 641 | e->setWrap(0); |
641 | m_isWrapped = true; | 642 | m_isWrapped = true; |
642 | } | 643 | } |
643 | } | 644 | } |
644 | } | 645 | } |
645 | } | 646 | } |
646 | 647 | ||
647 | void MainWindow::slotFullscreen() { | 648 | void MainWindow::slotFullscreen() { |
648 | 649 | ||
649 | 650 | ||
650 | 651 | ||
651 | if ( m_isFullscreen ) { | 652 | if ( m_isFullscreen ) { |
652 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 653 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
653 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 654 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
654 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 655 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
655 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 656 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
656 | 657 | ||
657 | } else { | 658 | } else { |
658 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 659 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
659 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 660 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
660 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 661 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
661 | , QPoint(0,0), false ); | 662 | , QPoint(0,0), false ); |
662 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 663 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
663 | ( m_curSession->widgetStack() )->setFocus(); | 664 | ( m_curSession->widgetStack() )->setFocus(); |
664 | ( m_curSession->widgetStack() )->show(); | 665 | ( m_curSession->widgetStack() )->show(); |
665 | 666 | ||
666 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 667 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
667 | 668 | ||
668 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 669 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
669 | } | 670 | } |
670 | 671 | ||
671 | m_isFullscreen = !m_isFullscreen; | 672 | m_isFullscreen = !m_isFullscreen; |
672 | } | 673 | } |
673 | 674 | ||
674 | 675 | ||
675 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 676 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
676 | 677 | ||
677 | if ( m_curSession ) { | 678 | if ( m_curSession ) { |
678 | 679 | ||
679 | QEvent::Type state; | 680 | QEvent::Type state; |
680 | 681 | ||
681 | if (pressed) state = QEvent::KeyPress; | 682 | if (pressed) state = QEvent::KeyPress; |
682 | else state = QEvent::KeyRelease; | 683 | else state = QEvent::KeyRelease; |
683 | 684 | ||
684 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 685 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
685 | 686 | ||
686 | // is this the best way to do this? cant figure out any other way to work | 687 | // is this the best way to do this? cant figure out any other way to work |
687 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 688 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
688 | ke.ignore(); | 689 | ke.ignore(); |
689 | } | 690 | } |
690 | } | 691 | } |
691 | void MainWindow::slotCopy() { | 692 | void MainWindow::slotCopy() { |
692 | if (!currentSession() ) return; | 693 | if (!currentSession() ) return; |
693 | currentSession()->emulationHandler()->copy(); | 694 | currentSession()->emulationHandler()->copy(); |
694 | } | 695 | } |
695 | void MainWindow::slotPaste() { | 696 | void MainWindow::slotPaste() { |
696 | if (!currentSession() ) return; | 697 | if (!currentSession() ) return; |
697 | currentSession()->emulationHandler()->paste(); | 698 | currentSession()->emulationHandler()->paste(); |
698 | } | 699 | } |
699 | 700 | ||
700 | /* | 701 | /* |
701 | * Save the session | 702 | * Save the session |
702 | */ | 703 | */ |
703 | 704 | ||
704 | void MainWindow::slotSaveSession() { | 705 | void MainWindow::slotSaveSession() { |
705 | if (!currentSession() ) { | 706 | if (!currentSession() ) { |
706 | QMessageBox::information(this, tr("Save Connection"), | 707 | QMessageBox::information(this, tr("Save Connection"), |
707 | tr("<qt>There is no Connection.</qt>"), 1 ); | 708 | tr("<qt>There is no Connection.</qt>"), 1 ); |
708 | return; | 709 | return; |
709 | } | 710 | } |
710 | manager()->add( currentSession()->profile() ); | 711 | manager()->add( currentSession()->profile() ); |
711 | manager()->save(); | 712 | manager()->save(); |
712 | populateProfiles(); | 713 | populateProfiles(); |
713 | } | 714 | } |
714 | void MainWindow::slotSaveHistory() { | 715 | void MainWindow::slotSaveHistory() { |
715 | QMap<QString, QStringList> map; | 716 | QMap<QString, QStringList> map; |
716 | QStringList text; | 717 | QStringList text; |
717 | text << "text/plain"; | 718 | text << "text/plain"; |
718 | map.insert(tr("History"), text ); | 719 | map.insert(tr("History"), text ); |
719 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 720 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
720 | if (filename.isEmpty() ) return; | 721 | if (filename.isEmpty() ) return; |
721 | 722 | ||
722 | QFileInfo info(filename); | 723 | QFileInfo info(filename); |
723 | 724 | ||
724 | DocLnk nf; | 725 | DocLnk nf; |
725 | nf.setType("text/plain"); | 726 | nf.setType("text/plain"); |
726 | nf.setFile(filename); | 727 | nf.setFile(filename); |
727 | nf.setName(info.fileName()); | 728 | nf.setName(info.fileName()); |
728 | 729 | ||
729 | 730 | ||
730 | QFile file(filename); | 731 | QFile file(filename); |
731 | file.open(IO_WriteOnly ); | 732 | file.open(IO_WriteOnly ); |
732 | QTextStream str(&file ); | 733 | QTextStream str(&file ); |
733 | if ( currentSession() ) | 734 | if ( currentSession() ) |
734 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | 735 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); |
735 | 736 | ||
736 | file.close(); | 737 | file.close(); |
737 | nf.writeLink(); | 738 | nf.writeLink(); |
738 | } | 739 | } |
diff --git a/noncore/apps/opie-console/opie-console.control b/noncore/apps/opie-console/opie-console.control index 693c72c..852451d 100644 --- a/noncore/apps/opie-console/opie-console.control +++ b/noncore/apps/opie-console/opie-console.control | |||
@@ -1,11 +1,11 @@ | |||
1 | Package: opie-console | 1 | Package: opie-console |
2 | Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* | 2 | Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Opie team <opie@handhelds.org> | 5 | Maintainer: Opie team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: 0.6-$SUB_VERSION | 7 | Version: 0.6-$SUB_VERSION |
8 | Depends: qpe-base, libopie1, lrzsz, opie-keytabs | 8 | Depends: qpe-base, libopie1, opie-console-help-en, lrzsz, opie-keytabs |
9 | License: GPL | 9 | License: GPL |
10 | Description: Opie terminal app | 10 | Description: Opie terminal app |
11 | 11 | ||
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 58b29ca..ccf2e08 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro | |||
@@ -1,77 +1,76 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | TMAKE_CXXFLAGS+= -DHAVE_OPENPTY | 2 | TMAKE_CXXFLAGS+= -DHAVE_OPENPTY |
3 | CONFIG += qt warn_on release | 3 | CONFIG += qt warn_on release |
4 | #CONFIG = qt debug | 4 | #CONFIG = qt debug |
5 | DESTDIR = $(OPIEDIR)/bin | 5 | DESTDIR = $(OPIEDIR)/bin |
6 | HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ | 6 | HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ |
7 | file_layer.h filetransfer.h \ | 7 | file_layer.h filetransfer.h \ |
8 | metafactory.h \ | 8 | metafactory.h \ |
9 | session.h \ | 9 | session.h \ |
10 | mainwindow.h \ | 10 | mainwindow.h \ |
11 | profile.h \ | 11 | profile.h \ |
12 | profileconfig.h \ | 12 | profileconfig.h \ |
13 | profilemanager.h \ | 13 | profilemanager.h \ |
14 | configwidget.h \ | ||
15 | tabwidget.h \ | 14 | tabwidget.h \ |
16 | configdialog.h \ | 15 | configdialog.h \ |
17 | keytrans.h \ | 16 | keytrans.h \ |
18 | transferdialog.h \ | 17 | transferdialog.h \ |
19 | profiledialogwidget.h \ | 18 | profiledialogwidget.h \ |
20 | profileeditordialog.h \ | 19 | profileeditordialog.h \ |
21 | default.h \ | 20 | default.h \ |
22 | iolayerbase.h \ | 21 | iolayerbase.h \ |
23 | serialconfigwidget.h irdaconfigwidget.h \ | 22 | serialconfigwidget.h irdaconfigwidget.h \ |
24 | btconfigwidget.h modemconfigwidget.h \ | 23 | btconfigwidget.h modemconfigwidget.h \ |
25 | atconfigdialog.h dialdialog.h \ | 24 | atconfigdialog.h dialdialog.h \ |
26 | procctl.h \ | 25 | procctl.h \ |
27 | function_keyboard.h \ | 26 | function_keyboard.h \ |
28 | receive_layer.h filereceive.h \ | 27 | receive_layer.h filereceive.h \ |
29 | script.h \ | 28 | script.h \ |
30 | dialer.h \ | 29 | dialer.h \ |
31 | terminalwidget.h \ | 30 | terminalwidget.h \ |
32 | emulation_handler.h TECommon.h \ | 31 | emulation_handler.h TECommon.h \ |
33 | TEHistory.h TEScreen.h TEWidget.h \ | 32 | TEHistory.h TEScreen.h TEWidget.h \ |
34 | TEmuVt102.h TEmulation.h MyPty.h \ | 33 | TEmuVt102.h TEmulation.h MyPty.h \ |
35 | consoleconfigwidget.h | 34 | consoleconfigwidget.h |
36 | 35 | ||
37 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ | 36 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ |
38 | file_layer.cpp filetransfer.cpp \ | 37 | file_layer.cpp filetransfer.cpp \ |
39 | main.cpp \ | 38 | main.cpp \ |
40 | metafactory.cpp \ | 39 | metafactory.cpp \ |
41 | session.cpp \ | 40 | session.cpp \ |
42 | mainwindow.cpp \ | 41 | mainwindow.cpp \ |
43 | profile.cpp \ | 42 | profile.cpp \ |
44 | profileconfig.cpp \ | 43 | profileconfig.cpp \ |
45 | profilemanager.cpp \ | 44 | profilemanager.cpp \ |
46 | tabwidget.cpp \ | 45 | tabwidget.cpp \ |
47 | configdialog.cpp \ | 46 | configdialog.cpp \ |
48 | keytrans.cpp \ | 47 | keytrans.cpp \ |
49 | transferdialog.cpp \ | 48 | transferdialog.cpp \ |
50 | profiledialogwidget.cpp \ | 49 | profiledialogwidget.cpp \ |
51 | profileeditordialog.cpp \ | 50 | profileeditordialog.cpp \ |
52 | iolayerbase.cpp \ | 51 | iolayerbase.cpp \ |
53 | serialconfigwidget.cpp irdaconfigwidget.cpp \ | 52 | serialconfigwidget.cpp irdaconfigwidget.cpp \ |
54 | btconfigwidget.cpp modemconfigwidget.cpp \ | 53 | btconfigwidget.cpp modemconfigwidget.cpp \ |
55 | atconfigdialog.cpp dialdialog.cpp \ | 54 | atconfigdialog.cpp dialdialog.cpp \ |
56 | default.cpp procctl.cpp \ | 55 | default.cpp procctl.cpp \ |
57 | function_keyboard.cpp \ | 56 | function_keyboard.cpp \ |
58 | receive_layer.cpp filereceive.cpp \ | 57 | receive_layer.cpp filereceive.cpp \ |
59 | script.cpp \ | 58 | script.cpp \ |
60 | dialer.cpp \ | 59 | dialer.cpp \ |
61 | terminalwidget.cpp \ | 60 | terminalwidget.cpp \ |
62 | emulation_handler.cpp TEHistory.cpp \ | 61 | emulation_handler.cpp TEHistory.cpp \ |
63 | TEScreen.cpp TEWidget.cpp \ | 62 | TEScreen.cpp TEWidget.cpp \ |
64 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ | 63 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ |
65 | consoleconfigwidget.cpp | 64 | consoleconfigwidget.cpp |
66 | 65 | ||
67 | 66 | ||
68 | INTERFACES = configurebase.ui editbase.ui | 67 | INTERFACES = configurebase.ui editbase.ui |
69 | INCLUDEPATH += $(OPIEDIR)/include | 68 | INCLUDEPATH += $(OPIEDIR)/include |
70 | DEPENDPATH += $(OPIEDIR)/include | 69 | DEPENDPATH += $(OPIEDIR)/include |
71 | LIBS += -lqpe -lopie -lutil | 70 | LIBS += -lqpe -lopie -lutil |
72 | TARGET = opie-console | 71 | TARGET = opie-console |
73 | 72 | ||
74 | 73 | ||
75 | 74 | ||
76 | 75 | ||
77 | include ( $(OPIEDIR)/include.pro ) | 76 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 6b607df..e2501a6 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -1,239 +1,242 @@ | |||
1 | #include <qlayout.h> | 1 | #include <qlayout.h> |
2 | #include <qlineedit.h> | 2 | #include <qlineedit.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qmessagebox.h> | 4 | #include <qmessagebox.h> |
5 | #include <qstringlist.h> | 5 | #include <qstringlist.h> |
6 | #include <qcombobox.h> | 6 | #include <qcombobox.h> |
7 | #include <qcheckbox.h> | 7 | #include <qcheckbox.h> |
8 | #include <qscrollview.h> | 8 | #include <qscrollview.h> |
9 | 9 | ||
10 | #include "metafactory.h" | 10 | #include "metafactory.h" |
11 | #include "profileeditordialog.h" | 11 | #include "profileeditordialog.h" |
12 | 12 | ||
13 | namespace { | 13 | namespace { |
14 | void setCurrent( const QString& str, QComboBox* bo ) { | 14 | void setCurrent( const QString& str, QComboBox* bo ) { |
15 | for (int i = 0; i < bo->count(); i++ ) { | 15 | for (int i = 0; i < bo->count(); i++ ) { |
16 | if ( bo->text(i) == str ) { | 16 | if ( bo->text(i) == str ) { |
17 | bo->setCurrentItem( i ); | 17 | bo->setCurrentItem( i ); |
18 | } | 18 | } |
19 | } | 19 | } |
20 | }; | 20 | }; |
21 | } | 21 | } |
22 | 22 | ||
23 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, | 23 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, |
24 | const Profile& prof ) | 24 | const Profile& prof ) |
25 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) | 25 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) |
26 | { | 26 | { |
27 | initUI(); | 27 | initUI(); |
28 | 28 | ||
29 | // Apply current profile | 29 | // Apply current profile |
30 | // plugin_plugin->load(profile); | 30 | // plugin_plugin->load(profile); |
31 | // ... (reset profile name line edit etc.) | 31 | // ... (reset profile name line edit etc.) |
32 | } | 32 | } |
33 | 33 | ||
34 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | 34 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) |
35 | : QDialog(0, 0, TRUE), m_fact( fact ) | 35 | : QDialog(0, 0, TRUE), m_fact( fact ) |
36 | { | 36 | { |
37 | // Default profile | 37 | // Default profile |
38 | m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); | 38 | m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102); |
39 | 39 | ||
40 | initUI(); | 40 | initUI(); |
41 | 41 | ||
42 | // Apply current profile | 42 | // Apply current profile |
43 | // plugin_plugin->load(profile); | 43 | // plugin_plugin->load(profile); |
44 | } | 44 | } |
45 | 45 | ||
46 | Profile ProfileEditorDialog::profile() const | 46 | Profile ProfileEditorDialog::profile() const |
47 | { | 47 | { |
48 | return m_prof; | 48 | return m_prof; |
49 | } | 49 | } |
50 | 50 | ||
51 | void ProfileEditorDialog::initUI() | 51 | void ProfileEditorDialog::initUI() |
52 | { | 52 | { |
53 | m_con = m_term = m_key = 0l; | 53 | m_con = m_term = m_key = 0l; |
54 | 54 | ||
55 | 55 | ||
56 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); | 56 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); |
57 | tabWidget = new OTabWidget( this ); | 57 | tabWidget = new OTabWidget( this ); |
58 | tabWidget->setTabStyle(OTabWidget::TextTab); | 58 | tabWidget->setTabStyle(OTabWidget::TextTab); |
59 | mainLayout->add(tabWidget); | 59 | mainLayout->add(tabWidget); |
60 | 60 | ||
61 | /* base tabs */ | 61 | /* base tabs */ |
62 | tabprof = new QWidget(this); | 62 | tabprof = new QWidget(this); |
63 | m_tabTerm = new QWidget(this); | 63 | m_tabTerm = new QWidget(this); |
64 | m_tabCon = new QWidget(this); | 64 | m_tabCon = new QWidget(this); |
65 | m_tabKey = new QWidget(this); | 65 | m_tabKey = new QWidget(this); |
66 | 66 | ||
67 | m_svCon = new QScrollView( m_tabCon ); | 67 | m_svCon = new QScrollView( m_tabCon ); |
68 | m_svCon->setResizePolicy( QScrollView::AutoOneFit ); | 68 | m_svCon->setResizePolicy( QScrollView::AutoOneFit ); |
69 | //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); | 69 | //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); |
70 | m_svCon->setFrameShape( QFrame::NoFrame ); | 70 | m_svCon->setFrameShape( QFrame::NoFrame ); |
71 | m_svTerm = new QScrollView( m_tabTerm ); | 71 | m_svTerm = new QScrollView( m_tabTerm ); |
72 | m_svTerm->setResizePolicy( QScrollView::AutoOneFit ); | 72 | m_svTerm->setResizePolicy( QScrollView::AutoOneFit ); |
73 | //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); | 73 | //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); |
74 | m_svTerm->setFrameShape( QFrame::NoFrame ); | 74 | m_svTerm->setFrameShape( QFrame::NoFrame ); |
75 | 75 | ||
76 | /* base layout for tabs */ | 76 | /* base layout for tabs */ |
77 | m_layCon = new QHBoxLayout( m_tabCon , 2 ); | 77 | m_layCon = new QHBoxLayout( m_tabCon , 2 ); |
78 | m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); | 78 | m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); |
79 | m_layKey = new QHBoxLayout( m_tabKey, 2 ); | 79 | m_layKey = new QHBoxLayout( m_tabKey, 2 ); |
80 | 80 | ||
81 | m_layCon->addWidget( m_svCon ); | 81 | m_layCon->addWidget( m_svCon ); |
82 | m_layTerm->addWidget( m_svTerm ); | 82 | m_layTerm->addWidget( m_svTerm ); |
83 | 83 | ||
84 | // profile tab | 84 | // profile tab |
85 | 85 | ||
86 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); | 86 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); |
87 | m_name = new QLineEdit(tabprof); | 87 | m_name = new QLineEdit(tabprof); |
88 | QLabel *con = new QLabel(tr("Connection"), tabprof ); | 88 | QLabel *con = new QLabel(tr("Connection"), tabprof ); |
89 | QLabel *term = new QLabel(tr("Terminal"), tabprof ); | 89 | QLabel *term = new QLabel(tr("Terminal"), tabprof ); |
90 | m_conCmb = new QComboBox( tabprof ); | 90 | m_conCmb = new QComboBox( tabprof ); |
91 | m_termCmb = new QComboBox( tabprof ); | 91 | m_termCmb = new QComboBox( tabprof ); |
92 | m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); | 92 | m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); |
93 | 93 | ||
94 | // layouting | 94 | // layouting |
95 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); | 95 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); |
96 | vbox3->add(name); | 96 | vbox3->add(name); |
97 | vbox3->add(m_name); | 97 | vbox3->add(m_name); |
98 | vbox3->add(con ); | 98 | vbox3->add(con ); |
99 | vbox3->add(m_conCmb ); | 99 | vbox3->add(m_conCmb ); |
100 | vbox3->add(term ); | 100 | vbox3->add(term ); |
101 | vbox3->add(m_termCmb ); | 101 | vbox3->add(m_termCmb ); |
102 | vbox3->add(m_autoConnect); | 102 | vbox3->add(m_autoConnect); |
103 | vbox3->addStretch(1); | 103 | vbox3->addStretch(1); |
104 | 104 | ||
105 | m_showconntab = 0; | 105 | m_showconntab = 0; |
106 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); | 106 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); |
107 | tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); | 107 | tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); |
108 | tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); | 108 | tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); |
109 | tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); | 109 | tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); |
110 | tabWidget->setCurrentTab( tabprof ); | 110 | tabWidget->setCurrentTab( tabprof ); |
111 | 111 | ||
112 | 112 | ||
113 | // fill the comboboxes | 113 | // fill the comboboxes |
114 | QStringList list = m_fact->connectionWidgets(); | 114 | QStringList list = m_fact->connectionWidgets(); |
115 | QStringList::Iterator it; | 115 | QStringList::Iterator it; |
116 | for (it =list.begin(); it != list.end(); ++it ) { | 116 | for (it =list.begin(); it != list.end(); ++it ) { |
117 | m_conCmb->insertItem( (*it) ); | 117 | m_conCmb->insertItem( (*it) ); |
118 | } | 118 | } |
119 | list = m_fact->terminalWidgets(); | 119 | list = m_fact->terminalWidgets(); |
120 | for (it =list.begin(); it != list.end(); ++it ) { | 120 | for (it =list.begin(); it != list.end(); ++it ) { |
121 | m_termCmb->insertItem( (*it) ); | 121 | m_termCmb->insertItem( (*it) ); |
122 | } | 122 | } |
123 | 123 | ||
124 | // load profile values | 124 | // load profile values |
125 | m_name->setText(m_prof.name()); | 125 | m_name->setText(m_prof.name()); |
126 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); | ||
127 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); | ||
128 | slotKeyActivated( "Default Keyboard" ); | 126 | slotKeyActivated( "Default Keyboard" ); |
129 | setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); | 127 | setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); |
130 | setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); | 128 | setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); |
129 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); | ||
130 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); | ||
131 | m_autoConnect->setChecked(m_prof.autoConnect()); | 131 | m_autoConnect->setChecked(m_prof.autoConnect()); |
132 | 132 | ||
133 | 133 | ||
134 | // signal and slots | 134 | // signal and slots |
135 | connect(m_conCmb, SIGNAL(activated(const QString& ) ), | 135 | connect(m_conCmb, SIGNAL(activated(const QString& ) ), |
136 | this, SLOT(slotConActivated(const QString&) ) ); | 136 | this, SLOT(slotConActivated(const QString&) ) ); |
137 | connect(m_termCmb, SIGNAL(activated(const QString& ) ), | 137 | connect(m_termCmb, SIGNAL(activated(const QString& ) ), |
138 | this, SLOT(slotTermActivated(const QString& ) ) ); | 138 | this, SLOT(slotTermActivated(const QString& ) ) ); |
139 | 139 | ||
140 | } | 140 | } |
141 | 141 | ||
142 | ProfileEditorDialog::~ProfileEditorDialog() { | 142 | ProfileEditorDialog::~ProfileEditorDialog() { |
143 | 143 | ||
144 | } | 144 | } |
145 | void ProfileEditorDialog::accept() | 145 | void ProfileEditorDialog::accept() |
146 | { | 146 | { |
147 | if(profName().isEmpty()) | 147 | if(profName().isEmpty()) |
148 | { | 148 | { |
149 | QMessageBox::information(this, | 149 | QMessageBox::information(this, |
150 | QObject::tr("Invalid profile"), | 150 | QObject::tr("Invalid profile"), |
151 | QObject::tr("Please enter a profile name.")); | 151 | QObject::tr("Please enter a profile name.")); |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | // Save profile and plugin profile | 154 | // Save profile and plugin profile |
155 | //if(plugin_plugin) plugin_plugin->save(); | 155 | //if(plugin_plugin) plugin_plugin->save(); |
156 | 156 | ||
157 | // Save general values | 157 | // Save general values |
158 | m_prof.setName( profName() ); | 158 | m_prof.setName( profName() ); |
159 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); | 159 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); |
160 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); | 160 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); |
161 | m_prof.setAutoConnect( m_autoConnect->isChecked() ); | 161 | m_prof.setAutoConnect( m_autoConnect->isChecked() ); |
162 | 162 | ||
163 | if (m_con ) | 163 | if (m_con ) |
164 | m_con->save( m_prof ); | 164 | m_con->save( m_prof ); |
165 | if (m_term ) | 165 | if (m_term ) |
166 | m_term->save( m_prof ); | 166 | m_term->save( m_prof ); |
167 | if (m_key) | 167 | if (m_key) |
168 | m_key->save( m_prof ); | 168 | m_key->save( m_prof ); |
169 | 169 | ||
170 | QDialog::accept(); | 170 | QDialog::accept(); |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | QString ProfileEditorDialog::profName()const | 174 | QString ProfileEditorDialog::profName()const |
175 | { | 175 | { |
176 | return m_name->text(); | 176 | return m_name->text(); |
177 | } | 177 | } |
178 | 178 | ||
179 | QCString ProfileEditorDialog::profType()const | 179 | QCString ProfileEditorDialog::profType()const |
180 | { | 180 | { |
181 | /*QStringList w = m_fact->configWidgets(); | 181 | /*QStringList w = m_fact->configWidgets(); |
182 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 182 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
183 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 183 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
184 | */ | 184 | */ |
185 | return QCString(); | 185 | return QCString(); |
186 | } | 186 | } |
187 | /* | 187 | /* |
188 | * we need to switch the widget | 188 | * we need to switch the widget |
189 | */ | 189 | */ |
190 | void ProfileEditorDialog::slotConActivated( const QString& str ) { | 190 | void ProfileEditorDialog::slotConActivated( const QString& str ) { |
191 | 191 | ||
192 | delete m_con; | 192 | delete m_con; |
193 | 193 | ||
194 | m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); | 194 | m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); |
195 | 195 | ||
196 | if ( !m_con ) { | 196 | if ( !m_con ) { |
197 | m_con = new NoOptions( str, m_svCon->viewport(), "name"); | 197 | m_con = new NoOptions( str, m_svCon->viewport(), "name"); |
198 | } | 198 | } |
199 | 199 | ||
200 | // FIXME ugly hack right. Right solution would be to look into the layer and see if it | 200 | // FIXME ugly hack right. Right solution would be to look into the layer and see if it |
201 | // supports auto connect and then set it as prefered | 201 | // supports auto connect and then set it as prefered |
202 | //if ( ( )->layer()->supports()[0] == 1 ) { | ||
203 | if ( m_conCmb ->currentText() == tr("Local Console") ) { | 202 | if ( m_conCmb ->currentText() == tr("Local Console") ) { |
204 | m_autoConnect->setChecked( true ); | 203 | m_autoConnect->setChecked( true ); |
204 | m_prof.writeEntry("Terminal", Profile::Linux ); | ||
205 | slotTermActivated( m_fact->external (m_prof.terminalName() ) ); | ||
205 | } else { | 206 | } else { |
207 | m_prof.writeEntry("Terminal", Profile::VT102 ); | ||
208 | slotTermActivated( m_fact->external (m_prof.terminalName() ) ); | ||
206 | m_autoConnect->setChecked( false ); | 209 | m_autoConnect->setChecked( false ); |
207 | } | 210 | } |
208 | 211 | ||
209 | m_con->load( m_prof ); | 212 | m_con->load( m_prof ); |
210 | m_svCon->addChild( m_con ); | 213 | m_svCon->addChild( m_con ); |
211 | } | 214 | } |
212 | 215 | ||
213 | 216 | ||
214 | /* | 217 | /* |
215 | * we need to switch the widget | 218 | * we need to switch the widget |
216 | */ | 219 | */ |
217 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { | 220 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { |
218 | 221 | ||
219 | delete m_term; | 222 | delete m_term; |
220 | 223 | ||
221 | m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() ); | 224 | m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() ); |
222 | 225 | ||
223 | if (m_term) { | 226 | if ( m_term ) { |
224 | m_term->load( m_prof ); | 227 | m_term->load( m_prof ); |
225 | m_svTerm->addChild( m_term ); | 228 | m_svTerm->addChild( m_term ); |
226 | } | 229 | } |
227 | } | 230 | } |
228 | 231 | ||
229 | void ProfileEditorDialog::slotKeyActivated(const QString &str) { | 232 | void ProfileEditorDialog::slotKeyActivated(const QString &str) { |
230 | delete m_key; | 233 | delete m_key; |
231 | m_key = m_fact->newKeyboardPlugin( str, m_tabKey ); | 234 | m_key = m_fact->newKeyboardPlugin( str, m_tabKey ); |
232 | 235 | ||
233 | if (m_key) { | 236 | if (m_key) { |
234 | 237 | ||
235 | m_key->load(m_prof); | 238 | m_key->load(m_prof); |
236 | m_layKey->addWidget(m_key); | 239 | m_layKey->addWidget(m_key); |
237 | } | 240 | } |
238 | 241 | ||
239 | } | 242 | } |
diff --git a/noncore/apps/opie-reader/Prefs.cpp b/noncore/apps/opie-reader/Prefs.cpp index 825608e..e5320d9 100644 --- a/noncore/apps/opie-reader/Prefs.cpp +++ b/noncore/apps/opie-reader/Prefs.cpp | |||
@@ -1,636 +1,636 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'Prefs.ui' | 2 | ** Form implementation generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:35 2003 | 4 | ** Created: Tue Feb 11 23:53:35 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #include "useqpe.h" | 9 | #include "useqpe.h" |
10 | #include "Prefs.h" | 10 | #include "Prefs.h" |
11 | 11 | ||
12 | #include <qcheckbox.h> | 12 | #include <qcheckbox.h> |
13 | #include <qlabel.h> | 13 | #include <qlabel.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qspinbox.h> | 15 | #include <qspinbox.h> |
16 | #include <qlayout.h> | 16 | #include <qlayout.h> |
17 | #include <qvariant.h> | 17 | #include <qvariant.h> |
18 | #include <qtooltip.h> | 18 | #include <qtooltip.h> |
19 | #include <qwhatsthis.h> | 19 | #include <qwhatsthis.h> |
20 | #include <qcombobox.h> | 20 | #include <qcombobox.h> |
21 | #include <qbuttongroup.h> | 21 | #include <qbuttongroup.h> |
22 | #include <qlineedit.h> | 22 | #include <qlineedit.h> |
23 | #ifdef USEQPE | 23 | #ifdef USEQPE |
24 | #include <qpe/menubutton.h> | 24 | #include <qpe/menubutton.h> |
25 | #include <qpe/fontdatabase.h> | 25 | #include <qpe/fontdatabase.h> |
26 | #else | 26 | #else |
27 | #include <qfontdatabase.h> | 27 | #include <qfontdatabase.h> |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl ) | 30 | CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl ) |
31 | : QWidget( parent, name, fl ) | 31 | : QWidget( parent, name, fl ) |
32 | { | 32 | { |
33 | QHBoxLayout* hb = new QHBoxLayout(this); | 33 | QHBoxLayout* hb = new QHBoxLayout(this); |
34 | QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, "Text", this); | 34 | QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, tr("Text"), this); |
35 | hb->addWidget(bg); | 35 | hb->addWidget(bg); |
36 | 36 | ||
37 | StripCR = new QCheckBox( bg ); | 37 | StripCR = new QCheckBox( bg ); |
38 | StripCR->setText( tr( "Strip CR" ) ); | 38 | StripCR->setText( tr( "Strip CR" ) ); |
39 | 39 | ||
40 | Dehyphen = new QCheckBox( bg ); | 40 | Dehyphen = new QCheckBox( bg ); |
41 | Dehyphen->setText( tr( "Dehyphen" ) ); | 41 | Dehyphen->setText( tr( "Dehyphen" ) ); |
42 | 42 | ||
43 | SingleSpace = new QCheckBox( bg ); | 43 | SingleSpace = new QCheckBox( bg ); |
44 | SingleSpace->setText( tr( "Single Space" ) ); | 44 | SingleSpace->setText( tr( "Single Space" ) ); |
45 | 45 | ||
46 | Unindent = new QCheckBox( bg ); | 46 | Unindent = new QCheckBox( bg ); |
47 | Unindent->setText( tr( "Unindent" ) ); | 47 | Unindent->setText( tr( "Unindent" ) ); |
48 | 48 | ||
49 | Reparagraph = new QCheckBox( bg ); | 49 | Reparagraph = new QCheckBox( bg ); |
50 | Reparagraph->setText( tr( "Reparagraph" ) ); | 50 | Reparagraph->setText( tr( "Reparagraph" ) ); |
51 | 51 | ||
52 | DoubleSpace = new QCheckBox( bg ); | 52 | DoubleSpace = new QCheckBox( bg ); |
53 | DoubleSpace->setText( tr( "Double Space" ) ); | 53 | DoubleSpace->setText( tr( "Double Space" ) ); |
54 | 54 | ||
55 | Remap = new QCheckBox( bg ); | 55 | Remap = new QCheckBox( bg ); |
56 | Remap->setText( tr( "Remap" ) ); | 56 | Remap->setText( tr( "Remap" ) ); |
57 | 57 | ||
58 | Embolden = new QCheckBox( bg ); | 58 | Embolden = new QCheckBox( bg ); |
59 | Embolden->setText( tr( "Embolden" ) ); | 59 | Embolden->setText( tr( "Embolden" ) ); |
60 | 60 | ||
61 | FullJustify = new QCheckBox( bg ); | 61 | FullJustify = new QCheckBox( bg ); |
62 | FullJustify->setText( tr( "Full Justify" ) ); | 62 | FullJustify->setText( tr( "Full Justify" ) ); |
63 | 63 | ||
64 | } | 64 | } |
65 | 65 | ||
66 | /* | 66 | /* |
67 | * Destroys the object and frees any allocated resources | 67 | * Destroys the object and frees any allocated resources |
68 | */ | 68 | */ |
69 | CLayoutPrefs::~CLayoutPrefs() | 69 | CLayoutPrefs::~CLayoutPrefs() |
70 | { | 70 | { |
71 | // no need to delete child widgets, Qt does it all for us | 71 | // no need to delete child widgets, Qt does it all for us |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | 75 | ||
76 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) | 76 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) |
77 | : QWidget( parent, name, fl ) | 77 | : QWidget( parent, name, fl ) |
78 | { | 78 | { |
79 | 79 | ||
80 | QVBoxLayout* vb = new QVBoxLayout(this); | 80 | QVBoxLayout* vb = new QVBoxLayout(this); |
81 | QGridLayout* gl = new QGridLayout(vb, 4, 3); | 81 | QGridLayout* gl = new QGridLayout(vb, 4, 3); |
82 | 82 | ||
83 | QLabel *TextLabel; | 83 | QLabel *TextLabel; |
84 | 84 | ||
85 | TextLabel = new QLabel( this, "TextLabel1" ); | 85 | TextLabel = new QLabel( this, "TextLabel1" ); |
86 | TextLabel->setText( tr( "Indent" ) ); | 86 | TextLabel->setText( tr( "Indent" ) ); |
87 | gl->addWidget(TextLabel, 0, 0); | 87 | gl->addWidget(TextLabel, 0, 0); |
88 | 88 | ||
89 | 89 | ||
90 | TextLabel = new QLabel( this ); | 90 | TextLabel = new QLabel( this ); |
91 | TextLabel->setText( tr( "Page\nOverlap" ) ); | 91 | TextLabel->setText( tr( "Page\nOverlap" ) ); |
92 | gl->addWidget(TextLabel, 0, 1); | 92 | gl->addWidget(TextLabel, 0, 1); |
93 | 93 | ||
94 | TextLabel = new QLabel( this ); | 94 | TextLabel = new QLabel( this ); |
95 | TextLabel->setText( tr( "Graphics\nZoom" ) ); | 95 | TextLabel->setText( tr( "Graphics\nZoom" ) ); |
96 | gl->addWidget(TextLabel, 0, 2); | 96 | gl->addWidget(TextLabel, 0, 2); |
97 | 97 | ||
98 | Indent = new QSpinBox( this, "Indent" ); | 98 | Indent = new QSpinBox( this, "Indent" ); |
99 | Indent->setRange(0,20); | 99 | Indent->setRange(0,20); |
100 | gl->addWidget(Indent, 1, 0); | 100 | gl->addWidget(Indent, 1, 0); |
101 | 101 | ||
102 | pageoverlap = new QSpinBox( this ); | 102 | pageoverlap = new QSpinBox( this ); |
103 | pageoverlap->setRange(0,20); | 103 | pageoverlap->setRange(0,20); |
104 | gl->addWidget(pageoverlap, 1, 1); | 104 | gl->addWidget(pageoverlap, 1, 1); |
105 | 105 | ||
106 | gfxzoom = new QSpinBox( this ); | 106 | gfxzoom = new QSpinBox( this ); |
107 | gfxzoom->setRange(0,100); | 107 | gfxzoom->setRange(0,100); |
108 | gl->addWidget(gfxzoom, 1, 2); | 108 | gl->addWidget(gfxzoom, 1, 2); |
109 | 109 | ||
110 | TextLabel = new QLabel( this, "TextLabel4" ); | 110 | TextLabel = new QLabel( this, "TextLabel4" ); |
111 | TextLabel->setText( tr( "Margin" ) ); | 111 | TextLabel->setText( tr( "Margin" ) ); |
112 | gl->addWidget(TextLabel, 2, 0); | 112 | gl->addWidget(TextLabel, 2, 0); |
113 | 113 | ||
114 | TextLabel = new QLabel( this ); | 114 | TextLabel = new QLabel( this ); |
115 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); | 115 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); |
116 | gl->addWidget(TextLabel, 2, 1); | 116 | gl->addWidget(TextLabel, 2, 1); |
117 | 117 | ||
118 | TextLabel = new QLabel( this ); | 118 | TextLabel = new QLabel( this ); |
119 | TextLabel->setText( tr( "Line\nLeading" ) ); | 119 | TextLabel->setText( tr( "Line\nLeading" ) ); |
120 | gl->addWidget(TextLabel, 2, 2); | 120 | gl->addWidget(TextLabel, 2, 2); |
121 | 121 | ||
122 | Margin = new QSpinBox( this, "Margin" ); | 122 | Margin = new QSpinBox( this, "Margin" ); |
123 | Margin->setRange(0, 100); | 123 | Margin->setRange(0, 100); |
124 | gl->addWidget(Margin, 3, 0); | 124 | gl->addWidget(Margin, 3, 0); |
125 | 125 | ||
126 | ParaLead = new QSpinBox( this ); | 126 | ParaLead = new QSpinBox( this ); |
127 | ParaLead->setRange(-5, 50); | 127 | ParaLead->setRange(-5, 50); |
128 | gl->addWidget(ParaLead, 3, 1); | 128 | gl->addWidget(ParaLead, 3, 1); |
129 | 129 | ||
130 | LineLead = new QSpinBox( this ); | 130 | LineLead = new QSpinBox( this ); |
131 | LineLead->setRange(-5, 50); | 131 | LineLead->setRange(-5, 50); |
132 | gl->addWidget(LineLead, 3, 2); | 132 | gl->addWidget(LineLead, 3, 2); |
133 | 133 | ||
134 | gl = new QGridLayout(vb, 2, 2); | 134 | gl = new QGridLayout(vb, 2, 2); |
135 | 135 | ||
136 | TextLabel = new QLabel( this); | 136 | TextLabel = new QLabel( this); |
137 | TextLabel->setText( tr( "Markup" ) ); | 137 | TextLabel->setText( tr( "Markup" ) ); |
138 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); | 138 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); |
139 | TextLabel = new QLabel( this); | 139 | TextLabel = new QLabel( this); |
140 | TextLabel->setText( tr( "Font" ) ); | 140 | TextLabel->setText( tr( "Font" ) ); |
141 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); | 141 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); |
142 | 142 | ||
143 | 143 | ||
144 | #ifdef USECOMBO | 144 | #ifdef USECOMBO |
145 | Markup = new QComboBox( this); | 145 | Markup = new QComboBox( this); |
146 | #else | 146 | #else |
147 | Markup = new MenuButton( this); | 147 | Markup = new MenuButton( this); |
148 | #endif | 148 | #endif |
149 | Markup->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 149 | Markup->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
150 | Markup->insertItem("Auto"); | 150 | Markup->insertItem("Auto"); |
151 | Markup->insertItem("None"); | 151 | Markup->insertItem("None"); |
152 | Markup->insertItem("Text"); | 152 | Markup->insertItem("Text"); |
153 | Markup->insertItem("HTML"); | 153 | Markup->insertItem("HTML"); |
154 | Markup->insertItem("PML"); | 154 | Markup->insertItem("PML"); |
155 | gl->addWidget(Markup, 1, 0, Qt::AlignTop); | 155 | gl->addWidget(Markup, 1, 0, Qt::AlignTop); |
156 | 156 | ||
157 | #ifdef USECOMBO | 157 | #ifdef USECOMBO |
158 | fontselector = new QComboBox( this); | 158 | fontselector = new QComboBox( this); |
159 | #else | 159 | #else |
160 | fontselector = new MenuButton( this); | 160 | fontselector = new MenuButton( this); |
161 | #endif | 161 | #endif |
162 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 162 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
163 | { | 163 | { |
164 | #ifdef USEQPE | 164 | #ifdef USEQPE |
165 | FontDatabase f; | 165 | FontDatabase f; |
166 | #else | 166 | #else |
167 | QFontDatabase f; | 167 | QFontDatabase f; |
168 | #endif | 168 | #endif |
169 | QStringList flist = f.families(); | 169 | QStringList flist = f.families(); |
170 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 170 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
171 | { | 171 | { |
172 | fontselector->insertItem(*nm); | 172 | fontselector->insertItem(*nm); |
173 | } | 173 | } |
174 | } // delete the FontDatabase!!! | 174 | } // delete the FontDatabase!!! |
175 | gl->addWidget(fontselector, 1, 1, Qt::AlignTop); | 175 | gl->addWidget(fontselector, 1, 1, Qt::AlignTop); |
176 | } | 176 | } |
177 | /* | 177 | /* |
178 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) | 178 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) |
179 | : QWidget( parent, name, fl ) | 179 | : QWidget( parent, name, fl ) |
180 | { | 180 | { |
181 | QHBoxLayout* hb = new QHBoxLayout(this); | 181 | QHBoxLayout* hb = new QHBoxLayout(this); |
182 | 182 | ||
183 | QVBoxLayout* vb = new QVBoxLayout; | 183 | QVBoxLayout* vb = new QVBoxLayout; |
184 | hb->addLayout(vb); | 184 | hb->addLayout(vb); |
185 | 185 | ||
186 | QLabel *TextLabel; | 186 | QLabel *TextLabel; |
187 | 187 | ||
188 | TextLabel = new QLabel( this, "TextLabel1" ); | 188 | TextLabel = new QLabel( this, "TextLabel1" ); |
189 | TextLabel->setText( tr( "Indent" ) ); | 189 | TextLabel->setText( tr( "Indent" ) ); |
190 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 190 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
191 | Indent = new QSpinBox( this, "Indent" ); | 191 | Indent = new QSpinBox( this, "Indent" ); |
192 | Indent->setRange(0,20); | 192 | Indent->setRange(0,20); |
193 | vb->addWidget( Indent, 0, Qt::AlignLeft ); | 193 | vb->addWidget( Indent, 0, Qt::AlignLeft ); |
194 | 194 | ||
195 | TextLabel = new QLabel( this ); | 195 | TextLabel = new QLabel( this ); |
196 | TextLabel->setText( tr( "Page\nOverlap" ) ); | 196 | TextLabel->setText( tr( "Page\nOverlap" ) ); |
197 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 197 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
198 | pageoverlap = new QSpinBox( this ); | 198 | pageoverlap = new QSpinBox( this ); |
199 | pageoverlap->setRange(0,20); | 199 | pageoverlap->setRange(0,20); |
200 | vb->addWidget( pageoverlap, 0, Qt::AlignLeft ); | 200 | vb->addWidget( pageoverlap, 0, Qt::AlignLeft ); |
201 | 201 | ||
202 | TextLabel = new QLabel( this ); | 202 | TextLabel = new QLabel( this ); |
203 | TextLabel->setText( tr( "Graphics\nZoom" ) ); | 203 | TextLabel->setText( tr( "Graphics\nZoom" ) ); |
204 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 204 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
205 | gfxzoom = new QSpinBox( this ); | 205 | gfxzoom = new QSpinBox( this ); |
206 | gfxzoom->setRange(0,100); | 206 | gfxzoom->setRange(0,100); |
207 | vb->addWidget( gfxzoom, 0, Qt::AlignLeft ); | 207 | vb->addWidget( gfxzoom, 0, Qt::AlignLeft ); |
208 | 208 | ||
209 | vb->addStretch(); | 209 | vb->addStretch(); |
210 | 210 | ||
211 | vb = new QVBoxLayout; | 211 | vb = new QVBoxLayout; |
212 | hb->addLayout(vb); | 212 | hb->addLayout(vb); |
213 | 213 | ||
214 | TextLabel = new QLabel( this, "TextLabel4" ); | 214 | TextLabel = new QLabel( this, "TextLabel4" ); |
215 | TextLabel->setText( tr( "Margin" ) ); | 215 | TextLabel->setText( tr( "Margin" ) ); |
216 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 216 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
217 | Margin = new QSpinBox( this, "Margin" ); | 217 | Margin = new QSpinBox( this, "Margin" ); |
218 | Margin->setRange(0, 100); | 218 | Margin->setRange(0, 100); |
219 | vb->addWidget( Margin, 0, Qt::AlignLeft ); | 219 | vb->addWidget( Margin, 0, Qt::AlignLeft ); |
220 | 220 | ||
221 | TextLabel = new QLabel( this ); | 221 | TextLabel = new QLabel( this ); |
222 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); | 222 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); |
223 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 223 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
224 | ParaLead = new QSpinBox( this ); | 224 | ParaLead = new QSpinBox( this ); |
225 | ParaLead->setRange(-5, 50); | 225 | ParaLead->setRange(-5, 50); |
226 | vb->addWidget( ParaLead, 0, Qt::AlignLeft ); | 226 | vb->addWidget( ParaLead, 0, Qt::AlignLeft ); |
227 | 227 | ||
228 | TextLabel = new QLabel( this ); | 228 | TextLabel = new QLabel( this ); |
229 | TextLabel->setText( tr( "Line\nLeading" ) ); | 229 | TextLabel->setText( tr( "Line\nLeading" ) ); |
230 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 230 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
231 | LineLead = new QSpinBox( this ); | 231 | LineLead = new QSpinBox( this ); |
232 | LineLead->setRange(-5, 50); | 232 | LineLead->setRange(-5, 50); |
233 | vb->addWidget( LineLead, 0, Qt::AlignLeft ); | 233 | vb->addWidget( LineLead, 0, Qt::AlignLeft ); |
234 | 234 | ||
235 | vb->addStretch(); | 235 | vb->addStretch(); |
236 | 236 | ||
237 | vb = new QVBoxLayout; | 237 | vb = new QVBoxLayout; |
238 | hb->addLayout(vb); | 238 | hb->addLayout(vb); |
239 | 239 | ||
240 | 240 | ||
241 | TextLabel = new QLabel( this); | 241 | TextLabel = new QLabel( this); |
242 | TextLabel->setText( tr( "Markup" ) ); | 242 | TextLabel->setText( tr( "Markup" ) ); |
243 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 243 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
244 | Markup = new MenuButton( this); | 244 | Markup = new MenuButton( this); |
245 | Markup->insertItem("Auto"); | 245 | Markup->insertItem("Auto"); |
246 | Markup->insertItem("None"); | 246 | Markup->insertItem("None"); |
247 | Markup->insertItem("Text"); | 247 | Markup->insertItem("Text"); |
248 | Markup->insertItem("HTML"); | 248 | Markup->insertItem("HTML"); |
249 | Markup->insertItem("PML"); | 249 | Markup->insertItem("PML"); |
250 | vb->addWidget( Markup, 0, Qt::AlignLeft ); | 250 | vb->addWidget( Markup, 0, Qt::AlignLeft ); |
251 | 251 | ||
252 | TextLabel = new QLabel( this); | 252 | TextLabel = new QLabel( this); |
253 | TextLabel->setText( tr( "Font" ) ); | 253 | TextLabel->setText( tr( "Font" ) ); |
254 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 254 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
255 | fontselector = new MenuButton( this); | 255 | fontselector = new MenuButton( this); |
256 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 256 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
257 | { | 257 | { |
258 | FontDatabase f; | 258 | FontDatabase f; |
259 | QStringList flist = f.families(); | 259 | QStringList flist = f.families(); |
260 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 260 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
261 | { | 261 | { |
262 | fontselector->insertItem(*nm); | 262 | fontselector->insertItem(*nm); |
263 | } | 263 | } |
264 | } // delete the FontDatabase!!! | 264 | } // delete the FontDatabase!!! |
265 | vb->addWidget( fontselector, 0, Qt::AlignLeft ); | 265 | vb->addWidget( fontselector, 0, Qt::AlignLeft ); |
266 | 266 | ||
267 | vb->addStretch(); | 267 | vb->addStretch(); |
268 | } | 268 | } |
269 | */ | 269 | */ |
270 | /* | 270 | /* |
271 | * Destroys the object and frees any allocated resources | 271 | * Destroys the object and frees any allocated resources |
272 | */ | 272 | */ |
273 | CLayoutPrefs2::~CLayoutPrefs2() | 273 | CLayoutPrefs2::~CLayoutPrefs2() |
274 | { | 274 | { |
275 | // no need to delete child widgets, Qt does it all for us | 275 | // no need to delete child widgets, Qt does it all for us |
276 | } | 276 | } |
277 | 277 | ||
278 | /* | 278 | /* |
279 | CPluckerPrefs::CPluckerPrefs( QWidget* parent, const char* name, WFlags fl ) | 279 | CPluckerPrefs::CPluckerPrefs( QWidget* parent, const char* name, WFlags fl ) |
280 | : QWidget( parent, name, fl ) | 280 | : QWidget( parent, name, fl ) |
281 | { | 281 | { |
282 | Layout11 = new QVBoxLayout(this); | 282 | Layout11 = new QVBoxLayout(this); |
283 | Layout11->setMargin( 0 ); | 283 | Layout11->setMargin( 0 ); |
284 | 284 | ||
285 | Depluck = new QCheckBox( this, "Depluck" ); | 285 | Depluck = new QCheckBox( this, "Depluck" ); |
286 | Depluck->setText( tr( "Depluck" ) ); | 286 | Depluck->setText( tr( "Depluck" ) ); |
287 | Layout11->addWidget( Depluck ); | 287 | Layout11->addWidget( Depluck ); |
288 | 288 | ||
289 | Dejpluck = new QCheckBox( this, "Dejpluck" ); | 289 | Dejpluck = new QCheckBox( this, "Dejpluck" ); |
290 | Dejpluck->setText( tr( "Dejpluck" ) ); | 290 | Dejpluck->setText( tr( "Dejpluck" ) ); |
291 | Layout11->addWidget( Dejpluck ); | 291 | Layout11->addWidget( Dejpluck ); |
292 | 292 | ||
293 | Continuous = new QCheckBox( this, "Continuous" ); | 293 | Continuous = new QCheckBox( this, "Continuous" ); |
294 | Continuous->setText( tr( "Continuous" ) ); | 294 | Continuous->setText( tr( "Continuous" ) ); |
295 | Layout11->addWidget( Continuous ); | 295 | Layout11->addWidget( Continuous ); |
296 | 296 | ||
297 | } | 297 | } |
298 | 298 | ||
299 | CPluckerPrefs::~CPluckerPrefs() | 299 | CPluckerPrefs::~CPluckerPrefs() |
300 | { | 300 | { |
301 | // no need to delete child widgets, Qt does it all for us | 301 | // no need to delete child widgets, Qt does it all for us |
302 | } | 302 | } |
303 | */ | 303 | */ |
304 | /* | 304 | /* |
305 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) | 305 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) |
306 | : QWidget( parent, name, fl ) | 306 | : QWidget( parent, name, fl ) |
307 | { | 307 | { |
308 | 308 | ||
309 | QVBoxLayout* Layout11 = new QVBoxLayout(this); | 309 | QVBoxLayout* Layout11 = new QVBoxLayout(this); |
310 | Layout11->setMargin( 0 ); | 310 | Layout11->setMargin( 0 ); |
311 | 311 | ||
312 | 312 | ||
313 | QHBoxLayout* hl = new QHBoxLayout; | 313 | QHBoxLayout* hl = new QHBoxLayout; |
314 | 314 | ||
315 | QLabel* TextLabel = new QLabel( this ); | 315 | QLabel* TextLabel = new QLabel( this ); |
316 | TextLabel->setText( tr( "Action for\nSelect Button" ) ); | 316 | TextLabel->setText( tr( "Action for\nSelect Button" ) ); |
317 | hl->addWidget(TextLabel); | 317 | hl->addWidget(TextLabel); |
318 | 318 | ||
319 | action = new QComboBox( this ); | 319 | action = new QComboBox( this ); |
320 | action->insertItem("Open file"); | 320 | action->insertItem("Open file"); |
321 | action->insertItem("Autoscroll"); | 321 | action->insertItem("Autoscroll"); |
322 | action->insertItem("Mark"); | 322 | action->insertItem("Mark"); |
323 | action->insertItem("Annotate"); | 323 | action->insertItem("Annotate"); |
324 | action->insertItem("Fullscreen"); | 324 | action->insertItem("Fullscreen"); |
325 | hl->addWidget( action ); | 325 | hl->addWidget( action ); |
326 | 326 | ||
327 | Layout11->addLayout(hl); | 327 | Layout11->addLayout(hl); |
328 | 328 | ||
329 | hl = new QHBoxLayout; | 329 | hl = new QHBoxLayout; |
330 | 330 | ||
331 | TextLabel = new QLabel( this ); | 331 | TextLabel = new QLabel( this ); |
332 | TextLabel->setText( tr( "Dictionary\nApplication" ) ); | 332 | TextLabel->setText( tr( "Dictionary\nApplication" ) ); |
333 | hl->addWidget(TextLabel); | 333 | hl->addWidget(TextLabel); |
334 | target = new QLineEdit(this); | 334 | target = new QLineEdit(this); |
335 | hl->addWidget( target ); | 335 | hl->addWidget( target ); |
336 | 336 | ||
337 | Layout11->addLayout(hl); | 337 | Layout11->addLayout(hl); |
338 | 338 | ||
339 | 339 | ||
340 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Selection Target", this); | 340 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Selection Target", this); |
341 | Layout11->addWidget( bg ); | 341 | Layout11->addWidget( bg ); |
342 | 342 | ||
343 | annotation = new QCheckBox( bg ); | 343 | annotation = new QCheckBox( bg ); |
344 | annotation->setText( tr( "Annotation" ) ); | 344 | annotation->setText( tr( "Annotation" ) ); |
345 | 345 | ||
346 | dictionary = new QCheckBox( bg ); | 346 | dictionary = new QCheckBox( bg ); |
347 | dictionary->setText( tr( "Dictionary" ) ); | 347 | dictionary->setText( tr( "Dictionary" ) ); |
348 | 348 | ||
349 | clipboard = new QCheckBox( bg ); | 349 | clipboard = new QCheckBox( bg ); |
350 | clipboard->setText( tr( "Clipboard" ) ); | 350 | clipboard->setText( tr( "Clipboard" ) ); |
351 | 351 | ||
352 | } | 352 | } |
353 | 353 | ||
354 | CMiscPrefs::~CMiscPrefs() | 354 | CMiscPrefs::~CMiscPrefs() |
355 | { | 355 | { |
356 | // no need to delete child widgets, Qt does it all for us | 356 | // no need to delete child widgets, Qt does it all for us |
357 | } | 357 | } |
358 | */ | 358 | */ |
359 | 359 | ||
360 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) | 360 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) |
361 | : QWidget( parent, name, fl ) | 361 | : QWidget( parent, name, fl ) |
362 | { | 362 | { |
363 | 363 | ||
364 | QGridLayout* hl = new QGridLayout(this,1,2); | 364 | QGridLayout* hl = new QGridLayout(this,1,2); |
365 | 365 | ||
366 | hl->setMargin( 0 ); | 366 | hl->setMargin( 0 ); |
367 | 367 | ||
368 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Select Action", this); | 368 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("Select Action"), this); |
369 | hl->addWidget( gb, 0, 0 ); | 369 | hl->addWidget( gb, 0, 0 ); |
370 | 370 | ||
371 | annotation = new QCheckBox( gb ); | 371 | annotation = new QCheckBox( gb ); |
372 | annotation->setText( tr( "Annotation" ) ); | 372 | annotation->setText( tr( "Annotation" ) ); |
373 | 373 | ||
374 | dictionary = new QCheckBox( gb ); | 374 | dictionary = new QCheckBox( gb ); |
375 | dictionary->setText( tr( "Dictionary" ) ); | 375 | dictionary->setText( tr( "Dictionary" ) ); |
376 | 376 | ||
377 | clipboard = new QCheckBox( gb ); | 377 | clipboard = new QCheckBox( gb ); |
378 | clipboard->setText( tr( "Clipboard" ) ); | 378 | clipboard->setText( tr( "Clipboard" ) ); |
379 | 379 | ||
380 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Plucker", this); | 380 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, tr("Plucker"), this); |
381 | hl->addWidget( bg, 0 , 1 ); | 381 | hl->addWidget( bg, 0 , 1 ); |
382 | 382 | ||
383 | Depluck = new QCheckBox( bg ); | 383 | Depluck = new QCheckBox( bg ); |
384 | Depluck->setText( tr( "Depluck" ) ); | 384 | Depluck->setText( tr( "Depluck" ) ); |
385 | 385 | ||
386 | Dejpluck = new QCheckBox( bg ); | 386 | Dejpluck = new QCheckBox( bg ); |
387 | Dejpluck->setText( tr( "Dejpluck" ) ); | 387 | Dejpluck->setText( tr( "Dejpluck" ) ); |
388 | 388 | ||
389 | Continuous = new QCheckBox( bg ); | 389 | Continuous = new QCheckBox( bg ); |
390 | Continuous->setText( tr( "Continuous" ) ); | 390 | Continuous->setText( tr( "Continuous" ) ); |
391 | 391 | ||
392 | 392 | ||
393 | /* | 393 | /* |
394 | 394 | ||
395 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Navigation", this); | 395 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Navigation", this); |
396 | TextLabel = new QLabel( gb ); | 396 | TextLabel = new QLabel( gb ); |
397 | TextLabel->setText( tr( "Overlap" ) ); | 397 | TextLabel->setText( tr( "Overlap" ) ); |
398 | QSpinBox* sb = new QSpinBox( gb ); | 398 | QSpinBox* sb = new QSpinBox( gb ); |
399 | 399 | ||
400 | Internationalisation | 400 | Internationalisation |
401 | Ideogram/Word | 401 | Ideogram/Word |
402 | Set Width | 402 | Set Width |
403 | Set Encoding | 403 | Set Encoding |
404 | Set Font | 404 | Set Font |
405 | */ | 405 | */ |
406 | } | 406 | } |
407 | 407 | ||
408 | CMiscPrefs::~CMiscPrefs() | 408 | CMiscPrefs::~CMiscPrefs() |
409 | { | 409 | { |
410 | // no need to delete child widgets, Qt does it all for us | 410 | // no need to delete child widgets, Qt does it all for us |
411 | } | 411 | } |
412 | 412 | ||
413 | CPrefs::CPrefs(bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) | 413 | CPrefs::CPrefs(bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) |
414 | { | 414 | { |
415 | setCaption(tr( "OpieReader Settings" ) ); | 415 | setCaption(tr( "OpieReader Settings" ) ); |
416 | QTabWidget* td = new QTabWidget(this); | 416 | QTabWidget* td = new QTabWidget(this); |
417 | layout = new CLayoutPrefs(this); | 417 | layout = new CLayoutPrefs(this); |
418 | layout2 = new CLayoutPrefs2(this); | 418 | layout2 = new CLayoutPrefs2(this); |
419 | misc = new CMiscPrefs(this); | 419 | misc = new CMiscPrefs(this); |
420 | button = new CButtonPrefs(this); | 420 | button = new CButtonPrefs(this); |
421 | inter = new CInterPrefs(this); | 421 | inter = new CInterPrefs(this); |
422 | td->addTab(layout, tr("Layout")); | 422 | td->addTab(layout, tr("Layout")); |
423 | td->addTab(layout2, tr("Layout(2)")); | 423 | td->addTab(layout2, tr("Layout(2)")); |
424 | td->addTab(inter, tr("Locale")); | 424 | td->addTab(inter, tr("Locale")); |
425 | td->addTab(misc, tr("Misc")); | 425 | td->addTab(misc, tr("Misc")); |
426 | td->addTab(button, tr("Buttons")); | 426 | td->addTab(button, tr("Buttons")); |
427 | QVBoxLayout* v = new QVBoxLayout(this); | 427 | QVBoxLayout* v = new QVBoxLayout(this); |
428 | v->addWidget(td); | 428 | v->addWidget(td); |
429 | 429 | ||
430 | if (fs) showMaximized(); | 430 | if (fs) showMaximized(); |
431 | } | 431 | } |
432 | 432 | ||
433 | 433 | ||
434 | /* | 434 | /* |
435 | 435 | ||
436 | Unicode | 436 | Unicode |
437 | Ideo/Word | 437 | Ideo/Word |
438 | Width | 438 | Width |
439 | Encoding | 439 | Encoding |
440 | 440 | ||
441 | */ | 441 | */ |
442 | 442 | ||
443 | #include "CEncoding_tables.h" | 443 | #include "CEncoding_tables.h" |
444 | 444 | ||
445 | CInterPrefs::CInterPrefs( QWidget* parent, const char* name, WFlags fl ) | 445 | CInterPrefs::CInterPrefs( QWidget* parent, const char* name, WFlags fl ) |
446 | : QWidget( parent, name, fl ) | 446 | : QWidget( parent, name, fl ) |
447 | { | 447 | { |
448 | QHBoxLayout* hb = new QHBoxLayout(this); | 448 | QHBoxLayout* hb = new QHBoxLayout(this); |
449 | 449 | ||
450 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("International"), this); | 450 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("International"), this); |
451 | 451 | ||
452 | hb->addWidget(gb); | 452 | hb->addWidget(gb); |
453 | 453 | ||
454 | QLabel *TextLabel; | 454 | QLabel *TextLabel; |
455 | 455 | ||
456 | ideogram = new QCheckBox( gb ); | 456 | ideogram = new QCheckBox( gb ); |
457 | ideogram->setText( tr( "Ideograms" ) ); | 457 | ideogram->setText( tr( "Ideograms" ) ); |
458 | 458 | ||
459 | TextLabel = new QLabel( gb ); | 459 | TextLabel = new QLabel( gb ); |
460 | TextLabel->setText( tr( "Ideogram Width" ) ); | 460 | TextLabel->setText( tr( "Ideogram Width" ) ); |
461 | ideogramwidth = new QSpinBox( gb ); | 461 | ideogramwidth = new QSpinBox( gb ); |
462 | ideogramwidth->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 462 | ideogramwidth->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
463 | ideogramwidth->setRange(1,200); | 463 | ideogramwidth->setRange(1,200); |
464 | 464 | ||
465 | propfontchange = new QCheckBox( gb ); | 465 | propfontchange = new QCheckBox( gb ); |
466 | propfontchange->setText( tr( "Apply font\nto dialogs" ) ); | 466 | propfontchange->setText( tr( "Apply font\nto dialogs" ) ); |
467 | 467 | ||
468 | TextLabel = new QLabel( gb ); | 468 | TextLabel = new QLabel( gb ); |
469 | TextLabel->setText( tr( "Encoding" ) ); | 469 | TextLabel->setText( tr( "Encoding" ) ); |
470 | #ifdef USECOMBO | 470 | #ifdef USECOMBO |
471 | encoding = new QComboBox(gb); | 471 | encoding = new QComboBox(gb); |
472 | #else | 472 | #else |
473 | encoding = new MenuButton(gb); | 473 | encoding = new MenuButton(gb); |
474 | #endif | 474 | #endif |
475 | encoding->insertItem("Ascii"); | 475 | encoding->insertItem("Ascii"); |
476 | encoding->insertItem("UTF-8"); | 476 | encoding->insertItem("UTF-8"); |
477 | encoding->insertItem("UCS-2(BE)"); | 477 | encoding->insertItem("UCS-2(BE)"); |
478 | encoding->insertItem("USC-2(LE)"); | 478 | encoding->insertItem("USC-2(LE)"); |
479 | encoding->insertItem("Palm"); | 479 | encoding->insertItem("Palm"); |
480 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) | 480 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) |
481 | { | 481 | { |
482 | encoding->insertItem(iter->mime); | 482 | encoding->insertItem(iter->mime); |
483 | } | 483 | } |
484 | 484 | ||
485 | QVBoxLayout* vb = new QVBoxLayout; | 485 | QVBoxLayout* vb = new QVBoxLayout; |
486 | 486 | ||
487 | gb = new QGroupBox(1, Qt::Horizontal, "Dictionary", this); | 487 | gb = new QGroupBox(1, Qt::Horizontal, tr("Dictionary"), this); |
488 | 488 | ||
489 | TextLabel = new QLabel( gb ); | 489 | TextLabel = new QLabel( gb ); |
490 | TextLabel->setText( tr( "Application" ) ); | 490 | TextLabel->setText( tr( "Application" ) ); |
491 | application = new QLineEdit(gb); | 491 | application = new QLineEdit(gb); |
492 | application->setFixedWidth(80); | 492 | application->setFixedWidth(80); |
493 | 493 | ||
494 | TextLabel = new QLabel( gb ); | 494 | TextLabel = new QLabel( gb ); |
495 | TextLabel->setText( tr( "Message" ) ); | 495 | TextLabel->setText( tr( "Message" ) ); |
496 | message = new QLineEdit(gb); | 496 | message = new QLineEdit(gb); |
497 | message->setFixedWidth(80); | 497 | message->setFixedWidth(80); |
498 | // message->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 498 | // message->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
499 | twotouch = new QCheckBox( gb ); | 499 | twotouch = new QCheckBox( gb ); |
500 | twotouch->setText( tr( "Two/One\nTouch" ) ); | 500 | twotouch->setText( tr( "Two/One\nTouch" ) ); |
501 | 501 | ||
502 | SwapMouse = new QCheckBox( gb ); | 502 | SwapMouse = new QCheckBox( gb ); |
503 | SwapMouse->setText("Swap Tap\nActions"); | 503 | SwapMouse->setText(tr("Swap Tap\nActions") ); |
504 | 504 | ||
505 | 505 | ||
506 | vb->addWidget(gb); | 506 | vb->addWidget(gb); |
507 | 507 | ||
508 | // vb->addStretch(); | 508 | // vb->addStretch(); |
509 | hb->addLayout(vb); | 509 | hb->addLayout(vb); |
510 | } | 510 | } |
511 | 511 | ||
512 | CInterPrefs::~CInterPrefs() | 512 | CInterPrefs::~CInterPrefs() |
513 | { | 513 | { |
514 | // no need to delete child widgets, Qt does it all for us | 514 | // no need to delete child widgets, Qt does it all for us |
515 | } | 515 | } |
516 | 516 | ||
517 | 517 | ||
518 | 518 | ||
519 | #ifdef USECOMBO | 519 | #ifdef USECOMBO |
520 | void CButtonPrefs::populate(QComboBox *mb) | 520 | void CButtonPrefs::populate(QComboBox *mb) |
521 | #else | 521 | #else |
522 | void CButtonPrefs::populate(MenuButton *mb) | 522 | void CButtonPrefs::populate(MenuButton *mb) |
523 | #endif | 523 | #endif |
524 | { | 524 | { |
525 | mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 525 | mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
526 | mb->insertItem("<Nothing>"); | 526 | mb->insertItem(tr("<Nothing>") ); |
527 | mb->insertItem("Open file"); | 527 | mb->insertItem(tr("Open file") ); |
528 | mb->insertItem("Autoscroll"); | 528 | mb->insertItem(tr("Autoscroll") ); |
529 | mb->insertItem("Bookmark"); | 529 | mb->insertItem(tr("Bookmark") ); |
530 | mb->insertItem("Annotate"); | 530 | mb->insertItem(tr("Annotate") ); |
531 | mb->insertItem("Fullscreen"); | 531 | mb->insertItem(tr("Fullscreen") ); |
532 | 532 | ||
533 | mb->insertItem("Zoom in"); | 533 | mb->insertItem(tr("Zoom in") ); |
534 | mb->insertItem("Zoom out"); | 534 | mb->insertItem(tr("Zoom out") ); |
535 | mb->insertItem("Back"); | 535 | mb->insertItem(tr("Back") ); |
536 | mb->insertItem("Forward"); | 536 | mb->insertItem(tr("Forward") ); |
537 | mb->insertItem("Home"); | 537 | mb->insertItem(tr("Home") ); |
538 | mb->insertItem("Page up"); | 538 | mb->insertItem(tr("Page up") ); |
539 | mb->insertItem("Page down"); | 539 | mb->insertItem(tr("Page down") ); |
540 | mb->insertItem("Line up"); | 540 | mb->insertItem(tr("Line up") ); |
541 | mb->insertItem("Line down"); | 541 | mb->insertItem(tr("Line down") ); |
542 | mb->insertItem("Beginning"); | 542 | mb->insertItem(tr("Beginning") ); |
543 | mb->insertItem("End"); | 543 | mb->insertItem(tr("End") ); |
544 | } | 544 | } |
545 | 545 | ||
546 | CButtonPrefs::CButtonPrefs( QWidget* parent, const char* name, WFlags fl ) | 546 | CButtonPrefs::CButtonPrefs( QWidget* parent, const char* name, WFlags fl ) |
547 | : QWidget( parent, name, fl ) | 547 | : QWidget( parent, name, fl ) |
548 | { | 548 | { |
549 | 549 | ||
550 | QGridLayout* hl = new QGridLayout(this,10,2); | 550 | QGridLayout* hl = new QGridLayout(this,10,2); |
551 | 551 | ||
552 | hl->setMargin( 0 ); | 552 | hl->setMargin( 0 ); |
553 | 553 | ||
554 | QLabel* ql = new QLabel("Escape Button", this); | 554 | QLabel* ql = new QLabel(tr("Escape Button"), this); |
555 | hl->addWidget(ql, 0, 0, Qt::AlignBottom); | 555 | hl->addWidget(ql, 0, 0, Qt::AlignBottom); |
556 | #ifdef USECOMBO | 556 | #ifdef USECOMBO |
557 | escapeAction = new QComboBox( this ); | 557 | escapeAction = new QComboBox( this ); |
558 | #else | 558 | #else |
559 | escapeAction = new MenuButton( this ); | 559 | escapeAction = new MenuButton( this ); |
560 | #endif | 560 | #endif |
561 | populate(escapeAction); | 561 | populate(escapeAction); |
562 | hl->addWidget(escapeAction, 1, 0, Qt::AlignTop | Qt::AlignLeft); | 562 | hl->addWidget(escapeAction, 1, 0, Qt::AlignTop | Qt::AlignLeft); |
563 | 563 | ||
564 | ql = new QLabel("Space Button", this); | 564 | ql = new QLabel(tr("Space Button"), this); |
565 | hl->addWidget(ql, 2, 0, Qt::AlignBottom); | 565 | hl->addWidget(ql, 2, 0, Qt::AlignBottom); |
566 | #ifdef USECOMBO | 566 | #ifdef USECOMBO |
567 | spaceAction = new QComboBox( this ); | 567 | spaceAction = new QComboBox( this ); |
568 | #else | 568 | #else |
569 | spaceAction = new MenuButton( this ); | 569 | spaceAction = new MenuButton( this ); |
570 | #endif | 570 | #endif |
571 | populate(spaceAction); | 571 | populate(spaceAction); |
572 | hl->addWidget(spaceAction, 3, 0, Qt::AlignTop | Qt::AlignLeft); | 572 | hl->addWidget(spaceAction, 3, 0, Qt::AlignTop | Qt::AlignLeft); |
573 | 573 | ||
574 | ql = new QLabel("Return Button", this); | 574 | ql = new QLabel(tr("Return Button"), this); |
575 | hl->addWidget(ql, 2, 1, Qt::AlignBottom); | 575 | hl->addWidget(ql, 2, 1, Qt::AlignBottom); |
576 | #ifdef USECOMBO | 576 | #ifdef USECOMBO |
577 | returnAction = new QComboBox( this ); | 577 | returnAction = new QComboBox( this ); |
578 | #else | 578 | #else |
579 | returnAction = new MenuButton( this ); | 579 | returnAction = new MenuButton( this ); |
580 | #endif | 580 | #endif |
581 | populate(returnAction); | 581 | populate(returnAction); |
582 | hl->addWidget(returnAction, 3, 1, Qt::AlignTop | Qt::AlignLeft); | 582 | hl->addWidget(returnAction, 3, 1, Qt::AlignTop | Qt::AlignLeft); |
583 | 583 | ||
584 | ql = new QLabel("Left Arrow", this); | 584 | ql = new QLabel(tr("Left Arrow"), this); |
585 | hl->addWidget(ql, 4, 0, Qt::AlignBottom); | 585 | hl->addWidget(ql, 4, 0, Qt::AlignBottom); |
586 | #ifdef USECOMBO | 586 | #ifdef USECOMBO |
587 | leftAction = new QComboBox( this ); | 587 | leftAction = new QComboBox( this ); |
588 | #else | 588 | #else |
589 | leftAction = new MenuButton( this ); | 589 | leftAction = new MenuButton( this ); |
590 | #endif | 590 | #endif |
591 | populate(leftAction); | 591 | populate(leftAction); |
592 | hl->addWidget(leftAction, 5, 0, Qt::AlignTop | Qt::AlignLeft); | 592 | hl->addWidget(leftAction, 5, 0, Qt::AlignTop | Qt::AlignLeft); |
593 | leftScroll = new QCheckBox( tr("Scroll Speed"), this ); | 593 | leftScroll = new QCheckBox( tr("Scroll Speed"), this ); |
594 | hl->addWidget(leftScroll, 6, 0, Qt::AlignTop | Qt::AlignLeft); | 594 | hl->addWidget(leftScroll, 6, 0, Qt::AlignTop | Qt::AlignLeft); |
595 | 595 | ||
596 | ql = new QLabel("Right Arrow", this); | 596 | ql = new QLabel(tr("Right Arrow"), this); |
597 | hl->addWidget(ql, 4, 1, Qt::AlignBottom); | 597 | hl->addWidget(ql, 4, 1, Qt::AlignBottom); |
598 | #ifdef USECOMBO | 598 | #ifdef USECOMBO |
599 | rightAction = new QComboBox( this ); | 599 | rightAction = new QComboBox( this ); |
600 | #else | 600 | #else |
601 | rightAction = new MenuButton( this ); | 601 | rightAction = new MenuButton( this ); |
602 | #endif | 602 | #endif |
603 | populate(rightAction); | 603 | populate(rightAction); |
604 | hl->addWidget(rightAction, 5, 1, Qt::AlignTop | Qt::AlignLeft); | 604 | hl->addWidget(rightAction, 5, 1, Qt::AlignTop | Qt::AlignLeft); |
605 | rightScroll = new QCheckBox( tr("Scroll Speed"), this ); | 605 | rightScroll = new QCheckBox( tr("Scroll Speed"), this ); |
606 | hl->addWidget(rightScroll, 6, 1, Qt::AlignTop | Qt::AlignLeft); | 606 | hl->addWidget(rightScroll, 6, 1, Qt::AlignTop | Qt::AlignLeft); |
607 | 607 | ||
608 | ql = new QLabel("Down Arrow", this); | 608 | ql = new QLabel(tr("Down Arrow"), this); |
609 | hl->addWidget(ql, 7, 0, Qt::AlignBottom); | 609 | hl->addWidget(ql, 7, 0, Qt::AlignBottom); |
610 | #ifdef USECOMBO | 610 | #ifdef USECOMBO |
611 | downAction = new QComboBox( this ); | 611 | downAction = new QComboBox( this ); |
612 | #else | 612 | #else |
613 | downAction = new MenuButton( this ); | 613 | downAction = new MenuButton( this ); |
614 | #endif | 614 | #endif |
615 | populate(downAction); | 615 | populate(downAction); |
616 | hl->addWidget(downAction, 8, 0, Qt::AlignTop | Qt::AlignLeft); | 616 | hl->addWidget(downAction, 8, 0, Qt::AlignTop | Qt::AlignLeft); |
617 | downScroll = new QCheckBox( tr("Scroll Speed"), this ); | 617 | downScroll = new QCheckBox( tr("Scroll Speed"), this ); |
618 | hl->addWidget(downScroll, 9, 0, Qt::AlignTop | Qt::AlignLeft); | 618 | hl->addWidget(downScroll, 9, 0, Qt::AlignTop | Qt::AlignLeft); |
619 | 619 | ||
620 | ql = new QLabel("Up Arrow", this); | 620 | ql = new QLabel(tr("Up Arrow"), this); |
621 | hl->addWidget(ql, 7, 1, Qt::AlignBottom); | 621 | hl->addWidget(ql, 7, 1, Qt::AlignBottom); |
622 | #ifdef USECOMBO | 622 | #ifdef USECOMBO |
623 | upAction = new QComboBox( this ); | 623 | upAction = new QComboBox( this ); |
624 | #else | 624 | #else |
625 | upAction = new MenuButton( this ); | 625 | upAction = new MenuButton( this ); |
626 | #endif | 626 | #endif |
627 | populate(upAction); | 627 | populate(upAction); |
628 | hl->addWidget(upAction, 8, 1, Qt::AlignTop | Qt::AlignLeft); | 628 | hl->addWidget(upAction, 8, 1, Qt::AlignTop | Qt::AlignLeft); |
629 | upScroll = new QCheckBox( tr("Scroll Speed"), this ); | 629 | upScroll = new QCheckBox( tr("Scroll Speed"), this ); |
630 | hl->addWidget(upScroll, 9, 1, Qt::AlignTop | Qt::AlignLeft); | 630 | hl->addWidget(upScroll, 9, 1, Qt::AlignTop | Qt::AlignLeft); |
631 | } | 631 | } |
632 | 632 | ||
633 | CButtonPrefs::~CButtonPrefs() | 633 | CButtonPrefs::~CButtonPrefs() |
634 | { | 634 | { |
635 | // no need to delete child widgets, Qt does it all for us | 635 | // no need to delete child widgets, Qt does it all for us |
636 | } | 636 | } |
diff --git a/noncore/apps/opie-reader/Prefs.h b/noncore/apps/opie-reader/Prefs.h index 37d8c9e..8fef2f5 100644 --- a/noncore/apps/opie-reader/Prefs.h +++ b/noncore/apps/opie-reader/Prefs.h | |||
@@ -1,340 +1,341 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form interface generated from reading ui file 'Prefs.ui' | 2 | ** Form interface generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:32 2003 | 4 | ** Created: Tue Feb 11 23:53:32 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #ifndef CPREFS_H | 9 | #ifndef CPREFS_H |
10 | #define CPREFS_H | 10 | #define CPREFS_H |
11 | #include "useqpe.h" | 11 | #include "useqpe.h" |
12 | #include <qvariant.h> | 12 | #include <qvariant.h> |
13 | #include <qwidget.h> | 13 | #include <qwidget.h> |
14 | #include <qtabdialog.h> | 14 | #include <qtabdialog.h> |
15 | #include <qtabwidget.h> | 15 | #include <qtabwidget.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qcombobox.h> | 18 | #include <qcombobox.h> |
19 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
20 | #ifdef USEQPE | 20 | #ifdef USEQPE |
21 | #include <qpe/menubutton.h> | 21 | #include <qpe/menubutton.h> |
22 | #endif | 22 | #endif |
23 | //#include "opie.h" | 23 | //#include "opie.h" |
24 | 24 | ||
25 | //#ifdef OPIE | 25 | //#ifdef OPIE |
26 | #define USECOMBO | 26 | #define USECOMBO |
27 | //#endif | 27 | //#endif |
28 | 28 | ||
29 | class QVBoxLayout; | 29 | class QVBoxLayout; |
30 | class QHBoxLayout; | 30 | class QHBoxLayout; |
31 | class QGridLayout; | 31 | class QGridLayout; |
32 | //class QCheckBox; | 32 | //class QCheckBox; |
33 | class QLabel; | 33 | class QLabel; |
34 | //class QSpinBox; | 34 | //class QSpinBox; |
35 | 35 | ||
36 | class CLayoutPrefs : public QWidget | 36 | class CLayoutPrefs : public QWidget |
37 | { | 37 | { |
38 | 38 | Q_OBJECT | |
39 | public: | 39 | public: |
40 | 40 | ||
41 | friend class CPrefs; | 41 | friend class CPrefs; |
42 | 42 | ||
43 | CLayoutPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 43 | CLayoutPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
44 | ~CLayoutPrefs(); | 44 | ~CLayoutPrefs(); |
45 | 45 | ||
46 | QCheckBox* StripCR; | 46 | QCheckBox* StripCR; |
47 | QCheckBox* Dehyphen; | 47 | QCheckBox* Dehyphen; |
48 | QCheckBox* SingleSpace; | 48 | QCheckBox* SingleSpace; |
49 | QCheckBox* Unindent; | 49 | QCheckBox* Unindent; |
50 | QCheckBox* Reparagraph; | 50 | QCheckBox* Reparagraph; |
51 | QCheckBox* DoubleSpace; | 51 | QCheckBox* DoubleSpace; |
52 | QCheckBox* Remap; | 52 | QCheckBox* Remap; |
53 | QCheckBox* Embolden; | 53 | QCheckBox* Embolden; |
54 | QCheckBox* FullJustify; | 54 | QCheckBox* FullJustify; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | class CLayoutPrefs2 : public QWidget | 57 | class CLayoutPrefs2 : public QWidget |
58 | { | 58 | { |
59 | 59 | Q_OBJECT | |
60 | public: | 60 | public: |
61 | 61 | ||
62 | friend class CPrefs; | 62 | friend class CPrefs; |
63 | 63 | ||
64 | CLayoutPrefs2( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 64 | CLayoutPrefs2( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
65 | ~CLayoutPrefs2(); | 65 | ~CLayoutPrefs2(); |
66 | 66 | ||
67 | QSpinBox* ParaLead; | 67 | QSpinBox* ParaLead; |
68 | QSpinBox* LineLead; | 68 | QSpinBox* LineLead; |
69 | QSpinBox* Indent; | 69 | QSpinBox* Indent; |
70 | QSpinBox* Margin, *gfxzoom, *pageoverlap; | 70 | QSpinBox* Margin, *gfxzoom, *pageoverlap; |
71 | #ifdef USECOMBO | 71 | #ifdef USECOMBO |
72 | QComboBox *Markup, *fontselector; | 72 | QComboBox *Markup, *fontselector; |
73 | #else | 73 | #else |
74 | MenuButton *Markup, *fontselector; | 74 | MenuButton *Markup, *fontselector; |
75 | #endif | 75 | #endif |
76 | }; | 76 | }; |
77 | 77 | ||
78 | /* | 78 | /* |
79 | class CPluckerPrefs : public QWidget | 79 | class CPluckerPrefs : public QWidget |
80 | { | 80 | { |
81 | 81 | ||
82 | public: | 82 | public: |
83 | 83 | ||
84 | friend class CPrefs; | 84 | friend class CPrefs; |
85 | 85 | ||
86 | CPluckerPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 86 | CPluckerPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
87 | ~CPluckerPrefs(); | 87 | ~CPluckerPrefs(); |
88 | 88 | ||
89 | QCheckBox* Depluck; | 89 | QCheckBox* Depluck; |
90 | QCheckBox* Dejpluck; | 90 | QCheckBox* Dejpluck; |
91 | QCheckBox* Continuous; | 91 | QCheckBox* Continuous; |
92 | protected: | 92 | protected: |
93 | 93 | ||
94 | QHBoxLayout* Layout5; | 94 | QHBoxLayout* Layout5; |
95 | QVBoxLayout* Layout11; | 95 | QVBoxLayout* Layout11; |
96 | QGridLayout* Layout4; | 96 | QGridLayout* Layout4; |
97 | 97 | ||
98 | }; | 98 | }; |
99 | */ | 99 | */ |
100 | class CMiscPrefs : public QWidget | 100 | class CMiscPrefs : public QWidget |
101 | { | 101 | { |
102 | 102 | Q_OBJECT | |
103 | public: | 103 | public: |
104 | 104 | ||
105 | friend class CPrefs; | 105 | friend class CPrefs; |
106 | 106 | ||
107 | CMiscPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 107 | CMiscPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
108 | ~CMiscPrefs(); | 108 | ~CMiscPrefs(); |
109 | 109 | ||
110 | QCheckBox *annotation, *dictionary, *clipboard; | 110 | QCheckBox *annotation, *dictionary, *clipboard; |
111 | QCheckBox *Depluck, *Dejpluck, *Continuous; | 111 | QCheckBox *Depluck, *Dejpluck, *Continuous; |
112 | }; | 112 | }; |
113 | 113 | ||
114 | class CButtonPrefs : public QWidget | 114 | class CButtonPrefs : public QWidget |
115 | { | 115 | { |
116 | Q_OBJECT | ||
116 | #ifdef USECOMBO | 117 | #ifdef USECOMBO |
117 | void populate(QComboBox*); | 118 | void populate(QComboBox*); |
118 | #else | 119 | #else |
119 | void populate(MenuButton*); | 120 | void populate(MenuButton*); |
120 | #endif | 121 | #endif |
121 | public: | 122 | public: |
122 | 123 | ||
123 | friend class CPrefs; | 124 | friend class CPrefs; |
124 | 125 | ||
125 | CButtonPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 126 | CButtonPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
126 | ~CButtonPrefs(); | 127 | ~CButtonPrefs(); |
127 | 128 | ||
128 | #ifdef USECOMBO | 129 | #ifdef USECOMBO |
129 | QComboBox *returnAction, *spaceAction, *escapeAction, *leftAction, *rightAction, *upAction, *downAction; | 130 | QComboBox *returnAction, *spaceAction, *escapeAction, *leftAction, *rightAction, *upAction, *downAction; |
130 | #else | 131 | #else |
131 | MenuButton *returnAction, *spaceAction, *escapeAction, *leftAction, *rightAction, *upAction, *downAction; | 132 | MenuButton *returnAction, *spaceAction, *escapeAction, *leftAction, *rightAction, *upAction, *downAction; |
132 | #endif | 133 | #endif |
133 | QCheckBox *leftScroll, *rightScroll, *upScroll, *downScroll; | 134 | QCheckBox *leftScroll, *rightScroll, *upScroll, *downScroll; |
134 | }; | 135 | }; |
135 | 136 | ||
136 | class CInterPrefs : public QWidget | 137 | class CInterPrefs : public QWidget |
137 | { | 138 | { |
138 | 139 | Q_OBJECT | |
139 | public: | 140 | public: |
140 | 141 | ||
141 | friend class CPrefs; | 142 | friend class CPrefs; |
142 | 143 | ||
143 | CInterPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 144 | CInterPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
144 | ~CInterPrefs(); | 145 | ~CInterPrefs(); |
145 | 146 | ||
146 | QCheckBox *ideogram, *propfontchange, *SwapMouse, *twotouch; | 147 | QCheckBox *ideogram, *propfontchange, *SwapMouse, *twotouch; |
147 | #ifdef USECOMBO | 148 | #ifdef USECOMBO |
148 | QComboBox* encoding; | 149 | QComboBox* encoding; |
149 | #else | 150 | #else |
150 | MenuButton* encoding; | 151 | MenuButton* encoding; |
151 | #endif | 152 | #endif |
152 | QSpinBox* ideogramwidth; | 153 | QSpinBox* ideogramwidth; |
153 | QLineEdit *application, *message; | 154 | QLineEdit *application, *message; |
154 | }; | 155 | }; |
155 | 156 | ||
156 | 157 | ||
157 | class CPrefs : public QDialog | 158 | class CPrefs : public QDialog |
158 | { | 159 | { |
159 | Q_OBJECT | 160 | Q_OBJECT |
160 | CLayoutPrefs* layout; | 161 | CLayoutPrefs* layout; |
161 | CLayoutPrefs2* layout2; | 162 | CLayoutPrefs2* layout2; |
162 | CMiscPrefs* misc; | 163 | CMiscPrefs* misc; |
163 | CButtonPrefs* button; | 164 | CButtonPrefs* button; |
164 | CInterPrefs* inter; | 165 | CInterPrefs* inter; |
165 | 166 | ||
166 | void keyPressEvent(QKeyEvent* e) | 167 | void keyPressEvent(QKeyEvent* e) |
167 | { | 168 | { |
168 | switch (e->key()) | 169 | switch (e->key()) |
169 | { | 170 | { |
170 | case Key_Escape: | 171 | case Key_Escape: |
171 | e->accept(); | 172 | e->accept(); |
172 | reject(); | 173 | reject(); |
173 | break; | 174 | break; |
174 | case Key_Space: | 175 | case Key_Space: |
175 | case Key_Return: | 176 | case Key_Return: |
176 | e->accept(); | 177 | e->accept(); |
177 | accept(); | 178 | accept(); |
178 | break; | 179 | break; |
179 | default: | 180 | default: |
180 | QWidget::keyPressEvent(e); | 181 | QWidget::keyPressEvent(e); |
181 | } | 182 | } |
182 | } | 183 | } |
183 | public: | 184 | public: |
184 | CPrefs(bool fs = true, QWidget* parent = 0, const char* name = 0); | 185 | CPrefs(bool fs = true, QWidget* parent = 0, const char* name = 0); |
185 | ~CPrefs() | 186 | ~CPrefs() |
186 | { | 187 | { |
187 | } | 188 | } |
188 | bool StripCR() { return layout->StripCR->isChecked(); } | 189 | bool StripCR() { return layout->StripCR->isChecked(); } |
189 | bool Dehyphen() { return layout->Dehyphen->isChecked(); } | 190 | bool Dehyphen() { return layout->Dehyphen->isChecked(); } |
190 | bool SingleSpace() { return layout->SingleSpace->isChecked(); } | 191 | bool SingleSpace() { return layout->SingleSpace->isChecked(); } |
191 | bool Unindent() { return layout->Unindent->isChecked(); } | 192 | bool Unindent() { return layout->Unindent->isChecked(); } |
192 | bool Reparagraph() { return layout->Reparagraph->isChecked(); } | 193 | bool Reparagraph() { return layout->Reparagraph->isChecked(); } |
193 | bool DoubleSpace() { return layout->DoubleSpace->isChecked(); } | 194 | bool DoubleSpace() { return layout->DoubleSpace->isChecked(); } |
194 | bool Remap() { return layout->Remap->isChecked(); } | 195 | bool Remap() { return layout->Remap->isChecked(); } |
195 | bool Embolden() { return layout->Embolden->isChecked(); } | 196 | bool Embolden() { return layout->Embolden->isChecked(); } |
196 | bool FullJustify() { return layout->FullJustify->isChecked(); } | 197 | bool FullJustify() { return layout->FullJustify->isChecked(); } |
197 | int ParaLead() { return layout2->ParaLead->value(); } | 198 | int ParaLead() { return layout2->ParaLead->value(); } |
198 | int LineLead() { return layout2->LineLead->value(); } | 199 | int LineLead() { return layout2->LineLead->value(); } |
199 | int Margin() { return layout2->Margin->value(); } | 200 | int Margin() { return layout2->Margin->value(); } |
200 | int Indent() { return layout2->Indent->value(); } | 201 | int Indent() { return layout2->Indent->value(); } |
201 | int Markup() { return layout2->Markup->currentItem(); } | 202 | int Markup() { return layout2->Markup->currentItem(); } |
202 | QString Font() { return layout2->fontselector->currentText(); } | 203 | QString Font() { return layout2->fontselector->currentText(); } |
203 | 204 | ||
204 | 205 | ||
205 | void StripCR(bool v) { layout->StripCR->setChecked(v); } | 206 | void StripCR(bool v) { layout->StripCR->setChecked(v); } |
206 | void Dehyphen(bool v) { layout->Dehyphen->setChecked(v); } | 207 | void Dehyphen(bool v) { layout->Dehyphen->setChecked(v); } |
207 | void SingleSpace(bool v) { layout->SingleSpace->setChecked(v); } | 208 | void SingleSpace(bool v) { layout->SingleSpace->setChecked(v); } |
208 | void Unindent(bool v) { layout->Unindent->setChecked(v); } | 209 | void Unindent(bool v) { layout->Unindent->setChecked(v); } |
209 | void Reparagraph(bool v) { layout->Reparagraph->setChecked(v); } | 210 | void Reparagraph(bool v) { layout->Reparagraph->setChecked(v); } |
210 | void DoubleSpace(bool v) { layout->DoubleSpace->setChecked(v); } | 211 | void DoubleSpace(bool v) { layout->DoubleSpace->setChecked(v); } |
211 | void Remap(bool v) { layout->Remap->setChecked(v); } | 212 | void Remap(bool v) { layout->Remap->setChecked(v); } |
212 | void Embolden(bool v) { layout->Embolden->setChecked(v); } | 213 | void Embolden(bool v) { layout->Embolden->setChecked(v); } |
213 | void FullJustify(bool v) { layout->FullJustify->setChecked(v); } | 214 | void FullJustify(bool v) { layout->FullJustify->setChecked(v); } |
214 | void ParaLead(int v) { layout2->ParaLead->setValue(v); } | 215 | void ParaLead(int v) { layout2->ParaLead->setValue(v); } |
215 | void LineLead(int v) { layout2->LineLead->setValue(v); } | 216 | void LineLead(int v) { layout2->LineLead->setValue(v); } |
216 | void Margin(int v) { layout2->Margin->setValue(v); } | 217 | void Margin(int v) { layout2->Margin->setValue(v); } |
217 | void Indent(int v) { layout2->Indent->setValue(v); } | 218 | void Indent(int v) { layout2->Indent->setValue(v); } |
218 | #ifdef USECOMBO | 219 | #ifdef USECOMBO |
219 | void Markup(int v) { layout2->Markup->setCurrentItem(v); } | 220 | void Markup(int v) { layout2->Markup->setCurrentItem(v); } |
220 | #else | 221 | #else |
221 | void Markup(int v) { layout2->Markup->select(v); } | 222 | void Markup(int v) { layout2->Markup->select(v); } |
222 | #endif | 223 | #endif |
223 | #ifdef USECOMBO | 224 | #ifdef USECOMBO |
224 | void Font(QString& s) | 225 | void Font(QString& s) |
225 | { | 226 | { |
226 | for (int i = 1; i <= layout2->fontselector->count(); i++) | 227 | for (int i = 1; i <= layout2->fontselector->count(); i++) |
227 | { | 228 | { |
228 | if (layout2->fontselector->text(i) == s) | 229 | if (layout2->fontselector->text(i) == s) |
229 | { | 230 | { |
230 | layout2->fontselector->setCurrentItem(i); | 231 | layout2->fontselector->setCurrentItem(i); |
231 | break; | 232 | break; |
232 | } | 233 | } |
233 | } | 234 | } |
234 | } | 235 | } |
235 | #else | 236 | #else |
236 | void Font(QString& s) { layout2->fontselector->select(s); } | 237 | void Font(QString& s) { layout2->fontselector->select(s); } |
237 | #endif | 238 | #endif |
238 | 239 | ||
239 | bool Depluck() { return misc->Depluck->isChecked(); } | 240 | bool Depluck() { return misc->Depluck->isChecked(); } |
240 | void Depluck(bool v) { misc->Depluck->setChecked(v); } | 241 | void Depluck(bool v) { misc->Depluck->setChecked(v); } |
241 | bool Dejpluck() { return misc->Dejpluck->isChecked(); } | 242 | bool Dejpluck() { return misc->Dejpluck->isChecked(); } |
242 | void Dejpluck(bool v) { misc->Dejpluck->setChecked(v); } | 243 | void Dejpluck(bool v) { misc->Dejpluck->setChecked(v); } |
243 | bool Continuous() { return misc->Continuous->isChecked(); } | 244 | bool Continuous() { return misc->Continuous->isChecked(); } |
244 | void Continuous(bool v) { misc->Continuous->setChecked(v); } | 245 | void Continuous(bool v) { misc->Continuous->setChecked(v); } |
245 | bool SwapMouse() { return inter->SwapMouse->isChecked(); } | 246 | bool SwapMouse() { return inter->SwapMouse->isChecked(); } |
246 | void SwapMouse(bool v) { inter->SwapMouse->setChecked(v); } | 247 | void SwapMouse(bool v) { inter->SwapMouse->setChecked(v); } |
247 | 248 | ||
248 | 249 | ||
249 | void dictApplication(const QString& v) { inter->application->setText(v); } | 250 | void dictApplication(const QString& v) { inter->application->setText(v); } |
250 | QString dictApplication() { return inter->application->text(); } | 251 | QString dictApplication() { return inter->application->text(); } |
251 | void dictMessage(const QString& v) { inter->message->setText(v); } | 252 | void dictMessage(const QString& v) { inter->message->setText(v); } |
252 | QString dictMessage() { return inter->message->text(); } | 253 | QString dictMessage() { return inter->message->text(); } |
253 | 254 | ||
254 | void miscannotation(bool v) { misc->annotation->setChecked(v); } | 255 | void miscannotation(bool v) { misc->annotation->setChecked(v); } |
255 | void miscdictionary(bool v) { misc->dictionary->setChecked(v); } | 256 | void miscdictionary(bool v) { misc->dictionary->setChecked(v); } |
256 | void miscclipboard(bool v) { misc->clipboard->setChecked(v); } | 257 | void miscclipboard(bool v) { misc->clipboard->setChecked(v); } |
257 | bool miscannotation() { return misc->annotation->isChecked(); } | 258 | bool miscannotation() { return misc->annotation->isChecked(); } |
258 | bool miscdictionary() { return misc->dictionary->isChecked(); } | 259 | bool miscdictionary() { return misc->dictionary->isChecked(); } |
259 | bool miscclipboard() { return misc->clipboard->isChecked(); } | 260 | bool miscclipboard() { return misc->clipboard->isChecked(); } |
260 | 261 | ||
261 | int spaceAction() { return button->spaceAction->currentItem(); } | 262 | int spaceAction() { return button->spaceAction->currentItem(); } |
262 | #ifdef USECOMBO | 263 | #ifdef USECOMBO |
263 | void spaceAction(int v) { button->spaceAction->setCurrentItem(v); } | 264 | void spaceAction(int v) { button->spaceAction->setCurrentItem(v); } |
264 | #else | 265 | #else |
265 | void spaceAction(int v) { button->spaceAction->select(v); } | 266 | void spaceAction(int v) { button->spaceAction->select(v); } |
266 | #endif | 267 | #endif |
267 | int escapeAction() { return button->escapeAction->currentItem(); } | 268 | int escapeAction() { return button->escapeAction->currentItem(); } |
268 | #ifdef USECOMBO | 269 | #ifdef USECOMBO |
269 | void escapeAction(int v) { button->escapeAction->setCurrentItem(v); } | 270 | void escapeAction(int v) { button->escapeAction->setCurrentItem(v); } |
270 | #else | 271 | #else |
271 | void escapeAction(int v) { button->escapeAction->select(v); } | 272 | void escapeAction(int v) { button->escapeAction->select(v); } |
272 | #endif | 273 | #endif |
273 | int returnAction() { return button->returnAction->currentItem(); } | 274 | int returnAction() { return button->returnAction->currentItem(); } |
274 | #ifdef USECOMBO | 275 | #ifdef USECOMBO |
275 | void returnAction(int v) { button->returnAction->setCurrentItem(v); } | 276 | void returnAction(int v) { button->returnAction->setCurrentItem(v); } |
276 | #else | 277 | #else |
277 | void returnAction(int v) { button->returnAction->select(v); } | 278 | void returnAction(int v) { button->returnAction->select(v); } |
278 | #endif | 279 | #endif |
279 | int leftAction() { return button->leftAction->currentItem(); } | 280 | int leftAction() { return button->leftAction->currentItem(); } |
280 | #ifdef USECOMBO | 281 | #ifdef USECOMBO |
281 | void leftAction(int v) { button->leftAction->setCurrentItem(v); } | 282 | void leftAction(int v) { button->leftAction->setCurrentItem(v); } |
282 | #else | 283 | #else |
283 | void leftAction(int v) { button->leftAction->select(v); } | 284 | void leftAction(int v) { button->leftAction->select(v); } |
284 | #endif | 285 | #endif |
285 | int rightAction() { return button->rightAction->currentItem(); } | 286 | int rightAction() { return button->rightAction->currentItem(); } |
286 | #ifdef USECOMBO | 287 | #ifdef USECOMBO |
287 | void rightAction(int v) { button->rightAction->setCurrentItem(v); } | 288 | void rightAction(int v) { button->rightAction->setCurrentItem(v); } |
288 | #else | 289 | #else |
289 | void rightAction(int v) { button->rightAction->select(v); } | 290 | void rightAction(int v) { button->rightAction->select(v); } |
290 | #endif | 291 | #endif |
291 | int upAction() { return button->upAction->currentItem(); } | 292 | int upAction() { return button->upAction->currentItem(); } |
292 | #ifdef USECOMBO | 293 | #ifdef USECOMBO |
293 | void upAction(int v) { button->upAction->setCurrentItem(v); } | 294 | void upAction(int v) { button->upAction->setCurrentItem(v); } |
294 | #else | 295 | #else |
295 | void upAction(int v) { button->upAction->select(v); } | 296 | void upAction(int v) { button->upAction->select(v); } |
296 | #endif | 297 | #endif |
297 | int downAction() { return button->downAction->currentItem(); } | 298 | int downAction() { return button->downAction->currentItem(); } |
298 | #ifdef USECOMBO | 299 | #ifdef USECOMBO |
299 | void downAction(int v) { button->downAction->setCurrentItem(v); } | 300 | void downAction(int v) { button->downAction->setCurrentItem(v); } |
300 | #else | 301 | #else |
301 | void downAction(int v) { button->downAction->select(v); } | 302 | void downAction(int v) { button->downAction->select(v); } |
302 | #endif | 303 | #endif |
303 | bool leftScroll() { return button->leftScroll->isChecked(); } | 304 | bool leftScroll() { return button->leftScroll->isChecked(); } |
304 | void leftScroll(bool v) { button->leftScroll->setChecked(v); } | 305 | void leftScroll(bool v) { button->leftScroll->setChecked(v); } |
305 | bool rightScroll() { return button->rightScroll->isChecked(); } | 306 | bool rightScroll() { return button->rightScroll->isChecked(); } |
306 | void rightScroll(bool v) { button->rightScroll->setChecked(v); } | 307 | void rightScroll(bool v) { button->rightScroll->setChecked(v); } |
307 | bool upScroll() { return button->upScroll->isChecked(); } | 308 | bool upScroll() { return button->upScroll->isChecked(); } |
308 | void upScroll(bool v) { button->upScroll->setChecked(v); } | 309 | void upScroll(bool v) { button->upScroll->setChecked(v); } |
309 | bool downScroll() { return button->downScroll->isChecked(); } | 310 | bool downScroll() { return button->downScroll->isChecked(); } |
310 | void downScroll(bool v) { button->downScroll->setChecked(v); } | 311 | void downScroll(bool v) { button->downScroll->setChecked(v); } |
311 | 312 | ||
312 | 313 | ||
313 | int gfxsize() { return layout2->gfxzoom->value(); } | 314 | int gfxsize() { return layout2->gfxzoom->value(); } |
314 | void gfxsize(int v) { layout2->gfxzoom->setValue(v); } | 315 | void gfxsize(int v) { layout2->gfxzoom->setValue(v); } |
315 | int pageoverlap() { return layout2->pageoverlap->value(); } | 316 | int pageoverlap() { return layout2->pageoverlap->value(); } |
316 | void pageoverlap(int v) { layout2->pageoverlap->setValue(v); } | 317 | void pageoverlap(int v) { layout2->pageoverlap->setValue(v); } |
317 | 318 | ||
318 | bool twotouch() { return inter->twotouch->isChecked(); } | 319 | bool twotouch() { return inter->twotouch->isChecked(); } |
319 | void twotouch(bool v) { inter->twotouch->setChecked(v); } | 320 | void twotouch(bool v) { inter->twotouch->setChecked(v); } |
320 | 321 | ||
321 | bool ideogram() { return inter->ideogram->isChecked(); } | 322 | bool ideogram() { return inter->ideogram->isChecked(); } |
322 | void ideogram(bool v) { inter->ideogram->setChecked(v); } | 323 | void ideogram(bool v) { inter->ideogram->setChecked(v); } |
323 | 324 | ||
324 | int ideogramwidth() { return inter->ideogramwidth->value(); } | 325 | int ideogramwidth() { return inter->ideogramwidth->value(); } |
325 | void ideogramwidth(int v) { inter->ideogramwidth->setValue(v); } | 326 | void ideogramwidth(int v) { inter->ideogramwidth->setValue(v); } |
326 | 327 | ||
327 | bool propfontchange() { return inter->propfontchange->isChecked(); } | 328 | bool propfontchange() { return inter->propfontchange->isChecked(); } |
328 | void propfontchange(bool v) { inter->propfontchange->setChecked(v); } | 329 | void propfontchange(bool v) { inter->propfontchange->setChecked(v); } |
329 | 330 | ||
330 | int encoding() { return inter->encoding->currentItem(); } | 331 | int encoding() { return inter->encoding->currentItem(); } |
331 | #ifdef USECOMBO | 332 | #ifdef USECOMBO |
332 | void encoding(int v) { inter->encoding->setCurrentItem(v); } | 333 | void encoding(int v) { inter->encoding->setCurrentItem(v); } |
333 | #else | 334 | #else |
334 | void encoding(int v) { inter->encoding->select(v); } | 335 | void encoding(int v) { inter->encoding->select(v); } |
335 | #endif | 336 | #endif |
336 | 337 | ||
337 | 338 | ||
338 | 339 | ||
339 | }; | 340 | }; |
340 | #endif // CPREFS_H | 341 | #endif // CPREFS_H |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index af1da27..087ce00 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -1068,3073 +1068,3073 @@ QToolBar* QTReaderApp::navbar() | |||
1068 | if (navBar == NULL) | 1068 | if (navBar == NULL) |
1069 | { | 1069 | { |
1070 | switch (m_tbpol) | 1070 | switch (m_tbpol) |
1071 | { | 1071 | { |
1072 | case cesMultiple: | 1072 | case cesMultiple: |
1073 | // qDebug("Creating new nav bar"); | 1073 | // qDebug("Creating new nav bar"); |
1074 | navBar = new QToolBar("Navigation", this, m_tbposition); | 1074 | navBar = new QToolBar("Navigation", this, m_tbposition); |
1075 | break; | 1075 | break; |
1076 | default: | 1076 | default: |
1077 | qDebug("Incorrect toolbar policy set"); | 1077 | qDebug("Incorrect toolbar policy set"); |
1078 | case cesSingle: | 1078 | case cesSingle: |
1079 | case cesMenuTool: | 1079 | case cesMenuTool: |
1080 | navBar = fileBar; | 1080 | navBar = fileBar; |
1081 | // qDebug("Setting navbar to filebar"); | 1081 | // qDebug("Setting navbar to filebar"); |
1082 | break; | 1082 | break; |
1083 | } | 1083 | } |
1084 | } | 1084 | } |
1085 | return navBar; | 1085 | return navBar; |
1086 | } | 1086 | } |
1087 | QToolBar* QTReaderApp::markbar() | 1087 | QToolBar* QTReaderApp::markbar() |
1088 | { | 1088 | { |
1089 | if (markBar == NULL) | 1089 | if (markBar == NULL) |
1090 | { | 1090 | { |
1091 | switch (m_tbpol) | 1091 | switch (m_tbpol) |
1092 | { | 1092 | { |
1093 | case cesMultiple: | 1093 | case cesMultiple: |
1094 | markBar = new QToolBar("Marks", this, m_tbposition); | 1094 | markBar = new QToolBar("Marks", this, m_tbposition); |
1095 | break; | 1095 | break; |
1096 | default: | 1096 | default: |
1097 | qDebug("Incorrect toolbar policy set"); | 1097 | qDebug("Incorrect toolbar policy set"); |
1098 | case cesSingle: | 1098 | case cesSingle: |
1099 | case cesMenuTool: | 1099 | case cesMenuTool: |
1100 | markBar = fileBar; | 1100 | markBar = fileBar; |
1101 | break; | 1101 | break; |
1102 | } | 1102 | } |
1103 | } | 1103 | } |
1104 | return markBar; | 1104 | return markBar; |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) | 1107 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) |
1108 | { | 1108 | { |
1109 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); | 1109 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); |
1110 | } | 1110 | } |
1111 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) | 1111 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) |
1112 | { | 1112 | { |
1113 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); | 1113 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); |
1114 | } | 1114 | } |
1115 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) | 1115 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) |
1116 | { | 1116 | { |
1117 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); | 1117 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); |
1118 | } | 1118 | } |
1119 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) | 1119 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) |
1120 | { | 1120 | { |
1121 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); | 1121 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | void QTReaderApp::suspend() { reader->suspend(); } | 1124 | void QTReaderApp::suspend() { reader->suspend(); } |
1125 | 1125 | ||
1126 | #ifdef USEMSGS | 1126 | #ifdef USEMSGS |
1127 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | 1127 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) |
1128 | { | 1128 | { |
1129 | QString msg = QString::fromUtf8(_msg); | 1129 | QString msg = QString::fromUtf8(_msg); |
1130 | 1130 | ||
1131 | //// qDebug("Received:%s", (const char*)msg); | 1131 | //// qDebug("Received:%s", (const char*)msg); |
1132 | 1132 | ||
1133 | QDataStream stream( _data, IO_ReadOnly ); | 1133 | QDataStream stream( _data, IO_ReadOnly ); |
1134 | if ( msg == "info(QString)" ) | 1134 | if ( msg == "info(QString)" ) |
1135 | { | 1135 | { |
1136 | QString info; | 1136 | QString info; |
1137 | stream >> info; | 1137 | stream >> info; |
1138 | QMessageBox::information(this, PROGNAME, info); | 1138 | QMessageBox::information(this, PROGNAME, info); |
1139 | } | 1139 | } |
1140 | else if ( msg == "Update(int)" ) | 1140 | else if ( msg == "Update(int)" ) |
1141 | { | 1141 | { |
1142 | int info; | 1142 | int info; |
1143 | stream >> info; | 1143 | stream >> info; |
1144 | if (info) | 1144 | if (info) |
1145 | { | 1145 | { |
1146 | reader->bDoUpdates = true; | 1146 | reader->bDoUpdates = true; |
1147 | reader->refresh(); | 1147 | reader->refresh(); |
1148 | } | 1148 | } |
1149 | else | 1149 | else |
1150 | { | 1150 | { |
1151 | reader->bDoUpdates = false; | 1151 | reader->bDoUpdates = false; |
1152 | } | 1152 | } |
1153 | } | 1153 | } |
1154 | else if ( msg == "warn(QString)" ) | 1154 | else if ( msg == "warn(QString)" ) |
1155 | { | 1155 | { |
1156 | QString info; | 1156 | QString info; |
1157 | stream >> info; | 1157 | stream >> info; |
1158 | QMessageBox::warning(this, PROGNAME, info); | 1158 | QMessageBox::warning(this, PROGNAME, info); |
1159 | } | 1159 | } |
1160 | else if ( msg == "exit()" ) | 1160 | else if ( msg == "exit()" ) |
1161 | { | 1161 | { |
1162 | m_dontSave = true; | 1162 | m_dontSave = true; |
1163 | close(); | 1163 | close(); |
1164 | } | 1164 | } |
1165 | else if ( msg == "pageDown()" ) | 1165 | else if ( msg == "pageDown()" ) |
1166 | { | 1166 | { |
1167 | reader->dopagedn(); | 1167 | reader->dopagedn(); |
1168 | } | 1168 | } |
1169 | else if ( msg == "pageUp()" ) | 1169 | else if ( msg == "pageUp()" ) |
1170 | { | 1170 | { |
1171 | reader->dopageup(); | 1171 | reader->dopageup(); |
1172 | } | 1172 | } |
1173 | else if ( msg == "lineDown()" ) | 1173 | else if ( msg == "lineDown()" ) |
1174 | { | 1174 | { |
1175 | reader->lineDown(); | 1175 | reader->lineDown(); |
1176 | } | 1176 | } |
1177 | else if ( msg == "lineUp()" ) | 1177 | else if ( msg == "lineUp()" ) |
1178 | { | 1178 | { |
1179 | reader->lineUp(); | 1179 | reader->lineUp(); |
1180 | } | 1180 | } |
1181 | else if ( msg == "showText()" ) | 1181 | else if ( msg == "showText()" ) |
1182 | { | 1182 | { |
1183 | showEditTools(); | 1183 | showEditTools(); |
1184 | } | 1184 | } |
1185 | else if ( msg == "home()" ) | 1185 | else if ( msg == "home()" ) |
1186 | { | 1186 | { |
1187 | reader->goHome(); | 1187 | reader->goHome(); |
1188 | } | 1188 | } |
1189 | else if ( msg == "back()" ) | 1189 | else if ( msg == "back()" ) |
1190 | { | 1190 | { |
1191 | reader->goBack(); | 1191 | reader->goBack(); |
1192 | } | 1192 | } |
1193 | else if ( msg == "forward()" ) | 1193 | else if ( msg == "forward()" ) |
1194 | { | 1194 | { |
1195 | reader->goForward(); | 1195 | reader->goForward(); |
1196 | } | 1196 | } |
1197 | else if ( msg == "File/Open(QString)" ) | 1197 | else if ( msg == "File/Open(QString)" ) |
1198 | { | 1198 | { |
1199 | QString info; | 1199 | QString info; |
1200 | stream >> info; | 1200 | stream >> info; |
1201 | openFile( info ); | 1201 | openFile( info ); |
1202 | } | 1202 | } |
1203 | else if ( msg == "File/Info()" ) | 1203 | else if ( msg == "File/Info()" ) |
1204 | { | 1204 | { |
1205 | showinfo(); | 1205 | showinfo(); |
1206 | } | 1206 | } |
1207 | else if ( msg == "File/Action(QString)" ) | 1207 | else if ( msg == "File/Action(QString)" ) |
1208 | { | 1208 | { |
1209 | QString info; | 1209 | QString info; |
1210 | stream >> info; | 1210 | stream >> info; |
1211 | m_spaceTarget = ActNameToInt(info); | 1211 | m_spaceTarget = ActNameToInt(info); |
1212 | } | 1212 | } |
1213 | else if ( msg == "Navigation/Scroll(int)" ) | 1213 | else if ( msg == "Navigation/Scroll(int)" ) |
1214 | { | 1214 | { |
1215 | int info; | 1215 | int info; |
1216 | stream >> info; | 1216 | stream >> info; |
1217 | autoScroll(info); | 1217 | autoScroll(info); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | else if ( msg == "Navigation/GotoStart()" ) | 1220 | else if ( msg == "Navigation/GotoStart()" ) |
1221 | { | 1221 | { |
1222 | gotoStart(); | 1222 | gotoStart(); |
1223 | } | 1223 | } |
1224 | else if ( msg == "Navigation/GotoEnd()" ) | 1224 | else if ( msg == "Navigation/GotoEnd()" ) |
1225 | { | 1225 | { |
1226 | gotoEnd(); | 1226 | gotoEnd(); |
1227 | } | 1227 | } |
1228 | else if ( msg == "Navigation/Jump(int)" ) | 1228 | else if ( msg == "Navigation/Jump(int)" ) |
1229 | { | 1229 | { |
1230 | int info; | 1230 | int info; |
1231 | stream >> info; | 1231 | stream >> info; |
1232 | reader->locate(info); | 1232 | reader->locate(info); |
1233 | } | 1233 | } |
1234 | else if ( msg == "Navigation/Page/LineScroll(int)" ) | 1234 | else if ( msg == "Navigation/Page/LineScroll(int)" ) |
1235 | { | 1235 | { |
1236 | int info; | 1236 | int info; |
1237 | stream >> info; | 1237 | stream >> info; |
1238 | pagemode(info); | 1238 | pagemode(info); |
1239 | } | 1239 | } |
1240 | else if ( msg == "Navigation/SetOverlap(int)" ) | 1240 | else if ( msg == "Navigation/SetOverlap(int)" ) |
1241 | { | 1241 | { |
1242 | int info; | 1242 | int info; |
1243 | stream >> info; | 1243 | stream >> info; |
1244 | reader->m_overlap = info; | 1244 | reader->m_overlap = info; |
1245 | } | 1245 | } |
1246 | else if ( msg == "Navigation/SetMargin(int)" ) | 1246 | else if ( msg == "Navigation/SetMargin(int)" ) |
1247 | { | 1247 | { |
1248 | int info; | 1248 | int info; |
1249 | stream >> info; | 1249 | stream >> info; |
1250 | do_margin(info); | 1250 | do_margin(info); |
1251 | } | 1251 | } |
1252 | else if ( msg == "File/SetDictionary(QString)" ) | 1252 | else if ( msg == "File/SetDictionary(QString)" ) |
1253 | { | 1253 | { |
1254 | QString info; | 1254 | QString info; |
1255 | stream >> info; | 1255 | stream >> info; |
1256 | do_settarget(info); | 1256 | do_settarget(info); |
1257 | } | 1257 | } |
1258 | #ifdef _SCROLLPIPE | 1258 | #ifdef _SCROLLPIPE |
1259 | else if ( msg == "File/SetScrollTarget(QString)" ) | 1259 | else if ( msg == "File/SetScrollTarget(QString)" ) |
1260 | { | 1260 | { |
1261 | QString info; | 1261 | QString info; |
1262 | stream >> info; | 1262 | stream >> info; |
1263 | reader->m_pipetarget = info; | 1263 | reader->m_pipetarget = info; |
1264 | } | 1264 | } |
1265 | #endif | 1265 | #endif |
1266 | else if ( msg == "File/Two/OneTouch(int)" ) | 1266 | else if ( msg == "File/Two/OneTouch(int)" ) |
1267 | { | 1267 | { |
1268 | int info; | 1268 | int info; |
1269 | stream >> info; | 1269 | stream >> info; |
1270 | setTwoTouch(info); | 1270 | setTwoTouch(info); |
1271 | } | 1271 | } |
1272 | else if ( msg == "Target/Annotation(int)" ) | 1272 | else if ( msg == "Target/Annotation(int)" ) |
1273 | { | 1273 | { |
1274 | int info; | 1274 | int info; |
1275 | stream >> info; | 1275 | stream >> info; |
1276 | OnAnnotation(info); | 1276 | OnAnnotation(info); |
1277 | } | 1277 | } |
1278 | else if ( msg == "Target/Dictionary(int)" ) | 1278 | else if ( msg == "Target/Dictionary(int)" ) |
1279 | { | 1279 | { |
1280 | int info; | 1280 | int info; |
1281 | stream >> info; | 1281 | stream >> info; |
1282 | OnDictionary(info); | 1282 | OnDictionary(info); |
1283 | } | 1283 | } |
1284 | else if ( msg == "Target/Clipboard(int)" ) | 1284 | else if ( msg == "Target/Clipboard(int)" ) |
1285 | { | 1285 | { |
1286 | int info; | 1286 | int info; |
1287 | stream >> info; | 1287 | stream >> info; |
1288 | OnClipboard(info); | 1288 | OnClipboard(info); |
1289 | } | 1289 | } |
1290 | else if ( msg == "File/Find(QString)" ) | 1290 | else if ( msg == "File/Find(QString)" ) |
1291 | { | 1291 | { |
1292 | QString info; | 1292 | QString info; |
1293 | stream >> info; | 1293 | stream >> info; |
1294 | QRegExp arg(info); | 1294 | QRegExp arg(info); |
1295 | size_t pos = reader->pagelocate(); | 1295 | size_t pos = reader->pagelocate(); |
1296 | size_t start = pos; | 1296 | size_t start = pos; |
1297 | CDrawBuffer test(&(reader->m_fontControl)); | 1297 | CDrawBuffer test(&(reader->m_fontControl)); |
1298 | reader->getline(&test); | 1298 | reader->getline(&test); |
1299 | while (arg.match(toQString(test.data())) == -1) | 1299 | while (arg.match(toQString(test.data())) == -1) |
1300 | { | 1300 | { |
1301 | pos = reader->locate(); | 1301 | pos = reader->locate(); |
1302 | if (!reader->getline(&test)) | 1302 | if (!reader->getline(&test)) |
1303 | { | 1303 | { |
1304 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); | 1304 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); |
1305 | pos = start; | 1305 | pos = start; |
1306 | break; | 1306 | break; |
1307 | } | 1307 | } |
1308 | } | 1308 | } |
1309 | reader->locate(pos); | 1309 | reader->locate(pos); |
1310 | } | 1310 | } |
1311 | else if ( msg == "File/Fullscreen(int)" ) | 1311 | else if ( msg == "File/Fullscreen(int)" ) |
1312 | { | 1312 | { |
1313 | int info; | 1313 | int info; |
1314 | stream >> info; | 1314 | stream >> info; |
1315 | setfullscreen(info); | 1315 | setfullscreen(info); |
1316 | } | 1316 | } |
1317 | else if ( msg == "File/Continuous(int)" ) | 1317 | else if ( msg == "File/Continuous(int)" ) |
1318 | { | 1318 | { |
1319 | int info; | 1319 | int info; |
1320 | stream >> info; | 1320 | stream >> info; |
1321 | setcontinuous(info); | 1321 | setcontinuous(info); |
1322 | } | 1322 | } |
1323 | else if ( msg == "Markup(QString)" ) | 1323 | else if ( msg == "Markup(QString)" ) |
1324 | { | 1324 | { |
1325 | QString info; | 1325 | QString info; |
1326 | stream >> info; | 1326 | stream >> info; |
1327 | if (info == "Auto") | 1327 | if (info == "Auto") |
1328 | { | 1328 | { |
1329 | autofmt(true); | 1329 | autofmt(true); |
1330 | } | 1330 | } |
1331 | if (info == "None") | 1331 | if (info == "None") |
1332 | { | 1332 | { |
1333 | autofmt(false); | 1333 | autofmt(false); |
1334 | textfmt(false); | 1334 | textfmt(false); |
1335 | striphtml(false); | 1335 | striphtml(false); |
1336 | peanut(false); | 1336 | peanut(false); |
1337 | } | 1337 | } |
1338 | if (info == "Text") | 1338 | if (info == "Text") |
1339 | { | 1339 | { |
1340 | textfmt(true); | 1340 | textfmt(true); |
1341 | } | 1341 | } |
1342 | if (info == "HTML") | 1342 | if (info == "HTML") |
1343 | { | 1343 | { |
1344 | striphtml(true); | 1344 | striphtml(true); |
1345 | } | 1345 | } |
1346 | if (info == "Peanut/PML") | 1346 | if (info == "Peanut/PML") |
1347 | { | 1347 | { |
1348 | peanut(true); | 1348 | peanut(true); |
1349 | } | 1349 | } |
1350 | } | 1350 | } |
1351 | else if ( msg == "Layout/StripCR(int)" ) | 1351 | else if ( msg == "Layout/StripCR(int)" ) |
1352 | { | 1352 | { |
1353 | int info; | 1353 | int info; |
1354 | stream >> info; | 1354 | stream >> info; |
1355 | stripcr(info); | 1355 | stripcr(info); |
1356 | } | 1356 | } |
1357 | else if ( msg == "Layout/Dehyphen(int)" ) | 1357 | else if ( msg == "Layout/Dehyphen(int)" ) |
1358 | { | 1358 | { |
1359 | int info; | 1359 | int info; |
1360 | stream >> info; | 1360 | stream >> info; |
1361 | dehyphen(info); | 1361 | dehyphen(info); |
1362 | } | 1362 | } |
1363 | else if ( msg == "Layout/Depluck(int)" ) | 1363 | else if ( msg == "Layout/Depluck(int)" ) |
1364 | { | 1364 | { |
1365 | int info; | 1365 | int info; |
1366 | stream >> info; | 1366 | stream >> info; |
1367 | depluck(info); | 1367 | depluck(info); |
1368 | } | 1368 | } |
1369 | else if ( msg == "Layout/Dejpluck(int)" ) | 1369 | else if ( msg == "Layout/Dejpluck(int)" ) |
1370 | { | 1370 | { |
1371 | int info; | 1371 | int info; |
1372 | stream >> info; | 1372 | stream >> info; |
1373 | dejpluck(info); | 1373 | dejpluck(info); |
1374 | } | 1374 | } |
1375 | else if ( msg == "Layout/SingleSpace(int)" ) | 1375 | else if ( msg == "Layout/SingleSpace(int)" ) |
1376 | { | 1376 | { |
1377 | int info; | 1377 | int info; |
1378 | stream >> info; | 1378 | stream >> info; |
1379 | onespace(info); | 1379 | onespace(info); |
1380 | } | 1380 | } |
1381 | #ifdef REPALM | 1381 | #ifdef REPALM |
1382 | else if ( msg == "Layout/Repalm(int)" ) | 1382 | else if ( msg == "Layout/Repalm(int)" ) |
1383 | { | 1383 | { |
1384 | int info; | 1384 | int info; |
1385 | stream >> info; | 1385 | stream >> info; |
1386 | repalm(info); | 1386 | repalm(info); |
1387 | } | 1387 | } |
1388 | #endif | 1388 | #endif |
1389 | else if ( msg == "Layout/Unindent(int)" ) | 1389 | else if ( msg == "Layout/Unindent(int)" ) |
1390 | { | 1390 | { |
1391 | int info; | 1391 | int info; |
1392 | stream >> info; | 1392 | stream >> info; |
1393 | unindent(info); | 1393 | unindent(info); |
1394 | } | 1394 | } |
1395 | else if ( msg == "Layout/Re-paragraph(int)" ) | 1395 | else if ( msg == "Layout/Re-paragraph(int)" ) |
1396 | { | 1396 | { |
1397 | int info; | 1397 | int info; |
1398 | stream >> info; | 1398 | stream >> info; |
1399 | repara(info); | 1399 | repara(info); |
1400 | } | 1400 | } |
1401 | else if ( msg == "Layout/DoubleSpace(int)" ) | 1401 | else if ( msg == "Layout/DoubleSpace(int)" ) |
1402 | { | 1402 | { |
1403 | int info; | 1403 | int info; |
1404 | stream >> info; | 1404 | stream >> info; |
1405 | dblspce(info); | 1405 | dblspce(info); |
1406 | } | 1406 | } |
1407 | else if ( msg == "Layout/Indent(int)" ) | 1407 | else if ( msg == "Layout/Indent(int)" ) |
1408 | { | 1408 | { |
1409 | int info; | 1409 | int info; |
1410 | stream >> info; | 1410 | stream >> info; |
1411 | reader->bindenter = info; | 1411 | reader->bindenter = info; |
1412 | reader->setfilter(reader->getfilter()); | 1412 | reader->setfilter(reader->getfilter()); |
1413 | } | 1413 | } |
1414 | else if ( msg == "Layout/Remap(int)" ) | 1414 | else if ( msg == "Layout/Remap(int)" ) |
1415 | { | 1415 | { |
1416 | int info; | 1416 | int info; |
1417 | stream >> info; | 1417 | stream >> info; |
1418 | remap(info); | 1418 | remap(info); |
1419 | } | 1419 | } |
1420 | else if ( msg == "Layout/Embolden(int)" ) | 1420 | else if ( msg == "Layout/Embolden(int)" ) |
1421 | { | 1421 | { |
1422 | int info; | 1422 | int info; |
1423 | stream >> info; | 1423 | stream >> info; |
1424 | embolden(info); | 1424 | embolden(info); |
1425 | } | 1425 | } |
1426 | else if ( msg == "Format/Ideogram/Word(int)" ) | 1426 | else if ( msg == "Format/Ideogram/Word(int)" ) |
1427 | { | 1427 | { |
1428 | int info; | 1428 | int info; |
1429 | stream >> info; | 1429 | stream >> info; |
1430 | monospace(info); | 1430 | monospace(info); |
1431 | } | 1431 | } |
1432 | else if ( msg == "Format/SetWidth(int)" ) | 1432 | else if ( msg == "Format/SetWidth(int)" ) |
1433 | { | 1433 | { |
1434 | int info; | 1434 | int info; |
1435 | stream >> info; | 1435 | stream >> info; |
1436 | reader->m_charpc = info; | 1436 | reader->m_charpc = info; |
1437 | reader->setfont(); | 1437 | reader->setfont(); |
1438 | reader->refresh(); | 1438 | reader->refresh(); |
1439 | } | 1439 | } |
1440 | else if ( msg == "Format/SetFont(QString,int)" ) | 1440 | else if ( msg == "Format/SetFont(QString,int)" ) |
1441 | { | 1441 | { |
1442 | QString fontname; | 1442 | QString fontname; |
1443 | int size; | 1443 | int size; |
1444 | stream >> fontname; | 1444 | stream >> fontname; |
1445 | stream >> size; | 1445 | stream >> size; |
1446 | setfontHelper(fontname, size); | 1446 | setfontHelper(fontname, size); |
1447 | } | 1447 | } |
1448 | else if ( msg == "Marks/Autogen(QString)" ) | 1448 | else if ( msg == "Marks/Autogen(QString)" ) |
1449 | { | 1449 | { |
1450 | QString info; | 1450 | QString info; |
1451 | stream >> info; | 1451 | stream >> info; |
1452 | do_autogen(info); | 1452 | do_autogen(info); |
1453 | } | 1453 | } |
1454 | else if ( msg == "File/StartBlock()" ) | 1454 | else if ( msg == "File/StartBlock()" ) |
1455 | { | 1455 | { |
1456 | editMark(); | 1456 | editMark(); |
1457 | } | 1457 | } |
1458 | else if ( msg == "File/CopyBlock()" ) | 1458 | else if ( msg == "File/CopyBlock()" ) |
1459 | { | 1459 | { |
1460 | editCopy(); | 1460 | editCopy(); |
1461 | } | 1461 | } |
1462 | } | 1462 | } |
1463 | #endif | 1463 | #endif |
1464 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | 1464 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) |
1465 | { | 1465 | { |
1466 | for (int i = 0; i < MAX_ACTIONS; i++) | 1466 | for (int i = 0; i < MAX_ACTIONS; i++) |
1467 | { | 1467 | { |
1468 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; | 1468 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; |
1469 | } | 1469 | } |
1470 | return cesAutoScroll; | 1470 | return cesAutoScroll; |
1471 | } | 1471 | } |
1472 | 1472 | ||
1473 | void QTReaderApp::setfullscreen(bool sfs) | 1473 | void QTReaderApp::setfullscreen(bool sfs) |
1474 | { | 1474 | { |
1475 | reader->bDoUpdates = false; | 1475 | reader->bDoUpdates = false; |
1476 | m_fullscreen = sfs; | 1476 | m_fullscreen = sfs; |
1477 | showEditTools(); | 1477 | showEditTools(); |
1478 | // qApp->processEvents(); | 1478 | // qApp->processEvents(); |
1479 | reader->bDoUpdates = true; | 1479 | reader->bDoUpdates = true; |
1480 | reader->update(); | 1480 | reader->update(); |
1481 | } | 1481 | } |
1482 | 1482 | ||
1483 | void QTReaderApp::buttonActionSelected(QAction* _a) | 1483 | void QTReaderApp::buttonActionSelected(QAction* _a) |
1484 | { | 1484 | { |
1485 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); | 1485 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); |
1486 | m_spaceTarget = ActNameToInt(_a->text()); | 1486 | m_spaceTarget = ActNameToInt(_a->text()); |
1487 | } | 1487 | } |
1488 | 1488 | ||
1489 | QTReaderApp::~QTReaderApp() | 1489 | QTReaderApp::~QTReaderApp() |
1490 | { | 1490 | { |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | void QTReaderApp::autoScroll(bool _b) | 1493 | void QTReaderApp::autoScroll(bool _b) |
1494 | { | 1494 | { |
1495 | reader->setautoscroll(_b); | 1495 | reader->setautoscroll(_b); |
1496 | setScrollState(reader->m_autoScroll); | 1496 | setScrollState(reader->m_autoScroll); |
1497 | } | 1497 | } |
1498 | 1498 | ||
1499 | void QTReaderApp::zoomin() | 1499 | void QTReaderApp::zoomin() |
1500 | { | 1500 | { |
1501 | reader->zoomin(); | 1501 | reader->zoomin(); |
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | void QTReaderApp::zoomout() | 1504 | void QTReaderApp::zoomout() |
1505 | { | 1505 | { |
1506 | reader->zoomout(); | 1506 | reader->zoomout(); |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | void QTReaderApp::clearBkmkList() | 1509 | void QTReaderApp::clearBkmkList() |
1510 | { | 1510 | { |
1511 | delete pBkmklist; | 1511 | delete pBkmklist; |
1512 | pBkmklist = NULL; | 1512 | pBkmklist = NULL; |
1513 | m_fBkmksChanged = false; | 1513 | m_fBkmksChanged = false; |
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | void QTReaderApp::fileClose() | 1516 | void QTReaderApp::fileClose() |
1517 | { | 1517 | { |
1518 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); | 1518 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); |
1519 | if (cd->exec()) | 1519 | if (cd->exec()) |
1520 | { | 1520 | { |
1521 | if (pOpenlist != NULL) | 1521 | if (pOpenlist != NULL) |
1522 | { | 1522 | { |
1523 | int ind = 0; | 1523 | int ind = 0; |
1524 | Bkmk* p = (*pOpenlist)[ind]; | 1524 | Bkmk* p = (*pOpenlist)[ind]; |
1525 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 1525 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
1526 | { | 1526 | { |
1527 | p = (*pOpenlist)[++ind]; | 1527 | p = (*pOpenlist)[++ind]; |
1528 | } | 1528 | } |
1529 | if (p != NULL) pOpenlist->erase(ind); | 1529 | if (p != NULL) pOpenlist->erase(ind); |
1530 | if (cd->delFile()) | 1530 | if (cd->delFile()) |
1531 | { | 1531 | { |
1532 | unlink((const char*)reader->m_lastfile); | 1532 | unlink((const char*)reader->m_lastfile); |
1533 | } | 1533 | } |
1534 | if (cd->delMarks()) | 1534 | if (cd->delMarks()) |
1535 | { | 1535 | { |
1536 | #ifndef USEQPE | 1536 | #ifndef USEQPE |
1537 | QDir d = QDir::home(); // "/" | 1537 | QDir d = QDir::home(); // "/" |
1538 | d.cd(APPDIR); | 1538 | d.cd(APPDIR); |
1539 | d.remove(reader->m_string); | 1539 | d.remove(reader->m_string); |
1540 | #else /* USEQPE */ | 1540 | #else /* USEQPE */ |
1541 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 1541 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
1542 | #endif /* USEQPE */ | 1542 | #endif /* USEQPE */ |
1543 | } | 1543 | } |
1544 | if (cd->delConfig()) | 1544 | if (cd->delConfig()) |
1545 | { | 1545 | { |
1546 | #ifndef USEQPE | 1546 | #ifndef USEQPE |
1547 | QDir d = QDir::home(); // "/" | 1547 | QDir d = QDir::home(); // "/" |
1548 | d.cd(APPDIR "/configs"); | 1548 | d.cd(APPDIR "/configs"); |
1549 | d.remove(reader->m_string); | 1549 | d.remove(reader->m_string); |
1550 | #else /* USEQPE */ | 1550 | #else /* USEQPE */ |
1551 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); | 1551 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); |
1552 | #endif /* USEQPE */ | 1552 | #endif /* USEQPE */ |
1553 | } | 1553 | } |
1554 | } | 1554 | } |
1555 | 1555 | ||
1556 | fileOpen2(); | 1556 | fileOpen2(); |
1557 | } | 1557 | } |
1558 | delete cd; | 1558 | delete cd; |
1559 | } | 1559 | } |
1560 | 1560 | ||
1561 | void QTReaderApp::updatefileinfo() | 1561 | void QTReaderApp::updatefileinfo() |
1562 | { | 1562 | { |
1563 | if (reader->m_string.isEmpty()) return; | 1563 | if (reader->m_string.isEmpty()) return; |
1564 | if (reader->m_lastfile.isEmpty()) return; | 1564 | if (reader->m_lastfile.isEmpty()) return; |
1565 | tchar* nm = fromQString(reader->m_string); | 1565 | tchar* nm = fromQString(reader->m_string); |
1566 | tchar* fl = fromQString(reader->m_lastfile); | 1566 | tchar* fl = fromQString(reader->m_lastfile); |
1567 | // qDebug("Lastfile:%x", fl); | 1567 | // qDebug("Lastfile:%x", fl); |
1568 | bool notadded = true; | 1568 | bool notadded = true; |
1569 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; | 1569 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; |
1570 | else | 1570 | else |
1571 | { | 1571 | { |
1572 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 1572 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
1573 | { | 1573 | { |
1574 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) | 1574 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) |
1575 | { | 1575 | { |
1576 | iter->value(reader->pagelocate()); | 1576 | iter->value(reader->pagelocate()); |
1577 | unsigned short dlen; | 1577 | unsigned short dlen; |
1578 | unsigned char* data; | 1578 | unsigned char* data; |
1579 | CFiledata fd(iter->anno()); | 1579 | CFiledata fd(iter->anno()); |
1580 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1580 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1581 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); | 1581 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); |
1582 | // getstate(data, dlen); | 1582 | // getstate(data, dlen); |
1583 | iter->setAnno(data, dlen); | 1583 | iter->setAnno(data, dlen); |
1584 | notadded = false; | 1584 | notadded = false; |
1585 | delete [] data; | 1585 | delete [] data; |
1586 | break; | 1586 | break; |
1587 | } | 1587 | } |
1588 | } | 1588 | } |
1589 | } | 1589 | } |
1590 | // qDebug("Added?:%x", notadded); | 1590 | // qDebug("Added?:%x", notadded); |
1591 | if (notadded) | 1591 | if (notadded) |
1592 | { | 1592 | { |
1593 | struct stat fnstat; | 1593 | struct stat fnstat; |
1594 | stat((const char *)reader->m_lastfile, &fnstat); | 1594 | stat((const char *)reader->m_lastfile, &fnstat); |
1595 | CFiledata fd(fnstat.st_mtime, fl); | 1595 | CFiledata fd(fnstat.st_mtime, fl); |
1596 | unsigned short dlen; | 1596 | unsigned short dlen; |
1597 | unsigned char* data; | 1597 | unsigned char* data; |
1598 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1598 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1599 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); | 1599 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); |
1600 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); | 1600 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); |
1601 | delete [] data; | 1601 | delete [] data; |
1602 | } | 1602 | } |
1603 | delete [] nm; | 1603 | delete [] nm; |
1604 | delete [] fl; | 1604 | delete [] fl; |
1605 | } | 1605 | } |
1606 | 1606 | ||
1607 | void QTReaderApp::fileOpen() | 1607 | void QTReaderApp::fileOpen() |
1608 | { | 1608 | { |
1609 | /* | 1609 | /* |
1610 | menu->hide(); | 1610 | menu->hide(); |
1611 | fileBar->hide(); | 1611 | fileBar->hide(); |
1612 | if (regVisible) regBar->hide(); | 1612 | if (regVisible) regBar->hide(); |
1613 | if (searchVisible) searchBar->hide(); | 1613 | if (searchVisible) searchBar->hide(); |
1614 | */ | 1614 | */ |
1615 | // qDebug("fileOpen"); | 1615 | // qDebug("fileOpen"); |
1616 | // if (!reader->m_lastfile.isEmpty()) | 1616 | // if (!reader->m_lastfile.isEmpty()) |
1617 | updatefileinfo(); | 1617 | updatefileinfo(); |
1618 | fileOpen2(); | 1618 | fileOpen2(); |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | void QTReaderApp::fileOpen2() | 1621 | void QTReaderApp::fileOpen2() |
1622 | { | 1622 | { |
1623 | if (pBkmklist != NULL) | 1623 | if (pBkmklist != NULL) |
1624 | { | 1624 | { |
1625 | if (m_fBkmksChanged) | 1625 | if (m_fBkmksChanged) |
1626 | { | 1626 | { |
1627 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 1627 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
1628 | savebkmks(); | 1628 | savebkmks(); |
1629 | } | 1629 | } |
1630 | delete pBkmklist; | 1630 | delete pBkmklist; |
1631 | pBkmklist = NULL; | 1631 | pBkmklist = NULL; |
1632 | m_fBkmksChanged = false; | 1632 | m_fBkmksChanged = false; |
1633 | } | 1633 | } |
1634 | reader->disableAutoscroll(); | 1634 | reader->disableAutoscroll(); |
1635 | /* | 1635 | /* |
1636 | editorStack->raiseWidget( fileSelector ); | 1636 | editorStack->raiseWidget( fileSelector ); |
1637 | fileSelector->reread(); | 1637 | fileSelector->reread(); |
1638 | */ | 1638 | */ |
1639 | bool usebrowser = true; | 1639 | bool usebrowser = true; |
1640 | if (pOpenlist != NULL) | 1640 | if (pOpenlist != NULL) |
1641 | { | 1641 | { |
1642 | m_nBkmkAction = cOpenFile; | 1642 | m_nBkmkAction = cOpenFile; |
1643 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; | 1643 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; |
1644 | } | 1644 | } |
1645 | if (usebrowser) | 1645 | if (usebrowser) |
1646 | { | 1646 | { |
1647 | QString fn = usefilebrowser(); | 1647 | QString fn = usefilebrowser(); |
1648 | //qApp->processEvents(); | 1648 | //qApp->processEvents(); |
1649 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 1649 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
1650 | { | 1650 | { |
1651 | openFile(fn); | 1651 | openFile(fn); |
1652 | } | 1652 | } |
1653 | reader->setFocus(); | 1653 | reader->setFocus(); |
1654 | } | 1654 | } |
1655 | // reader->refresh(); | 1655 | // reader->refresh(); |
1656 | // qDebug("HEIGHT:%d", reader->m_lastheight); | 1656 | // qDebug("HEIGHT:%d", reader->m_lastheight); |
1657 | } | 1657 | } |
1658 | 1658 | ||
1659 | QString QTReaderApp::usefilebrowser() | 1659 | QString QTReaderApp::usefilebrowser() |
1660 | { | 1660 | { |
1661 | #ifndef USEQPE | 1661 | #ifndef USEQPE |
1662 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); | 1662 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); |
1663 | return s; | 1663 | return s; |
1664 | #else | 1664 | #else |
1665 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, | 1665 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, |
1666 | 0, | 1666 | 0, |
1667 | // WStyle_Customize | WStyle_NoBorderEx, | 1667 | // WStyle_Customize | WStyle_NoBorderEx, |
1668 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | 1668 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); |
1669 | 1669 | ||
1670 | 1670 | ||
1671 | QString fn; | 1671 | QString fn; |
1672 | if (fb->exec()) | 1672 | if (fb->exec()) |
1673 | { | 1673 | { |
1674 | fn = fb->getCurrentFile(); | 1674 | fn = fb->getCurrentFile(); |
1675 | } | 1675 | } |
1676 | // qDebug("Selected %s", (const char*)fn); | 1676 | // qDebug("Selected %s", (const char*)fn); |
1677 | delete fb; | 1677 | delete fb; |
1678 | showEditTools(); | 1678 | showEditTools(); |
1679 | return fn; | 1679 | return fn; |
1680 | #endif | 1680 | #endif |
1681 | } | 1681 | } |
1682 | 1682 | ||
1683 | void QTReaderApp::showgraphic(QImage& pm) | 1683 | void QTReaderApp::showgraphic(QImage& pm) |
1684 | { | 1684 | { |
1685 | QPixmap pc; | 1685 | QPixmap pc; |
1686 | pc.convertFromImage(pm); | 1686 | pc.convertFromImage(pm); |
1687 | m_graphicwin->setPixmap(pc); | 1687 | m_graphicwin->setPixmap(pc); |
1688 | editorStack->raiseWidget( m_graphicwin ); | 1688 | editorStack->raiseWidget( m_graphicwin ); |
1689 | m_graphicwin->setFocus(); | 1689 | m_graphicwin->setFocus(); |
1690 | } | 1690 | } |
1691 | 1691 | ||
1692 | 1692 | ||
1693 | void QTReaderApp::showprefs() | 1693 | void QTReaderApp::showprefs() |
1694 | { | 1694 | { |
1695 | CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this); | 1695 | CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this); |
1696 | 1696 | ||
1697 | prefwin->twotouch(m_twoTouch); | 1697 | prefwin->twotouch(m_twoTouch); |
1698 | prefwin->propfontchange(m_propogatefontchange); | 1698 | prefwin->propfontchange(m_propogatefontchange); |
1699 | prefwin->StripCR(reader->bstripcr); | 1699 | prefwin->StripCR(reader->bstripcr); |
1700 | prefwin->Dehyphen(reader->bdehyphen); | 1700 | prefwin->Dehyphen(reader->bdehyphen); |
1701 | prefwin->SingleSpace(reader->bonespace); | 1701 | prefwin->SingleSpace(reader->bonespace); |
1702 | prefwin->Unindent(reader->bunindent); | 1702 | prefwin->Unindent(reader->bunindent); |
1703 | prefwin->Reparagraph(reader->brepara); | 1703 | prefwin->Reparagraph(reader->brepara); |
1704 | prefwin->DoubleSpace(reader->bdblspce); | 1704 | prefwin->DoubleSpace(reader->bdblspce); |
1705 | prefwin->Remap(reader->bremap); | 1705 | prefwin->Remap(reader->bremap); |
1706 | prefwin->Embolden(reader->bmakebold); | 1706 | prefwin->Embolden(reader->bmakebold); |
1707 | prefwin->FullJustify(reader->bfulljust); | 1707 | prefwin->FullJustify(reader->bfulljust); |
1708 | prefwin->ParaLead(reader->getextraspace()); | 1708 | prefwin->ParaLead(reader->getextraspace()); |
1709 | prefwin->LineLead(reader->getlead()); | 1709 | prefwin->LineLead(reader->getlead()); |
1710 | prefwin->Margin(reader->m_border); | 1710 | prefwin->Margin(reader->m_border); |
1711 | prefwin->Indent(reader->bindenter); | 1711 | prefwin->Indent(reader->bindenter); |
1712 | if (reader->bautofmt) | 1712 | if (reader->bautofmt) |
1713 | { | 1713 | { |
1714 | prefwin->Markup(0); | 1714 | prefwin->Markup(0); |
1715 | } | 1715 | } |
1716 | else if (reader->btextfmt) | 1716 | else if (reader->btextfmt) |
1717 | { | 1717 | { |
1718 | prefwin->Markup(2); | 1718 | prefwin->Markup(2); |
1719 | } | 1719 | } |
1720 | else if (reader->bstriphtml) | 1720 | else if (reader->bstriphtml) |
1721 | { | 1721 | { |
1722 | prefwin->Markup(3); | 1722 | prefwin->Markup(3); |
1723 | } | 1723 | } |
1724 | else if (reader->bpeanut) | 1724 | else if (reader->bpeanut) |
1725 | { | 1725 | { |
1726 | prefwin->Markup(4); | 1726 | prefwin->Markup(4); |
1727 | } | 1727 | } |
1728 | else | 1728 | else |
1729 | { | 1729 | { |
1730 | prefwin->Markup(1); | 1730 | prefwin->Markup(1); |
1731 | } | 1731 | } |
1732 | prefwin->Depluck(reader->bdepluck); | 1732 | prefwin->Depluck(reader->bdepluck); |
1733 | prefwin->Dejpluck(reader->bdejpluck); | 1733 | prefwin->Dejpluck(reader->bdejpluck); |
1734 | prefwin->Continuous(reader->m_continuousDocument); | 1734 | prefwin->Continuous(reader->m_continuousDocument); |
1735 | 1735 | ||
1736 | prefwin->dictApplication(m_targetapp); | 1736 | prefwin->dictApplication(m_targetapp); |
1737 | prefwin->dictMessage(m_targetmsg); | 1737 | prefwin->dictMessage(m_targetmsg); |
1738 | 1738 | ||
1739 | prefwin->spaceAction(m_spaceTarget); | 1739 | prefwin->spaceAction(m_spaceTarget); |
1740 | prefwin->escapeAction(m_escapeTarget); | 1740 | prefwin->escapeAction(m_escapeTarget); |
1741 | prefwin->returnAction(m_returnTarget); | 1741 | prefwin->returnAction(m_returnTarget); |
1742 | prefwin->leftAction(m_leftTarget); | 1742 | prefwin->leftAction(m_leftTarget); |
1743 | prefwin->rightAction(m_rightTarget); | 1743 | prefwin->rightAction(m_rightTarget); |
1744 | prefwin->upAction(m_upTarget); | 1744 | prefwin->upAction(m_upTarget); |
1745 | prefwin->downAction(m_downTarget); | 1745 | prefwin->downAction(m_downTarget); |
1746 | 1746 | ||
1747 | prefwin->leftScroll(m_leftScroll); | 1747 | prefwin->leftScroll(m_leftScroll); |
1748 | prefwin->rightScroll(m_rightScroll); | 1748 | prefwin->rightScroll(m_rightScroll); |
1749 | prefwin->upScroll(m_upScroll); | 1749 | prefwin->upScroll(m_upScroll); |
1750 | prefwin->downScroll(m_downScroll); | 1750 | prefwin->downScroll(m_downScroll); |
1751 | 1751 | ||
1752 | prefwin->miscannotation(m_doAnnotation); | 1752 | prefwin->miscannotation(m_doAnnotation); |
1753 | prefwin->miscdictionary(m_doDictionary); | 1753 | prefwin->miscdictionary(m_doDictionary); |
1754 | prefwin->miscclipboard(m_doClipboard); | 1754 | prefwin->miscclipboard(m_doClipboard); |
1755 | 1755 | ||
1756 | prefwin->SwapMouse(reader->m_swapmouse); | 1756 | prefwin->SwapMouse(reader->m_swapmouse); |
1757 | 1757 | ||
1758 | prefwin->Font(reader->m_fontname); | 1758 | prefwin->Font(reader->m_fontname); |
1759 | 1759 | ||
1760 | prefwin->gfxsize(reader->getBaseSize()); | 1760 | prefwin->gfxsize(reader->getBaseSize()); |
1761 | 1761 | ||
1762 | prefwin->pageoverlap(reader->m_overlap); | 1762 | prefwin->pageoverlap(reader->m_overlap); |
1763 | 1763 | ||
1764 | prefwin->ideogram(reader->m_bMonoSpaced); | 1764 | prefwin->ideogram(reader->m_bMonoSpaced); |
1765 | 1765 | ||
1766 | prefwin->encoding(reader->m_encd); | 1766 | prefwin->encoding(reader->m_encd); |
1767 | 1767 | ||
1768 | prefwin->ideogramwidth(reader->m_charpc); | 1768 | prefwin->ideogramwidth(reader->m_charpc); |
1769 | 1769 | ||
1770 | if (prefwin->exec()) | 1770 | if (prefwin->exec()) |
1771 | { | 1771 | { |
1772 | m_twoTouch = prefwin->twotouch(); | 1772 | m_twoTouch = prefwin->twotouch(); |
1773 | reader->setTwoTouch(m_twoTouch); | 1773 | reader->setTwoTouch(m_twoTouch); |
1774 | m_touch_action->setOn(m_twoTouch); | 1774 | m_touch_action->setOn(m_twoTouch); |
1775 | 1775 | ||
1776 | reader->bstripcr = prefwin->StripCR(); | 1776 | reader->bstripcr = prefwin->StripCR(); |
1777 | reader->bdehyphen = prefwin->Dehyphen(); | 1777 | reader->bdehyphen = prefwin->Dehyphen(); |
1778 | reader->bonespace = prefwin->SingleSpace(); | 1778 | reader->bonespace = prefwin->SingleSpace(); |
1779 | reader->bunindent = prefwin->Unindent(); | 1779 | reader->bunindent = prefwin->Unindent(); |
1780 | reader->brepara = prefwin->Reparagraph(); | 1780 | reader->brepara = prefwin->Reparagraph(); |
1781 | reader->bdblspce = prefwin->DoubleSpace(); | 1781 | reader->bdblspce = prefwin->DoubleSpace(); |
1782 | reader->bremap = prefwin->Remap(); | 1782 | reader->bremap = prefwin->Remap(); |
1783 | reader->bmakebold = prefwin->Embolden(); | 1783 | reader->bmakebold = prefwin->Embolden(); |
1784 | reader->bfulljust = prefwin->FullJustify(); | 1784 | reader->bfulljust = prefwin->FullJustify(); |
1785 | reader->setextraspace(prefwin->ParaLead()); | 1785 | reader->setextraspace(prefwin->ParaLead()); |
1786 | reader->setlead(prefwin->LineLead()); | 1786 | reader->setlead(prefwin->LineLead()); |
1787 | reader->m_border = prefwin->Margin(); | 1787 | reader->m_border = prefwin->Margin(); |
1788 | reader->bindenter = prefwin->Indent(); | 1788 | reader->bindenter = prefwin->Indent(); |
1789 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; | 1789 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; |
1790 | switch (prefwin->Markup()) | 1790 | switch (prefwin->Markup()) |
1791 | { | 1791 | { |
1792 | case 0: | 1792 | case 0: |
1793 | reader->bautofmt = true; | 1793 | reader->bautofmt = true; |
1794 | break; | 1794 | break; |
1795 | case 1: | 1795 | case 1: |
1796 | break; | 1796 | break; |
1797 | case 2: | 1797 | case 2: |
1798 | reader->btextfmt = true; | 1798 | reader->btextfmt = true; |
1799 | break; | 1799 | break; |
1800 | case 3: | 1800 | case 3: |
1801 | reader->bstriphtml = true; | 1801 | reader->bstriphtml = true; |
1802 | break; | 1802 | break; |
1803 | case 4: | 1803 | case 4: |
1804 | reader->bpeanut = true; | 1804 | reader->bpeanut = true; |
1805 | break; | 1805 | break; |
1806 | default: | 1806 | default: |
1807 | qDebug("Format out of range"); | 1807 | qDebug("Format out of range"); |
1808 | } | 1808 | } |
1809 | reader->bdepluck = prefwin->Depluck(); | 1809 | reader->bdepluck = prefwin->Depluck(); |
1810 | reader->bdejpluck = prefwin->Dejpluck(); | 1810 | reader->bdejpluck = prefwin->Dejpluck(); |
1811 | reader->setContinuous(prefwin->Continuous()); | 1811 | reader->setContinuous(prefwin->Continuous()); |
1812 | 1812 | ||
1813 | m_spaceTarget = (ActionTypes)prefwin->spaceAction(); | 1813 | m_spaceTarget = (ActionTypes)prefwin->spaceAction(); |
1814 | m_escapeTarget = (ActionTypes)prefwin->escapeAction(); | 1814 | m_escapeTarget = (ActionTypes)prefwin->escapeAction(); |
1815 | m_returnTarget = (ActionTypes)prefwin->returnAction(); | 1815 | m_returnTarget = (ActionTypes)prefwin->returnAction(); |
1816 | m_leftTarget = (ActionTypes)prefwin->leftAction(); | 1816 | m_leftTarget = (ActionTypes)prefwin->leftAction(); |
1817 | m_rightTarget = (ActionTypes)prefwin->rightAction(); | 1817 | m_rightTarget = (ActionTypes)prefwin->rightAction(); |
1818 | m_upTarget = (ActionTypes)prefwin->upAction(); | 1818 | m_upTarget = (ActionTypes)prefwin->upAction(); |
1819 | m_downTarget = (ActionTypes)prefwin->downAction(); | 1819 | m_downTarget = (ActionTypes)prefwin->downAction(); |
1820 | m_leftScroll = prefwin->leftScroll(); | 1820 | m_leftScroll = prefwin->leftScroll(); |
1821 | m_rightScroll = prefwin->rightScroll(); | 1821 | m_rightScroll = prefwin->rightScroll(); |
1822 | m_upScroll = prefwin->upScroll(); | 1822 | m_upScroll = prefwin->upScroll(); |
1823 | m_downScroll = prefwin->downScroll(); | 1823 | m_downScroll = prefwin->downScroll(); |
1824 | 1824 | ||
1825 | m_targetapp = prefwin->dictApplication(); | 1825 | m_targetapp = prefwin->dictApplication(); |
1826 | m_targetmsg = prefwin->dictMessage(); | 1826 | m_targetmsg = prefwin->dictMessage(); |
1827 | 1827 | ||
1828 | m_doAnnotation = prefwin->miscannotation(); | 1828 | m_doAnnotation = prefwin->miscannotation(); |
1829 | m_doDictionary = prefwin->miscdictionary(); | 1829 | m_doDictionary = prefwin->miscdictionary(); |
1830 | m_doClipboard = prefwin->miscclipboard(); | 1830 | m_doClipboard = prefwin->miscclipboard(); |
1831 | reader->m_swapmouse = prefwin->SwapMouse(); | 1831 | reader->m_swapmouse = prefwin->SwapMouse(); |
1832 | reader->setBaseSize(prefwin->gfxsize()); | 1832 | reader->setBaseSize(prefwin->gfxsize()); |
1833 | reader->m_overlap = prefwin->pageoverlap(); | 1833 | reader->m_overlap = prefwin->pageoverlap(); |
1834 | reader->m_bMonoSpaced = prefwin->ideogram(); | 1834 | reader->m_bMonoSpaced = prefwin->ideogram(); |
1835 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 1835 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
1836 | reader->m_encd = prefwin->encoding(); | 1836 | reader->m_encd = prefwin->encoding(); |
1837 | reader->m_charpc = prefwin->ideogramwidth(); | 1837 | reader->m_charpc = prefwin->ideogramwidth(); |
1838 | 1838 | ||
1839 | if ( | 1839 | if ( |
1840 | reader->m_fontname != prefwin->Font() | 1840 | reader->m_fontname != prefwin->Font() |
1841 | || | 1841 | || |
1842 | m_propogatefontchange != prefwin->propfontchange()) | 1842 | m_propogatefontchange != prefwin->propfontchange()) |
1843 | { | 1843 | { |
1844 | m_propogatefontchange = prefwin->propfontchange(); | 1844 | m_propogatefontchange = prefwin->propfontchange(); |
1845 | setfontHelper(prefwin->Font()); | 1845 | setfontHelper(prefwin->Font()); |
1846 | } | 1846 | } |
1847 | delete prefwin; | 1847 | delete prefwin; |
1848 | reader->setfilter(reader->getfilter()); | 1848 | reader->setfilter(reader->getfilter()); |
1849 | reader->refresh(); | 1849 | reader->refresh(); |
1850 | 1850 | ||
1851 | } | 1851 | } |
1852 | else | 1852 | else |
1853 | { | 1853 | { |
1854 | delete prefwin; | 1854 | delete prefwin; |
1855 | } | 1855 | } |
1856 | } | 1856 | } |
1857 | 1857 | ||
1858 | void QTReaderApp::showtoolbarprefs() | 1858 | void QTReaderApp::showtoolbarprefs() |
1859 | { | 1859 | { |
1860 | #ifdef USEQPE | 1860 | #ifdef USEQPE |
1861 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); | 1861 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); |
1862 | #else | 1862 | #else |
1863 | QFileInfo fi; | 1863 | QFileInfo fi; |
1864 | QDir d = QDir::home(); // "/" | 1864 | QDir d = QDir::home(); // "/" |
1865 | if ( !d.cd(APPDIR) ) | 1865 | if ( !d.cd(APPDIR) ) |
1866 | { // "/tmp" | 1866 | { // "/tmp" |
1867 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 1867 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
1868 | d = QDir::home(); | 1868 | d = QDir::home(); |
1869 | d.mkdir(APPDIR); | 1869 | d.mkdir(APPDIR); |
1870 | d.cd(APPDIR); | 1870 | d.cd(APPDIR); |
1871 | } | 1871 | } |
1872 | fi.setFile(d, INIFILE); | 1872 | fi.setFile(d, INIFILE); |
1873 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); | 1873 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); |
1874 | #endif | 1874 | #endif |
1875 | prefwin->tbpolicy(m_tbpolsave); | 1875 | prefwin->tbpolicy(m_tbpolsave); |
1876 | prefwin->tbposition(m_tbposition-2); | 1876 | prefwin->tbposition(m_tbposition-2); |
1877 | prefwin->tbmovable(m_tbmovesave); | 1877 | prefwin->tbmovable(m_tbmovesave); |
1878 | prefwin->floating(m_bFloatingDialog); | 1878 | prefwin->floating(m_bFloatingDialog); |
1879 | if (prefwin->exec()) | 1879 | if (prefwin->exec()) |
1880 | { | 1880 | { |
1881 | m_bFloatingDialog = prefwin->floating(); | 1881 | m_bFloatingDialog = prefwin->floating(); |
1882 | if ( | 1882 | if ( |
1883 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() | 1883 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() |
1884 | || | 1884 | || |
1885 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) | 1885 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) |
1886 | || | 1886 | || |
1887 | m_tbmovesave != prefwin->tbmovable() | 1887 | m_tbmovesave != prefwin->tbmovable() |
1888 | ) | 1888 | ) |
1889 | { | 1889 | { |
1890 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); | 1890 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); |
1891 | } | 1891 | } |
1892 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); | 1892 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); |
1893 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); | 1893 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); |
1894 | m_tbmovesave = prefwin->tbmovable(); | 1894 | m_tbmovesave = prefwin->tbmovable(); |
1895 | bool isChanged = prefwin->isChanged(); | 1895 | bool isChanged = prefwin->isChanged(); |
1896 | delete prefwin; | 1896 | delete prefwin; |
1897 | #ifdef USEQPE | 1897 | #ifdef USEQPE |
1898 | Config config( APPDIR ); | 1898 | Config config( APPDIR ); |
1899 | #else | 1899 | #else |
1900 | QFileInfo fi; | 1900 | QFileInfo fi; |
1901 | QDir d = QDir::home(); // "/" | 1901 | QDir d = QDir::home(); // "/" |
1902 | if ( !d.cd(APPDIR) ) | 1902 | if ( !d.cd(APPDIR) ) |
1903 | { // "/tmp" | 1903 | { // "/tmp" |
1904 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 1904 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
1905 | d = QDir::home(); | 1905 | d = QDir::home(); |
1906 | d.mkdir(APPDIR); | 1906 | d.mkdir(APPDIR); |
1907 | d.cd(APPDIR); | 1907 | d.cd(APPDIR); |
1908 | } | 1908 | } |
1909 | fi.setFile(d, INIFILE); | 1909 | fi.setFile(d, INIFILE); |
1910 | Config config( fi.absFilePath() ); | 1910 | Config config( fi.absFilePath() ); |
1911 | #endif | 1911 | #endif |
1912 | if (isChanged) addtoolbars(&config); | 1912 | if (isChanged) addtoolbars(&config); |
1913 | } | 1913 | } |
1914 | else | 1914 | else |
1915 | { | 1915 | { |
1916 | delete prefwin; | 1916 | delete prefwin; |
1917 | } | 1917 | } |
1918 | } | 1918 | } |
1919 | 1919 | ||
1920 | void QTReaderApp::showinfo() | 1920 | void QTReaderApp::showinfo() |
1921 | { | 1921 | { |
1922 | unsigned long fs, ts, pl; | 1922 | unsigned long fs, ts, pl; |
1923 | if (reader->empty()) | 1923 | if (reader->empty()) |
1924 | { | 1924 | { |
1925 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 1925 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
1926 | } | 1926 | } |
1927 | else | 1927 | else |
1928 | { | 1928 | { |
1929 | reader->sizes(fs,ts); | 1929 | reader->sizes(fs,ts); |
1930 | pl = reader->pagelocate(); | 1930 | pl = reader->pagelocate(); |
1931 | m_infoWin->setFileSize(fs); | 1931 | m_infoWin->setFileSize(fs); |
1932 | m_infoWin->setTextSize(ts); | 1932 | m_infoWin->setTextSize(ts); |
1933 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 1933 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); |
1934 | m_infoWin->setLocation(pl); | 1934 | m_infoWin->setLocation(pl); |
1935 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 1935 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); |
1936 | editorStack->raiseWidget( m_infoWin ); | 1936 | editorStack->raiseWidget( m_infoWin ); |
1937 | m_infoWin->setFocus(); | 1937 | m_infoWin->setFocus(); |
1938 | } | 1938 | } |
1939 | } | 1939 | } |
1940 | 1940 | ||
1941 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) | 1941 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) |
1942 | { | 1942 | { |
1943 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; | 1943 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; |
1944 | #ifdef _UNICODE | 1944 | #ifdef _UNICODE |
1945 | CBuffer buff(name.length()+1); | 1945 | CBuffer buff(name.length()+1); |
1946 | int i; | 1946 | int i; |
1947 | for (i = 0; i < name.length(); i++) | 1947 | for (i = 0; i < name.length(); i++) |
1948 | { | 1948 | { |
1949 | buff[i] = name[i].unicode(); | 1949 | buff[i] = name[i].unicode(); |
1950 | } | 1950 | } |
1951 | buff[i] = 0; | 1951 | buff[i] = 0; |
1952 | CBuffer buff2(text.length()+1); | 1952 | CBuffer buff2(text.length()+1); |
1953 | for (i = 0; i < text.length(); i++) | 1953 | for (i = 0; i < text.length(); i++) |
1954 | { | 1954 | { |
1955 | buff2[i] = text[i].unicode(); | 1955 | buff2[i] = text[i].unicode(); |
1956 | } | 1956 | } |
1957 | buff2[i] = 0; | 1957 | buff2[i] = 0; |
1958 | pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); | 1958 | pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); |
1959 | #else | 1959 | #else |
1960 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); | 1960 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); |
1961 | #endif | 1961 | #endif |
1962 | m_fBkmksChanged = true; | 1962 | m_fBkmksChanged = true; |
1963 | pBkmklist->sort(); | 1963 | pBkmklist->sort(); |
1964 | } | 1964 | } |
1965 | 1965 | ||
1966 | void QTReaderApp::addAnno(const QString& name, const QString& text) | 1966 | void QTReaderApp::addAnno(const QString& name, const QString& text) |
1967 | { | 1967 | { |
1968 | if (m_annoIsEditing) | 1968 | if (m_annoIsEditing) |
1969 | { | 1969 | { |
1970 | if (name.isEmpty()) | 1970 | if (name.isEmpty()) |
1971 | { | 1971 | { |
1972 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); | 1972 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); |
1973 | } | 1973 | } |
1974 | else | 1974 | else |
1975 | { | 1975 | { |
1976 | addAnno(name, text, m_annoWin->getPosn()); | 1976 | addAnno(name, text, m_annoWin->getPosn()); |
1977 | } | 1977 | } |
1978 | showEditTools(); | 1978 | showEditTools(); |
1979 | } | 1979 | } |
1980 | else | 1980 | else |
1981 | { | 1981 | { |
1982 | if (m_annoWin->edited()) | 1982 | if (m_annoWin->edited()) |
1983 | { | 1983 | { |
1984 | CBuffer buff(text.length()+1); | 1984 | CBuffer buff(text.length()+1); |
1985 | int i; | 1985 | int i; |
1986 | for (i = 0; i < text.length(); i++) | 1986 | for (i = 0; i < text.length(); i++) |
1987 | { | 1987 | { |
1988 | buff[i] = text[i].unicode(); | 1988 | buff[i] = text[i].unicode(); |
1989 | } | 1989 | } |
1990 | buff[i] = 0; | 1990 | buff[i] = 0; |
1991 | m_fBkmksChanged = true; | 1991 | m_fBkmksChanged = true; |
1992 | m_anno->setAnno(buff.data()); | 1992 | m_anno->setAnno(buff.data()); |
1993 | } | 1993 | } |
1994 | bool found = findNextBookmark(m_anno->value()+1); | 1994 | bool found = findNextBookmark(m_anno->value()+1); |
1995 | if (found) | 1995 | if (found) |
1996 | { | 1996 | { |
1997 | m_annoWin->setName(toQString(m_anno->name())); | 1997 | m_annoWin->setName(toQString(m_anno->name())); |
1998 | m_annoWin->setAnno(toQString(m_anno->anno())); | 1998 | m_annoWin->setAnno(toQString(m_anno->anno())); |
1999 | } | 1999 | } |
2000 | else | 2000 | else |
2001 | { | 2001 | { |
2002 | showEditTools(); | 2002 | showEditTools(); |
2003 | } | 2003 | } |
2004 | } | 2004 | } |
2005 | } | 2005 | } |
2006 | 2006 | ||
2007 | bool QTReaderApp::findNextBookmark(size_t start) | 2007 | bool QTReaderApp::findNextBookmark(size_t start) |
2008 | { | 2008 | { |
2009 | bool found = false; | 2009 | bool found = false; |
2010 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) | 2010 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) |
2011 | { | 2011 | { |
2012 | if (iter->value() >= start) | 2012 | if (iter->value() >= start) |
2013 | { | 2013 | { |
2014 | if (iter->value() < reader->locate()) | 2014 | if (iter->value() < reader->locate()) |
2015 | { | 2015 | { |
2016 | found = true; | 2016 | found = true; |
2017 | m_anno = iter.pContent(); | 2017 | m_anno = iter.pContent(); |
2018 | } | 2018 | } |
2019 | break; | 2019 | break; |
2020 | } | 2020 | } |
2021 | } | 2021 | } |
2022 | return found; | 2022 | return found; |
2023 | } | 2023 | } |
2024 | 2024 | ||
2025 | void QTReaderApp::addanno() | 2025 | void QTReaderApp::addanno() |
2026 | { | 2026 | { |
2027 | if (reader->empty()) | 2027 | if (reader->empty()) |
2028 | { | 2028 | { |
2029 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2029 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2030 | } | 2030 | } |
2031 | else | 2031 | else |
2032 | { | 2032 | { |
2033 | m_annoWin->setName(""); | 2033 | m_annoWin->setName(""); |
2034 | m_annoWin->setAnno(""); | 2034 | m_annoWin->setAnno(""); |
2035 | m_annoWin->setPosn(reader->pagelocate()); | 2035 | m_annoWin->setPosn(reader->pagelocate()); |
2036 | m_annoIsEditing = true; | 2036 | m_annoIsEditing = true; |
2037 | editorStack->raiseWidget( m_annoWin ); | 2037 | editorStack->raiseWidget( m_annoWin ); |
2038 | #ifdef USEQPE | 2038 | #ifdef USEQPE |
2039 | Global::showInputMethod(); | 2039 | Global::showInputMethod(); |
2040 | #endif | 2040 | #endif |
2041 | m_annoWin->setFocus(); | 2041 | m_annoWin->setFocus(); |
2042 | } | 2042 | } |
2043 | } | 2043 | } |
2044 | 2044 | ||
2045 | void QTReaderApp::infoClose() | 2045 | void QTReaderApp::infoClose() |
2046 | { | 2046 | { |
2047 | showEditTools(); | 2047 | showEditTools(); |
2048 | } | 2048 | } |
2049 | 2049 | ||
2050 | /* | 2050 | /* |
2051 | void QTReaderApp::fileRevert() | 2051 | void QTReaderApp::fileRevert() |
2052 | { | 2052 | { |
2053 | clear(); | 2053 | clear(); |
2054 | fileOpen(); | 2054 | fileOpen(); |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | void QTReaderApp::editCut() | 2057 | void QTReaderApp::editCut() |
2058 | { | 2058 | { |
2059 | #ifndef QT_NO_CLIPBOARD | 2059 | #ifndef QT_NO_CLIPBOARD |
2060 | editor->cut(); | 2060 | editor->cut(); |
2061 | #endif | 2061 | #endif |
2062 | } | 2062 | } |
2063 | */ | 2063 | */ |
2064 | void QTReaderApp::editMark() | 2064 | void QTReaderApp::editMark() |
2065 | { | 2065 | { |
2066 | m_savedpos = reader->pagelocate(); | 2066 | m_savedpos = reader->pagelocate(); |
2067 | } | 2067 | } |
2068 | 2068 | ||
2069 | void QTReaderApp::editCopy() | 2069 | void QTReaderApp::editCopy() |
2070 | { | 2070 | { |
2071 | QClipboard* cb = QApplication::clipboard(); | 2071 | QClipboard* cb = QApplication::clipboard(); |
2072 | QString text; | 2072 | QString text; |
2073 | int ch; | 2073 | int ch; |
2074 | unsigned long currentpos = reader->pagelocate(); | 2074 | unsigned long currentpos = reader->pagelocate(); |
2075 | unsigned long endpos = reader->locate(); | 2075 | unsigned long endpos = reader->locate(); |
2076 | if (m_savedpos == 0xffffffff) | 2076 | if (m_savedpos == 0xffffffff) |
2077 | { | 2077 | { |
2078 | m_savedpos = currentpos; | 2078 | m_savedpos = currentpos; |
2079 | } | 2079 | } |
2080 | reader->jumpto(m_savedpos); | 2080 | reader->jumpto(m_savedpos); |
2081 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) | 2081 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) |
2082 | { | 2082 | { |
2083 | text += ch; | 2083 | text += ch; |
2084 | } | 2084 | } |
2085 | cb->setText(text); | 2085 | cb->setText(text); |
2086 | reader->locate(currentpos); | 2086 | reader->locate(currentpos); |
2087 | m_savedpos = 0xffffffff; | 2087 | m_savedpos = 0xffffffff; |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | void QTReaderApp::gotoStart() | 2090 | void QTReaderApp::gotoStart() |
2091 | { | 2091 | { |
2092 | reader->locate(reader->buffdoc.startSection()); | 2092 | reader->locate(reader->buffdoc.startSection()); |
2093 | } | 2093 | } |
2094 | 2094 | ||
2095 | void QTReaderApp::gotoEnd() | 2095 | void QTReaderApp::gotoEnd() |
2096 | { | 2096 | { |
2097 | reader->dopageup(reader->buffdoc.endSection()); | 2097 | reader->dopageup(reader->buffdoc.endSection()); |
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | void QTReaderApp::pageup() | 2100 | void QTReaderApp::pageup() |
2101 | { | 2101 | { |
2102 | reader->NavUp(); | 2102 | reader->NavUp(); |
2103 | } | 2103 | } |
2104 | 2104 | ||
2105 | void QTReaderApp::pagedn() | 2105 | void QTReaderApp::pagedn() |
2106 | { | 2106 | { |
2107 | reader->NavDown(); | 2107 | reader->NavDown(); |
2108 | } | 2108 | } |
2109 | 2109 | ||
2110 | void QTReaderApp::pagemode(bool _b) | 2110 | void QTReaderApp::pagemode(bool _b) |
2111 | { | 2111 | { |
2112 | reader->setpagemode(_b); | 2112 | reader->setpagemode(_b); |
2113 | } | 2113 | } |
2114 | 2114 | ||
2115 | /* | 2115 | /* |
2116 | void QTReaderApp::setspacing() | 2116 | void QTReaderApp::setspacing() |
2117 | { | 2117 | { |
2118 | m_nRegAction = cMonoSpace; | 2118 | m_nRegAction = cMonoSpace; |
2119 | char lcn[20]; | 2119 | char lcn[20]; |
2120 | sprintf(lcn, "%lu", reader->m_charpc); | 2120 | sprintf(lcn, "%lu", reader->m_charpc); |
2121 | regEdit->setText(lcn); | 2121 | regEdit->setText(lcn); |
2122 | do_regedit(); | 2122 | do_regedit(); |
2123 | } | 2123 | } |
2124 | */ | 2124 | */ |
2125 | void QTReaderApp::settarget() | 2125 | void QTReaderApp::settarget() |
2126 | { | 2126 | { |
2127 | m_nRegAction = cSetTarget; | 2127 | m_nRegAction = cSetTarget; |
2128 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) | 2128 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) |
2129 | + "/" | 2129 | + "/" |
2130 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); | 2130 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); |
2131 | regEdit->setText(text); | 2131 | regEdit->setText(text); |
2132 | do_regedit(); | 2132 | do_regedit(); |
2133 | } | 2133 | } |
2134 | 2134 | ||
2135 | /* | 2135 | /* |
2136 | void QTReaderApp::do_mono(const QString& lcn) | 2136 | void QTReaderApp::do_mono(const QString& lcn) |
2137 | { | 2137 | { |
2138 | bool ok; | 2138 | bool ok; |
2139 | unsigned long ulcn = lcn.toULong(&ok); | 2139 | unsigned long ulcn = lcn.toULong(&ok); |
2140 | if (ok) | 2140 | if (ok) |
2141 | { | 2141 | { |
2142 | reader->m_charpc = ulcn; | 2142 | reader->m_charpc = ulcn; |
2143 | reader->setfont(); | 2143 | reader->setfont(); |
2144 | reader->refresh(); | 2144 | reader->refresh(); |
2145 | //reader->setmono(true); | 2145 | //reader->setmono(true); |
2146 | } | 2146 | } |
2147 | else | 2147 | else |
2148 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2148 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
2149 | } | 2149 | } |
2150 | */ | 2150 | */ |
2151 | /* | 2151 | /* |
2152 | void QTReaderApp::editPaste() | 2152 | void QTReaderApp::editPaste() |
2153 | { | 2153 | { |
2154 | #ifndef QT_NO_CLIPBOARD | 2154 | #ifndef QT_NO_CLIPBOARD |
2155 | editor->paste(); | 2155 | editor->paste(); |
2156 | #endif | 2156 | #endif |
2157 | } | 2157 | } |
2158 | */ | 2158 | */ |
2159 | 2159 | ||
2160 | void QTReaderApp::editFind() | 2160 | void QTReaderApp::editFind() |
2161 | { | 2161 | { |
2162 | searchStart = reader->pagelocate(); | 2162 | searchStart = reader->pagelocate(); |
2163 | #ifdef __ISEARCH | 2163 | #ifdef __ISEARCH |
2164 | searchStack = new QStack<searchrecord>; | 2164 | searchStack = new QStack<searchrecord>; |
2165 | #endif | 2165 | #endif |
2166 | #ifdef USEQPE | 2166 | #ifdef USEQPE |
2167 | Global::showInputMethod(); | 2167 | Global::showInputMethod(); |
2168 | #endif | 2168 | #endif |
2169 | searchBar->show(); | 2169 | searchBar->show(); |
2170 | searchVisible = TRUE; | 2170 | searchVisible = TRUE; |
2171 | searchEdit->setFocus(); | 2171 | searchEdit->setFocus(); |
2172 | #ifdef __ISEARCH | 2172 | #ifdef __ISEARCH |
2173 | searchStack->push(new searchrecord("",reader->pagelocate())); | 2173 | searchStack->push(new searchrecord("",reader->pagelocate())); |
2174 | #endif | 2174 | #endif |
2175 | } | 2175 | } |
2176 | 2176 | ||
2177 | void QTReaderApp::findNext() | 2177 | void QTReaderApp::findNext() |
2178 | { | 2178 | { |
2179 | // // qDebug("findNext called\n"); | 2179 | // // qDebug("findNext called\n"); |
2180 | #ifdef __ISEARCH | 2180 | #ifdef __ISEARCH |
2181 | QString arg = searchEdit->text(); | 2181 | QString arg = searchEdit->text(); |
2182 | #else | 2182 | #else |
2183 | QRegExp arg = searchEdit->text(); | 2183 | QRegExp arg = searchEdit->text(); |
2184 | #endif | 2184 | #endif |
2185 | CDrawBuffer test(&(reader->m_fontControl)); | 2185 | CDrawBuffer test(&(reader->m_fontControl)); |
2186 | size_t start = reader->pagelocate(); | 2186 | size_t start = reader->pagelocate(); |
2187 | reader->jumpto(start); | 2187 | reader->jumpto(start); |
2188 | reader->getline(&test); | 2188 | reader->getline(&test); |
2189 | dosearch(start, test, arg); | 2189 | dosearch(start, test, arg); |
2190 | } | 2190 | } |
2191 | 2191 | ||
2192 | void QTReaderApp::findClose() | 2192 | void QTReaderApp::findClose() |
2193 | { | 2193 | { |
2194 | searchVisible = FALSE; | 2194 | searchVisible = FALSE; |
2195 | searchEdit->setText(""); | 2195 | searchEdit->setText(""); |
2196 | #ifdef USEQPE | 2196 | #ifdef USEQPE |
2197 | Global::hideInputMethod(); | 2197 | Global::hideInputMethod(); |
2198 | #endif | 2198 | #endif |
2199 | searchBar->hide(); | 2199 | searchBar->hide(); |
2200 | #ifdef __ISEARCH | 2200 | #ifdef __ISEARCH |
2201 | // searchStack = new QStack<searchrecord>; | 2201 | // searchStack = new QStack<searchrecord>; |
2202 | while (!searchStack->isEmpty()) | 2202 | while (!searchStack->isEmpty()) |
2203 | { | 2203 | { |
2204 | delete searchStack->pop(); | 2204 | delete searchStack->pop(); |
2205 | } | 2205 | } |
2206 | delete searchStack; | 2206 | delete searchStack; |
2207 | #endif | 2207 | #endif |
2208 | reader->setFocus(); | 2208 | reader->setFocus(); |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | void QTReaderApp::regClose() | 2211 | void QTReaderApp::regClose() |
2212 | { | 2212 | { |
2213 | regVisible = FALSE; | 2213 | regVisible = FALSE; |
2214 | regEdit->setText(""); | 2214 | regEdit->setText(""); |
2215 | regBar->hide(); | 2215 | regBar->hide(); |
2216 | #ifdef USEQPE | 2216 | #ifdef USEQPE |
2217 | Global::hideInputMethod(); | 2217 | Global::hideInputMethod(); |
2218 | #endif | 2218 | #endif |
2219 | reader->setFocus(); | 2219 | reader->setFocus(); |
2220 | } | 2220 | } |
2221 | 2221 | ||
2222 | #ifdef __ISEARCH | 2222 | #ifdef __ISEARCH |
2223 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) | 2223 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) |
2224 | #else | 2224 | #else |
2225 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | 2225 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) |
2226 | #endif | 2226 | #endif |
2227 | { | 2227 | { |
2228 | bool ret = true; | 2228 | bool ret = true; |
2229 | unsigned long fs, ts; | 2229 | unsigned long fs, ts; |
2230 | reader->sizes(fs,ts); | 2230 | reader->sizes(fs,ts); |
2231 | size_t pos = reader->locate(); | 2231 | size_t pos = reader->locate(); |
2232 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); | 2232 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); |
2233 | pbar->show(); | 2233 | pbar->show(); |
2234 | pbar->raise(); | 2234 | pbar->raise(); |
2235 | pbar->reset(); | 2235 | pbar->reset(); |
2236 | int offset; | 2236 | int offset; |
2237 | int lastpc = (100*pos)/ts; | 2237 | int lastpc = (100*pos)/ts; |
2238 | pbar->setProgress(lastpc); | 2238 | pbar->setProgress(lastpc); |
2239 | // qApp->processEvents(); | 2239 | // qApp->processEvents(); |
2240 | if (reader->buffdoc.getpara(test) >= 0) | 2240 | if (reader->buffdoc.getpara(test) >= 0) |
2241 | { | 2241 | { |
2242 | reader->setFocus(); | 2242 | reader->setFocus(); |
2243 | #ifdef __ISEARCH | 2243 | #ifdef __ISEARCH |
2244 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 2244 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
2245 | #else | 2245 | #else |
2246 | #ifdef _UNICODE | 2246 | #ifdef _UNICODE |
2247 | while ((offset = arg.match(toQString(test.data()))) == -1) | 2247 | while ((offset = arg.match(toQString(test.data()))) == -1) |
2248 | #else | 2248 | #else |
2249 | while (arg.match(test.data()) == -1) | 2249 | while (arg.match(test.data()) == -1) |
2250 | #endif | 2250 | #endif |
2251 | #endif | 2251 | #endif |
2252 | { | 2252 | { |
2253 | pos = reader->locate(); | 2253 | pos = reader->locate(); |
2254 | int pc = (100*pos)/ts; | 2254 | int pc = (100*pos)/ts; |
2255 | if (pc != lastpc) | 2255 | if (pc != lastpc) |
2256 | { | 2256 | { |
2257 | pbar->setProgress(pc); | 2257 | pbar->setProgress(pc); |
2258 | qApp->processEvents(); | 2258 | qApp->processEvents(); |
2259 | reader->setFocus(); | 2259 | reader->setFocus(); |
2260 | lastpc = pc; | 2260 | lastpc = pc; |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | if (reader->buffdoc.getpara(test) < 0) | 2263 | if (reader->buffdoc.getpara(test) < 0) |
2264 | { | 2264 | { |
2265 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2265 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2266 | pos = searchStart; | 2266 | pos = searchStart; |
2267 | else | 2267 | else |
2268 | pos = start; | 2268 | pos = start; |
2269 | findClose(); | 2269 | findClose(); |
2270 | pbar->hide(); | 2270 | pbar->hide(); |
2271 | reader->locate(pos); | 2271 | reader->locate(pos); |
2272 | return false; | 2272 | return false; |
2273 | } | 2273 | } |
2274 | } | 2274 | } |
2275 | // qDebug("Found it at %u:%u", pos, offset); | 2275 | // qDebug("Found it at %u:%u", pos, offset); |
2276 | pbar->hide(); | 2276 | pbar->hide(); |
2277 | // qDebug("Hid"); | 2277 | // qDebug("Hid"); |
2278 | reader->locate(pos+offset); | 2278 | reader->locate(pos+offset); |
2279 | // qDebug("Loacted"); | 2279 | // qDebug("Loacted"); |
2280 | // qDebug("page up"); | 2280 | // qDebug("page up"); |
2281 | ret = true; | 2281 | ret = true; |
2282 | } | 2282 | } |
2283 | else | 2283 | else |
2284 | { | 2284 | { |
2285 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2285 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2286 | pos = searchStart; | 2286 | pos = searchStart; |
2287 | else | 2287 | else |
2288 | pos = start; | 2288 | pos = start; |
2289 | ret = false; | 2289 | ret = false; |
2290 | findClose(); | 2290 | findClose(); |
2291 | } | 2291 | } |
2292 | return ret; | 2292 | return ret; |
2293 | } | 2293 | } |
2294 | 2294 | ||
2295 | #ifdef __ISEARCH | 2295 | #ifdef __ISEARCH |
2296 | void QTReaderApp::search(const QString & arg) | 2296 | void QTReaderApp::search(const QString & arg) |
2297 | { | 2297 | { |
2298 | searchrecord* ss = searchStack->top(); | 2298 | searchrecord* ss = searchStack->top(); |
2299 | CBuffer test; | 2299 | CBuffer test; |
2300 | size_t start = reader->pagelocate(); | 2300 | size_t start = reader->pagelocate(); |
2301 | bool haspopped = false; | 2301 | bool haspopped = false; |
2302 | while (arg.left(ss->s.length()) != ss->s) | 2302 | while (arg.left(ss->s.length()) != ss->s) |
2303 | { | 2303 | { |
2304 | haspopped = true; | 2304 | haspopped = true; |
2305 | start = ss->pos; | 2305 | start = ss->pos; |
2306 | // reader->locate(start); | 2306 | // reader->locate(start); |
2307 | searchStack->pop(); | 2307 | searchStack->pop(); |
2308 | delete ss; | 2308 | delete ss; |
2309 | } | 2309 | } |
2310 | if (haspopped) reader->locate(start); | 2310 | if (haspopped) reader->locate(start); |
2311 | /* | 2311 | /* |
2312 | if (arg.length() < ss->len) | 2312 | if (arg.length() < ss->len) |
2313 | { | 2313 | { |
2314 | start = ss->pos; | 2314 | start = ss->pos; |
2315 | reader->locate(start); | 2315 | reader->locate(start); |
2316 | searchStack->pop(); | 2316 | searchStack->pop(); |
2317 | delete ss; | 2317 | delete ss; |
2318 | } | 2318 | } |
2319 | */ | 2319 | */ |
2320 | else | 2320 | else |
2321 | { | 2321 | { |
2322 | start = reader->pagelocate(); | 2322 | start = reader->pagelocate(); |
2323 | reader->jumpto(start); | 2323 | reader->jumpto(start); |
2324 | searchStack->push(new searchrecord(arg,start)); | 2324 | searchStack->push(new searchrecord(arg,start)); |
2325 | } | 2325 | } |
2326 | dosearch(start, test, arg); | 2326 | dosearch(start, test, arg); |
2327 | } | 2327 | } |
2328 | #else | 2328 | #else |
2329 | void QTReaderApp::search() | 2329 | void QTReaderApp::search() |
2330 | { | 2330 | { |
2331 | findNext(); | 2331 | findNext(); |
2332 | } | 2332 | } |
2333 | #endif | 2333 | #endif |
2334 | 2334 | ||
2335 | void QTReaderApp::openFile( const QString &f ) | 2335 | void QTReaderApp::openFile( const QString &f ) |
2336 | { | 2336 | { |
2337 | // qDebug("File:%s", (const char*)f); | 2337 | // qDebug("File:%s", (const char*)f); |
2338 | // openFile(DocLnk(f)); | 2338 | // openFile(DocLnk(f)); |
2339 | //} | 2339 | //} |
2340 | // | 2340 | // |
2341 | //void QTReaderApp::openFile( const DocLnk &f ) | 2341 | //void QTReaderApp::openFile( const DocLnk &f ) |
2342 | //{ | 2342 | //{ |
2343 | clear(); | 2343 | clear(); |
2344 | QFileInfo fm(f); | 2344 | QFileInfo fm(f); |
2345 | if ( fm.exists() ) | 2345 | if ( fm.exists() ) |
2346 | { | 2346 | { |
2347 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 2347 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
2348 | #ifdef USEQPE | 2348 | #ifdef USEQPE |
2349 | if (fm.extension( FALSE ) == "desktop") | 2349 | if (fm.extension( FALSE ) == "desktop") |
2350 | { | 2350 | { |
2351 | DocLnk d(f); | 2351 | DocLnk d(f); |
2352 | QFileInfo fnew(d.file()); | 2352 | QFileInfo fnew(d.file()); |
2353 | fm = fnew; | 2353 | fm = fnew; |
2354 | if (!fm.exists()) return; | 2354 | if (!fm.exists()) return; |
2355 | } | 2355 | } |
2356 | #endif | 2356 | #endif |
2357 | clear(); | 2357 | clear(); |
2358 | 2358 | ||
2359 | reader->setText(fm.baseName(), fm.absFilePath()); | 2359 | reader->setText(fm.baseName(), fm.absFilePath()); |
2360 | m_loadedconfig = readconfig(reader->m_string, false); | 2360 | m_loadedconfig = readconfig(reader->m_string, false); |
2361 | showEditTools(); | 2361 | showEditTools(); |
2362 | readbkmks(); | 2362 | readbkmks(); |
2363 | m_savedpos = 0xffffffff; | 2363 | m_savedpos = 0xffffffff; |
2364 | } | 2364 | } |
2365 | else | 2365 | else |
2366 | { | 2366 | { |
2367 | QMessageBox::information(this, PROGNAME, "File does not exist"); | 2367 | QMessageBox::information(this, PROGNAME, "File does not exist"); |
2368 | reader->m_lastfile = QString::null; | 2368 | reader->m_lastfile = QString::null; |
2369 | } | 2369 | } |
2370 | 2370 | ||
2371 | } | 2371 | } |
2372 | /* | 2372 | /* |
2373 | void QTReaderApp::resizeEvent(QResizeEvent* e) | 2373 | void QTReaderApp::resizeEvent(QResizeEvent* e) |
2374 | { | 2374 | { |
2375 | if (m_fullscreen) | 2375 | if (m_fullscreen) |
2376 | { | 2376 | { |
2377 | showNormal(); | 2377 | showNormal(); |
2378 | showFullScreen(); | 2378 | showFullScreen(); |
2379 | } | 2379 | } |
2380 | } | 2380 | } |
2381 | */ | 2381 | */ |
2382 | void QTReaderApp::handlekey(QKeyEvent* e) | 2382 | void QTReaderApp::handlekey(QKeyEvent* e) |
2383 | { | 2383 | { |
2384 | // qDebug("Keypress event"); | 2384 | // qDebug("Keypress event"); |
2385 | timeb now; | 2385 | timeb now; |
2386 | ftime(&now); | 2386 | ftime(&now); |
2387 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; | 2387 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; |
2388 | if (etime < m_debounce) | 2388 | if (etime < m_debounce) |
2389 | { | 2389 | { |
2390 | return; | 2390 | return; |
2391 | } | 2391 | } |
2392 | m_lastkeytime = now; | 2392 | m_lastkeytime = now; |
2393 | switch(e->key()) | 2393 | switch(e->key()) |
2394 | { | 2394 | { |
2395 | case Key_Escape: | 2395 | case Key_Escape: |
2396 | // qDebug("escape event"); | 2396 | // qDebug("escape event"); |
2397 | if (m_disableesckey) | 2397 | if (m_disableesckey) |
2398 | { | 2398 | { |
2399 | m_disableesckey = false; | 2399 | m_disableesckey = false; |
2400 | } | 2400 | } |
2401 | else | 2401 | else |
2402 | { | 2402 | { |
2403 | m_bcloseDisabled = true; | 2403 | m_bcloseDisabled = true; |
2404 | if (m_fullscreen) | 2404 | if (m_fullscreen) |
2405 | { | 2405 | { |
2406 | m_actFullscreen->setOn(false); | 2406 | m_actFullscreen->setOn(false); |
2407 | e->accept(); | 2407 | e->accept(); |
2408 | } | 2408 | } |
2409 | else | 2409 | else |
2410 | { | 2410 | { |
2411 | // qDebug("escape action"); | 2411 | // qDebug("escape action"); |
2412 | doAction(m_escapeTarget, e); | 2412 | doAction(m_escapeTarget, e); |
2413 | } | 2413 | } |
2414 | } | 2414 | } |
2415 | break; | 2415 | break; |
2416 | case Key_Space: | 2416 | case Key_Space: |
2417 | { | 2417 | { |
2418 | doAction(m_spaceTarget, e); | 2418 | doAction(m_spaceTarget, e); |
2419 | } | 2419 | } |
2420 | break; | 2420 | break; |
2421 | case Key_Return: | 2421 | case Key_Return: |
2422 | { | 2422 | { |
2423 | doAction(m_returnTarget, e); | 2423 | doAction(m_returnTarget, e); |
2424 | } | 2424 | } |
2425 | break; | 2425 | break; |
2426 | case Key_Left: | 2426 | case Key_Left: |
2427 | { | 2427 | { |
2428 | if (reader->m_autoScroll && m_leftScroll) | 2428 | if (reader->m_autoScroll && m_leftScroll) |
2429 | { | 2429 | { |
2430 | reader->reduceScroll(); | 2430 | reader->reduceScroll(); |
2431 | } | 2431 | } |
2432 | else | 2432 | else |
2433 | { | 2433 | { |
2434 | doAction(m_leftTarget, e); | 2434 | doAction(m_leftTarget, e); |
2435 | } | 2435 | } |
2436 | } | 2436 | } |
2437 | break; | 2437 | break; |
2438 | case Key_Right: | 2438 | case Key_Right: |
2439 | { | 2439 | { |
2440 | if (reader->m_autoScroll && m_rightScroll) | 2440 | if (reader->m_autoScroll && m_rightScroll) |
2441 | { | 2441 | { |
2442 | reader->increaseScroll(); | 2442 | reader->increaseScroll(); |
2443 | } | 2443 | } |
2444 | else | 2444 | else |
2445 | { | 2445 | { |
2446 | doAction(m_rightTarget, e); | 2446 | doAction(m_rightTarget, e); |
2447 | } | 2447 | } |
2448 | } | 2448 | } |
2449 | break; | 2449 | break; |
2450 | case Key_Up: | 2450 | case Key_Up: |
2451 | { | 2451 | { |
2452 | if (reader->m_autoScroll && m_upScroll) | 2452 | if (reader->m_autoScroll && m_upScroll) |
2453 | { | 2453 | { |
2454 | reader->increaseScroll(); | 2454 | reader->increaseScroll(); |
2455 | } | 2455 | } |
2456 | else | 2456 | else |
2457 | { | 2457 | { |
2458 | doAction(m_upTarget, e); | 2458 | doAction(m_upTarget, e); |
2459 | } | 2459 | } |
2460 | } | 2460 | } |
2461 | break; | 2461 | break; |
2462 | case Key_Down: | 2462 | case Key_Down: |
2463 | { | 2463 | { |
2464 | if (reader->m_autoScroll && m_downScroll) | 2464 | if (reader->m_autoScroll && m_downScroll) |
2465 | { | 2465 | { |
2466 | reader->reduceScroll(); | 2466 | reader->reduceScroll(); |
2467 | } | 2467 | } |
2468 | else | 2468 | else |
2469 | { | 2469 | { |
2470 | doAction(m_downTarget, e); | 2470 | doAction(m_downTarget, e); |
2471 | } | 2471 | } |
2472 | } | 2472 | } |
2473 | break; | 2473 | break; |
2474 | default: | 2474 | default: |
2475 | { | 2475 | { |
2476 | e->ignore(); | 2476 | e->ignore(); |
2477 | } | 2477 | } |
2478 | 2478 | ||
2479 | /* | 2479 | /* |
2480 | QString msg("Key press was:"); | 2480 | QString msg("Key press was:"); |
2481 | QString key; | 2481 | QString key; |
2482 | msg += key.setNum(e->key()); | 2482 | msg += key.setNum(e->key()); |
2483 | QMessageBox::information(this, PROGNAME, msg); | 2483 | QMessageBox::information(this, PROGNAME, msg); |
2484 | */ | 2484 | */ |
2485 | } | 2485 | } |
2486 | } | 2486 | } |
2487 | 2487 | ||
2488 | void QTReaderApp::showEditTools() | 2488 | void QTReaderApp::showEditTools() |
2489 | { | 2489 | { |
2490 | // if ( !doc ) | 2490 | // if ( !doc ) |
2491 | //close(); | 2491 | //close(); |
2492 | if (m_fullscreen) | 2492 | if (m_fullscreen) |
2493 | { | 2493 | { |
2494 | if (menubar != NULL) menubar->hide(); | 2494 | if (menubar != NULL) menubar->hide(); |
2495 | if (fileBar != NULL) fileBar->hide(); | 2495 | if (fileBar != NULL) fileBar->hide(); |
2496 | if (viewBar != NULL) viewBar->hide(); | 2496 | if (viewBar != NULL) viewBar->hide(); |
2497 | if (navBar != NULL) navBar->hide(); | 2497 | if (navBar != NULL) navBar->hide(); |
2498 | if (markBar != NULL) markBar->hide(); | 2498 | if (markBar != NULL) markBar->hide(); |
2499 | searchBar->hide(); | 2499 | searchBar->hide(); |
2500 | regBar->hide(); | 2500 | regBar->hide(); |
2501 | #ifdef USEQPE | 2501 | #ifdef USEQPE |
2502 | Global::hideInputMethod(); | 2502 | Global::hideInputMethod(); |
2503 | #endif | 2503 | #endif |
2504 | m_fontBar->hide(); | 2504 | m_fontBar->hide(); |
2505 | //showNormal(); | 2505 | //showNormal(); |
2506 | showFullScreen(); | 2506 | showFullScreen(); |
2507 | } | 2507 | } |
2508 | else | 2508 | else |
2509 | { | 2509 | { |
2510 | //qDebug("him"); | 2510 | //qDebug("him"); |
2511 | #ifdef USEQPE | 2511 | #ifdef USEQPE |
2512 | Global::hideInputMethod(); | 2512 | Global::hideInputMethod(); |
2513 | #endif | 2513 | #endif |
2514 | //qDebug("eb"); | 2514 | //qDebug("eb"); |
2515 | menubar->show(); | 2515 | menubar->show(); |
2516 | if (fileBar != NULL) fileBar->show(); | 2516 | if (fileBar != NULL) fileBar->show(); |
2517 | if (viewBar != NULL) viewBar->show(); | 2517 | if (viewBar != NULL) viewBar->show(); |
2518 | if (navBar != NULL) navBar->show(); | 2518 | if (navBar != NULL) navBar->show(); |
2519 | if (markBar != NULL) markBar->show(); | 2519 | if (markBar != NULL) markBar->show(); |
2520 | mb->show(); | 2520 | mb->show(); |
2521 | if ( searchVisible ) | 2521 | if ( searchVisible ) |
2522 | { | 2522 | { |
2523 | #ifdef USEQPE | 2523 | #ifdef USEQPE |
2524 | Global::showInputMethod(); | 2524 | Global::showInputMethod(); |
2525 | #endif | 2525 | #endif |
2526 | searchBar->show(); | 2526 | searchBar->show(); |
2527 | } | 2527 | } |
2528 | if ( regVisible ) | 2528 | if ( regVisible ) |
2529 | { | 2529 | { |
2530 | #ifdef USEQPE | 2530 | #ifdef USEQPE |
2531 | Global::showInputMethod(); | 2531 | Global::showInputMethod(); |
2532 | #endif | 2532 | #endif |
2533 | regBar->show(); | 2533 | regBar->show(); |
2534 | } | 2534 | } |
2535 | if (m_fontVisible) m_fontBar->show(); | 2535 | if (m_fontVisible) m_fontBar->show(); |
2536 | //qDebug("sn"); | 2536 | //qDebug("sn"); |
2537 | showNormal(); | 2537 | showNormal(); |
2538 | //qDebug("sm"); | 2538 | //qDebug("sm"); |
2539 | #ifdef USEQPE | 2539 | #ifdef USEQPE |
2540 | showMaximized(); | 2540 | showMaximized(); |
2541 | #endif | 2541 | #endif |
2542 | //setCentralWidget(reader); | 2542 | //setCentralWidget(reader); |
2543 | } | 2543 | } |
2544 | 2544 | ||
2545 | // qDebug("uc"); | 2545 | // qDebug("uc"); |
2546 | updateCaption(); | 2546 | updateCaption(); |
2547 | // qDebug("rw"); | 2547 | // qDebug("rw"); |
2548 | editorStack->raiseWidget( reader ); | 2548 | editorStack->raiseWidget( reader ); |
2549 | // qDebug("sf"); | 2549 | // qDebug("sf"); |
2550 | reader->setFocus(); | 2550 | reader->setFocus(); |
2551 | reader->refresh(); | 2551 | reader->refresh(); |
2552 | } | 2552 | } |
2553 | /* | 2553 | /* |
2554 | void QTReaderApp::save() | 2554 | void QTReaderApp::save() |
2555 | { | 2555 | { |
2556 | if ( !doc ) | 2556 | if ( !doc ) |
2557 | return; | 2557 | return; |
2558 | if ( !editor->edited() ) | 2558 | if ( !editor->edited() ) |
2559 | return; | 2559 | return; |
2560 | 2560 | ||
2561 | QString rt = editor->text(); | 2561 | QString rt = editor->text(); |
2562 | QString pt = rt; | 2562 | QString pt = rt; |
2563 | 2563 | ||
2564 | if ( doc->name().isEmpty() ) { | 2564 | if ( doc->name().isEmpty() ) { |
2565 | unsigned ispace = pt.find( ' ' ); | 2565 | unsigned ispace = pt.find( ' ' ); |
2566 | unsigned ienter = pt.find( '\n' ); | 2566 | unsigned ienter = pt.find( '\n' ); |
2567 | int i = (ispace < ienter) ? ispace : ienter; | 2567 | int i = (ispace < ienter) ? ispace : ienter; |
2568 | QString docname; | 2568 | QString docname; |
2569 | if ( i == -1 ) { | 2569 | if ( i == -1 ) { |
2570 | if ( pt.isEmpty() ) | 2570 | if ( pt.isEmpty() ) |
2571 | docname = "Empty Text"; | 2571 | docname = "Empty Text"; |
2572 | else | 2572 | else |
2573 | docname = pt; | 2573 | docname = pt; |
2574 | } else { | 2574 | } else { |
2575 | docname = pt.left( i ); | 2575 | docname = pt.left( i ); |
2576 | } | 2576 | } |
2577 | doc->setName(docname); | 2577 | doc->setName(docname); |
2578 | } | 2578 | } |
2579 | FileManager fm; | 2579 | FileManager fm; |
2580 | fm.saveFile( *doc, rt ); | 2580 | fm.saveFile( *doc, rt ); |
2581 | } | 2581 | } |
2582 | */ | 2582 | */ |
2583 | 2583 | ||
2584 | void QTReaderApp::clear() | 2584 | void QTReaderApp::clear() |
2585 | { | 2585 | { |
2586 | // if (doc != 0) | 2586 | // if (doc != 0) |
2587 | // { | 2587 | // { |
2588 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); | 2588 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); |
2589 | //delete doc; | 2589 | //delete doc; |
2590 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); | 2590 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); |
2591 | //doc = 0; | 2591 | //doc = 0; |
2592 | // } | 2592 | // } |
2593 | reader->clear(); | 2593 | reader->clear(); |
2594 | } | 2594 | } |
2595 | 2595 | ||
2596 | void QTReaderApp::updateCaption() | 2596 | void QTReaderApp::updateCaption() |
2597 | { | 2597 | { |
2598 | // if ( !doc ) | 2598 | // if ( !doc ) |
2599 | //setCaption( tr("QTReader") ); | 2599 | //setCaption( tr("QTReader") ); |
2600 | // else { | 2600 | // else { |
2601 | //QString s = doc->name(); | 2601 | //QString s = doc->name(); |
2602 | //if ( s.isEmpty() ) | 2602 | //if ( s.isEmpty() ) |
2603 | // s = tr( "Unnamed" ); | 2603 | // s = tr( "Unnamed" ); |
2604 | setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); | 2604 | setCaption( reader->m_string + " - " + tr("Reader") ); |
2605 | // } | 2605 | // } |
2606 | } | 2606 | } |
2607 | 2607 | ||
2608 | void QTReaderApp::setDocument(const QString& fileref) | 2608 | void QTReaderApp::setDocument(const QString& fileref) |
2609 | { | 2609 | { |
2610 | bFromDocView = TRUE; | 2610 | bFromDocView = TRUE; |
2611 | //QMessageBox::information(0, "setDocument", fileref); | 2611 | //QMessageBox::information(0, "setDocument", fileref); |
2612 | openFile(fileref); | 2612 | openFile(fileref); |
2613 | // showEditTools(); | 2613 | // showEditTools(); |
2614 | } | 2614 | } |
2615 | 2615 | ||
2616 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 2616 | void QTReaderApp::closeEvent( QCloseEvent *e ) |
2617 | { | 2617 | { |
2618 | // qDebug("Close event"); | 2618 | // qDebug("Close event"); |
2619 | if (m_fullscreen) | 2619 | if (m_fullscreen) |
2620 | { | 2620 | { |
2621 | m_fullscreen = false; | 2621 | m_fullscreen = false; |
2622 | showEditTools(); | 2622 | showEditTools(); |
2623 | e->accept(); | 2623 | e->accept(); |
2624 | } | 2624 | } |
2625 | else if (m_dontSave) | 2625 | else if (m_dontSave) |
2626 | { | 2626 | { |
2627 | e->accept(); | 2627 | e->accept(); |
2628 | } | 2628 | } |
2629 | else | 2629 | else |
2630 | { | 2630 | { |
2631 | if (editorStack->visibleWidget() == reader) | 2631 | if (editorStack->visibleWidget() == reader) |
2632 | { | 2632 | { |
2633 | if ((m_escapeTarget != cesNone) && m_bcloseDisabled) | 2633 | if ((m_escapeTarget != cesNone) && m_bcloseDisabled) |
2634 | { | 2634 | { |
2635 | //qDebug("Close disabled"); | 2635 | //qDebug("Close disabled"); |
2636 | m_bcloseDisabled = false; | 2636 | m_bcloseDisabled = false; |
2637 | e->ignore(); | 2637 | e->ignore(); |
2638 | } | 2638 | } |
2639 | else | 2639 | else |
2640 | { | 2640 | { |
2641 | if (m_fontVisible) | 2641 | if (m_fontVisible) |
2642 | { | 2642 | { |
2643 | m_fontBar->hide(); | 2643 | m_fontBar->hide(); |
2644 | m_fontVisible = false; | 2644 | m_fontVisible = false; |
2645 | } | 2645 | } |
2646 | if (regVisible) | 2646 | if (regVisible) |
2647 | { | 2647 | { |
2648 | regBar->hide(); | 2648 | regBar->hide(); |
2649 | #ifdef USEQPE | 2649 | #ifdef USEQPE |
2650 | Global::hideInputMethod(); | 2650 | Global::hideInputMethod(); |
2651 | #endif | 2651 | #endif |
2652 | regVisible = false; | 2652 | regVisible = false; |
2653 | return; | 2653 | return; |
2654 | } | 2654 | } |
2655 | if (searchVisible) | 2655 | if (searchVisible) |
2656 | { | 2656 | { |
2657 | searchBar->hide(); | 2657 | searchBar->hide(); |
2658 | #ifdef USEQPE | 2658 | #ifdef USEQPE |
2659 | Global::hideInputMethod(); | 2659 | Global::hideInputMethod(); |
2660 | #endif | 2660 | #endif |
2661 | searchVisible = false; | 2661 | searchVisible = false; |
2662 | return; | 2662 | return; |
2663 | } | 2663 | } |
2664 | if (m_fBkmksChanged && pBkmklist != NULL) | 2664 | if (m_fBkmksChanged && pBkmklist != NULL) |
2665 | { | 2665 | { |
2666 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 2666 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
2667 | savebkmks(); | 2667 | savebkmks(); |
2668 | delete pBkmklist; | 2668 | delete pBkmklist; |
2669 | pBkmklist = NULL; | 2669 | pBkmklist = NULL; |
2670 | m_fBkmksChanged = false; | 2670 | m_fBkmksChanged = false; |
2671 | } | 2671 | } |
2672 | bFromDocView = FALSE; | 2672 | bFromDocView = FALSE; |
2673 | updatefileinfo(); | 2673 | updatefileinfo(); |
2674 | saveprefs(); | 2674 | saveprefs(); |
2675 | e->accept(); | 2675 | e->accept(); |
2676 | } | 2676 | } |
2677 | } | 2677 | } |
2678 | else | 2678 | else |
2679 | { | 2679 | { |
2680 | showEditTools(); | 2680 | showEditTools(); |
2681 | m_disableesckey = true; | 2681 | m_disableesckey = true; |
2682 | } | 2682 | } |
2683 | } | 2683 | } |
2684 | } | 2684 | } |
2685 | 2685 | ||
2686 | void QTReaderApp::do_gotomark() | 2686 | void QTReaderApp::do_gotomark() |
2687 | { | 2687 | { |
2688 | m_nBkmkAction = cGotoBkmk; | 2688 | m_nBkmkAction = cGotoBkmk; |
2689 | if (!listbkmk(pBkmklist)) | 2689 | if (!listbkmk(pBkmklist)) |
2690 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 2690 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
2691 | } | 2691 | } |
2692 | 2692 | ||
2693 | void QTReaderApp::do_delmark() | 2693 | void QTReaderApp::do_delmark() |
2694 | { | 2694 | { |
2695 | m_nBkmkAction = cDelBkmk; | 2695 | m_nBkmkAction = cDelBkmk; |
2696 | if (!listbkmk(pBkmklist)) | 2696 | if (!listbkmk(pBkmklist)) |
2697 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 2697 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
2698 | } | 2698 | } |
2699 | 2699 | ||
2700 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) | 2700 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) |
2701 | { | 2701 | { |
2702 | bkmkselector->clear(); | 2702 | bkmkselector->clear(); |
2703 | if (_lab.isEmpty()) | 2703 | if (_lab.isEmpty()) |
2704 | bkmkselector->setText("Cancel"); | 2704 | bkmkselector->setText("Cancel"); |
2705 | else | 2705 | else |
2706 | bkmkselector->setText(_lab); | 2706 | bkmkselector->setText(_lab); |
2707 | int cnt = 0; | 2707 | int cnt = 0; |
2708 | if (plist != NULL) | 2708 | if (plist != NULL) |
2709 | { | 2709 | { |
2710 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) | 2710 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) |
2711 | { | 2711 | { |
2712 | #ifdef _UNICODE | 2712 | #ifdef _UNICODE |
2713 | // qDebug("Item:%s", (const char*)toQString(i->name())); | 2713 | // qDebug("Item:%s", (const char*)toQString(i->name())); |
2714 | bkmkselector->insertItem(toQString(i->name())); | 2714 | bkmkselector->insertItem(toQString(i->name())); |
2715 | #else | 2715 | #else |
2716 | bkmkselector->insertItem(i->name()); | 2716 | bkmkselector->insertItem(i->name()); |
2717 | #endif | 2717 | #endif |
2718 | cnt++; | 2718 | cnt++; |
2719 | } | 2719 | } |
2720 | } | 2720 | } |
2721 | if (cnt > 0) | 2721 | if (cnt > 0) |
2722 | { | 2722 | { |
2723 | hidetoolbars(); | 2723 | hidetoolbars(); |
2724 | editorStack->raiseWidget( bkmkselector ); | 2724 | editorStack->raiseWidget( bkmkselector ); |
2725 | return true; | 2725 | return true; |
2726 | } | 2726 | } |
2727 | else | 2727 | else |
2728 | return false; | 2728 | return false; |
2729 | } | 2729 | } |
2730 | 2730 | ||
2731 | void QTReaderApp::do_autogen() | 2731 | void QTReaderApp::do_autogen() |
2732 | { | 2732 | { |
2733 | m_nRegAction = cAutoGen; | 2733 | m_nRegAction = cAutoGen; |
2734 | regEdit->setText(m_autogenstr); | 2734 | regEdit->setText(m_autogenstr); |
2735 | do_regedit(); | 2735 | do_regedit(); |
2736 | } | 2736 | } |
2737 | 2737 | ||
2738 | void QTReaderApp::do_regedit() | 2738 | void QTReaderApp::do_regedit() |
2739 | { | 2739 | { |
2740 | // fileBar->hide(); | 2740 | // fileBar->hide(); |
2741 | reader->bDoUpdates = false; | 2741 | reader->bDoUpdates = false; |
2742 | // qDebug("Showing regbar"); | 2742 | // qDebug("Showing regbar"); |
2743 | regBar->show(); | 2743 | regBar->show(); |
2744 | // qDebug("Showing kbd"); | 2744 | // qDebug("Showing kbd"); |
2745 | #ifdef USEQPE | 2745 | #ifdef USEQPE |
2746 | Global::showInputMethod(); | 2746 | Global::showInputMethod(); |
2747 | #endif | 2747 | #endif |
2748 | regVisible = true; | 2748 | regVisible = true; |
2749 | regEdit->setFocus(); | 2749 | regEdit->setFocus(); |
2750 | // qApp->processEvents(); | 2750 | // qApp->processEvents(); |
2751 | reader->bDoUpdates = true; | 2751 | reader->bDoUpdates = true; |
2752 | reader->update(); | 2752 | reader->update(); |
2753 | } | 2753 | } |
2754 | 2754 | ||
2755 | bool QTReaderApp::openfrombkmk(Bkmk* bk) | 2755 | bool QTReaderApp::openfrombkmk(Bkmk* bk) |
2756 | { | 2756 | { |
2757 | QString fn = toQString( | 2757 | QString fn = toQString( |
2758 | CFiledata(bk->anno()).name() | 2758 | CFiledata(bk->anno()).name() |
2759 | ); | 2759 | ); |
2760 | //qDebug("fileinfo"); | 2760 | //qDebug("fileinfo"); |
2761 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 2761 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
2762 | { | 2762 | { |
2763 | //qDebug("Opening"); | 2763 | //qDebug("Opening"); |
2764 | openFile(fn); | 2764 | openFile(fn); |
2765 | struct stat fnstat; | 2765 | struct stat fnstat; |
2766 | stat((const char *)reader->m_lastfile, &fnstat); | 2766 | stat((const char *)reader->m_lastfile, &fnstat); |
2767 | 2767 | ||
2768 | if (CFiledata(bk->anno()).date() | 2768 | if (CFiledata(bk->anno()).date() |
2769 | != fnstat.st_mtime) | 2769 | != fnstat.st_mtime) |
2770 | { | 2770 | { |
2771 | CFiledata fd(bk->anno()); | 2771 | CFiledata fd(bk->anno()); |
2772 | fd.setdate(fnstat.st_mtime); | 2772 | fd.setdate(fnstat.st_mtime); |
2773 | bk->value(0); | 2773 | bk->value(0); |
2774 | } | 2774 | } |
2775 | else | 2775 | else |
2776 | { | 2776 | { |
2777 | unsigned short svlen = bk->filedatalen(); | 2777 | unsigned short svlen = bk->filedatalen(); |
2778 | unsigned char* svdata = bk->filedata(); | 2778 | unsigned char* svdata = bk->filedata(); |
2779 | reader->putSaveData(svdata, svlen); | 2779 | reader->putSaveData(svdata, svlen); |
2780 | // setstate(svdata, svlen); | 2780 | // setstate(svdata, svlen); |
2781 | if (svlen != 0) | 2781 | if (svlen != 0) |
2782 | { | 2782 | { |
2783 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); | 2783 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); |
2784 | } | 2784 | } |
2785 | // qDebug("updating"); | 2785 | // qDebug("updating"); |
2786 | // showEditTools(); | 2786 | // showEditTools(); |
2787 | reader->locate(bk->value()); | 2787 | reader->locate(bk->value()); |
2788 | } | 2788 | } |
2789 | return true; | 2789 | return true; |
2790 | } | 2790 | } |
2791 | else | 2791 | else |
2792 | { | 2792 | { |
2793 | return false; | 2793 | return false; |
2794 | } | 2794 | } |
2795 | } | 2795 | } |
2796 | 2796 | ||
2797 | void QTReaderApp::gotobkmk(int ind) | 2797 | void QTReaderApp::gotobkmk(int ind) |
2798 | { | 2798 | { |
2799 | showEditTools(); | 2799 | showEditTools(); |
2800 | switch (m_nBkmkAction) | 2800 | switch (m_nBkmkAction) |
2801 | { | 2801 | { |
2802 | case cOpenFile: | 2802 | case cOpenFile: |
2803 | { | 2803 | { |
2804 | // qApp->processEvents(); | 2804 | // qApp->processEvents(); |
2805 | if (!openfrombkmk((*pOpenlist)[ind])) | 2805 | if (!openfrombkmk((*pOpenlist)[ind])) |
2806 | { | 2806 | { |
2807 | pOpenlist->erase(ind); | 2807 | pOpenlist->erase(ind); |
2808 | QMessageBox::information(this, PROGNAME, "Can't find file"); | 2808 | QMessageBox::information(this, PROGNAME, "Can't find file"); |
2809 | } | 2809 | } |
2810 | } | 2810 | } |
2811 | break; | 2811 | break; |
2812 | case cGotoBkmk: | 2812 | case cGotoBkmk: |
2813 | reader->locate((*pBkmklist)[ind]->value()); | 2813 | reader->locate((*pBkmklist)[ind]->value()); |
2814 | break; | 2814 | break; |
2815 | case cDelBkmk: | 2815 | case cDelBkmk: |
2816 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | 2816 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); |
2817 | pBkmklist->erase(ind); | 2817 | pBkmklist->erase(ind); |
2818 | m_fBkmksChanged = true; | 2818 | m_fBkmksChanged = true; |
2819 | // pBkmklist->sort(); | 2819 | // pBkmklist->sort(); |
2820 | break; | 2820 | break; |
2821 | case cRmBkmkFile: | 2821 | case cRmBkmkFile: |
2822 | { | 2822 | { |
2823 | #ifndef USEQPE | 2823 | #ifndef USEQPE |
2824 | QDir d = QDir::home(); // "/" | 2824 | QDir d = QDir::home(); // "/" |
2825 | d.cd(APPDIR); | 2825 | d.cd(APPDIR); |
2826 | d.remove(bkmkselector->text(ind)); | 2826 | d.remove(bkmkselector->text(ind)); |
2827 | #else /* USEQPE */ | 2827 | #else /* USEQPE */ |
2828 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); | 2828 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); |
2829 | #endif /* USEQPE */ | 2829 | #endif /* USEQPE */ |
2830 | } | 2830 | } |
2831 | break; | 2831 | break; |
2832 | case cLdConfig: | 2832 | case cLdConfig: |
2833 | readconfig(bkmkselector->text(ind), false); | 2833 | readconfig(bkmkselector->text(ind), false); |
2834 | break; | 2834 | break; |
2835 | case cRmConfig: | 2835 | case cRmConfig: |
2836 | { | 2836 | { |
2837 | #ifndef USEQPE | 2837 | #ifndef USEQPE |
2838 | QDir d = QDir::home(); // "/" | 2838 | QDir d = QDir::home(); // "/" |
2839 | d.cd(APPDIR "/configs"); | 2839 | d.cd(APPDIR "/configs"); |
2840 | d.remove(bkmkselector->text(ind)); | 2840 | d.remove(bkmkselector->text(ind)); |
2841 | #else /* USEQPE */ | 2841 | #else /* USEQPE */ |
2842 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); | 2842 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); |
2843 | #endif /* USEQPE */ | 2843 | #endif /* USEQPE */ |
2844 | } | 2844 | } |
2845 | break; | 2845 | break; |
2846 | case cExportLinks: | 2846 | case cExportLinks: |
2847 | { | 2847 | { |
2848 | #ifndef USEQPE | 2848 | #ifndef USEQPE |
2849 | QDir d = QDir::home(); // "/" | 2849 | QDir d = QDir::home(); // "/" |
2850 | d.cd(APPDIR "/urls"); | 2850 | d.cd(APPDIR "/urls"); |
2851 | QFileInfo fi(d, bkmkselector->text(ind)); | 2851 | QFileInfo fi(d, bkmkselector->text(ind)); |
2852 | if (fi.exists()) | 2852 | if (fi.exists()) |
2853 | { | 2853 | { |
2854 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); | 2854 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); |
2855 | if (!outfile.isEmpty()) | 2855 | if (!outfile.isEmpty()) |
2856 | { | 2856 | { |
2857 | FILE* fout = fopen((const char *)outfile, "w"); | 2857 | FILE* fout = fopen((const char *)outfile, "w"); |
2858 | if (fout != NULL) | 2858 | if (fout != NULL) |
2859 | { | 2859 | { |
2860 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); | 2860 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); |
2861 | if (fin != NULL) | 2861 | if (fin != NULL) |
2862 | { | 2862 | { |
2863 | fprintf(fout, "<html><body>\n"); | 2863 | fprintf(fout, "<html><body>\n"); |
2864 | int ch = 0; | 2864 | int ch = 0; |
2865 | while ((ch = fgetc(fin)) != EOF) | 2865 | while ((ch = fgetc(fin)) != EOF) |
2866 | { | 2866 | { |
2867 | fputc(ch, fout); | 2867 | fputc(ch, fout); |
2868 | } | 2868 | } |
2869 | fclose(fin); | 2869 | fclose(fin); |
2870 | fprintf(fout, "</html></body>\n"); | 2870 | fprintf(fout, "</html></body>\n"); |
2871 | d.remove(bkmkselector->text(ind)); | 2871 | d.remove(bkmkselector->text(ind)); |
2872 | } | 2872 | } |
2873 | fclose(fout); | 2873 | fclose(fout); |
2874 | } | 2874 | } |
2875 | else | 2875 | else |
2876 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 2876 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
2877 | } | 2877 | } |
2878 | } | 2878 | } |
2879 | #else /* USEQPE */ | 2879 | #else /* USEQPE */ |
2880 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 2880 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
2881 | if (fin != NULL) | 2881 | if (fin != NULL) |
2882 | { | 2882 | { |
2883 | bool allok = false; | 2883 | bool allok = false; |
2884 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); | 2884 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); |
2885 | if (fb->exec()) | 2885 | if (fb->exec()) |
2886 | { | 2886 | { |
2887 | QString outfile = fb->getCurrentFile(); | 2887 | QString outfile = fb->getCurrentFile(); |
2888 | FILE* fout = fopen((const char *)outfile, "w"); | 2888 | FILE* fout = fopen((const char *)outfile, "w"); |
2889 | if (fout != NULL) | 2889 | if (fout != NULL) |
2890 | { | 2890 | { |
2891 | fprintf(fout, "<html><body>\n"); | 2891 | fprintf(fout, "<html><body>\n"); |
2892 | int ch = 0; | 2892 | int ch = 0; |
2893 | while ((ch = fgetc(fin)) != EOF) | 2893 | while ((ch = fgetc(fin)) != EOF) |
2894 | { | 2894 | { |
2895 | fputc(ch, fout); | 2895 | fputc(ch, fout); |
2896 | } | 2896 | } |
2897 | fprintf(fout, "</html></body>\n"); | 2897 | fprintf(fout, "</html></body>\n"); |
2898 | fclose(fout); | 2898 | fclose(fout); |
2899 | allok = true; | 2899 | allok = true; |
2900 | } | 2900 | } |
2901 | else | 2901 | else |
2902 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 2902 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
2903 | } | 2903 | } |
2904 | delete fb; | 2904 | delete fb; |
2905 | fclose(fin); | 2905 | fclose(fin); |
2906 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); | 2906 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); |
2907 | } | 2907 | } |
2908 | else | 2908 | else |
2909 | { | 2909 | { |
2910 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); | 2910 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); |
2911 | } | 2911 | } |
2912 | 2912 | ||
2913 | /* | 2913 | /* |
2914 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); | 2914 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); |
2915 | int ret = f->exec(); | 2915 | int ret = f->exec(); |
2916 | qDebug("Return:%d", ret); | 2916 | qDebug("Return:%d", ret); |
2917 | DocLnk* doc = f->getDoc(); | 2917 | DocLnk* doc = f->getDoc(); |
2918 | if (doc != NULL) | 2918 | if (doc != NULL) |
2919 | { | 2919 | { |
2920 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 2920 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
2921 | QString rt; | 2921 | QString rt; |
2922 | rt = "<html><body>\n"; | 2922 | rt = "<html><body>\n"; |
2923 | int ch = 0; | 2923 | int ch = 0; |
2924 | while ((ch = fgetc(fin)) != EOF) | 2924 | while ((ch = fgetc(fin)) != EOF) |
2925 | { | 2925 | { |
2926 | rt += (char)ch; | 2926 | rt += (char)ch; |
2927 | } | 2927 | } |
2928 | fclose(fin); | 2928 | fclose(fin); |
2929 | rt += "</html></body>\n"; | 2929 | rt += "</html></body>\n"; |
2930 | if ( doc->name().isEmpty() ) | 2930 | if ( doc->name().isEmpty() ) |
2931 | { | 2931 | { |
2932 | doc->setName(bkmkselector->text(ind)); | 2932 | doc->setName(bkmkselector->text(ind)); |
2933 | } | 2933 | } |
2934 | FileManager fm; | 2934 | FileManager fm; |
2935 | fm.saveFile( *doc, rt ); | 2935 | fm.saveFile( *doc, rt ); |
2936 | qDebug("YES"); | 2936 | qDebug("YES"); |
2937 | } | 2937 | } |
2938 | else | 2938 | else |
2939 | { | 2939 | { |
2940 | qDebug("NO"); | 2940 | qDebug("NO"); |
2941 | } | 2941 | } |
2942 | delete f; | 2942 | delete f; |
2943 | */ | 2943 | */ |
2944 | 2944 | ||
2945 | #endif /* USEQPE */ | 2945 | #endif /* USEQPE */ |
2946 | } | 2946 | } |
2947 | break; | 2947 | break; |
2948 | } | 2948 | } |
2949 | } | 2949 | } |
2950 | 2950 | ||
2951 | void QTReaderApp::cancelbkmk() | 2951 | void QTReaderApp::cancelbkmk() |
2952 | { | 2952 | { |
2953 | if (m_nBkmkAction == cOpenFile) | 2953 | if (m_nBkmkAction == cOpenFile) |
2954 | { | 2954 | { |
2955 | QString fn = usefilebrowser(); | 2955 | QString fn = usefilebrowser(); |
2956 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | 2956 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); |
2957 | } | 2957 | } |
2958 | showEditTools(); | 2958 | showEditTools(); |
2959 | } | 2959 | } |
2960 | 2960 | ||
2961 | void QTReaderApp::jump() | 2961 | void QTReaderApp::jump() |
2962 | { | 2962 | { |
2963 | m_nRegAction = cJump; | 2963 | m_nRegAction = cJump; |
2964 | char lcn[20]; | 2964 | char lcn[20]; |
2965 | sprintf(lcn, "%lu", reader->pagelocate()); | 2965 | sprintf(lcn, "%lu", reader->pagelocate()); |
2966 | regEdit->setText(lcn); | 2966 | regEdit->setText(lcn); |
2967 | do_regedit(); | 2967 | do_regedit(); |
2968 | } | 2968 | } |
2969 | 2969 | ||
2970 | void QTReaderApp::do_jump(const QString& lcn) | 2970 | void QTReaderApp::do_jump(const QString& lcn) |
2971 | { | 2971 | { |
2972 | bool ok; | 2972 | bool ok; |
2973 | unsigned long ulcn = lcn.toULong(&ok); | 2973 | unsigned long ulcn = lcn.toULong(&ok); |
2974 | if (ok) | 2974 | if (ok) |
2975 | reader->locate(ulcn); | 2975 | reader->locate(ulcn); |
2976 | else | 2976 | else |
2977 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2977 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
2978 | } | 2978 | } |
2979 | 2979 | ||
2980 | void QTReaderApp::do_regaction() | 2980 | void QTReaderApp::do_regaction() |
2981 | { | 2981 | { |
2982 | reader->bDoUpdates = false; | 2982 | reader->bDoUpdates = false; |
2983 | regBar->hide(); | 2983 | regBar->hide(); |
2984 | #ifdef USEQPE | 2984 | #ifdef USEQPE |
2985 | Global::hideInputMethod(); | 2985 | Global::hideInputMethod(); |
2986 | #endif | 2986 | #endif |
2987 | regVisible = false; | 2987 | regVisible = false; |
2988 | switch(m_nRegAction) | 2988 | switch(m_nRegAction) |
2989 | { | 2989 | { |
2990 | case cAutoGen: | 2990 | case cAutoGen: |
2991 | do_autogen(regEdit->text()); | 2991 | do_autogen(regEdit->text()); |
2992 | break; | 2992 | break; |
2993 | case cAddBkmk: | 2993 | case cAddBkmk: |
2994 | do_addbkmk(regEdit->text()); | 2994 | do_addbkmk(regEdit->text()); |
2995 | break; | 2995 | break; |
2996 | case cJump: | 2996 | case cJump: |
2997 | do_jump(regEdit->text()); | 2997 | do_jump(regEdit->text()); |
2998 | break; | 2998 | break; |
2999 | /* | 2999 | /* |
3000 | case cMonoSpace: | 3000 | case cMonoSpace: |
3001 | do_mono(regEdit->text()); | 3001 | do_mono(regEdit->text()); |
3002 | break; | 3002 | break; |
3003 | */ | 3003 | */ |
3004 | case cSetTarget: | 3004 | case cSetTarget: |
3005 | do_settarget(regEdit->text()); | 3005 | do_settarget(regEdit->text()); |
3006 | break; | 3006 | break; |
3007 | #ifdef _SCROLLPIPE | 3007 | #ifdef _SCROLLPIPE |
3008 | case cSetPipeTarget: | 3008 | case cSetPipeTarget: |
3009 | do_setpipetarget(regEdit->text()); | 3009 | do_setpipetarget(regEdit->text()); |
3010 | break; | 3010 | break; |
3011 | #endif | 3011 | #endif |
3012 | case cSetConfigName: | 3012 | case cSetConfigName: |
3013 | // qDebug("Saving config"); | 3013 | // qDebug("Saving config"); |
3014 | do_saveconfig(regEdit->text(), false); | 3014 | do_saveconfig(regEdit->text(), false); |
3015 | break; | 3015 | break; |
3016 | } | 3016 | } |
3017 | // reader->restore(); | 3017 | // reader->restore(); |
3018 | // fileBar->show(); | 3018 | // fileBar->show(); |
3019 | reader->setFocus(); | 3019 | reader->setFocus(); |
3020 | // qApp->processEvents(); | 3020 | // qApp->processEvents(); |
3021 | reader->bDoUpdates = true; | 3021 | reader->bDoUpdates = true; |
3022 | reader->update(); | 3022 | reader->update(); |
3023 | } | 3023 | } |
3024 | 3024 | ||
3025 | void QTReaderApp::do_settarget(const QString& _txt) | 3025 | void QTReaderApp::do_settarget(const QString& _txt) |
3026 | { | 3026 | { |
3027 | int ind = _txt.find('/'); | 3027 | int ind = _txt.find('/'); |
3028 | if (ind == -1) | 3028 | if (ind == -1) |
3029 | { | 3029 | { |
3030 | m_targetapp = ""; | 3030 | m_targetapp = ""; |
3031 | m_targetmsg = ""; | 3031 | m_targetmsg = ""; |
3032 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); | 3032 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); |
3033 | } | 3033 | } |
3034 | else | 3034 | else |
3035 | { | 3035 | { |
3036 | m_targetapp = _txt.left(ind); | 3036 | m_targetapp = _txt.left(ind); |
3037 | m_targetmsg = _txt.right(_txt.length()-ind-1); | 3037 | m_targetmsg = _txt.right(_txt.length()-ind-1); |
3038 | } | 3038 | } |
3039 | } | 3039 | } |
3040 | 3040 | ||
3041 | void QTReaderApp::chooseencoding() | 3041 | void QTReaderApp::chooseencoding() |
3042 | { | 3042 | { |
3043 | m_fontSelector->clear(); | 3043 | m_fontSelector->clear(); |
3044 | m_fontSelector->insertItem("Ascii"); | 3044 | m_fontSelector->insertItem("Ascii"); |
3045 | m_fontSelector->insertItem("UTF-8"); | 3045 | m_fontSelector->insertItem("UTF-8"); |
3046 | m_fontSelector->insertItem("UCS-2(BE)"); | 3046 | m_fontSelector->insertItem("UCS-2(BE)"); |
3047 | m_fontSelector->insertItem("USC-2(LE)"); | 3047 | m_fontSelector->insertItem("USC-2(LE)"); |
3048 | m_fontSelector->insertItem("Palm"); | 3048 | m_fontSelector->insertItem("Palm"); |
3049 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) | 3049 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) |
3050 | { | 3050 | { |
3051 | m_fontSelector->insertItem(iter->mime); | 3051 | m_fontSelector->insertItem(iter->mime); |
3052 | } // delete the FontDatabase!!! | 3052 | } // delete the FontDatabase!!! |
3053 | m_fontSelector->setCurrentItem (reader->m_encd); | 3053 | m_fontSelector->setCurrentItem (reader->m_encd); |
3054 | m_fontAction = cChooseEncoding; | 3054 | m_fontAction = cChooseEncoding; |
3055 | m_fontBar->show(); | 3055 | m_fontBar->show(); |
3056 | m_fontVisible = true; | 3056 | m_fontVisible = true; |
3057 | } | 3057 | } |
3058 | 3058 | ||
3059 | void QTReaderApp::setfont() | 3059 | void QTReaderApp::setfont() |
3060 | { | 3060 | { |
3061 | m_fontSelector->clear(); | 3061 | m_fontSelector->clear(); |
3062 | { | 3062 | { |
3063 | #ifdef USEQPE | 3063 | #ifdef USEQPE |
3064 | FontDatabase f; | 3064 | FontDatabase f; |
3065 | #else | 3065 | #else |
3066 | QFontDatabase f; | 3066 | QFontDatabase f; |
3067 | #endif | 3067 | #endif |
3068 | QStringList flist = f.families(); | 3068 | QStringList flist = f.families(); |
3069 | m_fontSelector->insertStringList(flist); | 3069 | m_fontSelector->insertStringList(flist); |
3070 | } // delete the FontDatabase!!! | 3070 | } // delete the FontDatabase!!! |
3071 | 3071 | ||
3072 | for (int i = 1; i <= m_fontSelector->count(); i++) | 3072 | for (int i = 1; i <= m_fontSelector->count(); i++) |
3073 | { | 3073 | { |
3074 | if (m_fontSelector->text(i) == reader->m_fontname) | 3074 | if (m_fontSelector->text(i) == reader->m_fontname) |
3075 | { | 3075 | { |
3076 | m_fontSelector->setCurrentItem(i); | 3076 | m_fontSelector->setCurrentItem(i); |
3077 | break; | 3077 | break; |
3078 | } | 3078 | } |
3079 | } | 3079 | } |
3080 | m_fontAction = cChooseFont; | 3080 | m_fontAction = cChooseFont; |
3081 | m_fontBar->show(); | 3081 | m_fontBar->show(); |
3082 | m_fontVisible = true; | 3082 | m_fontVisible = true; |
3083 | } | 3083 | } |
3084 | 3084 | ||
3085 | void QTReaderApp::setfontHelper(const QString& lcn, int size) | 3085 | void QTReaderApp::setfontHelper(const QString& lcn, int size) |
3086 | { | 3086 | { |
3087 | if (size == 0) size = reader->m_fontControl.currentsize(); | 3087 | if (size == 0) size = reader->m_fontControl.currentsize(); |
3088 | if (m_propogatefontchange) | 3088 | if (m_propogatefontchange) |
3089 | { | 3089 | { |
3090 | QFont f(lcn, 10); | 3090 | QFont f(lcn, 10); |
3091 | bkmkselector->setFont( f ); | 3091 | bkmkselector->setFont( f ); |
3092 | regEdit->setFont( f ); | 3092 | regEdit->setFont( f ); |
3093 | searchEdit->setFont( f ); | 3093 | searchEdit->setFont( f ); |
3094 | m_annoWin->setFont( f ); | 3094 | m_annoWin->setFont( f ); |
3095 | } | 3095 | } |
3096 | reader->m_fontname = lcn; | 3096 | reader->m_fontname = lcn; |
3097 | if (!reader->ChangeFont(size)) | 3097 | if (!reader->ChangeFont(size)) |
3098 | { | 3098 | { |
3099 | reader->ChangeFont(size); | 3099 | reader->ChangeFont(size); |
3100 | } | 3100 | } |
3101 | } | 3101 | } |
3102 | 3102 | ||
3103 | void QTReaderApp::do_setencoding(int i) | 3103 | void QTReaderApp::do_setencoding(int i) |
3104 | { | 3104 | { |
3105 | // qDebug("setencoding:%d", i); | 3105 | // qDebug("setencoding:%d", i); |
3106 | if (m_fontAction == cChooseEncoding) | 3106 | if (m_fontAction == cChooseEncoding) |
3107 | { | 3107 | { |
3108 | reader->setencoding(i); | 3108 | reader->setencoding(i); |
3109 | } | 3109 | } |
3110 | reader->refresh(); | 3110 | reader->refresh(); |
3111 | m_fontBar->hide(); | 3111 | m_fontBar->hide(); |
3112 | m_fontVisible = false; | 3112 | m_fontVisible = false; |
3113 | // qDebug("showedit"); | 3113 | // qDebug("showedit"); |
3114 | if (reader->isVisible()) showEditTools(); | 3114 | if (reader->isVisible()) showEditTools(); |
3115 | // qDebug("showeditdone"); | 3115 | // qDebug("showeditdone"); |
3116 | } | 3116 | } |
3117 | 3117 | ||
3118 | void QTReaderApp::do_setfont(const QString& lcn) | 3118 | void QTReaderApp::do_setfont(const QString& lcn) |
3119 | { | 3119 | { |
3120 | if (m_fontAction == cChooseFont) | 3120 | if (m_fontAction == cChooseFont) |
3121 | { | 3121 | { |
3122 | setfontHelper(lcn); | 3122 | setfontHelper(lcn); |
3123 | } | 3123 | } |
3124 | reader->refresh(); | 3124 | reader->refresh(); |
3125 | m_fontBar->hide(); | 3125 | m_fontBar->hide(); |
3126 | m_fontVisible = false; | 3126 | m_fontVisible = false; |
3127 | // qDebug("showedit"); | 3127 | // qDebug("showedit"); |
3128 | //if (reader->isVisible()) | 3128 | //if (reader->isVisible()) |
3129 | showEditTools(); | 3129 | showEditTools(); |
3130 | // qDebug("showeditdone"); | 3130 | // qDebug("showeditdone"); |
3131 | } | 3131 | } |
3132 | 3132 | ||
3133 | void QTReaderApp::do_autogen(const QString& regText) | 3133 | void QTReaderApp::do_autogen(const QString& regText) |
3134 | { | 3134 | { |
3135 | unsigned long fs, ts; | 3135 | unsigned long fs, ts; |
3136 | reader->sizes(fs,ts); | 3136 | reader->sizes(fs,ts); |
3137 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); | 3137 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); |
3138 | m_autogenstr = regText; | 3138 | m_autogenstr = regText; |
3139 | QRegExp re(regText); | 3139 | QRegExp re(regText); |
3140 | CBuffer buff; | 3140 | CBuffer buff; |
3141 | if (pBkmklist != NULL) delete pBkmklist; | 3141 | if (pBkmklist != NULL) delete pBkmklist; |
3142 | pBkmklist = new CList<Bkmk>; | 3142 | pBkmklist = new CList<Bkmk>; |
3143 | m_fBkmksChanged = true; | 3143 | m_fBkmksChanged = true; |
3144 | 3144 | ||
3145 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); | 3145 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); |
3146 | pbar->show(); | 3146 | pbar->show(); |
3147 | pbar->raise(); | 3147 | pbar->raise(); |
3148 | pbar->reset(); | 3148 | pbar->reset(); |
3149 | reader->update(); | 3149 | reader->update(); |
3150 | qApp->processEvents(); | 3150 | qApp->processEvents(); |
3151 | reader->setFocus(); | 3151 | reader->setFocus(); |
3152 | reader->jumpto(0); | 3152 | reader->jumpto(0); |
3153 | int lastpc = 0; | 3153 | int lastpc = 0; |
3154 | int i = 0; | 3154 | int i = 0; |
3155 | while (i >= 0) | 3155 | while (i >= 0) |
3156 | { | 3156 | { |
3157 | unsigned int lcn = reader->locate(); | 3157 | unsigned int lcn = reader->locate(); |
3158 | int pc = (100*lcn)/ts; | 3158 | int pc = (100*lcn)/ts; |
3159 | if (pc != lastpc) | 3159 | if (pc != lastpc) |
3160 | { | 3160 | { |
3161 | pbar->setProgress(pc); | 3161 | pbar->setProgress(pc); |
3162 | qApp->processEvents(); | 3162 | qApp->processEvents(); |
3163 | if (reader->locate() != lcn) reader->jumpto(lcn); | 3163 | if (reader->locate() != lcn) reader->jumpto(lcn); |
3164 | reader->setFocus(); | 3164 | reader->setFocus(); |
3165 | lastpc = pc; | 3165 | lastpc = pc; |
3166 | } | 3166 | } |
3167 | i = reader->buffdoc.getpara(buff); | 3167 | i = reader->buffdoc.getpara(buff); |
3168 | #ifdef _UNICODE | 3168 | #ifdef _UNICODE |
3169 | if (re.match(toQString(buff.data())) != -1) | 3169 | if (re.match(toQString(buff.data())) != -1) |
3170 | #else | 3170 | #else |
3171 | if (re.match(buff.data()) != -1) | 3171 | if (re.match(buff.data()) != -1) |
3172 | #endif | 3172 | #endif |
3173 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); | 3173 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); |
3174 | } | 3174 | } |
3175 | pBkmklist->sort(); | 3175 | pBkmklist->sort(); |
3176 | pbar->setProgress(100); | 3176 | pbar->setProgress(100); |
3177 | qApp->processEvents(); | 3177 | qApp->processEvents(); |
3178 | pbar->hide(); | 3178 | pbar->hide(); |
3179 | reader->refresh(); | 3179 | reader->refresh(); |
3180 | } | 3180 | } |
3181 | 3181 | ||
3182 | void QTReaderApp::saveprefs() | 3182 | void QTReaderApp::saveprefs() |
3183 | { | 3183 | { |
3184 | // qDebug("saveprefs"); | 3184 | // qDebug("saveprefs"); |
3185 | // reader->saveprefs("uqtreader"); | 3185 | // reader->saveprefs("uqtreader"); |
3186 | // if (!m_loadedconfig) | 3186 | // if (!m_loadedconfig) |
3187 | do_saveconfig( APPDIR, true ); | 3187 | do_saveconfig( APPDIR, true ); |
3188 | 3188 | ||
3189 | /* | 3189 | /* |
3190 | Config config( APPDIR ); | 3190 | Config config( APPDIR ); |
3191 | config.setGroup( "View" ); | 3191 | config.setGroup( "View" ); |
3192 | 3192 | ||
3193 | reader->m_lastposn = reader->pagelocate(); | 3193 | reader->m_lastposn = reader->pagelocate(); |
3194 | 3194 | ||
3195 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | 3195 | config.writeEntry("FloatDialogs", m_bFloatingDialog); |
3196 | config.writeEntry( "StripCr", reader->bstripcr ); | 3196 | config.writeEntry( "StripCr", reader->bstripcr ); |
3197 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 3197 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
3198 | config.writeEntry( "TextFmt", reader->btextfmt ); | 3198 | config.writeEntry( "TextFmt", reader->btextfmt ); |
3199 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 3199 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
3200 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 3200 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
3201 | config.writeEntry( "Depluck", reader->bdepluck ); | 3201 | config.writeEntry( "Depluck", reader->bdepluck ); |
3202 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | 3202 | config.writeEntry( "Dejpluck", reader->bdejpluck ); |
3203 | config.writeEntry( "OneSpace", reader->bonespace ); | 3203 | config.writeEntry( "OneSpace", reader->bonespace ); |
3204 | config.writeEntry( "Unindent", reader->bunindent ); | 3204 | config.writeEntry( "Unindent", reader->bunindent ); |
3205 | config.writeEntry( "Repara", reader->brepara ); | 3205 | config.writeEntry( "Repara", reader->brepara ); |
3206 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 3206 | config.writeEntry( "DoubleSpace", reader->bdblspce ); |
3207 | config.writeEntry( "Indent", reader->bindenter ); | 3207 | config.writeEntry( "Indent", reader->bindenter ); |
3208 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 3208 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
3209 | config.writeEntry( "ScrollDelay", reader->m_delay); | 3209 | config.writeEntry( "ScrollDelay", reader->m_delay); |
3210 | config.writeEntry( "LastFile", reader->m_lastfile ); | 3210 | config.writeEntry( "LastFile", reader->m_lastfile ); |
3211 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 3211 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
3212 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 3212 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
3213 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 3213 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
3214 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | 3214 | config.writeEntry( "SwapMouse", reader->m_swapmouse); |
3215 | config.writeEntry( "Fontname", reader->m_fontname ); | 3215 | config.writeEntry( "Fontname", reader->m_fontname ); |
3216 | config.writeEntry( "Encoding", reader->m_encd ); | 3216 | config.writeEntry( "Encoding", reader->m_encd ); |
3217 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 3217 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
3218 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 3218 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
3219 | config.writeEntry( "Margin", (int)reader->m_border ); | 3219 | config.writeEntry( "Margin", (int)reader->m_border ); |
3220 | config.writeEntry( "TargetApp", m_targetapp ); | 3220 | config.writeEntry( "TargetApp", m_targetapp ); |
3221 | config.writeEntry( "TargetMsg", m_targetmsg ); | 3221 | config.writeEntry( "TargetMsg", m_targetmsg ); |
3222 | #ifdef _SCROLLPIPE | 3222 | #ifdef _SCROLLPIPE |
3223 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | 3223 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); |
3224 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 3224 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
3225 | #endif | 3225 | #endif |
3226 | config.writeEntry( "TwoTouch", m_twoTouch ); | 3226 | config.writeEntry( "TwoTouch", m_twoTouch ); |
3227 | config.writeEntry( "Annotation", m_doAnnotation); | 3227 | config.writeEntry( "Annotation", m_doAnnotation); |
3228 | config.writeEntry( "Dictionary", m_doDictionary); | 3228 | config.writeEntry( "Dictionary", m_doDictionary); |
3229 | config.writeEntry( "Clipboard", m_doClipboard); | 3229 | config.writeEntry( "Clipboard", m_doClipboard); |
3230 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 3230 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
3231 | config.writeEntry( "EscapeTarget", m_escapeTarget); | 3231 | config.writeEntry( "EscapeTarget", m_escapeTarget); |
3232 | config.writeEntry( "ReturnTarget", m_returnTarget); | 3232 | config.writeEntry( "ReturnTarget", m_returnTarget); |
3233 | config.writeEntry( "LeftTarget", m_leftTarget); | 3233 | config.writeEntry( "LeftTarget", m_leftTarget); |
3234 | config.writeEntry( "RightTarget", m_rightTarget); | 3234 | config.writeEntry( "RightTarget", m_rightTarget); |
3235 | config.writeEntry( "UpTarget", m_upTarget); | 3235 | config.writeEntry( "UpTarget", m_upTarget); |
3236 | config.writeEntry( "DownTarget", m_downTarget); | 3236 | config.writeEntry( "DownTarget", m_downTarget); |
3237 | config.writeEntry("LeftScroll", m_leftScroll); | 3237 | config.writeEntry("LeftScroll", m_leftScroll); |
3238 | config.writeEntry("RightScroll", m_rightScroll); | 3238 | config.writeEntry("RightScroll", m_rightScroll); |
3239 | config.writeEntry("UpScroll", m_upScroll); | 3239 | config.writeEntry("UpScroll", m_upScroll); |
3240 | config.writeEntry("DownScroll", m_downScroll); | 3240 | config.writeEntry("DownScroll", m_downScroll); |
3241 | #ifdef REPALM | 3241 | #ifdef REPALM |
3242 | config.writeEntry( "Repalm", reader->brepalm ); | 3242 | config.writeEntry( "Repalm", reader->brepalm ); |
3243 | #endif | 3243 | #endif |
3244 | config.writeEntry( "Remap", reader->bremap ); | 3244 | config.writeEntry( "Remap", reader->bremap ); |
3245 | config.writeEntry( "Peanut", reader->bpeanut ); | 3245 | config.writeEntry( "Peanut", reader->bpeanut ); |
3246 | config.writeEntry( "MakeBold", reader->bmakebold ); | 3246 | config.writeEntry( "MakeBold", reader->bmakebold ); |
3247 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 3247 | config.writeEntry( "Continuous", reader->m_continuousDocument ); |
3248 | config.writeEntry( "FullJust", reader->bfulljust ); | 3248 | config.writeEntry( "FullJust", reader->bfulljust ); |
3249 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | 3249 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); |
3250 | config.writeEntry( "ExtraLead", reader->getlead() ); | 3250 | config.writeEntry( "ExtraLead", reader->getlead() ); |
3251 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | 3251 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); |
3252 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | 3252 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); |
3253 | 3253 | ||
3254 | config.setGroup( "Toolbar" ); | 3254 | config.setGroup( "Toolbar" ); |
3255 | config.writeEntry("Movable", m_tbmovesave); | 3255 | config.writeEntry("Movable", m_tbmovesave); |
3256 | config.writeEntry("Policy", m_tbpolsave); | 3256 | config.writeEntry("Policy", m_tbpolsave); |
3257 | config.writeEntry("Position", m_tbposition); | 3257 | config.writeEntry("Position", m_tbposition); |
3258 | */ | 3258 | */ |
3259 | savefilelist(); | 3259 | savefilelist(); |
3260 | } | 3260 | } |
3261 | 3261 | ||
3262 | /* | 3262 | /* |
3263 | void QTReaderApp::oldFile() | 3263 | void QTReaderApp::oldFile() |
3264 | { | 3264 | { |
3265 | // qDebug("oldFile called"); | 3265 | // qDebug("oldFile called"); |
3266 | reader->setText(true); | 3266 | reader->setText(true); |
3267 | // qDebug("settext called"); | 3267 | // qDebug("settext called"); |
3268 | showEditTools(); | 3268 | showEditTools(); |
3269 | // qDebug("showedit called"); | 3269 | // qDebug("showedit called"); |
3270 | } | 3270 | } |
3271 | */ | 3271 | */ |
3272 | 3272 | ||
3273 | /* | 3273 | /* |
3274 | void info_cb(Fl_Widget* o, void* _data) | 3274 | void info_cb(Fl_Widget* o, void* _data) |
3275 | { | 3275 | { |
3276 | 3276 | ||
3277 | if (infowin == NULL) | 3277 | if (infowin == NULL) |
3278 | { | 3278 | { |
3279 | 3279 | ||
3280 | infowin = new Fl_Window(160,240); | 3280 | infowin = new Fl_Window(160,240); |
3281 | filename = new Fl_Output(45,5,110,14,"Filename"); | 3281 | filename = new Fl_Output(45,5,110,14,"Filename"); |
3282 | filesize = new Fl_Output(45,25,110,14,"Filesize"); | 3282 | filesize = new Fl_Output(45,25,110,14,"Filesize"); |
3283 | textsize = new Fl_Output(45,45,110,14,"Textsize"); | 3283 | textsize = new Fl_Output(45,45,110,14,"Textsize"); |
3284 | comprat = new CBar(45,65,110,14,"Ratio %"); | 3284 | comprat = new CBar(45,65,110,14,"Ratio %"); |
3285 | posn = new Fl_Output(45,85,110,14,"Location"); | 3285 | posn = new Fl_Output(45,85,110,14,"Location"); |
3286 | frcn = new CBar(45,105,110,14,"% Read"); | 3286 | frcn = new CBar(45,105,110,14,"% Read"); |
3287 | about = new Fl_Multiline_Output(5,125,150,90); | 3287 | about = new Fl_Multiline_Output(5,125,150,90); |
3288 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); | 3288 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); |
3289 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); | 3289 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); |
3290 | infowin->set_modal(); | 3290 | infowin->set_modal(); |
3291 | } | 3291 | } |
3292 | if (((reader_ui *)_data)->g_filename[0] != '\0') | 3292 | if (((reader_ui *)_data)->g_filename[0] != '\0') |
3293 | { | 3293 | { |
3294 | unsigned long fs,ts; | 3294 | unsigned long fs,ts; |
3295 | tchar sz[20]; | 3295 | tchar sz[20]; |
3296 | ((reader_ui *)_data)->input->sizes(fs,ts); | 3296 | ((reader_ui *)_data)->input->sizes(fs,ts); |
3297 | unsigned long pl = ((reader_ui *)_data)->input->locate(); | 3297 | unsigned long pl = ((reader_ui *)_data)->input->locate(); |
3298 | 3298 | ||
3299 | filename->value(((reader_ui *)_data)->g_filename); | 3299 | filename->value(((reader_ui *)_data)->g_filename); |
3300 | 3300 | ||
3301 | sprintf(sz,"%u",fs); | 3301 | sprintf(sz,"%u",fs); |
3302 | filesize->value(sz); | 3302 | filesize->value(sz); |
3303 | 3303 | ||
3304 | sprintf(sz,"%u",ts); | 3304 | sprintf(sz,"%u",ts); |
3305 | textsize->value(sz); | 3305 | textsize->value(sz); |
3306 | 3306 | ||
3307 | comprat->value(100-(100*fs + (ts >> 1))/ts); | 3307 | comprat->value(100-(100*fs + (ts >> 1))/ts); |
3308 | 3308 | ||
3309 | sprintf(sz,"%u",pl); | 3309 | sprintf(sz,"%u",pl); |
3310 | posn->value(sz); | 3310 | posn->value(sz); |
3311 | 3311 | ||
3312 | frcn->value((100*pl + (ts >> 1))/ts); | 3312 | frcn->value((100*pl + (ts >> 1))/ts); |
3313 | } | 3313 | } |
3314 | infowin->show(); | 3314 | infowin->show(); |
3315 | } | 3315 | } |
3316 | */ | 3316 | */ |
3317 | 3317 | ||
3318 | void QTReaderApp::savebkmks() | 3318 | void QTReaderApp::savebkmks() |
3319 | { | 3319 | { |
3320 | if (pBkmklist != NULL) | 3320 | if (pBkmklist != NULL) |
3321 | { | 3321 | { |
3322 | #ifndef USEQPE | 3322 | #ifndef USEQPE |
3323 | QDir d = QDir::home(); // "/" | 3323 | QDir d = QDir::home(); // "/" |
3324 | d.cd(APPDIR); | 3324 | d.cd(APPDIR); |
3325 | QFileInfo fi(d, reader->m_string); | 3325 | QFileInfo fi(d, reader->m_string); |
3326 | BkmkFile bf((const char *)fi.absFilePath(), true); | 3326 | BkmkFile bf((const char *)fi.absFilePath(), true); |
3327 | #else /* USEQPE */ | 3327 | #else /* USEQPE */ |
3328 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true); | 3328 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true); |
3329 | #endif /* USEQPE */ | 3329 | #endif /* USEQPE */ |
3330 | bf.write(*pBkmklist); | 3330 | bf.write(*pBkmklist); |
3331 | } | 3331 | } |
3332 | m_fBkmksChanged = false; | 3332 | m_fBkmksChanged = false; |
3333 | } | 3333 | } |
3334 | 3334 | ||
3335 | void QTReaderApp::readfilelist() | 3335 | void QTReaderApp::readfilelist() |
3336 | { | 3336 | { |
3337 | #ifndef USEQPE | 3337 | #ifndef USEQPE |
3338 | QDir d = QDir::home(); // "/" | 3338 | QDir d = QDir::home(); // "/" |
3339 | d.cd(APPDIR); | 3339 | d.cd(APPDIR); |
3340 | QFileInfo fi(d, ".openfiles"); | 3340 | QFileInfo fi(d, ".openfiles"); |
3341 | BkmkFile bf((const char *)fi.absFilePath()); | 3341 | BkmkFile bf((const char *)fi.absFilePath()); |
3342 | #else /* USEQPE */ | 3342 | #else /* USEQPE */ |
3343 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles")); | 3343 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles")); |
3344 | #endif /* USEQPE */ | 3344 | #endif /* USEQPE */ |
3345 | // qDebug("Reading open files"); | 3345 | // qDebug("Reading open files"); |
3346 | pOpenlist = bf.readall(); | 3346 | pOpenlist = bf.readall(); |
3347 | // if (pOpenlist != NULL) qDebug("...with success"); | 3347 | // if (pOpenlist != NULL) qDebug("...with success"); |
3348 | // else qDebug("...without success!"); | 3348 | // else qDebug("...without success!"); |
3349 | } | 3349 | } |
3350 | 3350 | ||
3351 | void QTReaderApp::savefilelist() | 3351 | void QTReaderApp::savefilelist() |
3352 | { | 3352 | { |
3353 | if (pOpenlist != NULL) | 3353 | if (pOpenlist != NULL) |
3354 | { | 3354 | { |
3355 | #ifndef USEQPE | 3355 | #ifndef USEQPE |
3356 | QDir d = QDir::home(); // "/" | 3356 | QDir d = QDir::home(); // "/" |
3357 | d.cd(APPDIR); | 3357 | d.cd(APPDIR); |
3358 | QFileInfo fi(d, ".openfiles"); | 3358 | QFileInfo fi(d, ".openfiles"); |
3359 | BkmkFile bf((const char *)fi.absFilePath(), true); | 3359 | BkmkFile bf((const char *)fi.absFilePath(), true); |
3360 | #else /* USEQPE */ | 3360 | #else /* USEQPE */ |
3361 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true); | 3361 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true); |
3362 | #endif /* USEQPE */ | 3362 | #endif /* USEQPE */ |
3363 | //qDebug("Writing open files"); | 3363 | //qDebug("Writing open files"); |
3364 | bf.write(*pOpenlist); | 3364 | bf.write(*pOpenlist); |
3365 | } | 3365 | } |
3366 | } | 3366 | } |
3367 | 3367 | ||
3368 | void QTReaderApp::readbkmks() | 3368 | void QTReaderApp::readbkmks() |
3369 | { | 3369 | { |
3370 | if (pBkmklist != NULL) | 3370 | if (pBkmklist != NULL) |
3371 | { | 3371 | { |
3372 | delete pBkmklist; | 3372 | delete pBkmklist; |
3373 | } | 3373 | } |
3374 | struct stat fnstat; | 3374 | struct stat fnstat; |
3375 | struct stat bkstat; | 3375 | struct stat bkstat; |
3376 | #ifndef USEQPE | 3376 | #ifndef USEQPE |
3377 | QDir d = QDir::home(); // "/" | 3377 | QDir d = QDir::home(); // "/" |
3378 | d.cd(APPDIR); | 3378 | d.cd(APPDIR); |
3379 | QFileInfo fi(d, reader->m_string); | 3379 | QFileInfo fi(d, reader->m_string); |
3380 | #endif /* ! USEQPE */ | 3380 | #endif /* ! USEQPE */ |
3381 | if ( | 3381 | if ( |
3382 | stat((const char *)reader->m_lastfile, &fnstat) == 0 | 3382 | stat((const char *)reader->m_lastfile, &fnstat) == 0 |
3383 | && | 3383 | && |
3384 | #ifndef USEQPE | 3384 | #ifndef USEQPE |
3385 | stat((const char *)fi.absFilePath(), &bkstat) == 0 | 3385 | stat((const char *)fi.absFilePath(), &bkstat) == 0 |
3386 | #else /* USEQPE */ | 3386 | #else /* USEQPE */ |
3387 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 | 3387 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 |
3388 | #endif /* USEQPE */ | 3388 | #endif /* USEQPE */ |
3389 | ) | 3389 | ) |
3390 | { | 3390 | { |
3391 | if (bkstat.st_mtime < fnstat.st_mtime) | 3391 | if (bkstat.st_mtime < fnstat.st_mtime) |
3392 | { | 3392 | { |
3393 | #ifndef USEQPE | 3393 | #ifndef USEQPE |
3394 | unlink((const char *)fi.absFilePath()); | 3394 | unlink((const char *)fi.absFilePath()); |
3395 | #else /* USEQPE */ | 3395 | #else /* USEQPE */ |
3396 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 3396 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
3397 | #endif /* USEQPE */ | 3397 | #endif /* USEQPE */ |
3398 | } | 3398 | } |
3399 | } | 3399 | } |
3400 | 3400 | ||
3401 | #ifndef USEQPE | 3401 | #ifndef USEQPE |
3402 | BkmkFile bf((const char *)fi.absFilePath()); | 3402 | BkmkFile bf((const char *)fi.absFilePath()); |
3403 | #else /* USEQPE */ | 3403 | #else /* USEQPE */ |
3404 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 3404 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
3405 | #endif /* USEQPE */ | 3405 | #endif /* USEQPE */ |
3406 | 3406 | ||
3407 | pBkmklist = bf.readall(); | 3407 | pBkmklist = bf.readall(); |
3408 | m_fBkmksChanged = bf.upgraded(); | 3408 | m_fBkmksChanged = bf.upgraded(); |
3409 | if (pBkmklist == NULL) | 3409 | if (pBkmklist == NULL) |
3410 | { | 3410 | { |
3411 | pBkmklist = reader->getbkmklist(); | 3411 | pBkmklist = reader->getbkmklist(); |
3412 | } | 3412 | } |
3413 | if (pBkmklist != NULL) | 3413 | if (pBkmklist != NULL) |
3414 | pBkmklist->sort(); | 3414 | pBkmklist->sort(); |
3415 | } | 3415 | } |
3416 | 3416 | ||
3417 | void QTReaderApp::addbkmk() | 3417 | void QTReaderApp::addbkmk() |
3418 | { | 3418 | { |
3419 | m_nRegAction = cAddBkmk; | 3419 | m_nRegAction = cAddBkmk; |
3420 | regEdit->setText(reader->firstword()); | 3420 | regEdit->setText(reader->firstword()); |
3421 | do_regedit(); | 3421 | do_regedit(); |
3422 | } | 3422 | } |
3423 | 3423 | ||
3424 | void QTReaderApp::do_addbkmk(const QString& text) | 3424 | void QTReaderApp::do_addbkmk(const QString& text) |
3425 | { | 3425 | { |
3426 | if (text.isEmpty()) | 3426 | if (text.isEmpty()) |
3427 | { | 3427 | { |
3428 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); | 3428 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); |
3429 | } | 3429 | } |
3430 | else | 3430 | else |
3431 | { | 3431 | { |
3432 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; | 3432 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; |
3433 | #ifdef _UNICODE | 3433 | #ifdef _UNICODE |
3434 | CBuffer buff; | 3434 | CBuffer buff; |
3435 | int i = 0; | 3435 | int i = 0; |
3436 | for (i = 0; i < text.length(); i++) | 3436 | for (i = 0; i < text.length(); i++) |
3437 | { | 3437 | { |
3438 | buff[i] = text[i].unicode(); | 3438 | buff[i] = text[i].unicode(); |
3439 | } | 3439 | } |
3440 | buff[i] = 0; | 3440 | buff[i] = 0; |
3441 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); | 3441 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); |
3442 | #else | 3442 | #else |
3443 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); | 3443 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); |
3444 | #endif | 3444 | #endif |
3445 | m_fBkmksChanged = true; | 3445 | m_fBkmksChanged = true; |
3446 | pBkmklist->sort(); | 3446 | pBkmklist->sort(); |
3447 | } | 3447 | } |
3448 | } | 3448 | } |
3449 | 3449 | ||
3450 | void QTReaderApp::OnRedraw() | 3450 | void QTReaderApp::OnRedraw() |
3451 | { | 3451 | { |
3452 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) | 3452 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) |
3453 | { | 3453 | { |
3454 | bool found = findNextBookmark(reader->pagelocate()); | 3454 | bool found = findNextBookmark(reader->pagelocate()); |
3455 | m_bkmkAvail->setEnabled(found); | 3455 | m_bkmkAvail->setEnabled(found); |
3456 | } | 3456 | } |
3457 | } | 3457 | } |
3458 | 3458 | ||
3459 | void QTReaderApp::showAnnotation() | 3459 | void QTReaderApp::showAnnotation() |
3460 | { | 3460 | { |
3461 | m_annoWin->setName(toQString(m_anno->name())); | 3461 | m_annoWin->setName(toQString(m_anno->name())); |
3462 | m_annoWin->setAnno(toQString(m_anno->anno())); | 3462 | m_annoWin->setAnno(toQString(m_anno->anno())); |
3463 | m_annoIsEditing = false; | 3463 | m_annoIsEditing = false; |
3464 | #ifdef USEQPE | 3464 | #ifdef USEQPE |
3465 | Global::showInputMethod(); | 3465 | Global::showInputMethod(); |
3466 | #endif | 3466 | #endif |
3467 | editorStack->raiseWidget( m_annoWin ); | 3467 | editorStack->raiseWidget( m_annoWin ); |
3468 | m_annoWin->setFocus(); | 3468 | m_annoWin->setFocus(); |
3469 | } | 3469 | } |
3470 | 3470 | ||
3471 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) | 3471 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) |
3472 | { | 3472 | { |
3473 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); | 3473 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); |
3474 | 3474 | ||
3475 | if (m_doClipboard) | 3475 | if (m_doClipboard) |
3476 | { | 3476 | { |
3477 | QClipboard* cb = QApplication::clipboard(); | 3477 | QClipboard* cb = QApplication::clipboard(); |
3478 | cb->setText(wrd); | 3478 | cb->setText(wrd); |
3479 | #ifdef USEQPE | 3479 | #ifdef USEQPE |
3480 | if (wrd.length() > 10) | 3480 | if (wrd.length() > 10) |
3481 | { | 3481 | { |
3482 | Global::statusMessage(wrd.left(8) + ".."); | 3482 | Global::statusMessage(wrd.left(8) + ".."); |
3483 | } | 3483 | } |
3484 | else | 3484 | else |
3485 | { | 3485 | { |
3486 | Global::statusMessage(wrd); | 3486 | Global::statusMessage(wrd); |
3487 | } | 3487 | } |
3488 | #endif | 3488 | #endif |
3489 | } | 3489 | } |
3490 | if (m_doAnnotation) | 3490 | if (m_doAnnotation) |
3491 | { | 3491 | { |
3492 | //addAnno(wrd, "Need to be able to edit this", posn); | 3492 | //addAnno(wrd, "Need to be able to edit this", posn); |
3493 | m_annoWin->setName(line); | 3493 | m_annoWin->setName(line); |
3494 | m_annoWin->setAnno(""); | 3494 | m_annoWin->setAnno(""); |
3495 | m_annoWin->setPosn(posn); | 3495 | m_annoWin->setPosn(posn); |
3496 | m_annoIsEditing = true; | 3496 | m_annoIsEditing = true; |
3497 | #ifdef USEQPE | 3497 | #ifdef USEQPE |
3498 | Global::showInputMethod(); | 3498 | Global::showInputMethod(); |
3499 | #endif | 3499 | #endif |
3500 | editorStack->raiseWidget( m_annoWin ); | 3500 | editorStack->raiseWidget( m_annoWin ); |
3501 | } | 3501 | } |
3502 | #ifdef USEQPE | 3502 | #ifdef USEQPE |
3503 | if (m_doDictionary) | 3503 | if (m_doDictionary) |
3504 | { | 3504 | { |
3505 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) | 3505 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) |
3506 | { | 3506 | { |
3507 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); | 3507 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); |
3508 | e << wrd; | 3508 | e << wrd; |
3509 | } | 3509 | } |
3510 | } | 3510 | } |
3511 | #endif | 3511 | #endif |
3512 | } | 3512 | } |
3513 | 3513 | ||
3514 | void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e) | 3514 | void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e) |
3515 | { | 3515 | { |
3516 | if (a == 0) | 3516 | if (a == 0) |
3517 | { | 3517 | { |
3518 | e->ignore(); | 3518 | e->ignore(); |
3519 | } | 3519 | } |
3520 | else | 3520 | else |
3521 | { | 3521 | { |
3522 | e->accept(); | 3522 | e->accept(); |
3523 | //qDebug("Accepted"); | 3523 | //qDebug("Accepted"); |
3524 | switch (a) | 3524 | switch (a) |
3525 | { | 3525 | { |
3526 | case cesOpenFile: | 3526 | case cesOpenFile: |
3527 | { | 3527 | { |
3528 | fileOpen(); | 3528 | fileOpen(); |
3529 | } | 3529 | } |
3530 | break; | 3530 | break; |
3531 | case cesAutoScroll: | 3531 | case cesAutoScroll: |
3532 | { | 3532 | { |
3533 | reader->setautoscroll(!reader->m_autoScroll); | 3533 | reader->setautoscroll(!reader->m_autoScroll); |
3534 | setScrollState(reader->m_autoScroll); | 3534 | setScrollState(reader->m_autoScroll); |
3535 | } | 3535 | } |
3536 | break; | 3536 | break; |
3537 | case cesActionMark: | 3537 | case cesActionMark: |
3538 | { | 3538 | { |
3539 | addbkmk(); | 3539 | addbkmk(); |
3540 | } | 3540 | } |
3541 | break; | 3541 | break; |
3542 | case cesFullScreen: | 3542 | case cesFullScreen: |
3543 | { | 3543 | { |
3544 | m_actFullscreen->setOn(!m_fullscreen); | 3544 | m_actFullscreen->setOn(!m_fullscreen); |
3545 | } | 3545 | } |
3546 | break; | 3546 | break; |
3547 | case cesActionAnno: | 3547 | case cesActionAnno: |
3548 | { | 3548 | { |
3549 | addanno(); | 3549 | addanno(); |
3550 | } | 3550 | } |
3551 | break; | 3551 | break; |
3552 | case cesZoomIn: | 3552 | case cesZoomIn: |
3553 | zoomin(); | 3553 | zoomin(); |
3554 | break; | 3554 | break; |
3555 | case cesZoomOut: | 3555 | case cesZoomOut: |
3556 | zoomout(); | 3556 | zoomout(); |
3557 | break; | 3557 | break; |
3558 | case cesBack: | 3558 | case cesBack: |
3559 | reader->goBack(); | 3559 | reader->goBack(); |
3560 | break; | 3560 | break; |
3561 | case cesForward: | 3561 | case cesForward: |
3562 | reader->goForward(); | 3562 | reader->goForward(); |
3563 | break; | 3563 | break; |
3564 | case cesHome: | 3564 | case cesHome: |
3565 | reader->goHome(); | 3565 | reader->goHome(); |
3566 | break; | 3566 | break; |
3567 | case cesPageUp: | 3567 | case cesPageUp: |
3568 | reader->dopageup(); | 3568 | reader->dopageup(); |
3569 | break; | 3569 | break; |
3570 | case cesPageDown: | 3570 | case cesPageDown: |
3571 | reader->dopagedn(); | 3571 | reader->dopagedn(); |
3572 | break; | 3572 | break; |
3573 | case cesLineUp: | 3573 | case cesLineUp: |
3574 | reader->lineUp(); | 3574 | reader->lineUp(); |
3575 | break; | 3575 | break; |
3576 | case cesLineDown: | 3576 | case cesLineDown: |
3577 | reader->lineDown(); | 3577 | reader->lineDown(); |
3578 | break; | 3578 | break; |
3579 | case cesStartDoc: | 3579 | case cesStartDoc: |
3580 | gotoStart(); | 3580 | gotoStart(); |
3581 | break; | 3581 | break; |
3582 | case cesEndDoc: | 3582 | case cesEndDoc: |
3583 | gotoEnd(); | 3583 | gotoEnd(); |
3584 | break; | 3584 | break; |
3585 | default: | 3585 | default: |
3586 | qDebug("Unknown ActionType:%u", a); | 3586 | qDebug("Unknown ActionType:%u", a); |
3587 | break; | 3587 | break; |
3588 | } | 3588 | } |
3589 | } | 3589 | } |
3590 | } | 3590 | } |
3591 | 3591 | ||
3592 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | 3592 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } |
3593 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | 3593 | void QTReaderApp::restoreFocus() { reader->setFocus(); } |
3594 | 3594 | ||
3595 | void QTReaderApp::SaveConfig() | 3595 | void QTReaderApp::SaveConfig() |
3596 | { | 3596 | { |
3597 | m_nRegAction = cSetConfigName; | 3597 | m_nRegAction = cSetConfigName; |
3598 | regEdit->setText(reader->m_string); | 3598 | regEdit->setText(reader->m_string); |
3599 | do_regedit(); | 3599 | do_regedit(); |
3600 | } | 3600 | } |
3601 | 3601 | ||
3602 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | 3602 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) |
3603 | { | 3603 | { |
3604 | // qDebug("do_saveconfig:%s", (const char*)_txt); | 3604 | // qDebug("do_saveconfig:%s", (const char*)_txt); |
3605 | #ifdef USEQPE | 3605 | #ifdef USEQPE |
3606 | QString configname; | 3606 | QString configname; |
3607 | Config::Domain dom; | 3607 | Config::Domain dom; |
3608 | 3608 | ||
3609 | if (full) | 3609 | if (full) |
3610 | { | 3610 | { |
3611 | configname = _txt; | 3611 | configname = _txt; |
3612 | dom = Config::User; | 3612 | dom = Config::User; |
3613 | } | 3613 | } |
3614 | else | 3614 | else |
3615 | { | 3615 | { |
3616 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | 3616 | configname = Global::applicationFileName(APPDIR "/configs", _txt); |
3617 | dom = Config::File; | 3617 | dom = Config::File; |
3618 | } | 3618 | } |
3619 | 3619 | ||
3620 | Config config(configname, dom); | 3620 | Config config(configname, dom); |
3621 | config.setGroup( "View" ); | 3621 | config.setGroup( "View" ); |
3622 | 3622 | ||
3623 | #else | 3623 | #else |
3624 | QFileInfo fi; | 3624 | QFileInfo fi; |
3625 | if (full) | 3625 | if (full) |
3626 | { | 3626 | { |
3627 | // qDebug("full:%s", (const char*)_txt); | 3627 | // qDebug("full:%s", (const char*)_txt); |
3628 | QDir d = QDir::home(); // "/" | 3628 | QDir d = QDir::home(); // "/" |
3629 | if ( !d.cd(_txt) ) | 3629 | if ( !d.cd(_txt) ) |
3630 | { // "/tmp" | 3630 | { // "/tmp" |
3631 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); | 3631 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); |
3632 | d = QDir::home(); | 3632 | d = QDir::home(); |
3633 | d.mkdir(_txt); | 3633 | d.mkdir(_txt); |
3634 | d.cd(_txt); | 3634 | d.cd(_txt); |
3635 | } | 3635 | } |
3636 | fi.setFile(d, INIFILE); | 3636 | fi.setFile(d, INIFILE); |
3637 | } | 3637 | } |
3638 | else | 3638 | else |
3639 | { | 3639 | { |
3640 | QDir d = QDir::home(); // "/" | 3640 | QDir d = QDir::home(); // "/" |
3641 | if ( !d.cd(APPDIR) ) | 3641 | if ( !d.cd(APPDIR) ) |
3642 | { // "/tmp" | 3642 | { // "/tmp" |
3643 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 3643 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
3644 | d = QDir::home(); | 3644 | d = QDir::home(); |
3645 | d.mkdir(APPDIR); | 3645 | d.mkdir(APPDIR); |
3646 | d.cd(APPDIR); | 3646 | d.cd(APPDIR); |
3647 | } | 3647 | } |
3648 | if ( !d.cd("configs") ) | 3648 | if ( !d.cd("configs") ) |
3649 | { // "/tmp" | 3649 | { // "/tmp" |
3650 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); | 3650 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); |
3651 | d = QDir::home(); | 3651 | d = QDir::home(); |
3652 | d.cd(APPDIR); | 3652 | d.cd(APPDIR); |
3653 | d.mkdir("configs"); | 3653 | d.mkdir("configs"); |
3654 | d.cd("configs"); | 3654 | d.cd("configs"); |
3655 | } | 3655 | } |
3656 | fi.setFile(d, _txt); | 3656 | fi.setFile(d, _txt); |
3657 | } | 3657 | } |
3658 | //qDebug("Path:%s", (const char*)fi.absFilePath()); | 3658 | //qDebug("Path:%s", (const char*)fi.absFilePath()); |
3659 | Config config(fi.absFilePath()); | 3659 | Config config(fi.absFilePath()); |
3660 | #endif | 3660 | #endif |
3661 | 3661 | ||
3662 | 3662 | ||
3663 | config.writeEntry( "StripCr", reader->bstripcr ); | 3663 | config.writeEntry( "StripCr", reader->bstripcr ); |
3664 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 3664 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
3665 | config.writeEntry( "TextFmt", reader->btextfmt ); | 3665 | config.writeEntry( "TextFmt", reader->btextfmt ); |
3666 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 3666 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
3667 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 3667 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
3668 | config.writeEntry( "Depluck", reader->bdepluck ); | 3668 | config.writeEntry( "Depluck", reader->bdepluck ); |
3669 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | 3669 | config.writeEntry( "Dejpluck", reader->bdejpluck ); |
3670 | config.writeEntry( "OneSpace", reader->bonespace ); | 3670 | config.writeEntry( "OneSpace", reader->bonespace ); |
3671 | config.writeEntry( "Unindent", reader->bunindent ); | 3671 | config.writeEntry( "Unindent", reader->bunindent ); |
3672 | config.writeEntry( "Repara", reader->brepara ); | 3672 | config.writeEntry( "Repara", reader->brepara ); |
3673 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 3673 | config.writeEntry( "DoubleSpace", reader->bdblspce ); |
3674 | config.writeEntry( "Indent", reader->bindenter ); | 3674 | config.writeEntry( "Indent", reader->bindenter ); |
3675 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 3675 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
3676 | config.writeEntry( "ScrollDelay", reader->m_delay); | 3676 | config.writeEntry( "ScrollDelay", reader->m_delay); |
3677 | if (full) | 3677 | if (full) |
3678 | { | 3678 | { |
3679 | config.writeEntry("Debounce", m_debounce); | 3679 | config.writeEntry("Debounce", m_debounce); |
3680 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | 3680 | config.writeEntry("FloatDialogs", m_bFloatingDialog); |
3681 | reader->m_lastposn = reader->pagelocate(); | 3681 | reader->m_lastposn = reader->pagelocate(); |
3682 | config.writeEntry( "LastFile", reader->m_lastfile ); | 3682 | config.writeEntry( "LastFile", reader->m_lastfile ); |
3683 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 3683 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
3684 | } | 3684 | } |
3685 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 3685 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
3686 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 3686 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
3687 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | 3687 | config.writeEntry( "SwapMouse", reader->m_swapmouse); |
3688 | config.writeEntry( "Fontname", reader->m_fontname ); | 3688 | config.writeEntry( "Fontname", reader->m_fontname ); |
3689 | config.writeEntry( "Encoding", reader->m_encd ); | 3689 | config.writeEntry( "Encoding", reader->m_encd ); |
3690 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 3690 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
3691 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 3691 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
3692 | config.writeEntry( "Margin", (int)reader->m_border ); | 3692 | config.writeEntry( "Margin", (int)reader->m_border ); |
3693 | config.writeEntry( "TargetApp", m_targetapp ); | 3693 | config.writeEntry( "TargetApp", m_targetapp ); |
3694 | config.writeEntry( "TargetMsg", m_targetmsg ); | 3694 | config.writeEntry( "TargetMsg", m_targetmsg ); |
3695 | #ifdef _SCROLLPIPE | 3695 | #ifdef _SCROLLPIPE |
3696 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | 3696 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); |
3697 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 3697 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
3698 | #endif | 3698 | #endif |
3699 | config.writeEntry( "TwoTouch", m_twoTouch ); | 3699 | config.writeEntry( "TwoTouch", m_twoTouch ); |
3700 | config.writeEntry( "Annotation", m_doAnnotation); | 3700 | config.writeEntry( "Annotation", m_doAnnotation); |
3701 | config.writeEntry( "Dictionary", m_doDictionary); | 3701 | config.writeEntry( "Dictionary", m_doDictionary); |
3702 | config.writeEntry( "Clipboard", m_doClipboard); | 3702 | config.writeEntry( "Clipboard", m_doClipboard); |
3703 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 3703 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
3704 | config.writeEntry( "EscapeTarget", m_escapeTarget); | 3704 | config.writeEntry( "EscapeTarget", m_escapeTarget); |
3705 | config.writeEntry( "ReturnTarget", m_returnTarget); | 3705 | config.writeEntry( "ReturnTarget", m_returnTarget); |
3706 | config.writeEntry( "LeftTarget", m_leftTarget); | 3706 | config.writeEntry( "LeftTarget", m_leftTarget); |
3707 | config.writeEntry( "RightTarget", m_rightTarget); | 3707 | config.writeEntry( "RightTarget", m_rightTarget); |
3708 | config.writeEntry( "UpTarget", m_upTarget); | 3708 | config.writeEntry( "UpTarget", m_upTarget); |
3709 | config.writeEntry( "DownTarget", m_downTarget); | 3709 | config.writeEntry( "DownTarget", m_downTarget); |
3710 | config.writeEntry("LeftScroll", m_leftScroll); | 3710 | config.writeEntry("LeftScroll", m_leftScroll); |
3711 | config.writeEntry("RightScroll", m_rightScroll); | 3711 | config.writeEntry("RightScroll", m_rightScroll); |
3712 | config.writeEntry("UpScroll", m_upScroll); | 3712 | config.writeEntry("UpScroll", m_upScroll); |
3713 | config.writeEntry("DownScroll", m_downScroll); | 3713 | config.writeEntry("DownScroll", m_downScroll); |
3714 | #ifdef REPALM | 3714 | #ifdef REPALM |
3715 | config.writeEntry( "Repalm", reader->brepalm ); | 3715 | config.writeEntry( "Repalm", reader->brepalm ); |
3716 | #endif | 3716 | #endif |
3717 | config.writeEntry( "Remap", reader->bremap ); | 3717 | config.writeEntry( "Remap", reader->bremap ); |
3718 | config.writeEntry( "Peanut", reader->bpeanut ); | 3718 | config.writeEntry( "Peanut", reader->bpeanut ); |
3719 | config.writeEntry( "MakeBold", reader->bmakebold ); | 3719 | config.writeEntry( "MakeBold", reader->bmakebold ); |
3720 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 3720 | config.writeEntry( "Continuous", reader->m_continuousDocument ); |
3721 | config.writeEntry( "FullJust", reader->bfulljust ); | 3721 | config.writeEntry( "FullJust", reader->bfulljust ); |
3722 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | 3722 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); |
3723 | config.writeEntry( "ExtraLead", reader->getlead() ); | 3723 | config.writeEntry( "ExtraLead", reader->getlead() ); |
3724 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | 3724 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); |
3725 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | 3725 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); |
3726 | if (full) | 3726 | if (full) |
3727 | { | 3727 | { |
3728 | config.setGroup( "Toolbar" ); | 3728 | config.setGroup( "Toolbar" ); |
3729 | config.writeEntry("Movable", m_tbmovesave); | 3729 | config.writeEntry("Movable", m_tbmovesave); |
3730 | config.writeEntry("Policy", m_tbpolsave); | 3730 | config.writeEntry("Policy", m_tbpolsave); |
3731 | config.writeEntry("Position", m_tbposition); | 3731 | config.writeEntry("Position", m_tbposition); |
3732 | #ifndef USEQPE | 3732 | #ifndef USEQPE |
3733 | config.setGroup( "Geometry" ); | 3733 | config.setGroup( "Geometry" ); |
3734 | config.writeEntry( "x", x() ); | 3734 | config.writeEntry( "x", x() ); |
3735 | config.writeEntry( "y", y() ); | 3735 | config.writeEntry( "y", y() ); |
3736 | config.writeEntry( "width", width() ); | 3736 | config.writeEntry( "width", width() ); |
3737 | config.writeEntry( "height", height() ); | 3737 | config.writeEntry( "height", height() ); |
3738 | #endif | 3738 | #endif |
3739 | } | 3739 | } |
3740 | } | 3740 | } |
3741 | 3741 | ||
3742 | /* | 3742 | /* |
3743 | void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) | 3743 | void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) |
3744 | { | 3744 | { |
3745 | unsigned short sdlen; | 3745 | unsigned short sdlen; |
3746 | memcpy(&sdlen, _sd, sizeof(sdlen)); | 3746 | memcpy(&sdlen, _sd, sizeof(sdlen)); |
3747 | sdlen -= sizeof(sdlen); | 3747 | sdlen -= sizeof(sdlen); |
3748 | _sd += sizeof(sdlen); | 3748 | _sd += sizeof(sdlen); |
3749 | statedata* sd; | 3749 | statedata* sd; |
3750 | char* data; | 3750 | char* data; |
3751 | if (sdlen < sizeof(statedata)+1) | 3751 | if (sdlen < sizeof(statedata)+1) |
3752 | { | 3752 | { |
3753 | sdlen = sizeof(statedata)+1; | 3753 | sdlen = sizeof(statedata)+1; |
3754 | } | 3754 | } |
3755 | data = new char[sdlen]; | 3755 | data = new char[sdlen]; |
3756 | sd = (statedata*)data; | 3756 | sd = (statedata*)data; |
3757 | memcpy(sd, _sd, sdlen); | 3757 | memcpy(sd, _sd, sdlen); |
3758 | data[sdlen] = 0; | 3758 | data[sdlen] = 0; |
3759 | reader->setstate(*sd); | 3759 | reader->setstate(*sd); |
3760 | delete [] data; | 3760 | delete [] data; |
3761 | } | 3761 | } |
3762 | 3762 | ||
3763 | void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) | 3763 | void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) |
3764 | { | 3764 | { |
3765 | unsigned char* olddata = data; | 3765 | unsigned char* olddata = data; |
3766 | unsigned short oldlen = len; | 3766 | unsigned short oldlen = len; |
3767 | len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length(); | 3767 | len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length(); |
3768 | data = new unsigned char[len]; | 3768 | data = new unsigned char[len]; |
3769 | memcpy(data, olddata, oldlen); | 3769 | memcpy(data, olddata, oldlen); |
3770 | delete [] olddata; | 3770 | delete [] olddata; |
3771 | memcpy(data+oldlen, &len, sizeof(len)); | 3771 | memcpy(data+oldlen, &len, sizeof(len)); |
3772 | statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short)); | 3772 | statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short)); |
3773 | 3773 | ||
3774 | sd->bstripcr = reader->bstripcr; | 3774 | sd->bstripcr = reader->bstripcr; |
3775 | sd->btextfmt = reader->btextfmt; | 3775 | sd->btextfmt = reader->btextfmt; |
3776 | sd->bautofmt = reader->bautofmt; | 3776 | sd->bautofmt = reader->bautofmt; |
3777 | sd->bstriphtml = reader->bstriphtml; | 3777 | sd->bstriphtml = reader->bstriphtml; |
3778 | sd->bpeanut = reader->bpeanut; | 3778 | sd->bpeanut = reader->bpeanut; |
3779 | sd->bdehyphen = reader->bdehyphen; | 3779 | sd->bdehyphen = reader->bdehyphen; |
3780 | sd->bdepluck = reader->bdepluck; | 3780 | sd->bdepluck = reader->bdepluck; |
3781 | sd->bdejpluck = reader->bdejpluck; | 3781 | sd->bdejpluck = reader->bdejpluck; |
3782 | sd->bonespace = reader->bonespace; | 3782 | sd->bonespace = reader->bonespace; |
3783 | sd->bunindent = reader->bunindent; | 3783 | sd->bunindent = reader->bunindent; |
3784 | sd->brepara = reader->brepara; | 3784 | sd->brepara = reader->brepara; |
3785 | sd->bdblspce = reader->bdblspce; | 3785 | sd->bdblspce = reader->bdblspce; |
3786 | sd->m_bpagemode = reader->m_bpagemode; | 3786 | sd->m_bpagemode = reader->m_bpagemode; |
3787 | sd->m_bMonoSpaced = reader->m_bMonoSpaced; | 3787 | sd->m_bMonoSpaced = reader->m_bMonoSpaced; |
3788 | sd->bremap = reader->bremap; | 3788 | sd->bremap = reader->bremap; |
3789 | sd->bmakebold = reader->bmakebold; | 3789 | sd->bmakebold = reader->bmakebold; |
3790 | sd->Continuous = reader->m_continuousDocument; | 3790 | sd->Continuous = reader->m_continuousDocument; |
3791 | #ifdef REPALM | 3791 | #ifdef REPALM |
3792 | sd->brepalm = reader->brepalm; | 3792 | sd->brepalm = reader->brepalm; |
3793 | #endif | 3793 | #endif |
3794 | sd->bindenter = reader->bindenter; | 3794 | sd->bindenter = reader->bindenter; |
3795 | sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize() | 3795 | sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize() |
3796 | sd->m_encd = reader->m_encd; | 3796 | sd->m_encd = reader->m_encd; |
3797 | sd->m_charpc = reader->m_charpc; | 3797 | sd->m_charpc = reader->m_charpc; |
3798 | strcpy(sd->m_fontname, reader->m_fontname.latin1()); | 3798 | strcpy(sd->m_fontname, reader->m_fontname.latin1()); |
3799 | } | 3799 | } |
3800 | */ | 3800 | */ |
3801 | #ifdef _SCRIPT | 3801 | #ifdef _SCRIPT |
3802 | void QTReaderApp::RunScript() | 3802 | void QTReaderApp::RunScript() |
3803 | { | 3803 | { |
3804 | fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog, | 3804 | fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog, |
3805 | 0, | 3805 | 0, |
3806 | // WStyle_Customize | WStyle_NoBorderEx, | 3806 | // WStyle_Customize | WStyle_NoBorderEx, |
3807 | "*", Global::applicationFileName(APPDIR "/scripts", "")); | 3807 | "*", Global::applicationFileName(APPDIR "/scripts", "")); |
3808 | 3808 | ||
3809 | QString fn; | 3809 | QString fn; |
3810 | if (fb->exec()) | 3810 | if (fb->exec()) |
3811 | { | 3811 | { |
3812 | fn = fb->fileList[0]; | 3812 | fn = fb->fileList[0]; |
3813 | } | 3813 | } |
3814 | delete fb; | 3814 | delete fb; |
3815 | if ( !fn.isEmpty() && fork() == 0 ) | 3815 | if ( !fn.isEmpty() && fork() == 0 ) |
3816 | { | 3816 | { |
3817 | execlp((const char *)fn,(const char *)fn,NULL); | 3817 | execlp((const char *)fn,(const char *)fn,NULL); |
3818 | } | 3818 | } |
3819 | } | 3819 | } |
3820 | 3820 | ||
3821 | void QTReaderApp::SaveScript(const char* sname) | 3821 | void QTReaderApp::SaveScript(const char* sname) |
3822 | { | 3822 | { |
3823 | FILE* f = fopen(sname,"w"); | 3823 | FILE* f = fopen(sname,"w"); |
3824 | if (f != NULL) | 3824 | if (f != NULL) |
3825 | { | 3825 | { |
3826 | #ifdef OPIE | 3826 | #ifdef OPIE |
3827 | fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n"); | 3827 | fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n"); |
3828 | #else | 3828 | #else |
3829 | fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n"); | 3829 | fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n"); |
3830 | #endif | 3830 | #endif |
3831 | fprintf(f, "msg \"Update(int)\" 0\n"); | 3831 | fprintf(f, "msg \"Update(int)\" 0\n"); |
3832 | fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0); | 3832 | fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0); |
3833 | if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n"); | 3833 | if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n"); |
3834 | else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n"); | 3834 | else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n"); |
3835 | else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n"); | 3835 | else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n"); |
3836 | else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n"); | 3836 | else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n"); |
3837 | else fprintf(f, "msg \"Markup(QString)\" \"None\"\n"); | 3837 | else fprintf(f, "msg \"Markup(QString)\" \"None\"\n"); |
3838 | fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0); | 3838 | fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0); |
3839 | fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0); | 3839 | fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0); |
3840 | fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0); | 3840 | fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0); |
3841 | fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0); | 3841 | fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0); |
3842 | fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0); | 3842 | fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0); |
3843 | fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0); | 3843 | fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0); |
3844 | fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0); | 3844 | fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0); |
3845 | fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter); | 3845 | fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter); |
3846 | fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize); | 3846 | fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize); |
3847 | fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0); | 3847 | fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0); |
3848 | fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0); | 3848 | fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0); |
3849 | fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text()); | 3849 | fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text()); |
3850 | fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc); | 3850 | fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc); |
3851 | fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap); | 3851 | fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap); |
3852 | fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0); | 3852 | fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0); |
3853 | fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0); | 3853 | fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0); |
3854 | fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0); | 3854 | fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0); |
3855 | fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg); | 3855 | fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg); |
3856 | #ifdef _SCROLLPIPE | 3856 | #ifdef _SCROLLPIPE |
3857 | fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget); | 3857 | fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget); |
3858 | #endif | 3858 | #endif |
3859 | fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0); | 3859 | fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0); |
3860 | fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0); | 3860 | fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0); |
3861 | fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0); | 3861 | fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0); |
3862 | fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0); | 3862 | fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0); |
3863 | fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text()); | 3863 | fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text()); |
3864 | fprintf(f, "msg \"Update(int)\" 1\n"); | 3864 | fprintf(f, "msg \"Update(int)\" 1\n"); |
3865 | fprintf(f, "msg \"info(QString)\" \"All Done\"\n"); | 3865 | fprintf(f, "msg \"info(QString)\" \"All Done\"\n"); |
3866 | fclose(f); | 3866 | fclose(f); |
3867 | chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH); | 3867 | chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH); |
3868 | } | 3868 | } |
3869 | } | 3869 | } |
3870 | 3870 | ||
3871 | void QTReaderApp::SaveConfig() | 3871 | void QTReaderApp::SaveConfig() |
3872 | { | 3872 | { |
3873 | m_nRegAction = cSetConfigName; | 3873 | m_nRegAction = cSetConfigName; |
3874 | regEdit->setText(""); | 3874 | regEdit->setText(""); |
3875 | do_regedit(); | 3875 | do_regedit(); |
3876 | } | 3876 | } |
3877 | 3877 | ||
3878 | void QTReaderApp::do_saveconfig(const QString& _txt) | 3878 | void QTReaderApp::do_saveconfig(const QString& _txt) |
3879 | { | 3879 | { |
3880 | SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt)); | 3880 | SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt)); |
3881 | } | 3881 | } |
3882 | #endif | 3882 | #endif |
3883 | 3883 | ||
3884 | #ifdef _SCROLLPIPE | 3884 | #ifdef _SCROLLPIPE |
3885 | void QTReaderApp::setpipetarget() | 3885 | void QTReaderApp::setpipetarget() |
3886 | { | 3886 | { |
3887 | m_nRegAction = cSetPipeTarget; | 3887 | m_nRegAction = cSetPipeTarget; |
3888 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; | 3888 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; |
3889 | regEdit->setText(text); | 3889 | regEdit->setText(text); |
3890 | do_regedit(); | 3890 | do_regedit(); |
3891 | } | 3891 | } |
3892 | 3892 | ||
3893 | void QTReaderApp::do_setpipetarget(const QString& _txt) | 3893 | void QTReaderApp::do_setpipetarget(const QString& _txt) |
3894 | { | 3894 | { |
3895 | reader->m_pipetarget = _txt; | 3895 | reader->m_pipetarget = _txt; |
3896 | } | 3896 | } |
3897 | 3897 | ||
3898 | void QTReaderApp::setpause(bool sfs) | 3898 | void QTReaderApp::setpause(bool sfs) |
3899 | { | 3899 | { |
3900 | reader->m_pauseAfterEachPara = sfs; | 3900 | reader->m_pauseAfterEachPara = sfs; |
3901 | } | 3901 | } |
3902 | #endif | 3902 | #endif |
3903 | 3903 | ||
3904 | void QTReaderApp::monospace(bool _b) | 3904 | void QTReaderApp::monospace(bool _b) |
3905 | { | 3905 | { |
3906 | reader->setmono(_b); | 3906 | reader->setmono(_b); |
3907 | } | 3907 | } |
3908 | 3908 | ||
3909 | bool QTReaderApp::readconfig(const QString& _txt, bool full=false) | 3909 | bool QTReaderApp::readconfig(const QString& _txt, bool full=false) |
3910 | { | 3910 | { |
3911 | #ifdef USEQPE | 3911 | #ifdef USEQPE |
3912 | QString configname; | 3912 | QString configname; |
3913 | Config::Domain dom; | 3913 | Config::Domain dom; |
3914 | 3914 | ||
3915 | if (full) | 3915 | if (full) |
3916 | { | 3916 | { |
3917 | configname = _txt; | 3917 | configname = _txt; |
3918 | dom = Config::User; | 3918 | dom = Config::User; |
3919 | } | 3919 | } |
3920 | else | 3920 | else |
3921 | { | 3921 | { |
3922 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | 3922 | configname = Global::applicationFileName(APPDIR "/configs", _txt); |
3923 | QFileInfo fm(configname); | 3923 | QFileInfo fm(configname); |
3924 | if ( !fm.exists() ) return false; | 3924 | if ( !fm.exists() ) return false; |
3925 | dom = Config::File; | 3925 | dom = Config::File; |
3926 | } | 3926 | } |
3927 | 3927 | ||
3928 | Config config(configname, dom); | 3928 | Config config(configname, dom); |
3929 | config.setGroup( "View" ); | 3929 | config.setGroup( "View" ); |
3930 | 3930 | ||
3931 | #else | 3931 | #else |
3932 | QFileInfo fi; | 3932 | QFileInfo fi; |
3933 | if (full) | 3933 | if (full) |
3934 | { | 3934 | { |
3935 | QDir d = QDir::home(); // "/" | 3935 | QDir d = QDir::home(); // "/" |
3936 | if ( !d.cd(_txt) ) | 3936 | if ( !d.cd(_txt) ) |
3937 | { // "/tmp" | 3937 | { // "/tmp" |
3938 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); | 3938 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); |
3939 | d = QDir::home(); | 3939 | d = QDir::home(); |
3940 | d.mkdir(_txt); | 3940 | d.mkdir(_txt); |
3941 | d.cd(_txt); | 3941 | d.cd(_txt); |
3942 | } | 3942 | } |
3943 | fi.setFile(d, INIFILE); | 3943 | fi.setFile(d, INIFILE); |
3944 | } | 3944 | } |
3945 | else | 3945 | else |
3946 | { | 3946 | { |
3947 | QDir d = QDir::home(); // "/" | 3947 | QDir d = QDir::home(); // "/" |
3948 | if ( !d.cd(APPDIR) ) | 3948 | if ( !d.cd(APPDIR) ) |
3949 | { // "/tmp" | 3949 | { // "/tmp" |
3950 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 3950 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
3951 | d = QDir::home(); | 3951 | d = QDir::home(); |
3952 | d.mkdir(APPDIR); | 3952 | d.mkdir(APPDIR); |
3953 | d.cd(APPDIR); | 3953 | d.cd(APPDIR); |
3954 | } | 3954 | } |
3955 | if ( !d.cd("configs") ) | 3955 | if ( !d.cd("configs") ) |
3956 | { // "/tmp" | 3956 | { // "/tmp" |
3957 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); | 3957 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); |
3958 | d = QDir::home(); | 3958 | d = QDir::home(); |
3959 | d.mkdir("configs"); | 3959 | d.mkdir("configs"); |
3960 | d.cd("configs"); | 3960 | d.cd("configs"); |
3961 | } | 3961 | } |
3962 | fi.setFile(d, _txt); | 3962 | fi.setFile(d, _txt); |
3963 | } | 3963 | } |
3964 | #ifdef _WINDOWS | 3964 | #ifdef _WINDOWS |
3965 | struct stat fnstat; | 3965 | struct stat fnstat; |
3966 | if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows | 3966 | if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows |
3967 | #else | 3967 | #else |
3968 | if (!fi.exists()) return false; | 3968 | if (!fi.exists()) return false; |
3969 | #endif | 3969 | #endif |
3970 | Config config(fi.absFilePath()); | 3970 | Config config(fi.absFilePath()); |
3971 | #endif | 3971 | #endif |
3972 | if (full) | 3972 | if (full) |
3973 | { | 3973 | { |
3974 | config.setGroup("Toolbar"); | 3974 | config.setGroup("Toolbar"); |
3975 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 3975 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); |
3976 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 3976 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); |
3977 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 3977 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); |
3978 | } | 3978 | } |
3979 | config.setGroup( "View" ); | 3979 | config.setGroup( "View" ); |
3980 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 3980 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); |
3981 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 3981 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); |
3982 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 3982 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); |
3983 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 3983 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); |
3984 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 3984 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); |
3985 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 3985 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
3986 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 3986 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); |
3987 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 3987 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
3988 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 3988 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
3989 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 3989 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
3990 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 3990 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); |
3991 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 3991 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); |
3992 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 3992 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
3993 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 3993 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
3994 | reader->brepara = config.readBoolEntry( "Repara", false ); | 3994 | reader->brepara = config.readBoolEntry( "Repara", false ); |
3995 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 3995 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
3996 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 3996 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
3997 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 3997 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
3998 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 3998 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
3999 | if (full) | 3999 | if (full) |
4000 | { | 4000 | { |
4001 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 4001 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
4002 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 4002 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
4003 | } | 4003 | } |
4004 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 4004 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
4005 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 4005 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
4006 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 4006 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); |
4007 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 4007 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
4008 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 4008 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
4009 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 4009 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
4010 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 4010 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
4011 | reader->m_border = config.readNumEntry( "Margin", 6 ); | 4011 | reader->m_border = config.readNumEntry( "Margin", 6 ); |
4012 | #ifdef REPALM | 4012 | #ifdef REPALM |
4013 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | 4013 | reader->brepalm = config.readBoolEntry( "Repalm", true ); |
4014 | #endif | 4014 | #endif |
4015 | reader->bremap = config.readBoolEntry( "Remap", true ); | 4015 | reader->bremap = config.readBoolEntry( "Remap", true ); |
4016 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 4016 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
4017 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 4017 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); |
4018 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 4018 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
4019 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 4019 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
4020 | #ifdef _SCROLLPIPE | 4020 | #ifdef _SCROLLPIPE |
4021 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 4021 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); |
4022 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 4022 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); |
4023 | #endif | 4023 | #endif |
4024 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 4024 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
4025 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 4025 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
4026 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 4026 | m_doDictionary = config.readBoolEntry( "Dictionary", false); |
4027 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 4027 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
4028 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 4028 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
4029 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 4029 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); |
4030 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 4030 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); |
4031 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 4031 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); |
4032 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 4032 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); |
4033 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 4033 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); |
4034 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 4034 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); |
4035 | 4035 | ||
4036 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 4036 | m_leftScroll = config.readBoolEntry("LeftScroll", false); |
4037 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 4037 | m_rightScroll = config.readBoolEntry("RightScroll", false); |
4038 | m_upScroll = config.readBoolEntry("UpScroll", true); | 4038 | m_upScroll = config.readBoolEntry("UpScroll", true); |
4039 | m_downScroll = config.readBoolEntry("DownScroll", true); | 4039 | m_downScroll = config.readBoolEntry("DownScroll", true); |
4040 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | 4040 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); |
4041 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | 4041 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); |
4042 | reader->setTwoTouch(m_twoTouch); | 4042 | reader->setTwoTouch(m_twoTouch); |
4043 | 4043 | ||
4044 | m_touch_action->setOn(m_twoTouch); | 4044 | m_touch_action->setOn(m_twoTouch); |
4045 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 4045 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
4046 | setfontHelper(reader->m_fontname); | 4046 | setfontHelper(reader->m_fontname); |
4047 | if (full) | 4047 | if (full) |
4048 | { | 4048 | { |
4049 | addtoolbars(&config); | 4049 | addtoolbars(&config); |
4050 | } | 4050 | } |
4051 | reader->setfilter(reader->getfilter()); | 4051 | reader->setfilter(reader->getfilter()); |
4052 | reader->refresh(); | 4052 | reader->refresh(); |
4053 | return true; | 4053 | return true; |
4054 | } | 4054 | } |
4055 | 4055 | ||
4056 | bool QTReaderApp::PopulateConfig(const char* tgtdir) | 4056 | bool QTReaderApp::PopulateConfig(const char* tgtdir) |
4057 | { | 4057 | { |
4058 | bkmkselector->clear(); | 4058 | bkmkselector->clear(); |
4059 | bkmkselector->setText("Cancel"); | 4059 | bkmkselector->setText("Cancel"); |
4060 | #ifndef USEQPE | 4060 | #ifndef USEQPE |
4061 | int cnt = 0; | 4061 | int cnt = 0; |
4062 | 4062 | ||
4063 | QDir d = QDir::home(); // "/" | 4063 | QDir d = QDir::home(); // "/" |
4064 | if ( !d.cd(APPDIR) ) { // "/tmp" | 4064 | if ( !d.cd(APPDIR) ) { // "/tmp" |
4065 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 4065 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
4066 | d = QDir::home(); | 4066 | d = QDir::home(); |
4067 | d.mkdir(APPDIR); | 4067 | d.mkdir(APPDIR); |
4068 | d.cd(APPDIR); | 4068 | d.cd(APPDIR); |
4069 | } | 4069 | } |
4070 | if ( !d.cd(tgtdir) ) { // "/tmp" | 4070 | if ( !d.cd(tgtdir) ) { // "/tmp" |
4071 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); | 4071 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); |
4072 | d = QDir::home(); | 4072 | d = QDir::home(); |
4073 | d.mkdir(tgtdir); | 4073 | d.mkdir(tgtdir); |
4074 | d.cd(tgtdir); | 4074 | d.cd(tgtdir); |
4075 | } | 4075 | } |
4076 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 4076 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
4077 | // d.setSorting( QDir::Size | QDir::Reversed ); | 4077 | // d.setSorting( QDir::Size | QDir::Reversed ); |
4078 | 4078 | ||
4079 | const QFileInfoList *list = d.entryInfoList(); | 4079 | const QFileInfoList *list = d.entryInfoList(); |
4080 | QFileInfoListIterator it( *list ); // create list iterator | 4080 | QFileInfoListIterator it( *list ); // create list iterator |
4081 | QFileInfo *fi; // pointer for traversing | 4081 | QFileInfo *fi; // pointer for traversing |
4082 | 4082 | ||
4083 | while ( (fi=it.current()) ) { // for each file... | 4083 | while ( (fi=it.current()) ) { // for each file... |
4084 | 4084 | ||
4085 | bkmkselector->insertItem(fi->fileName()); | 4085 | bkmkselector->insertItem(fi->fileName()); |
4086 | cnt++; | 4086 | cnt++; |
4087 | 4087 | ||
4088 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 4088 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); |
4089 | ++it; // goto next list element | 4089 | ++it; // goto next list element |
4090 | } | 4090 | } |
4091 | 4091 | ||
4092 | #else /* USEQPE */ | 4092 | #else /* USEQPE */ |
4093 | int cnt = 0; | 4093 | int cnt = 0; |
4094 | DIR *d; | 4094 | DIR *d; |
4095 | char* finaldir; | 4095 | char* finaldir; |
4096 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; | 4096 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; |
4097 | strcpy(finaldir, APPDIR); | 4097 | strcpy(finaldir, APPDIR); |
4098 | strcat(finaldir, "/"); | 4098 | strcat(finaldir, "/"); |
4099 | strcat(finaldir, tgtdir); | 4099 | strcat(finaldir, tgtdir); |
4100 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); | 4100 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); |
4101 | 4101 | ||
4102 | while(1) | 4102 | while(1) |
4103 | { | 4103 | { |
4104 | struct dirent* de; | 4104 | struct dirent* de; |
4105 | struct stat buf; | 4105 | struct stat buf; |
4106 | de = readdir(d); | 4106 | de = readdir(d); |
4107 | if (de == NULL) break; | 4107 | if (de == NULL) break; |
4108 | 4108 | ||
4109 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 4109 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
4110 | { | 4110 | { |
4111 | bkmkselector->insertItem(de->d_name); | 4111 | bkmkselector->insertItem(de->d_name); |
4112 | cnt++; | 4112 | cnt++; |
4113 | } | 4113 | } |
4114 | } | 4114 | } |
4115 | delete [] finaldir; | 4115 | delete [] finaldir; |
4116 | closedir(d); | 4116 | closedir(d); |
4117 | #endif | 4117 | #endif |
4118 | return (cnt > 0); | 4118 | return (cnt > 0); |
4119 | } | 4119 | } |
4120 | 4120 | ||
4121 | void QTReaderApp::LoadConfig() | 4121 | void QTReaderApp::LoadConfig() |
4122 | { | 4122 | { |
4123 | if (PopulateConfig("configs")) | 4123 | if (PopulateConfig("configs")) |
4124 | { | 4124 | { |
4125 | editorStack->raiseWidget( bkmkselector ); | 4125 | editorStack->raiseWidget( bkmkselector ); |
4126 | hidetoolbars(); | 4126 | hidetoolbars(); |
4127 | m_nBkmkAction = cLdConfig; | 4127 | m_nBkmkAction = cLdConfig; |
4128 | } | 4128 | } |
4129 | else | 4129 | else |
4130 | QMessageBox::information(this, PROGNAME, "No config files"); | 4130 | QMessageBox::information(this, PROGNAME, "No config files"); |
4131 | } | 4131 | } |
4132 | 4132 | ||
4133 | void QTReaderApp::TidyConfig() | 4133 | void QTReaderApp::TidyConfig() |
4134 | { | 4134 | { |
4135 | if (PopulateConfig("configs")) | 4135 | if (PopulateConfig("configs")) |
4136 | { | 4136 | { |
4137 | editorStack->raiseWidget( bkmkselector ); | 4137 | editorStack->raiseWidget( bkmkselector ); |
4138 | hidetoolbars(); | 4138 | hidetoolbars(); |
4139 | m_nBkmkAction = cRmConfig; | 4139 | m_nBkmkAction = cRmConfig; |
4140 | } | 4140 | } |
diff --git a/noncore/apps/opie-reader/ToolbarPrefs.h b/noncore/apps/opie-reader/ToolbarPrefs.h index 297d63a..9571c28 100644 --- a/noncore/apps/opie-reader/ToolbarPrefs.h +++ b/noncore/apps/opie-reader/ToolbarPrefs.h | |||
@@ -1,263 +1,263 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form interface generated from reading ui file 'Prefs.ui' | 2 | ** Form interface generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:32 2003 | 4 | ** Created: Tue Feb 11 23:53:32 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #ifndef CTOOLBARPREFS_H | 9 | #ifndef CTOOLBARPREFS_H |
10 | #define CTOOLBARPREFS_H | 10 | #define CTOOLBARPREFS_H |
11 | #include "useqpe.h" | 11 | #include "useqpe.h" |
12 | #include <qvariant.h> | 12 | #include <qvariant.h> |
13 | #include <qwidget.h> | 13 | #include <qwidget.h> |
14 | #include <qtabdialog.h> | 14 | #include <qtabdialog.h> |
15 | #include <qtabwidget.h> | 15 | #include <qtabwidget.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qcombobox.h> | 18 | #include <qcombobox.h> |
19 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
20 | #ifdef USEQPE | 20 | #ifdef USEQPE |
21 | #include <qpe/menubutton.h> | 21 | #include <qpe/menubutton.h> |
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | #else | 23 | #else |
24 | #include "preferences.h" | 24 | #include "preferences.h" |
25 | #endif | 25 | #endif |
26 | //#include "opie.h" | 26 | //#include "opie.h" |
27 | //#ifdef OPIE | 27 | //#ifdef OPIE |
28 | #define USECOMBO | 28 | #define USECOMBO |
29 | //#endif | 29 | //#endif |
30 | 30 | ||
31 | class QVBoxLayout; | 31 | class QVBoxLayout; |
32 | class QHBoxLayout; | 32 | class QHBoxLayout; |
33 | class QGridLayout; | 33 | class QGridLayout; |
34 | //class QCheckBox; | 34 | //class QCheckBox; |
35 | class QLabel; | 35 | class QLabel; |
36 | //class QSpinBox; | 36 | //class QSpinBox; |
37 | /* | 37 | /* |
38 | class CBarPrefs1 : public QWidget | 38 | class CBarPrefs1 : public QWidget |
39 | { | 39 | { |
40 | Q_OBJECT | 40 | Q_OBJECT |
41 | 41 | ||
42 | Config& config; | 42 | Config& config; |
43 | QCheckBox *open, *close, *info, *twotouch,*find,*scroll,*navigation,*page,*startend,*jump,*pageline; | 43 | QCheckBox *open, *close, *info, *twotouch,*find,*scroll,*navigation,*page,*startend,*jump,*pageline; |
44 | 44 | ||
45 | bool m_isChanged; | 45 | bool m_isChanged; |
46 | 46 | ||
47 | private slots: | 47 | private slots: |
48 | void isChanged(int _v) { m_isChanged = true; } | 48 | void isChanged(int _v) { m_isChanged = true; } |
49 | 49 | ||
50 | public: | 50 | public: |
51 | CBarPrefs1( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 51 | CBarPrefs1( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
52 | ~CBarPrefs1(); | 52 | ~CBarPrefs1(); |
53 | void saveall(); | 53 | void saveall(); |
54 | bool isChanged() { return m_isChanged; } | 54 | bool isChanged() { return m_isChanged; } |
55 | }; | 55 | }; |
56 | */ | 56 | */ |
57 | class CFileBarPrefs : public QWidget | 57 | class CFileBarPrefs : public QWidget |
58 | { | 58 | { |
59 | Q_OBJECT | 59 | Q_OBJECT |
60 | 60 | ||
61 | Config& config; | 61 | Config& config; |
62 | QCheckBox *open, *close, *info, *twotouch, *find, *scroll; | 62 | QCheckBox *open, *close, *info, *twotouch, *find, *scroll; |
63 | 63 | ||
64 | bool m_isChanged; | 64 | bool m_isChanged; |
65 | 65 | ||
66 | private slots: | 66 | private slots: |
67 | void isChanged(int _v) { m_isChanged = true; } | 67 | void isChanged(int _v) { m_isChanged = true; } |
68 | 68 | ||
69 | public: | 69 | public: |
70 | CFileBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 70 | CFileBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
71 | ~CFileBarPrefs(); | 71 | ~CFileBarPrefs(); |
72 | void saveall(); | 72 | void saveall(); |
73 | bool isChanged() { return m_isChanged; } | 73 | bool isChanged() { return m_isChanged; } |
74 | }; | 74 | }; |
75 | 75 | ||
76 | class CNavBarPrefs : public QWidget | 76 | class CNavBarPrefs : public QWidget |
77 | { | 77 | { |
78 | Q_OBJECT | 78 | Q_OBJECT |
79 | 79 | ||
80 | Config& config; | 80 | Config& config; |
81 | QCheckBox *scroll, *navback, *navhome, *navforward; | 81 | QCheckBox *scroll, *navback, *navhome, *navforward; |
82 | QCheckBox *pageup, *pagedown, *gotostart, *gotoend, *jump, *pageline; | 82 | QCheckBox *pageup, *pagedown, *gotostart, *gotoend, *jump, *pageline; |
83 | 83 | ||
84 | bool m_isChanged; | 84 | bool m_isChanged; |
85 | 85 | ||
86 | private slots: | 86 | private slots: |
87 | void isChanged(int _v) { m_isChanged = true; } | 87 | void isChanged(int _v) { m_isChanged = true; } |
88 | 88 | ||
89 | public: | 89 | public: |
90 | CNavBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 90 | CNavBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
91 | ~CNavBarPrefs(); | 91 | ~CNavBarPrefs(); |
92 | void saveall(); | 92 | void saveall(); |
93 | bool isChanged() { return m_isChanged; } | 93 | bool isChanged() { return m_isChanged; } |
94 | }; | 94 | }; |
95 | /* | 95 | /* |
96 | class CBarPrefs2 : public QWidget | 96 | class CBarPrefs2 : public QWidget |
97 | { | 97 | { |
98 | Q_OBJECT | 98 | Q_OBJECT |
99 | Config& config; | 99 | Config& config; |
100 | QCheckBox *fullscreen, *zoom, *setfont, *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *block, *indannotate, *encoding, *ideogram; | 100 | QCheckBox *fullscreen, *zoom, *setfont, *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *block, *indannotate, *encoding, *ideogram; |
101 | 101 | ||
102 | bool m_isChanged; | 102 | bool m_isChanged; |
103 | 103 | ||
104 | private slots: | 104 | private slots: |
105 | void isChanged(int _v) { m_isChanged = true; } | 105 | void isChanged(int _v) { m_isChanged = true; } |
106 | 106 | ||
107 | public: | 107 | public: |
108 | CBarPrefs2( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 108 | CBarPrefs2( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
109 | ~CBarPrefs2(); | 109 | ~CBarPrefs2(); |
110 | void saveall(); | 110 | void saveall(); |
111 | bool isChanged() { return m_isChanged; } | 111 | bool isChanged() { return m_isChanged; } |
112 | 112 | ||
113 | }; | 113 | }; |
114 | */ | 114 | */ |
115 | class CViewBarPrefs : public QWidget | 115 | class CViewBarPrefs : public QWidget |
116 | { | 116 | { |
117 | Q_OBJECT | 117 | Q_OBJECT |
118 | Config& config; | 118 | Config& config; |
119 | QCheckBox *fullscreen, *zoomin, *zoomout, *setfont, *encoding, *ideogram; | 119 | QCheckBox *fullscreen, *zoomin, *zoomout, *setfont, *encoding, *ideogram; |
120 | 120 | ||
121 | bool m_isChanged; | 121 | bool m_isChanged; |
122 | 122 | ||
123 | private slots: | 123 | private slots: |
124 | void isChanged(int _v) { m_isChanged = true; } | 124 | void isChanged(int _v) { m_isChanged = true; } |
125 | 125 | ||
126 | public: | 126 | public: |
127 | CViewBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 127 | CViewBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
128 | ~CViewBarPrefs(); | 128 | ~CViewBarPrefs(); |
129 | void saveall(); | 129 | void saveall(); |
130 | bool isChanged() { return m_isChanged; } | 130 | bool isChanged() { return m_isChanged; } |
131 | 131 | ||
132 | }; | 132 | }; |
133 | 133 | ||
134 | class CMarkBarPrefs : public QWidget | 134 | class CMarkBarPrefs : public QWidget |
135 | { | 135 | { |
136 | Q_OBJECT | 136 | Q_OBJECT |
137 | Config& config; | 137 | Config& config; |
138 | QCheckBox *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *startblock, *copyblock; | 138 | QCheckBox *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *startblock, *copyblock; |
139 | 139 | ||
140 | bool m_isChanged; | 140 | bool m_isChanged; |
141 | 141 | ||
142 | private slots: | 142 | private slots: |
143 | void isChanged(int _v) { m_isChanged = true; } | 143 | void isChanged(int _v) { m_isChanged = true; } |
144 | 144 | ||
145 | public: | 145 | public: |
146 | CMarkBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 146 | CMarkBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
147 | ~CMarkBarPrefs(); | 147 | ~CMarkBarPrefs(); |
148 | void saveall(); | 148 | void saveall(); |
149 | bool isChanged() { return m_isChanged; } | 149 | bool isChanged() { return m_isChanged; } |
150 | 150 | ||
151 | }; | 151 | }; |
152 | 152 | ||
153 | class CIndBarPrefs : public QWidget | 153 | class CIndBarPrefs : public QWidget |
154 | { | 154 | { |
155 | Q_OBJECT | 155 | Q_OBJECT |
156 | Config& config; | 156 | Config& config; |
157 | QCheckBox *indannotate; | 157 | QCheckBox *indannotate; |
158 | 158 | ||
159 | bool m_isChanged; | 159 | bool m_isChanged; |
160 | 160 | ||
161 | private slots: | 161 | private slots: |
162 | void isChanged(int _v) { m_isChanged = true; } | 162 | void isChanged(int _v) { m_isChanged = true; } |
163 | 163 | ||
164 | public: | 164 | public: |
165 | CIndBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 165 | CIndBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
166 | ~CIndBarPrefs(); | 166 | ~CIndBarPrefs(); |
167 | void saveall(); | 167 | void saveall(); |
168 | bool isChanged() { return m_isChanged; } | 168 | bool isChanged() { return m_isChanged; } |
169 | 169 | ||
170 | }; | 170 | }; |
171 | 171 | ||
172 | class CMiscBarPrefs : public QWidget | 172 | class CMiscBarPrefs : public QWidget |
173 | { | 173 | { |
174 | 174 | Q_OBJECT | |
175 | public: | 175 | public: |
176 | 176 | ||
177 | CMiscBarPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 177 | CMiscBarPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
178 | ~CMiscBarPrefs(); | 178 | ~CMiscBarPrefs(); |
179 | 179 | ||
180 | #ifdef USECOMBO | 180 | #ifdef USECOMBO |
181 | QComboBox *tbpolicy, *tbposition; | 181 | QComboBox *tbpolicy, *tbposition; |
182 | #else | 182 | #else |
183 | MenuButton *tbpolicy, *tbposition; | 183 | MenuButton *tbpolicy, *tbposition; |
184 | #endif | 184 | #endif |
185 | QCheckBox *tbmovable, *floating; | 185 | QCheckBox *tbmovable, *floating; |
186 | }; | 186 | }; |
187 | 187 | ||
188 | class CBarPrefs : public QDialog | 188 | class CBarPrefs : public QDialog |
189 | { | 189 | { |
190 | Q_OBJECT | 190 | Q_OBJECT |
191 | ; | 191 | ; |
192 | CMiscBarPrefs* misc; | 192 | CMiscBarPrefs* misc; |
193 | CFileBarPrefs* filebar; | 193 | CFileBarPrefs* filebar; |
194 | CNavBarPrefs* navbar; | 194 | CNavBarPrefs* navbar; |
195 | CViewBarPrefs* viewbar; | 195 | CViewBarPrefs* viewbar; |
196 | CMarkBarPrefs* markbar; | 196 | CMarkBarPrefs* markbar; |
197 | CIndBarPrefs* indbar; | 197 | CIndBarPrefs* indbar; |
198 | Config config; | 198 | Config config; |
199 | 199 | ||
200 | void keyPressEvent(QKeyEvent* e) | 200 | void keyPressEvent(QKeyEvent* e) |
201 | { | 201 | { |
202 | switch (e->key()) | 202 | switch (e->key()) |
203 | { | 203 | { |
204 | case Key_Escape: | 204 | case Key_Escape: |
205 | e->accept(); | 205 | e->accept(); |
206 | reject(); | 206 | reject(); |
207 | break; | 207 | break; |
208 | case Key_Space: | 208 | case Key_Space: |
209 | case Key_Return: | 209 | case Key_Return: |
210 | e->accept(); | 210 | e->accept(); |
211 | accept(); | 211 | accept(); |
212 | break; | 212 | break; |
213 | default: | 213 | default: |
214 | QWidget::keyPressEvent(e); | 214 | QWidget::keyPressEvent(e); |
215 | } | 215 | } |
216 | } | 216 | } |
217 | public: | 217 | public: |
218 | CBarPrefs(const QString& appdir, bool fs = true, QWidget* parent = 0, const char* name = 0); | 218 | CBarPrefs(const QString& appdir, bool fs = true, QWidget* parent = 0, const char* name = 0); |
219 | ~CBarPrefs() | 219 | ~CBarPrefs() |
220 | { | 220 | { |
221 | if (result()) | 221 | if (result()) |
222 | { | 222 | { |
223 | if (navbar->isChanged()) navbar->saveall(); | 223 | if (navbar->isChanged()) navbar->saveall(); |
224 | if (filebar->isChanged()) filebar->saveall(); | 224 | if (filebar->isChanged()) filebar->saveall(); |
225 | if (viewbar->isChanged()) viewbar->saveall(); | 225 | if (viewbar->isChanged()) viewbar->saveall(); |
226 | if (markbar->isChanged()) markbar->saveall(); | 226 | if (markbar->isChanged()) markbar->saveall(); |
227 | if (indbar->isChanged()) indbar->saveall(); | 227 | if (indbar->isChanged()) indbar->saveall(); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | bool isChanged() | 230 | bool isChanged() |
231 | { | 231 | { |
232 | return | 232 | return |
233 | ( | 233 | ( |
234 | filebar->isChanged() | 234 | filebar->isChanged() |
235 | || | 235 | || |
236 | navbar->isChanged() | 236 | navbar->isChanged() |
237 | || | 237 | || |
238 | viewbar->isChanged() | 238 | viewbar->isChanged() |
239 | || | 239 | || |
240 | markbar->isChanged() | 240 | markbar->isChanged() |
241 | || | 241 | || |
242 | indbar->isChanged() | 242 | indbar->isChanged() |
243 | ); | 243 | ); |
244 | } | 244 | } |
245 | bool floating() { return misc->floating->isChecked(); } | 245 | bool floating() { return misc->floating->isChecked(); } |
246 | void floating(bool v) { misc->floating->setChecked(v); } | 246 | void floating(bool v) { misc->floating->setChecked(v); } |
247 | int tbpolicy() { return misc->tbpolicy->currentItem(); } | 247 | int tbpolicy() { return misc->tbpolicy->currentItem(); } |
248 | #ifdef USECOMBO | 248 | #ifdef USECOMBO |
249 | void tbpolicy(int v) { misc->tbpolicy->setCurrentItem(v); } | 249 | void tbpolicy(int v) { misc->tbpolicy->setCurrentItem(v); } |
250 | #else | 250 | #else |
251 | void tbpolicy(int v) { misc->tbpolicy->select(v); } | 251 | void tbpolicy(int v) { misc->tbpolicy->select(v); } |
252 | #endif | 252 | #endif |
253 | bool tbmovable() { return misc->tbmovable->isChecked(); } | 253 | bool tbmovable() { return misc->tbmovable->isChecked(); } |
254 | void tbmovable(bool v) { misc->tbmovable->setChecked(v); } | 254 | void tbmovable(bool v) { misc->tbmovable->setChecked(v); } |
255 | int tbposition() { return misc->tbposition->currentItem(); } | 255 | int tbposition() { return misc->tbposition->currentItem(); } |
256 | #ifdef USECOMBO | 256 | #ifdef USECOMBO |
257 | void tbposition(int v) { misc->tbposition->setCurrentItem(v); } | 257 | void tbposition(int v) { misc->tbposition->setCurrentItem(v); } |
258 | #else | 258 | #else |
259 | void tbposition(int v) { misc->tbposition->select(v); } | 259 | void tbposition(int v) { misc->tbposition->select(v); } |
260 | #endif | 260 | #endif |
261 | 261 | ||
262 | }; | 262 | }; |
263 | #endif // CPREFS_H | 263 | #endif // CPREFS_H |
diff --git a/noncore/apps/opie-reader/opie-reader.control b/noncore/apps/opie-reader/opie-reader.control index 9996297..b7b0e8f 100644 --- a/noncore/apps/opie-reader/opie-reader.control +++ b/noncore/apps/opie-reader/opie-reader.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-reader | 1 | Package: opie-reader |
2 | Files: bin/reader apps/Applications/opie-reader.desktop pics/opie-reader/* | 2 | Files: bin/reader apps/Applications/opie-reader.desktop pics/opie-reader/* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: applications | 4 | Section: applications |
5 | Maintainer: Tim Wentford <timwentford@hotmail.com> | 5 | Maintainer: Tim Wentford <timwentford@hotmail.com> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal | 7 | Depends: task-opie-minimal |
9 | License: GPL | 8 | License: GPL |
10 | Description: E-Book reader | 9 | Description: E-Book reader |
10 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/opie-write/opie-write.control b/noncore/apps/opie-write/opie-write.control index 52b518a..7b37671 100644 --- a/noncore/apps/opie-write/opie-write.control +++ b/noncore/apps/opie-write/opie-write.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-write | 1 | Package: opie-write |
2 | Files: bin/opie-write apps/Applications/opie-write.desktop pics/opie-write | 2 | Files: bin/opie-write apps/Applications/opie-write.desktop pics/opie-write |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: L.J. Potter <ljp@llornkcor.com> | 5 | Maintainer: L.J. Potter <ljp@llornkcor.com> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal | 7 | Depends: task-opie-minimal |
9 | Description: Rich Text Editor | 8 | Description: Rich Text Editor |
10 | The rich text editor for the Opie environment. | 9 | The rich text editor for the Opie environment. |
10 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/oxygen/opie-oxygen.control b/noncore/apps/oxygen/opie-oxygen.control index 1eff80b..6d40d1b 100644 --- a/noncore/apps/oxygen/opie-oxygen.control +++ b/noncore/apps/oxygen/opie-oxygen.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-oxygen | 1 | Package: opie-oxygen |
2 | Files: bin/oxygen apps/Applications/oxygen.desktop pics/oxygen/oxygen.png share/oxygen/* | 2 | Files: bin/oxygen apps/Applications/oxygen.desktop pics/oxygen/oxygen.png share/oxygen/* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: applications | 4 | Section: applications |
5 | Maintainer: Carsten Niehaus <cniehaus@handhelds.org> | 5 | Maintainer: Carsten Niehaus <cniehaus@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal | 7 | Depends: task-opie-minimal |
9 | Description: Periodic System of the Elements | 8 | Description: Periodic System of the Elements |
10 | The chemistry application for the Opie-environment | 9 | The chemistry application for the Opie-environment |
10 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/tableviewer/opie-tableviewer.control b/noncore/apps/tableviewer/opie-tableviewer.control index b5495e1..aba9b8d 100644 --- a/noncore/apps/tableviewer/opie-tableviewer.control +++ b/noncore/apps/tableviewer/opie-tableviewer.control | |||
@@ -1,11 +1,11 @@ | |||
1 | Package: opie-tableviewer | 1 | Package: opie-tableviewer |
2 | Files: bin/tableviewer apps/Applications/tableviewer.desktop | 2 | Files: bin/tableviewer apps/Applications/tableviewer.desktop |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Warwick Allison <warwick@trolltech.com> | 5 | Maintainer: Warwick Allison <warwick@trolltech.com> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Arch: iPAQ | 7 | Arch: iPAQ |
8 | Version: $QPE_VERSION-$SUB_VERSION | ||
9 | Depends: task-opie-minimal | 8 | Depends: task-opie-minimal |
10 | Description: XML database browsers | 9 | Description: XML database browsers |
11 | A table/database viewer for the Opie environment. | 10 | A table/database viewer for the Opie environment. |
11 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/tinykate/libkate/document/katebuffer.cpp b/noncore/apps/tinykate/libkate/document/katebuffer.cpp index 38ba55d..22a4917 100644 --- a/noncore/apps/tinykate/libkate/document/katebuffer.cpp +++ b/noncore/apps/tinykate/libkate/document/katebuffer.cpp | |||
@@ -1,179 +1,179 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KWrite | 2 | This file is part of KWrite |
3 | Copyright (c) 2000 Waldo Bastian <bastian@kde.org> | 3 | Copyright (c) 2000 Waldo Bastian <bastian@kde.org> |
4 | Copyright (c) 2002 Joseph Wenninger <jowenn@kde.org> | 4 | Copyright (c) 2002 Joseph Wenninger <jowenn@kde.org> |
5 | 5 | ||
6 | $Id$ | 6 | $Id$ |
7 | 7 | ||
8 | This library is free software; you can redistribute it and/or | 8 | This library is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU Library General Public | 9 | modify it under the terms of the GNU Library General Public |
10 | License version 2 as published by the Free Software Foundation. | 10 | License version 2 as published by the Free Software Foundation. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | 23 | ||
24 | #include "katebuffer.h" | 24 | #include "katebuffer.h" |
25 | 25 | ||
26 | // Includes for reading file | 26 | // Includes for reading file |
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
29 | #include <fcntl.h> | 29 | #include <fcntl.h> |
30 | #include <errno.h> | 30 | #include <errno.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | 32 | ||
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | 35 | ||
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qtextcodec.h> | 37 | #include <qtextcodec.h> |
38 | 38 | ||
39 | // | 39 | // |
40 | 40 | ||
41 | #include <assert.h> | 41 | #include <assert.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Create an empty buffer. | 45 | * Create an empty buffer. |
46 | */ | 46 | */ |
47 | KWBuffer::KWBuffer() | 47 | KWBuffer::KWBuffer() |
48 | { | 48 | { |
49 | clear(); | 49 | clear(); |
50 | } | 50 | } |
51 | 51 | ||
52 | void | 52 | void |
53 | KWBuffer::clear() | 53 | KWBuffer::clear() |
54 | { | 54 | { |
55 | m_stringListIt=0; | 55 | m_stringListIt=0; |
56 | m_stringListCurrent=0; | 56 | m_stringListCurrent=0; |
57 | m_stringList.clear(); | 57 | m_stringList.clear(); |
58 | m_lineCount=1; | 58 | m_lineCount=1; |
59 | m_stringListIt = m_stringList.append(new TextLine()); | 59 | m_stringListIt = m_stringList.append(new TextLine()); |
60 | } | 60 | } |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Insert a file at line @p line in the buffer. | 63 | * Insert a file at line @p line in the buffer. |
64 | */ | 64 | */ |
65 | void | 65 | void |
66 | KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec) | 66 | KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec) |
67 | { | 67 | { |
68 | if (line) { | 68 | if (line) { |
69 | qDebug("insert File only supports insertion at line 0 == file opening"); | 69 | qDebug("insert File only supports insertion at line 0 == file opening"); |
70 | return; | 70 | return; |
71 | } | 71 | } |
72 | clear(); | 72 | clear(); |
73 | QFile iofile(file); | 73 | QFile iofile(file); |
74 | iofile.open(IO_ReadOnly); | 74 | iofile.open(IO_ReadOnly); |
75 | QTextStream stream(&iofile); | 75 | QTextStream stream(&iofile); |
76 | stream.setCodec(codec); | 76 | stream.setCodec(codec); |
77 | QString qsl; | 77 | QString qsl; |
78 | int count=0; | 78 | int count=0; |
79 | for (count=0;((qsl=stream.readLine())!=QString::null);count++) | 79 | for (count=0;((qsl=stream.readLine())!=QString::null);count++) |
80 | { | 80 | { |
81 | if (count==0) | 81 | if (count==0) |
82 | { | 82 | { |
83 | (*m_stringListIt)->append(qsl.unicode(),qsl.length()); | 83 | (*m_stringListIt)->append(qsl.unicode(),qsl.length()); |
84 | } | 84 | } |
85 | else | 85 | else |
86 | { | 86 | { |
87 | TextLine::Ptr tl=new TextLine(); | 87 | TextLine::Ptr tl=new TextLine(); |
88 | tl ->append(qsl.unicode(),qsl.length()); | 88 | tl ->append(qsl.unicode(),qsl.length()); |
89 | m_stringListIt=m_stringList.append(tl); | 89 | m_stringListIt=m_stringList.append(tl); |
90 | } | 90 | } |
91 | } | 91 | } |
92 | if (count!=0) | 92 | if (count!=0) |
93 | { | 93 | { |
94 | m_stringListCurrent=count-1; | 94 | m_stringListCurrent=count-1; |
95 | m_lineCount=count; | 95 | m_lineCount=count; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | void | 99 | void |
100 | KWBuffer::loadFilePart() | 100 | KWBuffer::loadFilePart() |
101 | { | 101 | { |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | void | 105 | void |
106 | KWBuffer::insertData(int line, const QByteArray &data, QTextCodec *codec) | 106 | KWBuffer::insertData(int line, const QByteArray &data, QTextCodec *codec) |
107 | { | 107 | { |
108 | } | 108 | } |
109 | 109 | ||
110 | void | 110 | void |
111 | KWBuffer::slotLoadFile() | 111 | KWBuffer::slotLoadFile() |
112 | { | 112 | { |
113 | loadFilePart(); | 113 | loadFilePart(); |
114 | // emit linesChanged(m_totalLines); | 114 | // emit linesChanged(m_totalLines); |
115 | emit linesChanged(20); | 115 | emit linesChanged(20); |
116 | } | 116 | } |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * Return the total number of lines in the buffer. | 119 | * Return the total number of lines in the buffer. |
120 | */ | 120 | */ |
121 | int | 121 | int |
122 | KWBuffer::count() | 122 | KWBuffer::count() |
123 | { | 123 | { |
124 | // qDebug("m_stringList.count %d",m_stringList.count()); | 124 | qDebug("m_stringList.count %d",m_stringList.count()); |
125 | return m_lineCount; | 125 | return m_lineCount; |
126 | //return m_stringList.count(); | 126 | //return m_stringList.count(); |
127 | // return m_totalLines; | 127 | // return m_totalLines; |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | void KWBuffer::seek(int i) | 131 | void KWBuffer::seek(int i) |
132 | { | 132 | { |
133 | if (m_stringListCurrent == i) | 133 | if (m_stringListCurrent == i) |
134 | return; | 134 | return; |
135 | while(m_stringListCurrent < i) | 135 | while(m_stringListCurrent < i) |
136 | { | 136 | { |
137 | ++m_stringListCurrent; | 137 | ++m_stringListCurrent; |
138 | ++m_stringListIt; | 138 | ++m_stringListIt; |
139 | } | 139 | } |
140 | while(m_stringListCurrent > i) | 140 | while(m_stringListCurrent > i) |
141 | { | 141 | { |
142 | --m_stringListCurrent; | 142 | --m_stringListCurrent; |
143 | --m_stringListIt; | 143 | --m_stringListIt; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | TextLine::Ptr | 148 | TextLine::Ptr |
149 | KWBuffer::line(int i) | 149 | KWBuffer::line(int i) |
150 | { | 150 | { |
151 | if (i>=m_stringList.count()) return 0; | 151 | if (i>=m_stringList.count()) return 0; |
152 | seek(i); | 152 | seek(i); |
153 | return *m_stringListIt; | 153 | return *m_stringListIt; |
154 | } | 154 | } |
155 | 155 | ||
156 | void | 156 | void |
157 | KWBuffer::insertLine(int i, TextLine::Ptr line) | 157 | KWBuffer::insertLine(int i, TextLine::Ptr line) |
158 | { | 158 | { |
159 | seek(i); | 159 | seek(i); |
160 | m_stringListIt = m_stringList.insert(m_stringListIt, line); | 160 | m_stringListIt = m_stringList.insert(m_stringListIt, line); |
161 | m_stringListCurrent = i; | 161 | m_stringListCurrent = i; |
162 | m_lineCount++; | 162 | m_lineCount++; |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | void | 166 | void |
167 | KWBuffer::removeLine(int i) | 167 | KWBuffer::removeLine(int i) |
168 | { | 168 | { |
169 | seek(i); | 169 | seek(i); |
170 | m_stringListIt = m_stringList.remove(m_stringListIt); | 170 | m_stringListIt = m_stringList.remove(m_stringListIt); |
171 | m_stringListCurrent = i; | 171 | m_stringListCurrent = i; |
172 | m_lineCount--; | 172 | m_lineCount--; |
173 | } | 173 | } |
174 | 174 | ||
175 | void | 175 | void |
176 | KWBuffer::changeLine(int i) | 176 | KWBuffer::changeLine(int i) |
177 | { | 177 | { |
178 | } | 178 | } |
179 | 179 | ||
diff --git a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp index 844f27d..f90a5f8 100644 --- a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp +++ b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp | |||
@@ -1,305 +1,306 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | katesyntaxdocument.cpp - description | 2 | katesyntaxdocument.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Sat 31 March 2001 | 4 | begin : Sat 31 March 2001 |
5 | copyright : (C) 2001,2002 by Joseph Wenninger | 5 | copyright : (C) 2001,2002 by Joseph Wenninger |
6 | email : jowenn@kde.org | 6 | email : jowenn@kde.org |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include "katesyntaxdocument.h" | 18 | #include "katesyntaxdocument.h" |
19 | #include <kateconfig.h> | 19 | #include <kateconfig.h> |
20 | #include <qfile.h> | 20 | #include <qfile.h> |
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <kstddirs.h> | 22 | #include <kstddirs.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | 29 | ||
30 | SyntaxDocument::SyntaxDocument() | 30 | SyntaxDocument::SyntaxDocument() |
31 | { | 31 | { |
32 | m_root=0; | 32 | m_root=0; |
33 | currentFile=""; | 33 | currentFile=""; |
34 | setupModeList(); | 34 | setupModeList(); |
35 | } | 35 | } |
36 | 36 | ||
37 | void SyntaxDocument::setIdentifier(const QString& identifier) | 37 | void SyntaxDocument::setIdentifier(const QString& identifier) |
38 | { | 38 | { |
39 | #warning FIXME delete m_root; | 39 | #warning FIXME delete m_root; |
40 | m_root=Opie::XMLElement::load(identifier); | 40 | m_root=Opie::XMLElement::load(identifier); |
41 | if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) ); | 41 | if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) ); |
42 | 42 | ||
43 | } | 43 | } |
44 | 44 | ||
45 | SyntaxDocument::~SyntaxDocument() | 45 | SyntaxDocument::~SyntaxDocument() |
46 | { | 46 | { |
47 | } | 47 | } |
48 | 48 | ||
49 | void SyntaxDocument::setupModeList(bool force) | 49 | void SyntaxDocument::setupModeList(bool force) |
50 | { | 50 | { |
51 | 51 | ||
52 | if (myModeList.count() > 0) return; | 52 | if (myModeList.count() > 0) return; |
53 | 53 | ||
54 | KateConfig *config=KGlobal::config(); | 54 | KateConfig *config=KGlobal::config(); |
55 | KStandardDirs *dirs = KGlobal::dirs(); | 55 | KStandardDirs *dirs = KGlobal::dirs(); |
56 | 56 | ||
57 | // QStringList list=dirs->findAllResources("data","kate/syntax/*.xml",false,true); | 57 | // QStringList list=dirs->findAllResources("data","kate/syntax/*.xml",false,true); |
58 | QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/"; | 58 | QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/"; |
59 | 59 | ||
60 | QDir dir(path); | 60 | QDir dir(path); |
61 | QStringList list=dir.entryList("*.xml"); | 61 | QStringList list=dir.entryList("*.xml"); |
62 | 62 | ||
63 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 63 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
64 | { | 64 | { |
65 | QString Group="Highlighting_Cache"+path+*it; | 65 | QString Group="Highlighting_Cache"+path+*it; |
66 | if ((config->hasGroup(Group)) && (!force)) | 66 | if ((config->hasGroup(Group)) && (!force)) |
67 | { | 67 | { |
68 | config->setGroup(Group); | 68 | config->setGroup(Group); |
69 | syntaxModeListItem *mli=new syntaxModeListItem; | 69 | syntaxModeListItem *mli=new syntaxModeListItem; |
70 | mli->name = config->readEntry("name",""); | 70 | mli->name = config->readEntry("name",""); |
71 | mli->section = config->readEntry("section",""); | 71 | mli->section = config->readEntry("section",""); |
72 | mli->mimetype = config->readEntry("mimetype",""); | 72 | mli->mimetype = config->readEntry("mimetype",""); |
73 | mli->extension = config->readEntry("extension",""); | 73 | mli->extension = config->readEntry("extension",""); |
74 | mli->identifier = *it; | 74 | mli->identifier = path+*it; |
75 | myModeList.append(mli); | 75 | myModeList.append(mli); |
76 | } | 76 | } |
77 | else | 77 | else |
78 | { | 78 | { |
79 | qDebug("Found a description file:"+path+(*it)); | 79 | qDebug("Found a description file:"+path+(*it)); |
80 | setIdentifier(path+(*it)); | 80 | setIdentifier(path+(*it)); |
81 | Opie::XMLElement *e=m_root; | 81 | Opie::XMLElement *e=m_root; |
82 | if (e) | 82 | if (e) |
83 | { | 83 | { |
84 | e=e->firstChild(); | 84 | e=e->firstChild(); |
85 | qDebug(e->tagName()); | 85 | qDebug(e->tagName()); |
86 | if (e->tagName()=="language") | 86 | if (e->tagName()=="language") |
87 | { | 87 | { |
88 | syntaxModeListItem *mli=new syntaxModeListItem; | 88 | syntaxModeListItem *mli=new syntaxModeListItem; |
89 | mli->name = e->attribute("name"); | 89 | mli->name = e->attribute("name"); |
90 | mli->section = e->attribute("section"); | 90 | mli->section = e->attribute("section"); |
91 | mli->mimetype = e->attribute("mimetype"); | 91 | mli->mimetype = e->attribute("mimetype"); |
92 | mli->extension = e->attribute("extensions"); | 92 | mli->extension = e->attribute("extensions"); |
93 | qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name)); | 93 | qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name)); |
94 | if (mli->section.isEmpty()) | 94 | if (mli->section.isEmpty()) |
95 | mli->section=i18n("Other"); | 95 | mli->section=i18n("Other"); |
96 | 96 | ||
97 | mli->identifier = path+(*it); | 97 | mli->identifier = path+(*it); |
98 | config->setGroup(Group); | 98 | config->setGroup(Group); |
99 | config->writeEntry("name",mli->name); | 99 | config->writeEntry("name",mli->name); |
100 | config->writeEntry("section",mli->section); | 100 | config->writeEntry("section",mli->section); |
101 | config->writeEntry("mimetype",mli->mimetype); | 101 | config->writeEntry("mimetype",mli->mimetype); |
102 | config->writeEntry("extension",mli->extension); | 102 | config->writeEntry("extension",mli->extension); |
103 | myModeList.append(mli); | 103 | myModeList.append(mli); |
104 | } | 104 | } |
105 | } | 105 | } |
106 | } | 106 | } |
107 | } | 107 | } |
108 | config->write(); | ||
108 | // config->sync(); | 109 | // config->sync(); |
109 | } | 110 | } |
110 | 111 | ||
111 | SyntaxModeList SyntaxDocument::modeList() | 112 | SyntaxModeList SyntaxDocument::modeList() |
112 | { | 113 | { |
113 | return myModeList; | 114 | return myModeList; |
114 | } | 115 | } |
115 | 116 | ||
116 | bool SyntaxDocument::nextGroup( syntaxContextData* data) | 117 | bool SyntaxDocument::nextGroup( syntaxContextData* data) |
117 | { | 118 | { |
118 | if(!data) return false; | 119 | if(!data) return false; |
119 | 120 | ||
120 | if (!data->currentGroup) | 121 | if (!data->currentGroup) |
121 | data->currentGroup=data->parent->firstChild(); | 122 | data->currentGroup=data->parent->firstChild(); |
122 | else | 123 | else |
123 | data->currentGroup=data->currentGroup->nextChild(); | 124 | data->currentGroup=data->currentGroup->nextChild(); |
124 | 125 | ||
125 | data->item=0; | 126 | data->item=0; |
126 | 127 | ||
127 | if (!data->currentGroup) | 128 | if (!data->currentGroup) |
128 | return false; | 129 | return false; |
129 | else | 130 | else |
130 | return true; | 131 | return true; |
131 | } | 132 | } |
132 | 133 | ||
133 | bool SyntaxDocument::nextItem( syntaxContextData* data) | 134 | bool SyntaxDocument::nextItem( syntaxContextData* data) |
134 | { | 135 | { |
135 | if(!data) return false; | 136 | if(!data) return false; |
136 | 137 | ||
137 | if (!data->item) | 138 | if (!data->item) |
138 | data->item=data->currentGroup->firstChild(); | 139 | data->item=data->currentGroup->firstChild(); |
139 | else | 140 | else |
140 | data->item=data->item->nextChild(); | 141 | data->item=data->item->nextChild(); |
141 | 142 | ||
142 | if (!data->item) | 143 | if (!data->item) |
143 | return false; | 144 | return false; |
144 | else | 145 | else |
145 | return true; | 146 | return true; |
146 | } | 147 | } |
147 | 148 | ||
148 | QString SyntaxDocument::groupItemData( syntaxContextData* data,QString name) | 149 | QString SyntaxDocument::groupItemData( syntaxContextData* data,QString name) |
149 | { | 150 | { |
150 | if(!data) | 151 | if(!data) |
151 | return QString::null; | 152 | return QString::null; |
152 | 153 | ||
153 | if ( (data->item) && (name.isEmpty())) | 154 | if ( (data->item) && (name.isEmpty())) |
154 | return data->item->tagName(); | 155 | return data->item->tagName(); |
155 | 156 | ||
156 | if (data->item) | 157 | if (data->item) |
157 | return data->item->attribute(name); | 158 | return data->item->attribute(name); |
158 | else | 159 | else |
159 | return QString(); | 160 | return QString(); |
160 | } | 161 | } |
161 | 162 | ||
162 | QString SyntaxDocument::groupData( syntaxContextData* data,QString name) | 163 | QString SyntaxDocument::groupData( syntaxContextData* data,QString name) |
163 | { | 164 | { |
164 | if(!data) | 165 | if(!data) |
165 | return QString::null; | 166 | return QString::null; |
166 | 167 | ||
167 | if (data->currentGroup) | 168 | if (data->currentGroup) |
168 | return data->currentGroup->attribute(name); | 169 | return data->currentGroup->attribute(name); |
169 | else | 170 | else |
170 | return QString(); | 171 | return QString(); |
171 | } | 172 | } |
172 | 173 | ||
173 | void SyntaxDocument::freeGroupInfo( syntaxContextData* data) | 174 | void SyntaxDocument::freeGroupInfo( syntaxContextData* data) |
174 | { | 175 | { |
175 | if (data) | 176 | if (data) |
176 | delete data; | 177 | delete data; |
177 | } | 178 | } |
178 | 179 | ||
179 | syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data) | 180 | syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data) |
180 | { | 181 | { |
181 | syntaxContextData *retval=new syntaxContextData; | 182 | syntaxContextData *retval=new syntaxContextData; |
182 | retval->parent=0; | 183 | retval->parent=0; |
183 | retval->currentGroup=0; | 184 | retval->currentGroup=0; |
184 | retval->item=0; | 185 | retval->item=0; |
185 | if (data != 0) | 186 | if (data != 0) |
186 | { | 187 | { |
187 | retval->parent=data->currentGroup; | 188 | retval->parent=data->currentGroup; |
188 | retval->currentGroup=data->item; | 189 | retval->currentGroup=data->item; |
189 | retval->item=0; | 190 | retval->item=0; |
190 | } | 191 | } |
191 | 192 | ||
192 | return retval; | 193 | return retval; |
193 | } | 194 | } |
194 | 195 | ||
195 | syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config) | 196 | syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config) |
196 | { | 197 | { |
197 | Opie::XMLElement *e = m_root->firstChild()->firstChild(); | 198 | Opie::XMLElement *e = m_root->firstChild()->firstChild(); |
198 | 199 | ||
199 | while (e) | 200 | while (e) |
200 | { | 201 | { |
201 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl; | 202 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl; |
202 | 203 | ||
203 | if (e->tagName().compare(mainGroupName)==0 ) | 204 | if (e->tagName().compare(mainGroupName)==0 ) |
204 | { | 205 | { |
205 | Opie::XMLElement *e1=e->firstChild(); | 206 | Opie::XMLElement *e1=e->firstChild(); |
206 | 207 | ||
207 | while (e1) | 208 | while (e1) |
208 | { | 209 | { |
209 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; | 210 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; |
210 | 211 | ||
211 | if (e1->tagName()==Config) | 212 | if (e1->tagName()==Config) |
212 | { | 213 | { |
213 | syntaxContextData *data=new ( syntaxContextData); | 214 | syntaxContextData *data=new ( syntaxContextData); |
214 | data->currentGroup=0; | 215 | data->currentGroup=0; |
215 | data->parent=0; | 216 | data->parent=0; |
216 | data->item=e1; | 217 | data->item=e1; |
217 | return data; | 218 | return data; |
218 | } | 219 | } |
219 | 220 | ||
220 | e1=e1->nextChild(); | 221 | e1=e1->nextChild(); |
221 | } | 222 | } |
222 | 223 | ||
223 | kdDebug(13010) << "WARNING :returning null 3"<< endl; | 224 | kdDebug(13010) << "WARNING :returning null 3"<< endl; |
224 | return 0; | 225 | return 0; |
225 | } | 226 | } |
226 | 227 | ||
227 | e=e->nextChild(); | 228 | e=e->nextChild(); |
228 | } | 229 | } |
229 | 230 | ||
230 | kdDebug(13010) << "WARNING :returning null 4" << endl; | 231 | kdDebug(13010) << "WARNING :returning null 4" << endl; |
231 | return 0; | 232 | return 0; |
232 | } | 233 | } |
233 | 234 | ||
234 | 235 | ||
235 | 236 | ||
236 | syntaxContextData* SyntaxDocument::getGroupInfo(const QString& mainGroupName, const QString &group) | 237 | syntaxContextData* SyntaxDocument::getGroupInfo(const QString& mainGroupName, const QString &group) |
237 | { | 238 | { |
238 | 239 | ||
239 | Opie::XMLElement *e=m_root->firstChild()->firstChild(); | 240 | Opie::XMLElement *e=m_root->firstChild()->firstChild(); |
240 | 241 | ||
241 | while (e) | 242 | while (e) |
242 | { | 243 | { |
243 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl; | 244 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl; |
244 | 245 | ||
245 | if (e->tagName().compare(mainGroupName)==0 ) | 246 | if (e->tagName().compare(mainGroupName)==0 ) |
246 | { | 247 | { |
247 | Opie::XMLElement *e1=e->firstChild(); | 248 | Opie::XMLElement *e1=e->firstChild(); |
248 | 249 | ||
249 | while (e1) | 250 | while (e1) |
250 | { | 251 | { |
251 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; | 252 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; |
252 | if (e1->tagName()==group+"s") | 253 | if (e1->tagName()==group+"s") |
253 | { | 254 | { |
254 | syntaxContextData *data=new ( syntaxContextData); | 255 | syntaxContextData *data=new ( syntaxContextData); |
255 | data->parent=e1; | 256 | data->parent=e1; |
256 | data->currentGroup=0; | 257 | data->currentGroup=0; |
257 | data->item=0; | 258 | data->item=0; |
258 | return data; | 259 | return data; |
259 | } | 260 | } |
260 | 261 | ||
261 | e1=e1->nextChild(); | 262 | e1=e1->nextChild(); |
262 | } | 263 | } |
263 | 264 | ||
264 | kdDebug(13010) << "WARNING : getGroupInfo returning null :1 " << endl; | 265 | kdDebug(13010) << "WARNING : getGroupInfo returning null :1 " << endl; |
265 | return 0; | 266 | return 0; |
266 | } | 267 | } |
267 | 268 | ||
268 | e=e->nextChild(); | 269 | e=e->nextChild(); |
269 | } | 270 | } |
270 | 271 | ||
271 | kdDebug(13010) << "WARNING : getGroupInfo returning null :2" << endl; | 272 | kdDebug(13010) << "WARNING : getGroupInfo returning null :2" << endl; |
272 | return 0; | 273 | return 0; |
273 | } | 274 | } |
274 | 275 | ||
275 | 276 | ||
276 | QStringList& SyntaxDocument::finddata(const QString& mainGroup,const QString& type,bool clearList) | 277 | QStringList& SyntaxDocument::finddata(const QString& mainGroup,const QString& type,bool clearList) |
277 | { | 278 | { |
278 | Opie::XMLElement *e = m_root->firstChild(); | 279 | Opie::XMLElement *e = m_root->firstChild(); |
279 | if (clearList) | 280 | if (clearList) |
280 | m_data.clear(); | 281 | m_data.clear(); |
281 | 282 | ||
282 | for(e=e->firstChild(); e; e=e->nextChild()) | 283 | for(e=e->firstChild(); e; e=e->nextChild()) |
283 | { | 284 | { |
284 | if (e->tagName()==mainGroup) | 285 | if (e->tagName()==mainGroup) |
285 | { | 286 | { |
286 | for (Opie::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild()) | 287 | for (Opie::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild()) |
287 | { | 288 | { |
288 | if (e1->tagName()!="list") continue; | 289 | if (e1->tagName()!="list") continue; |
289 | 290 | ||
290 | if (e1->attribute("name")==type) | 291 | if (e1->attribute("name")==type) |
291 | { | 292 | { |
292 | for (Opie::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild()) | 293 | for (Opie::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild()) |
293 | { | 294 | { |
294 | qDebug("FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value()); | 295 | qDebug("FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value()); |
295 | m_data+=e2->firstChild()->value().stripWhiteSpace(); | 296 | m_data+=e2->firstChild()->value().stripWhiteSpace(); |
296 | } | 297 | } |
297 | break; | 298 | break; |
298 | } | 299 | } |
299 | } | 300 | } |
300 | break; | 301 | break; |
301 | } | 302 | } |
302 | } | 303 | } |
303 | 304 | ||
304 | return m_data; | 305 | return m_data; |
305 | } | 306 | } |
diff --git a/noncore/apps/tinykate/libkate/libkate.pro b/noncore/apps/tinykate/libkate/libkate.pro index 5cb0b14..b282059 100644 --- a/noncore/apps/tinykate/libkate/libkate.pro +++ b/noncore/apps/tinykate/libkate/libkate.pro | |||
@@ -1,86 +1,91 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE= lib |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = microkde/kapplication.h \ | 3 | HEADERS = microkde/kapplication.h \ |
4 | kateconfig.h \ | 4 | kateconfig.h \ |
5 | microkde/kdebug.h \ | 5 | microkde/kdebug.h \ |
6 | microkde/kdialog.h \ | 6 | microkde/kdialog.h \ |
7 | microkde/kdialogbase.h \ | 7 | microkde/kdialogbase.h \ |
8 | microkde/kfiledialog.h \ | 8 | microkde/kfiledialog.h \ |
9 | microkde/kglobal.h \ | 9 | microkde/kglobal.h \ |
10 | microkde/kiconloader.h \ | 10 | microkde/kiconloader.h \ |
11 | microkde/klineedit.h \ | 11 | microkde/klineedit.h \ |
12 | microkde/klocale.h \ | 12 | microkde/klocale.h \ |
13 | microkde/kmessagebox.h \ | 13 | microkde/kmessagebox.h \ |
14 | microkde/kprinter.h \ | 14 | microkde/kprinter.h \ |
15 | microkde/krestrictedline.h \ | 15 | microkde/krestrictedline.h \ |
16 | microkde/kseparator.h \ | 16 | microkde/kseparator.h \ |
17 | microkde/kstandarddirs.h \ | 17 | microkde/kstandarddirs.h \ |
18 | microkde/ktempfile.h \ | 18 | microkde/ktempfile.h \ |
19 | microkde/kunload.h \ | 19 | microkde/kunload.h \ |
20 | microkde/kurlrequester.h \ | 20 | microkde/kurlrequester.h \ |
21 | microkde/kfontdialog.h \ | 21 | microkde/kfontdialog.h \ |
22 | microkde/krun.h \ | 22 | microkde/krun.h \ |
23 | microkde/knumvalidator.h \ | 23 | microkde/knumvalidator.h \ |
24 | microkde/kstaticdeleter.h \ | 24 | microkde/kstaticdeleter.h \ |
25 | microkde/klistview.h \ | 25 | microkde/klistview.h \ |
26 | microkde/kglobalsettings.h \ | 26 | microkde/kglobalsettings.h \ |
27 | microkde/kcolorbtn.h \ | 27 | microkde/kcolorbtn.h \ |
28 | qt3back/qregexp3.h \ | 28 | \ |
29 | microkde/ksharedptr.h \ | 29 | \ |
30 | document/katebuffer.h document/katedialogs.h \ | 30 | qt3back/qregexp3.h \ |
31 | document/katetextline.h \ | 31 | microkde/ksharedptr.h \ |
32 | document/katecmd.h \ | 32 | document/katebuffer.h document/katedialogs.h \ |
33 | document/katehighlight.h \ | 33 | document/katetextline.h \ |
34 | document/katecmds.h document/katedocument.h \ | 34 | document/katecmd.h \ |
35 | document/katesyntaxdocument.h \ | 35 | document/katehighlight.h \ |
36 | view/kateundohistory.h \ | 36 | document/katecmds.h document/katedocument.h \ |
37 | view/kateview.h \ | 37 | document/katesyntaxdocument.h \ |
38 | view/kateviewdialog.h \ | 38 | view/kateundohistory.h \ |
39 | interfaces/view.h \ | 39 | view/kateview.h \ |
40 | interfaces/document.h \ | 40 | view/kateviewdialog.h \ |
41 | ktexteditor/ktexteditor.h | 41 | interfaces/view.h \ |
42 | interfaces/document.h \ | ||
43 | ktexteditor/ktexteditor.h | ||
42 | 44 | ||
43 | SOURCES = microkde/kapplication.cpp \ | 45 | SOURCES = microkde/kapplication.cpp \ |
44 | microkde/kdialogbase.cpp \ | 46 | microkde/kdialogbase.cpp \ |
45 | kateconfig.cpp \ | 47 | kateconfig.cpp \ |
46 | microkde/klocale.cpp \ | 48 | microkde/klocale.cpp \ |
47 | microkde/kmessagebox.cpp \ | 49 | microkde/kmessagebox.cpp \ |
48 | microkde/kprocess.cpp \ | 50 | microkde/kprocess.cpp \ |
49 | microkde/kstandarddirs.cpp \ | 51 | microkde/kstandarddirs.cpp \ |
50 | microkde/ktempfile.cpp \ | 52 | microkde/ktempfile.cpp \ |
51 | microkde/kurlrequester.cpp \ | 53 | microkde/kurlrequester.cpp \ |
54 | microkde/kcolordialog.cpp \ | ||
52 | microkde/kfontdialog.cpp \ | 55 | microkde/kfontdialog.cpp \ |
53 | microkde/krun.cpp \ | 56 | microkde/krun.cpp \ |
54 | microkde/knumvalidator.cpp \ | 57 | microkde/knumvalidator.cpp \ |
55 | microkde/kglobal.cpp \ | 58 | microkde/kglobal.cpp \ |
56 | microkde/kglobalsettings.cpp \ | 59 | microkde/kglobalsettings.cpp \ |
57 | microkde/kcolorbtn.cpp \ | 60 | microkde/kcolorbtn.cpp \ |
58 | qt3back/qregexp3.cpp \ | 61 | \ |
59 | ktexteditor/ktexteditor.cpp \ | 62 | \ |
60 | document/katebuffer.cpp document/katedialogs.cpp \ | 63 | qt3back/qregexp3.cpp \ |
61 | document/katehighlight.cpp \ | 64 | ktexteditor/ktexteditor.cpp \ |
62 | document/katecmd.cpp \ | 65 | document/katebuffer.cpp document/katedialogs.cpp \ |
63 | document/katesyntaxdocument.cpp document/katecmds.cpp \ | 66 | document/katehighlight.cpp \ |
64 | document/katedocument.cpp document/katetextline.cpp \ | 67 | document/katecmd.cpp \ |
65 | view/kateundohistory.cpp \ | 68 | document/katesyntaxdocument.cpp document/katecmds.cpp \ |
66 | view/kateview.cpp \ | 69 | document/katedocument.cpp document/katetextline.cpp \ |
67 | view/kateviewdialog.cpp \ | 70 | view/kateundohistory.cpp \ |
68 | interfaces/interfaces.cpp | 71 | view/kateview.cpp \ |
72 | view/kateviewdialog.cpp \ | ||
73 | interfaces/interfaces.cpp | ||
69 | 74 | ||
70 | INTERFACES = | 75 | INTERFACES= |
71 | INCLUDEPATH += $(OPIEDIR)/include \ | 76 | INCLUDEPATH+= $(OPIEDIR)/include \ |
72 | $(OPIEDIR)/noncore/apps/tinykate/libkate \ | 77 | $(OPIEDIR)/noncore/apps/tinykate/libkate \ |
73 | $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ | 78 | $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ |
74 | $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ | 79 | $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ |
75 | $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ | 80 | $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ |
76 | $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ | 81 | $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ |
77 | $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ | 82 | $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ |
78 | $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back | 83 | $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back |
79 | DEPENDPATH += $(OPIEDIR)/include | 84 | DEPENDPATH+= $(OPIEDIR)/include |
80 | LIBS += -lqpe -lopie | 85 | LIBS += -lqpe -lopie |
81 | TARGET = tinykate | 86 | TARGET = tinykate |
82 | 87 | ||
83 | INCLUDEPATH += $(OPIEDIR)/include | 88 | INCLUDEPATH += $(OPIEDIR)/include |
84 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) | 89 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) |
85 | 90 | ||
86 | include ( $(OPIEDIR)/include.pro ) | 91 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp b/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp index 976f1db..5d21f15 100644 --- a/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp +++ b/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp | |||
@@ -1,86 +1,84 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 | Copyright (C) 1997 Martin Jones (mjones@kde.org) |
3 | Copyright (C) 1999 Cristian Tibirna (ctibirna@kde.org) | 3 | Copyright (C) 1999 Cristian Tibirna (ctibirna@kde.org) |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qdialog.h> | 21 | #include <qdialog.h> |
22 | #include <qpainter.h> | 22 | #include <qpainter.h> |
23 | #include <qdrawutil.h> | 23 | #include <qdrawutil.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <kglobalsettings.h> | 25 | #include <kglobalsettings.h> |
26 | //#include "kcolordialog.h" | 26 | #include "kcolordialog.h" |
27 | #include "kcolorbtn.h" | 27 | #include "kcolorbtn.h" |
28 | 28 | ||
29 | #include <opie/colordialog.h> | ||
30 | |||
31 | KColorButton::KColorButton( QWidget *parent, const char *name ) | 29 | KColorButton::KColorButton( QWidget *parent, const char *name ) |
32 | : QPushButton( parent, name ), dragFlag(false) | 30 | : QPushButton( parent, name ), dragFlag(false) |
33 | { | 31 | { |
34 | // 2000-10-15 (putzer): fixes broken keyboard usage | 32 | // 2000-10-15 (putzer): fixes broken keyboard usage |
35 | connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); | 33 | connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); |
36 | } | 34 | } |
37 | 35 | ||
38 | KColorButton::KColorButton( const QColor &c, QWidget *parent, | 36 | KColorButton::KColorButton( const QColor &c, QWidget *parent, |
39 | const char *name ) | 37 | const char *name ) |
40 | : QPushButton( parent, name ), col(c), dragFlag(false) | 38 | : QPushButton( parent, name ), col(c), dragFlag(false) |
41 | { | 39 | { |
42 | 40 | ||
43 | // 2000-10-15 (putzer): fixes broken keyboard usage | 41 | // 2000-10-15 (putzer): fixes broken keyboard usage |
44 | connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); | 42 | connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); |
45 | } | 43 | } |
46 | 44 | ||
47 | void KColorButton::setColor( const QColor &c ) | 45 | void KColorButton::setColor( const QColor &c ) |
48 | { | 46 | { |
49 | col = c; | 47 | col = c; |
50 | repaint( false ); | 48 | repaint( false ); |
51 | } | 49 | } |
52 | 50 | ||
53 | void KColorButton::drawButtonLabel( QPainter *painter ) | 51 | void KColorButton::drawButtonLabel( QPainter *painter ) |
54 | { | 52 | { |
55 | QRect r = QApplication::style().buttonRect( 0, 0, width(), height() ); | 53 | QRect r = QApplication::style().buttonRect( 0, 0, width(), height() ); |
56 | int l = r.x(); | 54 | int l = r.x(); |
57 | int t = r.y(); | 55 | int t = r.y(); |
58 | int w = r.width(); | 56 | int w = r.width(); |
59 | int h = r.height(); | 57 | int h = r.height(); |
60 | int b = 5; | 58 | int b = 5; |
61 | 59 | ||
62 | QColor lnCol = colorGroup().text(); | 60 | QColor lnCol = colorGroup().text(); |
63 | QColor fillCol = isEnabled() ? col : backgroundColor(); | 61 | QColor fillCol = isEnabled() ? col : backgroundColor(); |
64 | 62 | ||
65 | if ( isDown() ) { | 63 | if ( isDown() ) { |
66 | qDrawPlainRect( painter, l+b+1, t+b+1, w-b*2, h-b*2, lnCol, 1, 0 ); | 64 | qDrawPlainRect( painter, l+b+1, t+b+1, w-b*2, h-b*2, lnCol, 1, 0 ); |
67 | b++; | 65 | b++; |
68 | painter->fillRect( l+b+1, t+b+1, w-b*2, h-b*2, fillCol ); | 66 | painter->fillRect( l+b+1, t+b+1, w-b*2, h-b*2, fillCol ); |
69 | } else { | 67 | } else { |
70 | qDrawPlainRect( painter, l+b, t+b, w-b*2, h-b*2, lnCol, 1, 0 ); | 68 | qDrawPlainRect( painter, l+b, t+b, w-b*2, h-b*2, lnCol, 1, 0 ); |
71 | b++; | 69 | b++; |
72 | painter->fillRect( l+b, t+b, w-b*2, h-b*2, fillCol ); | 70 | painter->fillRect( l+b, t+b, w-b*2, h-b*2, fillCol ); |
73 | } | 71 | } |
74 | } | 72 | } |
75 | 73 | ||
76 | void KColorButton::chooseColor() | 74 | void KColorButton::chooseColor() |
77 | { | 75 | { |
78 | QColor newCol=OColorDialog::getColor( col); | 76 | if( KColorDialog::getColor( col) == QDialog::Rejected ) |
79 | if( newCol != QDialog::Rejected ) | ||
80 | { | 77 | { |
81 | col=newCol; | 78 | return; |
79 | } | ||
80 | |||
82 | repaint( false ); | 81 | repaint( false ); |
83 | emit changed( col ); | 82 | emit changed( col ); |
84 | } | ||
85 | } | 83 | } |
86 | 84 | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/kcolordialog.h b/noncore/apps/tinykate/libkate/microkde/kcolordialog.h index 1d5c27e..0f831cd 100644 --- a/noncore/apps/tinykate/libkate/microkde/kcolordialog.h +++ b/noncore/apps/tinykate/libkate/microkde/kcolordialog.h | |||
@@ -1,16 +1,14 @@ | |||
1 | #ifndef MINIKDE_KCOLORDIALOG_H | 1 | #ifndef MINIKDE_KCOLORDIALOG_H |
2 | #define MINIKDE_KCOLORDIALOG_H | 2 | #define MINIKDE_KCOLORDIALOG_H |
3 | 3 | ||
4 | #include <qcolor.h> | 4 | #include <qcolor.h> |
5 | #include <opie/colordialog.h> | ||
6 | 5 | ||
7 | class KColorDialog : OColorDialog | 6 | class KColorDialog |
8 | { | 7 | { |
9 | Q_OBJECT | ||
10 | public: | 8 | public: |
11 | enum { Accepted }; | 9 | enum { Accepted }; |
12 | 10 | ||
13 | static int getColor( const QColor & ); | 11 | static int getColor( const QColor & ); |
14 | }; | 12 | }; |
15 | 13 | ||
16 | #endif | 14 | #endif |
diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp index de81d0f..af3b30d 100644 --- a/noncore/apps/tinykate/libkate/view/kateview.cpp +++ b/noncore/apps/tinykate/libkate/view/kateview.cpp | |||
@@ -663,2263 +663,2261 @@ void KateViewInternal::clearDirtyCache(int height) { | |||
663 | updateState = 0; | 663 | updateState = 0; |
664 | 664 | ||
665 | lines = endLine - startLine +1; | 665 | lines = endLine - startLine +1; |
666 | if (lines > numLines) { // resize the dirty cache | 666 | if (lines > numLines) { // resize the dirty cache |
667 | numLines = lines*2; | 667 | numLines = lines*2; |
668 | delete [] lineRanges; | 668 | delete [] lineRanges; |
669 | lineRanges = new LineRange[numLines]; | 669 | lineRanges = new LineRange[numLines]; |
670 | } | 670 | } |
671 | 671 | ||
672 | for (z = 0; z < lines; z++) { // clear all lines | 672 | for (z = 0; z < lines; z++) { // clear all lines |
673 | lineRanges[z].start = 0xffffff; | 673 | lineRanges[z].start = 0xffffff; |
674 | lineRanges[z].end = -2; | 674 | lineRanges[z].end = -2; |
675 | } | 675 | } |
676 | newXPos = newYPos = -1; | 676 | newXPos = newYPos = -1; |
677 | } | 677 | } |
678 | 678 | ||
679 | void KateViewInternal::tagLines(int start, int end, int x1, int x2) { | 679 | void KateViewInternal::tagLines(int start, int end, int x1, int x2) { |
680 | LineRange *r; | 680 | LineRange *r; |
681 | int z; | 681 | int z; |
682 | 682 | ||
683 | start -= startLine; | 683 | start -= startLine; |
684 | if (start < 0) start = 0; | 684 | if (start < 0) start = 0; |
685 | end -= startLine; | 685 | end -= startLine; |
686 | if (end > endLine - startLine) end = endLine - startLine; | 686 | if (end > endLine - startLine) end = endLine - startLine; |
687 | 687 | ||
688 | if (x1 <= 0) x1 = -2; | 688 | if (x1 <= 0) x1 = -2; |
689 | if (x1 < xPos-2) x1 = xPos-2; | 689 | if (x1 < xPos-2) x1 = xPos-2; |
690 | if (x2 > width() + xPos-2) x2 = width() + xPos-2; | 690 | if (x2 > width() + xPos-2) x2 = width() + xPos-2; |
691 | if (x1 >= x2) return; | 691 | if (x1 >= x2) return; |
692 | 692 | ||
693 | r = &lineRanges[start]; | 693 | r = &lineRanges[start]; |
694 | for (z = start; z <= end; z++) { | 694 | for (z = start; z <= end; z++) { |
695 | if (x1 < r->start) r->start = x1; | 695 | if (x1 < r->start) r->start = x1; |
696 | if (x2 > r->end) r->end = x2; | 696 | if (x2 > r->end) r->end = x2; |
697 | r++; | 697 | r++; |
698 | updateState |= 1; | 698 | updateState |= 1; |
699 | } | 699 | } |
700 | } | 700 | } |
701 | 701 | ||
702 | void KateViewInternal::tagAll() { | 702 | void KateViewInternal::tagAll() { |
703 | updateState = 3; | 703 | updateState = 3; |
704 | } | 704 | } |
705 | 705 | ||
706 | void KateViewInternal::setPos(int x, int y) { | 706 | void KateViewInternal::setPos(int x, int y) { |
707 | newXPos = x; | 707 | newXPos = x; |
708 | newYPos = y; | 708 | newYPos = y; |
709 | } | 709 | } |
710 | 710 | ||
711 | void KateViewInternal::center() { | 711 | void KateViewInternal::center() { |
712 | newXPos = 0; | 712 | newXPos = 0; |
713 | newYPos = cursor.y*myDoc->fontHeight - height()/2; | 713 | newYPos = cursor.y*myDoc->fontHeight - height()/2; |
714 | if (newYPos < 0) newYPos = 0; | 714 | if (newYPos < 0) newYPos = 0; |
715 | } | 715 | } |
716 | 716 | ||
717 | void KateViewInternal::updateView(int flags) { | 717 | void KateViewInternal::updateView(int flags) { |
718 | int fontHeight; | 718 | int fontHeight; |
719 | int oldXPos, oldYPos; | 719 | int oldXPos, oldYPos; |
720 | int w, h; | 720 | int w, h; |
721 | int z; | 721 | int z; |
722 | bool b; | 722 | bool b; |
723 | int xMax, yMax; | 723 | int xMax, yMax; |
724 | int cYPos; | 724 | int cYPos; |
725 | int cXPosMin, cXPosMax, cYPosMin, cYPosMax; | 725 | int cXPosMin, cXPosMax, cYPosMin, cYPosMax; |
726 | int dx, dy; | 726 | int dx, dy; |
727 | int pageScroll; | 727 | int pageScroll; |
728 | int scrollbarWidth = style().scrollBarExtent().width(); | 728 | int scrollbarWidth = style().scrollBarExtent().width(); |
729 | 729 | ||
730 | //debug("upView %d %d %d %d %d", exposeCursor, updateState, flags, newXPos, newYPos); | 730 | //debug("upView %d %d %d %d %d", exposeCursor, updateState, flags, newXPos, newYPos); |
731 | if (exposeCursor || flags & KateView::ufDocGeometry) { | 731 | if (exposeCursor || flags & KateView::ufDocGeometry) { |
732 | emit myView->newCurPos(); | 732 | emit myView->newCurPos(); |
733 | } else { | 733 | } else { |
734 | if (updateState == 0 && newXPos < 0 && newYPos < 0) return; | 734 | if (updateState == 0 && newXPos < 0 && newYPos < 0) return; |
735 | } | 735 | } |
736 | 736 | ||
737 | if (cursorTimer) { | 737 | if (cursorTimer) { |
738 | killTimer(cursorTimer); | 738 | killTimer(cursorTimer); |
739 | cursorTimer = startTimer(KApplication::cursorFlashTime() / 2); | 739 | cursorTimer = startTimer(KApplication::cursorFlashTime() / 2); |
740 | cursorOn = true; | 740 | cursorOn = true; |
741 | } | 741 | } |
742 | 742 | ||
743 | oldXPos = xPos; | 743 | oldXPos = xPos; |
744 | oldYPos = yPos; | 744 | oldYPos = yPos; |
745 | /* if (flags & ufPos) { | 745 | /* if (flags & ufPos) { |
746 | xPos = newXPos; | 746 | xPos = newXPos; |
747 | yPos = newYPos; | 747 | yPos = newYPos; |
748 | exposeCursor = true; | 748 | exposeCursor = true; |
749 | }*/ | 749 | }*/ |
750 | if (newXPos >= 0) xPos = newXPos; | 750 | if (newXPos >= 0) xPos = newXPos; |
751 | if (newYPos >= 0) yPos = newYPos; | 751 | if (newYPos >= 0) yPos = newYPos; |
752 | 752 | ||
753 | fontHeight = myDoc->fontHeight; | 753 | fontHeight = myDoc->fontHeight; |
754 | cYPos = cursor.y*fontHeight; | 754 | cYPos = cursor.y*fontHeight; |
755 | 755 | ||
756 | z = 0; | 756 | z = 0; |
757 | do { | 757 | do { |
758 | w = myView->width() - 4; | 758 | w = myView->width() - 4; |
759 | h = myView->height() - 4; | 759 | h = myView->height() - 4; |
760 | 760 | ||
761 | xMax = myDoc->textWidth() - w; | 761 | xMax = myDoc->textWidth() - w; |
762 | b = (xPos > 0 || xMax > 0); | 762 | b = (xPos > 0 || xMax > 0); |
763 | if (b) h -= scrollbarWidth; | 763 | if (b) h -= scrollbarWidth; |
764 | yMax = myDoc->textHeight() - h; | 764 | yMax = myDoc->textHeight() - h; |
765 | if (yPos > 0 || yMax > 0) { | 765 | if (yPos > 0 || yMax > 0) { |
766 | w -= scrollbarWidth; | 766 | w -= scrollbarWidth; |
767 | xMax += scrollbarWidth; | 767 | xMax += scrollbarWidth; |
768 | if (!b && xMax > 0) { | 768 | if (!b && xMax > 0) { |
769 | h -= scrollbarWidth; | 769 | h -= scrollbarWidth; |
770 | yMax += scrollbarWidth; | 770 | yMax += scrollbarWidth; |
771 | } | 771 | } |
772 | } | 772 | } |
773 | 773 | ||
774 | if (!exposeCursor) break; | 774 | if (!exposeCursor) break; |
775 | // if (flags & KateView::ufNoScroll) break; | 775 | // if (flags & KateView::ufNoScroll) break; |
776 | /* | 776 | /* |
777 | if (flags & KateView::ufCenter) { | 777 | if (flags & KateView::ufCenter) { |
778 | cXPosMin = xPos + w/3; | 778 | cXPosMin = xPos + w/3; |
779 | cXPosMax = xPos + (w*2)/3; | 779 | cXPosMax = xPos + (w*2)/3; |
780 | cYPosMin = yPos + h/3; | 780 | cYPosMin = yPos + h/3; |
781 | cYPosMax = yPos + ((h - fontHeight)*2)/3; | 781 | cYPosMax = yPos + ((h - fontHeight)*2)/3; |
782 | } else {*/ | 782 | } else {*/ |
783 | cXPosMin = xPos + 4; | 783 | cXPosMin = xPos + 4; |
784 | cXPosMax = xPos + w - 8; | 784 | cXPosMax = xPos + w - 8; |
785 | cYPosMin = yPos; | 785 | cYPosMin = yPos; |
786 | cYPosMax = yPos + (h - fontHeight); | 786 | cYPosMax = yPos + (h - fontHeight); |
787 | // } | 787 | // } |
788 | 788 | ||
789 | if (cXPos < cXPosMin) { | 789 | if (cXPos < cXPosMin) { |
790 | xPos -= cXPosMin - cXPos; | 790 | xPos -= cXPosMin - cXPos; |
791 | } | 791 | } |
792 | if (xPos < 0) xPos = 0; | 792 | if (xPos < 0) xPos = 0; |
793 | if (cXPos > cXPosMax) { | 793 | if (cXPos > cXPosMax) { |
794 | xPos += cXPos - cXPosMax; | 794 | xPos += cXPos - cXPosMax; |
795 | } | 795 | } |
796 | if (cYPos < cYPosMin) { | 796 | if (cYPos < cYPosMin) { |
797 | yPos -= cYPosMin - cYPos; | 797 | yPos -= cYPosMin - cYPos; |
798 | } | 798 | } |
799 | if (yPos < 0) yPos = 0; | 799 | if (yPos < 0) yPos = 0; |
800 | if (cYPos > cYPosMax) { | 800 | if (cYPos > cYPosMax) { |
801 | yPos += cYPos - cYPosMax; | 801 | yPos += cYPos - cYPosMax; |
802 | } | 802 | } |
803 | 803 | ||
804 | z++; | 804 | z++; |
805 | } while (z < 2); | 805 | } while (z < 2); |
806 | 806 | ||
807 | if (xMax < xPos) xMax = xPos; | 807 | if (xMax < xPos) xMax = xPos; |
808 | if (yMax < yPos) yMax = yPos; | 808 | if (yMax < yPos) yMax = yPos; |
809 | 809 | ||
810 | if (xMax > 0) { | 810 | if (xMax > 0) { |
811 | pageScroll = w - (w % fontHeight) - fontHeight; | 811 | pageScroll = w - (w % fontHeight) - fontHeight; |
812 | if (pageScroll <= 0) | 812 | if (pageScroll <= 0) |
813 | pageScroll = fontHeight; | 813 | pageScroll = fontHeight; |
814 | 814 | ||
815 | xScroll->blockSignals(true); | 815 | xScroll->blockSignals(true); |
816 | xScroll->setGeometry(2,h + 2,w,scrollbarWidth); | 816 | xScroll->setGeometry(2,h + 2,w,scrollbarWidth); |
817 | xScroll->setRange(0,xMax); | 817 | xScroll->setRange(0,xMax); |
818 | xScroll->setValue(xPos); | 818 | xScroll->setValue(xPos); |
819 | xScroll->setSteps(fontHeight,pageScroll); | 819 | xScroll->setSteps(fontHeight,pageScroll); |
820 | xScroll->blockSignals(false); | 820 | xScroll->blockSignals(false); |
821 | xScroll->show(); | 821 | xScroll->show(); |
822 | } else xScroll->hide(); | 822 | } else xScroll->hide(); |
823 | 823 | ||
824 | if (yMax > 0) { | 824 | if (yMax > 0) { |
825 | pageScroll = h - (h % fontHeight) - fontHeight; | 825 | pageScroll = h - (h % fontHeight) - fontHeight; |
826 | if (pageScroll <= 0) | 826 | if (pageScroll <= 0) |
827 | pageScroll = fontHeight; | 827 | pageScroll = fontHeight; |
828 | 828 | ||
829 | yScroll->blockSignals(true); | 829 | yScroll->blockSignals(true); |
830 | yScroll->setGeometry(w + 2,2,scrollbarWidth,h); | 830 | yScroll->setGeometry(w + 2,2,scrollbarWidth,h); |
831 | yScroll->setRange(0,yMax); | 831 | yScroll->setRange(0,yMax); |
832 | yScroll->setValue(yPos); | 832 | yScroll->setValue(yPos); |
833 | yScroll->setSteps(fontHeight,pageScroll); | 833 | yScroll->setSteps(fontHeight,pageScroll); |
834 | yScroll->blockSignals(false); | 834 | yScroll->blockSignals(false); |
835 | yScroll->show(); | 835 | yScroll->show(); |
836 | } else yScroll->hide(); | 836 | } else yScroll->hide(); |
837 | 837 | ||
838 | if (w != width() || h != height()) { | 838 | if (w != width() || h != height()) { |
839 | clearDirtyCache(h); | 839 | clearDirtyCache(h); |
840 | resize(w,h); | 840 | resize(w,h); |
841 | } else { | 841 | } else { |
842 | dx = oldXPos - xPos; | 842 | dx = oldXPos - xPos; |
843 | dy = oldYPos - yPos; | 843 | dy = oldYPos - yPos; |
844 | 844 | ||
845 | b = updateState == 3; | 845 | b = updateState == 3; |
846 | if (flags & KateView::ufUpdateOnScroll) { | 846 | if (flags & KateView::ufUpdateOnScroll) { |
847 | b |= dx || dy; | 847 | b |= dx || dy; |
848 | } else { | 848 | } else { |
849 | b |= QABS(dx)*3 > w*2 || QABS(dy)*3 > h*2; | 849 | b |= QABS(dx)*3 > w*2 || QABS(dy)*3 > h*2; |
850 | } | 850 | } |
851 | 851 | ||
852 | if (b) { | 852 | if (b) { |
853 | clearDirtyCache(h); | 853 | clearDirtyCache(h); |
854 | update(); | 854 | update(); |
855 | } else { | 855 | } else { |
856 | if (dy) | 856 | if (dy) |
857 | leftBorder->scroll(0, dy); | 857 | leftBorder->scroll(0, dy); |
858 | if (updateState > 0) paintTextLines(oldXPos, oldYPos); | 858 | if (updateState > 0) paintTextLines(oldXPos, oldYPos); |
859 | clearDirtyCache(h); | 859 | clearDirtyCache(h); |
860 | 860 | ||
861 | if (dx || dy) { | 861 | if (dx || dy) { |
862 | scroll(dx,dy); | 862 | scroll(dx,dy); |
863 | // kapp->syncX(); | 863 | // kapp->syncX(); |
864 | // scroll2(dx - dx/2,dy - dy/2); | 864 | // scroll2(dx - dx/2,dy - dy/2); |
865 | // } else { | 865 | // } else { |
866 | } | 866 | } |
867 | if (cursorOn) paintCursor(); | 867 | if (cursorOn) paintCursor(); |
868 | if (bm.eXPos > bm.sXPos) paintBracketMark(); | 868 | if (bm.eXPos > bm.sXPos) paintBracketMark(); |
869 | } | 869 | } |
870 | } | 870 | } |
871 | exposeCursor = false; | 871 | exposeCursor = false; |
872 | // updateState = 0; | 872 | // updateState = 0; |
873 | } | 873 | } |
874 | 874 | ||
875 | 875 | ||
876 | void KateViewInternal::paintTextLines(int xPos, int yPos) { | 876 | void KateViewInternal::paintTextLines(int xPos, int yPos) { |
877 | // int xStart, xEnd; | 877 | // int xStart, xEnd; |
878 | int line;//, z; | 878 | int line;//, z; |
879 | int h; | 879 | int h; |
880 | LineRange *r; | 880 | LineRange *r; |
881 | 881 | ||
882 | if (!drawBuffer) return; | 882 | if (!drawBuffer) return; |
883 | if (drawBuffer->isNull()) return; | 883 | if (drawBuffer->isNull()) return; |
884 | 884 | ||
885 | QPainter paint; | 885 | QPainter paint; |
886 | paint.begin(drawBuffer); | 886 | paint.begin(drawBuffer); |
887 | 887 | ||
888 | h = myDoc->fontHeight; | 888 | h = myDoc->fontHeight; |
889 | r = lineRanges; | 889 | r = lineRanges; |
890 | for (line = startLine; line <= endLine; line++) { | 890 | for (line = startLine; line <= endLine; line++) { |
891 | if (r->start < r->end) { | 891 | if (r->start < r->end) { |
892 | //debug("painttextline %d %d %d", line, r->start, r->end); | 892 | //debug("painttextline %d %d %d", line, r->start, r->end); |
893 | myDoc->paintTextLine(paint, line, r->start, r->end, myView->configFlags & KateView::cfShowTabs); | 893 | myDoc->paintTextLine(paint, line, r->start, r->end, myView->configFlags & KateView::cfShowTabs); |
894 | bitBlt(this, r->start - (xPos-2), line*h - yPos, drawBuffer, 0, 0, | 894 | bitBlt(this, r->start - (xPos-2), line*h - yPos, drawBuffer, 0, 0, |
895 | r->end - r->start, h); | 895 | r->end - r->start, h); |
896 | leftBorder->paintLine(line); | 896 | leftBorder->paintLine(line); |
897 | } | 897 | } |
898 | r++; | 898 | r++; |
899 | } | 899 | } |
900 | 900 | ||
901 | paint.end(); | 901 | paint.end(); |
902 | } | 902 | } |
903 | 903 | ||
904 | void KateViewInternal::paintCursor() { | 904 | void KateViewInternal::paintCursor() { |
905 | int h, y, x; | 905 | int h, y, x; |
906 | static int cx = 0, cy = 0, ch = 0; | 906 | static int cx = 0, cy = 0, ch = 0; |
907 | 907 | ||
908 | h = myDoc->fontHeight; | 908 | h = myDoc->fontHeight; |
909 | y = h*cursor.y - yPos; | 909 | y = h*cursor.y - yPos; |
910 | x = cXPos - (xPos-2); | 910 | x = cXPos - (xPos-2); |
911 | 911 | ||
912 | if(myDoc->myFont != font()) setFont(myDoc->myFont); | 912 | if(myDoc->myFont != font()) setFont(myDoc->myFont); |
913 | if(cx != x || cy != y || ch != h){ | 913 | if(cx != x || cy != y || ch != h){ |
914 | cx = x; | 914 | cx = x; |
915 | cy = y; | 915 | cy = y; |
916 | ch = h; | 916 | ch = h; |
917 | setMicroFocusHint(cx, cy, 0, ch - 2); | 917 | setMicroFocusHint(cx, cy, 0, ch - 2); |
918 | } | 918 | } |
919 | 919 | ||
920 | QPainter paint; | 920 | QPainter paint; |
921 | if (cursorOn) { | 921 | if (cursorOn) { |
922 | paint.begin(this); | 922 | paint.begin(this); |
923 | paint.setClipping(false); | 923 | paint.setClipping(false); |
924 | paint.setPen(myDoc->cursorCol(cursor.x,cursor.y)); | 924 | paint.setPen(myDoc->cursorCol(cursor.x,cursor.y)); |
925 | 925 | ||
926 | h += y - 1; | 926 | h += y - 1; |
927 | paint.drawLine(x, y, x, h); | 927 | paint.drawLine(x, y, x, h); |
928 | 928 | ||
929 | paint.end(); | 929 | paint.end(); |
930 | } else { if (drawBuffer && !drawBuffer->isNull()) { | 930 | } else { if (drawBuffer && !drawBuffer->isNull()) { |
931 | paint.begin(drawBuffer); | 931 | paint.begin(drawBuffer); |
932 | myDoc->paintTextLine(paint, cursor.y, cXPos - 2, cXPos + 3, myView->configFlags & KateView::cfShowTabs); | 932 | myDoc->paintTextLine(paint, cursor.y, cXPos - 2, cXPos + 3, myView->configFlags & KateView::cfShowTabs); |
933 | bitBlt(this,x - 2,y, drawBuffer, 0, 0, 5, h); | 933 | bitBlt(this,x - 2,y, drawBuffer, 0, 0, 5, h); |
934 | paint.end(); } | 934 | paint.end(); } |
935 | } | 935 | } |
936 | 936 | ||
937 | } | 937 | } |
938 | 938 | ||
939 | void KateViewInternal::paintBracketMark() { | 939 | void KateViewInternal::paintBracketMark() { |
940 | int y; | 940 | int y; |
941 | 941 | ||
942 | y = myDoc->fontHeight*(bm.cursor.y +1) - yPos -1; | 942 | y = myDoc->fontHeight*(bm.cursor.y +1) - yPos -1; |
943 | 943 | ||
944 | QPainter paint; | 944 | QPainter paint; |
945 | paint.begin(this); | 945 | paint.begin(this); |
946 | paint.setPen(myDoc->cursorCol(bm.cursor.x, bm.cursor.y)); | 946 | paint.setPen(myDoc->cursorCol(bm.cursor.x, bm.cursor.y)); |
947 | 947 | ||
948 | paint.drawLine(bm.sXPos - (xPos-2), y, bm.eXPos - (xPos-2) -1, y); | 948 | paint.drawLine(bm.sXPos - (xPos-2), y, bm.eXPos - (xPos-2) -1, y); |
949 | paint.end(); | 949 | paint.end(); |
950 | } | 950 | } |
951 | 951 | ||
952 | void KateViewInternal::placeCursor(int x, int y, int flags) { | 952 | void KateViewInternal::placeCursor(int x, int y, int flags) { |
953 | VConfig c; | 953 | VConfig c; |
954 | 954 | ||
955 | getVConfig(c); | 955 | getVConfig(c); |
956 | c.flags |= flags; | 956 | c.flags |= flags; |
957 | cursor.y = (yPos + y)/myDoc->fontHeight; | 957 | cursor.y = (yPos + y)/myDoc->fontHeight; |
958 | cXPos = cOldXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor,xPos-2 + x); | 958 | cXPos = cOldXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor,xPos-2 + x); |
959 | changeState(c); | 959 | changeState(c); |
960 | } | 960 | } |
961 | 961 | ||
962 | // given physical coordinates, report whether the text there is selected | 962 | // given physical coordinates, report whether the text there is selected |
963 | bool KateViewInternal::isTargetSelected(int x, int y) { | 963 | bool KateViewInternal::isTargetSelected(int x, int y) { |
964 | 964 | ||
965 | y = (yPos + y) / myDoc->fontHeight; | 965 | y = (yPos + y) / myDoc->fontHeight; |
966 | 966 | ||
967 | TextLine::Ptr line = myDoc->getTextLine(y); | 967 | TextLine::Ptr line = myDoc->getTextLine(y); |
968 | if (!line) | 968 | if (!line) |
969 | return false; | 969 | return false; |
970 | 970 | ||
971 | x = myDoc->textPos(line, x); | 971 | x = myDoc->textPos(line, x); |
972 | 972 | ||
973 | return line->isSelected(x); | 973 | return line->isSelected(x); |
974 | } | 974 | } |
975 | 975 | ||
976 | void KateViewInternal::focusInEvent(QFocusEvent *) { | 976 | void KateViewInternal::focusInEvent(QFocusEvent *) { |
977 | // debug("got focus %d",cursorTimer); | 977 | // debug("got focus %d",cursorTimer); |
978 | 978 | ||
979 | if (!cursorTimer) { | 979 | if (!cursorTimer) { |
980 | cursorTimer = startTimer(KApplication::cursorFlashTime() / 2); | 980 | cursorTimer = startTimer(KApplication::cursorFlashTime() / 2); |
981 | cursorOn = true; | 981 | cursorOn = true; |
982 | paintCursor(); | 982 | paintCursor(); |
983 | } | 983 | } |
984 | } | 984 | } |
985 | 985 | ||
986 | void KateViewInternal::focusOutEvent(QFocusEvent *) { | 986 | void KateViewInternal::focusOutEvent(QFocusEvent *) { |
987 | // debug("lost focus %d", cursorTimer); | 987 | // debug("lost focus %d", cursorTimer); |
988 | 988 | ||
989 | if (cursorTimer) { | 989 | if (cursorTimer) { |
990 | killTimer(cursorTimer); | 990 | killTimer(cursorTimer); |
991 | cursorTimer = 0; | 991 | cursorTimer = 0; |
992 | } | 992 | } |
993 | 993 | ||
994 | if (cursorOn) { | 994 | if (cursorOn) { |
995 | cursorOn = false; | 995 | cursorOn = false; |
996 | paintCursor(); | 996 | paintCursor(); |
997 | } | 997 | } |
998 | } | 998 | } |
999 | 999 | ||
1000 | void KateViewInternal::keyPressEvent(QKeyEvent *e) { | 1000 | void KateViewInternal::keyPressEvent(QKeyEvent *e) { |
1001 | VConfig c; | 1001 | VConfig c; |
1002 | // int ascii; | 1002 | // int ascii; |
1003 | 1003 | ||
1004 | /* if (e->state() & AltButton) { | 1004 | /* if (e->state() & AltButton) { |
1005 | e->ignore(); | 1005 | e->ignore(); |
1006 | return; | 1006 | return; |
1007 | }*/ | 1007 | }*/ |
1008 | // debug("ascii %i, key %i, state %i",e->ascii(), e->key(), e->state()); | 1008 | // debug("ascii %i, key %i, state %i",e->ascii(), e->key(), e->state()); |
1009 | 1009 | ||
1010 | getVConfig(c); | 1010 | getVConfig(c); |
1011 | // ascii = e->ascii(); | 1011 | // ascii = e->ascii(); |
1012 | 1012 | ||
1013 | if (!myView->isReadOnly()) { | 1013 | if (!myView->isReadOnly()) { |
1014 | if (c.flags & KateView::cfTabIndents && myDoc->hasMarkedText()) { | 1014 | if (c.flags & KateView::cfTabIndents && myDoc->hasMarkedText()) { |
1015 | if (e->key() == Qt::Key_Tab) { | 1015 | if (e->key() == Qt::Key_Tab) { |
1016 | myDoc->indent(c); | 1016 | myDoc->indent(c); |
1017 | myDoc->updateViews(); | 1017 | myDoc->updateViews(); |
1018 | return; | 1018 | return; |
1019 | } | 1019 | } |
1020 | if (e->key() == Qt::Key_Backtab) { | 1020 | if (e->key() == Qt::Key_Backtab) { |
1021 | myDoc->unIndent(c); | 1021 | myDoc->unIndent(c); |
1022 | myDoc->updateViews(); | 1022 | myDoc->updateViews(); |
1023 | return; | 1023 | return; |
1024 | } | 1024 | } |
1025 | } | 1025 | } |
1026 | if ( !(e->state() & ControlButton ) && myDoc->insertChars(c, e->text())) { | 1026 | if ( !(e->state() & ControlButton ) && myDoc->insertChars(c, e->text())) { |
1027 | myDoc->updateViews(); | 1027 | myDoc->updateViews(); |
1028 | e->accept(); | 1028 | e->accept(); |
1029 | return; | 1029 | return; |
1030 | } | 1030 | } |
1031 | } | 1031 | } |
1032 | e->ignore(); | 1032 | e->ignore(); |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | void KateViewInternal::mousePressEvent(QMouseEvent *e) { | 1035 | void KateViewInternal::mousePressEvent(QMouseEvent *e) { |
1036 | 1036 | ||
1037 | if (e->button() == LeftButton) { | 1037 | if (e->button() == LeftButton) { |
1038 | 1038 | ||
1039 | int flags; | 1039 | int flags; |
1040 | 1040 | ||
1041 | flags = 0; | 1041 | flags = 0; |
1042 | if (e->state() & ShiftButton) { | 1042 | if (e->state() & ShiftButton) { |
1043 | flags |= KateView::cfMark; | 1043 | flags |= KateView::cfMark; |
1044 | if (e->state() & ControlButton) flags |= KateView::cfMark | KateView::cfKeepSelection; | 1044 | if (e->state() & ControlButton) flags |= KateView::cfMark | KateView::cfKeepSelection; |
1045 | } | 1045 | } |
1046 | placeCursor(e->x(), e->y(), flags); | 1046 | placeCursor(e->x(), e->y(), flags); |
1047 | scrollX = 0; | 1047 | scrollX = 0; |
1048 | scrollY = 0; | 1048 | scrollY = 0; |
1049 | if (!scrollTimer) scrollTimer = startTimer(50); | 1049 | if (!scrollTimer) scrollTimer = startTimer(50); |
1050 | myDoc->updateViews(); | 1050 | myDoc->updateViews(); |
1051 | } | 1051 | } |
1052 | if (e->button() == MidButton) { | 1052 | if (e->button() == MidButton) { |
1053 | placeCursor(e->x(), e->y()); | 1053 | placeCursor(e->x(), e->y()); |
1054 | if (! myView->isReadOnly()) | 1054 | if (! myView->isReadOnly()) |
1055 | myView->paste(); | 1055 | myView->paste(); |
1056 | } | 1056 | } |
1057 | if (myView->rmbMenu && e->button() == RightButton) { | 1057 | if (myView->rmbMenu && e->button() == RightButton) { |
1058 | myView->rmbMenu->popup(mapToGlobal(e->pos())); | 1058 | myView->rmbMenu->popup(mapToGlobal(e->pos())); |
1059 | } | 1059 | } |
1060 | myView->mousePressEvent(e); // this doesn't do anything, does it? | 1060 | myView->mousePressEvent(e); // this doesn't do anything, does it? |
1061 | // it does :-), we need this for KDevelop, so please don't uncomment it again -Sandy | 1061 | // it does :-), we need this for KDevelop, so please don't uncomment it again -Sandy |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | void KateViewInternal::mouseDoubleClickEvent(QMouseEvent *e) { | 1064 | void KateViewInternal::mouseDoubleClickEvent(QMouseEvent *e) { |
1065 | 1065 | ||
1066 | if (e->button() == LeftButton) { | 1066 | if (e->button() == LeftButton) { |
1067 | VConfig c; | 1067 | VConfig c; |
1068 | getVConfig(c); | 1068 | getVConfig(c); |
1069 | myDoc->selectWord(c.cursor, c.flags); | 1069 | myDoc->selectWord(c.cursor, c.flags); |
1070 | myDoc->updateViews(); | 1070 | myDoc->updateViews(); |
1071 | } | 1071 | } |
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | void KateViewInternal::mouseReleaseEvent(QMouseEvent *e) { | 1074 | void KateViewInternal::mouseReleaseEvent(QMouseEvent *e) { |
1075 | 1075 | ||
1076 | if (e->button() == LeftButton) { | 1076 | if (e->button() == LeftButton) { |
1077 | if (myView->config() & KateView::cfMouseAutoCopy) myView->copy(); | 1077 | if (myView->config() & KateView::cfMouseAutoCopy) myView->copy(); |
1078 | killTimer(scrollTimer); | 1078 | killTimer(scrollTimer); |
1079 | scrollTimer = 0; | 1079 | scrollTimer = 0; |
1080 | } | 1080 | } |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | void KateViewInternal::mouseMoveEvent(QMouseEvent *e) { | 1083 | void KateViewInternal::mouseMoveEvent(QMouseEvent *e) { |
1084 | 1084 | ||
1085 | if (e->state() & LeftButton) { | 1085 | if (e->state() & LeftButton) { |
1086 | int flags; | 1086 | int flags; |
1087 | int d; | 1087 | int d; |
1088 | int x = e->x(), | 1088 | int x = e->x(), |
1089 | y = e->y(); | 1089 | y = e->y(); |
1090 | 1090 | ||
1091 | mouseX = e->x(); | 1091 | mouseX = e->x(); |
1092 | mouseY = e->y(); | 1092 | mouseY = e->y(); |
1093 | scrollX = 0; | 1093 | scrollX = 0; |
1094 | scrollY = 0; | 1094 | scrollY = 0; |
1095 | d = myDoc->fontHeight; | 1095 | d = myDoc->fontHeight; |
1096 | if (mouseX < 0) { | 1096 | if (mouseX < 0) { |
1097 | mouseX = 0; | 1097 | mouseX = 0; |
1098 | scrollX = -d; | 1098 | scrollX = -d; |
1099 | } | 1099 | } |
1100 | if (mouseX > width()) { | 1100 | if (mouseX > width()) { |
1101 | mouseX = width(); | 1101 | mouseX = width(); |
1102 | scrollX = d; | 1102 | scrollX = d; |
1103 | } | 1103 | } |
1104 | if (mouseY < 0) { | 1104 | if (mouseY < 0) { |
1105 | mouseY = 0; | 1105 | mouseY = 0; |
1106 | scrollY = -d; | 1106 | scrollY = -d; |
1107 | } | 1107 | } |
1108 | if (mouseY > height()) { | 1108 | if (mouseY > height()) { |
1109 | mouseY = height(); | 1109 | mouseY = height(); |
1110 | scrollY = d; | 1110 | scrollY = d; |
1111 | } | 1111 | } |
1112 | //debug("modifiers %d", ((KGuiCmdApp *) kapp)->getModifiers()); | 1112 | //debug("modifiers %d", ((KGuiCmdApp *) kapp)->getModifiers()); |
1113 | flags = KateView::cfMark; | 1113 | flags = KateView::cfMark; |
1114 | if (e->state() & ControlButton) flags |= KateView::cfKeepSelection; | 1114 | if (e->state() & ControlButton) flags |= KateView::cfKeepSelection; |
1115 | placeCursor(mouseX, mouseY, flags); | 1115 | placeCursor(mouseX, mouseY, flags); |
1116 | myDoc->updateViews(/*ufNoScroll*/); | 1116 | myDoc->updateViews(/*ufNoScroll*/); |
1117 | } | 1117 | } |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | 1120 | ||
1121 | 1121 | ||
1122 | void KateViewInternal::wheelEvent( QWheelEvent *e ) | 1122 | void KateViewInternal::wheelEvent( QWheelEvent *e ) |
1123 | { | 1123 | { |
1124 | if( yScroll->isVisible() == true ) | 1124 | if( yScroll->isVisible() == true ) |
1125 | { | 1125 | { |
1126 | QApplication::sendEvent( yScroll, e ); | 1126 | QApplication::sendEvent( yScroll, e ); |
1127 | } | 1127 | } |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | 1130 | ||
1131 | 1131 | ||
1132 | void KateViewInternal::paintEvent(QPaintEvent *e) { | 1132 | void KateViewInternal::paintEvent(QPaintEvent *e) { |
1133 | int xStart, xEnd; | 1133 | int xStart, xEnd; |
1134 | int h; | 1134 | int h; |
1135 | int line, y, yEnd; | 1135 | int line, y, yEnd; |
1136 | 1136 | ||
1137 | QRect updateR = e->rect(); | 1137 | QRect updateR = e->rect(); |
1138 | 1138 | ||
1139 | if (!drawBuffer) return; | 1139 | if (!drawBuffer) return; |
1140 | if (drawBuffer->isNull()) return; | 1140 | if (drawBuffer->isNull()) return; |
1141 | 1141 | ||
1142 | QPainter paint; | 1142 | QPainter paint; |
1143 | paint.begin(drawBuffer); | 1143 | paint.begin(drawBuffer); |
1144 | 1144 | ||
1145 | xStart = xPos-2 + updateR.x(); | 1145 | xStart = xPos-2 + updateR.x(); |
1146 | xEnd = xStart + updateR.width(); | 1146 | xEnd = xStart + updateR.width(); |
1147 | 1147 | ||
1148 | h = myDoc->fontHeight; | 1148 | h = myDoc->fontHeight; |
1149 | line = (yPos + updateR.y()) / h; | 1149 | line = (yPos + updateR.y()) / h; |
1150 | y = line*h - yPos; | 1150 | y = line*h - yPos; |
1151 | yEnd = updateR.y() + updateR.height(); | 1151 | yEnd = updateR.y() + updateR.height(); |
1152 | waitForPreHighlight=myDoc->needPreHighlight(waitForPreHighlight=line+((long)(yEnd-y)/h)+5); | 1152 | waitForPreHighlight=myDoc->needPreHighlight(waitForPreHighlight=line+((long)(yEnd-y)/h)+5); |
1153 | 1153 | ||
1154 | while (y < yEnd) | 1154 | while (y < yEnd) |
1155 | { | 1155 | { |
1156 | TextLine *textLine; | 1156 | TextLine *textLine; |
1157 | int ctxNum = 0; | 1157 | int ctxNum = 0; |
1158 | myDoc->paintTextLine(paint, line, xStart, xEnd, myView->configFlags & KateView::cfShowTabs); | 1158 | myDoc->paintTextLine(paint, line, xStart, xEnd, myView->configFlags & KateView::cfShowTabs); |
1159 | bitBlt(this, updateR.x(), y, drawBuffer, 0, 0, updateR.width(), h); | 1159 | bitBlt(this, updateR.x(), y, drawBuffer, 0, 0, updateR.width(), h); |
1160 | leftBorder->paintLine(line); | 1160 | leftBorder->paintLine(line); |
1161 | line++; | 1161 | line++; |
1162 | y += h; | 1162 | y += h; |
1163 | } | 1163 | } |
1164 | paint.end(); | 1164 | paint.end(); |
1165 | 1165 | ||
1166 | if (cursorOn) paintCursor(); | 1166 | if (cursorOn) paintCursor(); |
1167 | if (bm.eXPos > bm.sXPos) paintBracketMark(); | 1167 | if (bm.eXPos > bm.sXPos) paintBracketMark(); |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | void KateViewInternal::resizeEvent(QResizeEvent *) | 1170 | void KateViewInternal::resizeEvent(QResizeEvent *) |
1171 | { | 1171 | { |
1172 | drawBuffer->resize (width(), myDoc->fontHeight); | 1172 | drawBuffer->resize (width(), myDoc->fontHeight); |
1173 | leftBorder->resize(iconBorderWidth, height()); | 1173 | leftBorder->resize(iconBorderWidth, height()); |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | void KateViewInternal::timerEvent(QTimerEvent *e) { | 1176 | void KateViewInternal::timerEvent(QTimerEvent *e) { |
1177 | if (e->timerId() == cursorTimer) { | 1177 | if (e->timerId() == cursorTimer) { |
1178 | cursorOn = !cursorOn; | 1178 | cursorOn = !cursorOn; |
1179 | paintCursor(); | 1179 | paintCursor(); |
1180 | } | 1180 | } |
1181 | if (e->timerId() == scrollTimer && (scrollX | scrollY)) { | 1181 | if (e->timerId() == scrollTimer && (scrollX | scrollY)) { |
1182 | xScroll->setValue(xPos + scrollX); | 1182 | xScroll->setValue(xPos + scrollX); |
1183 | yScroll->setValue(yPos + scrollY); | 1183 | yScroll->setValue(yPos + scrollY); |
1184 | 1184 | ||
1185 | placeCursor(mouseX, mouseY, KateView::cfMark); | 1185 | placeCursor(mouseX, mouseY, KateView::cfMark); |
1186 | myDoc->updateViews(/*ufNoScroll*/); | 1186 | myDoc->updateViews(/*ufNoScroll*/); |
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | uint KateView::uniqueID = 0; | 1190 | uint KateView::uniqueID = 0; |
1191 | 1191 | ||
1192 | KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate::View (doc, parent, name) | 1192 | KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate::View (doc, parent, name) |
1193 | { | 1193 | { |
1194 | 1194 | ||
1195 | myViewID = uniqueID; | 1195 | myViewID = uniqueID; |
1196 | uniqueID++; | 1196 | uniqueID++; |
1197 | 1197 | ||
1198 | active = false; | 1198 | active = false; |
1199 | myIconBorder = false; | 1199 | myIconBorder = false; |
1200 | 1200 | ||
1201 | myDoc = doc; | 1201 | myDoc = doc; |
1202 | myViewInternal = new KateViewInternal (this,doc); | 1202 | myViewInternal = new KateViewInternal (this,doc); |
1203 | myViewInternal->move(2, 2); | 1203 | myViewInternal->move(2, 2); |
1204 | myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal); | 1204 | myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal); |
1205 | myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight); | 1205 | myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight); |
1206 | myViewInternal->leftBorder->hide(); | 1206 | myViewInternal->leftBorder->hide(); |
1207 | 1207 | ||
1208 | doc->addView( this ); | 1208 | doc->addView( this ); |
1209 | 1209 | ||
1210 | 1210 | ||
1211 | // some defaults | 1211 | // some defaults |
1212 | configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents | 1212 | configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents |
1213 | | KateView::cfTabIndents | KateView::cfKeepIndentProfile | 1213 | | KateView::cfTabIndents | KateView::cfKeepIndentProfile |
1214 | | KateView::cfRemoveSpaces | 1214 | | KateView::cfRemoveSpaces |
1215 | | KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor | 1215 | | KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor |
1216 | | KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome; | 1216 | | KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome; |
1217 | 1217 | ||
1218 | searchFlags = 0; | 1218 | searchFlags = 0; |
1219 | replacePrompt = 0L; | 1219 | replacePrompt = 0L; |
1220 | rmbMenu = 0L; | 1220 | rmbMenu = 0L; |
1221 | 1221 | ||
1222 | 1222 | ||
1223 | setFocusProxy( myViewInternal ); | 1223 | setFocusProxy( myViewInternal ); |
1224 | myViewInternal->setFocus(); | 1224 | myViewInternal->setFocus(); |
1225 | resize(parent->width() -4, parent->height() -4); | 1225 | resize(parent->width() -4, parent->height() -4); |
1226 | 1226 | ||
1227 | 1227 | ||
1228 | myViewInternal->installEventFilter( this ); | 1228 | myViewInternal->installEventFilter( this ); |
1229 | 1229 | ||
1230 | //setupActions(); | 1230 | //setupActions(); |
1231 | 1231 | ||
1232 | connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) ); | 1232 | connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) ); |
1233 | connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) ); | 1233 | connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) ); |
1234 | connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) ); | 1234 | connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) ); |
1235 | connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) ); | 1235 | connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) ); |
1236 | 1236 | ||
1237 | readConfig(); | 1237 | readConfig(); |
1238 | // setHighlight->setCurrentItem(getHl()); | 1238 | // setHighlight->setCurrentItem(getHl()); |
1239 | slotUpdate(); | 1239 | slotUpdate(); |
1240 | } | 1240 | } |
1241 | 1241 | ||
1242 | KateView::~KateView() | 1242 | KateView::~KateView() |
1243 | { | 1243 | { |
1244 | writeConfig(); | 1244 | writeConfig(); |
1245 | 1245 | ||
1246 | if (myDoc && !myDoc->m_bSingleViewMode) | 1246 | if (myDoc && !myDoc->m_bSingleViewMode) |
1247 | myDoc->removeView( this ); | 1247 | myDoc->removeView( this ); |
1248 | 1248 | ||
1249 | delete myViewInternal; | 1249 | delete myViewInternal; |
1250 | } | 1250 | } |
1251 | 1251 | ||
1252 | #if 0 | 1252 | #if 0 |
1253 | void KateView::setupActions() | 1253 | void KateView::setupActions() |
1254 | { | 1254 | { |
1255 | #if 0 | 1255 | #if 0 |
1256 | KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" ); | 1256 | KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" ); |
1257 | 1257 | ||
1258 | KStdAction::save(this, SLOT(save()), actionCollection()); | 1258 | KStdAction::save(this, SLOT(save()), actionCollection()); |
1259 | 1259 | ||
1260 | // setup edit menu | 1260 | // setup edit menu |
1261 | editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection()); | 1261 | editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection()); |
1262 | editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection()); | 1262 | editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection()); |
1263 | editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()), | 1263 | editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()), |
1264 | actionCollection(), "edit_undoHistory"); | 1264 | actionCollection(), "edit_undoHistory"); |
1265 | KStdAction::cut(this, SLOT(cut()), actionCollection()); | 1265 | KStdAction::cut(this, SLOT(cut()), actionCollection()); |
1266 | KStdAction::copy(this, SLOT(copy()), actionCollection()); | 1266 | KStdAction::copy(this, SLOT(copy()), actionCollection()); |
1267 | KStdAction::paste(this, SLOT(paste()), actionCollection()); | 1267 | KStdAction::paste(this, SLOT(paste()), actionCollection()); |
1268 | 1268 | ||
1269 | if ( myDoc->hasBrowserExtension() ) | 1269 | if ( myDoc->hasBrowserExtension() ) |
1270 | { | 1270 | { |
1271 | KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection()); | 1271 | KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection()); |
1272 | KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find"); | 1272 | KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find"); |
1273 | KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again"); | 1273 | KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again"); |
1274 | KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev"); | 1274 | KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev"); |
1275 | KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" ); | 1275 | KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" ); |
1276 | new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg"); | 1276 | new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg"); |
1277 | setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight"); | 1277 | setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight"); |
1278 | KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all"); | 1278 | KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all"); |
1279 | new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), | 1279 | new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), |
1280 | myDoc->actionCollection(), "unselect_all"); | 1280 | myDoc->actionCollection(), "unselect_all"); |
1281 | new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), | 1281 | new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), |
1282 | myDoc->actionCollection(), "invert_select"); | 1282 | myDoc->actionCollection(), "invert_select"); |
1283 | 1283 | ||
1284 | new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), | 1284 | new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), |
1285 | myDoc->actionCollection(), "incFontSizes"); | 1285 | myDoc->actionCollection(), "incFontSizes"); |
1286 | new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), | 1286 | new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), |
1287 | myDoc->actionCollection(), "decFontSizes"); | 1287 | myDoc->actionCollection(), "decFontSizes"); |
1288 | } | 1288 | } |
1289 | else | 1289 | else |
1290 | { | 1290 | { |
1291 | KStdAction::saveAs(this, SLOT(saveAs()), actionCollection()); | 1291 | KStdAction::saveAs(this, SLOT(saveAs()), actionCollection()); |
1292 | KStdAction::find(this, SLOT(find()), actionCollection()); | 1292 | KStdAction::find(this, SLOT(find()), actionCollection()); |
1293 | KStdAction::findNext(this, SLOT(findAgain()), actionCollection()); | 1293 | KStdAction::findNext(this, SLOT(findAgain()), actionCollection()); |
1294 | KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev"); | 1294 | KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev"); |
1295 | KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection()); | 1295 | KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection()); |
1296 | new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg"); | 1296 | new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg"); |
1297 | setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight"); | 1297 | setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight"); |
1298 | KStdAction::selectAll(this, SLOT(selectAll()), actionCollection()); | 1298 | KStdAction::selectAll(this, SLOT(selectAll()), actionCollection()); |
1299 | new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), | 1299 | new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), |
1300 | actionCollection(), "edit_deselectAll"); | 1300 | actionCollection(), "edit_deselectAll"); |
1301 | new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), | 1301 | new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), |
1302 | actionCollection(), "edit_invertSelection"); | 1302 | actionCollection(), "edit_invertSelection"); |
1303 | 1303 | ||
1304 | new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), | 1304 | new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), |
1305 | actionCollection(), "incFontSizes"); | 1305 | actionCollection(), "incFontSizes"); |
1306 | new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), | 1306 | new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), |
1307 | actionCollection(), "decFontSizes"); | 1307 | actionCollection(), "decFontSizes"); |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | new KAction(i18n("Apply Word Wrap"), 0, myDoc, SLOT(applyWordWrap()), actionCollection(), "edit_apply_wordwrap"); | 1310 | new KAction(i18n("Apply Word Wrap"), 0, myDoc, SLOT(applyWordWrap()), actionCollection(), "edit_apply_wordwrap"); |
1311 | 1311 | ||
1312 | KStdAction::replace(this, SLOT(replace()), actionCollection()); | 1312 | KStdAction::replace(this, SLOT(replace()), actionCollection()); |
1313 | 1313 | ||
1314 | new KAction(i18n("Editing Co&mmand"), Qt::CTRL+Qt::Key_M, this, SLOT(slotEditCommand()), | 1314 | new KAction(i18n("Editing Co&mmand"), Qt::CTRL+Qt::Key_M, this, SLOT(slotEditCommand()), |
1315 | actionCollection(), "edit_cmd"); | 1315 | actionCollection(), "edit_cmd"); |
1316 | 1316 | ||
1317 | // setup bookmark menu | 1317 | // setup bookmark menu |
1318 | bookmarkToggle = new KAction(i18n("Toggle &Bookmark"), Qt::CTRL+Qt::Key_B, this, SLOT(toggleBookmark()), actionCollection(), "edit_bookmarkToggle"); | 1318 | bookmarkToggle = new KAction(i18n("Toggle &Bookmark"), Qt::CTRL+Qt::Key_B, this, SLOT(toggleBookmark()), actionCollection(), "edit_bookmarkToggle"); |
1319 | bookmarkClear = new KAction(i18n("Clear Bookmarks"), 0, this, SLOT(clearBookmarks()), actionCollection(), "edit_bookmarksClear"); | 1319 | bookmarkClear = new KAction(i18n("Clear Bookmarks"), 0, this, SLOT(clearBookmarks()), actionCollection(), "edit_bookmarksClear"); |
1320 | 1320 | ||
1321 | // connect settings menu aboutToshow | 1321 | // connect settings menu aboutToshow |
1322 | bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(), "bookmarks"); | 1322 | bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(), "bookmarks"); |
1323 | connect(bookmarkMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow())); | 1323 | connect(bookmarkMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow())); |
1324 | 1324 | ||
1325 | new KToggleAction(i18n("Show &IconBorder"), Key_F6, this, SLOT(toggleIconBorder()), actionCollection(), "view_border"); | 1325 | new KToggleAction(i18n("Show &IconBorder"), Key_F6, this, SLOT(toggleIconBorder()), actionCollection(), "view_border"); |
1326 | 1326 | ||
1327 | // setup Tools menu | 1327 | // setup Tools menu |
1328 | KStdAction::spelling(this, SLOT(spellcheck()), actionCollection()); | 1328 | KStdAction::spelling(this, SLOT(spellcheck()), actionCollection()); |
1329 | new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()), | 1329 | new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()), |
1330 | actionCollection(), "tools_indent"); | 1330 | actionCollection(), "tools_indent"); |
1331 | new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::Key_U, this, SLOT(unIndent()), | 1331 | new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::Key_U, this, SLOT(unIndent()), |
1332 | actionCollection(), "tools_unindent"); | 1332 | actionCollection(), "tools_unindent"); |
1333 | new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()), | 1333 | new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()), |
1334 | actionCollection(), "tools_cleanIndent"); | 1334 | actionCollection(), "tools_cleanIndent"); |
1335 | new KAction(i18n("C&omment"), CTRL+Qt::Key_NumberSign, this, SLOT(comment()), | 1335 | new KAction(i18n("C&omment"), CTRL+Qt::Key_NumberSign, this, SLOT(comment()), |
1336 | actionCollection(), "tools_comment"); | 1336 | actionCollection(), "tools_comment"); |
1337 | new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_NumberSign, this, SLOT(uncomment()), | 1337 | new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_NumberSign, this, SLOT(uncomment()), |
1338 | actionCollection(), "tools_uncomment"); | 1338 | actionCollection(), "tools_uncomment"); |
1339 | 1339 | ||
1340 | setVerticalSelection = new KToggleAction(i18n("&Vertical Selection"), Key_F4, this, SLOT(toggleVertical()), | 1340 | setVerticalSelection = new KToggleAction(i18n("&Vertical Selection"), Key_F4, this, SLOT(toggleVertical()), |
1341 | actionCollection(), "set_verticalSelect"); | 1341 | actionCollection(), "set_verticalSelect"); |
1342 | 1342 | ||
1343 | connect(setHighlight, SIGNAL(activated(int)), this, SLOT(setHl(int))); | 1343 | connect(setHighlight, SIGNAL(activated(int)), this, SLOT(setHl(int))); |
1344 | QStringList list; | 1344 | QStringList list; |
1345 | for (int z = 0; z < HlManager::self()->highlights(); z++) | 1345 | for (int z = 0; z < HlManager::self()->highlights(); z++) |
1346 | list.append(HlManager::self()->hlName(z)); | 1346 | list.append(HlManager::self()->hlName(z)); |
1347 | setHighlight->setItems(list); | 1347 | setHighlight->setItems(list); |
1348 | 1348 | ||
1349 | setEndOfLine = new KSelectAction(i18n("&End Of Line"), 0, actionCollection(), "set_eol"); | 1349 | setEndOfLine = new KSelectAction(i18n("&End Of Line"), 0, actionCollection(), "set_eol"); |
1350 | connect(setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int))); | 1350 | connect(setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int))); |
1351 | list.clear(); | 1351 | list.clear(); |
1352 | list.append("&Unix"); | 1352 | list.append("&Unix"); |
1353 | list.append("&Windows/Dos"); | 1353 | list.append("&Windows/Dos"); |
1354 | list.append("&Macintosh"); | 1354 | list.append("&Macintosh"); |
1355 | setEndOfLine->setItems(list); | 1355 | setEndOfLine->setItems(list); |
1356 | #endif | 1356 | #endif |
1357 | } | 1357 | } |
1358 | #endif | 1358 | #endif |
1359 | 1359 | ||
1360 | void KateView::slotUpdate() | 1360 | void KateView::slotUpdate() |
1361 | { | 1361 | { |
1362 | int cfg = config(); | 1362 | int cfg = config(); |
1363 | 1363 | ||
1364 | #warning fixme setVerticalSelection->setChecked(cfg & KateView::cfVerticalSelect); | 1364 | #warning fixme setVerticalSelection->setChecked(cfg & KateView::cfVerticalSelect); |
1365 | 1365 | ||
1366 | slotNewUndo(); | 1366 | slotNewUndo(); |
1367 | } | 1367 | } |
1368 | void KateView::slotFileStatusChanged() | 1368 | void KateView::slotFileStatusChanged() |
1369 | { | 1369 | { |
1370 | int eol = getEol(); | 1370 | int eol = getEol(); |
1371 | eol = eol>=1 ? eol : 0; | 1371 | eol = eol>=1 ? eol : 0; |
1372 | 1372 | ||
1373 | #warning fixme setEndOfLine->setCurrentItem(eol); | 1373 | #warning fixme setEndOfLine->setCurrentItem(eol); |
1374 | } | 1374 | } |
1375 | void KateView::slotNewUndo() | 1375 | void KateView::slotNewUndo() |
1376 | { | 1376 | { |
1377 | #if 0 | 1377 | #if 0 |
1378 | int state = undoState(); | 1378 | int state = undoState(); |
1379 | 1379 | ||
1380 | editUndoHist->setEnabled(state & 1 || state & 2); | 1380 | editUndoHist->setEnabled(state & 1 || state & 2); |
1381 | 1381 | ||
1382 | QString t = i18n("Und&o"); // it would be nicer to fetch the original string | 1382 | QString t = i18n("Und&o"); // it would be nicer to fetch the original string |
1383 | if (state & 1) { | 1383 | if (state & 1) { |
1384 | editUndo->setEnabled(true); | 1384 | editUndo->setEnabled(true); |
1385 | t += ' '; | 1385 | t += ' '; |
1386 | t += i18n(undoTypeName(nextUndoType())); | 1386 | t += i18n(undoTypeName(nextUndoType())); |
1387 | } else { | 1387 | } else { |
1388 | editUndo->setEnabled(false); | 1388 | editUndo->setEnabled(false); |
1389 | } | 1389 | } |
1390 | editUndo->setText(t); | 1390 | editUndo->setText(t); |
1391 | 1391 | ||
1392 | t = i18n("Re&do"); // it would be nicer to fetch the original string | 1392 | t = i18n("Re&do"); // it would be nicer to fetch the original string |
1393 | if (state & 2) { | 1393 | if (state & 2) { |
1394 | editRedo->setEnabled(true); | 1394 | editRedo->setEnabled(true); |
1395 | t += ' '; | 1395 | t += ' '; |
1396 | t += i18n(undoTypeName(nextRedoType())); | 1396 | t += i18n(undoTypeName(nextRedoType())); |
1397 | } else { | 1397 | } else { |
1398 | editRedo->setEnabled(false); | 1398 | editRedo->setEnabled(false); |
1399 | } | 1399 | } |
1400 | editRedo->setText(t); | 1400 | editRedo->setText(t); |
1401 | #endif | 1401 | #endif |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | void KateView::slotHighlightChanged() | 1404 | void KateView::slotHighlightChanged() |
1405 | { | 1405 | { |
1406 | // setHighlight->setCurrentItem(getHl()); | 1406 | // setHighlight->setCurrentItem(getHl()); |
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | 1409 | ||
1410 | void KateView::keyPressEvent( QKeyEvent *ev ) | 1410 | void KateView::keyPressEvent( QKeyEvent *ev ) |
1411 | { | 1411 | { |
1412 | switch ( ev->key() ) | 1412 | switch ( ev->key() ) |
1413 | { | 1413 | { |
1414 | case Key_Left: | 1414 | case Key_Left: |
1415 | if ( ev->state() & ShiftButton ) | 1415 | if ( ev->state() & ShiftButton ) |
1416 | { | 1416 | { |
1417 | if ( ev->state() & ControlButton ) | 1417 | if ( ev->state() & ControlButton ) |
1418 | shiftWordLeft(); | 1418 | shiftWordLeft(); |
1419 | else | 1419 | else |
1420 | shiftCursorLeft(); | 1420 | shiftCursorLeft(); |
1421 | } | 1421 | } |
1422 | else if ( ev->state() & ControlButton ) | 1422 | else if ( ev->state() & ControlButton ) |
1423 | wordLeft(); | 1423 | wordLeft(); |
1424 | else | 1424 | else |
1425 | cursorLeft(); | 1425 | cursorLeft(); |
1426 | break; | 1426 | break; |
1427 | case Key_Right: | 1427 | case Key_Right: |
1428 | if ( ev->state() & ShiftButton ) | 1428 | if ( ev->state() & ShiftButton ) |
1429 | { | 1429 | { |
1430 | if ( ev->state() & ControlButton ) | 1430 | if ( ev->state() & ControlButton ) |
1431 | shiftWordRight(); | 1431 | shiftWordRight(); |
1432 | else | 1432 | else |
1433 | shiftCursorRight(); | 1433 | shiftCursorRight(); |
1434 | } | 1434 | } |
1435 | else if ( ev->state() & ControlButton ) | 1435 | else if ( ev->state() & ControlButton ) |
1436 | wordRight(); | 1436 | wordRight(); |
1437 | else | 1437 | else |
1438 | cursorRight(); | 1438 | cursorRight(); |
1439 | break; | 1439 | break; |
1440 | case Key_Home: | 1440 | case Key_Home: |
1441 | if ( ev->state() & ShiftButton ) | 1441 | if ( ev->state() & ShiftButton ) |
1442 | { | 1442 | { |
1443 | if ( ev->state() & ControlButton ) | 1443 | if ( ev->state() & ControlButton ) |
1444 | shiftTop(); | 1444 | shiftTop(); |
1445 | else | 1445 | else |
1446 | shiftHome(); | 1446 | shiftHome(); |
1447 | } | 1447 | } |
1448 | else if ( ev->state() & ControlButton ) | 1448 | else if ( ev->state() & ControlButton ) |
1449 | top(); | 1449 | top(); |
1450 | else | 1450 | else |
1451 | home(); | 1451 | home(); |
1452 | break; | 1452 | break; |
1453 | case Key_End: | 1453 | case Key_End: |
1454 | if ( ev->state() & ShiftButton ) | 1454 | if ( ev->state() & ShiftButton ) |
1455 | { | 1455 | { |
1456 | if ( ev->state() & ControlButton ) | 1456 | if ( ev->state() & ControlButton ) |
1457 | shiftBottom(); | 1457 | shiftBottom(); |
1458 | else | 1458 | else |
1459 | shiftEnd(); | 1459 | shiftEnd(); |
1460 | } | 1460 | } |
1461 | else if ( ev->state() & ControlButton ) | 1461 | else if ( ev->state() & ControlButton ) |
1462 | bottom(); | 1462 | bottom(); |
1463 | else | 1463 | else |
1464 | end(); | 1464 | end(); |
1465 | break; | 1465 | break; |
1466 | case Key_Up: | 1466 | case Key_Up: |
1467 | if ( ev->state() & ShiftButton ) | 1467 | if ( ev->state() & ShiftButton ) |
1468 | shiftUp(); | 1468 | shiftUp(); |
1469 | else if ( ev->state() & ControlButton ) | 1469 | else if ( ev->state() & ControlButton ) |
1470 | scrollUp(); | 1470 | scrollUp(); |
1471 | else | 1471 | else |
1472 | up(); | 1472 | up(); |
1473 | break; | 1473 | break; |
1474 | case Key_Down: | 1474 | case Key_Down: |
1475 | if ( ev->state() & ShiftButton ) | 1475 | if ( ev->state() & ShiftButton ) |
1476 | shiftDown(); | 1476 | shiftDown(); |
1477 | else if ( ev->state() & ControlButton ) | 1477 | else if ( ev->state() & ControlButton ) |
1478 | scrollDown(); | 1478 | scrollDown(); |
1479 | else | 1479 | else |
1480 | down(); | 1480 | down(); |
1481 | break; | 1481 | break; |
1482 | case Key_PageUp: | 1482 | case Key_PageUp: |
1483 | if ( ev->state() & ShiftButton ) | 1483 | if ( ev->state() & ShiftButton ) |
1484 | shiftPageUp(); | 1484 | shiftPageUp(); |
1485 | else if ( ev->state() & ControlButton ) | 1485 | else if ( ev->state() & ControlButton ) |
1486 | topOfView(); | 1486 | topOfView(); |
1487 | else | 1487 | else |
1488 | pageUp(); | 1488 | pageUp(); |
1489 | break; | 1489 | break; |
1490 | case Key_PageDown: | 1490 | case Key_PageDown: |
1491 | if ( ev->state() & ShiftButton ) | 1491 | if ( ev->state() & ShiftButton ) |
1492 | shiftPageDown(); | 1492 | shiftPageDown(); |
1493 | else if ( ev->state() & ControlButton ) | 1493 | else if ( ev->state() & ControlButton ) |
1494 | bottomOfView(); | 1494 | bottomOfView(); |
1495 | else | 1495 | else |
1496 | pageDown(); | 1496 | pageDown(); |
1497 | break; | 1497 | break; |
1498 | case Key_Return: | 1498 | case Key_Return: |
1499 | case Key_Enter: | 1499 | case Key_Enter: |
1500 | keyReturn(); | 1500 | keyReturn(); |
1501 | break; | 1501 | break; |
1502 | case Key_Delete: | 1502 | case Key_Delete: |
1503 | if ( ev->state() & ControlButton ) | 1503 | if ( ev->state() & ControlButton ) |
1504 | { | 1504 | { |
1505 | VConfig c; | 1505 | VConfig c; |
1506 | shiftWordRight(); | 1506 | shiftWordRight(); |
1507 | myViewInternal->getVConfig(c); | 1507 | myViewInternal->getVConfig(c); |
1508 | myDoc->delMarkedText(c); | 1508 | myDoc->delMarkedText(c); |
1509 | myViewInternal->update(); | 1509 | myViewInternal->update(); |
1510 | } | 1510 | } |
1511 | else keyDelete(); | 1511 | else keyDelete(); |
1512 | break; | 1512 | break; |
1513 | case Key_Backspace: | 1513 | case Key_Backspace: |
1514 | if ( ev->state() & ControlButton ) | 1514 | if ( ev->state() & ControlButton ) |
1515 | { | 1515 | { |
1516 | VConfig c; | 1516 | VConfig c; |
1517 | shiftWordLeft(); | 1517 | shiftWordLeft(); |
1518 | myViewInternal->getVConfig(c); | 1518 | myViewInternal->getVConfig(c); |
1519 | myDoc->delMarkedText(c); | 1519 | myDoc->delMarkedText(c); |
1520 | myViewInternal->update(); | 1520 | myViewInternal->update(); |
1521 | } | 1521 | } |
1522 | else backspace(); | 1522 | else backspace(); |
1523 | break; | 1523 | break; |
1524 | case Key_Insert: | 1524 | case Key_Insert: |
1525 | toggleInsert(); | 1525 | toggleInsert(); |
1526 | break; | 1526 | break; |
1527 | case Key_K: | 1527 | case Key_K: |
1528 | if ( ev->state() & ControlButton ) | 1528 | if ( ev->state() & ControlButton ) |
1529 | { | 1529 | { |
1530 | killLine(); | 1530 | killLine(); |
1531 | break; | 1531 | break; |
1532 | } | 1532 | } |
1533 | default: | 1533 | default: |
1534 | KTextEditor::View::keyPressEvent( ev ); | 1534 | KTextEditor::View::keyPressEvent( ev ); |
1535 | return; | 1535 | return; |
1536 | break; | 1536 | break; |
1537 | } | 1537 | } |
1538 | ev->accept(); | 1538 | ev->accept(); |
1539 | } | 1539 | } |
1540 | 1540 | ||
1541 | 1541 | ||
1542 | void KateView::setCursorPosition( int line, int col, bool /*mark*/ ) | 1542 | void KateView::setCursorPosition( int line, int col, bool /*mark*/ ) |
1543 | { | 1543 | { |
1544 | setCursorPositionInternal( line, col ); | 1544 | setCursorPositionInternal( line, col ); |
1545 | } | 1545 | } |
1546 | 1546 | ||
1547 | void KateView::getCursorPosition( int *line, int *col ) | 1547 | void KateView::getCursorPosition( int *line, int *col ) |
1548 | { | 1548 | { |
1549 | if ( line ) | 1549 | if ( line ) |
1550 | *line = currentLine(); | 1550 | *line = currentLine(); |
1551 | 1551 | ||
1552 | if ( col ) | 1552 | if ( col ) |
1553 | *col = currentColumn(); | 1553 | *col = currentColumn(); |
1554 | } | 1554 | } |
1555 | 1555 | ||
1556 | 1556 | ||
1557 | int KateView::currentLine() { | 1557 | int KateView::currentLine() { |
1558 | return myViewInternal->cursor.y; | 1558 | return myViewInternal->cursor.y; |
1559 | } | 1559 | } |
1560 | 1560 | ||
1561 | int KateView::currentColumn() { | 1561 | int KateView::currentColumn() { |
1562 | return myDoc->currentColumn(myViewInternal->cursor); | 1562 | return myDoc->currentColumn(myViewInternal->cursor); |
1563 | } | 1563 | } |
1564 | 1564 | ||
1565 | int KateView::currentCharNum() { | 1565 | int KateView::currentCharNum() { |
1566 | return myViewInternal->cursor.x; | 1566 | return myViewInternal->cursor.x; |
1567 | } | 1567 | } |
1568 | 1568 | ||
1569 | void KateView::setCursorPositionInternal(int line, int col) { | 1569 | void KateView::setCursorPositionInternal(int line, int col) { |
1570 | PointStruc cursor; | 1570 | PointStruc cursor; |
1571 | 1571 | ||
1572 | cursor.x = col; | 1572 | cursor.x = col; |
1573 | cursor.y = line; | 1573 | cursor.y = line; |
1574 | myViewInternal->updateCursor(cursor); | 1574 | myViewInternal->updateCursor(cursor); |
1575 | myViewInternal->center(); | 1575 | myViewInternal->center(); |
1576 | // myViewInternal->updateView(ufPos, 0, line*myDoc->fontHeight - height()/2); | 1576 | // myViewInternal->updateView(ufPos, 0, line*myDoc->fontHeight - height()/2); |
1577 | // myDoc->updateViews(myViewInternal); //uptade all other views except this one | 1577 | // myDoc->updateViews(myViewInternal); //uptade all other views except this one |
1578 | myDoc->updateViews(); | 1578 | myDoc->updateViews(); |
1579 | } | 1579 | } |
1580 | 1580 | ||
1581 | int KateView::config() { | 1581 | int KateView::config() { |
1582 | int flags; | 1582 | int flags; |
1583 | 1583 | ||
1584 | flags = configFlags; | 1584 | flags = configFlags; |
1585 | if (myDoc->singleSelection()) flags |= KateView::cfSingleSelection; | 1585 | if (myDoc->singleSelection()) flags |= KateView::cfSingleSelection; |
1586 | return flags; | 1586 | return flags; |
1587 | } | 1587 | } |
1588 | 1588 | ||
1589 | void KateView::setConfig(int flags) { | 1589 | void KateView::setConfig(int flags) { |
1590 | bool updateView; | 1590 | bool updateView; |
1591 | 1591 | ||
1592 | // cfSingleSelection is a doc-property | 1592 | // cfSingleSelection is a doc-property |
1593 | myDoc->setSingleSelection(flags & KateView::cfSingleSelection); | 1593 | myDoc->setSingleSelection(flags & KateView::cfSingleSelection); |
1594 | flags &= ~KateView::cfSingleSelection; | 1594 | flags &= ~KateView::cfSingleSelection; |
1595 | 1595 | ||
1596 | if (flags != configFlags) { | 1596 | if (flags != configFlags) { |
1597 | // update the view if visibility of tabs has changed | 1597 | // update the view if visibility of tabs has changed |
1598 | updateView = (flags ^ configFlags) & KateView::cfShowTabs; | 1598 | updateView = (flags ^ configFlags) & KateView::cfShowTabs; |
1599 | configFlags = flags; | 1599 | configFlags = flags; |
1600 | emit newStatus(); | 1600 | emit newStatus(); |
1601 | if (updateView) myViewInternal->update(); | 1601 | if (updateView) myViewInternal->update(); |
1602 | } | 1602 | } |
1603 | } | 1603 | } |
1604 | 1604 | ||
1605 | int KateView::tabWidth() { | 1605 | int KateView::tabWidth() { |
1606 | return myDoc->tabChars; | 1606 | return myDoc->tabChars; |
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | void KateView::setTabWidth(int w) { | 1609 | void KateView::setTabWidth(int w) { |
1610 | myDoc->setTabWidth(w); | 1610 | myDoc->setTabWidth(w); |
1611 | myDoc->updateViews(); | 1611 | myDoc->updateViews(); |
1612 | } | 1612 | } |
1613 | 1613 | ||
1614 | void KateView::setEncoding (QString e) { | 1614 | void KateView::setEncoding (QString e) { |
1615 | myDoc->setEncoding (e); | 1615 | myDoc->setEncoding (e); |
1616 | myDoc->updateViews(); | 1616 | myDoc->updateViews(); |
1617 | } | 1617 | } |
1618 | 1618 | ||
1619 | int KateView::undoSteps() { | 1619 | int KateView::undoSteps() { |
1620 | return myDoc->undoSteps; | 1620 | return myDoc->undoSteps; |
1621 | } | 1621 | } |
1622 | 1622 | ||
1623 | void KateView::setUndoSteps(int s) { | 1623 | void KateView::setUndoSteps(int s) { |
1624 | myDoc->setUndoSteps(s); | 1624 | myDoc->setUndoSteps(s); |
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | bool KateView::isReadOnly() { | 1627 | bool KateView::isReadOnly() { |
1628 | return myDoc->readOnly; | 1628 | return myDoc->readOnly; |
1629 | } | 1629 | } |
1630 | 1630 | ||
1631 | bool KateView::isModified() { | 1631 | bool KateView::isModified() { |
1632 | return myDoc->modified; | 1632 | return myDoc->modified; |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | void KateView::setReadOnly(bool m) { | 1635 | void KateView::setReadOnly(bool m) { |
1636 | myDoc->setReadOnly(m); | 1636 | myDoc->setReadOnly(m); |
1637 | } | 1637 | } |
1638 | 1638 | ||
1639 | void KateView::setModified(bool m) { | 1639 | void KateView::setModified(bool m) { |
1640 | myDoc->setModified(m); | 1640 | myDoc->setModified(m); |
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | bool KateView::isLastView() { | 1643 | bool KateView::isLastView() { |
1644 | return myDoc->isLastView(1); | 1644 | return myDoc->isLastView(1); |
1645 | } | 1645 | } |
1646 | 1646 | ||
1647 | KateDocument *KateView::doc() { | 1647 | KateDocument *KateView::doc() { |
1648 | return myDoc; | 1648 | return myDoc; |
1649 | } | 1649 | } |
1650 | 1650 | ||
1651 | int KateView::undoState() { | 1651 | int KateView::undoState() { |
1652 | if (isReadOnly()) | 1652 | if (isReadOnly()) |
1653 | return 0; | 1653 | return 0; |
1654 | else | 1654 | else |
1655 | return myDoc->undoState; | 1655 | return myDoc->undoState; |
1656 | } | 1656 | } |
1657 | 1657 | ||
1658 | int KateView::nextUndoType() { | 1658 | int KateView::nextUndoType() { |
1659 | return myDoc->nextUndoType(); | 1659 | return myDoc->nextUndoType(); |
1660 | } | 1660 | } |
1661 | 1661 | ||
1662 | int KateView::nextRedoType() { | 1662 | int KateView::nextRedoType() { |
1663 | return myDoc->nextRedoType(); | 1663 | return myDoc->nextRedoType(); |
1664 | } | 1664 | } |
1665 | 1665 | ||
1666 | void KateView::undoTypeList(QValueList<int> &lst) | 1666 | void KateView::undoTypeList(QValueList<int> &lst) |
1667 | { | 1667 | { |
1668 | myDoc->undoTypeList(lst); | 1668 | myDoc->undoTypeList(lst); |
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | void KateView::redoTypeList(QValueList<int> &lst) | 1671 | void KateView::redoTypeList(QValueList<int> &lst) |
1672 | { | 1672 | { |
1673 | myDoc->redoTypeList(lst); | 1673 | myDoc->redoTypeList(lst); |
1674 | } | 1674 | } |
1675 | 1675 | ||
1676 | const char * KateView::undoTypeName(int type) { | 1676 | const char * KateView::undoTypeName(int type) { |
1677 | return KateActionGroup::typeName(type); | 1677 | return KateActionGroup::typeName(type); |
1678 | } | 1678 | } |
1679 | 1679 | ||
1680 | QColor* KateView::getColors() | 1680 | QColor* KateView::getColors() |
1681 | { | 1681 | { |
1682 | return myDoc->colors; | 1682 | return myDoc->colors; |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | void KateView::applyColors() | 1685 | void KateView::applyColors() |
1686 | { | 1686 | { |
1687 | myDoc->tagAll(); | 1687 | myDoc->tagAll(); |
1688 | myDoc->updateViews(); | 1688 | myDoc->updateViews(); |
1689 | } | 1689 | } |
1690 | 1690 | ||
1691 | bool KateView::isOverwriteMode() const | 1691 | bool KateView::isOverwriteMode() const |
1692 | { | 1692 | { |
1693 | return ( configFlags & KateView::cfOvr ); | 1693 | return ( configFlags & KateView::cfOvr ); |
1694 | } | 1694 | } |
1695 | 1695 | ||
1696 | void KateView::setOverwriteMode( bool b ) | 1696 | void KateView::setOverwriteMode( bool b ) |
1697 | { | 1697 | { |
1698 | if ( isOverwriteMode() && !b ) | 1698 | if ( isOverwriteMode() && !b ) |
1699 | setConfig( configFlags ^ KateView::cfOvr ); | 1699 | setConfig( configFlags ^ KateView::cfOvr ); |
1700 | else | 1700 | else |
1701 | setConfig( configFlags | KateView::cfOvr ); | 1701 | setConfig( configFlags | KateView::cfOvr ); |
1702 | } | 1702 | } |
1703 | 1703 | ||
1704 | void KateView::toggleInsert() { | 1704 | void KateView::toggleInsert() { |
1705 | setConfig(configFlags ^ KateView::cfOvr); | 1705 | setConfig(configFlags ^ KateView::cfOvr); |
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | void KateView::toggleVertical() | 1708 | void KateView::toggleVertical() |
1709 | { | 1709 | { |
1710 | setConfig(configFlags ^ KateView::cfVerticalSelect); | 1710 | setConfig(configFlags ^ KateView::cfVerticalSelect); |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | 1713 | ||
1714 | int KateView::numLines() { | 1714 | int KateView::numLines() { |
1715 | return myDoc->numLines(); | 1715 | return myDoc->numLines(); |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | QString KateView::text() { | 1718 | QString KateView::text() { |
1719 | return myDoc->text(); | 1719 | return myDoc->text(); |
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | QString KateView::currentTextLine() { | 1722 | QString KateView::currentTextLine() { |
1723 | TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y); | 1723 | TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y); |
1724 | return QString(textLine->getText(), textLine->length()); | 1724 | return QString(textLine->getText(), textLine->length()); |
1725 | } | 1725 | } |
1726 | 1726 | ||
1727 | QString KateView::textLine(int num) { | 1727 | QString KateView::textLine(int num) { |
1728 | TextLine::Ptr textLine = myDoc->getTextLine(num); | 1728 | TextLine::Ptr textLine = myDoc->getTextLine(num); |
1729 | return QString(textLine->getText(), textLine->length()); | 1729 | return QString(textLine->getText(), textLine->length()); |
1730 | } | 1730 | } |
1731 | 1731 | ||
1732 | QString KateView::currentWord() { | 1732 | QString KateView::currentWord() { |
1733 | return myDoc->getWord(myViewInternal->cursor); | 1733 | return myDoc->getWord(myViewInternal->cursor); |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | QString KateView::word(int x, int y) { | 1736 | QString KateView::word(int x, int y) { |
1737 | PointStruc cursor; | 1737 | PointStruc cursor; |
1738 | cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight; | 1738 | cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight; |
1739 | if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString(); | 1739 | if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString(); |
1740 | cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x); | 1740 | cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x); |
1741 | return myDoc->getWord(cursor); | 1741 | return myDoc->getWord(cursor); |
1742 | } | 1742 | } |
1743 | 1743 | ||
1744 | void KateView::setText(const QString &s) { | 1744 | void KateView::setText(const QString &s) { |
1745 | myDoc->setText(s); | 1745 | myDoc->setText(s); |
1746 | myDoc->updateViews(); | 1746 | myDoc->updateViews(); |
1747 | } | 1747 | } |
1748 | 1748 | ||
1749 | void KateView::insertText(const QString &s, bool /*mark*/) { | 1749 | void KateView::insertText(const QString &s, bool /*mark*/) { |
1750 | VConfig c; | 1750 | VConfig c; |
1751 | myViewInternal->getVConfig(c); | 1751 | myViewInternal->getVConfig(c); |
1752 | myDoc->insert(c, s); | 1752 | myDoc->insert(c, s); |
1753 | myDoc->updateViews(); | 1753 | myDoc->updateViews(); |
1754 | } | 1754 | } |
1755 | 1755 | ||
1756 | bool KateView::hasMarkedText() { | 1756 | bool KateView::hasMarkedText() { |
1757 | return myDoc->hasMarkedText(); | 1757 | return myDoc->hasMarkedText(); |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | QString KateView::markedText() { | 1760 | QString KateView::markedText() { |
1761 | return myDoc->markedText(configFlags); | 1761 | return myDoc->markedText(configFlags); |
1762 | } | 1762 | } |
1763 | 1763 | ||
1764 | bool KateView::canDiscard() { | 1764 | bool KateView::canDiscard() { |
1765 | int query; | 1765 | int query; |
1766 | 1766 | ||
1767 | if (isModified()) { | 1767 | if (isModified()) { |
1768 | query = KMessageBox::warningYesNoCancel(this, | 1768 | query = KMessageBox::warningYesNoCancel(this, |
1769 | i18n("The current Document has been modified.\nWould you like to save it?")); | 1769 | i18n("The current Document has been modified.\nWould you like to save it?")); |
1770 | switch (query) { | 1770 | switch (query) { |
1771 | case KMessageBox::Yes: //yes | 1771 | case KMessageBox::Yes: //yes |
1772 | if (save() == CANCEL) return false; | 1772 | if (save() == CANCEL) return false; |
1773 | if (isModified()) { | 1773 | if (isModified()) { |
1774 | query = KMessageBox::warningContinueCancel(this, | 1774 | query = KMessageBox::warningContinueCancel(this, |
1775 | i18n("Could not save the document.\nDiscard it and continue?"), | 1775 | i18n("Could not save the document.\nDiscard it and continue?"), |
1776 | QString::null, i18n("&Discard")); | 1776 | QString::null, i18n("&Discard")); |
1777 | if (query == KMessageBox::Cancel) return false; | 1777 | if (query == KMessageBox::Cancel) return false; |
1778 | } | 1778 | } |
1779 | break; | 1779 | break; |
1780 | case KMessageBox::Cancel: //cancel | 1780 | case KMessageBox::Cancel: //cancel |
1781 | return false; | 1781 | return false; |
1782 | } | 1782 | } |
1783 | } | 1783 | } |
1784 | return true; | 1784 | return true; |
1785 | } | 1785 | } |
1786 | 1786 | ||
1787 | void KateView::flush() | 1787 | void KateView::flush() |
1788 | { | 1788 | { |
1789 | if (canDiscard()) myDoc->flush(); | 1789 | if (canDiscard()) myDoc->flush(); |
1790 | } | 1790 | } |
1791 | 1791 | ||
1792 | KateView::fileResult KateView::save() { | 1792 | KateView::fileResult KateView::save() { |
1793 | int query = KMessageBox::Yes; | 1793 | int query = KMessageBox::Yes; |
1794 | if (isModified()) { | 1794 | if (isModified()) { |
1795 | return saveAs(); | 1795 | return saveAs(); |
1796 | } | 1796 | } |
1797 | return OK; | 1797 | return OK; |
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | KateView::fileResult KateView::saveAs() { | 1800 | KateView::fileResult KateView::saveAs() { |
1801 | return OK; | 1801 | return OK; |
1802 | } | 1802 | } |
1803 | 1803 | ||
1804 | void KateView::doCursorCommand(int cmdNum) { | 1804 | void KateView::doCursorCommand(int cmdNum) { |
1805 | VConfig c; | 1805 | VConfig c; |
1806 | myViewInternal->getVConfig(c); | 1806 | myViewInternal->getVConfig(c); |
1807 | if (cmdNum & selectFlag) c.flags |= KateView::cfMark; | 1807 | if (cmdNum & selectFlag) c.flags |= KateView::cfMark; |
1808 | if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection; | 1808 | if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection; |
1809 | cmdNum &= ~(selectFlag | multiSelectFlag); | 1809 | cmdNum &= ~(selectFlag | multiSelectFlag); |
1810 | myViewInternal->doCursorCommand(c, cmdNum); | 1810 | myViewInternal->doCursorCommand(c, cmdNum); |
1811 | myDoc->updateViews(); | 1811 | myDoc->updateViews(); |
1812 | } | 1812 | } |
1813 | 1813 | ||
1814 | void KateView::doEditCommand(int cmdNum) { | 1814 | void KateView::doEditCommand(int cmdNum) { |
1815 | VConfig c; | 1815 | VConfig c; |
1816 | myViewInternal->getVConfig(c); | 1816 | myViewInternal->getVConfig(c); |
1817 | myViewInternal->doEditCommand(c, cmdNum); | 1817 | myViewInternal->doEditCommand(c, cmdNum); |
1818 | myDoc->updateViews(); | 1818 | myDoc->updateViews(); |
1819 | } | 1819 | } |
1820 | 1820 | ||
1821 | void KateView::undoMultiple(int count) { | 1821 | void KateView::undoMultiple(int count) { |
1822 | if (isReadOnly()) | 1822 | if (isReadOnly()) |
1823 | return; | 1823 | return; |
1824 | 1824 | ||
1825 | VConfig c; | 1825 | VConfig c; |
1826 | myViewInternal->getVConfig(c); | 1826 | myViewInternal->getVConfig(c); |
1827 | myDoc->undo(c, count); | 1827 | myDoc->undo(c, count); |
1828 | myDoc->updateViews(); | 1828 | myDoc->updateViews(); |
1829 | } | 1829 | } |
1830 | 1830 | ||
1831 | void KateView::redoMultiple(int count) { | 1831 | void KateView::redoMultiple(int count) { |
1832 | if (isReadOnly()) | 1832 | if (isReadOnly()) |
1833 | return; | 1833 | return; |
1834 | 1834 | ||
1835 | VConfig c; | 1835 | VConfig c; |
1836 | myViewInternal->getVConfig(c); | 1836 | myViewInternal->getVConfig(c); |
1837 | myDoc->redo(c, count); | 1837 | myDoc->redo(c, count); |
1838 | myDoc->updateViews(); | 1838 | myDoc->updateViews(); |
1839 | } | 1839 | } |
1840 | 1840 | ||
1841 | void KateView::undoHistory() | 1841 | void KateView::undoHistory() |
1842 | { | 1842 | { |
1843 | UndoHistory *undoH; | 1843 | UndoHistory *undoH; |
1844 | 1844 | ||
1845 | undoH = new UndoHistory(this, this, "UndoHistory", true); | 1845 | undoH = new UndoHistory(this, this, "UndoHistory", true); |
1846 | 1846 | ||
1847 | undoH->setCaption(i18n("Undo/Redo History")); | 1847 | undoH->setCaption(i18n("Undo/Redo History")); |
1848 | 1848 | ||
1849 | connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo())); | 1849 | connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo())); |
1850 | connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int))); | 1850 | connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int))); |
1851 | connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int))); | 1851 | connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int))); |
1852 | 1852 | ||
1853 | undoH->exec(); | 1853 | undoH->exec(); |
1854 | 1854 | ||
1855 | delete undoH; | 1855 | delete undoH; |
1856 | } | 1856 | } |
1857 | 1857 | ||
1858 | static void kwview_addToStrList(QStringList &list, const QString &str) { | 1858 | static void kwview_addToStrList(QStringList &list, const QString &str) { |
1859 | if (list.count() > 0) { | 1859 | if (list.count() > 0) { |
1860 | if (list.first() == str) return; | 1860 | if (list.first() == str) return; |
1861 | QStringList::Iterator it; | 1861 | QStringList::Iterator it; |
1862 | it = list.find(str); | 1862 | it = list.find(str); |
1863 | if (*it != 0L) list.remove(it); | 1863 | if (*it != 0L) list.remove(it); |
1864 | if (list.count() >= 16) list.remove(list.fromLast()); | 1864 | if (list.count() >= 16) list.remove(list.fromLast()); |
1865 | } | 1865 | } |
1866 | list.prepend(str); | 1866 | list.prepend(str); |
1867 | } | 1867 | } |
1868 | 1868 | ||
1869 | void KateView::find() { | 1869 | void KateView::find() { |
1870 | SearchDialog *searchDialog; | 1870 | SearchDialog *searchDialog; |
1871 | 1871 | ||
1872 | if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; | 1872 | if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; |
1873 | 1873 | ||
1874 | searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, | 1874 | searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, |
1875 | searchFlags & ~KateView::sfReplace); | 1875 | searchFlags & ~KateView::sfReplace); |
1876 | 1876 | ||
1877 | // If the user has marked some text we use that otherwise | 1877 | // If the user has marked some text we use that otherwise |
1878 | // use the word under the cursor. | 1878 | // use the word under the cursor. |
1879 | QString str; | 1879 | QString str; |
1880 | if (myDoc->hasMarkedText()) | 1880 | if (myDoc->hasMarkedText()) |
1881 | str = markedText(); | 1881 | str = markedText(); |
1882 | 1882 | ||
1883 | if (str.isEmpty()) | 1883 | if (str.isEmpty()) |
1884 | str = currentWord(); | 1884 | str = currentWord(); |
1885 | 1885 | ||
1886 | if (!str.isEmpty()) | 1886 | if (!str.isEmpty()) |
1887 | { | 1887 | { |
1888 | str.replace(QRegExp("^\n"), ""); | 1888 | str.replace(QRegExp("^\n"), ""); |
1889 | int pos=str.find("\n"); | 1889 | int pos=str.find("\n"); |
1890 | if (pos>-1) | 1890 | if (pos>-1) |
1891 | str=str.left(pos); | 1891 | str=str.left(pos); |
1892 | searchDialog->setSearchText( str ); | 1892 | searchDialog->setSearchText( str ); |
1893 | } | 1893 | } |
1894 | 1894 | ||
1895 | myViewInternal->focusOutEvent(0L);// QT bug ? | 1895 | myViewInternal->focusOutEvent(0L);// QT bug ? |
1896 | if (searchDialog->exec() == QDialog::Accepted) { | 1896 | if (searchDialog->exec() == QDialog::Accepted) { |
1897 | kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); | 1897 | kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); |
1898 | searchFlags = searchDialog->getFlags() | (searchFlags & KateView::sfPrompt); | 1898 | searchFlags = searchDialog->getFlags() | (searchFlags & KateView::sfPrompt); |
1899 | initSearch(s, searchFlags); | 1899 | initSearch(s, searchFlags); |
1900 | findAgain(s); | 1900 | findAgain(s); |
1901 | } | 1901 | } |
1902 | delete searchDialog; | 1902 | delete searchDialog; |
1903 | } | 1903 | } |
1904 | 1904 | ||
1905 | void KateView::replace() { | 1905 | void KateView::replace() { |
1906 | SearchDialog *searchDialog; | 1906 | SearchDialog *searchDialog; |
1907 | 1907 | ||
1908 | if (isReadOnly()) return; | 1908 | if (isReadOnly()) return; |
1909 | 1909 | ||
1910 | if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; | 1910 | if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; |
1911 | searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, | 1911 | searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, |
1912 | searchFlags | KateView::sfReplace); | 1912 | searchFlags | KateView::sfReplace); |
1913 | 1913 | ||
1914 | // If the user has marked some text we use that otherwise | 1914 | // If the user has marked some text we use that otherwise |
1915 | // use the word under the cursor. | 1915 | // use the word under the cursor. |
1916 | QString str; | 1916 | QString str; |
1917 | if (myDoc->hasMarkedText()) | 1917 | if (myDoc->hasMarkedText()) |
1918 | str = markedText(); | 1918 | str = markedText(); |
1919 | 1919 | ||
1920 | if (str.isEmpty()) | 1920 | if (str.isEmpty()) |
1921 | str = currentWord(); | 1921 | str = currentWord(); |
1922 | 1922 | ||
1923 | if (!str.isEmpty()) | 1923 | if (!str.isEmpty()) |
1924 | { | 1924 | { |
1925 | str.replace(QRegExp("^\n"), ""); | 1925 | str.replace(QRegExp("^\n"), ""); |
1926 | int pos=str.find("\n"); | 1926 | int pos=str.find("\n"); |
1927 | if (pos>-1) | 1927 | if (pos>-1) |
1928 | str=str.left(pos); | 1928 | str=str.left(pos); |
1929 | searchDialog->setSearchText( str ); | 1929 | searchDialog->setSearchText( str ); |
1930 | } | 1930 | } |
1931 | 1931 | ||
1932 | myViewInternal->focusOutEvent(0L);// QT bug ? | 1932 | myViewInternal->focusOutEvent(0L);// QT bug ? |
1933 | if (searchDialog->exec() == QDialog::Accepted) { | 1933 | if (searchDialog->exec() == QDialog::Accepted) { |
1934 | // myDoc->recordReset(); | 1934 | // myDoc->recordReset(); |
1935 | kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); | 1935 | kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); |
1936 | kwview_addToStrList(myDoc->replaceWithList, searchDialog->getReplaceWith()); | 1936 | kwview_addToStrList(myDoc->replaceWithList, searchDialog->getReplaceWith()); |
1937 | searchFlags = searchDialog->getFlags(); | 1937 | searchFlags = searchDialog->getFlags(); |
1938 | initSearch(s, searchFlags); | 1938 | initSearch(s, searchFlags); |
1939 | replaceAgain(); | 1939 | replaceAgain(); |
1940 | } | 1940 | } |
1941 | delete searchDialog; | 1941 | delete searchDialog; |
1942 | } | 1942 | } |
1943 | 1943 | ||
1944 | void KateView::gotoLine() { | 1944 | void KateView::gotoLine() { |
1945 | GotoLineDialog *dlg; | 1945 | GotoLineDialog *dlg; |
1946 | PointStruc cursor; | 1946 | PointStruc cursor; |
1947 | 1947 | ||
1948 | dlg = new GotoLineDialog(this, myViewInternal->cursor.y + 1, myDoc->numLines()); | 1948 | dlg = new GotoLineDialog(this, myViewInternal->cursor.y + 1, myDoc->numLines()); |
1949 | // dlg = new GotoLineDialog(myViewInternal->cursor.y + 1, this); | 1949 | // dlg = new GotoLineDialog(myViewInternal->cursor.y + 1, this); |
1950 | 1950 | ||
1951 | if (dlg->exec() == QDialog::Accepted) { | 1951 | if (dlg->exec() == QDialog::Accepted) { |
1952 | // myDoc->recordReset(); | 1952 | // myDoc->recordReset(); |
1953 | cursor.x = 0; | 1953 | cursor.x = 0; |
1954 | cursor.y = dlg->getLine() - 1; | 1954 | cursor.y = dlg->getLine() - 1; |
1955 | myDoc->needPreHighlight(cursor.y); | 1955 | myDoc->needPreHighlight(cursor.y); |
1956 | myViewInternal->updateCursor(cursor); | 1956 | myViewInternal->updateCursor(cursor); |
1957 | myViewInternal->center(); | 1957 | myViewInternal->center(); |
1958 | myViewInternal->updateView(KateView::ufUpdateOnScroll); | 1958 | myViewInternal->updateView(KateView::ufUpdateOnScroll); |
1959 | myDoc->updateViews(this); //uptade all other views except this one | 1959 | myDoc->updateViews(this); //uptade all other views except this one |
1960 | } | 1960 | } |
1961 | delete dlg; | 1961 | delete dlg; |
1962 | } | 1962 | } |
1963 | 1963 | ||
1964 | 1964 | ||
1965 | void KateView::initSearch(SConfig &s, int flags) { | 1965 | void KateView::initSearch(SConfig &s, int flags) { |
1966 | 1966 | ||
1967 | s.flags = flags; | 1967 | s.flags = flags; |
1968 | s.setPattern(myDoc->searchForList.first()); | 1968 | s.setPattern(myDoc->searchForList.first()); |
1969 | 1969 | ||
1970 | if (!(s.flags & KateView::sfFromBeginning)) { | 1970 | if (!(s.flags & KateView::sfFromBeginning)) { |
1971 | // If we are continuing a backward search, make sure we do not get stuck | 1971 | // If we are continuing a backward search, make sure we do not get stuck |
1972 | // at an existing match. | 1972 | // at an existing match. |
1973 | s.cursor = myViewInternal->cursor; | 1973 | s.cursor = myViewInternal->cursor; |
1974 | TextLine::Ptr textLine = myDoc->getTextLine(s.cursor.y); | 1974 | TextLine::Ptr textLine = myDoc->getTextLine(s.cursor.y); |
1975 | QString const txt(textLine->getText(),textLine->length()); | 1975 | QString const txt(textLine->getText(),textLine->length()); |
1976 | const QString searchFor= myDoc->searchForList.first(); | 1976 | const QString searchFor= myDoc->searchForList.first(); |
1977 | int pos = s.cursor.x-searchFor.length()-1; | 1977 | int pos = s.cursor.x-searchFor.length()-1; |
1978 | if ( pos < 0 ) pos = 0; | 1978 | if ( pos < 0 ) pos = 0; |
1979 | pos= txt.find(searchFor, pos, s.flags & KateView::sfCaseSensitive); | 1979 | pos= txt.find(searchFor, pos, s.flags & KateView::sfCaseSensitive); |
1980 | if ( s.flags & KateView::sfBackward ) | 1980 | if ( s.flags & KateView::sfBackward ) |
1981 | { | 1981 | { |
1982 | if ( pos <= s.cursor.x ) s.cursor.x= pos-1; | 1982 | if ( pos <= s.cursor.x ) s.cursor.x= pos-1; |
1983 | } | 1983 | } |
1984 | else | 1984 | else |
1985 | if ( pos == s.cursor.x ) s.cursor.x++; | 1985 | if ( pos == s.cursor.x ) s.cursor.x++; |
1986 | } else { | 1986 | } else { |
1987 | if (!(s.flags & KateView::sfBackward)) { | 1987 | if (!(s.flags & KateView::sfBackward)) { |
1988 | s.cursor.x = 0; | 1988 | s.cursor.x = 0; |
1989 | s.cursor.y = 0; | 1989 | s.cursor.y = 0; |
1990 | } else { | 1990 | } else { |
1991 | s.cursor.x = -1; | 1991 | s.cursor.x = -1; |
1992 | s.cursor.y = myDoc->lastLine(); | 1992 | s.cursor.y = myDoc->lastLine(); |
1993 | } | 1993 | } |
1994 | s.flags |= KateView::sfFinished; | 1994 | s.flags |= KateView::sfFinished; |
1995 | } | 1995 | } |
1996 | if (!(s.flags & KateView::sfBackward)) { | 1996 | if (!(s.flags & KateView::sfBackward)) { |
1997 | if (!(s.cursor.x || s.cursor.y)) | 1997 | if (!(s.cursor.x || s.cursor.y)) |
1998 | s.flags |= KateView::sfFinished; | 1998 | s.flags |= KateView::sfFinished; |
1999 | } | 1999 | } |
2000 | s.startCursor = s.cursor; | 2000 | s.startCursor = s.cursor; |
2001 | } | 2001 | } |
2002 | 2002 | ||
2003 | void KateView::continueSearch(SConfig &s) { | 2003 | void KateView::continueSearch(SConfig &s) { |
2004 | 2004 | ||
2005 | if (!(s.flags & KateView::sfBackward)) { | 2005 | if (!(s.flags & KateView::sfBackward)) { |
2006 | s.cursor.x = 0; | 2006 | s.cursor.x = 0; |
2007 | s.cursor.y = 0; | 2007 | s.cursor.y = 0; |
2008 | } else { | 2008 | } else { |
2009 | s.cursor.x = -1; | 2009 | s.cursor.x = -1; |
2010 | s.cursor.y = myDoc->lastLine(); | 2010 | s.cursor.y = myDoc->lastLine(); |
2011 | } | 2011 | } |
2012 | s.flags |= KateView::sfFinished; | 2012 | s.flags |= KateView::sfFinished; |
2013 | s.flags &= ~KateView::sfAgain; | 2013 | s.flags &= ~KateView::sfAgain; |
2014 | } | 2014 | } |
2015 | 2015 | ||
2016 | void KateView::findAgain(SConfig &s) { | 2016 | void KateView::findAgain(SConfig &s) { |
2017 | int query; | 2017 | int query; |
2018 | PointStruc cursor; | 2018 | PointStruc cursor; |
2019 | QString str; | 2019 | QString str; |
2020 | 2020 | ||
2021 | QString searchFor = myDoc->searchForList.first(); | 2021 | QString searchFor = myDoc->searchForList.first(); |
2022 | 2022 | ||
2023 | if( searchFor.isEmpty() ) { | 2023 | if( searchFor.isEmpty() ) { |
2024 | find(); | 2024 | find(); |
2025 | return; | 2025 | return; |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | do { | 2028 | do { |
2029 | query = KMessageBox::Cancel; | 2029 | query = KMessageBox::Cancel; |
2030 | if (myDoc->doSearch(s,searchFor)) { | 2030 | if (myDoc->doSearch(s,searchFor)) { |
2031 | cursor = s.cursor; | 2031 | cursor = s.cursor; |
2032 | if (!(s.flags & KateView::sfBackward)) | 2032 | if (!(s.flags & KateView::sfBackward)) |
2033 | s.cursor.x += s.matchedLength; | 2033 | s.cursor.x += s.matchedLength; |
2034 | myViewInternal->updateCursor(s.cursor); //does deselectAll() | 2034 | myViewInternal->updateCursor(s.cursor); //does deselectAll() |
2035 | exposeFound(cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,false); | 2035 | exposeFound(cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,false); |
2036 | } else { | 2036 | } else { |
2037 | if (!(s.flags & KateView::sfFinished)) { | 2037 | if (!(s.flags & KateView::sfFinished)) { |
2038 | // ask for continue | 2038 | // ask for continue |
2039 | if (!(s.flags & KateView::sfBackward)) { | 2039 | if (!(s.flags & KateView::sfBackward)) { |
2040 | // forward search | 2040 | // forward search |
2041 | str = i18n("End of document reached.\n" | 2041 | str = i18n("End of document reached.\n" |
2042 | "Continue from the beginning?"); | 2042 | "Continue from the beginning?"); |
2043 | query = KMessageBox::warningContinueCancel(this, | 2043 | query = KMessageBox::warningContinueCancel(this, |
2044 | str, i18n("Find"), i18n("Continue")); | 2044 | str, i18n("Find"), i18n("Continue")); |
2045 | } else { | 2045 | } else { |
2046 | // backward search | 2046 | // backward search |
2047 | str = i18n("Beginning of document reached.\n" | 2047 | str = i18n("Beginning of document reached.\n" |
2048 | "Continue from the end?"); | 2048 | "Continue from the end?"); |
2049 | query = KMessageBox::warningContinueCancel(this, | 2049 | query = KMessageBox::warningContinueCancel(this, |
2050 | str, i18n("Find"), i18n("Continue")); | 2050 | str, i18n("Find"), i18n("Continue")); |
2051 | } | 2051 | } |
2052 | continueSearch(s); | 2052 | continueSearch(s); |
2053 | } else { | 2053 | } else { |
2054 | // wrapped | 2054 | // wrapped |
2055 | KMessageBox::sorry(this, | 2055 | KMessageBox::sorry(this, |
2056 | i18n("Search string '%1' not found!").arg(searchFor), | 2056 | i18n("Search string '%1' not found!").arg(searchFor), |
2057 | i18n("Find")); | 2057 | i18n("Find")); |
2058 | } | 2058 | } |
2059 | } | 2059 | } |
2060 | } while (query == KMessageBox::Continue); | 2060 | } while (query == KMessageBox::Continue); |
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | void KateView::replaceAgain() { | 2063 | void KateView::replaceAgain() { |
2064 | if (isReadOnly()) | 2064 | if (isReadOnly()) |
2065 | return; | 2065 | return; |
2066 | 2066 | ||
2067 | replaces = 0; | 2067 | replaces = 0; |
2068 | if (s.flags & KateView::sfPrompt) { | 2068 | if (s.flags & KateView::sfPrompt) { |
2069 | doReplaceAction(-1); | 2069 | doReplaceAction(-1); |
2070 | } else { | 2070 | } else { |
2071 | doReplaceAction(KateView::srAll); | 2071 | doReplaceAction(KateView::srAll); |
2072 | } | 2072 | } |
2073 | } | 2073 | } |
2074 | 2074 | ||
2075 | void KateView::doReplaceAction(int result, bool found) { | 2075 | void KateView::doReplaceAction(int result, bool found) { |
2076 | int rlen; | 2076 | int rlen; |
2077 | PointStruc cursor; | 2077 | PointStruc cursor; |
2078 | bool started; | 2078 | bool started; |
2079 | 2079 | ||
2080 | QString searchFor = myDoc->searchForList.first(); | 2080 | QString searchFor = myDoc->searchForList.first(); |
2081 | QString replaceWith = myDoc->replaceWithList.first(); | 2081 | QString replaceWith = myDoc->replaceWithList.first(); |
2082 | rlen = replaceWith.length(); | 2082 | rlen = replaceWith.length(); |
2083 | 2083 | ||
2084 | switch (result) { | 2084 | switch (result) { |
2085 | case KateView::srYes: //yes | 2085 | case KateView::srYes: //yes |
2086 | myDoc->recordStart(this, s.cursor, configFlags, | 2086 | myDoc->recordStart(this, s.cursor, configFlags, |
2087 | KateActionGroup::ugReplace, true); | 2087 | KateActionGroup::ugReplace, true); |
2088 | myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); | 2088 | myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); |
2089 | replaces++; | 2089 | replaces++; |
2090 | if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) | 2090 | if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) |
2091 | s.startCursor.x += rlen - s.matchedLength; | 2091 | s.startCursor.x += rlen - s.matchedLength; |
2092 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; | 2092 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; |
2093 | myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent); | 2093 | myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent); |
2094 | break; | 2094 | break; |
2095 | case KateView::srNo: //no | 2095 | case KateView::srNo: //no |
2096 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength; | 2096 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength; |
2097 | break; | 2097 | break; |
2098 | case KateView::srAll: //replace all | 2098 | case KateView::srAll: //replace all |
2099 | deleteReplacePrompt(); | 2099 | deleteReplacePrompt(); |
2100 | do { | 2100 | do { |
2101 | started = false; | 2101 | started = false; |
2102 | while (found || myDoc->doSearch(s,searchFor)) { | 2102 | while (found || myDoc->doSearch(s,searchFor)) { |
2103 | if (!started) { | 2103 | if (!started) { |
2104 | found = false; | 2104 | found = false; |
2105 | myDoc->recordStart(this, s.cursor, configFlags, | 2105 | myDoc->recordStart(this, s.cursor, configFlags, |
2106 | KateActionGroup::ugReplace); | 2106 | KateActionGroup::ugReplace); |
2107 | started = true; | 2107 | started = true; |
2108 | } | 2108 | } |
2109 | myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); | 2109 | myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); |
2110 | replaces++; | 2110 | replaces++; |
2111 | if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) | 2111 | if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) |
2112 | s.startCursor.x += rlen - s.matchedLength; | 2112 | s.startCursor.x += rlen - s.matchedLength; |
2113 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; | 2113 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; |
2114 | } | 2114 | } |
2115 | if (started) myDoc->recordEnd(this, s.cursor, | 2115 | if (started) myDoc->recordEnd(this, s.cursor, |
2116 | configFlags | KateView::cfPersistent); | 2116 | configFlags | KateView::cfPersistent); |
2117 | } while (!askReplaceEnd()); | 2117 | } while (!askReplaceEnd()); |
2118 | return; | 2118 | return; |
2119 | case KateView::srCancel: //cancel | 2119 | case KateView::srCancel: //cancel |
2120 | deleteReplacePrompt(); | 2120 | deleteReplacePrompt(); |
2121 | return; | 2121 | return; |
2122 | default: | 2122 | default: |
2123 | replacePrompt = 0L; | 2123 | replacePrompt = 0L; |
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | do { | 2126 | do { |
2127 | if (myDoc->doSearch(s,searchFor)) { | 2127 | if (myDoc->doSearch(s,searchFor)) { |
2128 | //text found: highlight it, show replace prompt if needed and exit | 2128 | //text found: highlight it, show replace prompt if needed and exit |
2129 | cursor = s.cursor; | 2129 | cursor = s.cursor; |
2130 | if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength; | 2130 | if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength; |
2131 | myViewInternal->updateCursor(cursor); //does deselectAll() | 2131 | myViewInternal->updateCursor(cursor); //does deselectAll() |
2132 | exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true); | 2132 | exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true); |
2133 | if (replacePrompt == 0L) { | 2133 | if (replacePrompt == 0L) { |
2134 | replacePrompt = new ReplacePrompt(this); | 2134 | replacePrompt = new ReplacePrompt(this); |
2135 | myDoc->setPseudoModal(replacePrompt);//disable(); | 2135 | myDoc->setPseudoModal(replacePrompt);//disable(); |
2136 | connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot())); | 2136 | connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot())); |
2137 | replacePrompt->show(); //this is not modal | 2137 | replacePrompt->show(); //this is not modal |
2138 | } | 2138 | } |
2139 | return; //exit if text found | 2139 | return; //exit if text found |
2140 | } | 2140 | } |
2141 | //nothing found: repeat until user cancels "repeat from beginning" dialog | 2141 | //nothing found: repeat until user cancels "repeat from beginning" dialog |
2142 | } while (!askReplaceEnd()); | 2142 | } while (!askReplaceEnd()); |
2143 | deleteReplacePrompt(); | 2143 | deleteReplacePrompt(); |
2144 | } | 2144 | } |
2145 | 2145 | ||
2146 | void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) { | 2146 | void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) { |
2147 | int x1, x2, y1, y2, xPos, yPos; | 2147 | int x1, x2, y1, y2, xPos, yPos; |
2148 | 2148 | ||
2149 | VConfig c; | 2149 | VConfig c; |
2150 | myViewInternal->getVConfig(c); | 2150 | myViewInternal->getVConfig(c); |
2151 | myDoc->selectLength(cursor,slen,c.flags); | 2151 | myDoc->selectLength(cursor,slen,c.flags); |
2152 | 2152 | ||
2153 | TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); | 2153 | TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); |
2154 | x1 = myDoc->textWidth(textLine,cursor.x) -10; | 2154 | x1 = myDoc->textWidth(textLine,cursor.x) -10; |
2155 | x2 = myDoc->textWidth(textLine,cursor.x + slen) +20; | 2155 | x2 = myDoc->textWidth(textLine,cursor.x + slen) +20; |
2156 | y1 = myDoc->fontHeight*cursor.y -10; | 2156 | y1 = myDoc->fontHeight*cursor.y -10; |
2157 | y2 = y1 + myDoc->fontHeight +30; | 2157 | y2 = y1 + myDoc->fontHeight +30; |
2158 | 2158 | ||
2159 | xPos = myViewInternal->xPos; | 2159 | xPos = myViewInternal->xPos; |
2160 | yPos = myViewInternal->yPos; | 2160 | yPos = myViewInternal->yPos; |
2161 | 2161 | ||
2162 | if (x1 < 0) x1 = 0; | 2162 | if (x1 < 0) x1 = 0; |
2163 | if (replace) y2 += 90; | 2163 | if (replace) y2 += 90; |
2164 | 2164 | ||
2165 | if (x1 < xPos || x2 > xPos + myViewInternal->width()) { | 2165 | if (x1 < xPos || x2 > xPos + myViewInternal->width()) { |
2166 | xPos = x2 - myViewInternal->width(); | 2166 | xPos = x2 - myViewInternal->width(); |
2167 | } | 2167 | } |
2168 | if (y1 < yPos || y2 > yPos + myViewInternal->height()) { | 2168 | if (y1 < yPos || y2 > yPos + myViewInternal->height()) { |
2169 | xPos = x2 - myViewInternal->width(); | 2169 | xPos = x2 - myViewInternal->width(); |
2170 | yPos = myDoc->fontHeight*cursor.y - height()/3; | 2170 | yPos = myDoc->fontHeight*cursor.y - height()/3; |
2171 | } | 2171 | } |
2172 | myViewInternal->setPos(xPos, yPos); | 2172 | myViewInternal->setPos(xPos, yPos); |
2173 | myViewInternal->updateView(flags);// | ufPos,xPos,yPos); | 2173 | myViewInternal->updateView(flags);// | ufPos,xPos,yPos); |
2174 | myDoc->updateViews(this); | 2174 | myDoc->updateViews(this); |
2175 | } | 2175 | } |
2176 | 2176 | ||
2177 | void KateView::deleteReplacePrompt() { | 2177 | void KateView::deleteReplacePrompt() { |
2178 | myDoc->setPseudoModal(0L); | 2178 | myDoc->setPseudoModal(0L); |
2179 | } | 2179 | } |
2180 | 2180 | ||
2181 | bool KateView::askReplaceEnd() { | 2181 | bool KateView::askReplaceEnd() { |
2182 | QString str; | 2182 | QString str; |
2183 | int query; | 2183 | int query; |
2184 | 2184 | ||
2185 | myDoc->updateViews(); | 2185 | myDoc->updateViews(); |
2186 | if (s.flags & KateView::sfFinished) { | 2186 | if (s.flags & KateView::sfFinished) { |
2187 | // replace finished | 2187 | // replace finished |
2188 | str = i18n("%1 replacement(s) made").arg(replaces); | 2188 | str = i18n("%1 replacement(s) made").arg(replaces); |
2189 | KMessageBox::information(this, str, i18n("Replace")); | 2189 | KMessageBox::information(this, str, i18n("Replace")); |
2190 | return true; | 2190 | return true; |
2191 | } | 2191 | } |
2192 | 2192 | ||
2193 | // ask for continue | 2193 | // ask for continue |
2194 | if (!(s.flags & KateView::sfBackward)) { | 2194 | if (!(s.flags & KateView::sfBackward)) { |
2195 | // forward search | 2195 | // forward search |
2196 | str = i18n("%1 replacement(s) made.\n" | 2196 | str = i18n("%1 replacement(s) made.\n" |
2197 | "End of document reached.\n" | 2197 | "End of document reached.\n" |
2198 | "Continue from the beginning?").arg(replaces); | 2198 | "Continue from the beginning?").arg(replaces); |
2199 | query = KMessageBox::questionYesNo(this, str, i18n("Continue"), i18n("Stop")); | 2199 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), |
2200 | i18n("Continue"), i18n("Stop")); | ||
2200 | } else { | 2201 | } else { |
2201 | // backward search | 2202 | // backward search |
2202 | str = i18n("%1 replacement(s) made.\n" | 2203 | str = i18n("%1 replacement(s) made.\n" |
2203 | "Beginning of document reached.\n" | 2204 | "Beginning of document reached.\n" |
2204 | "Continue from the end?").arg(replaces); | 2205 | "Continue from the end?").arg(replaces); |
2205 | query = KMessageBox::questionYesNo(this, str, i18n("Continue"), i18n("Stop")); | 2206 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), |
2207 | i18n("Continue"), i18n("Stop")); | ||
2206 | } | 2208 | } |
2207 | replaces = 0; | 2209 | replaces = 0; |
2208 | continueSearch(s); | 2210 | continueSearch(s); |
2209 | return (query == KMessageBox::No); | 2211 | return (query == KMessageBox::No); |
2210 | } | 2212 | } |
2211 | 2213 | ||
2212 | void KateView::replaceSlot() { | 2214 | void KateView::replaceSlot() { |
2213 | doReplaceAction(replacePrompt->result(),true); | 2215 | doReplaceAction(replacePrompt->result(),true); |
2214 | } | 2216 | } |
2215 | 2217 | ||
2216 | void KateView::installPopup(QPopupMenu *rmb_Menu) | 2218 | void KateView::installPopup(QPopupMenu *rmb_Menu) |
2217 | { | 2219 | { |
2218 | rmbMenu = rmb_Menu; | 2220 | rmbMenu = rmb_Menu; |
2219 | } | 2221 | } |
2220 | 2222 | ||
2221 | void KateView::readConfig() | 2223 | void KateView::readConfig() |
2222 | { | 2224 | { |
2223 | KateConfig *config = KGlobal::config(); | 2225 | KateConfig *config = KGlobal::config(); |
2224 | config->setGroup("Kate View"); | 2226 | config->setGroup("Kate View"); |
2225 | 2227 | ||
2226 | searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); | 2228 | searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); |
2227 | configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; | 2229 | configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; |
2228 | 2230 | ||
2229 | // config->sync(); | 2231 | // config->sync(); |
2230 | } | 2232 | } |
2231 | 2233 | ||
2232 | void KateView::writeConfig() | 2234 | void KateView::writeConfig() |
2233 | { | 2235 | { |
2234 | KateConfig *config = KGlobal::config(); | 2236 | KateConfig *config = KGlobal::config(); |
2235 | config->setGroup("Kate View"); | 2237 | config->setGroup("Kate View"); |
2236 | 2238 | ||
2237 | config->writeEntry("SearchFlags",searchFlags); | 2239 | config->writeEntry("SearchFlags",searchFlags); |
2238 | config->writeEntry("ConfigFlags",configFlags); | 2240 | config->writeEntry("ConfigFlags",configFlags); |
2239 | 2241 | ||
2240 | // config->sync(); | 2242 | // config->sync(); |
2241 | } | 2243 | } |
2242 | 2244 | ||
2243 | void KateView::readSessionConfig(KateConfig *config) | 2245 | void KateView::readSessionConfig(KateConfig *config) |
2244 | { | 2246 | { |
2245 | PointStruc cursor; | 2247 | PointStruc cursor; |
2246 | 2248 | ||
2247 | myViewInternal->xPos = config->readNumEntry("XPos"); | 2249 | myViewInternal->xPos = config->readNumEntry("XPos"); |
2248 | myViewInternal->yPos = config->readNumEntry("YPos"); | 2250 | myViewInternal->yPos = config->readNumEntry("YPos"); |
2249 | cursor.x = config->readNumEntry("CursorX"); | 2251 | cursor.x = config->readNumEntry("CursorX"); |
2250 | cursor.y = config->readNumEntry("CursorY"); | 2252 | cursor.y = config->readNumEntry("CursorY"); |
2251 | myViewInternal->updateCursor(cursor); | 2253 | myViewInternal->updateCursor(cursor); |
2252 | myIconBorder = config->readBoolEntry("IconBorder on"); | 2254 | myIconBorder = config->readBoolEntry("IconBorder on"); |
2253 | setIconBorder(myIconBorder); | 2255 | setIconBorder(myIconBorder); |
2254 | } | 2256 | } |
2255 | 2257 | ||
2256 | void KateView::writeSessionConfig(KateConfig *config) | 2258 | void KateView::writeSessionConfig(KateConfig *config) |
2257 | { | 2259 | { |
2258 | config->writeEntry("XPos",myViewInternal->xPos); | 2260 | config->writeEntry("XPos",myViewInternal->xPos); |
2259 | config->writeEntry("YPos",myViewInternal->yPos); | 2261 | config->writeEntry("YPos",myViewInternal->yPos); |
2260 | config->writeEntry("CursorX",myViewInternal->cursor.x); | 2262 | config->writeEntry("CursorX",myViewInternal->cursor.x); |
2261 | config->writeEntry("CursorY",myViewInternal->cursor.y); | 2263 | config->writeEntry("CursorY",myViewInternal->cursor.y); |
2262 | config->writeEntry("IconBorder on", myIconBorder); | 2264 | config->writeEntry("IconBorder on", myIconBorder); |
2263 | } | 2265 | } |
2264 | 2266 | ||
2265 | void KateView::configDialog() | 2267 | void KateView::configDialog() |
2266 | { | 2268 | { |
2267 | 2269 | ||
2268 | #warning fixme | 2270 | #warning fixme |
2269 | QScrollView *pScroll; | ||
2270 | 2271 | ||
2271 | #if 1 | 2272 | #if 1 |
2272 | KDialogBase *kd = new KDialogBase(KDialogBase::IconList, | 2273 | KDialogBase *kd = new KDialogBase(KDialogBase::IconList, |
2273 | i18n("Configure Editor"), | 2274 | i18n("Configure Editor"), |
2274 | KDialogBase::Ok | KDialogBase::Cancel | | 2275 | KDialogBase::Ok | KDialogBase::Cancel | |
2275 | KDialogBase::Help , | 2276 | KDialogBase::Help , |
2276 | KDialogBase::Ok, this, "tabdialog"); | 2277 | KDialogBase::Ok, this, "tabdialog"); |
2277 | 2278 | ||
2278 | // color options | 2279 | // color options |
2279 | QFrame *page=kd->addPage(i18n("Colors")); | 2280 | QFrame *page=kd->addPage(i18n("Colors")); |
2280 | (new QVBoxLayout(page))->setAutoAdd(true); | 2281 | (new QVBoxLayout(page))->setAutoAdd(true); |
2281 | ColorConfig *colorConfig = new ColorConfig(page); | 2282 | ColorConfig *colorConfig = new ColorConfig(page); |
2282 | QColor* colors = getColors(); | 2283 | QColor* colors = getColors(); |
2283 | colorConfig->setColors(colors); | 2284 | colorConfig->setColors(colors); |
2284 | 2285 | ||
2285 | page = kd->addPage(i18n("Fonts")); | 2286 | page = kd->addPage(i18n("Fonts")); |
2286 | (new QVBoxLayout(page))->setAutoAdd(true); | 2287 | (new QVBoxLayout(page))->setAutoAdd(true); |
2287 | 2288 | ||
2288 | FontConfig *fontConfig = new FontConfig(page); | 2289 | FontConfig *fontConfig = new FontConfig(page); |
2289 | fontConfig->setFont (myDoc->getFont()); | 2290 | fontConfig->setFont (myDoc->getFont()); |
2290 | 2291 | ||
2291 | // indent options | 2292 | // indent options |
2292 | page=kd->addPage(i18n("Indent")); | 2293 | page=kd->addPage(i18n("Indent")); |
2293 | (new QVBoxLayout(page))->setAutoAdd(true); | 2294 | (new QVBoxLayout(page))->setAutoAdd(true); |
2294 | 2295 | ||
2295 | IndentConfigTab *indentConfig = new IndentConfigTab(page, this); | 2296 | IndentConfigTab *indentConfig = new IndentConfigTab(page, this); |
2296 | 2297 | ||
2297 | // select options | 2298 | // select options |
2298 | page=kd->addPage(i18n("Select")); | 2299 | page=kd->addPage(i18n("Select")); |
2299 | (new QVBoxLayout(page))->setAutoAdd(true); | 2300 | (new QVBoxLayout(page))->setAutoAdd(true); |
2300 | 2301 | ||
2301 | SelectConfigTab *selectConfig = new SelectConfigTab(page, this); | 2302 | SelectConfigTab *selectConfig = new SelectConfigTab(page, this); |
2302 | 2303 | ||
2303 | // edit options | 2304 | // edit options |
2304 | page=kd->addPage(i18n("Edit")); | 2305 | page=kd->addPage(i18n("Edit")); |
2305 | (new QVBoxLayout(page))->setAutoAdd(true); | 2306 | (new QVBoxLayout(page))->setAutoAdd(true); |
2306 | pScroll=new QScrollView(page); | 2307 | |
2307 | EditConfigTab *editConfig = new EditConfigTab(page, this); | 2308 | EditConfigTab *editConfig = new EditConfigTab(page, this); |
2308 | pScroll->addChild(editConfig); | ||
2309 | 2309 | ||
2310 | 2310 | ||
2311 | 2311 | ||
2312 | HighlightDialogPage *hlPage; | 2312 | HighlightDialogPage *hlPage; |
2313 | HlManager *hlManager; | 2313 | HlManager *hlManager; |
2314 | HlDataList hlDataList; | 2314 | HlDataList hlDataList; |
2315 | ItemStyleList defaultStyleList; | 2315 | ItemStyleList defaultStyleList; |
2316 | 2316 | ||
2317 | hlManager = HlManager::self(); | 2317 | hlManager = HlManager::self(); |
2318 | 2318 | ||
2319 | defaultStyleList.setAutoDelete(true); | 2319 | defaultStyleList.setAutoDelete(true); |
2320 | hlManager->getDefaults(defaultStyleList); | 2320 | hlManager->getDefaults(defaultStyleList); |
2321 | 2321 | ||
2322 | hlDataList.setAutoDelete(true); | 2322 | hlDataList.setAutoDelete(true); |
2323 | //this gets the data from the KateConfig object | 2323 | //this gets the data from the KateConfig object |
2324 | hlManager->getHlDataList(hlDataList); | 2324 | hlManager->getHlDataList(hlDataList); |
2325 | 2325 | ||
2326 | page=kd->addPage(i18n("Highlighting")); | 2326 | page=kd->addPage(i18n("Highlighting")); |
2327 | (new QVBoxLayout(page))->setAutoAdd(true); | 2327 | (new QVBoxLayout(page))->setAutoAdd(true); |
2328 | pScroll=new QScrollView(page); | ||
2329 | hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, pScroll->viewport()); | ||
2330 | pScroll->addChild(hlPage); | ||
2331 | 2328 | ||
2332 | kd->showMaximized(); | 2329 | hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); |
2330 | kd->showMaximized(); | ||
2333 | if (kd->exec()) { | 2331 | if (kd->exec()) { |
2334 | // color options | 2332 | // color options |
2335 | colorConfig->getColors(colors); | 2333 | colorConfig->getColors(colors); |
2336 | myDoc->setFont (fontConfig->getFont()); | 2334 | myDoc->setFont (fontConfig->getFont()); |
2337 | 2335 | ||
2338 | applyColors(); | 2336 | applyColors(); |
2339 | // indent options | 2337 | // indent options |
2340 | indentConfig->getData(this); | 2338 | indentConfig->getData(this); |
2341 | // select options | 2339 | // select options |
2342 | selectConfig->getData(this); | 2340 | selectConfig->getData(this); |
2343 | // edit options | 2341 | // edit options |
2344 | editConfig->getData(this); | 2342 | editConfig->getData(this); |
2345 | // spell checker | 2343 | // spell checker |
2346 | hlManager->setHlDataList(hlDataList); | 2344 | hlManager->setHlDataList(hlDataList); |
2347 | hlManager->setDefaults(defaultStyleList); | 2345 | hlManager->setDefaults(defaultStyleList); |
2348 | hlPage->saveData(); | 2346 | hlPage->saveData(); |
2349 | } | 2347 | } |
2350 | 2348 | ||
2351 | // delete kd; | 2349 | // delete kd; |
2352 | 2350 | ||
2353 | #endif | 2351 | #endif |
2354 | } | 2352 | } |
2355 | 2353 | ||
2356 | int KateView::getHl() { | 2354 | int KateView::getHl() { |
2357 | return myDoc->highlightNum(); | 2355 | return myDoc->highlightNum(); |
2358 | } | 2356 | } |
2359 | 2357 | ||
2360 | void KateView::setDontChangeHlOnSave() | 2358 | void KateView::setDontChangeHlOnSave() |
2361 | { | 2359 | { |
2362 | myDoc->setDontChangeHlOnSave(); | 2360 | myDoc->setDontChangeHlOnSave(); |
2363 | } | 2361 | } |
2364 | 2362 | ||
2365 | void KateView::setHl(int n) { | 2363 | void KateView::setHl(int n) { |
2366 | myDoc->setHighlight(n); | 2364 | myDoc->setHighlight(n); |
2367 | myDoc->setDontChangeHlOnSave(); | 2365 | myDoc->setDontChangeHlOnSave(); |
2368 | myDoc->updateViews(); | 2366 | myDoc->updateViews(); |
2369 | } | 2367 | } |
2370 | 2368 | ||
2371 | int KateView::getEol() { | 2369 | int KateView::getEol() { |
2372 | return myDoc->eolMode; | 2370 | return myDoc->eolMode; |
2373 | } | 2371 | } |
2374 | 2372 | ||
2375 | void KateView::setEol(int eol) { | 2373 | void KateView::setEol(int eol) { |
2376 | if (isReadOnly()) | 2374 | if (isReadOnly()) |
2377 | return; | 2375 | return; |
2378 | 2376 | ||
2379 | myDoc->eolMode = eol; | 2377 | myDoc->eolMode = eol; |
2380 | myDoc->setModified(true); | 2378 | myDoc->setModified(true); |
2381 | } | 2379 | } |
2382 | 2380 | ||
2383 | 2381 | ||
2384 | 2382 | ||
2385 | void KateView::paintEvent(QPaintEvent *e) { | 2383 | void KateView::paintEvent(QPaintEvent *e) { |
2386 | int x, y; | 2384 | int x, y; |
2387 | 2385 | ||
2388 | QRect updateR = e->rect(); // update rectangle | 2386 | QRect updateR = e->rect(); // update rectangle |
2389 | // debug("Update rect = ( %i, %i, %i, %i )", | 2387 | // debug("Update rect = ( %i, %i, %i, %i )", |
2390 | // updateR.x(),updateR.y(), updateR.width(), updateR.height() ); | 2388 | // updateR.x(),updateR.y(), updateR.width(), updateR.height() ); |
2391 | 2389 | ||
2392 | int ux1 = updateR.x(); | 2390 | int ux1 = updateR.x(); |
2393 | int uy1 = updateR.y(); | 2391 | int uy1 = updateR.y(); |
2394 | int ux2 = ux1 + updateR.width(); | 2392 | int ux2 = ux1 + updateR.width(); |
2395 | int uy2 = uy1 + updateR.height(); | 2393 | int uy2 = uy1 + updateR.height(); |
2396 | 2394 | ||
2397 | QPainter paint; | 2395 | QPainter paint; |
2398 | paint.begin(this); | 2396 | paint.begin(this); |
2399 | 2397 | ||
2400 | QColorGroup g = colorGroup(); | 2398 | QColorGroup g = colorGroup(); |
2401 | x = width(); | 2399 | x = width(); |
2402 | y = height(); | 2400 | y = height(); |
2403 | 2401 | ||
2404 | paint.setPen(g.dark()); | 2402 | paint.setPen(g.dark()); |
2405 | if (uy1 <= 0) paint.drawLine(0,0,x-2,0); | 2403 | if (uy1 <= 0) paint.drawLine(0,0,x-2,0); |
2406 | if (ux1 <= 0) paint.drawLine(0,1,0,y-2); | 2404 | if (ux1 <= 0) paint.drawLine(0,1,0,y-2); |
2407 | 2405 | ||
2408 | paint.setPen(black); | 2406 | paint.setPen(black); |
2409 | if (uy1 <= 1) paint.drawLine(1,1,x-3,1); | 2407 | if (uy1 <= 1) paint.drawLine(1,1,x-3,1); |
2410 | if (ux1 <= 1) paint.drawLine(1,2,1,y-3); | 2408 | if (ux1 <= 1) paint.drawLine(1,2,1,y-3); |
2411 | 2409 | ||
2412 | paint.setPen(g.midlight()); | 2410 | paint.setPen(g.midlight()); |
2413 | if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); | 2411 | if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); |
2414 | if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); | 2412 | if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); |
2415 | 2413 | ||
2416 | paint.setPen(g.light()); | 2414 | paint.setPen(g.light()); |
2417 | if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); | 2415 | if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); |
2418 | if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); | 2416 | if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); |
2419 | 2417 | ||
2420 | x -= 2 + 16; | 2418 | x -= 2 + 16; |
2421 | y -= 2 + 16; | 2419 | y -= 2 + 16; |
2422 | if (ux2 > x && uy2 > y) { | 2420 | if (ux2 > x && uy2 > y) { |
2423 | paint.fillRect(x,y,16,16,g.background()); | 2421 | paint.fillRect(x,y,16,16,g.background()); |
2424 | } | 2422 | } |
2425 | paint.end(); | 2423 | paint.end(); |
2426 | } | 2424 | } |
2427 | 2425 | ||
2428 | void KateView::resizeEvent(QResizeEvent *) { | 2426 | void KateView::resizeEvent(QResizeEvent *) { |
2429 | 2427 | ||
2430 | // debug("Resize %d, %d",e->size().width(),e->size().height()); | 2428 | // debug("Resize %d, %d",e->size().width(),e->size().height()); |
2431 | 2429 | ||
2432 | //myViewInternal->resize(width() -20, height() -20); | 2430 | //myViewInternal->resize(width() -20, height() -20); |
2433 | myViewInternal->tagAll(); | 2431 | myViewInternal->tagAll(); |
2434 | myViewInternal->updateView(0/*ufNoScroll*/); | 2432 | myViewInternal->updateView(0/*ufNoScroll*/); |
2435 | } | 2433 | } |
2436 | 2434 | ||
2437 | 2435 | ||
2438 | // Applies a new pattern to the search context. | 2436 | // Applies a new pattern to the search context. |
2439 | void SConfig::setPattern(QString &newPattern) { | 2437 | void SConfig::setPattern(QString &newPattern) { |
2440 | bool regExp = (flags & KateView::sfRegularExpression); | 2438 | bool regExp = (flags & KateView::sfRegularExpression); |
2441 | 2439 | ||
2442 | m_pattern = newPattern; | 2440 | m_pattern = newPattern; |
2443 | if (regExp) { | 2441 | if (regExp) { |
2444 | m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive); | 2442 | m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive); |
2445 | m_regExp.setPattern(m_pattern); | 2443 | m_regExp.setPattern(m_pattern); |
2446 | } | 2444 | } |
2447 | } | 2445 | } |
2448 | 2446 | ||
2449 | // Applies the search context to the given string, and returns whether a match was found. If one is, | 2447 | // Applies the search context to the given string, and returns whether a match was found. If one is, |
2450 | // the length of the string matched is also returned. | 2448 | // the length of the string matched is also returned. |
2451 | int SConfig::search(QString &text, int index) { | 2449 | int SConfig::search(QString &text, int index) { |
2452 | bool regExp = (flags & KateView::sfRegularExpression); | 2450 | bool regExp = (flags & KateView::sfRegularExpression); |
2453 | bool caseSensitive = (flags & KateView::sfCaseSensitive); | 2451 | bool caseSensitive = (flags & KateView::sfCaseSensitive); |
2454 | 2452 | ||
2455 | if (flags & KateView::sfBackward) { | 2453 | if (flags & KateView::sfBackward) { |
2456 | if (regExp) { | 2454 | if (regExp) { |
2457 | index = text.findRev(m_regExp, index); | 2455 | index = text.findRev(m_regExp, index); |
2458 | } | 2456 | } |
2459 | else { | 2457 | else { |
2460 | index = text.findRev(m_pattern, index, caseSensitive); | 2458 | index = text.findRev(m_pattern, index, caseSensitive); |
2461 | } | 2459 | } |
2462 | } | 2460 | } |
2463 | else { | 2461 | else { |
2464 | if (regExp) { | 2462 | if (regExp) { |
2465 | index = text.find(m_regExp, index); | 2463 | index = text.find(m_regExp, index); |
2466 | } | 2464 | } |
2467 | else { | 2465 | else { |
2468 | index = text.find(m_pattern, index, caseSensitive); | 2466 | index = text.find(m_pattern, index, caseSensitive); |
2469 | } | 2467 | } |
2470 | } | 2468 | } |
2471 | 2469 | ||
2472 | // Work out the matched length. | 2470 | // Work out the matched length. |
2473 | if (index != -1) | 2471 | if (index != -1) |
2474 | { | 2472 | { |
2475 | if (regExp) { | 2473 | if (regExp) { |
2476 | m_regExp.match(text, index, &matchedLength, false); | 2474 | m_regExp.match(text, index, &matchedLength, false); |
2477 | } | 2475 | } |
2478 | else { | 2476 | else { |
2479 | matchedLength = m_pattern.length(); | 2477 | matchedLength = m_pattern.length(); |
2480 | } | 2478 | } |
2481 | } | 2479 | } |
2482 | return index; | 2480 | return index; |
2483 | } | 2481 | } |
2484 | 2482 | ||
2485 | void KateView::setActive (bool b) | 2483 | void KateView::setActive (bool b) |
2486 | { | 2484 | { |
2487 | active = b; | 2485 | active = b; |
2488 | } | 2486 | } |
2489 | 2487 | ||
2490 | bool KateView::isActive () | 2488 | bool KateView::isActive () |
2491 | { | 2489 | { |
2492 | return active; | 2490 | return active; |
2493 | } | 2491 | } |
2494 | 2492 | ||
2495 | void KateView::setFocus () | 2493 | void KateView::setFocus () |
2496 | { | 2494 | { |
2497 | QWidget::setFocus (); | 2495 | QWidget::setFocus (); |
2498 | 2496 | ||
2499 | emit gotFocus (this); | 2497 | emit gotFocus (this); |
2500 | } | 2498 | } |
2501 | 2499 | ||
2502 | bool KateView::eventFilter (QObject *object, QEvent *event) | 2500 | bool KateView::eventFilter (QObject *object, QEvent *event) |
2503 | { | 2501 | { |
2504 | 2502 | ||
2505 | if ( (event->type() == QEvent::FocusIn) ) | 2503 | if ( (event->type() == QEvent::FocusIn) ) |
2506 | emit gotFocus (this); | 2504 | emit gotFocus (this); |
2507 | 2505 | ||
2508 | if ( (event->type() == QEvent::KeyPress) ) | 2506 | if ( (event->type() == QEvent::KeyPress) ) |
2509 | { | 2507 | { |
2510 | QKeyEvent * ke=(QKeyEvent *)event; | 2508 | QKeyEvent * ke=(QKeyEvent *)event; |
2511 | 2509 | ||
2512 | if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab)) | 2510 | if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab)) |
2513 | { | 2511 | { |
2514 | myViewInternal->keyPressEvent(ke); | 2512 | myViewInternal->keyPressEvent(ke); |
2515 | return true; | 2513 | return true; |
2516 | } | 2514 | } |
2517 | } | 2515 | } |
2518 | return QWidget::eventFilter (object, event); | 2516 | return QWidget::eventFilter (object, event); |
2519 | } | 2517 | } |
2520 | 2518 | ||
2521 | void KateView::findAgain (bool back) | 2519 | void KateView::findAgain (bool back) |
2522 | { | 2520 | { |
2523 | bool b= (searchFlags & sfBackward) > 0; | 2521 | bool b= (searchFlags & sfBackward) > 0; |
2524 | initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching | 2522 | initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching |
2525 | | sfPrompt | sfAgain | ((b!=back)?sfBackward:0) ); | 2523 | | sfPrompt | sfAgain | ((b!=back)?sfBackward:0) ); |
2526 | if (s.flags & sfReplace) | 2524 | if (s.flags & sfReplace) |
2527 | replaceAgain(); | 2525 | replaceAgain(); |
2528 | else | 2526 | else |
2529 | KateView::findAgain(s); | 2527 | KateView::findAgain(s); |
2530 | } | 2528 | } |
2531 | 2529 | ||
2532 | void KateView::slotEditCommand () | 2530 | void KateView::slotEditCommand () |
2533 | { | 2531 | { |
2534 | #warning fixme | 2532 | #warning fixme |
2535 | /* | 2533 | /* |
2536 | bool ok; | 2534 | bool ok; |
2537 | QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this); | 2535 | QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this); |
2538 | 2536 | ||
2539 | if (ok) | 2537 | if (ok) |
2540 | myDoc->cmd()->execCmd (cmd, this);*/ | 2538 | myDoc->cmd()->execCmd (cmd, this);*/ |
2541 | } | 2539 | } |
2542 | 2540 | ||
2543 | void KateView::setIconBorder (bool enable) | 2541 | void KateView::setIconBorder (bool enable) |
2544 | { | 2542 | { |
2545 | myIconBorder = enable; | 2543 | myIconBorder = enable; |
2546 | 2544 | ||
2547 | if (myIconBorder) | 2545 | if (myIconBorder) |
2548 | { | 2546 | { |
2549 | myViewInternal->move(myViewInternal->iconBorderWidth+2, 2); | 2547 | myViewInternal->move(myViewInternal->iconBorderWidth+2, 2); |
2550 | myViewInternal->leftBorder->show(); | 2548 | myViewInternal->leftBorder->show(); |
2551 | } | 2549 | } |
2552 | else | 2550 | else |
2553 | { | 2551 | { |
2554 | myViewInternal->leftBorder->hide(); | 2552 | myViewInternal->leftBorder->hide(); |
2555 | myViewInternal->move(2, 2); | 2553 | myViewInternal->move(2, 2); |
2556 | } | 2554 | } |
2557 | } | 2555 | } |
2558 | 2556 | ||
2559 | void KateView::toggleIconBorder () | 2557 | void KateView::toggleIconBorder () |
2560 | { | 2558 | { |
2561 | setIconBorder (!myIconBorder); | 2559 | setIconBorder (!myIconBorder); |
2562 | } | 2560 | } |
2563 | 2561 | ||
2564 | void KateView::gotoMark (Kate::Mark *mark) | 2562 | void KateView::gotoMark (Kate::Mark *mark) |
2565 | { | 2563 | { |
2566 | PointStruc cursor; | 2564 | PointStruc cursor; |
2567 | 2565 | ||
2568 | cursor.x = 0; | 2566 | cursor.x = 0; |
2569 | cursor.y = mark->line; | 2567 | cursor.y = mark->line; |
2570 | myDoc->needPreHighlight(cursor.y); | 2568 | myDoc->needPreHighlight(cursor.y); |
2571 | myViewInternal->updateCursor(cursor); | 2569 | myViewInternal->updateCursor(cursor); |
2572 | myViewInternal->center(); | 2570 | myViewInternal->center(); |
2573 | myViewInternal->updateView(KateView::ufUpdateOnScroll); | 2571 | myViewInternal->updateView(KateView::ufUpdateOnScroll); |
2574 | myDoc->updateViews(this); | 2572 | myDoc->updateViews(this); |
2575 | } | 2573 | } |
2576 | 2574 | ||
2577 | void KateView::toggleBookmark () | 2575 | void KateView::toggleBookmark () |
2578 | { | 2576 | { |
2579 | TextLine::Ptr line = myDoc->getTextLine (currentLine()); | 2577 | TextLine::Ptr line = myDoc->getTextLine (currentLine()); |
2580 | 2578 | ||
2581 | if (line->mark()&KateDocument::Bookmark) | 2579 | if (line->mark()&KateDocument::Bookmark) |
2582 | line->delMark(KateDocument::Bookmark); | 2580 | line->delMark(KateDocument::Bookmark); |
2583 | else | 2581 | else |
2584 | line->addMark(KateDocument::Bookmark); | 2582 | line->addMark(KateDocument::Bookmark); |
2585 | 2583 | ||
2586 | myDoc->tagLines (currentLine(), currentLine()); | 2584 | myDoc->tagLines (currentLine(), currentLine()); |
2587 | myDoc->updateViews(); | 2585 | myDoc->updateViews(); |
2588 | } | 2586 | } |
2589 | 2587 | ||
2590 | void KateView::clearBookmarks() | 2588 | void KateView::clearBookmarks() |
2591 | { | 2589 | { |
2592 | QList<Kate::Mark> list = myDoc->marks(); | 2590 | QList<Kate::Mark> list = myDoc->marks(); |
2593 | for (int i=0; (uint) i < list.count(); i++) | 2591 | for (int i=0; (uint) i < list.count(); i++) |
2594 | { | 2592 | { |
2595 | if (list.at(i)->type&KateDocument::Bookmark) | 2593 | if (list.at(i)->type&KateDocument::Bookmark) |
2596 | { | 2594 | { |
2597 | myDoc->getTextLine(list.at(i)->line)->delMark(KateDocument::Bookmark); | 2595 | myDoc->getTextLine(list.at(i)->line)->delMark(KateDocument::Bookmark); |
2598 | myDoc->tagLines(list.at(i)->line, list.at(i)->line); | 2596 | myDoc->tagLines(list.at(i)->line, list.at(i)->line); |
2599 | } | 2597 | } |
2600 | } | 2598 | } |
2601 | 2599 | ||
2602 | myDoc->updateViews(); | 2600 | myDoc->updateViews(); |
2603 | } | 2601 | } |
2604 | 2602 | ||
2605 | void KateView::bookmarkMenuAboutToShow() | 2603 | void KateView::bookmarkMenuAboutToShow() |
2606 | { | 2604 | { |
2607 | #warning fixme | 2605 | #warning fixme |
2608 | #if 0 | 2606 | #if 0 |
2609 | bookmarkMenu->popupMenu()->clear (); | 2607 | bookmarkMenu->popupMenu()->clear (); |
2610 | bookmarkToggle->plug (bookmarkMenu->popupMenu()); | 2608 | bookmarkToggle->plug (bookmarkMenu->popupMenu()); |
2611 | bookmarkClear->plug (bookmarkMenu->popupMenu()); | 2609 | bookmarkClear->plug (bookmarkMenu->popupMenu()); |
2612 | bookmarkMenu->popupMenu()->insertSeparator (); | 2610 | bookmarkMenu->popupMenu()->insertSeparator (); |
2613 | 2611 | ||
2614 | list = myDoc->marks(); | 2612 | list = myDoc->marks(); |
2615 | for (int i=0; (uint) i < list.count(); i++) | 2613 | for (int i=0; (uint) i < list.count(); i++) |
2616 | { | 2614 | { |
2617 | if (list.at(i)->type&KateDocument::Bookmark) | 2615 | if (list.at(i)->type&KateDocument::Bookmark) |
2618 | { | 2616 | { |
2619 | QString bText = textLine(list.at(i)->line); | 2617 | QString bText = textLine(list.at(i)->line); |
2620 | bText.truncate(32); | 2618 | bText.truncate(32); |
2621 | bText.append ("..."); | 2619 | bText.append ("..."); |
2622 | bookmarkMenu->popupMenu()->insertItem ( QString("%1 - \"%2\"").arg(list.at(i)->line).arg(bText), this, SLOT (gotoBookmark(int)), 0, i ); | 2620 | bookmarkMenu->popupMenu()->insertItem ( QString("%1 - \"%2\"").arg(list.at(i)->line).arg(bText), this, SLOT (gotoBookmark(int)), 0, i ); |
2623 | } | 2621 | } |
2624 | } | 2622 | } |
2625 | #endif | 2623 | #endif |
2626 | } | 2624 | } |
2627 | 2625 | ||
2628 | void KateView::gotoBookmark (int n) | 2626 | void KateView::gotoBookmark (int n) |
2629 | { | 2627 | { |
2630 | gotoMark (list.at(n)); | 2628 | gotoMark (list.at(n)); |
2631 | } | 2629 | } |
2632 | 2630 | ||
2633 | int KateView::getHlCount () | 2631 | int KateView::getHlCount () |
2634 | { | 2632 | { |
2635 | return HlManager::self()->highlights(); | 2633 | return HlManager::self()->highlights(); |
2636 | } | 2634 | } |
2637 | 2635 | ||
2638 | QString KateView::getHlName (int z) | 2636 | QString KateView::getHlName (int z) |
2639 | { | 2637 | { |
2640 | return HlManager::self()->hlName(z); | 2638 | return HlManager::self()->hlName(z); |
2641 | } | 2639 | } |
2642 | 2640 | ||
2643 | QString KateView::getHlSection (int z) | 2641 | QString KateView::getHlSection (int z) |
2644 | { | 2642 | { |
2645 | return HlManager::self()->hlSection (z); | 2643 | return HlManager::self()->hlSection (z); |
2646 | } | 2644 | } |
2647 | 2645 | ||
2648 | void KateView::slotIncFontSizes () | 2646 | void KateView::slotIncFontSizes () |
2649 | { | 2647 | { |
2650 | QFont font = myDoc->getFont(); | 2648 | QFont font = myDoc->getFont(); |
2651 | font.setPointSize (font.pointSize()+2); | 2649 | font.setPointSize (font.pointSize()+2); |
2652 | myDoc->setFont (font); | 2650 | myDoc->setFont (font); |
2653 | } | 2651 | } |
2654 | 2652 | ||
2655 | void KateView::slotDecFontSizes () | 2653 | void KateView::slotDecFontSizes () |
2656 | { | 2654 | { |
2657 | QFont font = myDoc->getFont(); | 2655 | QFont font = myDoc->getFont(); |
2658 | font.setPointSize (font.pointSize()-2); | 2656 | font.setPointSize (font.pointSize()-2); |
2659 | myDoc->setFont (font); | 2657 | myDoc->setFont (font); |
2660 | } | 2658 | } |
2661 | 2659 | ||
2662 | const char*bookmark_xpm[]={ | 2660 | const char*bookmark_xpm[]={ |
2663 | "12 16 4 1", | 2661 | "12 16 4 1", |
2664 | "b c #808080", | 2662 | "b c #808080", |
2665 | "a c #000080", | 2663 | "a c #000080", |
2666 | "# c #0000ff", | 2664 | "# c #0000ff", |
2667 | ". c None", | 2665 | ". c None", |
2668 | "............", | 2666 | "............", |
2669 | "............", | 2667 | "............", |
2670 | "........###.", | 2668 | "........###.", |
2671 | ".......#...a", | 2669 | ".......#...a", |
2672 | "......#.##.a", | 2670 | "......#.##.a", |
2673 | ".....#.#..aa", | 2671 | ".....#.#..aa", |
2674 | "....#.#...a.", | 2672 | "....#.#...a.", |
2675 | "...#.#.a.a..", | 2673 | "...#.#.a.a..", |
2676 | "..#.#.a.a...", | 2674 | "..#.#.a.a...", |
2677 | ".#.#.a.a....", | 2675 | ".#.#.a.a....", |
2678 | "#.#.a.a.....", | 2676 | "#.#.a.a.....", |
2679 | "#.#a.a...bbb", | 2677 | "#.#a.a...bbb", |
2680 | "#...a..bbb..", | 2678 | "#...a..bbb..", |
2681 | ".aaa.bbb....", | 2679 | ".aaa.bbb....", |
2682 | "............", | 2680 | "............", |
2683 | "............"}; | 2681 | "............"}; |
2684 | 2682 | ||
2685 | const char* breakpoint_xpm[]={ | 2683 | const char* breakpoint_xpm[]={ |
2686 | "11 16 6 1", | 2684 | "11 16 6 1", |
2687 | "c c #c6c6c6", | 2685 | "c c #c6c6c6", |
2688 | ". c None", | 2686 | ". c None", |
2689 | "# c #000000", | 2687 | "# c #000000", |
2690 | "d c #840000", | 2688 | "d c #840000", |
2691 | "a c #ffffff", | 2689 | "a c #ffffff", |
2692 | "b c #ff0000", | 2690 | "b c #ff0000", |
2693 | "...........", | 2691 | "...........", |
2694 | "...........", | 2692 | "...........", |
2695 | "...#####...", | 2693 | "...#####...", |
2696 | "..#aaaaa#..", | 2694 | "..#aaaaa#..", |
2697 | ".#abbbbbb#.", | 2695 | ".#abbbbbb#.", |
2698 | "#abbbbbbbb#", | 2696 | "#abbbbbbbb#", |
2699 | "#abcacacbd#", | 2697 | "#abcacacbd#", |
2700 | "#abbbbbbbb#", | 2698 | "#abbbbbbbb#", |
2701 | "#abcacacbd#", | 2699 | "#abcacacbd#", |
2702 | "#abbbbbbbb#", | 2700 | "#abbbbbbbb#", |
2703 | ".#bbbbbbb#.", | 2701 | ".#bbbbbbb#.", |
2704 | "..#bdbdb#..", | 2702 | "..#bdbdb#..", |
2705 | "...#####...", | 2703 | "...#####...", |
2706 | "...........", | 2704 | "...........", |
2707 | "...........", | 2705 | "...........", |
2708 | "..........."}; | 2706 | "..........."}; |
2709 | 2707 | ||
2710 | const char*breakpoint_bl_xpm[]={ | 2708 | const char*breakpoint_bl_xpm[]={ |
2711 | "11 16 7 1", | 2709 | "11 16 7 1", |
2712 | "a c #c0c0ff", | 2710 | "a c #c0c0ff", |
2713 | "# c #000000", | 2711 | "# c #000000", |
2714 | "c c #0000c0", | 2712 | "c c #0000c0", |
2715 | "e c #0000ff", | 2713 | "e c #0000ff", |
2716 | "b c #dcdcdc", | 2714 | "b c #dcdcdc", |
2717 | "d c #ffffff", | 2715 | "d c #ffffff", |
2718 | ". c None", | 2716 | ". c None", |
2719 | "...........", | 2717 | "...........", |
2720 | "...........", | 2718 | "...........", |
2721 | "...#####...", | 2719 | "...#####...", |
2722 | "..#ababa#..", | 2720 | "..#ababa#..", |
2723 | ".#bcccccc#.", | 2721 | ".#bcccccc#.", |
2724 | "#acccccccc#", | 2722 | "#acccccccc#", |
2725 | "#bcadadace#", | 2723 | "#bcadadace#", |
2726 | "#acccccccc#", | 2724 | "#acccccccc#", |
2727 | "#bcadadace#", | 2725 | "#bcadadace#", |
2728 | "#acccccccc#", | 2726 | "#acccccccc#", |
2729 | ".#ccccccc#.", | 2727 | ".#ccccccc#.", |
2730 | "..#cecec#..", | 2728 | "..#cecec#..", |
2731 | "...#####...", | 2729 | "...#####...", |
2732 | "...........", | 2730 | "...........", |
2733 | "...........", | 2731 | "...........", |
2734 | "..........."}; | 2732 | "..........."}; |
2735 | 2733 | ||
2736 | const char*breakpoint_gr_xpm[]={ | 2734 | const char*breakpoint_gr_xpm[]={ |
2737 | "11 16 6 1", | 2735 | "11 16 6 1", |
2738 | "c c #c6c6c6", | 2736 | "c c #c6c6c6", |
2739 | "d c #2c2c2c", | 2737 | "d c #2c2c2c", |
2740 | "# c #000000", | 2738 | "# c #000000", |
2741 | ". c None", | 2739 | ". c None", |
2742 | "a c #ffffff", | 2740 | "a c #ffffff", |
2743 | "b c #555555", | 2741 | "b c #555555", |
2744 | "...........", | 2742 | "...........", |
2745 | "...........", | 2743 | "...........", |
2746 | "...#####...", | 2744 | "...#####...", |
2747 | "..#aaaaa#..", | 2745 | "..#aaaaa#..", |
2748 | ".#abbbbbb#.", | 2746 | ".#abbbbbb#.", |
2749 | "#abbbbbbbb#", | 2747 | "#abbbbbbbb#", |
2750 | "#abcacacbd#", | 2748 | "#abcacacbd#", |
2751 | "#abbbbbbbb#", | 2749 | "#abbbbbbbb#", |
2752 | "#abcacacbd#", | 2750 | "#abcacacbd#", |
2753 | "#abbbbbbbb#", | 2751 | "#abbbbbbbb#", |
2754 | ".#bbbbbbb#.", | 2752 | ".#bbbbbbb#.", |
2755 | "..#bdbdb#..", | 2753 | "..#bdbdb#..", |
2756 | "...#####...", | 2754 | "...#####...", |
2757 | "...........", | 2755 | "...........", |
2758 | "...........", | 2756 | "...........", |
2759 | "..........."}; | 2757 | "..........."}; |
2760 | 2758 | ||
2761 | const char*ddd_xpm[]={ | 2759 | const char*ddd_xpm[]={ |
2762 | "11 16 4 1", | 2760 | "11 16 4 1", |
2763 | "a c #00ff00", | 2761 | "a c #00ff00", |
2764 | "b c #000000", | 2762 | "b c #000000", |
2765 | ". c None", | 2763 | ". c None", |
2766 | "# c #00c000", | 2764 | "# c #00c000", |
2767 | "...........", | 2765 | "...........", |
2768 | "...........", | 2766 | "...........", |
2769 | "...........", | 2767 | "...........", |
2770 | "#a.........", | 2768 | "#a.........", |
2771 | "#aaa.......", | 2769 | "#aaa.......", |
2772 | "#aaaaa.....", | 2770 | "#aaaaa.....", |
2773 | "#aaaaaaa...", | 2771 | "#aaaaaaa...", |
2774 | "#aaaaaaaaa.", | 2772 | "#aaaaaaaaa.", |
2775 | "#aaaaaaa#b.", | 2773 | "#aaaaaaa#b.", |
2776 | "#aaaaa#b...", | 2774 | "#aaaaa#b...", |
2777 | "#aaa#b.....", | 2775 | "#aaa#b.....", |
2778 | "#a#b.......", | 2776 | "#a#b.......", |
2779 | "#b.........", | 2777 | "#b.........", |
2780 | "...........", | 2778 | "...........", |
2781 | "...........", | 2779 | "...........", |
2782 | "..........."}; | 2780 | "..........."}; |
2783 | 2781 | ||
2784 | 2782 | ||
2785 | 2783 | ||
2786 | KateIconBorder::KateIconBorder(KateView *view, KateViewInternal *internalView) | 2784 | KateIconBorder::KateIconBorder(KateView *view, KateViewInternal *internalView) |
2787 | : QWidget(view), myView(view), myInternalView(internalView) | 2785 | : QWidget(view), myView(view), myInternalView(internalView) |
2788 | { | 2786 | { |
2789 | lmbSetsBreakpoints = true; | 2787 | lmbSetsBreakpoints = true; |
2790 | } | 2788 | } |
2791 | 2789 | ||
2792 | KateIconBorder::~KateIconBorder() | 2790 | KateIconBorder::~KateIconBorder() |
2793 | { | 2791 | { |
2794 | } | 2792 | } |
2795 | 2793 | ||
2796 | void KateIconBorder::paintLine(int i) | 2794 | void KateIconBorder::paintLine(int i) |
2797 | { | 2795 | { |
2798 | if (!myView->myIconBorder) return; | 2796 | if (!myView->myIconBorder) return; |
2799 | 2797 | ||
2800 | QPainter p(this); | 2798 | QPainter p(this); |
2801 | 2799 | ||
2802 | int fontHeight = myView->doc()->fontHeight; | 2800 | int fontHeight = myView->doc()->fontHeight; |
2803 | int y = i*fontHeight - myInternalView->yPos; | 2801 | int y = i*fontHeight - myInternalView->yPos; |
2804 | p.fillRect(0, y, myInternalView->iconBorderWidth-2, fontHeight, colorGroup().background()); | 2802 | p.fillRect(0, y, myInternalView->iconBorderWidth-2, fontHeight, colorGroup().background()); |
2805 | p.setPen(white); | 2803 | p.setPen(white); |
2806 | p.drawLine(myInternalView->iconBorderWidth-2, y, myInternalView->iconBorderWidth-2, y + fontHeight); | 2804 | p.drawLine(myInternalView->iconBorderWidth-2, y, myInternalView->iconBorderWidth-2, y + fontHeight); |
2807 | p.setPen(QColor(colorGroup().background()).dark()); | 2805 | p.setPen(QColor(colorGroup().background()).dark()); |
2808 | p.drawLine(myInternalView->iconBorderWidth-1, y, myInternalView->iconBorderWidth-1, y + fontHeight); | 2806 | p.drawLine(myInternalView->iconBorderWidth-1, y, myInternalView->iconBorderWidth-1, y + fontHeight); |
2809 | 2807 | ||
2810 | TextLine *line = myView->doc()->getTextLine(i); | 2808 | TextLine *line = myView->doc()->getTextLine(i); |
2811 | if (!line) | 2809 | if (!line) |
2812 | return; | 2810 | return; |
2813 | 2811 | ||
2814 | if (line->mark()&KateDocument::Bookmark) | 2812 | if (line->mark()&KateDocument::Bookmark) |
2815 | p.drawPixmap(2, y, QPixmap(bookmark_xpm)); /* | 2813 | p.drawPixmap(2, y, QPixmap(bookmark_xpm)); /* |
2816 | if (line && (line->breakpointId() != -1)) { | 2814 | if (line && (line->breakpointId() != -1)) { |
2817 | if (!line->breakpointEnabled()) | 2815 | if (!line->breakpointEnabled()) |
2818 | p.drawPixmap(2, y, QPixmap(breakpoint_gr_xpm)); | 2816 | p.drawPixmap(2, y, QPixmap(breakpoint_gr_xpm)); |
2819 | else if (line->breakpointPending()) | 2817 | else if (line->breakpointPending()) |
2820 | p.drawPixmap(2, y, QPixmap(breakpoint_bl_xpm)); | 2818 | p.drawPixmap(2, y, QPixmap(breakpoint_bl_xpm)); |
2821 | else | 2819 | else |
2822 | p.drawPixmap(2, y, QPixmap(breakpoint_xpm)); | 2820 | p.drawPixmap(2, y, QPixmap(breakpoint_xpm)); |
2823 | } | 2821 | } |
2824 | if (line->isExecutionPoint()) | 2822 | if (line->isExecutionPoint()) |
2825 | p.drawPixmap(2, y, QPixmap(ddd_xpm)); */ | 2823 | p.drawPixmap(2, y, QPixmap(ddd_xpm)); */ |
2826 | } | 2824 | } |
2827 | 2825 | ||
2828 | 2826 | ||
2829 | void KateIconBorder::paintEvent(QPaintEvent* e) | 2827 | void KateIconBorder::paintEvent(QPaintEvent* e) |
2830 | { | 2828 | { |
2831 | if (!myView->myIconBorder) return; | 2829 | if (!myView->myIconBorder) return; |
2832 | 2830 | ||
2833 | int lineStart = 0; | 2831 | int lineStart = 0; |
2834 | int lineEnd = 0; | 2832 | int lineEnd = 0; |
2835 | 2833 | ||
2836 | QRect updateR = e->rect(); | 2834 | QRect updateR = e->rect(); |
2837 | 2835 | ||
2838 | KateDocument *doc = myView->doc(); | 2836 | KateDocument *doc = myView->doc(); |
2839 | int h = doc->fontHeight; | 2837 | int h = doc->fontHeight; |
2840 | int yPos = myInternalView->yPos; | 2838 | int yPos = myInternalView->yPos; |
2841 | if (h) { | 2839 | if (h) { |
2842 | lineStart = (yPos + updateR.y()) / h; | 2840 | lineStart = (yPos + updateR.y()) / h; |
2843 | lineEnd = QMAX((yPos + updateR.y() + updateR.height()) / h, (int)doc->numLines()); | 2841 | lineEnd = QMAX((yPos + updateR.y() + updateR.height()) / h, (int)doc->numLines()); |
2844 | } | 2842 | } |
2845 | 2843 | ||
2846 | for(int i = lineStart; i <= lineEnd; ++i) | 2844 | for(int i = lineStart; i <= lineEnd; ++i) |
2847 | paintLine(i); | 2845 | paintLine(i); |
2848 | } | 2846 | } |
2849 | 2847 | ||
2850 | 2848 | ||
2851 | void KateIconBorder::mousePressEvent(QMouseEvent* e) | 2849 | void KateIconBorder::mousePressEvent(QMouseEvent* e) |
2852 | { | 2850 | { |
2853 | myInternalView->placeCursor( 0, e->y(), 0 ); | 2851 | myInternalView->placeCursor( 0, e->y(), 0 ); |
2854 | 2852 | ||
2855 | KateDocument *doc = myView->doc(); | 2853 | KateDocument *doc = myView->doc(); |
2856 | int cursorOnLine = (e->y() + myInternalView->yPos) / doc->fontHeight; | 2854 | int cursorOnLine = (e->y() + myInternalView->yPos) / doc->fontHeight; |
2857 | TextLine *line = doc->getTextLine(cursorOnLine); | 2855 | TextLine *line = doc->getTextLine(cursorOnLine); |
2858 | 2856 | ||
2859 | switch (e->button()) { | 2857 | switch (e->button()) { |
2860 | case LeftButton: | 2858 | case LeftButton: |
2861 | if (!line) | 2859 | if (!line) |
2862 | break; | 2860 | break; |
2863 | else | 2861 | else |
2864 | { | 2862 | { |
2865 | if (line->mark()&KateDocument::Bookmark) | 2863 | if (line->mark()&KateDocument::Bookmark) |
2866 | line->delMark (KateDocument::Bookmark); | 2864 | line->delMark (KateDocument::Bookmark); |
2867 | else | 2865 | else |
2868 | line->addMark (KateDocument::Bookmark); | 2866 | line->addMark (KateDocument::Bookmark); |
2869 | 2867 | ||
2870 | doc->tagLines(cursorOnLine, cursorOnLine); | 2868 | doc->tagLines(cursorOnLine, cursorOnLine); |
2871 | doc->updateViews(); | 2869 | doc->updateViews(); |
2872 | } | 2870 | } |
2873 | break; | 2871 | break; |
2874 | /* case RightButton: | 2872 | /* case RightButton: |
2875 | { | 2873 | { |
2876 | if (!line) | 2874 | if (!line) |
2877 | break; | 2875 | break; |
2878 | KPopupMenu popup; | 2876 | KPopupMenu popup; |
2879 | popup.setCheckable(true); | 2877 | popup.setCheckable(true); |
2880 | popup.insertTitle(i18n("Breakpoints/Bookmarks")); | 2878 | popup.insertTitle(i18n("Breakpoints/Bookmarks")); |
2881 | int idToggleBookmark = popup.insertItem(i18n("Toggle bookmark")); | 2879 | int idToggleBookmark = popup.insertItem(i18n("Toggle bookmark")); |
2882 | popup.insertSeparator(); | 2880 | popup.insertSeparator(); |
2883 | int idToggleBreakpoint = popup.insertItem(i18n("Toggle breakpoint")); | 2881 | int idToggleBreakpoint = popup.insertItem(i18n("Toggle breakpoint")); |
2884 | int idEditBreakpoint = popup.insertItem(i18n("Edit breakpoint")); | 2882 | int idEditBreakpoint = popup.insertItem(i18n("Edit breakpoint")); |
2885 | int idEnableBreakpoint = popup.insertItem(i18n("Disable breakpoint")); | 2883 | int idEnableBreakpoint = popup.insertItem(i18n("Disable breakpoint")); |
2886 | popup.insertSeparator(); | 2884 | popup.insertSeparator(); |
2887 | popup.insertSeparator(); | 2885 | popup.insertSeparator(); |
2888 | int idLmbSetsBreakpoints = popup.insertItem(i18n("LMB sets breakpoints")); | 2886 | int idLmbSetsBreakpoints = popup.insertItem(i18n("LMB sets breakpoints")); |
2889 | int idLmbSetsBookmarks = popup.insertItem(i18n("LMB sets bookmarks")); | 2887 | int idLmbSetsBookmarks = popup.insertItem(i18n("LMB sets bookmarks")); |
2890 | 2888 | ||
2891 | popup.setItemChecked(idLmbSetsBreakpoints, lmbSetsBreakpoints); | 2889 | popup.setItemChecked(idLmbSetsBreakpoints, lmbSetsBreakpoints); |
2892 | popup.setItemChecked(idLmbSetsBookmarks, !lmbSetsBreakpoints); | 2890 | popup.setItemChecked(idLmbSetsBookmarks, !lmbSetsBreakpoints); |
2893 | 2891 | ||
2894 | if (line->breakpointId() == -1) { | 2892 | if (line->breakpointId() == -1) { |
2895 | popup.setItemEnabled(idEditBreakpoint, false); | 2893 | popup.setItemEnabled(idEditBreakpoint, false); |
2896 | popup.setItemEnabled(idEnableBreakpoint, false); | 2894 | popup.setItemEnabled(idEnableBreakpoint, false); |
2897 | popup.changeItem(idEnableBreakpoint, i18n("Enable breakpoint")); | 2895 | popup.changeItem(idEnableBreakpoint, i18n("Enable breakpoint")); |
2898 | } | 2896 | } |
2899 | int res = popup.exec(mapToGlobal(e->pos())); | 2897 | int res = popup.exec(mapToGlobal(e->pos())); |
2900 | if (res == idToggleBookmark) { | 2898 | if (res == idToggleBookmark) { |
2901 | line->toggleBookmark(); | 2899 | line->toggleBookmark(); |
2902 | doc->tagLines(cursorOnLine, cursorOnLine); | 2900 | doc->tagLines(cursorOnLine, cursorOnLine); |
2903 | doc->updateViews(); | 2901 | doc->updateViews(); |
2904 | } else if (res == idToggleBreakpoint) | 2902 | } else if (res == idToggleBreakpoint) |
2905 | emit myView->toggledBreakpoint(cursorOnLine); | 2903 | emit myView->toggledBreakpoint(cursorOnLine); |
2906 | else if (res == idEditBreakpoint) | 2904 | else if (res == idEditBreakpoint) |
2907 | emit myView->editedBreakpoint(cursorOnLine); | 2905 | emit myView->editedBreakpoint(cursorOnLine); |
2908 | else if (res == idEnableBreakpoint) | 2906 | else if (res == idEnableBreakpoint) |
2909 | emit myView->toggledBreakpointEnabled(cursorOnLine+1); | 2907 | emit myView->toggledBreakpointEnabled(cursorOnLine+1); |
2910 | else if (res == idLmbSetsBreakpoints || res == idLmbSetsBookmarks) | 2908 | else if (res == idLmbSetsBreakpoints || res == idLmbSetsBookmarks) |
2911 | lmbSetsBreakpoints = !lmbSetsBreakpoints; | 2909 | lmbSetsBreakpoints = !lmbSetsBreakpoints; |
2912 | break; | 2910 | break; |
2913 | } | 2911 | } |
2914 | case MidButton: | 2912 | case MidButton: |
2915 | line->toggleBookmark(); | 2913 | line->toggleBookmark(); |
2916 | doc->tagLines(cursorOnLine, cursorOnLine); | 2914 | doc->tagLines(cursorOnLine, cursorOnLine); |
2917 | doc->updateViews(); | 2915 | doc->updateViews(); |
2918 | break; */ | 2916 | break; */ |
2919 | default: | 2917 | default: |
2920 | break; | 2918 | break; |
2921 | } | 2919 | } |
2922 | } | 2920 | } |
2923 | 2921 | ||
2924 | 2922 | ||
2925 | 2923 | ||
diff --git a/noncore/apps/tinykate/main.cpp b/noncore/apps/tinykate/main.cpp index e92df69..e06668a 100644 --- a/noncore/apps/tinykate/main.cpp +++ b/noncore/apps/tinykate/main.cpp | |||
@@ -1,29 +1,28 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | main.cpp | 2 | main.cpp |
3 | ------------------- | 3 | ------------------- |
4 | begin : November 2002 | 4 | begin : November 2002 |
5 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> | 5 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> |
6 | ***************************************************************************/ | 6 | ***************************************************************************/ |
7 | 7 | ||
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation. * | 12 | * the Free Software Foundation. * |
13 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * | 13 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | #include <qmainwindow.h> | 17 | #include <qmainwindow.h> |
18 | #include "tinykate.h" | 18 | #include "tinykate.h" |
19 | 19 | ||
20 | 20 | ||
21 | int main( int argc, char ** argv ) | 21 | int main( int argc, char ** argv ) |
22 | { | 22 | { |
23 | QPEApplication a( argc, argv ); | 23 | QPEApplication a( argc, argv ); |
24 | 24 | ||
25 | TinyKate *m = new TinyKate(); | 25 | TinyKate m; |
26 | a.setMainWidget( m ); | 26 | a.showMainWidget(&m ); |
27 | m->showMaximized(); | ||
28 | return a.exec(); | 27 | return a.exec(); |
29 | } | 28 | } |
diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-commondev.control b/noncore/apps/tinykate/opie-tinykate-syntax-commondev.control index 76704c1..dd5e24b 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-commondev.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-commondev.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-tinykate-syntax-commondev | 1 | Package: opie-tinykate-syntax-commondev |
2 | Files: share/tinykate/syntax/c.xml share/tinykate/syntax/cpp.xml share/tinykate/syntax/gnuassembler.xml share/tinykate/syntax/kbasic.xml share/tinykate/syntax/pascal.xml share/tinykate/syntax/perl.xml share/tinykate/syntax/php.xml share/tinykate/syntax/python.xml share/tinykate/syntax/ruby.xml share/tinykate/syntax/sql.xml share/tinykate/syntax/tcl.xml share/tinykate/syntax/xml.xml share/tinykate/syntax/xmldebug.xml share/tinykate/syntax/java.xml | 2 | Files: share/tinykate/syntax/c.xml share/tinykate/syntax/cpp.xml share/tinykate/syntax/gnuassembler.xml share/tinykate/syntax/kbasic.xml share/tinykate/syntax/pascal.xml share/tinykate/syntax/perl.xml share/tinykate/syntax/php.xml share/tinykate/syntax/python.xml share/tinykate/syntax/ruby.xml share/tinykate/syntax/sql.xml share/tinykate/syntax/tcl.xml share/tinykate/syntax/xml.xml share/tinykate/syntax/xmldebug.xml share/tinykate/syntax/java.xml |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal, opie-tinykate | 7 | Depends: task-opie-minimal, opie-tinykate |
9 | Description: Syntax Highlighting Patterns for for common programming languages for TinyKate | 8 | Description: Syntax Highlighting Patterns for for common programming languages for TinyKate |
9 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-documentation.control b/noncore/apps/tinykate/opie-tinykate-syntax-documentation.control index 9f60156..c47acc0 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-documentation.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-documentation.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-tinykate-syntax-documentation | 1 | Package: opie-tinykate-syntax-documentation |
2 | Files: share/tinykate/syntax/latex.xml share/tinykate/syntax/postscript.xml share/tinykate/syntax/sgml.xml | 2 | Files: share/tinykate/syntax/latex.xml share/tinykate/syntax/postscript.xml share/tinykate/syntax/sgml.xml |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal, opie-tinykate | 7 | Depends: task-opie-minimal, opie-tinykate |
9 | Description: Syntax Highlighting Patterns for document oriented languages for TinyKate | 8 | Description: Syntax Highlighting Patterns for document oriented languages for TinyKate |
9 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-misc.control b/noncore/apps/tinykate/opie-tinykate-syntax-misc.control index 4e0f529..0e80518 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-misc.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-misc.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-tinykate-syntax-misc | 1 | Package: opie-tinykate-syntax-misc |
2 | Files: share/tinykate/syntax/idconsole.xml share/tinykate/syntax/matlab.xml share/tinykate/syntax/verilog.xml share/tinykate/syntax/vhdl.xml | 2 | Files: share/tinykate/syntax/idconsole.xml share/tinykate/syntax/matlab.xml share/tinykate/syntax/verilog.xml share/tinykate/syntax/vhdl.xml |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal, opie-tinykate | 7 | Depends: task-opie-minimal, opie-tinykate |
9 | Description: Syntax Highlighting Patterns for misc languages for TinyKate | 8 | Description: Syntax Highlighting Patterns for misc languages for TinyKate |
9 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-miscdev.control b/noncore/apps/tinykate/opie-tinykate-syntax-miscdev.control index 3c8f61a..3f7ea0d 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-miscdev.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-miscdev.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-tinykate-syntax-miscdev | 1 | Package: opie-tinykate-syntax-miscdev |
2 | Files: share/tinykate/syntax/ada.xml share/tinykate/syntax/eiffel.xml share/tinykate/syntax/ferite.xml share/tinykate/syntax/fortran.xml share/tinykate/syntax/haskell.xml share/tinykate/syntax/literate-haskell.xml share/tinykate/syntax/objectivec.xml share/tinykate/syntax/sather.xml share/tinykate/syntax/scheme.xml | 2 | Files: share/tinykate/syntax/ada.xml share/tinykate/syntax/eiffel.xml share/tinykate/syntax/ferite.xml share/tinykate/syntax/fortran.xml share/tinykate/syntax/haskell.xml share/tinykate/syntax/literate-haskell.xml share/tinykate/syntax/objectivec.xml share/tinykate/syntax/sather.xml share/tinykate/syntax/scheme.xml |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal, opie-tinykate | 7 | Depends: task-opie-minimal, opie-tinykate |
9 | Description: Syntax Highlighting Patterns for for uncommon programming languages for TinyKate | 8 | Description: Syntax Highlighting Patterns for for uncommon programming languages for TinyKate |
9 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-unix.control b/noncore/apps/tinykate/opie-tinykate-syntax-unix.control index 36e88b5..ea4e026 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-unix.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-unix.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-tinykate-syntax-unix | 1 | Package: opie-tinykate-syntax-unix |
2 | Files: share/tinykate/syntax/cs.xml share/tinykate/syntax/bash.xml share/tinykate/syntax/changelog.xml share/tinykate/syntax/desktop.xml share/tinykate/syntax/diff.xml share/tinykate/syntax/mab.xml share/tinykate/syntax/makefile.xml share/tinykate/syntax/rpmspec.xml share/tinykate/syntax/sml.xml share/tinykate/syntax/winehq.xml | 2 | Files: share/tinykate/syntax/cs.xml share/tinykate/syntax/bash.xml share/tinykate/syntax/changelog.xml share/tinykate/syntax/desktop.xml share/tinykate/syntax/diff.xml share/tinykate/syntax/mab.xml share/tinykate/syntax/makefile.xml share/tinykate/syntax/rpmspec.xml share/tinykate/syntax/sml.xml share/tinykate/syntax/winehq.xml |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal, opie-tinykate | 7 | Depends: task-opie-minimal, opie-tinykate |
9 | Description: Syntax Highlighting Patterns for UNIX/Linux specific files for TinyKate | 8 | Description: Syntax Highlighting Patterns for UNIX/Linux specific files for TinyKate |
9 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-web.control b/noncore/apps/tinykate/opie-tinykate-syntax-web.control index 46fe64a..8f9c71a 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-web.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-web.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-tinykate-syntax-web | 1 | Package: opie-tinykate-syntax-web |
2 | Files: share/tinykate/syntax/css.xml share/tinykate/syntax/html.xml share/tinykate/syntax/javascript.xml | 2 | Files: share/tinykate/syntax/css.xml share/tinykate/syntax/html.xml share/tinykate/syntax/javascript.xml |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal, opie-tinykate | 7 | Depends: task-opie-minimal, opie-tinykate |
9 | Description: Syntax Highlighting Patterns for for common programming languages for TinyKate | 8 | Description: Syntax Highlighting Patterns for for common programming languages for TinyKate |
9 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/tinykate/opie-tinykate-syntax.control b/noncore/apps/tinykate/opie-tinykate-syntax.control index c4156fc..712933c 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-tinykate-syntax | 1 | Package: opie-tinykate-syntax |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: Opie Team <opie@handhelds.org> | 4 | Maintainer: Opie Team <opie@handhelds.org> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | ||
7 | Depends: task-opie-minimal, opie-tinykate, opie-tinykate-syntax-commondev, opie-tinykate-syntax-documentation, opie-tinykate-syntax-misc, opie-tinykate-syntax-miscdev, opie-tinykate-syntax-unix, opie-tinykate-syntax-web | 6 | Depends: task-opie-minimal, opie-tinykate, opie-tinykate-syntax-commondev, opie-tinykate-syntax-documentation, opie-tinykate-syntax-misc, opie-tinykate-syntax-miscdev, opie-tinykate-syntax-unix, opie-tinykate-syntax-web |
8 | Description: Syntax Highlighting Patterns virtual package, which installs all available syntax patterns. | 7 | Description: Syntax Highlighting Patterns virtual package, which installs all available syntax patterns. |
9 | Files: | 8 | Files: |
9 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/tinykate/opie-tinykate.control b/noncore/apps/tinykate/opie-tinykate.control index 95dd7e0..731375c 100644 --- a/noncore/apps/tinykate/opie-tinykate.control +++ b/noncore/apps/tinykate/opie-tinykate.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-tinykate | 1 | Package: opie-tinykate |
2 | Files: bin/tinykate apps/Applications/tinykate.desktop pics/tinykate $OPIEDIR/lib/libtinykate.so.1.0.0 $OPIEDIR/lib/libtinykate.so.1.0 $OPIEDIR/lib/libtinykate.so.1 | 2 | Files: bin/tinykate apps/Applications/tinykate.desktop pics/tinykate $OPIEDIR/lib/libtinykate.so.1.0.0 $OPIEDIR/lib/libtinykate.so.1.0 $OPIEDIR/lib/libtinykate.so.1 |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal | 7 | Depends: task-opie-minimal |
9 | Description: Kate for opie | 8 | Description: Kate for opie |
9 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp index dda8405..f470645 100644 --- a/noncore/apps/tinykate/tinykate.cpp +++ b/noncore/apps/tinykate/tinykate.cpp | |||
@@ -1,321 +1,283 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | tinykate.cpp | 2 | tinykate.cpp |
3 | Tiny KATE mainwindow | 3 | Tiny KATE mainwindow |
4 | ------------------- | 4 | ------------------- |
5 | begin : November 2002 | 5 | begin : November 2002 |
6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> | 6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free softwaSre; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation. * | 13 | * the Free Software Foundation. * |
14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * | 14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | #include <qwidget.h> | 17 | #include <qwidget.h> |
18 | #include <qaction.h> | 18 | #include <qaction.h> |
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | #include <qpe/qpetoolbar.h> | 20 | #include <qtoolbutton.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qmenubar.h> |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | 25 | ||
26 | #include <opie/ofiledialog.h> | 26 | #include <opie/ofiledialog.h> |
27 | 27 | ||
28 | #include "cgotoline.h" | ||
29 | |||
30 | #include "tinykate.h" | 28 | #include "tinykate.h" |
31 | 29 | ||
32 | #include <katedocument.h> | 30 | #include <katedocument.h> |
33 | #include <katehighlight.h> | 31 | #include <katehighlight.h> |
34 | #include <kateview.h> | 32 | #include <kateview.h> |
35 | #include <kglobal.h> | 33 | #include <kglobal.h> |
36 | 34 | ||
37 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | 35 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : |
38 | QMainWindow( parent, name, f ) | 36 | QMainWindow( parent, name, f ) |
39 | { | 37 | { |
38 | shutDown=false; | ||
40 | nextUnnamed=0; | 39 | nextUnnamed=0; |
41 | currentView=0; | 40 | currentView=0; |
42 | viewCount=0; | 41 | viewCount=0; |
43 | setCaption("TinyKATE : line 1 col 1"); | 42 | setCaption(tr("TinyKATE")); |
44 | KGlobal::setAppName("TinyKATE"); | 43 | KGlobal::setAppName("TinyKATE"); |
45 | 44 | ||
46 | curLine=curCol=1; | 45 | QMenuBar *mb = new QMenuBar( this ); |
47 | 46 | mb->setMargin( 0 ); | |
48 | setToolBarsMovable(FALSE); | ||
49 | |||
50 | QPEToolBar *bar = new QPEToolBar( this ); | ||
51 | bar->setHorizontalStretchable( TRUE ); | ||
52 | QPEMenuBar *mb = new QPEMenuBar( bar ); | ||
53 | mb->setMargin( 0 ); | ||
54 | 47 | ||
55 | tabwidget=new OTabWidget(this); | 48 | tabwidget=new OTabWidget(this); |
56 | setCentralWidget(tabwidget); | 49 | setCentralWidget(tabwidget); |
57 | connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *))); | 50 | connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *))); |
58 | 51 | ||
59 | //FILE ACTIONS | 52 | //FILE ACTIONS |
60 | QPopupMenu *popup = new QPopupMenu( this ); | 53 | QPopupMenu *popup = new QPopupMenu( this ); |
61 | 54 | ||
62 | // Action for creating a new document | 55 | // Action for creating a new document |
63 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, CTRL+Key_N, this, 0 ); | 56 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
64 | a->addTo( popup ); | 57 | a->addTo( popup ); |
65 | connect(a, SIGNAL(activated()), this, SLOT(slotNew())); | 58 | connect(a, SIGNAL(activated()), this, SLOT(slotNew())); |
66 | 59 | ||
67 | // Action for opening an exisiting document | 60 | // Action for opening an exisiting document |
68 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, CTRL+Key_O, this, 0 ); | 61 | a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 ); |
69 | a->addTo(popup); | 62 | a->addTo(popup); |
70 | connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); | 63 | connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); |
71 | 64 | ||
72 | 65 | ||
73 | // Action for saving document | 66 | // Action for saving document |
74 | a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ), QString::null, CTRL+Key_S, this, 0 ); | 67 | a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); |
75 | a->addTo(popup); | 68 | a->addTo(popup); |
76 | connect(a, SIGNAL(activated()), this, SLOT(slotSave())); | 69 | connect(a, SIGNAL(activated()), this, SLOT(slotSave())); |
77 | 70 | ||
78 | // Action for saving document to a new name | 71 | // Action for saving document to a new name |
79 | a = new QAction( tr( "Save As" ), Resource::loadPixmap( "save" ), QString::null, 0, this, 0 ); | 72 | a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); |
80 | a->addTo(popup); | 73 | a->addTo(popup); |
81 | connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); | 74 | connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); |
82 | 75 | ||
83 | // Action for closing the currently active document | 76 | // Action for closing the currently active document |
84 | a = new QAction( tr( "Close" ), Resource::loadPixmap( "close" ), QString::null, CTRL+Key_W, this, 0 ); | 77 | a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 ); |
85 | a->addTo(popup); | 78 | a->addTo(popup); |
86 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); | 79 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); |
87 | 80 | ||
88 | 81 | ||
89 | mb->insertItem(tr("File"),popup); | 82 | mb->insertItem(tr("File"),popup); |
90 | 83 | ||
91 | //EDIT ACTIONS | 84 | //EDIT ACTIONS |
92 | 85 | ||
93 | // Action for cutting text | 86 | // Action for cutting text |
94 | editCut = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, CTRL+Key_X, this, 0 ); | 87 | editCut = new QToolButton( 0 ); |
95 | editCut->addTo( bar ); | 88 | editCut->setAutoRaise( true ); |
89 | editCut->setIconSet( Resource::loadPixmap( "cut" ) ); | ||
96 | 90 | ||
97 | // Action for Copying text | 91 | // Action for Copying text |
98 | editCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, CTRL+Key_C, this, 0 ); | 92 | editCopy = new QToolButton( 0 ); |
99 | editCopy->addTo( bar ); | 93 | editCopy->setAutoRaise( true ); |
94 | editCopy->setIconSet( Resource::loadPixmap( "copy" ) ); | ||
100 | 95 | ||
101 | // Action for pasting text | 96 | // Action for pasting text |
102 | editPaste = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, CTRL+Key_V, this, 0 ); | 97 | editPaste = new QToolButton( 0 ); |
103 | editPaste->addTo( bar ); | 98 | editPaste->setAutoRaise( true ); |
104 | 99 | editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); | |
105 | 100 | ||
106 | // Action for finding / replacing text | 101 | // Action for finding / replacing text |
107 | editFindReplace = new QAction( tr( "Replace" ), Resource::loadPixmap("find"), QString::null, CTRL+Key_R, this, 0 ); | 102 | editFindReplace = new QToolButton( 0 ); |
108 | editFind = new QAction( tr( "Find" ), Resource::loadPixmap("find"), QString::null, CTRL+Key_F, this, 0 ); | 103 | editFindReplace->setAutoRaise( true ); |
109 | editFind->addTo( bar ); | 104 | editFindReplace->setIconSet( Resource::loadPixmap("find") ); |
110 | 105 | ||
111 | // Action for undo | 106 | // Action for undo |
112 | editUndo = new QAction( tr( "Undo" ), Resource::loadPixmap( "undo" ), QString::null, CTRL+Key_Z, this, 0 ); | 107 | editUndo = new QToolButton( 0 ); |
113 | editUndo->addTo( bar ); | 108 | editUndo->setAutoRaise( true ); |
109 | editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); | ||
114 | 110 | ||
115 | // Action for redo | 111 | // Action for redo |
116 | editRedo = new QAction( tr( "Redo" ), Resource::loadPixmap( "redo" ), QString::null, CTRL+SHIFT+Key_Z, this, 0 ); | 112 | editRedo = new QToolButton( 0 ); |
117 | editRedo->addTo( bar ); | 113 | editRedo->setAutoRaise( true ); |
118 | 114 | editRedo->setIconSet( Resource::loadPixmap( "redo" ) ); | |
119 | 115 | ||
120 | //VIEW ACITONS | 116 | //VIEW ACITONS |
121 | popup = new QPopupMenu( this ); | 117 | popup = new QPopupMenu( this ); |
122 | 118 | ||
123 | a = new QAction( tr( "Goto" ), QString::null, CTRL+Key_G, this, 0 ); | ||
124 | a->addTo( popup ); | ||
125 | connect(a, SIGNAL(activated()), this, SLOT(slotGoTo())); | ||
126 | |||
127 | viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); | 119 | viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); |
128 | viewIncFontSizes->addTo( popup ); | 120 | viewIncFontSizes->addTo( popup ); |
129 | 121 | ||
130 | viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); | 122 | viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); |
131 | viewDecFontSizes->addTo( popup ); | 123 | viewDecFontSizes->addTo( popup ); |
132 | 124 | ||
133 | mb->insertItem(tr("View"),popup); | 125 | mb->insertItem(tr("View"),popup); |
134 | 126 | ||
127 | popup = new QPopupMenu( this ); | ||
128 | mb->insertItem(tr("Utils"),popup); | ||
135 | 129 | ||
136 | 130 | ||
137 | popup = new QPopupMenu( this ); | 131 | mb->insertItem( editCut ); |
138 | mb->insertItem(tr("Utils"),popup); | 132 | mb->insertItem( editCopy ); |
133 | mb->insertItem( editPaste ); | ||
134 | mb->insertItem( editFindReplace ); | ||
135 | mb->insertItem( editUndo ); | ||
136 | mb->insertItem( editRedo ); | ||
137 | |||
139 | 138 | ||
140 | //Highlight management | 139 | //Highlight management |
141 | hlmenu=new QPopupMenu(this); | 140 | hlmenu=new QPopupMenu(this); |
142 | HlManager *hlm=HlManager::self(); | 141 | HlManager *hlm=HlManager::self(); |
143 | for (int i=0;i<hlm->highlights();i++) | 142 | for (int i=0;i<hlm->highlights();i++) |
144 | { | 143 | { |
145 | hlmenu->insertItem(hlm->hlName(i),i); | 144 | hlmenu->insertItem(hlm->hlName(i),i); |
146 | } | 145 | } |
147 | popup->insertItem(tr("Highlighting"),hlmenu); | 146 | popup->insertItem(tr("Highlighting"),hlmenu); |
148 | 147 | ||
149 | 148 | ||
150 | utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); | 149 | utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); |
151 | utilSettings->addTo( popup); | 150 | utilSettings->addTo( popup); |
152 | 151 | ||
153 | popup->insertSeparator(); | ||
154 | editFind->addTo(popup); | ||
155 | editFindReplace->addTo(popup); | ||
156 | |||
157 | if( qApp->argc() > 1) open(qApp->argv()[1]); | 152 | if( qApp->argc() > 1) open(qApp->argv()[1]); |
158 | else slotNew(); | 153 | else slotNew(); |
159 | 154 | ||
160 | } | 155 | } |
161 | 156 | ||
162 | TinyKate::~TinyKate( ) | 157 | TinyKate::~TinyKate( ) |
163 | { | 158 | { |
164 | qWarning("TinyKate destructor\n"); | 159 | qWarning("TinyKate destructor\n"); |
165 | printf("~TinyKate()\n"); | 160 | |
161 | shutDown=true; | ||
162 | while (currentView!=0) { | ||
163 | slotClose(); | ||
164 | } | ||
165 | |||
166 | if( KGlobal::config() != 0 ) { | 166 | if( KGlobal::config() != 0 ) { |
167 | printf("~TinyKate(): delete configs...\n"); | ||
168 | qWarning("deleting KateConfig object..\n"); | 167 | qWarning("deleting KateConfig object..\n"); |
169 | delete KGlobal::config(); | 168 | delete KGlobal::config(); |
170 | } | 169 | } |
171 | } | 170 | } |
172 | 171 | ||
173 | void TinyKate::slotOpen( ) | 172 | void TinyKate::slotOpen( ) |
174 | { | 173 | { |
175 | QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 174 | QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
176 | QString::null); | 175 | QString::null); |
177 | if (!filename.isEmpty()) { | 176 | if (!filename.isEmpty()) { |
178 | open(filename); | 177 | open(filename); |
179 | } | 178 | } |
180 | } | 179 | } |
181 | 180 | ||
182 | void TinyKate::open(const QString & filename) | 181 | void TinyKate::open(const QString & filename) |
183 | { | 182 | { |
184 | KateDocument *kd= new KateDocument(false, false, this,0,this); | 183 | KateDocument *kd= new KateDocument(false, false, this,0,this); |
185 | KTextEditor::View *kv; | 184 | KTextEditor::View *kv; |
186 | QFileInfo fi(filename); | 185 | QFileInfo fi(filename); |
187 | QString filenamed = fi.fileName(); | 186 | QString filenamed = fi.fileName(); |
188 | tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); | 187 | tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); |
189 | qDebug(filename); | 188 | qDebug(filename); |
190 | 189 | ||
191 | kd->setDocName( filenamed); | 190 | kd->setDocName( filenamed); |
192 | kd->open( filename ); | 191 | kd->open( filename ); |
193 | viewCount++; | 192 | viewCount++; |
194 | } | 193 | } |
195 | 194 | ||
196 | void TinyKate::setDocument(const QString &doc) | 195 | void TinyKate::setDocument(const QString& fileref) |
197 | { | 196 | { |
198 | printf("tinykate: setDocument(\"%s\")\n",(const char*)doc); | 197 | open( fileref ); |
199 | open(doc); | ||
200 | } | 198 | } |
201 | 199 | ||
202 | void TinyKate::slotCurrentChanged( QWidget * view) | 200 | void TinyKate::slotCurrentChanged( QWidget * view) |
203 | { | 201 | { |
204 | if (currentView) { | 202 | if (currentView) { |
205 | 203 | ||
206 | disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); | 204 | disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); |
207 | disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); | 205 | disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); |
208 | disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); | 206 | disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); |
209 | disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); | 207 | disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); |
210 | disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); | 208 | disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); |
211 | disconnect(editFindReplace,SIGNAL(activated()),currentView,SLOT(replace())); | 209 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); |
212 | disconnect(editFind,SIGNAL(activated()),currentView,SLOT(find())); | 210 | disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); |
213 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); | ||
214 | disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); | ||
215 | disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); | 211 | disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); |
216 | disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); | 212 | disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); |
217 | disconnect(currentView,SIGNAL(newCurPos()),this,SLOT(slotCursorMoved())); | ||
218 | } | 213 | } |
219 | 214 | ||
220 | currentView=(KTextEditor::View*)view; | 215 | currentView=(KTextEditor::View*)view; |
221 | 216 | ||
222 | connect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); | 217 | connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); |
223 | connect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); | 218 | connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); |
224 | connect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); | 219 | connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); |
225 | connect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); | 220 | connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); |
226 | connect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); | 221 | connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); |
227 | connect(editFindReplace,SIGNAL(activated()),currentView,SLOT(replace())); | ||
228 | connect(editFind,SIGNAL(activated()),currentView,SLOT(find())); | ||
229 | connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); | 222 | connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); |
230 | connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); | 223 | connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); |
231 | connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); | 224 | connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); |
232 | connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); | 225 | connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); |
233 | connect(currentView,SIGNAL(newCurPos()),this,SLOT(slotCursorMoved())); | 226 | |
234 | } | 227 | } |
235 | 228 | ||
236 | void TinyKate::slotNew( ) | 229 | void TinyKate::slotNew( ) |
237 | { | 230 | { |
238 | KateDocument *kd= new KateDocument(false, false, this,0,this); | 231 | KateDocument *kd= new KateDocument(false, false, this,0,this); |
239 | KTextEditor::View *kv; | 232 | KTextEditor::View *kv; |
240 | tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), | 233 | tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), |
241 | "tinykate/tinykate", | 234 | "tinykate/tinykate", |
242 | tr("Unnamed %1").arg(nextUnnamed++)); | 235 | tr("Unnamed %1").arg(nextUnnamed++)); |
243 | viewCount++; | 236 | viewCount++; |
244 | } | 237 | } |
245 | 238 | ||
246 | void TinyKate::slotClose( ) | 239 | void TinyKate::slotClose( ) |
247 | { | 240 | { |
248 | if (currentView==0) return; | 241 | if (currentView==0) return; |
249 | KTextEditor::View *dv=currentView; | 242 | KTextEditor::View *dv=currentView; |
250 | currentView=0; | 243 | currentView=0; |
251 | tabwidget->removePage(dv); | 244 | tabwidget->removePage(dv); |
252 | delete dv->document(); | 245 | delete dv->document(); |
253 | viewCount--; | 246 | viewCount--; |
254 | if (!viewCount) slotNew(); | 247 | if ((!viewCount) && (!shutDown)) slotNew(); |
255 | } | 248 | } |
256 | 249 | ||
257 | void TinyKate::slotSave() { | 250 | void TinyKate::slotSave() { |
258 | // feel free to make this how you want | 251 | // feel free to make this how you want |
259 | if (currentView==0) return; | 252 | if (currentView==0) return; |
260 | 253 | ||
261 | // KateView *kv = (KateView*) currentView; | 254 | // KateView *kv = (KateView*) currentView; |
262 | KateDocument *kd = (KateDocument*) currentView->document(); | 255 | KateDocument *kd = (KateDocument*) currentView->document(); |
263 | // qDebug("saving file "+kd->docName()); | 256 | // qDebug("saving file "+kd->docName()); |
264 | if( kd->docName().isEmpty()) | 257 | if( kd->docName().isEmpty()) |
265 | slotSaveAs(); | 258 | slotSaveAs(); |
266 | else | 259 | else |
267 | kd->saveFile(); | 260 | kd->saveFile(); |
268 | // kv->save(); | 261 | // kv->save(); |
269 | // kd->saveFile(); | 262 | // kd->saveFile(); |
270 | } | 263 | } |
271 | 264 | ||
272 | void TinyKate::slotSaveAs() { | 265 | void TinyKate::slotSaveAs() { |
273 | if (currentView==0) return; | 266 | if (currentView==0) return; |
274 | KateDocument *kd = (KateDocument*) currentView->document(); | 267 | KateDocument *kd = (KateDocument*) currentView->document(); |
275 | 268 | ||
276 | QString filename=OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, | 269 | QString filename=OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, |
277 | QString::null); | 270 | QString::null); |
278 | if (!filename.isEmpty()) { | 271 | if (!filename.isEmpty()) { |
279 | qDebug("saving file "+filename); | 272 | qDebug("saving file "+filename); |
280 | QFileInfo fi(filename); | 273 | QFileInfo fi(filename); |
281 | QString filenamed = fi.fileName(); | 274 | QString filenamed = fi.fileName(); |
282 | kd->setDocFile( filename); | 275 | kd->setDocFile( filename); |
283 | kd->setDocName( filenamed); | 276 | kd->setDocName( filenamed); |
284 | kd->saveFile(); | 277 | kd->saveFile(); |
285 | // KTextEditor::View *dv = currentView; | 278 | // KTextEditor::View *dv = currentView; |
286 | // tabwidget->changeTab( dv, filenamed); | 279 | // tabwidget->changeTab( dv, filenamed); |
287 | // need to change tab label here | 280 | // need to change tab label here |
288 | } | 281 | } |
289 | 282 | ||
290 | } | 283 | } |
291 | |||
292 | void TinyKate::slotGoTo() | ||
293 | { | ||
294 | int l,c; | ||
295 | if (currentView==0) return; | ||
296 | |||
297 | currentView->getCursorPosition(&l,&c); | ||
298 | |||
299 | CGotoLine g(l); | ||
300 | |||
301 | if(g.exec()==QDialog::Accepted) | ||
302 | { | ||
303 | currentView->setCursorPosition( g.line(), c ); | ||
304 | } | ||
305 | } | ||
306 | |||
307 | void TinyKate::slotCursorMoved() | ||
308 | { | ||
309 | char buf[100]; | ||
310 | int newLine,newCol; | ||
311 | currentView->getCursorPosition(&newLine,&newCol); | ||
312 | newLine++; | ||
313 | newCol++; | ||
314 | if((newLine!=curLine)||(newCol!=curCol)) | ||
315 | { | ||
316 | sprintf(buf,"TinyKATE : line %-6d col %d",newLine,newCol); | ||
317 | setCaption(buf); | ||
318 | curLine=newLine; | ||
319 | curCol=newCol; | ||
320 | } | ||
321 | } | ||
diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h index 077d5f0..2bf4de6 100644 --- a/noncore/apps/tinykate/tinykate.h +++ b/noncore/apps/tinykate/tinykate.h | |||
@@ -1,75 +1,64 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | tinykate.h | 2 | tinykate.h |
3 | Tiny KATE mainwindow | 3 | Tiny KATE mainwindow |
4 | ------------------- | 4 | ------------------- |
5 | begin : November 2002 | 5 | begin : November 2002 |
6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> | 6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation. * | 13 | * the Free Software Foundation. * |
14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * | 14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #ifndef __TINYKATE_H__ | 18 | #ifndef __TINYKATE_H__ |
19 | #define __TINYKATE_H__ | 19 | #define __TINYKATE_H__ |
20 | 20 | ||
21 | 21 | ||
22 | #include <qmainwindow.h> | 22 | #include <qmainwindow.h> |
23 | #include <opie/otabwidget.h> | 23 | #include <opie/otabwidget.h> |
24 | #include <ktexteditor.h> | 24 | #include <ktexteditor.h> |
25 | 25 | ||
26 | class QToolButton; | ||
26 | class QAction; | 27 | class QAction; |
27 | class QPopupMenu; | 28 | class QPopupMenu; |
28 | class CGotoLine; | ||
29 | 29 | ||
30 | class TinyKate : public QMainWindow | 30 | class TinyKate : public QMainWindow |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); | 34 | TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); |
35 | ~TinyKate( ); | 35 | ~TinyKate( ); |
36 | 36 | ||
37 | public slots: | 37 | public slots: |
38 | void slotNew(); | 38 | void slotNew(); |
39 | void setDocument(const QString& fileref); | ||
39 | 40 | ||
40 | protected slots: | 41 | protected slots: |
41 | void slotOpen(); | 42 | void slotOpen(); |
42 | void slotClose(); | 43 | void slotClose(); |
43 | void slotCurrentChanged(QWidget *); | 44 | void slotCurrentChanged(QWidget *); |
44 | void slotSave(); | 45 | void slotSave(); |
45 | void slotSaveAs(); | 46 | void slotSaveAs(); |
46 | void slotGoTo(); | ||
47 | void slotCursorMoved(); | ||
48 | void setDocument(const QString &doc); | ||
49 | |||
50 | protected: | 47 | protected: |
51 | void open(const QString&); | 48 | void open(const QString&); |
52 | private: | 49 | private: |
53 | QString currentFileName; | 50 | QString currentFileName; |
54 | OTabWidget *tabwidget; | 51 | OTabWidget *tabwidget; |
55 | KTextEditor::View *currentView; | 52 | KTextEditor::View *currentView; |
56 | 53 | bool shutDown; | |
57 | QAction *editCopy; | 54 | |
58 | QAction *editCut; | 55 | QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo, *editFindReplace; |
59 | QAction *editPaste; | 56 | QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings; |
60 | QAction *editUndo; | 57 | |
61 | QAction *editRedo; | ||
62 | QAction *editFind; | ||
63 | QAction *editFindReplace; | ||
64 | QAction *viewIncFontSizes; | ||
65 | QAction *viewDecFontSizes; | ||
66 | QAction *utilSettings; | ||
67 | |||
68 | QPopupMenu *hlmenu; | 58 | QPopupMenu *hlmenu; |
69 | uint nextUnnamed; | 59 | uint nextUnnamed; |
70 | uint viewCount; | 60 | uint viewCount; |
71 | int curLine,curCol; | ||
72 | }; | 61 | }; |
73 | 62 | ||
74 | 63 | ||
75 | #endif // __TINYKATE_H__ | 64 | #endif // __TINYKATE_H__ |
diff --git a/noncore/apps/tinykate/tinykate.pro b/noncore/apps/tinykate/tinykate.pro index f7ff451..632bd49 100644 --- a/noncore/apps/tinykate/tinykate.pro +++ b/noncore/apps/tinykate/tinykate.pro | |||
@@ -1,22 +1,22 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = tinykate.h cgotoline.h | 4 | HEADERS = tinykate.h |
5 | SOURCES = tinykate.cpp main.cpp cgotoline.cpp | 5 | SOURCES = tinykate.cpp main.cpp |
6 | INTERFACES = cgotobase.ui | 6 | INTERFACES= |
7 | INCLUDEPATH += $(OPIEDIR)/include \ | 7 | INCLUDEPATH+= $(OPIEDIR)/include \ |
8 | $(OPIEDIR)/noncore/apps/tinykate/libkate \ | 8 | $(OPIEDIR)/noncore/apps/tinykate/libkate \ |
9 | $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ | 9 | $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ |
10 | $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ | 10 | $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ |
11 | $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ | 11 | $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ |
12 | $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ | 12 | $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ |
13 | $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ | 13 | $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ |
14 | $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back | 14 | $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back |
15 | 15 | ||
16 | DEPENDPATH += $(OPIEDIR)/include | 16 | DEPENDPATH+= $(OPIEDIR)/include |
17 | LIBS += -lqpe -ltinykate -lopie | 17 | LIBS += -lqpe -ltinykate -lopie |
18 | TARGET = tinykate | 18 | TARGET = tinykate |
19 | 19 | ||
20 | 20 | ||
21 | 21 | ||
22 | include ( $(OPIEDIR)/include.pro ) | 22 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 45a6663..42093cf 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,1221 +1,1233 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/limits.h> | 30 | #include <linux/limits.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | 32 | ||
33 | #include <qpe/qcopenvelope_qws.h> | 33 | #include <qpe/qcopenvelope_qws.h> |
34 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qtoolbar.h> | 36 | #include <qtoolbar.h> |
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <qaction.h> | 40 | #include <qaction.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qlineedit.h> | 45 | #include <qlineedit.h> |
46 | #include <qlistview.h> | 46 | #include <qlistview.h> |
47 | #include <qmenubar.h> | 47 | #include <qmenubar.h> |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qpopupmenu.h> | 49 | #include <qpopupmenu.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qtimer.h> | 51 | #include <qtimer.h> |
52 | #include <qwhatsthis.h> | 52 | #include <qwhatsthis.h> |
53 | #include <qwidgetstack.h> | 53 | #include <qwidgetstack.h> |
54 | 54 | ||
55 | #include "categoryfilterimpl.h" | 55 | #include "categoryfilterimpl.h" |
56 | #include "datamgr.h" | 56 | #include "datamgr.h" |
57 | #include "global.h" | 57 | #include "global.h" |
58 | #include "inputdlg.h" | 58 | #include "inputdlg.h" |
59 | #include "ipkg.h" | 59 | #include "ipkg.h" |
60 | #include "installdlgimpl.h" | 60 | #include "installdlgimpl.h" |
61 | #include "letterpushbutton.h" | 61 | #include "letterpushbutton.h" |
62 | #include "mainwin.h" | 62 | #include "mainwin.h" |
63 | #include "packagewin.h" | 63 | #include "packagewin.h" |
64 | #include "settingsimpl.h" | 64 | #include "settingsimpl.h" |
65 | #include "utils.h" | 65 | #include "utils.h" |
66 | 66 | ||
67 | extern int compareVersions( const char *v1, const char *v2 ); | 67 | extern int compareVersions( const char *v1, const char *v2 ); |
68 | 68 | ||
69 | MainWindow :: MainWindow() | 69 | MainWindow :: MainWindow() |
70 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 70 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) |
71 | { | 71 | { |
72 | setCaption( tr( "AQPkg - Package Manager" ) ); | 72 | setCaption( tr( "AQPkg - Package Manager" ) ); |
73 | 73 | ||
74 | // Create UI widgets | 74 | // Create UI widgets |
75 | initMainWidget(); | 75 | initMainWidget(); |
76 | initProgressWidget(); | 76 | initProgressWidget(); |
77 | 77 | ||
78 | // Build menu and tool bars | 78 | // Build menu and tool bars |
79 | setToolBarsMovable( FALSE ); | 79 | setToolBarsMovable( FALSE ); |
80 | 80 | ||
81 | QToolBar *bar = new QToolBar( this ); | 81 | QToolBar *bar = new QToolBar( this ); |
82 | bar->setHorizontalStretchable( TRUE ); | 82 | bar->setHorizontalStretchable( TRUE ); |
83 | QMenuBar *mb = new QMenuBar( bar ); | 83 | QMenuBar *mb = new QMenuBar( bar ); |
84 | mb->setMargin( 0 ); | 84 | mb->setMargin( 0 ); |
85 | bar = new QToolBar( this ); | 85 | bar = new QToolBar( this ); |
86 | 86 | ||
87 | // Find toolbar | 87 | // Find toolbar |
88 | findBar = new QToolBar( this ); | 88 | findBar = new QToolBar( this ); |
89 | addToolBar( findBar, QMainWindow::Top, true ); | 89 | addToolBar( findBar, QMainWindow::Top, true ); |
90 | findBar->setHorizontalStretchable( true ); | 90 | findBar->setHorizontalStretchable( true ); |
91 | findEdit = new QLineEdit( findBar ); | 91 | findEdit = new QLineEdit( findBar ); |
92 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); | 92 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); |
93 | findBar->setStretchableWidget( findEdit ); | 93 | findBar->setStretchableWidget( findEdit ); |
94 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); | 94 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); |
95 | 95 | ||
96 | // Quick jump toolbar | 96 | // Quick jump toolbar |
97 | jumpBar = new QToolBar( this ); | 97 | jumpBar = new QToolBar( this ); |
98 | addToolBar( jumpBar, QMainWindow::Top, true ); | 98 | addToolBar( jumpBar, QMainWindow::Top, true ); |
99 | jumpBar->setHorizontalStretchable( true ); | 99 | jumpBar->setHorizontalStretchable( true ); |
100 | QWidget *w = new QWidget( jumpBar ); | 100 | QWidget *w = new QWidget( jumpBar ); |
101 | jumpBar->setStretchableWidget( w ); | 101 | jumpBar->setStretchableWidget( w ); |
102 | 102 | ||
103 | QGridLayout *layout = new QGridLayout( w ); | 103 | QGridLayout *layout = new QGridLayout( w ); |
104 | 104 | ||
105 | char text[2]; | 105 | char text[2]; |
106 | text[1] = '\0'; | 106 | text[1] = '\0'; |
107 | for ( int i = 0 ; i < 26 ; ++i ) | 107 | for ( int i = 0 ; i < 26 ; ++i ) |
108 | { | 108 | { |
109 | text[0] = 'A' + i; | 109 | text[0] = 'A' + i; |
110 | LetterPushButton *b = new LetterPushButton( text, w ); | 110 | LetterPushButton *b = new LetterPushButton( text, w ); |
111 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 111 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
112 | layout->addWidget( b, i / 13, i % 13); | 112 | layout->addWidget( b, i / 13, i % 13); |
113 | } | 113 | } |
114 | 114 | ||
115 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); | 115 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); |
116 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); | 116 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); |
117 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); | 117 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); |
118 | a->addTo( jumpBar ); | 118 | a->addTo( jumpBar ); |
119 | jumpBar->hide(); | 119 | jumpBar->hide(); |
120 | 120 | ||
121 | // Packages menu | 121 | // Packages menu |
122 | QPopupMenu *popup = new QPopupMenu( this ); | 122 | QPopupMenu *popup = new QPopupMenu( this ); |
123 | 123 | ||
124 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | 124 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); |
125 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 125 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
126 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); | 126 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); |
127 | a->addTo( popup ); | 127 | a->addTo( popup ); |
128 | a->addTo( bar ); | 128 | a->addTo( bar ); |
129 | 129 | ||
130 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | 130 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); |
131 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 131 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
132 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); | 132 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); |
133 | actionUpgrade->addTo( popup ); | 133 | actionUpgrade->addTo( popup ); |
134 | actionUpgrade->addTo( bar ); | 134 | actionUpgrade->addTo( bar ); |
135 | 135 | ||
136 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | 136 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); |
137 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | 137 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); |
138 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 138 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
139 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 139 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
140 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); | 140 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); |
141 | actionDownload->addTo( popup ); | 141 | actionDownload->addTo( popup ); |
142 | actionDownload->addTo( bar ); | 142 | actionDownload->addTo( bar ); |
143 | 143 | ||
144 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | 144 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); |
145 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 145 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
146 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); | 146 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); |
147 | a->addTo( popup ); | 147 | a->addTo( popup ); |
148 | a->addTo( bar ); | 148 | a->addTo( bar ); |
149 | 149 | ||
150 | popup->insertSeparator(); | 150 | popup->insertSeparator(); |
151 | 151 | ||
152 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 152 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
153 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 153 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
154 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | 154 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); |
155 | a->addTo( popup ); | 155 | a->addTo( popup ); |
156 | mb->insertItem( tr( "Actions" ), popup ); | 156 | mb->insertItem( tr( "Actions" ), popup ); |
157 | 157 | ||
158 | // View menu | 158 | // View menu |
159 | popup = new QPopupMenu( this ); | 159 | popup = new QPopupMenu( this ); |
160 | 160 | ||
161 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 161 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
162 | actionUninstalled->setToggleAction( TRUE ); | 162 | actionUninstalled->setToggleAction( TRUE ); |
163 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 163 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
164 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | 164 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); |
165 | actionUninstalled->addTo( popup ); | 165 | actionUninstalled->addTo( popup ); |
166 | 166 | ||
167 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 167 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
168 | actionInstalled->setToggleAction( TRUE ); | 168 | actionInstalled->setToggleAction( TRUE ); |
169 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 169 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
170 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | 170 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); |
171 | actionInstalled->addTo( popup ); | 171 | actionInstalled->addTo( popup ); |
172 | 172 | ||
173 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 173 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
174 | actionUpdated->setToggleAction( TRUE ); | 174 | actionUpdated->setToggleAction( TRUE ); |
175 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 175 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); |
176 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); | 176 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); |
177 | actionUpdated->addTo( popup ); | 177 | actionUpdated->addTo( popup ); |
178 | 178 | ||
179 | popup->insertSeparator(); | 179 | popup->insertSeparator(); |
180 | 180 | ||
181 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); | 181 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); |
182 | actionFilter->setToggleAction( TRUE ); | 182 | actionFilter->setToggleAction( TRUE ); |
183 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); | 183 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); |
184 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | 184 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); |
185 | actionFilter->addTo( popup ); | 185 | actionFilter->addTo( popup ); |
186 | 186 | ||
187 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); | 187 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); |
188 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); | 188 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); |
189 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | 189 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); |
190 | a->addTo( popup ); | 190 | a->addTo( popup ); |
191 | 191 | ||
192 | popup->insertSeparator(); | 192 | popup->insertSeparator(); |
193 | 193 | ||
194 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 194 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
195 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); | 195 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
196 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); | 196 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); |
197 | a->addTo( popup ); | 197 | a->addTo( popup ); |
198 | 198 | ||
199 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 199 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
200 | actionFindNext->setEnabled( FALSE ); | 200 | actionFindNext->setEnabled( FALSE ); |
201 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 201 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); |
202 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); | 202 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); |
203 | actionFindNext->addTo( popup ); | 203 | actionFindNext->addTo( popup ); |
204 | actionFindNext->addTo( findBar ); | 204 | actionFindNext->addTo( findBar ); |
205 | 205 | ||
206 | 206 | ||
207 | popup->insertSeparator(); | 207 | popup->insertSeparator(); |
208 | 208 | ||
209 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); | 209 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); |
210 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); | 210 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); |
211 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); | 211 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); |
212 | a->addTo( popup ); | 212 | a->addTo( popup ); |
213 | 213 | ||
214 | mb->insertItem( tr( "View" ), popup ); | 214 | mb->insertItem( tr( "View" ), popup ); |
215 | 215 | ||
216 | // Finish find toolbar creation | 216 | // Finish find toolbar creation |
217 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 217 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
218 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 218 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
219 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 219 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
220 | a->addTo( findBar ); | 220 | a->addTo( findBar ); |
221 | findBar->hide(); | 221 | findBar->hide(); |
222 | 222 | ||
223 | // Create widget stack and add UI widgets | 223 | // Create widget stack and add UI widgets |
224 | stack = new QWidgetStack( this ); | 224 | stack = new QWidgetStack( this ); |
225 | stack->addWidget( progressWindow, 2 ); | 225 | stack->addWidget( progressWindow, 2 ); |
226 | stack->addWidget( networkPkgWindow, 1 ); | 226 | stack->addWidget( networkPkgWindow, 1 ); |
227 | setCentralWidget( stack ); | 227 | setCentralWidget( stack ); |
228 | stack->raiseWidget( progressWindow ); | 228 | stack->raiseWidget( progressWindow ); |
229 | 229 | ||
230 | // Delayed call to finish initialization | 230 | // Delayed call to finish initialization |
231 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 231 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
232 | } | 232 | } |
233 | 233 | ||
234 | MainWindow :: ~MainWindow() | 234 | MainWindow :: ~MainWindow() |
235 | { | 235 | { |
236 | delete mgr; | 236 | delete mgr; |
237 | } | 237 | } |
238 | 238 | ||
239 | void MainWindow :: initMainWidget() | 239 | void MainWindow :: initMainWidget() |
240 | { | 240 | { |
241 | networkPkgWindow = new QWidget( this ); | 241 | networkPkgWindow = new QWidget( this ); |
242 | 242 | ||
243 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 243 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
244 | 244 | ||
245 | serversList = new QComboBox( networkPkgWindow ); | 245 | serversList = new QComboBox( networkPkgWindow ); |
246 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); | 246 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); |
247 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 247 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
248 | 248 | ||
249 | installedIcon = Resource::loadPixmap( "installed" ); | 249 | installedIcon = Resource::loadPixmap( "installed" ); |
250 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 250 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); |
251 | 251 | ||
252 | packagesList = new QListView( networkPkgWindow ); | 252 | packagesList = new QListView( networkPkgWindow ); |
253 | packagesList->addColumn( tr( "Packages" ), 225 ); | 253 | packagesList->addColumn( tr( "Packages" ), 225 ); |
254 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | 254 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); |
255 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); | 255 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); |
256 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), | 256 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), |
257 | this, SLOT(slotDisplayPackage(QListViewItem *)) ); | 257 | this, SLOT(slotDisplayPackage(QListViewItem *)) ); |
258 | 258 | ||
259 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 259 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
260 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 260 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
261 | hbox1->addWidget( l ); | 261 | hbox1->addWidget( l ); |
262 | hbox1->addWidget( serversList ); | 262 | hbox1->addWidget( serversList ); |
263 | 263 | ||
264 | vbox->addWidget( packagesList ); | 264 | vbox->addWidget( packagesList ); |
265 | 265 | ||
266 | downloadEnabled = TRUE; | 266 | downloadEnabled = TRUE; |
267 | } | 267 | } |
268 | 268 | ||
269 | void MainWindow :: initProgressWidget() | 269 | void MainWindow :: initProgressWidget() |
270 | { | 270 | { |
271 | progressWindow = new QWidget( this ); | 271 | progressWindow = new QWidget( this ); |
272 | 272 | ||
273 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | 273 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); |
274 | 274 | ||
275 | m_status = new QLabel( progressWindow ); | 275 | m_status = new QLabel( progressWindow ); |
276 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 276 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
277 | layout->addWidget( m_status ); | 277 | layout->addWidget( m_status ); |
278 | 278 | ||
279 | m_progress = new QProgressBar( progressWindow ); | 279 | m_progress = new QProgressBar( progressWindow ); |
280 | layout->addWidget( m_progress ); | 280 | layout->addWidget( m_progress ); |
281 | } | 281 | } |
282 | 282 | ||
283 | void MainWindow :: init() | 283 | void MainWindow :: init() |
284 | { | 284 | { |
285 | #ifdef QWS | 285 | #ifdef QWS |
286 | // read download directory from config file | 286 | // read download directory from config file |
287 | Config cfg( "aqpkg" ); | 287 | Config cfg( "aqpkg" ); |
288 | cfg.setGroup( "settings" ); | 288 | cfg.setGroup( "settings" ); |
289 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 289 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
290 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 290 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
291 | 291 | ||
292 | #endif | 292 | #endif |
293 | 293 | ||
294 | stack->raiseWidget( progressWindow ); | 294 | stack->raiseWidget( progressWindow ); |
295 | 295 | ||
296 | mgr = new DataManager(); | 296 | mgr = new DataManager(); |
297 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); | 297 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); |
298 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 298 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), |
299 | this, SLOT( setProgressMessage( const QString & ) ) ); | 299 | this, SLOT( setProgressMessage( const QString & ) ) ); |
300 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); | 300 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); |
301 | mgr->loadServers(); | 301 | mgr->loadServers(); |
302 | 302 | ||
303 | showUninstalledPkgs = false; | 303 | showUninstalledPkgs = false; |
304 | showInstalledPkgs = false; | 304 | showInstalledPkgs = false; |
305 | showUpgradedPkgs = false; | 305 | showUpgradedPkgs = false; |
306 | categoryFilterEnabled = false; | 306 | categoryFilterEnabled = false; |
307 | 307 | ||
308 | updateData(); | 308 | updateData(); |
309 | 309 | ||
310 | stack->raiseWidget( networkPkgWindow ); | 310 | stack->raiseWidget( networkPkgWindow ); |
311 | } | 311 | } |
312 | 312 | ||
313 | void MainWindow :: setDocument( const QString &doc ) | 313 | void MainWindow :: setDocument( const QString &doc ) |
314 | { | 314 | { |
315 | // Remove path from package | 315 | // Remove path from package |
316 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 316 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
317 | 317 | ||
318 | // First select local server | 318 | // First select local server |
319 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 319 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
320 | { | 320 | { |
321 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 321 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
322 | { | 322 | { |
323 | serversList->setCurrentItem( i ); | 323 | serversList->setCurrentItem( i ); |
324 | break; | 324 | break; |
325 | } | 325 | } |
326 | } | 326 | } |
327 | serverSelected( 0 ); | 327 | serverSelected( 0 ); |
328 | 328 | ||
329 | // Now set the check box of the selected package | 329 | // Now set the check box of the selected package |
330 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 330 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
331 | item != 0 ; | 331 | item != 0 ; |
332 | item = (QCheckListItem *)item->nextSibling() ) | 332 | item = (QCheckListItem *)item->nextSibling() ) |
333 | { | 333 | { |
334 | if ( item->text().startsWith( package ) ) | 334 | if ( item->text().startsWith( package ) ) |
335 | { | 335 | { |
336 | item->setOn( true ); | 336 | item->setOn( true ); |
337 | break; | 337 | break; |
338 | } | 338 | } |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | void MainWindow :: displaySettings() | 342 | void MainWindow :: displaySettings() |
343 | { | 343 | { |
344 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 344 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
345 | if ( dlg->showDlg() ) | 345 | if ( dlg->showDlg() ) |
346 | { | 346 | { |
347 | stack->raiseWidget( progressWindow ); | 347 | stack->raiseWidget( progressWindow ); |
348 | updateData(); | 348 | updateData(); |
349 | stack->raiseWidget( networkPkgWindow ); | 349 | stack->raiseWidget( networkPkgWindow ); |
350 | } | 350 | } |
351 | delete dlg; | 351 | delete dlg; |
352 | } | 352 | } |
353 | 353 | ||
354 | void MainWindow :: closeEvent( QCloseEvent *e ) | 354 | void MainWindow :: closeEvent( QCloseEvent *e ) |
355 | { | 355 | { |
356 | // If install dialog is visible, return to main view, otherwise close app | 356 | // If install dialog is visible, return to main view, otherwise close app |
357 | QWidget *widget = stack->visibleWidget(); | 357 | QWidget *widget = stack->visibleWidget(); |
358 | 358 | ||
359 | if ( widget != networkPkgWindow && widget != progressWindow ) | 359 | if ( widget != networkPkgWindow && widget != progressWindow ) |
360 | { | 360 | { |
361 | if ( widget ) delete widget; | 361 | if ( widget ) delete widget; |
362 | stack->raiseWidget( networkPkgWindow ); | 362 | stack->raiseWidget( networkPkgWindow ); |
363 | e->ignore(); | 363 | e->ignore(); |
364 | } | 364 | } |
365 | else | 365 | else |
366 | { | 366 | { |
367 | e->accept(); | 367 | e->accept(); |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | void MainWindow :: displayFindBar() | 371 | void MainWindow :: displayFindBar() |
372 | { | 372 | { |
373 | findBar->show(); | 373 | findBar->show(); |
374 | findEdit->setFocus(); | 374 | findEdit->setFocus(); |
375 | } | 375 | } |
376 | 376 | ||
377 | void MainWindow :: displayJumpBar() | 377 | void MainWindow :: displayJumpBar() |
378 | { | 378 | { |
379 | jumpBar->show(); | 379 | jumpBar->show(); |
380 | } | 380 | } |
381 | 381 | ||
382 | void MainWindow :: repeatFind() | 382 | void MainWindow :: repeatFind() |
383 | { | 383 | { |
384 | searchForPackage( findEdit->text() ); | 384 | searchForPackage( findEdit->text() ); |
385 | } | 385 | } |
386 | 386 | ||
387 | void MainWindow :: findPackage( const QString &text ) | 387 | void MainWindow :: findPackage( const QString &text ) |
388 | { | 388 | { |
389 | actionFindNext->setEnabled( !text.isEmpty() ); | 389 | actionFindNext->setEnabled( !text.isEmpty() ); |
390 | searchForPackage( text ); | 390 | searchForPackage( text ); |
391 | } | 391 | } |
392 | 392 | ||
393 | void MainWindow :: hideFindBar() | 393 | void MainWindow :: hideFindBar() |
394 | { | 394 | { |
395 | findBar->hide(); | 395 | findBar->hide(); |
396 | } | 396 | } |
397 | 397 | ||
398 | void MainWindow :: hideJumpBar() | 398 | void MainWindow :: hideJumpBar() |
399 | { | 399 | { |
400 | jumpBar->hide(); | 400 | jumpBar->hide(); |
401 | } | 401 | } |
402 | 402 | ||
403 | void MainWindow :: filterUninstalledPackages() | 403 | void MainWindow :: filterUninstalledPackages() |
404 | { | 404 | { |
405 | showUninstalledPkgs = actionUninstalled->isOn(); | 405 | showUninstalledPkgs = actionUninstalled->isOn(); |
406 | if ( showUninstalledPkgs ) | 406 | if ( showUninstalledPkgs ) |
407 | { | 407 | { |
408 | showInstalledPkgs = FALSE; | 408 | showInstalledPkgs = FALSE; |
409 | showUpgradedPkgs = FALSE; | 409 | showUpgradedPkgs = FALSE; |
410 | } | 410 | } |
411 | serverSelected( -1 ); | 411 | serverSelected( -1 ); |
412 | 412 | ||
413 | actionInstalled->setOn( FALSE ); | 413 | actionInstalled->setOn( FALSE ); |
414 | actionUpdated->setOn( FALSE ); | 414 | actionUpdated->setOn( FALSE ); |
415 | } | 415 | } |
416 | 416 | ||
417 | void MainWindow :: filterInstalledPackages() | 417 | void MainWindow :: filterInstalledPackages() |
418 | { | 418 | { |
419 | showInstalledPkgs = actionInstalled->isOn(); | 419 | showInstalledPkgs = actionInstalled->isOn(); |
420 | if ( showInstalledPkgs ) | 420 | if ( showInstalledPkgs ) |
421 | { | 421 | { |
422 | showUninstalledPkgs = FALSE; | 422 | showUninstalledPkgs = FALSE; |
423 | showUpgradedPkgs = FALSE; | 423 | showUpgradedPkgs = FALSE; |
424 | } | 424 | } |
425 | serverSelected( -1 ); | 425 | serverSelected( -1 ); |
426 | 426 | ||
427 | actionUninstalled->setOn( FALSE ); | 427 | actionUninstalled->setOn( FALSE ); |
428 | actionUpdated->setOn( FALSE ); | 428 | actionUpdated->setOn( FALSE ); |
429 | } | 429 | } |
430 | 430 | ||
431 | void MainWindow :: filterUpgradedPackages() | 431 | void MainWindow :: filterUpgradedPackages() |
432 | { | 432 | { |
433 | showUpgradedPkgs = actionUpdated->isOn(); | 433 | showUpgradedPkgs = actionUpdated->isOn(); |
434 | if ( showUpgradedPkgs ) | 434 | if ( showUpgradedPkgs ) |
435 | { | 435 | { |
436 | showUninstalledPkgs = FALSE; | 436 | showUninstalledPkgs = FALSE; |
437 | showInstalledPkgs = FALSE; | 437 | showInstalledPkgs = FALSE; |
438 | } | 438 | } |
439 | serverSelected( -1 ); | 439 | serverSelected( -1 ); |
440 | 440 | ||
441 | actionUninstalled->setOn( FALSE ); | 441 | actionUninstalled->setOn( FALSE ); |
442 | actionInstalled->setOn( FALSE ); | 442 | actionInstalled->setOn( FALSE ); |
443 | } | 443 | } |
444 | 444 | ||
445 | bool MainWindow :: setFilterCategory() | 445 | bool MainWindow :: setFilterCategory() |
446 | { | 446 | { |
447 | // Get categories; | 447 | // Get categories; |
448 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); | 448 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); |
449 | if ( dlg.exec() == QDialog::Accepted ) | 449 | if ( dlg.exec() == QDialog::Accepted ) |
450 | { | 450 | { |
451 | categoryFilter = dlg.getSelectedFilter(); | 451 | categoryFilter = dlg.getSelectedFilter(); |
452 | 452 | ||
453 | if ( categoryFilter == "" ) | 453 | if ( categoryFilter == "" ) |
454 | return false; | 454 | return false; |
455 | 455 | ||
456 | categoryFilterEnabled = true; | 456 | categoryFilterEnabled = true; |
457 | serverSelected( -1 ); | 457 | serverSelected( -1 ); |
458 | actionFilter->setOn( TRUE ); | 458 | actionFilter->setOn( TRUE ); |
459 | return true; | 459 | return true; |
460 | } | 460 | } |
461 | 461 | ||
462 | return false; | 462 | return false; |
463 | } | 463 | } |
464 | 464 | ||
465 | void MainWindow :: filterCategory() | 465 | void MainWindow :: filterCategory() |
466 | { | 466 | { |
467 | if ( !actionFilter->isOn() ) | 467 | if ( !actionFilter->isOn() ) |
468 | { | 468 | { |
469 | filterByCategory( FALSE ); | 469 | filterByCategory( FALSE ); |
470 | } | 470 | } |
471 | else | 471 | else |
472 | { | 472 | { |
473 | actionFilter->setOn( filterByCategory( TRUE ) ); | 473 | actionFilter->setOn( filterByCategory( TRUE ) ); |
474 | } | 474 | } |
475 | } | 475 | } |
476 | 476 | ||
477 | bool MainWindow :: filterByCategory( bool val ) | 477 | bool MainWindow :: filterByCategory( bool val ) |
478 | { | 478 | { |
479 | if ( val ) | 479 | if ( val ) |
480 | { | 480 | { |
481 | if ( categoryFilter == "" ) | 481 | if ( categoryFilter == "" ) |
482 | { | 482 | { |
483 | if ( !setFilterCategory() ) | 483 | if ( !setFilterCategory() ) |
484 | return false; | 484 | return false; |
485 | } | 485 | } |
486 | 486 | ||
487 | categoryFilterEnabled = true; | 487 | categoryFilterEnabled = true; |
488 | serverSelected( -1 ); | 488 | serverSelected( -1 ); |
489 | return true; | 489 | return true; |
490 | } | 490 | } |
491 | else | 491 | else |
492 | { | 492 | { |
493 | // Turn off filter | 493 | // Turn off filter |
494 | categoryFilterEnabled = false; | 494 | categoryFilterEnabled = false; |
495 | serverSelected( -1 ); | 495 | serverSelected( -1 ); |
496 | return false; | 496 | return false; |
497 | } | 497 | } |
498 | } | 498 | } |
499 | 499 | ||
500 | void MainWindow :: raiseMainWidget() | 500 | void MainWindow :: raiseMainWidget() |
501 | { | 501 | { |
502 | stack->raiseWidget( networkPkgWindow ); | 502 | stack->raiseWidget( networkPkgWindow ); |
503 | } | 503 | } |
504 | 504 | ||
505 | void MainWindow :: raiseProgressWidget() | 505 | void MainWindow :: raiseProgressWidget() |
506 | { | 506 | { |
507 | stack->raiseWidget( progressWindow ); | 507 | stack->raiseWidget( progressWindow ); |
508 | } | 508 | } |
509 | 509 | ||
510 | void MainWindow :: enableUpgrade( bool enabled ) | 510 | void MainWindow :: enableUpgrade( bool enabled ) |
511 | { | 511 | { |
512 | actionUpgrade->setEnabled( enabled ); | 512 | actionUpgrade->setEnabled( enabled ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void MainWindow :: enableDownload( bool enabled ) | 515 | void MainWindow :: enableDownload( bool enabled ) |
516 | { | 516 | { |
517 | if ( enabled ) | 517 | if ( enabled ) |
518 | { | 518 | { |
519 | actionDownload->setIconSet( iconDownload ); | 519 | actionDownload->setIconSet( iconDownload ); |
520 | actionDownload->setText( tr( "Download" ) ); | 520 | actionDownload->setText( tr( "Download" ) ); |
521 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 521 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
522 | } | 522 | } |
523 | else | 523 | else |
524 | { | 524 | { |
525 | actionDownload->setIconSet( iconRemove ); | 525 | actionDownload->setIconSet( iconRemove ); |
526 | actionDownload->setText( tr( "Remove" ) ); | 526 | actionDownload->setText( tr( "Remove" ) ); |
527 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 527 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
528 | } | 528 | } |
529 | } | 529 | } |
530 | 530 | ||
531 | void MainWindow :: setProgressSteps( int numsteps ) | 531 | void MainWindow :: setProgressSteps( int numsteps ) |
532 | { | 532 | { |
533 | m_progress->setTotalSteps( numsteps ); | 533 | m_progress->setTotalSteps( numsteps ); |
534 | } | 534 | } |
535 | 535 | ||
536 | void MainWindow :: setProgressMessage( const QString &msg ) | 536 | void MainWindow :: setProgressMessage( const QString &msg ) |
537 | { | 537 | { |
538 | m_status->setText( msg ); | 538 | m_status->setText( msg ); |
539 | } | 539 | } |
540 | 540 | ||
541 | void MainWindow :: updateProgress( int progress ) | 541 | void MainWindow :: updateProgress( int progress ) |
542 | { | 542 | { |
543 | m_progress->setProgress( progress ); | 543 | m_progress->setProgress( progress ); |
544 | } | 544 | } |
545 | 545 | ||
546 | void MainWindow :: updateData() | 546 | void MainWindow :: updateData() |
547 | { | 547 | { |
548 | m_progress->setTotalSteps( mgr->getServerList().count() ); | 548 | m_progress->setTotalSteps( mgr->getServerList().count() ); |
549 | 549 | ||
550 | serversList->clear(); | 550 | serversList->clear(); |
551 | packagesList->clear(); | 551 | packagesList->clear(); |
552 | 552 | ||
553 | int activeItem = -1; | 553 | int activeItem = -1; |
554 | int i = 0; | 554 | int i = 0; |
555 | QString serverName; | 555 | QString serverName; |
556 | 556 | ||
557 | QListIterator<Server> it( mgr->getServerList() ); | 557 | QListIterator<Server> it( mgr->getServerList() ); |
558 | Server *server; | 558 | Server *server; |
559 | 559 | ||
560 | for ( ; it.current(); ++it, ++i ) | 560 | for ( ; it.current(); ++it, ++i ) |
561 | { | 561 | { |
562 | server = it.current(); | 562 | server = it.current(); |
563 | serverName = server->getServerName(); | 563 | serverName = server->getServerName(); |
564 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); | 564 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); |
565 | m_progress->setProgress( i ); | 565 | m_progress->setProgress( i ); |
566 | qApp->processEvents(); | 566 | qApp->processEvents(); |
567 | 567 | ||
568 | if ( !server->isServerActive() ) | 568 | if ( !server->isServerActive() ) |
569 | { | 569 | { |
570 | i--; | 570 | i--; |
571 | continue; | 571 | continue; |
572 | } | 572 | } |
573 | 573 | ||
574 | serversList->insertItem( serverName ); | 574 | serversList->insertItem( serverName ); |
575 | if ( serverName == currentlySelectedServer ) | 575 | if ( serverName == currentlySelectedServer ) |
576 | activeItem = i; | 576 | activeItem = i; |
577 | } | 577 | } |
578 | 578 | ||
579 | // set selected server to be active server | 579 | // set selected server to be active server |
580 | if ( activeItem != -1 ) | 580 | if ( activeItem != -1 ) |
581 | serversList->setCurrentItem( activeItem ); | 581 | serversList->setCurrentItem( activeItem ); |
582 | serverSelected( 0, FALSE ); | 582 | serverSelected( 0, FALSE ); |
583 | } | 583 | } |
584 | 584 | ||
585 | void MainWindow :: serverSelected( int index ) | 585 | void MainWindow :: serverSelected( int index ) |
586 | { | 586 | { |
587 | serverSelected( index, TRUE ); | 587 | serverSelected( index, TRUE ); |
588 | } | 588 | } |
589 | 589 | ||
590 | void MainWindow :: serverSelected( int, bool raiseProgress ) | 590 | void MainWindow :: serverSelected( int, bool raiseProgress ) |
591 | { | 591 | { |
592 | QPixmap nullIcon( installedIcon.size() ); | 592 | QPixmap nullIcon( installedIcon.size() ); |
593 | nullIcon.fill( colorGroup().base() ); | 593 | nullIcon.fill( colorGroup().base() ); |
594 | 594 | ||
595 | // display packages | 595 | // display packages |
596 | QString serverName = serversList->currentText(); | 596 | QString serverName = serversList->currentText(); |
597 | currentlySelectedServer = serverName; | 597 | currentlySelectedServer = serverName; |
598 | 598 | ||
599 | Server *s = mgr->getServer( serverName ); | 599 | Server *s = mgr->getServer( serverName ); |
600 | 600 | ||
601 | QList<Package> &list = s->getPackageList(); | 601 | QList<Package> &list = s->getPackageList(); |
602 | QListIterator<Package> it( list ); | 602 | QListIterator<Package> it( list ); |
603 | 603 | ||
604 | // Display progress widget while loading list | 604 | // Display progress widget while loading list |
605 | bool doProgress = ( list.count() > 200 ); | 605 | bool doProgress = ( list.count() > 200 ); |
606 | if ( doProgress ) | 606 | if ( doProgress ) |
607 | { | 607 | { |
608 | if ( raiseProgress ) | 608 | if ( raiseProgress ) |
609 | { | 609 | { |
610 | stack->raiseWidget( progressWindow ); | 610 | stack->raiseWidget( progressWindow ); |
611 | } | 611 | } |
612 | m_progress->setTotalSteps( list.count() ); | 612 | m_progress->setTotalSteps( list.count() ); |
613 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 613 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
614 | } | 614 | } |
615 | 615 | ||
616 | packagesList->clear(); | 616 | packagesList->clear(); |
617 | 617 | ||
618 | #ifdef QWS | 618 | #ifdef QWS |
619 | // read download directory from config file | 619 | // read download directory from config file |
620 | Config cfg( "aqpkg" ); | 620 | Config cfg( "aqpkg" ); |
621 | cfg.setGroup( "settings" ); | 621 | cfg.setGroup( "settings" ); |
622 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 622 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
623 | #endif | 623 | #endif |
624 | 624 | ||
625 | int i = 0; | 625 | int i = 0; |
626 | Package *package; | 626 | Package *package; |
627 | for ( ; it.current(); ++it ) | 627 | for ( ; it.current(); ++it ) |
628 | { | 628 | { |
629 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 629 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
630 | i++; | 630 | i++; |
631 | if ( ( i % 100 ) == 0 ) | 631 | if ( ( i % 100 ) == 0 ) |
632 | { | 632 | { |
633 | if ( doProgress ) | 633 | if ( doProgress ) |
634 | { | 634 | { |
635 | m_progress->setProgress( i ); | 635 | m_progress->setProgress( i ); |
636 | } | 636 | } |
637 | qApp->processEvents(); | 637 | qApp->processEvents(); |
638 | } | 638 | } |
639 | 639 | ||
640 | QString text = ""; | 640 | QString text = ""; |
641 | 641 | ||
642 | package = it.current(); | 642 | package = it.current(); |
643 | 643 | ||
644 | // Apply show only uninstalled packages filter | 644 | // Apply show only uninstalled packages filter |
645 | if ( showUninstalledPkgs && package->isInstalled() ) | 645 | if ( showUninstalledPkgs && package->isInstalled() ) |
646 | continue; | 646 | continue; |
647 | 647 | ||
648 | // Apply show only installed packages filter | 648 | // Apply show only installed packages filter |
649 | if ( showInstalledPkgs && !package->isInstalled() ) | 649 | if ( showInstalledPkgs && !package->isInstalled() ) |
650 | continue; | 650 | continue; |
651 | 651 | ||
652 | // Apply show only new installed packages filter | 652 | // Apply show only new installed packages filter |
653 | if ( showUpgradedPkgs ) | 653 | if ( showUpgradedPkgs ) |
654 | { | 654 | { |
655 | if ( !package->isInstalled() || !package->getNewVersionAvailable() ) | 655 | if ( !package->isInstalled() || !package->getNewVersionAvailable() ) |
656 | continue; | 656 | continue; |
657 | } | 657 | } |
658 | 658 | ||
659 | // Apply the section filter | 659 | // Apply the section filter |
660 | if ( categoryFilterEnabled && categoryFilter != "" ) | 660 | if ( categoryFilterEnabled && categoryFilter != "" ) |
661 | { | 661 | { |
662 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) | 662 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) |
663 | continue; | 663 | continue; |
664 | } | 664 | } |
665 | 665 | ||
666 | // If the local server, only display installed packages | 666 | // If the local server, only display installed packages |
667 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) | 667 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) |
668 | continue; | 668 | continue; |
669 | 669 | ||
670 | 670 | ||
671 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), | 671 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), |
672 | QCheckListItem::CheckBox ); | 672 | QCheckListItem::CheckBox ); |
673 | 673 | ||
674 | if ( package->isInstalled() ) | 674 | if ( package->isInstalled() ) |
675 | { | 675 | { |
676 | // If a different version of package is available, show update available icon | 676 | // If a different version of package is available, show update available icon |
677 | // Otherwise, show installed icon | 677 | // Otherwise, show installed icon |
678 | if ( package->getNewVersionAvailable()) | 678 | if ( package->getNewVersionAvailable()) |
679 | { | 679 | { |
680 | 680 | ||
681 | item->setPixmap( 0, updatedIcon ); | 681 | item->setPixmap( 0, updatedIcon ); |
682 | } | 682 | } |
683 | else | 683 | else |
684 | { | 684 | { |
685 | item->setPixmap( 0, installedIcon ); | 685 | item->setPixmap( 0, installedIcon ); |
686 | } | 686 | } |
687 | } | 687 | } |
688 | else | 688 | else |
689 | { | 689 | { |
690 | item->setPixmap( 0, nullIcon ); | 690 | item->setPixmap( 0, nullIcon ); |
691 | } | 691 | } |
692 | 692 | ||
693 | packagesList->insertItem( item ); | 693 | packagesList->insertItem( item ); |
694 | } | 694 | } |
695 | 695 | ||
696 | // If the local server or the local ipkgs server disable the download button | 696 | // If the local server or the local ipkgs server disable the download button |
697 | if ( serverName == LOCAL_SERVER ) | 697 | if ( serverName == LOCAL_SERVER ) |
698 | { | 698 | { |
699 | downloadEnabled = TRUE; | 699 | downloadEnabled = TRUE; |
700 | actionUpgrade->setEnabled( FALSE ); | 700 | actionUpgrade->setEnabled( FALSE ); |
701 | } | 701 | } |
702 | else if ( serverName == LOCAL_IPKGS ) | 702 | else if ( serverName == LOCAL_IPKGS ) |
703 | { | 703 | { |
704 | downloadEnabled = FALSE; | 704 | downloadEnabled = FALSE; |
705 | actionUpgrade->setEnabled( FALSE ); | 705 | actionUpgrade->setEnabled( FALSE ); |
706 | } | 706 | } |
707 | else | 707 | else |
708 | { | 708 | { |
709 | downloadEnabled = TRUE; | 709 | downloadEnabled = TRUE; |
710 | actionUpgrade->setEnabled( TRUE ); | 710 | actionUpgrade->setEnabled( TRUE ); |
711 | } | 711 | } |
712 | enableDownload( downloadEnabled ); | 712 | enableDownload( downloadEnabled ); |
713 | 713 | ||
714 | // Display this widget once everything is done | 714 | // Display this widget once everything is done |
715 | if ( doProgress && raiseProgress ) | 715 | if ( doProgress && raiseProgress ) |
716 | { | 716 | { |
717 | stack->raiseWidget( networkPkgWindow ); | 717 | stack->raiseWidget( networkPkgWindow ); |
718 | } | 718 | } |
719 | } | 719 | } |
720 | 720 | ||
721 | void MainWindow :: searchForPackage( const QString &text ) | 721 | void MainWindow :: searchForPackage( const QString &text ) |
722 | { | 722 | { |
723 | if ( !text.isEmpty() ) | 723 | if ( !text.isEmpty() ) |
724 | { | 724 | { |
725 | // look through package list for text startng at current position | 725 | // look through package list for text startng at current position |
726 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 726 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
727 | 727 | ||
728 | if ( start == 0 ) | 728 | if ( start == 0 ) |
729 | start = (QCheckListItem *)packagesList->firstChild(); | 729 | start = (QCheckListItem *)packagesList->firstChild(); |
730 | 730 | ||
731 | for ( QCheckListItem *item = start; item != 0 ; | 731 | for ( QCheckListItem *item = start; item != 0 ; |
732 | item = (QCheckListItem *)item->nextSibling() ) | 732 | item = (QCheckListItem *)item->nextSibling() ) |
733 | { | 733 | { |
734 | if ( item->text().lower().find( text ) != -1 ) | 734 | if ( item->text().lower().find( text ) != -1 ) |
735 | { | 735 | { |
736 | packagesList->ensureItemVisible( item ); | 736 | packagesList->ensureItemVisible( item ); |
737 | packagesList->setCurrentItem( item ); | 737 | packagesList->setCurrentItem( item ); |
738 | break; | 738 | break; |
739 | } | 739 | } |
740 | } | 740 | } |
741 | } | 741 | } |
742 | } | 742 | } |
743 | 743 | ||
744 | void MainWindow :: updateServer() | 744 | void MainWindow :: updateServer() |
745 | { | 745 | { |
746 | QString serverName = serversList->currentText(); | 746 | QString serverName = serversList->currentText(); |
747 | 747 | ||
748 | // Update the current server | 748 | // Update the current server |
749 | // Display dialog | 749 | // Display dialog |
750 | 750 | ||
751 | // Disable buttons to stop silly people clicking lots on them :) | 751 | // Disable buttons to stop silly people clicking lots on them :) |
752 | 752 | ||
753 | // First, write out ipkg_conf file so that ipkg can use it | 753 | // First, write out ipkg_conf file so that ipkg can use it |
754 | mgr->writeOutIpkgConf(); | 754 | mgr->writeOutIpkgConf(); |
755 | 755 | ||
756 | Ipkg *ipkg = new Ipkg; | 756 | Ipkg *ipkg = new Ipkg; |
757 | ipkg->setOption( "update" ); | 757 | ipkg->setOption( "update" ); |
758 | 758 | ||
759 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), | 759 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), |
760 | tr( "Update lists" ) ); | 760 | tr( "Update lists" ) ); |
761 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 761 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
762 | reloadDocuments = FALSE; | 762 | reloadDocuments = FALSE; |
763 | stack->addWidget( dlg, 3 ); | 763 | stack->addWidget( dlg, 3 ); |
764 | stack->raiseWidget( dlg ); | 764 | stack->raiseWidget( dlg ); |
765 | 765 | ||
766 | // delete progDlg; | 766 | // delete progDlg; |
767 | } | 767 | } |
768 | 768 | ||
769 | void MainWindow :: upgradePackages() | 769 | void MainWindow :: upgradePackages() |
770 | { | 770 | { |
771 | // We're gonna do an upgrade of all packages | 771 | // We're gonna do an upgrade of all packages |
772 | // First warn user that this isn't recommended | 772 | // First warn user that this isn't recommended |
773 | // TODO - ODevice???? | 773 | // TODO - ODevice???? |
774 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); | 774 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); |
775 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, | 775 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, |
776 | QMessageBox::Yes, | 776 | QMessageBox::Yes, |
777 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 777 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
778 | 0, this ); | 778 | 0, this ); |
779 | warn.adjustSize(); | 779 | warn.adjustSize(); |
780 | 780 | ||
781 | if ( warn.exec() == QMessageBox::Yes ) | 781 | if ( warn.exec() == QMessageBox::Yes ) |
782 | { | 782 | { |
783 | // First, write out ipkg_conf file so that ipkg can use it | 783 | // First, write out ipkg_conf file so that ipkg can use it |
784 | mgr->writeOutIpkgConf(); | 784 | mgr->writeOutIpkgConf(); |
785 | 785 | ||
786 | // Now run upgrade | 786 | // Now run upgrade |
787 | Ipkg *ipkg = new Ipkg; | 787 | Ipkg *ipkg = new Ipkg; |
788 | ipkg->setOption( "upgrade" ); | 788 | ipkg->setOption( "upgrade" ); |
789 | 789 | ||
790 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), | 790 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), |
791 | tr ( "Upgrade" ) ); | 791 | tr ( "Upgrade" ) ); |
792 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 792 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
793 | reloadDocuments = TRUE; | 793 | reloadDocuments = TRUE; |
794 | stack->addWidget( dlg, 3 ); | 794 | stack->addWidget( dlg, 3 ); |
795 | stack->raiseWidget( dlg ); | 795 | stack->raiseWidget( dlg ); |
796 | } | 796 | } |
797 | } | 797 | } |
798 | 798 | ||
799 | void MainWindow :: downloadPackage() | 799 | void MainWindow :: downloadPackage() |
800 | { | 800 | { |
801 | bool doUpdate = true; | 801 | bool doUpdate = true; |
802 | if ( downloadEnabled ) | 802 | if ( downloadEnabled ) |
803 | { | 803 | { |
804 | // See if any packages are selected | 804 | // See if any packages are selected |
805 | bool found = false; | 805 | bool found = false; |
806 | if ( serversList->currentText() != LOCAL_SERVER ) | 806 | if ( serversList->currentText() != LOCAL_SERVER ) |
807 | { | 807 | { |
808 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 808 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
809 | item != 0 && !found; | 809 | item != 0 && !found; |
810 | item = (QCheckListItem *)item->nextSibling() ) | 810 | item = (QCheckListItem *)item->nextSibling() ) |
811 | { | 811 | { |
812 | if ( item->isOn() ) | 812 | if ( item->isOn() ) |
813 | found = true; | 813 | found = true; |
814 | } | 814 | } |
815 | } | 815 | } |
816 | 816 | ||
817 | // If user selected some packages then download the and store the locally | 817 | // If user selected some packages then download the and store the locally |
818 | // otherwise, display dialog asking user what package to download from an http server | 818 | // otherwise, display dialog asking user what package to download from an http server |
819 | // and whether to install it | 819 | // and whether to install it |
820 | if ( found ) | 820 | if ( found ) |
821 | downloadSelectedPackages(); | 821 | downloadSelectedPackages(); |
822 | else | 822 | else |
823 | downloadRemotePackage(); | 823 | downloadRemotePackage(); |
824 | 824 | ||
825 | } | 825 | } |
826 | else | 826 | else |
827 | { | 827 | { |
828 | doUpdate = false; | 828 | doUpdate = false; |
829 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 829 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
830 | item != 0 ; | 830 | item != 0 ; |
831 | item = (QCheckListItem *)item->nextSibling() ) | 831 | item = (QCheckListItem *)item->nextSibling() ) |
832 | { | 832 | { |
833 | if ( item->isOn() ) | 833 | if ( item->isOn() ) |
834 | { | 834 | { |
835 | QString name = item->text(); | 835 | QString name = item->text(); |
836 | int pos = name.find( "*" ); | 836 | int pos = name.find( "*" ); |
837 | name.truncate( pos ); | 837 | name.truncate( pos ); |
838 | 838 | ||
839 | // if (there is a (installed), remove it | 839 | // if (there is a (installed), remove it |
840 | pos = name.find( "(installed)" ); | 840 | pos = name.find( "(installed)" ); |
841 | if ( pos > 0 ) | 841 | if ( pos > 0 ) |
842 | name.truncate( pos - 1 ); | 842 | name.truncate( pos - 1 ); |
843 | 843 | ||
844 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); | 844 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); |
845 | 845 | ||
846 | QString msgtext; | 846 | QString msgtext; |
847 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); | 847 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); |
848 | if ( QMessageBox::information( this, tr( "Are you sure?" ), | 848 | if ( QMessageBox::information( this, tr( "Are you sure?" ), |
849 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) | 849 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) |
850 | { | 850 | { |
851 | doUpdate = true; | 851 | doUpdate = true; |
852 | QFile f( p->getFilename() ); | 852 | QFile f( p->getFilename() ); |
853 | f.remove(); | 853 | f.remove(); |
854 | } | 854 | } |
855 | } | 855 | } |
856 | } | 856 | } |
857 | } | 857 | } |
858 | 858 | ||
859 | if ( doUpdate ) | 859 | if ( doUpdate ) |
860 | { | 860 | { |
861 | reloadData( 0x0 ); | 861 | reloadData( 0x0 ); |
862 | } | 862 | } |
863 | } | 863 | } |
864 | 864 | ||
865 | void MainWindow :: downloadSelectedPackages() | 865 | void MainWindow :: downloadSelectedPackages() |
866 | { | 866 | { |
867 | // First, write out ipkg_conf file so that ipkg can use it | 867 | // First, write out ipkg_conf file so that ipkg can use it |
868 | mgr->writeOutIpkgConf(); | 868 | mgr->writeOutIpkgConf(); |
869 | 869 | ||
870 | // Display dialog to user asking where to download the files to | 870 | // Display dialog to user asking where to download the files to |
871 | bool ok = FALSE; | 871 | bool ok = FALSE; |
872 | QString dir = ""; | 872 | QString dir = ""; |
873 | #ifdef QWS | 873 | #ifdef QWS |
874 | // read download directory from config file | 874 | // read download directory from config file |
875 | Config cfg( "aqpkg" ); | 875 | Config cfg( "aqpkg" ); |
876 | cfg.setGroup( "settings" ); | 876 | cfg.setGroup( "settings" ); |
877 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 877 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
878 | #endif | 878 | #endif |
879 | 879 | ||
880 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 880 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
881 | if ( ok && !text.isEmpty() ) | 881 | if ( ok && !text.isEmpty() ) |
882 | dir = text; // user entered something and pressed ok | 882 | dir = text; // user entered something and pressed ok |
883 | else | 883 | else |
884 | return; // user entered nothing or pressed cancel | 884 | return; // user entered nothing or pressed cancel |
885 | 885 | ||
886 | #ifdef QWS | 886 | #ifdef QWS |
887 | // Store download directory in config file | 887 | // Store download directory in config file |
888 | cfg.writeEntry( "downloadDir", dir ); | 888 | cfg.writeEntry( "downloadDir", dir ); |
889 | #endif | 889 | #endif |
890 | 890 | ||
891 | // Get starting directory | 891 | // Get starting directory |
892 | char initDir[PATH_MAX]; | 892 | char initDir[PATH_MAX]; |
893 | getcwd( initDir, PATH_MAX ); | 893 | getcwd( initDir, PATH_MAX ); |
894 | 894 | ||
895 | // Download each package | 895 | // Download each package |
896 | Ipkg ipkg; | 896 | Ipkg ipkg; |
897 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 897 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
898 | 898 | ||
899 | ipkg.setOption( "download" ); | 899 | ipkg.setOption( "download" ); |
900 | ipkg.setRuntimeDirectory( dir ); | 900 | ipkg.setRuntimeDirectory( dir ); |
901 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 901 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
902 | item != 0 ; | 902 | item != 0 ; |
903 | item = (QCheckListItem *)item->nextSibling() ) | 903 | item = (QCheckListItem *)item->nextSibling() ) |
904 | { | 904 | { |
905 | if ( item->isOn() ) | 905 | if ( item->isOn() ) |
906 | { | 906 | { |
907 | ipkg.setPackage( item->text() ); | 907 | ipkg.setPackage( item->text() ); |
908 | ipkg.runIpkg( ); | 908 | ipkg.runIpkg( ); |
909 | } | 909 | } |
910 | } | 910 | } |
911 | } | 911 | } |
912 | 912 | ||
913 | void MainWindow :: downloadRemotePackage() | 913 | void MainWindow :: downloadRemotePackage() |
914 | { | 914 | { |
915 | // Display dialog | 915 | // Display dialog |
916 | bool ok; | 916 | bool ok; |
917 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); | 917 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); |
918 | if ( !ok || package.isEmpty() ) | 918 | if ( !ok || package.isEmpty() ) |
919 | return; | 919 | return; |
920 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 920 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
921 | // if ( dlg.exec() == QDialog::Rejected ) | 921 | // if ( dlg.exec() == QDialog::Rejected ) |
922 | // return; | 922 | // return; |
923 | 923 | ||
924 | // grab details from dialog | 924 | // grab details from dialog |
925 | // QString package = dlg.getPackageLocation(); | 925 | // QString package = dlg.getPackageLocation(); |
926 | 926 | ||
927 | InstallData *item = new InstallData(); | 927 | InstallData *item = new InstallData(); |
928 | item->option = "I"; | 928 | item->option = "I"; |
929 | item->packageName = package; | 929 | item->packageName = package; |
930 | QList<InstallData> workingPackages; | 930 | QList<InstallData> workingPackages; |
931 | workingPackages.setAutoDelete( TRUE ); | 931 | workingPackages.setAutoDelete( TRUE ); |
932 | workingPackages.append( item ); | 932 | workingPackages.append( item ); |
933 | 933 | ||
934 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); | 934 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); |
935 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 935 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
936 | reloadDocuments = TRUE; | 936 | reloadDocuments = TRUE; |
937 | stack->addWidget( dlg, 3 ); | 937 | stack->addWidget( dlg, 3 ); |
938 | stack->raiseWidget( dlg ); | 938 | stack->raiseWidget( dlg ); |
939 | } | 939 | } |
940 | 940 | ||
941 | 941 | ||
942 | void MainWindow :: applyChanges() | 942 | void MainWindow :: applyChanges() |
943 | { | 943 | { |
944 | stickyOption = ""; | 944 | stickyOption = ""; |
945 | 945 | ||
946 | // First, write out ipkg_conf file so that ipkg can use it | 946 | // First, write out ipkg_conf file so that ipkg can use it |
947 | mgr->writeOutIpkgConf(); | 947 | mgr->writeOutIpkgConf(); |
948 | 948 | ||
949 | // Now for each selected item | 949 | // Now for each selected item |
950 | // deal with it | 950 | // deal with it |
951 | 951 | ||
952 | QList<InstallData> workingPackages; | 952 | QList<InstallData> workingPackages; |
953 | workingPackages.setAutoDelete( TRUE ); | 953 | workingPackages.setAutoDelete( TRUE ); |
954 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 954 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
955 | item != 0 ; | 955 | item != 0 ; |
956 | item = (QCheckListItem *)item->nextSibling() ) | 956 | item = (QCheckListItem *)item->nextSibling() ) |
957 | { | 957 | { |
958 | if ( item->isOn() ) | 958 | if ( item->isOn() ) |
959 | { | 959 | { |
960 | InstallData *instdata = dealWithItem( item ); | 960 | InstallData *instdata = dealWithItem( item ); |
961 | if ( instdata ) | 961 | if ( instdata ) |
962 | workingPackages.append( instdata ); | 962 | workingPackages.append( instdata ); |
963 | else | 963 | else |
964 | return; | 964 | return; |
965 | } | 965 | } |
966 | } | 966 | } |
967 | 967 | ||
968 | if ( workingPackages.count() == 0 ) | 968 | if ( workingPackages.count() == 0 ) |
969 | { | 969 | { |
970 | // Nothing to do | 970 | // Nothing to do |
971 | QMessageBox::information( this, tr( "Nothing to do" ), | 971 | QMessageBox::information( this, tr( "Nothing to do" ), |
972 | tr( "No packages selected" ), tr( "OK" ) ); | 972 | tr( "No packages selected" ), tr( "OK" ) ); |
973 | 973 | ||
974 | return; | 974 | return; |
975 | } | 975 | } |
976 | 976 | ||
977 | // do the stuff | 977 | // do the stuff |
978 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); | 978 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); |
979 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 979 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
980 | reloadDocuments = TRUE; | 980 | reloadDocuments = TRUE; |
981 | stack->addWidget( dlg, 3 ); | 981 | stack->addWidget( dlg, 3 ); |
982 | stack->raiseWidget( dlg ); | 982 | stack->raiseWidget( dlg ); |
983 | } | 983 | } |
984 | 984 | ||
985 | // decide what to do - either remove, upgrade or install | 985 | // decide what to do - either remove, upgrade or install |
986 | // Current rules: | 986 | // Current rules: |
987 | // If not installed - install | 987 | // If not installed - install |
988 | // If installed and different version available - upgrade | 988 | // If installed and different version available - upgrade |
989 | // If installed and version up to date - remove | 989 | // If installed and version up to date - remove |
990 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) | 990 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) |
991 | { | 991 | { |
992 | QString name = item->text(); | 992 | QString name = item->text(); |
993 | 993 | ||
994 | // Get package | 994 | // Get package |
995 | Server *s = mgr->getServer( serversList->currentText() ); | 995 | Server *s = mgr->getServer( serversList->currentText() ); |
996 | Package *p = s->getPackage( name ); | 996 | Package *p = s->getPackage( name ); |
997 | 997 | ||
998 | // If the package has a filename then it is a local file | 998 | // If the package has a filename then it is a local file |
999 | if ( p->isPackageStoredLocally() ) | 999 | if ( p->isPackageStoredLocally() ) |
1000 | name = p->getFilename(); | 1000 | name = p->getFilename(); |
1001 | 1001 | ||
1002 | QString option; | 1002 | QString option; |
1003 | QString dest = "root"; | 1003 | QString dest = "root"; |
1004 | if ( !p->isInstalled() ) | 1004 | if ( !p->isInstalled() ) |
1005 | { | 1005 | { |
1006 | InstallData *newitem = new InstallData(); | 1006 | InstallData *newitem = new InstallData(); |
1007 | newitem->option = "I"; | 1007 | newitem->option = "I"; |
1008 | newitem->packageName = name; | 1008 | newitem->packageName = name; |
1009 | return newitem; | 1009 | return newitem; |
1010 | } | 1010 | } |
1011 | else | 1011 | else |
1012 | { | 1012 | { |
1013 | InstallData *newitem = new InstallData(); | 1013 | InstallData *newitem = new InstallData(); |
1014 | newitem->option = "D"; | 1014 | newitem->option = "D"; |
1015 | |||
1016 | // If local file, remove using package name, not filename | ||
1017 | if ( p->isPackageStoredLocally() ) | ||
1018 | name = item->text(); | ||
1019 | |||
1015 | if ( !p->isPackageStoredLocally() ) | 1020 | if ( !p->isPackageStoredLocally() ) |
1016 | newitem->packageName = p->getInstalledPackageName(); | 1021 | newitem->packageName = p->getInstalledPackageName(); |
1017 | else | 1022 | else |
1018 | newitem->packageName = name; | 1023 | newitem->packageName = name; |
1019 | 1024 | ||
1020 | if ( p->getInstalledTo() ) | 1025 | if ( p->getInstalledTo() ) |
1021 | { | 1026 | { |
1022 | newitem->destination = p->getInstalledTo(); | 1027 | newitem->destination = p->getInstalledTo(); |
1023 | } | 1028 | } |
1024 | else | 1029 | else |
1025 | { | 1030 | { |
1026 | newitem->destination = p->getLocalPackage()->getInstalledTo(); | 1031 | newitem->destination = p->getLocalPackage()->getInstalledTo(); |
1027 | } | 1032 | } |
1028 | 1033 | ||
1029 | // Now see if version is newer or not | 1034 | // Now see if version is newer or not |
1030 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 1035 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
1031 | 1036 | ||
1032 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 1037 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
1033 | if ( p->isPackageStoredLocally() && val == -1 ) | 1038 | if ( p->isPackageStoredLocally() && val == -1 ) |
1034 | val = 0; | 1039 | val = 0; |
1035 | 1040 | ||
1036 | if ( val == -2 ) | 1041 | if ( val == -2 ) |
1037 | { | 1042 | { |
1038 | // Error - should handle | 1043 | // Error - should handle |
1039 | } | 1044 | } |
1040 | else if ( val == -1 ) | 1045 | else if ( val == -1 ) |
1041 | { | 1046 | { |
1042 | // Version available is older - remove only | 1047 | // Version available is older - remove only |
1043 | newitem->option = "D"; | 1048 | newitem->option = "D"; |
1049 | |||
1050 | // If local file, remove using package name, not filename | ||
1051 | if ( p->isPackageStoredLocally() ) | ||
1052 | name = item->text(); | ||
1044 | } | 1053 | } |
1045 | else | 1054 | else |
1046 | { | 1055 | { |
1047 | QString caption; | 1056 | QString caption; |
1048 | QString text; | 1057 | QString text; |
1049 | QString secondButton; | 1058 | QString secondButton; |
1050 | QString secondOption; | 1059 | QString secondOption; |
1051 | if ( val == 0 ) | 1060 | if ( val == 0 ) |
1052 | { | 1061 | { |
1053 | // Version available is the same - option to remove or reinstall | 1062 | // Version available is the same - option to remove or reinstall |
1054 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | 1063 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); |
1055 | text = tr( "Remove or ReInstall" ); | 1064 | text = tr( "Remove or ReInstall" ); |
1056 | secondButton = tr( "ReInstall" ); | 1065 | secondButton = tr( "ReInstall" ); |
1057 | secondOption = "R"; // Internal action code, do not translate | 1066 | secondOption = "R"; // Internal action code, do not translate |
1058 | } | 1067 | } |
1059 | else if ( val == 1 ) | 1068 | else if ( val == 1 ) |
1060 | { | 1069 | { |
1061 | // Version available is newer - option to remove or upgrade | 1070 | // Version available is newer - option to remove or upgrade |
1062 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | 1071 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); |
1063 | text = tr( "Remove or Upgrade" ); | 1072 | text = tr( "Remove or Upgrade" ); |
1064 | secondButton = tr( "Upgrade" ); | 1073 | secondButton = tr( "Upgrade" ); |
1065 | secondOption = "U"; // Internal action code, do not translate | 1074 | secondOption = "U"; // Internal action code, do not translate |
1066 | } | 1075 | } |
1067 | 1076 | ||
1068 | // Sticky option not implemented yet, but will eventually allow | 1077 | // Sticky option not implemented yet, but will eventually allow |
1069 | // the user to say something like 'remove all' | 1078 | // the user to say something like 'remove all' |
1070 | if ( stickyOption == "" ) | 1079 | if ( stickyOption == "" ) |
1071 | { | 1080 | { |
1072 | QString msgtext; | 1081 | QString msgtext; |
1073 | msgtext = caption.arg( ( const char * )name ); | 1082 | msgtext = caption.arg( ( const char * )name ); |
1074 | QuestionDlg dlg( text, msgtext, secondButton ); | 1083 | QuestionDlg dlg( text, msgtext, secondButton ); |
1075 | switch( dlg.exec() ) | 1084 | switch( dlg.exec() ) |
1076 | { | 1085 | { |
1077 | case 0: // Cancel | 1086 | case 0: // Cancel |
1078 | delete newitem; | 1087 | delete newitem; |
1079 | return 0x0; | 1088 | return 0x0; |
1080 | break; | 1089 | break; |
1081 | case 1: // Remove | 1090 | case 1: // Remove |
1082 | newitem->option = "D"; | 1091 | newitem->option = "D"; |
1092 | // If local file, remove using package name, not filename | ||
1093 | if ( p->isPackageStoredLocally() ) | ||
1094 | name = item->text(); | ||
1083 | break; | 1095 | break; |
1084 | case 2: // Reinstall or Upgrade | 1096 | case 2: // Reinstall or Upgrade |
1085 | newitem->option = secondOption; | 1097 | newitem->option = secondOption; |
1086 | break; | 1098 | break; |
1087 | } | 1099 | } |
1088 | } | 1100 | } |
1089 | else | 1101 | else |
1090 | { | 1102 | { |
1091 | // newitem->option = stickyOption; | 1103 | // newitem->option = stickyOption; |
1092 | } | 1104 | } |
1093 | } | 1105 | } |
1094 | 1106 | ||
1095 | 1107 | ||
1096 | // Check if we are reinstalling the same version | 1108 | // Check if we are reinstalling the same version |
1097 | if ( newitem->option != "R" ) | 1109 | if ( newitem->option != "R" ) |
1098 | newitem->recreateLinks = true; | 1110 | newitem->recreateLinks = true; |
1099 | else | 1111 | else |
1100 | newitem->recreateLinks = false; | 1112 | newitem->recreateLinks = false; |
1101 | 1113 | ||
1102 | // User hit cancel (on dlg - assume remove) | 1114 | // User hit cancel (on dlg - assume remove) |
1103 | return newitem; | 1115 | return newitem; |
1104 | } | 1116 | } |
1105 | } | 1117 | } |
1106 | 1118 | ||
1107 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) | 1119 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) |
1108 | { | 1120 | { |
1109 | stack->raiseWidget( progressWindow ); | 1121 | stack->raiseWidget( progressWindow ); |
1110 | 1122 | ||
1111 | if ( dlg ) | 1123 | if ( dlg ) |
1112 | { | 1124 | { |
1113 | dlg->close(); | 1125 | dlg->close(); |
1114 | delete dlg; | 1126 | delete dlg; |
1115 | } | 1127 | } |
1116 | 1128 | ||
1117 | mgr->reloadServerData(); | 1129 | mgr->reloadServerData(); |
1118 | serverSelected( -1, FALSE ); | 1130 | serverSelected( -1, FALSE ); |
1119 | 1131 | ||
1120 | #ifdef QWS | 1132 | #ifdef QWS |
1121 | if ( reloadDocuments ) | 1133 | if ( reloadDocuments ) |
1122 | { | 1134 | { |
1123 | m_status->setText( tr( "Updating Launcher..." ) ); | 1135 | m_status->setText( tr( "Updating Launcher..." ) ); |
1124 | 1136 | ||
1125 | // Finally let the main system update itself | 1137 | // Finally let the main system update itself |
1126 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 1138 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
1127 | QString lf = QString::null; | 1139 | QString lf = QString::null; |
1128 | e << lf; | 1140 | e << lf; |
1129 | } | 1141 | } |
1130 | #endif | 1142 | #endif |
1131 | 1143 | ||
1132 | stack->raiseWidget( networkPkgWindow ); | 1144 | stack->raiseWidget( networkPkgWindow ); |
1133 | } | 1145 | } |
1134 | 1146 | ||
1135 | void MainWindow :: letterPushed( QString t ) | 1147 | void MainWindow :: letterPushed( QString t ) |
1136 | { | 1148 | { |
1137 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 1149 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
1138 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 1150 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
1139 | if ( packagesList->firstChild() == 0 ) | 1151 | if ( packagesList->firstChild() == 0 ) |
1140 | return; | 1152 | return; |
1141 | 1153 | ||
1142 | QCheckListItem *item; | 1154 | QCheckListItem *item; |
1143 | if ( start == 0 ) | 1155 | if ( start == 0 ) |
1144 | { | 1156 | { |
1145 | item = (QCheckListItem *)packagesList->firstChild(); | 1157 | item = (QCheckListItem *)packagesList->firstChild(); |
1146 | start = top; | 1158 | start = top; |
1147 | } | 1159 | } |
1148 | else | 1160 | else |
1149 | item = (QCheckListItem *)start->nextSibling(); | 1161 | item = (QCheckListItem *)start->nextSibling(); |
1150 | 1162 | ||
1151 | if ( item == 0 ) | 1163 | if ( item == 0 ) |
1152 | item = (QCheckListItem *)packagesList->firstChild(); | 1164 | item = (QCheckListItem *)packagesList->firstChild(); |
1153 | do | 1165 | do |
1154 | { | 1166 | { |
1155 | if ( item->text().lower().startsWith( t.lower() ) ) | 1167 | if ( item->text().lower().startsWith( t.lower() ) ) |
1156 | { | 1168 | { |
1157 | packagesList->setSelected( item, true ); | 1169 | packagesList->setSelected( item, true ); |
1158 | packagesList->ensureItemVisible( item ); | 1170 | packagesList->ensureItemVisible( item ); |
1159 | break; | 1171 | break; |
1160 | } | 1172 | } |
1161 | 1173 | ||
1162 | item = (QCheckListItem *)item->nextSibling(); | 1174 | item = (QCheckListItem *)item->nextSibling(); |
1163 | if ( !item ) | 1175 | if ( !item ) |
1164 | item = (QCheckListItem *)packagesList->firstChild(); | 1176 | item = (QCheckListItem *)packagesList->firstChild(); |
1165 | } while ( item != start); | 1177 | } while ( item != start); |
1166 | } | 1178 | } |
1167 | 1179 | ||
1168 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) | 1180 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) |
1169 | { | 1181 | { |
1170 | QString itemstr( ((QCheckListItem*)item)->text() ); | 1182 | QString itemstr( ((QCheckListItem*)item)->text() ); |
1171 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); | 1183 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); |
1172 | p->showMaximized(); | 1184 | p->showMaximized(); |
1173 | } | 1185 | } |
1174 | 1186 | ||
1175 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) | 1187 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) |
1176 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) | 1188 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) |
1177 | { | 1189 | { |
1178 | setCaption( caption ); | 1190 | setCaption( caption ); |
1179 | resize( 175, 100 ); | 1191 | resize( 175, 100 ); |
1180 | 1192 | ||
1181 | QGridLayout *layout = new QGridLayout( this ); | 1193 | QGridLayout *layout = new QGridLayout( this ); |
1182 | 1194 | ||
1183 | QLabel *l = new QLabel( text, this ); | 1195 | QLabel *l = new QLabel( text, this ); |
1184 | l->setAlignment( AlignCenter | WordBreak ); | 1196 | l->setAlignment( AlignCenter | WordBreak ); |
1185 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); | 1197 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); |
1186 | 1198 | ||
1187 | btn1 = new QPushButton( tr( "Remove" ), this ); | 1199 | btn1 = new QPushButton( tr( "Remove" ), this ); |
1188 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1200 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1189 | layout->addWidget( btn1, 1, 0 ); | 1201 | layout->addWidget( btn1, 1, 0 ); |
1190 | 1202 | ||
1191 | btn2 = new QPushButton( secondbtn, this ); | 1203 | btn2 = new QPushButton( secondbtn, this ); |
1192 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1204 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1193 | layout->addWidget( btn2, 1, 1 ); | 1205 | layout->addWidget( btn2, 1, 1 ); |
1194 | 1206 | ||
1195 | executing = FALSE; | 1207 | executing = FALSE; |
1196 | } | 1208 | } |
1197 | 1209 | ||
1198 | int QuestionDlg::exec() | 1210 | int QuestionDlg::exec() |
1199 | { | 1211 | { |
1200 | show(); | 1212 | show(); |
1201 | 1213 | ||
1202 | if ( !executing ) | 1214 | if ( !executing ) |
1203 | { | 1215 | { |
1204 | executing = TRUE; | 1216 | executing = TRUE; |
1205 | qApp->enter_loop(); | 1217 | qApp->enter_loop(); |
1206 | } | 1218 | } |
1207 | 1219 | ||
1208 | return buttonpressed; | 1220 | return buttonpressed; |
1209 | } | 1221 | } |
1210 | 1222 | ||
1211 | void QuestionDlg::slotButtonPressed() | 1223 | void QuestionDlg::slotButtonPressed() |
1212 | { | 1224 | { |
1213 | if ( sender() == btn1 ) | 1225 | if ( sender() == btn1 ) |
1214 | buttonpressed = 1; | 1226 | buttonpressed = 1; |
1215 | else if ( sender() == btn2 ) | 1227 | else if ( sender() == btn2 ) |
1216 | buttonpressed = 2; | 1228 | buttonpressed = 2; |
1217 | else | 1229 | else |
1218 | buttonpressed = 0; | 1230 | buttonpressed = 0; |
1219 | 1231 | ||
1220 | qApp->exit_loop(); | 1232 | qApp->exit_loop(); |
1221 | } | 1233 | } |
diff --git a/noncore/settings/aqpkg/opie-aqpkg.control b/noncore/settings/aqpkg/opie-aqpkg.control index b8ad1e8..46bffdd 100644 --- a/noncore/settings/aqpkg/opie-aqpkg.control +++ b/noncore/settings/aqpkg/opie-aqpkg.control | |||
@@ -1,11 +1,11 @@ | |||
1 | Package: opie-aqpkg | 1 | Package: opie-aqpkg |
2 | Files: bin/aqpkg pics/aqpkg apps/Settings/aqpkg.desktop | 2 | Files: bin/aqpkg pics/aqpkg apps/Settings/aqpkg.desktop |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: Settings | 4 | Section: Settings |
5 | Version: $QPE_VERSION-$SUB_VERSION | ||
6 | Depends: task-opie-minimal | 5 | Depends: task-opie-minimal |
7 | Replaces: aqpkg | 6 | Replaces: aqpkg |
8 | Architecture: arm | 7 | Architecture: arm |
9 | Maintainer: Andy Qua (andy.qua@blueyonder.co.uk) | 8 | Maintainer: Andy Qua (andy.qua@blueyonder.co.uk) |
10 | Description: A Package Manager | 9 | Description: A Package Manager |
11 | 10 | ||
11 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/settings/aqpkg/package.cpp b/noncore/settings/aqpkg/package.cpp index adda832..5a521d3 100644 --- a/noncore/settings/aqpkg/package.cpp +++ b/noncore/settings/aqpkg/package.cpp | |||
@@ -1,162 +1,163 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "package.h" | 30 | #include "package.h" |
31 | #include "global.h" | 31 | #include "global.h" |
32 | 32 | ||
33 | #include <qobject.h> | 33 | #include <qobject.h> |
34 | 34 | ||
35 | Package::Package( QString &name ) | 35 | Package::Package( QString &name ) |
36 | { | 36 | { |
37 | packageName = name; | 37 | packageName = name; |
38 | 38 | ||
39 | QString tempstr = QObject::tr( "N/A" ); | 39 | QString tempstr = QObject::tr( "N/A" ); |
40 | version = tempstr; | 40 | version = tempstr; |
41 | description = tempstr; | 41 | description = tempstr; |
42 | packageSize = tempstr; | 42 | packageSize = tempstr; |
43 | section = tempstr; | 43 | section = tempstr; |
44 | 44 | ||
45 | localPackage = 0; | 45 | localPackage = 0; |
46 | installed = false; | 46 | installed = false; |
47 | packageStoredLocally = false; | 47 | packageStoredLocally = false; |
48 | installedToRoot = false; | 48 | installedToRoot = false; |
49 | installed = false; | 49 | installed = false; |
50 | installedTo = 0; | 50 | installedTo = 0; |
51 | } | 51 | } |
52 | 52 | ||
53 | Package::Package( char *name ) | 53 | Package::Package( char *name ) |
54 | { | 54 | { |
55 | packageName = name; | 55 | packageName = name; |
56 | 56 | ||
57 | QString tempstr = QObject::tr( "N/A" ); | 57 | QString tempstr = QObject::tr( "N/A" ); |
58 | version = tempstr; | 58 | version = tempstr; |
59 | description = tempstr; | 59 | description = tempstr; |
60 | packageSize = tempstr; | 60 | packageSize = tempstr; |
61 | section = tempstr; | 61 | section = tempstr; |
62 | 62 | ||
63 | localPackage = 0; | 63 | localPackage = 0; |
64 | installed = false; | 64 | installed = false; |
65 | packageStoredLocally = false; | 65 | packageStoredLocally = false; |
66 | installedToRoot = false; | 66 | installedToRoot = false; |
67 | installed = false; | 67 | installed = false; |
68 | installedTo = 0; | 68 | installedTo = 0; |
69 | differentVersionAvailable = false; | 69 | differentVersionAvailable = false; |
70 | } | 70 | } |
71 | 71 | ||
72 | Package::~Package() | 72 | Package::~Package() |
73 | { | 73 | { |
74 | } | 74 | } |
75 | 75 | ||
76 | QString Package :: toString() | 76 | QString Package :: toString() |
77 | { | 77 | { |
78 | QString ret = QObject::tr( "Package - %1\n version - %2" ). | 78 | QString ret = QObject::tr( "Package - %1\n version - %2" ). |
79 | arg( getPackageName() ). | 79 | arg( getPackageName() ). |
80 | arg( getVersion() ); | 80 | arg( getVersion() ); |
81 | 81 | ||
82 | if ( localPackage ) | 82 | if ( localPackage ) |
83 | ret.append( QObject::tr( "\n inst version - %1" ).arg( localPackage->getVersion() ) ); | 83 | ret.append( QObject::tr( "\n inst version - %1" ).arg( localPackage->getVersion() ) ); |
84 | 84 | ||
85 | 85 | ||
86 | return ret; | 86 | return ret; |
87 | } | 87 | } |
88 | 88 | ||
89 | void Package :: setStatus( const QString &s ) | 89 | void Package :: setStatus( const QString &s ) |
90 | { | 90 | { |
91 | QString state_status; | 91 | QString state_status; |
92 | int two, three; | 92 | int two, three; |
93 | 93 | ||
94 | status = s.simplifyWhiteSpace( ); | 94 | status = s.simplifyWhiteSpace( ); |
95 | 95 | ||
96 | two = status.find( " " ); // find second column | 96 | two = status.find( " " ); // find second column |
97 | three = status.find( " ", two + 1 ); // find third column | 97 | three = status.find( " ", two + 1 ); // find third column |
98 | 98 | ||
99 | state_status = status.mid( three ).stripWhiteSpace( ); | 99 | state_status = status.mid( three ).stripWhiteSpace( ); |
100 | 100 | ||
101 | if ( state_status == "installed" ) | 101 | if ( state_status == "installed" ) |
102 | installed = true; | 102 | installed = true; |
103 | } | 103 | } |
104 | 104 | ||
105 | void Package :: setLocalPackage( Package *p ) | 105 | void Package :: setLocalPackage( Package *p ) |
106 | { | 106 | { |
107 | localPackage = p; | 107 | localPackage = p; |
108 | 108 | ||
109 | if ( localPackage ) | 109 | if ( localPackage ) |
110 | if ( localPackage->getVersion() < getVersion() && !installed ) | 110 | if ( localPackage->getVersion() < getVersion() && !installed ) |
111 | differentVersionAvailable = true; | 111 | differentVersionAvailable = true; |
112 | else | 112 | else |
113 | differentVersionAvailable = false; | 113 | differentVersionAvailable = false; |
114 | } | 114 | } |
115 | 115 | ||
116 | void Package :: setVersion( const QString &v ) | 116 | void Package :: setVersion( const QString &v ) |
117 | { | 117 | { |
118 | version = v; | 118 | version = v; |
119 | differentVersionAvailable = false; | ||
119 | 120 | ||
120 | if ( localPackage ) | 121 | if ( localPackage ) |
121 | if ( localPackage->getVersion() < getVersion() && !installed ) | 122 | if ( localPackage->getVersion() < getVersion() && !installed ) |
122 | differentVersionAvailable = true; | 123 | differentVersionAvailable = true; |
123 | else | 124 | else |
124 | differentVersionAvailable = false; | 125 | differentVersionAvailable = false; |
125 | } | 126 | } |
126 | 127 | ||
127 | void Package :: setPackageName( const QString &name ) | 128 | void Package :: setPackageName( const QString &name ) |
128 | { | 129 | { |
129 | packageName = name; | 130 | packageName = name; |
130 | } | 131 | } |
131 | 132 | ||
132 | void Package :: setDescription( const QString &d ) | 133 | void Package :: setDescription( const QString &d ) |
133 | { | 134 | { |
134 | description = d; | 135 | description = d; |
135 | } | 136 | } |
136 | 137 | ||
137 | void Package :: setFilename( const QString &f ) | 138 | void Package :: setFilename( const QString &f ) |
138 | { | 139 | { |
139 | filename = f; | 140 | filename = f; |
140 | } | 141 | } |
141 | 142 | ||
142 | 143 | ||
143 | QString Package :: getInstalledVersion() | 144 | QString Package :: getInstalledVersion() |
144 | { | 145 | { |
145 | if ( localPackage ) | 146 | if ( localPackage ) |
146 | return localPackage->getVersion(); | 147 | return localPackage->getVersion(); |
147 | else | 148 | else |
148 | return getVersion(); | 149 | return getVersion(); |
149 | } | 150 | } |
150 | 151 | ||
151 | QString Package :: getInstalledPackageName() | 152 | QString Package :: getInstalledPackageName() |
152 | { | 153 | { |
153 | if ( localPackage ) | 154 | if ( localPackage ) |
154 | return localPackage->getPackageName(); | 155 | return localPackage->getPackageName(); |
155 | else | 156 | else |
156 | return getPackageName(); | 157 | return getPackageName(); |
157 | } | 158 | } |
158 | 159 | ||
159 | bool Package :: isInstalled() | 160 | bool Package :: isInstalled() |
160 | { | 161 | { |
161 | return installed || ( localPackage && localPackage->isInstalled() ); | 162 | return installed || ( localPackage && localPackage->isInstalled() ); |
162 | } | 163 | } |
diff --git a/noncore/settings/aqpkg/packagewin.cpp b/noncore/settings/aqpkg/packagewin.cpp index 9553cd1..499d647 100644 --- a/noncore/settings/aqpkg/packagewin.cpp +++ b/noncore/settings/aqpkg/packagewin.cpp | |||
@@ -1,118 +1,119 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "packagewin.h" | 30 | #include "packagewin.h" |
31 | #include "package.h" | 31 | #include "package.h" |
32 | #include "datamgr.h" | 32 | #include "datamgr.h" |
33 | 33 | ||
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | 35 | ||
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qtextview.h> | 39 | #include <qtextview.h> |
40 | 40 | ||
41 | PackageWindow::PackageWindow( Package *package, const QString &server ) | 41 | PackageWindow::PackageWindow( Package *package, const QString &server ) |
42 | : QWidget( 0, 0, 0 ) | 42 | : QWidget( 0, 0, 0 ) |
43 | { | 43 | { |
44 | QString str; | 44 | QString str; |
45 | if ( package ) | 45 | if ( package ) |
46 | { | 46 | { |
47 | Package *local = package->getLocalPackage(); | ||
47 | setCaption( package->getPackageName() ); | 48 | setCaption( package->getPackageName() ); |
48 | QString destName; | 49 | QString destName; |
49 | if ( package->getLocalPackage() ) | 50 | if ( local ) |
50 | { | 51 | { |
51 | if ( package->getLocalPackage()->getInstalledTo() ) | 52 | if ( local->getInstalledTo() ) |
52 | destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); | 53 | destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); |
53 | } | 54 | } |
54 | else | 55 | else |
55 | { | 56 | { |
56 | if ( package->getInstalledTo() ) | 57 | if ( package->getInstalledTo() ) |
57 | destName = package->getInstalledTo()->getDestinationName(); | 58 | destName = package->getInstalledTo()->getDestinationName(); |
58 | } | 59 | } |
59 | 60 | ||
60 | if ( !package->isPackageStoredLocally() ) | 61 | if ( !package->isPackageStoredLocally() ) |
61 | { | 62 | { |
62 | str.append( tr( "<b>Description</b> - " ) ); | 63 | str.append( tr( "<b>Description</b> - " ) ); |
63 | str.append( package->getDescription() ); | 64 | str.append( package->getDescription() ); |
64 | if ( !destName.isNull() ) | 65 | if ( !destName.isNull() ) |
65 | { | 66 | { |
66 | str.append( tr( "<p><b>Installed To</b> - " ) ); | 67 | str.append( tr( "<p><b>Installed To</b> - " ) ); |
67 | str.append( destName ); | 68 | str.append( destName ); |
68 | } | 69 | } |
69 | str.append( tr( "<p><b>Size</b> - " ) ); | 70 | str.append( tr( "<p><b>Size</b> - " ) ); |
70 | str.append( package->getPackageSize() ); | 71 | str.append( package->getPackageSize() ); |
71 | str.append( tr( "<p><b>Section</b> - " ) ); | 72 | str.append( tr( "<p><b>Section</b> - " ) ); |
72 | str.append( package->getSection() ); | 73 | str.append( package->getSection() ); |
73 | } | 74 | } |
74 | else | 75 | else |
75 | { | 76 | { |
76 | str.append( tr( "<p><b>Filename</b> - " ) ); | 77 | str.append( tr( "<p><b>Filename</b> - " ) ); |
77 | str.append( package->getFilename() ); | 78 | str.append( package->getFilename() ); |
78 | } | 79 | } |
79 | 80 | ||
80 | if ( server == LOCAL_SERVER ) | 81 | if ( server == LOCAL_SERVER ) |
81 | { | 82 | { |
82 | str.append( tr( "<p><b>Version Installed</b> - " ) ); | 83 | str.append( tr( "<p><b>Version Installed</b> - " ) ); |
83 | str.append( package->getVersion() ); | 84 | str.append( package->getVersion() ); |
84 | } | 85 | } |
85 | else | 86 | else |
86 | { | 87 | { |
87 | str.append( tr( "<p><b>Version Available</b> - " ) ); | 88 | str.append( tr( "<p><b>Version Available</b> - " ) ); |
88 | str.append( package->getVersion() ); | 89 | str.append( package->getVersion() ); |
89 | if ( package->getLocalPackage() ) | 90 | if ( local ) |
90 | { | 91 | { |
91 | if ( package->isInstalled() ) | 92 | if ( package->isInstalled() ) |
92 | { | 93 | { |
93 | str.append( tr( "<p><b>Version Installed</b> - " ) ); | 94 | str.append( tr( "<p><b>Version Installed</b> - " ) ); |
94 | str.append( package->getInstalledVersion() ); | 95 | str.append( package->getInstalledVersion() ); |
95 | } | 96 | } |
96 | } | 97 | } |
97 | } | 98 | } |
98 | } | 99 | } |
99 | else | 100 | else |
100 | { | 101 | { |
101 | setCaption( tr( "Package Information" ) ); | 102 | setCaption( tr( "Package Information" ) ); |
102 | str = tr( "Package information is unavailable" ); | 103 | str = tr( "Package information is unavailable" ); |
103 | } | 104 | } |
104 | 105 | ||
105 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 ); | 106 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 ); |
106 | 107 | ||
107 | QTextView *l = new QTextView( str, QString::null, this ); | 108 | QTextView *l = new QTextView( str, QString::null, this ); |
108 | layout->addWidget( l ); | 109 | layout->addWidget( l ); |
109 | 110 | ||
110 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this ); | 111 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this ); |
111 | layout->addWidget( btn ); | 112 | layout->addWidget( btn ); |
112 | connect( btn, SIGNAL( clicked() ), this, SLOT( close() ) ); | 113 | connect( btn, SIGNAL( clicked() ), this, SLOT( close() ) ); |
113 | 114 | ||
114 | } | 115 | } |
115 | 116 | ||
116 | PackageWindow::~PackageWindow() | 117 | PackageWindow::~PackageWindow() |
117 | { | 118 | { |
118 | } | 119 | } |
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index 4693db1..0282236 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp | |||
@@ -1,315 +1,326 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "server.h" | 30 | #include "server.h" |
31 | #include "datamgr.h" | 31 | #include "datamgr.h" |
32 | 32 | ||
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | 35 | ||
36 | #ifdef QWS | 36 | #ifdef QWS |
37 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
38 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
39 | #include <qlist.h> | 39 | #include <qlist.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include "utils.h" | 42 | #include "utils.h" |
43 | 43 | ||
44 | #include "global.h" | 44 | #include "global.h" |
45 | 45 | ||
46 | Server :: Server( const char *name, const char *url ) | 46 | Server :: Server( const char *name, const char *url ) |
47 | { | 47 | { |
48 | serverName = name; | 48 | serverName = name; |
49 | serverUrl = url; | 49 | serverUrl = url; |
50 | packageFile = IPKG_DIR; | 50 | packageFile = IPKG_DIR; |
51 | active = true; | 51 | active = true; |
52 | packageFile.append( "lists/" ); | 52 | packageFile.append( "lists/" ); |
53 | packageFile.append( serverName ); | 53 | packageFile.append( serverName ); |
54 | } | 54 | } |
55 | 55 | ||
56 | Server :: ~Server() | 56 | Server :: ~Server() |
57 | { | 57 | { |
58 | cleanUp(); | 58 | cleanUp(); |
59 | } | 59 | } |
60 | 60 | ||
61 | void Server :: cleanUp() | 61 | void Server :: cleanUp() |
62 | { | 62 | { |
63 | packageList.clear(); | 63 | packageList.clear(); |
64 | } | 64 | } |
65 | 65 | ||
66 | void Server :: readStatusFile( QList<Destination> &destList ) | 66 | void Server :: readStatusFile( QList<Destination> &destList ) |
67 | { | 67 | { |
68 | cleanUp(); | 68 | cleanUp(); |
69 | 69 | ||
70 | Destination *dest; | 70 | Destination *dest; |
71 | QListIterator<Destination> dit( destList ); | 71 | QListIterator<Destination> dit( destList ); |
72 | bool rootRead = false; | 72 | bool rootRead = false; |
73 | for ( ; dit.current(); ++dit ) | 73 | for ( ; dit.current(); ++dit ) |
74 | { | 74 | { |
75 | dest = dit.current(); | 75 | dest = dit.current(); |
76 | bool installingToRoot = false; | 76 | bool installingToRoot = false; |
77 | 77 | ||
78 | QString path = dest->getDestinationPath(); | 78 | QString path = dest->getDestinationPath(); |
79 | if ( path.right( 1 ) != "/" ) | 79 | if ( path.right( 1 ) != "/" ) |
80 | path.append( "/" ); | 80 | path.append( "/" ); |
81 | 81 | ||
82 | if ( path == "/" ) | 82 | if ( path == "/" ) |
83 | { | 83 | { |
84 | rootRead = true; | 84 | rootRead = true; |
85 | installingToRoot = true; | 85 | installingToRoot = true; |
86 | } | 86 | } |
87 | 87 | ||
88 | packageFile = path; | 88 | packageFile = path; |
89 | packageFile.append( "usr/lib/ipkg/status" ); | 89 | packageFile.append( "usr/lib/ipkg/status" ); |
90 | readPackageFile( 0, false, installingToRoot, &( *dest ) ); | 90 | readPackageFile( 0, false, installingToRoot, &( *dest ) ); |
91 | } | 91 | } |
92 | 92 | ||
93 | // Ensure that the root status file is read | 93 | // Ensure that the root status file is read |
94 | if ( !rootRead ) | 94 | if ( !rootRead ) |
95 | { | 95 | { |
96 | packageFile = "/usr/lib/ipkg/status"; | 96 | packageFile = "/usr/lib/ipkg/status"; |
97 | readPackageFile( 0, false, true ); | 97 | readPackageFile( 0, false, true ); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | void Server :: readLocalIpks( Server *local ) | 101 | void Server :: readLocalIpks( Server *local ) |
102 | { | 102 | { |
103 | cleanUp(); | 103 | cleanUp(); |
104 | 104 | ||
105 | #ifdef QWS | 105 | #ifdef QWS |
106 | // First, get any local IPKGs in the documents area | 106 | // First, get any local IPKGs in the documents area |
107 | // Only applicable to Qtopie/Opie | 107 | // Only applicable to Qtopie/Opie |
108 | 108 | ||
109 | DocLnkSet files; | 109 | DocLnkSet files; |
110 | Global::findDocuments( &files, "application/ipkg" ); | 110 | Global::findDocuments( &files, "application/ipkg" ); |
111 | 111 | ||
112 | // Now add the items to the list | 112 | // Now add the items to the list |
113 | QListIterator<DocLnk> it( files.children() ); | 113 | QListIterator<DocLnk> it( files.children() ); |
114 | 114 | ||
115 | for ( ; it.current() ; ++it ) | 115 | for ( ; it.current() ; ++it ) |
116 | { | 116 | { |
117 | // OK, we have a local IPK file, I think the standard naming conventions | 117 | // OK, we have a local IPK file, I think the standard naming conventions |
118 | // for these are packagename_version_arm.ipk | 118 | // for these are packagename_version_arm.ipk |
119 | QString file = (*it)->file(); | 119 | QString file = (*it)->file(); |
120 | 120 | ||
121 | // Changed to display the filename (excluding the path) | 121 | // Changed to display the filename (excluding the path) |
122 | QString packageName = Utils::getFilenameFromIpkFilename( file ); | 122 | QString packageName = Utils::getPackageNameFromIpkFilename( file ); |
123 | QString ver = Utils::getPackageVersionFromIpkFilename( file ); | 123 | QString ver = Utils::getPackageVersionFromIpkFilename( file ); |
124 | Package *package = new Package( packageName ); | 124 | Package *package = new Package( packageName ); |
125 | package->setVersion( ver ); | 125 | package->setVersion( ver ); |
126 | package->setFilename( file ); | 126 | package->setFilename( file ); |
127 | package->setPackageStoredLocally( true ); | 127 | package->setPackageStoredLocally( true ); |
128 | packageList.append( package ); | 128 | packageList.append( package ); |
129 | } | 129 | } |
130 | #else | 130 | #else |
131 | QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" }; | 131 | QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" }; |
132 | for ( int i = 0 ; i < 4 ; ++i ) | 132 | for ( int i = 0 ; i < 4 ; ++i ) |
133 | { | 133 | { |
134 | // OK, we have a local IPK file, I think the standard naming conventions | 134 | // OK, we have a local IPK file, I think the standard naming conventions |
135 | // for these are packagename_version_arm.ipk | 135 | // for these are packagename_version_arm.ipk |
136 | QString file = names[i]; | 136 | QString file = names[i]; |
137 | int p = file.find( "_" ); | 137 | int p = file.find( "_" ); |
138 | QString tmp = file.mid( 0, p ); | 138 | QString tmp = file.mid( 0, p ); |
139 | packageList.push_back( Package( tmp ) ); | 139 | packageList.push_back( Package( tmp ) ); |
140 | int p2 = file.find( "_", p+1 ); | 140 | int p2 = file.find( "_", p+1 ); |
141 | tmp = file.mid( p+1, p2-(p+1) ); | 141 | tmp = file.mid( p+1, p2-(p+1) ); |
142 | packageList.back().setVersion( tmp ); | 142 | packageList.back().setVersion( tmp ); |
143 | packageList.back().setPackageStoredLocally( true ); | 143 | packageList.back().setPackageStoredLocally( true ); |
144 | } | 144 | } |
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | // build local packages | 147 | // build local packages |
148 | buildLocalPackages( local ); | 148 | buildLocalPackages( local ); |
149 | } | 149 | } |
150 | 150 | ||
151 | void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) | 151 | void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) |
152 | { | 152 | { |
153 | QFile f( packageFile ); | 153 | QFile f( packageFile ); |
154 | if ( !f.open( IO_ReadOnly ) ) | 154 | if ( !f.open( IO_ReadOnly ) ) |
155 | return; | 155 | return; |
156 | QTextStream t( &f ); | 156 | QTextStream t( &f ); |
157 | 157 | ||
158 | QString line; | 158 | QString line; |
159 | QString key; | 159 | QString key; |
160 | QString value; | 160 | QString value; |
161 | int pos; | 161 | int pos; |
162 | 162 | ||
163 | if ( clearAll ) | 163 | if ( clearAll ) |
164 | cleanUp(); | 164 | cleanUp(); |
165 | Package *currPackage = 0; | 165 | Package *currPackage = 0; |
166 | 166 | ||
167 | bool newPackage = true; | 167 | bool newPackage = true; |
168 | while ( !t.eof() ) | 168 | while ( !t.eof() ) |
169 | { | 169 | { |
170 | line = t.readLine(); | 170 | line = t.readLine(); |
171 | 171 | ||
172 | pos = line.find( ':', 0 ); | 172 | pos = line.find( ':', 0 ); |
173 | if ( pos > -1 ) | 173 | if ( pos > -1 ) |
174 | key = line.mid( 0, pos ).stripWhiteSpace(); | 174 | key = line.mid( 0, pos ).stripWhiteSpace(); |
175 | else | 175 | else |
176 | key = QString::null; | 176 | key = QString::null; |
177 | value = line.mid( pos+1, line.length()-pos ).stripWhiteSpace(); | 177 | value = line.mid( pos+1, line.length()-pos ).stripWhiteSpace(); |
178 | 178 | ||
179 | if ( key == "Package" && newPackage ) | 179 | if ( key == "Package" && newPackage ) |
180 | { | 180 | { |
181 | newPackage = false; | 181 | newPackage = false; |
182 | 182 | ||
183 | currPackage = getPackage( value ); | 183 | currPackage = getPackage( value ); |
184 | if ( !currPackage ) | 184 | if ( !currPackage ) |
185 | { | 185 | { |
186 | Package *package = new Package( value ); | 186 | Package *package = new Package( value ); |
187 | packageList.append( package ); | 187 | packageList.append( package ); |
188 | currPackage = package; | 188 | currPackage = package; |
189 | currPackage->setInstalledTo( dest ); | 189 | currPackage->setInstalledTo( dest ); |
190 | if ( installingToRoot ) | 190 | if ( installingToRoot ) |
191 | currPackage->setInstalledToRoot( true ); | 191 | currPackage->setInstalledToRoot( true ); |
192 | } | 192 | } |
193 | else | 193 | else |
194 | { | 194 | { |
195 | if ( currPackage->isInstalled() ) | 195 | if ( currPackage->isInstalled() ) |
196 | currPackage->setInstalledTo( dest ); | 196 | currPackage->setInstalledTo( dest ); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | else if ( key == "Version" ) | 199 | else if ( key == "Version" ) |
200 | { | 200 | { |
201 | if ( currPackage ) | 201 | if ( currPackage ) |
202 | currPackage->setVersion( value ); | 202 | currPackage->setVersion( value ); |
203 | } | 203 | } |
204 | else if ( key == "Status" ) | 204 | else if ( key == "Status" ) |
205 | { | 205 | { |
206 | if ( currPackage ) | 206 | if ( currPackage ) |
207 | currPackage->setStatus( value ); | 207 | currPackage->setStatus( value ); |
208 | } | 208 | } |
209 | else if ( key == "Description" ) | 209 | else if ( key == "Description" ) |
210 | { | 210 | { |
211 | if ( currPackage ) | 211 | if ( currPackage ) |
212 | currPackage->setDescription( value ); | 212 | currPackage->setDescription( value ); |
213 | } | 213 | } |
214 | else if ( key == "Filename" ) | 214 | else if ( key == "Filename" ) |
215 | { | 215 | { |
216 | if ( currPackage ) | 216 | if ( currPackage ) |
217 | currPackage->setFilename( value ); | 217 | currPackage->setFilename( value ); |
218 | } | 218 | } |
219 | else if ( key == "Size" ) | 219 | else if ( key == "Size" ) |
220 | { | 220 | { |
221 | if ( currPackage ) | 221 | if ( currPackage ) |
222 | currPackage->setPackageSize( value ); | 222 | currPackage->setPackageSize( value ); |
223 | } | 223 | } |
224 | else if ( key == "Section" ) | 224 | else if ( key == "Section" ) |
225 | { | 225 | { |
226 | if ( currPackage ) | 226 | if ( currPackage ) |
227 | currPackage->setSection( value ); | 227 | currPackage->setSection( value ); |
228 | 228 | ||
229 | DataManager::setAvailableCategories( value ); | 229 | DataManager::setAvailableCategories( value ); |
230 | } | 230 | } |
231 | else if ( key == QString::null ) | 231 | else if ( key == QString::null ) |
232 | { | 232 | { |
233 | newPackage = true; | 233 | newPackage = true; |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | f.close(); | 237 | f.close(); |
238 | 238 | ||
239 | // build local packages | 239 | // build local packages |
240 | buildLocalPackages( local ); | 240 | buildLocalPackages( local ); |
241 | } | 241 | } |
242 | 242 | ||
243 | void Server :: buildLocalPackages( Server *local ) | 243 | void Server :: buildLocalPackages( Server *local ) |
244 | { | 244 | { |
245 | Package *curr; | 245 | Package *curr; |
246 | QListIterator<Package> it( packageList ); | 246 | QListIterator<Package> it( packageList ); |
247 | |||
248 | QList<Package> *locallist = &local->getPackageList(); | ||
249 | |||
247 | for ( ; it.current(); ++it ) | 250 | for ( ; it.current(); ++it ) |
248 | { | 251 | { |
249 | curr = it.current(); | 252 | curr = it.current(); |
250 | QString name = curr->getPackageName(); | 253 | QString name = curr->getPackageName(); |
251 | 254 | ||
252 | // If the package name is an ipk name, then convert the filename to a package name | 255 | // If the package name is an ipk name, then convert the filename to a package name |
253 | if ( name.find( ".ipk" ) != -1 ) | 256 | if ( name.find( ".ipk" ) != -1 ) |
254 | name = Utils::getPackageNameFromIpkFilename( curr->getFilename() ); | 257 | name = Utils::getPackageNameFromIpkFilename( curr->getFilename() ); |
255 | 258 | ||
256 | if ( local ) | 259 | if ( local ) |
257 | { | 260 | { |
258 | Package *p = local->getPackage( name ); | 261 | Package *p = local->getPackage( name ); |
259 | curr->setLocalPackage( p ); | 262 | curr->setLocalPackage( p ); |
260 | if ( p ) | 263 | if ( p ) |
261 | { | 264 | { |
265 | // Replace local version | ||
266 | if ( curr->getVersion() > p->getVersion() ) | ||
267 | { | ||
268 | int pos = locallist->at(); | ||
269 | locallist->remove( p ); | ||
270 | locallist->insert( pos, curr ); | ||
271 | } | ||
272 | |||
262 | // Set some default stuff like size and things | 273 | // Set some default stuff like size and things |
263 | if ( p->getInstalledVersion() == curr->getVersion() ) | 274 | if ( p->getInstalledVersion() == curr->getVersion() ) |
264 | { | 275 | { |
265 | p->setPackageSize( curr->getPackageSize() ); | 276 | p->setPackageSize( curr->getPackageSize() ); |
266 | p->setSection( curr->getSection() ); | 277 | p->setSection( curr->getSection() ); |
267 | p->setDescription( curr->getDescription() ); | 278 | p->setDescription( curr->getDescription() ); |
268 | } | 279 | } |
269 | } | 280 | } |
270 | 281 | ||
271 | } | 282 | } |
272 | else | 283 | else |
273 | curr->setLocalPackage( 0 ); | 284 | curr->setLocalPackage( 0 ); |
274 | } | 285 | } |
275 | 286 | ||
276 | } | 287 | } |
277 | 288 | ||
278 | Package *Server :: getPackage( QString &name ) | 289 | Package *Server :: getPackage( QString &name ) |
279 | { | 290 | { |
280 | return getPackage( (const char *)name ); | 291 | return getPackage( (const char *)name ); |
281 | } | 292 | } |
282 | 293 | ||
283 | Package *Server :: getPackage( const char *name ) | 294 | Package *Server :: getPackage( const char *name ) |
284 | { | 295 | { |
285 | Package *ret = 0; | 296 | Package *ret = 0; |
286 | 297 | ||
287 | QListIterator<Package> it( packageList ); | 298 | QListIterator<Package> it( packageList ); |
288 | for ( ; it.current(); ++it ) | 299 | for ( ; it.current(); ++it ) |
289 | { | 300 | { |
290 | if ( it.current()->getPackageName() == name ) | 301 | if ( it.current()->getPackageName() == name ) |
291 | ret = it.current(); | 302 | ret = it.current(); |
292 | } | 303 | } |
293 | 304 | ||
294 | return ret; | 305 | return ret; |
295 | } | 306 | } |
296 | 307 | ||
297 | QString Server :: toString() | 308 | QString Server :: toString() |
298 | { | 309 | { |
299 | QString ret = QString( "Server\n name - %1\n url - %2\n" ).arg( serverName ).arg( serverUrl ); | 310 | QString ret = QString( "Server\n name - %1\n url - %2\n" ).arg( serverName ).arg( serverUrl ); |
300 | 311 | ||
301 | QListIterator<Package> it( packageList ); | 312 | QListIterator<Package> it( packageList ); |
302 | for ( ; it.current(); ++it ) | 313 | for ( ; it.current(); ++it ) |
303 | { | 314 | { |
304 | ret.append( QString( "\n %1" ).arg( it.current()->toString() ) ); | 315 | ret.append( QString( "\n %1" ).arg( it.current()->toString() ) ); |
305 | } | 316 | } |
306 | 317 | ||
307 | 318 | ||
308 | return ret; | 319 | return ret; |
309 | } | 320 | } |
310 | 321 | ||
311 | QList<Package> &Server::getPackageList() | 322 | QList<Package> &Server::getPackageList() |
312 | { | 323 | { |
313 | return packageList; | 324 | return packageList; |
314 | } | 325 | } |
315 | 326 | ||
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index 3d127a8..8def0d6 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp | |||
@@ -1,193 +1,191 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** ModulesInfo | 2 | ** ModulesInfo |
3 | ** | 3 | ** |
4 | ** Display Modules information | 4 | ** Display Modules information |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2002, Michael Lauer | 6 | ** Copyright (C) 2002, Michael Lauer |
7 | ** mickey@tm.informatik.uni-frankfurt.de | 7 | ** mickey@tm.informatik.uni-frankfurt.de |
8 | ** http://www.Vanille.de | 8 | ** http://www.Vanille.de |
9 | ** | 9 | ** |
10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> | 10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> |
11 | ** | 11 | ** |
12 | ** This file may be distributed and/or modified under the terms of the | 12 | ** This file may be distributed and/or modified under the terms of the |
13 | ** GNU General Public License version 2 as published by the Free Software | 13 | ** GNU General Public License version 2 as published by the Free Software |
14 | ** Foundation and appearing in the file LICENSE.GPL included in the | 14 | ** Foundation and appearing in the file LICENSE.GPL included in the |
15 | ** packaging of this file. | 15 | ** packaging of this file. |
16 | ** | 16 | ** |
17 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 17 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
18 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 18 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | 23 | ||
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qfile.h> | 25 | #include <qfile.h> |
26 | #include <qheader.h> | 26 | #include <qheader.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qwhatsthis.h> | 33 | #include <qwhatsthis.h> |
34 | 34 | ||
35 | #include "modulesinfo.h" | 35 | #include "modulesinfo.h" |
36 | #include "detail.h" | 36 | #include "detail.h" |
37 | 37 | ||
38 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 38 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) |
39 | : QWidget( parent, name, fl ) | 39 | : QWidget( parent, name, fl ) |
40 | { | 40 | { |
41 | QGridLayout *layout = new QGridLayout( this ); | 41 | QGridLayout *layout = new QGridLayout( this ); |
42 | layout->setSpacing( 4 ); | 42 | layout->setSpacing( 4 ); |
43 | layout->setMargin( 4 ); | 43 | layout->setMargin( 4 ); |
44 | 44 | ||
45 | ModulesView = new QListView( this ); | 45 | ModulesView = new QListView( this ); |
46 | int colnum = ModulesView->addColumn( tr( "Module" ) ); | 46 | int colnum = ModulesView->addColumn( tr( "Module" ) ); |
47 | colnum = ModulesView->addColumn( tr( "Size" ) ); | 47 | colnum = ModulesView->addColumn( tr( "Size" ) ); |
48 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 48 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
49 | colnum = ModulesView->addColumn( tr( "Use#" ) ); | 49 | colnum = ModulesView->addColumn( tr( "Use#" ) ); |
50 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 50 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
51 | colnum = ModulesView->addColumn( tr( "Used By" ) ); | 51 | colnum = ModulesView->addColumn( tr( "Used by" ) ); |
52 | ModulesView->setAllColumnsShowFocus( TRUE ); | 52 | ModulesView->setAllColumnsShowFocus( TRUE ); |
53 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); | 53 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); |
54 | QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); | 54 | QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); |
55 | 55 | ||
56 | // Test if we have /sbin/modinfo, and if so, allow module detail window | 56 | // Test if we have /sbin/modinfo, and if so, allow module detail window |
57 | if ( QFile::exists( "/sbin/modinfo" ) ) | 57 | if ( QFile::exists( "/sbin/modinfo" ) ) |
58 | { | 58 | { |
59 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); | 59 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); |
60 | connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 60 | connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
61 | this, SLOT( viewModules( QListViewItem * ) ) ); | 61 | this, SLOT( viewModules( QListViewItem * ) ) ); |
62 | } | 62 | } |
63 | 63 | ||
64 | CommandCB = new QComboBox( FALSE, this ); | 64 | CommandCB = new QComboBox( FALSE, this ); |
65 | CommandCB->insertItem( "modprobe -r" ); | 65 | CommandCB->insertItem( "modprobe -r" ); |
66 | CommandCB->insertItem( "rmmod" ); | 66 | CommandCB->insertItem( "rmmod" ); |
67 | // I can't think of other useful commands yet. Anyone? | 67 | // I can't think of other useful commands yet. Anyone? |
68 | layout->addWidget( CommandCB, 1, 0 ); | 68 | layout->addWidget( CommandCB, 1, 0 ); |
69 | QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); | 69 | QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); |
70 | 70 | ||
71 | QPushButton *btn = new QPushButton( this ); | 71 | QPushButton *btn = new QPushButton( this ); |
72 | btn->setMinimumSize( QSize( 50, 24 ) ); | 72 | btn->setMinimumSize( QSize( 50, 24 ) ); |
73 | btn->setMaximumSize( QSize( 50, 24 ) ); | 73 | btn->setMaximumSize( QSize( 50, 24 ) ); |
74 | btn->setText( tr( "Send" ) ); | 74 | btn->setText( tr( "Send" ) ); |
75 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 75 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
76 | layout->addWidget( btn, 1, 1 ); | 76 | layout->addWidget( btn, 1, 1 ); |
77 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); | 77 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); |
78 | 78 | ||
79 | QTimer *t = new QTimer( this ); | 79 | QTimer *t = new QTimer( this ); |
80 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 80 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
81 | t->start( 5000 ); | 81 | t->start( 5000 ); |
82 | 82 | ||
83 | updateData(); | 83 | updateData(); |
84 | 84 | ||
85 | ModulesDtl = new Detail(); | 85 | ModulesDtl = new Detail(); |
86 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); | 86 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); |
87 | } | 87 | } |
88 | 88 | ||
89 | ModulesInfo::~ModulesInfo() | 89 | ModulesInfo::~ModulesInfo() |
90 | { | 90 | { |
91 | } | 91 | } |
92 | 92 | ||
93 | void ModulesInfo::updateData() | 93 | void ModulesInfo::updateData() |
94 | { | 94 | { |
95 | char modname[64]; | 95 | char modname[64]; |
96 | char usage[200]; | 96 | char usage[200]; |
97 | int modsize, usecount; | 97 | int modsize, usecount; |
98 | 98 | ||
99 | QString selectedmod; | 99 | QString selectedmod; |
100 | QListViewItem *curritem = ModulesView->currentItem(); | 100 | QListViewItem *curritem = ModulesView->currentItem(); |
101 | if ( curritem ) | 101 | if ( curritem ) |
102 | { | 102 | { |
103 | selectedmod = curritem->text( 0 ); | 103 | selectedmod = curritem->text( 0 ); |
104 | } | 104 | } |
105 | 105 | ||
106 | ModulesView->clear(); | 106 | ModulesView->clear(); |
107 | 107 | ||
108 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); | 108 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); |
109 | 109 | ||
110 | if ( procfile ) | 110 | if ( procfile ) |
111 | { | 111 | { |
112 | QListViewItem *newitem; | 112 | QListViewItem *newitem; |
113 | QListViewItem *selecteditem = 0x0; | 113 | QListViewItem *selecteditem = 0x0; |
114 | while ( true ) { | 114 | while ( true ) { |
115 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); | 115 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); |
116 | 116 | ||
117 | if ( success == EOF ) | 117 | if ( success == EOF ) |
118 | break; | 118 | break; |
119 | 119 | ||
120 | QString qmodname = QString( modname ); | 120 | QString qmodname = QString( modname ); |
121 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 121 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
122 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 122 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
123 | QString qusage = QString( usage ); | 123 | QString qusage = QString( usage ); |
124 | 124 | ||
125 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); | 125 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); |
126 | if ( qmodname == selectedmod ) | 126 | if ( qmodname == selectedmod ) |
127 | { | 127 | { |
128 | selecteditem = newitem; | 128 | selecteditem = newitem; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | ModulesView->setCurrentItem( selecteditem ); | 131 | ModulesView->setCurrentItem( selecteditem ); |
132 | 132 | ||
133 | fclose( procfile ); | 133 | fclose( procfile ); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | void ModulesInfo::slotSendClicked() | 137 | void ModulesInfo::slotSendClicked() |
138 | { | 138 | { |
139 | if ( !ModulesView->currentItem() ) | 139 | if ( !ModulesView->currentItem() ) |
140 | { | 140 | { |
141 | return; | 141 | return; |
142 | } | 142 | } |
143 | 143 | ||
144 | QString capstr = tr( "You really want to execute\n" ); | 144 | QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); |
145 | capstr.append( CommandCB->currentText() ); | ||
146 | capstr.append( "\nfor this module?" ); | ||
147 | 145 | ||
148 | QString modname = ModulesView->currentItem()->text( 0 ); | 146 | QString modname = ModulesView->currentItem()->text( 0 ); |
149 | 147 | ||
150 | if ( QMessageBox::warning( this, modname, capstr, | 148 | if ( QMessageBox::warning( this, modname, capstr, |
151 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 149 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
152 | { | 150 | { |
153 | QString command = "/sbin/"; | 151 | QString command = "/sbin/"; |
154 | command.append( CommandCB->currentText() ); | 152 | command.append( CommandCB->currentText() ); |
155 | command.append( " " ); | 153 | command.append( " " ); |
156 | command.append( modname ); | 154 | command.append( modname ); |
157 | 155 | ||
158 | FILE* stream = popen( command, "r" ); | 156 | FILE* stream = popen( command, "r" ); |
159 | if ( stream ) | 157 | if ( stream ) |
160 | pclose( stream ); | 158 | pclose( stream ); |
161 | } | 159 | } |
162 | 160 | ||
163 | } | 161 | } |
164 | 162 | ||
165 | void ModulesInfo::viewModules( QListViewItem *modules ) | 163 | void ModulesInfo::viewModules( QListViewItem *modules ) |
166 | { | 164 | { |
167 | QString modname = modules->text( 0 ); | 165 | QString modname = modules->text( 0 ); |
168 | QString capstr = "Module: "; | 166 | QString capstr = "Module: "; |
169 | capstr.append( modname ); | 167 | capstr.append( modname ); |
170 | ModulesDtl->setCaption( capstr ); | 168 | ModulesDtl->setCaption( capstr ); |
171 | QString command = "/sbin/modinfo "; | 169 | QString command = "/sbin/modinfo "; |
172 | command.append( modname ); | 170 | command.append( modname ); |
173 | FILE* modinfo = popen( command, "r" ); | 171 | FILE* modinfo = popen( command, "r" ); |
174 | 172 | ||
175 | if ( modinfo ) | 173 | if ( modinfo ) |
176 | { | 174 | { |
177 | char line[200]; | 175 | char line[200]; |
178 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); | 176 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); |
179 | 177 | ||
180 | while( true ) | 178 | while( true ) |
181 | { | 179 | { |
182 | int success = fscanf( modinfo, "%[^\n]\n", line ); | 180 | int success = fscanf( modinfo, "%[^\n]\n", line ); |
183 | if ( success == EOF ) | 181 | if ( success == EOF ) |
184 | break; | 182 | break; |
185 | ModulesDtl->detailView->append( line ); | 183 | ModulesDtl->detailView->append( line ); |
186 | } | 184 | } |
187 | 185 | ||
188 | pclose( modinfo ); | 186 | pclose( modinfo ); |
189 | } | 187 | } |
190 | 188 | ||
191 | ModulesDtl->showMaximized(); | 189 | ModulesDtl->showMaximized(); |
192 | } | 190 | } |
193 | 191 | ||
diff --git a/noncore/settings/sysinfo/opie-sysinfo.control b/noncore/settings/sysinfo/opie-sysinfo.control index acb51e5..8250174 100644 --- a/noncore/settings/sysinfo/opie-sysinfo.control +++ b/noncore/settings/sysinfo/opie-sysinfo.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-sysinfo | 1 | Package: opie-sysinfo |
2 | Files: bin/sysinfo apps/Settings/sysinfo.desktop pics/sysinfo | 2 | Files: bin/sysinfo apps/Settings/sysinfo.desktop pics/sysinfo |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Dan Williams <williamsdr@acm.org> | 5 | Maintainer: Dan Williams <williamsdr@acm.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal, libopie1 | 7 | Depends: task-opie-minimal, libopie1 |
9 | Description: System Information dialog | 8 | Description: System Information dialog |
10 | For the Opie environment. | 9 | For the Opie environment. |
10 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 1de1a19..8dec9be 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -1,205 +1,203 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** ProcessInfo | 2 | ** ProcessInfo |
3 | ** | 3 | ** |
4 | ** Display process information | 4 | ** Display process information |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2002, Dan Williams | 6 | ** Copyright (C) 2002, Dan Williams |
7 | ** williamsdr@acm.org | 7 | ** williamsdr@acm.org |
8 | ** http://draknor.net | 8 | ** http://draknor.net |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ** This file may be distributed and/or modified under the terms of the |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | ** GNU General Public License version 2 as published by the Free Software |
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | 21 | ||
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | #include <qfile.h> | 23 | #include <qfile.h> |
24 | #include <qheader.h> | 24 | #include <qheader.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qlistview.h> | 26 | #include <qlistview.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <sys/types.h> | 31 | #include <sys/types.h> |
32 | #include <signal.h> | 32 | #include <signal.h> |
33 | 33 | ||
34 | #include "processinfo.h" | 34 | #include "processinfo.h" |
35 | #include "detail.h" | 35 | #include "detail.h" |
36 | 36 | ||
37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | 37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) |
38 | : QWidget( parent, name, fl ) | 38 | : QWidget( parent, name, fl ) |
39 | { | 39 | { |
40 | QGridLayout *layout = new QGridLayout( this ); | 40 | QGridLayout *layout = new QGridLayout( this ); |
41 | layout->setSpacing( 4 ); | 41 | layout->setSpacing( 4 ); |
42 | layout->setMargin( 4 ); | 42 | layout->setMargin( 4 ); |
43 | 43 | ||
44 | 44 | ||
45 | ProcessView = new QListView( this, "ProcessView" ); | 45 | ProcessView = new QListView( this, "ProcessView" ); |
46 | int colnum = ProcessView->addColumn( tr( "PID" ) ); | 46 | int colnum = ProcessView->addColumn( tr( "PID" ) ); |
47 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
48 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); | 48 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); |
49 | colnum = ProcessView->addColumn( tr( "Status" ) ); | 49 | colnum = ProcessView->addColumn( tr( "Status" ) ); |
50 | colnum = ProcessView->addColumn( tr( "Time" ) ); | 50 | colnum = ProcessView->addColumn( tr( "Time" ) ); |
51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
52 | ProcessView->setAllColumnsShowFocus( TRUE ); | 52 | ProcessView->setAllColumnsShowFocus( TRUE ); |
53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); | 53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); |
54 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 54 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
55 | this, SLOT( viewProcess( QListViewItem * ) ) ); | 55 | this, SLOT( viewProcess( QListViewItem * ) ) ); |
56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); | 56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); |
57 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); | 57 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); |
58 | 58 | ||
59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); | 59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); |
60 | SignalCB->insertItem( " 1: SIGHUP" ); | 60 | SignalCB->insertItem( " 1: SIGHUP" ); |
61 | SignalCB->insertItem( " 2: SIGINT" ); | 61 | SignalCB->insertItem( " 2: SIGINT" ); |
62 | SignalCB->insertItem( " 3: SIGQUIT" ); | 62 | SignalCB->insertItem( " 3: SIGQUIT" ); |
63 | SignalCB->insertItem( " 5: SIGTRAP" ); | 63 | SignalCB->insertItem( " 5: SIGTRAP" ); |
64 | SignalCB->insertItem( " 6: SIGABRT" ); | 64 | SignalCB->insertItem( " 6: SIGABRT" ); |
65 | SignalCB->insertItem( " 9: SIGKILL" ); | 65 | SignalCB->insertItem( " 9: SIGKILL" ); |
66 | SignalCB->insertItem( "14: SIGALRM" ); | 66 | SignalCB->insertItem( "14: SIGALRM" ); |
67 | SignalCB->insertItem( "15: SIGTERM" ); | 67 | SignalCB->insertItem( "15: SIGTERM" ); |
68 | SignalCB->insertItem( "18: SIGCONT" ); | 68 | SignalCB->insertItem( "18: SIGCONT" ); |
69 | SignalCB->insertItem( "19: SIGSTOP" ); | 69 | SignalCB->insertItem( "19: SIGSTOP" ); |
70 | layout->addWidget( SignalCB, 1, 0 ); | 70 | layout->addWidget( SignalCB, 1, 0 ); |
71 | QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); | 71 | QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); |
72 | 72 | ||
73 | SendButton = new QPushButton( this, "SendButton" ); | 73 | SendButton = new QPushButton( this, "SendButton" ); |
74 | SendButton->setMinimumSize( QSize( 50, 24 ) ); | 74 | SendButton->setMinimumSize( QSize( 50, 24 ) ); |
75 | SendButton->setMaximumSize( QSize( 50, 24 ) ); | 75 | SendButton->setMaximumSize( QSize( 50, 24 ) ); |
76 | SendButton->setText( tr( "Send" ) ); | 76 | SendButton->setText( tr( "Send" ) ); |
77 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 77 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
78 | layout->addWidget( SendButton, 1, 1 ); | 78 | layout->addWidget( SendButton, 1, 1 ); |
79 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); | 79 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); |
80 | 80 | ||
81 | QTimer *t = new QTimer( this ); | 81 | QTimer *t = new QTimer( this ); |
82 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 82 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
83 | t->start( 5000 ); | 83 | t->start( 5000 ); |
84 | 84 | ||
85 | updateData(); | 85 | updateData(); |
86 | 86 | ||
87 | ProcessDtl = new Detail(); | 87 | ProcessDtl = new Detail(); |
88 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); | 88 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); |
89 | } | 89 | } |
90 | 90 | ||
91 | ProcessInfo::~ProcessInfo() | 91 | ProcessInfo::~ProcessInfo() |
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | void ProcessInfo::updateData() | 95 | void ProcessInfo::updateData() |
96 | { | 96 | { |
97 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, | 97 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, |
98 | signal, blocked, sigignore, sigcatch; | 98 | signal, blocked, sigignore, sigcatch; |
99 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, | 99 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, |
100 | endcode, startstack, kstkesp, kstkeip, wchan; | 100 | endcode, startstack, kstkesp, kstkeip, wchan; |
101 | char state; | 101 | char state; |
102 | char comm[64]; | 102 | char comm[64]; |
103 | 103 | ||
104 | QString selectedpid; | 104 | QString selectedpid; |
105 | QListViewItem *curritem = ProcessView->currentItem(); | 105 | QListViewItem *curritem = ProcessView->currentItem(); |
106 | if ( curritem ) | 106 | if ( curritem ) |
107 | { | 107 | { |
108 | selectedpid = curritem->text( 0 ); | 108 | selectedpid = curritem->text( 0 ); |
109 | } | 109 | } |
110 | 110 | ||
111 | ProcessView->clear(); | 111 | ProcessView->clear(); |
112 | 112 | ||
113 | QListViewItem *newitem; | 113 | QListViewItem *newitem; |
114 | QListViewItem *selecteditem = 0x0; | 114 | QListViewItem *selecteditem = 0x0; |
115 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); | 115 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); |
116 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); | 116 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); |
117 | if ( proclist ) | 117 | if ( proclist ) |
118 | { | 118 | { |
119 | QFileInfoListIterator it(*proclist); | 119 | QFileInfoListIterator it(*proclist); |
120 | QFileInfo *f; | 120 | QFileInfo *f; |
121 | while ( ( f = it.current() ) != 0 ) | 121 | while ( ( f = it.current() ) != 0 ) |
122 | { | 122 | { |
123 | ++it; | 123 | ++it; |
124 | QString processnum = f->fileName(); | 124 | QString processnum = f->fileName(); |
125 | if ( processnum >= "1" && processnum <= "99999" ) | 125 | if ( processnum >= "1" && processnum <= "99999" ) |
126 | { | 126 | { |
127 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); | 127 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); |
128 | 128 | ||
129 | if ( procfile ) | 129 | if ( procfile ) |
130 | { | 130 | { |
131 | fscanf( procfile, | 131 | fscanf( procfile, |
132 | "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", | 132 | "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", |
133 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, | 133 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, |
134 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, | 134 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, |
135 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, | 135 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, |
136 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); | 136 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); |
137 | processnum = processnum.rightJustify( 5, ' ' ); | 137 | processnum = processnum.rightJustify( 5, ' ' ); |
138 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); | 138 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); |
139 | QString processstatus = QChar(state); | 139 | QString processstatus = QChar(state); |
140 | QString processtime = QString::number( ( utime + stime ) / 100 ); | 140 | QString processtime = QString::number( ( utime + stime ) / 100 ); |
141 | processtime = processtime.rightJustify( 9, ' ' ); | 141 | processtime = processtime.rightJustify( 9, ' ' ); |
142 | fclose( procfile ); | 142 | fclose( procfile ); |
143 | 143 | ||
144 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); | 144 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); |
145 | if ( processnum == selectedpid ) | 145 | if ( processnum == selectedpid ) |
146 | { | 146 | { |
147 | selecteditem = newitem; | 147 | selecteditem = newitem; |
148 | } | 148 | } |
149 | } | 149 | } |
150 | } | 150 | } |
151 | } | 151 | } |
152 | ProcessView->setCurrentItem( selecteditem ); | 152 | ProcessView->setCurrentItem( selecteditem ); |
153 | } | 153 | } |
154 | 154 | ||
155 | delete proclist; | 155 | delete proclist; |
156 | delete procdir; | 156 | delete procdir; |
157 | } | 157 | } |
158 | 158 | ||
159 | void ProcessInfo::slotSendClicked() | 159 | void ProcessInfo::slotSendClicked() |
160 | { | 160 | { |
161 | QListViewItem *currprocess = ProcessView->currentItem(); | 161 | QListViewItem *currprocess = ProcessView->currentItem(); |
162 | if ( !currprocess ) | 162 | if ( !currprocess ) |
163 | { | 163 | { |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | 166 | ||
167 | QString capstr = tr( "You really want to send\n" ); | 167 | QString capstr = tr( "You really want to send %1 to this process?" ).arg( SignalCB->currentText() ); |
168 | capstr.append( SignalCB->currentText() ); | ||
169 | capstr.append( "\nto this process?" ); | ||
170 | 168 | ||
171 | 169 | ||
172 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, | 170 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, |
173 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 171 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
174 | { | 172 | { |
175 | currprocess = ProcessView->currentItem(); | 173 | currprocess = ProcessView->currentItem(); |
176 | if ( currprocess ) | 174 | if ( currprocess ) |
177 | { | 175 | { |
178 | QString sigstr = SignalCB->currentText(); | 176 | QString sigstr = SignalCB->currentText(); |
179 | sigstr.truncate(2); | 177 | sigstr.truncate(2); |
180 | int sigid = sigstr.toUInt(); | 178 | int sigid = sigstr.toUInt(); |
181 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); | 179 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); |
182 | } | 180 | } |
183 | } | 181 | } |
184 | 182 | ||
185 | } | 183 | } |
186 | 184 | ||
187 | void ProcessInfo::viewProcess( QListViewItem *process ) | 185 | void ProcessInfo::viewProcess( QListViewItem *process ) |
188 | { | 186 | { |
189 | QString pid= process->text( 0 ).stripWhiteSpace(); | 187 | QString pid= process->text( 0 ).stripWhiteSpace(); |
190 | QString command = process->text( 1 ); | 188 | QString command = process->text( 1 ); |
191 | ProcessDtl->setCaption( pid + " - " + command ); | 189 | ProcessDtl->setCaption( pid + " - " + command ); |
192 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); | 190 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); |
193 | if ( statfile ) | 191 | if ( statfile ) |
194 | { | 192 | { |
195 | char line[81]; | 193 | char line[81]; |
196 | fgets( line, 81, statfile ); | 194 | fgets( line, 81, statfile ); |
197 | ProcessDtl->detailView->setText( line ); | 195 | ProcessDtl->detailView->setText( line ); |
198 | while ( fgets( line, 81, statfile ) ) | 196 | while ( fgets( line, 81, statfile ) ) |
199 | { | 197 | { |
200 | ProcessDtl->detailView->append( line ); | 198 | ProcessDtl->detailView->append( line ); |
201 | } | 199 | } |
202 | fclose( statfile ); | 200 | fclose( statfile ); |
203 | } | 201 | } |
204 | ProcessDtl->showMaximized(); | 202 | ProcessDtl->showMaximized(); |
205 | } | 203 | } |