1 /* 2 * Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 * 02110-1301, USA. 18 */ 19 20 #ifndef __FBREADERACTIONS_H__ 21 #define __FBREADERACTIONS_H__ 22 23 #include <ZLApplication.h> 24 25 #include "FBReader.h" 26 27 class ZLTextView; 28 29 class ActionCode { 30 31 public: 32 static const std::string SHOW_READING; 33 static const std::string SHOW_LIBRARY; 34 static const std::string SHOW_NETWORK_LIBRARY; 35 static const std::string SHOW_TOC; 36 static const std::string SHOW_HELP; 37 static const std::string SHOW_OPTIONS_DIALOG; 38 static const std::string SHOW_BOOK_INFO_DIALOG; 39 static const std::string SHOW_LIBRARY_OPTIONS_DIALOG; 40 static const std::string SHOW_NETWORK_OPTIONS_DIALOG; 41 static const std::string SHOW_SYSTEM_OPTIONS_DIALOG; 42 static const std::string SHOW_READING_OPTIONS_DIALOG; 43 static const std::string SHOW_LOOKANDFEEL_OPTIONS_DIALOG; 44 static const std::string UNDO; 45 static const std::string REDO; 46 static const std::string SEARCH; 47 static const std::string FIND_PREVIOUS; 48 static const std::string FIND_NEXT; 49 static const std::string PAGE_SCROLL_FORWARD; 50 static const std::string PAGE_SCROLL_BACKWARD; 51 static const std::string LINE_SCROLL_FORWARD; 52 static const std::string LINE_SCROLL_BACKWARD; 53 static const std::string MOUSE_SCROLL_FORWARD; 54 static const std::string MOUSE_SCROLL_BACKWARD; 55 static const std::string TAP_SCROLL_FORWARD; 56 static const std::string TAP_SCROLL_BACKWARD; 57 static const std::string SCROLL_TO_HOME; 58 static const std::string SCROLL_TO_START_OF_TEXT; 59 static const std::string SCROLL_TO_END_OF_TEXT; 60 static const std::string CANCEL; 61 static const std::string INCREASE_FONT; 62 static const std::string DECREASE_FONT; 63 static const std::string SHOW_HIDE_POSITION_INDICATOR; 64 static const std::string TOGGLE_FULLSCREEN; 65 static const std::string FULLSCREEN_ON; 66 static const std::string ADD_BOOK; 67 static const std::string ROTATE_SCREEN; 68 static const std::string QUIT; 69 static const std::string FORCE_QUIT; 70 static const std::string OPEN_PREVIOUS_BOOK; 71 static const std::string GOTO_NEXT_TOC_SECTION; 72 static const std::string GOTO_PREVIOUS_TOC_SECTION; 73 static const std::string COPY_SELECTED_TEXT_TO_CLIPBOARD; 74 static const std::string CLEAR_SELECTION; 75 static const std::string OPEN_SELECTED_TEXT_IN_DICTIONARY; 76 static const std::string GOTO_PAGE_NUMBER; 77 static const std::string GOTO_PAGE_NUMBER_WITH_PARAMETER; 78 static const std::string SEARCH_ON_NETWORK; 79 static const std::string ADVANCED_SEARCH_ON_NETWORK; 80 static const std::string ORGANIZE_BOOKS_BY_AUTHOR; 81 static const std::string ORGANIZE_BOOKS_BY_TAG; 82 static const std::string FILTER_LIBRARY; 83 84 private: 85 ActionCode(); 86 }; 87 88 class ModeDependentAction : public ZLApplication::Action { 89 90 protected: 91 ModeDependentAction(int visibleInModes); 92 93 public: 94 bool isVisible() const; 95 96 private: 97 int myVisibleInModes; 98 }; 99 100 class SetModeAction : public ModeDependentAction { 101 102 public: 103 SetModeAction(FBReader::ViewMode modeToSet, int visibleInModes); 104 void run(); 105 106 private: 107 FBReader::ViewMode myModeToSet; 108 }; 109 110 class ShowHelpAction : public ZLApplication::Action { 111 112 public: 113 void run(); 114 }; 115 116 class ShowOptionsDialogAction : public ZLApplication::Action { 117 118 public: 119 void run(); 120 }; 121 122 class ShowLibraryOptionsDialogAction : public ZLApplication::Action { 123 124 public: 125 void run(); 126 }; 127 128 class ShowNetworkOptionsDialogAction : public ZLApplication::Action { 129 130 public: 131 void run(); 132 }; 133 134 class ShowSystemOptionsDialogAction : public ZLApplication::Action { 135 136 public: 137 void run(); 138 }; 139 140 class ShowReadingOptionsDialogAction : public ZLApplication::Action { 141 142 public: 143 void run(); 144 }; 145 146 class ShowLookAndFeelOptionsDialogAction : public ZLApplication::Action { 147 148 public: 149 void run(); 150 }; 151 152 class ShowContentsAction : public SetModeAction { 153 154 public: 155 ShowContentsAction(); 156 bool isVisible() const; 157 }; 158 159 class ShowNetworkLibraryAction : public SetModeAction { 160 161 public: 162 ShowNetworkLibraryAction(); 163 bool isVisible() const; 164 }; 165 166 class AddBookAction : public ModeDependentAction { 167 168 private: 169 class FileFilter; 170 171 private: 172 ZLStringOption DirectoryOption; 173 ZLStringOption FileOption; 174 175 public: 176 AddBookAction(int visibleInModes); 177 void run(); 178 }; 179 180 class ShowBookInfoAction : public ModeDependentAction { 181 182 public: 183 ShowBookInfoAction(); 184 void run(); 185 }; 186 187 class ScrollToHomeAction : public ModeDependentAction { 188 189 public: 190 ScrollToHomeAction(); 191 bool isEnabled() const; 192 void run(); 193 }; 194 195 class ScrollToStartOfTextAction : public ModeDependentAction { 196 197 public: 198 ScrollToStartOfTextAction(); 199 bool isEnabled() const; 200 void run(); 201 }; 202 203 class ScrollToEndOfTextAction : public ModeDependentAction { 204 205 public: 206 ScrollToEndOfTextAction(); 207 bool isEnabled() const; 208 void run(); 209 }; 210 211 class UndoAction : public ModeDependentAction { 212 213 public: 214 UndoAction(int visibleInModes); 215 bool isEnabled() const; 216 void run(); 217 }; 218 219 class RedoAction : public ModeDependentAction { 220 221 public: 222 RedoAction(); 223 bool isEnabled() const; 224 void run(); 225 }; 226 227 class SearchAction : public ZLApplication::Action { 228 229 public: 230 bool isVisible() const; 231 }; 232 233 class SearchPatternAction : public SearchAction { 234 235 public: 236 SearchPatternAction(); 237 void run(); 238 239 private: 240 ZLBooleanOption SearchBackwardOption; 241 ZLBooleanOption SearchIgnoreCaseOption; 242 ZLBooleanOption SearchInWholeTextOption; 243 ZLBooleanOption SearchThisSectionOnlyOption; 244 ZLStringOption SearchPatternOption; 245 246 friend class SearchPatternEntry; 247 }; 248 249 class FindNextAction : public SearchAction { 250 251 public: 252 bool isEnabled() const; 253 void run(); 254 }; 255 256 class FindPreviousAction : public SearchAction { 257 258 public: 259 bool isEnabled() const; 260 void run(); 261 }; 262 263 class ChangeFontSizeAction : public ZLApplication::Action { 264 265 public: 266 ChangeFontSizeAction(int delta); 267 bool isEnabled() const; 268 void run(); 269 270 private: 271 const int myDelta; 272 }; 273 274 class CancelAction : public ZLApplication::Action { 275 276 public: 277 void run(); 278 }; 279 280 class ToggleIndicatorAction : public ZLApplication::Action { 281 282 public: 283 bool isVisible() const; 284 void run(); 285 }; 286 287 class QuitAction : public ZLApplication::Action { 288 289 public: 290 void run(); 291 }; 292 293 class ForceQuitAction : public ZLApplication::Action { 294 295 public: 296 void run(); 297 }; 298 299 class OpenPreviousBookAction : public ZLApplication::Action { 300 301 public: 302 bool isVisible() const; 303 void run(); 304 }; 305 306 class GotoNextTOCSectionAction : public ZLApplication::Action { 307 308 public: 309 bool isVisible() const; 310 bool isEnabled() const; 311 void run(); 312 }; 313 314 class GotoPreviousTOCSectionAction : public ZLApplication::Action { 315 316 public: 317 bool isVisible() const; 318 bool isEnabled() const; 319 void run(); 320 }; 321 322 class GotoPageNumberAction : public ModeDependentAction { 323 324 public: 325 GotoPageNumberAction(const std::string ¶meter); 326 bool isVisible() const; 327 bool isEnabled() const; 328 void run(); 329 330 private: 331 const std::string myParameter; 332 }; 333 334 class SelectionAction : public ZLApplication::Action { 335 336 public: 337 bool isVisible() const; 338 bool isEnabled() const; 339 340 protected: 341 ZLTextView &textView() const; 342 }; 343 344 class CopySelectedTextAction : public SelectionAction { 345 346 public: 347 bool isVisible() const; 348 void run(); 349 }; 350 351 class OpenSelectedTextInDictionaryAction : public SelectionAction { 352 353 public: 354 bool isVisible() const; 355 void run(); 356 }; 357 358 class ClearSelectionAction : public SelectionAction { 359 360 public: 361 void run(); 362 }; 363 364 class SearchOnNetworkAction : public ModeDependentAction { 365 366 public: 367 SearchOnNetworkAction(); 368 void run(); 369 370 private: 371 virtual void doSearch() = 0; 372 }; 373 374 class SimpleSearchOnNetworkAction : public SearchOnNetworkAction { 375 376 private: 377 void doSearch(); 378 std::string makeSummary(const std::string &pattern); 379 }; 380 381 class AdvancedSearchOnNetworkAction : public SearchOnNetworkAction { 382 383 private: 384 void doSearch(); 385 std::string makeSummary(const std::string &titleAndSeries, const std::string &author, const std::string &category, const std::string &description); 386 void appendQueryValue(std::string &query, const std::string &name, const std::string &value); 387 }; 388 389 class FBFullscreenAction : public ZLApplication::FullscreenAction { 390 391 public: 392 void run(); 393 }; 394 395 class BooksOrderAction : public ModeDependentAction { 396 397 public: 398 BooksOrderAction(); 399 void run(); 400 }; 401 402 class FilterLibraryAction : public ModeDependentAction { 403 404 public: 405 FilterLibraryAction(); 406 void run(); 407 }; 408 409 #endif /* __FBREADERACTIONS_H__ */ 410