author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/applets/notesapplet | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
-rw-r--r-- | noncore/applets/notesapplet/notes.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp index 1142028..9b5e475 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp | |||
@@ -82,192 +82,192 @@ NotesControl::NotesControl( QWidget *, const char * ) | |||
82 | // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 82 | // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
83 | { | 83 | { |
84 | QDir d( QDir::homeDirPath()+"/notes"); | 84 | QDir d( QDir::homeDirPath()+"/notes"); |
85 | if( !d.exists()) { | 85 | if( !d.exists()) { |
86 | qDebug("make dir"); | 86 | qDebug("make dir"); |
87 | if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) | 87 | if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) |
88 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed"); | 88 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed"); |
89 | } | 89 | } |
90 | Config cfg("Notes"); | 90 | Config cfg("Notes"); |
91 | cfg.setGroup("Options"); | 91 | cfg.setGroup("Options"); |
92 | showMax = cfg.readBoolEntry("ShowMax", false); | 92 | showMax = cfg.readBoolEntry("ShowMax", false); |
93 | 93 | ||
94 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 94 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
95 | loaded=false; | 95 | loaded=false; |
96 | edited=false; | 96 | edited=false; |
97 | doPopulate=true; | 97 | doPopulate=true; |
98 | isNew=false; | 98 | isNew=false; |
99 | QVBox *vbox = new QVBox( this, "Vlayout" ); | 99 | QVBox *vbox = new QVBox( this, "Vlayout" ); |
100 | QHBox *hbox = new QHBox( this, "HLayout" ); | 100 | QHBox *hbox = new QHBox( this, "HLayout" ); |
101 | 101 | ||
102 | view = new QMultiLineEdit(vbox, "OpieNotesView"); | 102 | view = new QMultiLineEdit(vbox, "OpieNotesView"); |
103 | 103 | ||
104 | box = new QListBox(vbox, "OpieNotesBox"); | 104 | box = new QListBox(vbox, "OpieNotesBox"); |
105 | 105 | ||
106 | QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold); | 106 | QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold); |
107 | 107 | ||
108 | box->setFixedHeight(50); | 108 | box->setFixedHeight(50); |
109 | 109 | ||
110 | vbox->setMargin( 6 ); | 110 | vbox->setMargin( 6 ); |
111 | vbox->setSpacing( 3 ); | 111 | vbox->setSpacing( 3 ); |
112 | 112 | ||
113 | 113 | ||
114 | 114 | ||
115 | setFocusPolicy(QWidget::StrongFocus); | 115 | setFocusPolicy(QWidget::StrongFocus); |
116 | 116 | ||
117 | newButton= new QPushButton( hbox, "newButton" ); | 117 | newButton= new QPushButton( hbox, "newButton" ); |
118 | newButton->setText(tr("New")); | 118 | newButton->setText(tr("New")); |
119 | 119 | ||
120 | 120 | ||
121 | saveButton= new QPushButton( hbox, "saveButton" ); | 121 | saveButton= new QPushButton( hbox, "saveButton" ); |
122 | saveButton->setText(tr("Save")); | 122 | saveButton->setText(tr("Save")); |
123 | 123 | ||
124 | 124 | ||
125 | deleteButton= new QPushButton( hbox, "deleteButton" ); | 125 | deleteButton= new QPushButton( hbox, "deleteButton" ); |
126 | deleteButton->setText(tr("Delete")); | 126 | deleteButton->setText(tr("Delete")); |
127 | 127 | ||
128 | 128 | ||
129 | 129 | ||
130 | connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)), | 130 | connect( box, SIGNAL( mouseButtonPressed(int,QListBoxItem*,const QPoint&)), |
131 | this,SLOT( boxPressed(int, QListBoxItem *, const QPoint&)) ); | 131 | this,SLOT( boxPressed(int,QListBoxItem*,const QPoint&)) ); |
132 | 132 | ||
133 | connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString &))); | 133 | connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString&))); |
134 | 134 | ||
135 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) ); | 135 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) ); |
136 | 136 | ||
137 | connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); | 137 | connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); |
138 | 138 | ||
139 | connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); | 139 | connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); |
140 | connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton())); | 140 | connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton())); |
141 | connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked())); | 141 | connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked())); |
142 | 142 | ||
143 | populateBox(); | 143 | populateBox(); |
144 | load(); | 144 | load(); |
145 | setCaption("Notes"); | 145 | setCaption("Notes"); |
146 | // parent->setFocus(); | 146 | // parent->setFocus(); |
147 | } | 147 | } |
148 | 148 | ||
149 | void NotesControl::slotSaveButton() { | 149 | void NotesControl::slotSaveButton() { |
150 | slotNewButton(); | 150 | slotNewButton(); |
151 | populateBox(); | 151 | populateBox(); |
152 | } | 152 | } |
153 | 153 | ||
154 | void NotesControl::slotDeleteButtonClicked() { | 154 | void NotesControl::slotDeleteButtonClicked() { |
155 | switch ( QMessageBox::warning(this,tr("Delete?") | 155 | switch ( QMessageBox::warning(this,tr("Delete?") |
156 | ,tr("Do you really want to<BR><B> delete</B> this note ?") | 156 | ,tr("Do you really want to<BR><B> delete</B> this note ?") |
157 | ,tr("Yes"),tr("No"),0,1,1) ) { | 157 | ,tr("Yes"),tr("No"),0,1,1) ) { |
158 | case 0: | 158 | case 0: |
159 | slotDeleteButton(); | 159 | slotDeleteButton(); |
160 | break; | 160 | break; |
161 | }; | 161 | }; |
162 | } | 162 | } |
163 | 163 | ||
164 | void NotesControl::slotDeleteButton() { | 164 | void NotesControl::slotDeleteButton() { |
165 | 165 | ||
166 | QString selectedText = box->currentText(); | 166 | QString selectedText = box->currentText(); |
167 | qDebug("deleting "+selectedText); | 167 | qDebug("deleting "+selectedText); |
168 | 168 | ||
169 | if( !selectedText.isEmpty()) { | 169 | if( !selectedText.isEmpty()) { |
170 | 170 | ||
171 | Config cfg("Notes"); | 171 | Config cfg("Notes"); |
172 | cfg.setGroup("Docs"); | 172 | cfg.setGroup("Docs"); |
173 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 173 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
174 | QString entryName, entryName2;; | 174 | QString entryName, entryName2;; |
175 | for ( int i = 0; i < noOfFiles; i++ ) { | 175 | for ( int i = 0; i < noOfFiles; i++ ) { |
176 | entryName.sprintf( "File%i", i + 1 ); | 176 | entryName.sprintf( "File%i", i + 1 ); |
177 | if(selectedText == cfg.readEntry( entryName )) { | 177 | if(selectedText == cfg.readEntry( entryName )) { |
178 | qDebug("removing %s, %d", selectedText.latin1(), i); | 178 | qDebug("removing %s, %d", selectedText.latin1(), i); |
179 | for ( int j = i; j < noOfFiles; j++ ) { | 179 | for ( int j = i; j < noOfFiles; j++ ) { |
180 | entryName.sprintf( "File%i", i + 1 ); | 180 | entryName.sprintf( "File%i", i + 1 ); |
181 | entryName2.sprintf( "File%i", i + 2 ); | 181 | entryName2.sprintf( "File%i", i + 2 ); |
182 | QString temp = cfg.readEntry(entryName2); | 182 | QString temp = cfg.readEntry(entryName2); |
183 | qDebug("move "+temp); | 183 | qDebug("move "+temp); |
184 | cfg.writeEntry(entryName, temp); | 184 | cfg.writeEntry(entryName, temp); |
185 | i++; | 185 | i++; |
186 | } | 186 | } |
187 | cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); | 187 | cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); |
188 | entryName.sprintf( "File%i", noOfFiles ); | 188 | entryName.sprintf( "File%i", noOfFiles ); |
189 | cfg.removeEntry(entryName); | 189 | cfg.removeEntry(entryName); |
190 | cfg.write(); | 190 | cfg.write(); |
191 | DocLnk nf(selectedText); | 191 | DocLnk nf(selectedText); |
192 | nf.removeFiles(); | 192 | nf.removeFiles(); |
193 | QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop"; | 193 | QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop"; |
194 | qDebug(fi); | 194 | qDebug(fi); |
195 | 195 | ||
196 | QFile f( fi); | 196 | QFile f( fi); |
197 | if( !f.remove()) qDebug(".desktop file not removed"); | 197 | if( !f.remove()) qDebug(".desktop file not removed"); |
198 | 198 | ||
199 | } | 199 | } |
200 | } | 200 | } |
201 | view->clear(); | 201 | view->clear(); |
202 | 202 | ||
203 | populateBox(); | 203 | populateBox(); |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
207 | void NotesControl::slotNewButton() { | 207 | void NotesControl::slotNewButton() { |
208 | if(edited) save(); | 208 | if(edited) save(); |
209 | view->clear(); | 209 | view->clear(); |
210 | view->setFocus(); | 210 | view->setFocus(); |
211 | edited=false; | 211 | edited=false; |
212 | isNew=false; | 212 | isNew=false; |
213 | } | 213 | } |
214 | 214 | ||
215 | void NotesControl::slotBeamButton() { | 215 | void NotesControl::slotBeamButton() { |
216 | Ir ir; | 216 | Ir ir; |
217 | if(!ir.supported()){ | 217 | if(!ir.supported()){ |
218 | } else { | 218 | } else { |
219 | this->hide(); | 219 | this->hide(); |
220 | QString selectedText = box->currentText(); | 220 | QString selectedText = box->currentText(); |
221 | if( !selectedText.isEmpty()) { | 221 | if( !selectedText.isEmpty()) { |
222 | QString file = QDir::homeDirPath()+"/"+selectedText; | 222 | QString file = QDir::homeDirPath()+"/"+selectedText; |
223 | QFile f(file); | 223 | QFile f(file); |
224 | Ir *irFile = new Ir(this, "IR"); | 224 | Ir *irFile = new Ir(this, "IR"); |
225 | connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished( Ir * ))); | 225 | connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished(Ir*))); |
226 | irFile->send( file, "Note", "text/plain" ); | 226 | irFile->send( file, "Note", "text/plain" ); |
227 | } | 227 | } |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | void NotesControl::slotBeamFinished(Ir *) { | 231 | void NotesControl::slotBeamFinished(Ir *) { |
232 | this->show(); | 232 | this->show(); |
233 | } | 233 | } |
234 | 234 | ||
235 | void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) { | 235 | void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) { |
236 | switch (mouse) { | 236 | switch (mouse) { |
237 | case 1:{ | 237 | case 1:{ |
238 | } | 238 | } |
239 | break; | 239 | break; |
240 | case 2: | 240 | case 2: |
241 | menuTimer.start( 500, TRUE ); | 241 | menuTimer.start( 500, TRUE ); |
242 | break; | 242 | break; |
243 | }; | 243 | }; |
244 | } | 244 | } |
245 | 245 | ||
246 | void NotesControl::slotBoxSelected(const QString &itemString) { | 246 | void NotesControl::slotBoxSelected(const QString &itemString) { |
247 | if(edited) { | 247 | if(edited) { |
248 | save(); | 248 | save(); |
249 | } | 249 | } |
250 | loaded=false; | 250 | loaded=false; |
251 | edited=false; | 251 | edited=false; |
252 | load(itemString); | 252 | load(itemString); |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | void NotesControl::showMenu() { | 256 | void NotesControl::showMenu() { |
257 | QPopupMenu *m = new QPopupMenu(0); | 257 | QPopupMenu *m = new QPopupMenu(0); |
258 | m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() )); | 258 | m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() )); |
259 | m->insertItem( tr( "Search For..." ), this, SLOT( slotSearch() )); | 259 | m->insertItem( tr( "Search For..." ), this, SLOT( slotSearch() )); |
260 | m->insertItem( tr( "Toggle Maximized" ), this, SLOT( slotShowMax() )); | 260 | m->insertItem( tr( "Toggle Maximized" ), this, SLOT( slotShowMax() )); |
261 | m->insertSeparator(); | 261 | m->insertSeparator(); |
262 | m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() )); | 262 | m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() )); |
263 | m->setFocus(); | 263 | m->setFocus(); |
264 | m->exec( QCursor::pos() ); | 264 | m->exec( QCursor::pos() ); |
265 | 265 | ||
266 | if(m) delete m; | 266 | if(m) delete m; |
267 | } | 267 | } |
268 | 268 | ||
269 | void NotesControl::focusOutEvent ( QFocusEvent * e) { | 269 | void NotesControl::focusOutEvent ( QFocusEvent * e) { |
270 | if( e->reason() == QFocusEvent::Popup) | 270 | if( e->reason() == QFocusEvent::Popup) |
271 | save(); | 271 | save(); |
272 | else { | 272 | else { |
273 | if(!loaded) { | 273 | if(!loaded) { |