Mercurial > hg > octave-nkf
comparison gui/src/m-editor/file-editor.cc @ 15080:4c4f2fb07a50 gui
Added find functionality in editor by to.lil.
* find.png: Added find icon.
* find-dialog.cc: Added find dialog.
* find-dialog.h: Added find dialog.
* file-editor-tab.cc: Integrated find dialog.
* file-editor-tab.h: Added new method for find.
* file-editor.cc: Added new actions, menus and toolbuttons.
* file-editor.h: Added new method/slot for find.
author | Jacob Dawid <jacob.dawid@gmail.com> |
---|---|
date | Thu, 02 Aug 2012 11:08:45 +0200 |
parents | 1ffaad442161 |
children | f4ea22ef2beb |
comparison
equal
deleted
inserted
replaced
15055:48ae6a7c69c1 | 15080:4c4f2fb07a50 |
---|---|
112 } | 112 } |
113 | 113 |
114 void | 114 void |
115 file_editor::request_undo () | 115 file_editor::request_undo () |
116 { | 116 { |
117 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 117 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
118 if (activeFileEditorTab) | 118 if (_active_file_editor_tab) |
119 activeFileEditorTab->undo (); | 119 _active_file_editor_tab->undo (); |
120 } | 120 } |
121 | 121 |
122 void | 122 void |
123 file_editor::request_redo () | 123 file_editor::request_redo () |
124 { | 124 { |
125 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 125 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
126 if (activeFileEditorTab) | 126 if (_active_file_editor_tab) |
127 activeFileEditorTab->redo (); | 127 _active_file_editor_tab->redo (); |
128 } | 128 } |
129 | 129 |
130 void | 130 void |
131 file_editor::request_copy () | 131 file_editor::request_copy () |
132 { | 132 { |
133 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 133 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
134 if (activeFileEditorTab) | 134 if (_active_file_editor_tab) |
135 activeFileEditorTab->copy (); | 135 _active_file_editor_tab->copy (); |
136 } | 136 } |
137 | 137 |
138 void | 138 void |
139 file_editor::request_cut () | 139 file_editor::request_cut () |
140 { | 140 { |
141 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 141 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
142 if (activeFileEditorTab) | 142 if (_active_file_editor_tab) |
143 activeFileEditorTab->cut (); | 143 _active_file_editor_tab->cut (); |
144 } | 144 } |
145 | 145 |
146 void | 146 void |
147 file_editor::request_paste () | 147 file_editor::request_paste () |
148 { | 148 { |
149 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 149 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
150 if (activeFileEditorTab) | 150 if (_active_file_editor_tab) |
151 activeFileEditorTab->paste (); | 151 _active_file_editor_tab->paste (); |
152 } | 152 } |
153 | 153 |
154 void | 154 void |
155 file_editor::request_save_file () | 155 file_editor::request_save_file () |
156 { | 156 { |
157 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 157 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
158 if (activeFileEditorTab) | 158 if (_active_file_editor_tab) |
159 activeFileEditorTab->save_file (); | 159 _active_file_editor_tab->save_file (); |
160 } | 160 } |
161 | 161 |
162 void | 162 void |
163 file_editor::request_save_file_as () | 163 file_editor::request_save_file_as () |
164 { | 164 { |
165 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 165 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
166 if (activeFileEditorTab) | 166 if (_active_file_editor_tab) |
167 activeFileEditorTab->save_file_as (); | 167 _active_file_editor_tab->save_file_as (); |
168 } | 168 } |
169 | 169 |
170 void | 170 void |
171 file_editor::request_run_file () | 171 file_editor::request_run_file () |
172 { | 172 { |
173 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 173 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
174 if (activeFileEditorTab) | 174 if (_active_file_editor_tab) |
175 activeFileEditorTab->run_file (); | 175 _active_file_editor_tab->run_file (); |
176 } | 176 } |
177 | 177 |
178 void | 178 void |
179 file_editor::request_toggle_bookmark () | 179 file_editor::request_toggle_bookmark () |
180 { | 180 { |
181 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 181 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
182 if (activeFileEditorTab) | 182 if (_active_file_editor_tab) |
183 activeFileEditorTab->toggle_bookmark (); | 183 _active_file_editor_tab->toggle_bookmark (); |
184 } | 184 } |
185 | 185 |
186 void | 186 void |
187 file_editor::request_next_bookmark () | 187 file_editor::request_next_bookmark () |
188 { | 188 { |
189 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 189 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
190 if (activeFileEditorTab) | 190 if (_active_file_editor_tab) |
191 activeFileEditorTab->next_bookmark (); | 191 _active_file_editor_tab->next_bookmark (); |
192 } | 192 } |
193 | 193 |
194 void | 194 void |
195 file_editor::request_previous_bookmark () | 195 file_editor::request_previous_bookmark () |
196 { | 196 { |
197 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 197 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
198 if (activeFileEditorTab) | 198 if (_active_file_editor_tab) |
199 activeFileEditorTab->previous_bookmark (); | 199 _active_file_editor_tab->previous_bookmark (); |
200 } | 200 } |
201 | 201 |
202 void | 202 void |
203 file_editor::request_remove_bookmark () | 203 file_editor::request_remove_bookmark () |
204 { | 204 { |
205 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 205 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
206 if (activeFileEditorTab) | 206 if (_active_file_editor_tab) |
207 activeFileEditorTab->remove_bookmark (); | 207 _active_file_editor_tab->remove_bookmark (); |
208 } | 208 } |
209 | 209 |
210 void | 210 void |
211 file_editor::request_toggle_breakpoint () | 211 file_editor::request_toggle_breakpoint () |
212 { | 212 { |
213 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 213 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
214 if (activeFileEditorTab) | 214 if (_active_file_editor_tab) |
215 activeFileEditorTab->toggle_breakpoint (); | 215 _active_file_editor_tab->toggle_breakpoint (); |
216 } | 216 } |
217 | 217 |
218 void | 218 void |
219 file_editor::request_next_breakpoint () | 219 file_editor::request_next_breakpoint () |
220 { | 220 { |
221 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 221 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
222 if (activeFileEditorTab) | 222 if (_active_file_editor_tab) |
223 activeFileEditorTab->next_breakpoint (); | 223 _active_file_editor_tab->next_breakpoint (); |
224 } | 224 } |
225 | 225 |
226 void | 226 void |
227 file_editor::request_previous_breakpoint () | 227 file_editor::request_previous_breakpoint () |
228 { | 228 { |
229 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 229 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
230 if (activeFileEditorTab) | 230 if (_active_file_editor_tab) |
231 activeFileEditorTab->previous_breakpoint (); | 231 _active_file_editor_tab->previous_breakpoint (); |
232 } | 232 } |
233 | 233 |
234 void | 234 void |
235 file_editor::request_remove_breakpoint () | 235 file_editor::request_remove_breakpoint () |
236 { | 236 { |
237 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 237 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
238 if (activeFileEditorTab) | 238 if (_active_file_editor_tab) |
239 activeFileEditorTab->remove_all_breakpoints (); | 239 _active_file_editor_tab->remove_all_breakpoints (); |
240 } | 240 } |
241 | 241 |
242 void | 242 void |
243 file_editor::request_comment_selected_text () | 243 file_editor::request_comment_selected_text () |
244 { | 244 { |
245 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 245 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
246 if (activeFileEditorTab) | 246 if (_active_file_editor_tab) |
247 activeFileEditorTab->comment_selected_text (); | 247 _active_file_editor_tab->comment_selected_text (); |
248 } | 248 } |
249 | 249 |
250 void | 250 void |
251 file_editor::request_uncomment_selected_text () | 251 file_editor::request_uncomment_selected_text () |
252 { | 252 { |
253 file_editor_tab *activeFileEditorTab = active_editor_tab (); | 253 file_editor_tab *_active_file_editor_tab = active_editor_tab (); |
254 if (activeFileEditorTab) | 254 if (_active_file_editor_tab) |
255 activeFileEditorTab->uncomment_selected_text (); | 255 _active_file_editor_tab->uncomment_selected_text (); |
256 } | |
257 | |
258 void | |
259 file_editor::request_find () | |
260 { | |
261 file_editor_tab *_active_file_editor_tab = active_editor_tab (); | |
262 if (_active_file_editor_tab) | |
263 _active_file_editor_tab->find (); | |
256 } | 264 } |
257 | 265 |
258 void | 266 void |
259 file_editor::handle_file_name_changed (QString fileName) | 267 file_editor::handle_file_name_changed (QString fileName) |
260 { | 268 { |
347 tr("&Undo"), _tool_bar); | 355 tr("&Undo"), _tool_bar); |
348 | 356 |
349 QAction *redo_action = new QAction (QIcon(":/actions/icons/redo.png"), | 357 QAction *redo_action = new QAction (QIcon(":/actions/icons/redo.png"), |
350 tr("&Redo"), _tool_bar); | 358 tr("&Redo"), _tool_bar); |
351 | 359 |
352 _copy_action = new QAction (QIcon::fromTheme ("edit-copy"), | 360 _copy_action = new QAction (QIcon(":/actions/icons/editcopy.png"), |
353 tr ("&Copy"), _tool_bar); | 361 tr ("&Copy"), _tool_bar); |
354 | 362 |
355 _cut_action = new QAction (QIcon::fromTheme ("edit-cut"), | 363 _cut_action = new QAction (QIcon(":/actions/icons/editcut.png"), |
356 tr ("Cu&t"), _tool_bar); | 364 tr ("Cu&t"), _tool_bar); |
357 | 365 |
358 QAction *paste_action | 366 QAction *paste_action |
359 = new QAction (QIcon (":/actions/icons/editpaste.png"), | 367 = new QAction (QIcon (":/actions/icons/editpaste.png"), |
360 tr("Paste"), _tool_bar); | 368 tr("Paste"), _tool_bar); |
368 QAction *toggle_breakpoint_action = new QAction (tr ("Toggle &breakpoint"),_tool_bar); | 376 QAction *toggle_breakpoint_action = new QAction (tr ("Toggle &breakpoint"),_tool_bar); |
369 QAction *remove_breakpoint_action = new QAction (tr ("&Remove All breakpoints"),_tool_bar); | 377 QAction *remove_breakpoint_action = new QAction (tr ("&Remove All breakpoints"),_tool_bar); |
370 | 378 |
371 QAction *comment_selection_action = new QAction (tr ("&Comment Selected Text"),_tool_bar); | 379 QAction *comment_selection_action = new QAction (tr ("&Comment Selected Text"),_tool_bar); |
372 QAction *uncomment_selection_action = new QAction (tr ("&Uncomment Selected Text"),_tool_bar); | 380 QAction *uncomment_selection_action = new QAction (tr ("&Uncomment Selected Text"),_tool_bar); |
381 | |
382 QAction *find_action = new QAction (QIcon(":/actions/icons/find.png"), | |
383 tr ("&Find"), _tool_bar); | |
373 | 384 |
374 _run_action = new QAction (QIcon(":/actions/icons/artsbuilderexecute.png"), | 385 _run_action = new QAction (QIcon(":/actions/icons/artsbuilderexecute.png"), |
375 tr("Save File And Run"), _tool_bar); | 386 tr("Save File And Run"), _tool_bar); |
376 | 387 |
377 // some actions are disabled from the beginning | 388 // some actions are disabled from the beginning |
387 toggle_bookmark_action->setShortcutContext (Qt::WindowShortcut); | 398 toggle_bookmark_action->setShortcutContext (Qt::WindowShortcut); |
388 comment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_7); | 399 comment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_7); |
389 comment_selection_action->setShortcutContext (Qt::WindowShortcut); | 400 comment_selection_action->setShortcutContext (Qt::WindowShortcut); |
390 uncomment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_8); | 401 uncomment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_8); |
391 uncomment_selection_action->setShortcutContext(Qt::WindowShortcut); | 402 uncomment_selection_action->setShortcutContext(Qt::WindowShortcut); |
403 find_action->setShortcut (Qt::ControlModifier+Qt::Key_F); | |
404 find_action->setShortcutContext (Qt::WindowShortcut); | |
392 | 405 |
393 // toolbar | 406 // toolbar |
394 _tool_bar->addAction (new_action); | 407 _tool_bar->addAction (new_action); |
395 _tool_bar->addAction (open_action); | 408 _tool_bar->addAction (open_action); |
396 _tool_bar->addAction (save_action); | 409 _tool_bar->addAction (save_action); |
398 _tool_bar->addSeparator (); | 411 _tool_bar->addSeparator (); |
399 _tool_bar->addAction (undo_action); | 412 _tool_bar->addAction (undo_action); |
400 _tool_bar->addAction (redo_action); | 413 _tool_bar->addAction (redo_action); |
401 _tool_bar->addAction (_copy_action); | 414 _tool_bar->addAction (_copy_action); |
402 _tool_bar->addAction (_cut_action); | 415 _tool_bar->addAction (_cut_action); |
416 _tool_bar->addSeparator (); | |
403 _tool_bar->addAction (paste_action); | 417 _tool_bar->addAction (paste_action); |
404 _tool_bar->addSeparator (); | 418 _tool_bar->addAction (find_action); |
405 _tool_bar->addAction (_run_action); | 419 _tool_bar->addAction (_run_action); |
406 | 420 |
407 // menu bar | 421 // menu bar |
408 QMenu *fileMenu = new QMenu (tr ("&File"), _menu_bar); | 422 QMenu *fileMenu = new QMenu (tr ("&File"), _menu_bar); |
409 fileMenu->addAction (new_action); | 423 fileMenu->addAction (new_action); |
418 editMenu->addAction (redo_action); | 432 editMenu->addAction (redo_action); |
419 editMenu->addSeparator (); | 433 editMenu->addSeparator (); |
420 editMenu->addAction (_copy_action); | 434 editMenu->addAction (_copy_action); |
421 editMenu->addAction (_cut_action); | 435 editMenu->addAction (_cut_action); |
422 editMenu->addAction (paste_action); | 436 editMenu->addAction (paste_action); |
437 editMenu->addSeparator (); | |
438 editMenu->addAction (find_action); | |
423 editMenu->addSeparator (); | 439 editMenu->addSeparator (); |
424 editMenu->addAction (comment_selection_action); | 440 editMenu->addAction (comment_selection_action); |
425 editMenu->addAction (uncomment_selection_action); | 441 editMenu->addAction (uncomment_selection_action); |
426 editMenu->addSeparator (); | 442 editMenu->addSeparator (); |
427 editMenu->addAction (toggle_bookmark_action); | 443 editMenu->addAction (toggle_bookmark_action); |
489 SIGNAL (triggered ()), this, SLOT (request_remove_breakpoint ())); | 505 SIGNAL (triggered ()), this, SLOT (request_remove_breakpoint ())); |
490 connect (comment_selection_action, | 506 connect (comment_selection_action, |
491 SIGNAL (triggered ()), this, SLOT (request_comment_selected_text ())); | 507 SIGNAL (triggered ()), this, SLOT (request_comment_selected_text ())); |
492 connect (uncomment_selection_action, | 508 connect (uncomment_selection_action, |
493 SIGNAL (triggered ()), this, SLOT (request_uncomment_selected_text ())); | 509 SIGNAL (triggered ()), this, SLOT (request_uncomment_selected_text ())); |
510 connect (find_action, | |
511 SIGNAL (triggered ()), this, SLOT (request_find ())); | |
494 connect (_tab_widget, | 512 connect (_tab_widget, |
495 SIGNAL (tabCloseRequested (int)), this, SLOT (handle_tab_close_request (int))); | 513 SIGNAL (tabCloseRequested (int)), this, SLOT (handle_tab_close_request (int))); |
496 connect (_tab_widget, | 514 connect (_tab_widget, |
497 SIGNAL (currentChanged(int)), this, SLOT (active_tab_changed (int))); | 515 SIGNAL (currentChanged(int)), this, SLOT (active_tab_changed (int))); |
498 | 516 |