Changeset 561 for trunk/src/gui/kernel/qaction.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/kernel/qaction.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 77 77 } 78 78 return s.trimmed(); 79 } ;79 } 80 80 81 81 82 82 QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), 83 83 visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), 84 menuRole(QAction::TextHeuristicRole), iconVisibleInMenu(-1) 84 menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::NoSoftKey), 85 priority(QAction::NormalPriority), iconVisibleInMenu(-1) 85 86 { 86 87 #ifdef QT3_SUPPORT … … 100 101 } 101 102 103 bool QActionPrivate::showStatusText(QWidget *widget, const QString &str) 104 { 105 #ifdef QT_NO_STATUSTIP 106 Q_UNUSED(widget); 107 Q_UNUSED(str); 108 #else 109 if(QObject *object = widget ? widget : parent) { 110 QStatusTipEvent tip(str); 111 QApplication::sendEvent(object, &tip); 112 return true; 113 } 114 #endif 115 return false; 116 } 117 102 118 void QActionPrivate::sendDataChanged() 103 119 { … … 137 153 { 138 154 Q_Q(QAction); 139 for each (int id, alternateShortcutIds)140 if ( id)155 for(int i = 0; i < alternateShortcutIds.count(); ++i) { 156 if (const int id = alternateShortcutIds.at(i)) 141 157 map.removeShortcut(id, q); 158 } 142 159 alternateShortcutIds.clear(); 143 160 if (alternateShortcuts.isEmpty()) 144 161 return; 145 foreach (const QKeySequence& alternate, alternateShortcuts) { 162 for(int i = 0; i < alternateShortcuts.count(); ++i) { 163 const QKeySequence& alternate = alternateShortcuts.at(i); 146 164 if (!alternate.isEmpty()) 147 165 alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext)); … … 150 168 } 151 169 if (!enabled) { 152 foreach (int id, alternateShortcutIds) 170 for(int i = 0; i < alternateShortcutIds.count(); ++i) { 171 const int id = alternateShortcutIds.at(i); 153 172 map.setShortcutEnabled(false, id, q); 173 } 154 174 } 155 175 if (!autorepeat) { 156 foreach (int id, alternateShortcutIds) 176 for(int i = 0; i < alternateShortcutIds.count(); ++i) { 177 const int id = alternateShortcutIds.at(i); 157 178 map.setShortcutAutoRepeat(false, id, q); 179 } 158 180 } 159 181 } … … 164 186 if (shortcutId) 165 187 map.setShortcutEnabled(enable, shortcutId, q); 166 for each (int id, alternateShortcutIds)167 if ( id)188 for(int i = 0; i < alternateShortcutIds.count(); ++i) { 189 if (const int id = alternateShortcutIds.at(i)) 168 190 map.setShortcutEnabled(enable, id, q); 191 } 169 192 } 170 193 #endif // QT_NO_SHORTCUT … … 176 199 action that can be inserted into widgets. 177 200 178 \ingroup application179 \mainclass 201 \ingroup mainwindow-classes 202 180 203 181 204 \omit … … 250 273 \value ApplicationSpecificRole This action should be put in the application menu with an application specific role 251 274 \value AboutQtRole This action matches handles the "About Qt" menu item. 252 \value AboutRole This action should be placed where the "About" menu item is in the application menu. 275 \value AboutRole This action should be placed where the "About" menu item is in the application menu. The text of 276 the menu item will be set to "About <application name>". The application name is fetched from the 277 \c{Info.plist} file in the application's bundle (See \l{Deploying an Application on Mac OS X}). 253 278 \value PreferencesRole This action should be placed where the "Preferences..." menu item is in the application menu. 254 279 \value QuitRole This action should be placed where the Quit menu item is in the application menu. 255 */ 280 281 Setting this value only has effect on items that are in the immediate menus 282 of the menubar, not the submenus of those menus. For example, if you have 283 File menu in your menubar and the File menu has a submenu, setting the 284 MenuRole for the actions in that submenu have no effect. They will never be moved. 285 */ 286 287 /*! \since 4.6 288 289 \enum QAction::SoftKeyRole 290 291 This enum describes how an action should be placed in the softkey bar. Currently this enum only 292 has an effect on the Symbian platform. 293 294 \value NoSoftKey This action should not be used as a softkey 295 \value PositiveSoftKey This action is used to describe a softkey with a positive or non-destructive 296 role such as Ok, Select, or Options. 297 \value NegativeSoftKey This action is used to describe a soft ey with a negative or destructive role 298 role such as Cancel, Discard, or Close. 299 \value SelectSoftKey This action is used to describe a role that selects a particular item or widget 300 in the application. 301 302 Actions with a softkey role defined are only visible in the softkey bar when the widget containing 303 the action has focus. If no widget currently has focus, the softkey framework will traverse up the 304 widget parent hierarchy looking for a widget containing softkey actions. 305 */ 256 306 257 307 /*! … … 616 666 if (d->shortcutId && qApp) { 617 667 qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); 618 foreach (int id, d->alternateShortcutIds) 668 for(int i = 0; i < d->alternateShortcutIds.count(); ++i) { 669 const int id = d->alternateShortcutIds.at(i); 619 670 qApp->d_func()->shortcutMap.removeShortcut(id, this); 671 } 620 672 } 621 673 #endif … … 899 951 } 900 952 953 /*! 954 \enum QAction::Priority 955 \since 4.6 956 957 This enum defines priorities for actions in user interface. 958 959 \value LowPriority The action should not be prioritized in 960 the user interface. 961 962 \value NormalPriority 963 964 \value HighPriority The action should be prioritized in 965 the user interface. 966 967 \sa priority 968 */ 969 970 971 /*! 972 \property QAction::priority 973 \since 4.6 974 975 \brief the actions's priority in the user interface. 976 977 This property can be set to indicate how the action should be prioritized 978 in the user interface. 979 980 For instance, when toolbars have the Qt::ToolButtonTextBesideIcon 981 mode set, then actions with LowPriority will not show the text 982 labels. 983 */ 984 void QAction::setPriority(Priority priority) 985 { 986 Q_D(QAction); 987 if (d->priority == priority) 988 return; 989 990 d->priority = priority; 991 d->sendDataChanged(); 992 } 993 994 QAction::Priority QAction::priority() const 995 { 996 Q_D(const QAction); 997 return d->priority; 998 } 901 999 902 1000 /*! … … 1124 1222 QAction::showStatusText(QWidget *widget) 1125 1223 { 1126 #ifdef QT_NO_STATUSTIP 1127 Q_UNUSED(widget); 1128 #else 1129 if(QObject *object = widget ? widget : parent()) { 1130 QStatusTipEvent tip(statusTip()); 1131 QApplication::sendEvent(object, &tip); 1132 return true; 1133 } 1134 #endif 1135 return false; 1224 return d_func()->showStatusText(widget, statusTip()); 1136 1225 } 1137 1226 … … 1152 1241 if (d->checked && (d->group && d->group->isExclusive() 1153 1242 && d->group->checkedAction() == this)) { 1243 if (guard) 1244 emit triggered(true); 1154 1245 QMetaObject::removeGuard(&guard); 1155 1246 return; … … 1349 1440 1350 1441 /*! 1442 \property QAction::softKeyRole 1443 \brief the action's softkey role 1444 \since 4.6 1445 1446 This indicates what type of role this action describes in the softkey framework 1447 on platforms where such a framework is supported. Currently this is only 1448 supported on the Symbian platform. 1449 1450 The softkey role can be changed any time. 1451 */ 1452 void QAction::setSoftKeyRole(SoftKeyRole softKeyRole) 1453 { 1454 Q_D(QAction); 1455 if (d->softKeyRole == softKeyRole) 1456 return; 1457 1458 d->softKeyRole = softKeyRole; 1459 d->sendDataChanged(); 1460 } 1461 1462 QAction::SoftKeyRole QAction::softKeyRole() const 1463 { 1464 Q_D(const QAction); 1465 return d->softKeyRole; 1466 } 1467 1468 /*! 1351 1469 \property QAction::iconVisibleInMenu 1352 1470 \brief Whether or not an action should show an icon in a menu … … 1369 1487 { 1370 1488 Q_D(QAction); 1371 if ( visible != (bool)d->iconVisibleInMenu) {1489 if (d->iconVisibleInMenu == -1 || visible != bool(d->iconVisibleInMenu)) { 1372 1490 int oldValue = d->iconVisibleInMenu; 1373 1491 d->iconVisibleInMenu = visible;
Note:
See TracChangeset
for help on using the changeset viewer.