42 #import <private/qcocoatoolbardelegate_mac_p.h> 43 #ifdef QT_MAC_USE_COCOA 44 #include <private/qmainwindowlayout_p.h> 45 #include <private/qt_mac_p.h> 46 #include <private/qt_cocoa_helpers_mac_p.h> 47 #include <private/qcocoaview_mac_p.h> 48 #include <private/qwidget_p.h> 61 @implementation QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate)
72 - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar
75 return [NSArray arrayWithObject:@"com.trolltech.qt.nstoolbar-qtoolbar"];
78 - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar
80 return [
self toolbarAllowedItemIdentifiers:toolbar];
83 - (void)toolbarDidRemoveItem:(NSNotification *)notification
85 NSToolbarItem *item = [[notification userInfo] valueForKey:@"item"];
86 mainWindowLayout->unifiedToolbarHash.remove(item);
87 for (
int i = 0; i < mainWindowLayout->toolbarItemsCopy.size(); ++i) {
88 if (mainWindowLayout->toolbarItemsCopy.at(i) == item) {
90 mainWindowLayout->toolbarItemsCopy.removeAt(i);
91 mainWindowLayout->qtoolbarsInUnifiedToolbarList.removeAt(i);
98 - (NSToolbarItem *)
toolbar:(NSToolbar *)nstoolbar itemForItemIdentifier:(NSString *)itemIdentifier
99 willBeInsertedIntoToolbar:(BOOL)flag
103 QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value(
105 NSToolbarItem *item = nil;
107 item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
108 mainWindowLayout->unifiedToolbarHash.insert(item, tb);
113 - (void)toolbarWillAddItem:(NSNotification *)notification
115 NSToolbarItem *item = [[notification userInfo] valueForKey:@"item"];
116 QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value(
121 [item setView:QT_PREPEND_NAMESPACE(qt_mac_nativeview_for)(tb)];
123 NSArray *items = [[qt_mac_window_for(mainWindowLayout->layoutState.mainWindow->window()) toolbar] items];
125 for (NSToolbarItem *i in items) {
130 mainWindowLayout->toolbarItemsCopy.insert(someIndex, item);
135 int toolbarIndex = mainWindowLayout->qtoolbarsInUnifiedToolbarList.indexOf(toolbar);
136 if (someIndex != toolbarIndex) {
138 mainWindowLayout->qtoolbarsInUnifiedToolbarList.clear();
139 for (
int i = 0; i < mainWindowLayout->toolbarItemsCopy.size(); ++i) {
143 mainWindowLayout->qtoolbarsInUnifiedToolbarList.append(
144 mainWindowLayout->unifiedToolbarHash.value(mainWindowLayout->
145 toolbarItemsCopy.at(i)));
153 #endif // QT_MAC_USE_COCOA #define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
#define QT_FORWARD_DECLARE_CLASS(name)
#define QT_BEGIN_NAMESPACE
This macro expands to.
#define QT_PREPEND_NAMESPACE(name)
This macro qualifies identifier with the full namespace.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...