1 /***************************************************************************** 2 * Copyright (C) 2002 Shie Erlich <erlich@users.sourceforge.net> * 3 * Copyright (C) 2002 Rafi Yanai <yanai@users.sourceforge.net> * 4 * Copyright (C) 2004-2019 Krusader Krew [https://krusader.org] * 5 * * 6 * This file is part of Krusader [https://krusader.org]. * 7 * * 8 * Krusader is free software: you can redistribute it and/or modify * 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 * 11 * (at your option) any later version. * 12 * * 13 * Krusader is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 * GNU General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU General Public License * 19 * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * 20 *****************************************************************************/ 21 22 #ifndef KRSELECTIONMODE_H 23 #define KRSELECTIONMODE_H 24 25 // QtCore 26 #include <QString> 27 28 /** 29 Every selection mode inherits this class, and has to implement init(). 30 Usage: 31 KrSelectionMode::getSelectionHandler()->whateverFunctionYouNeed() 32 33 \note You can call KrSelectionMode::resetSelectionHandler() if you want the 34 selection mode to be re-read. This is useful after a configuration where you 35 changed the selection mode. calling resetSelectionHandler() will cause the next 36 call to getSelectionHandler() to (possibly) select a different mode. 37 */ 38 class KrSelectionMode 39 { 40 public: 41 static KrSelectionMode * getSelectionHandlerForMode(const QString &mode); 42 static KrSelectionMode * getSelectionHandler(); 43 static void resetSelectionHandler(); 44 45 virtual void init() = 0; // everyone must implement this in order to be a selection mode useQTSelection()46 inline bool useQTSelection() { 47 return _useQTSelection; 48 } spaceMovesDown()49 inline bool spaceMovesDown() { 50 return _spaceMovesDown; 51 } insertMovesDown()52 inline bool insertMovesDown() { 53 return _insertMovesDown; 54 } spaceCalculatesDiskSpace()55 inline bool spaceCalculatesDiskSpace() { 56 return _spaceCalculatesDiskSpace; 57 } rightButtonSelects()58 inline bool rightButtonSelects() { 59 return _rightButtonSelects; 60 } leftButtonSelects()61 inline bool leftButtonSelects() { 62 return _leftButtonSelects; 63 } rightButtonPreservesSelection()64 inline bool rightButtonPreservesSelection() { 65 return _rightButtonPreservesSelection; 66 } leftButtonPreservesSelection()67 inline bool leftButtonPreservesSelection() { 68 return _leftButtonPreservesSelection; 69 } shiftCtrlRightButtonSelects()70 inline bool shiftCtrlRightButtonSelects() { 71 return _shiftCtrlRightButtonSelects; 72 } shiftCtrlLeftButtonSelects()73 inline bool shiftCtrlLeftButtonSelects() { 74 return _shiftCtrlLeftButtonSelects; 75 } showContextMenu()76 inline int showContextMenu() { 77 return _showContextMenu; 78 } // 0: no, -1: yes, n>0: after n milliseconds 79 ~KrSelectionMode()80 virtual ~KrSelectionMode() {} 81 82 protected: 83 bool _useQTSelection, _spaceMovesDown, _insertMovesDown, _spaceCalculatesDiskSpace; 84 bool _rightButtonSelects, _leftButtonSelects, _rightButtonPreservesSelection; 85 bool _leftButtonPreservesSelection, _shiftCtrlRightButtonSelects, _shiftCtrlLeftButtonSelects; 86 int _showContextMenu; 87 }; 88 89 class KonqSelectionMode : public KrSelectionMode 90 { 91 public: init()92 void init() Q_DECL_OVERRIDE { 93 _useQTSelection = true; 94 _spaceMovesDown = false; 95 _insertMovesDown = true; 96 _spaceCalculatesDiskSpace = false; 97 _rightButtonSelects = true; 98 _leftButtonSelects = true; 99 _rightButtonPreservesSelection = false; 100 _leftButtonPreservesSelection = false; 101 _shiftCtrlRightButtonSelects = false; 102 _shiftCtrlLeftButtonSelects = false; 103 _showContextMenu = -1; 104 } 105 }; 106 107 class OriginalSelectionMode : public KrSelectionMode 108 { 109 public: init()110 void init() Q_DECL_OVERRIDE { 111 _useQTSelection = false; 112 _spaceMovesDown = true; 113 _insertMovesDown = true; 114 _spaceCalculatesDiskSpace = true; 115 _rightButtonSelects = true; 116 _leftButtonSelects = true; 117 _rightButtonPreservesSelection = false; 118 _leftButtonPreservesSelection = false; 119 _shiftCtrlRightButtonSelects = false; 120 _shiftCtrlLeftButtonSelects = false; 121 _showContextMenu = -1; 122 } 123 }; 124 125 class TCSelectionMode : public KrSelectionMode 126 { 127 public: init()128 void init() Q_DECL_OVERRIDE { 129 _useQTSelection = false; 130 _spaceMovesDown = false; 131 _insertMovesDown = true; 132 _spaceCalculatesDiskSpace = true; 133 _rightButtonSelects = true; 134 _leftButtonSelects = false; 135 _rightButtonPreservesSelection = true; 136 _leftButtonPreservesSelection = false; 137 _shiftCtrlRightButtonSelects = false; 138 _shiftCtrlLeftButtonSelects = true; 139 _showContextMenu = 500; 140 } 141 }; 142 143 class ErgonomicSelectionMode : public KrSelectionMode 144 { 145 public: init()146 void init() Q_DECL_OVERRIDE { 147 _useQTSelection = false; 148 _spaceMovesDown = false; 149 _insertMovesDown = true; 150 _spaceCalculatesDiskSpace = true; 151 _rightButtonSelects = false; 152 _leftButtonSelects = false; 153 _rightButtonPreservesSelection = true; 154 _leftButtonPreservesSelection = true; 155 _shiftCtrlRightButtonSelects = false; 156 _shiftCtrlLeftButtonSelects = true; 157 _showContextMenu = -1; 158 } 159 }; 160 161 class UserSelectionMode: public KrSelectionMode 162 { 163 public: 164 void init() Q_DECL_OVERRIDE; 165 }; 166 167 #endif // KR_SELECTION_MODE_H 168