summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/ktoolbarhandler.cpp
Unidiff
Diffstat (limited to 'microkde/kdeui/ktoolbarhandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/ktoolbarhandler.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/microkde/kdeui/ktoolbarhandler.cpp b/microkde/kdeui/ktoolbarhandler.cpp
index 7b97233..4d3ace7 100644
--- a/microkde/kdeui/ktoolbarhandler.cpp
+++ b/microkde/kdeui/ktoolbarhandler.cpp
@@ -9,25 +9,27 @@
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19#include "ktoolbarhandler.h" 19#include "ktoolbarhandler.h"
20 20
21#include <qpopupmenu.h> 21#include <q3popupmenu.h>
22//Added by qt3to4:
23#include <Q3PtrList>
22#include <kapplication.h> 24#include <kapplication.h>
23#include <ktoolbar.h> 25#include <ktoolbar.h>
24#include <kmainwindow.h> 26#include <kmainwindow.h>
25#include <klocale.h> 27#include <klocale.h>
26#include <kaction.h> 28#include <kaction.h>
27#include <assert.h> 29#include <assert.h>
28 30
29namespace 31namespace
30{ 32{
31 const char *actionListName = "show_menu_and_toolbar_actionlist"; 33 const char *actionListName = "show_menu_and_toolbar_actionlist";
32 34
33 const char *guiDescription = "" 35 const char *guiDescription = ""
@@ -35,25 +37,25 @@ namespace
35 "<MenuBar>" 37 "<MenuBar>"
36 " <Menu name=\"settings\">" 38 " <Menu name=\"settings\">"
37 " <ActionList name=\"%1\" />" 39 " <ActionList name=\"%1\" />"
38 " </Menu>" 40 " </Menu>"
39 "</MenuBar>" 41 "</MenuBar>"
40 "</kpartgui>"; 42 "</kpartgui>";
41 43
42 const char *resourceFileName = "barhandler.rc"; 44 const char *resourceFileName = "barhandler.rc";
43 45
44 class BarActionBuilder 46 class BarActionBuilder
45 { 47 {
46 public: 48 public:
47 BarActionBuilder( KActionCollection *actionCollection, KMainWindow *mainWindow, QPtrList<KToolBar> &oldToolBarList ) 49 BarActionBuilder( KActionCollection *actionCollection, KMainWindow *mainWindow, Q3PtrList<KToolBar> &oldToolBarList )
48 : m_actionCollection( actionCollection ), m_mainWindow( mainWindow ), m_needsRebuild( false ) 50 : m_actionCollection( actionCollection ), m_mainWindow( mainWindow ), m_needsRebuild( false )
49 { 51 {
50/*US 52/*US
51 QPtrList<QDockWindow> dockWindows = m_mainWindow->dockWindows(); 53 QPtrList<QDockWindow> dockWindows = m_mainWindow->dockWindows();
52 QPtrListIterator<QDockWindow> dockWindowIt( dockWindows ); 54 QPtrListIterator<QDockWindow> dockWindowIt( dockWindows );
53 for ( ; dockWindowIt.current(); ++dockWindowIt ) { 55 for ( ; dockWindowIt.current(); ++dockWindowIt ) {
54 56
55//US KToolBar *toolBar = dynamic_cast<KToolBar *>( dockWindowIt.current() ); 57//US KToolBar *toolBar = dynamic_cast<KToolBar *>( dockWindowIt.current() );
56 KToolBar *toolBar = (KToolBar *)( dockWindowIt.current() ); 58 KToolBar *toolBar = (KToolBar *)( dockWindowIt.current() );
57 if ( !toolBar ) 59 if ( !toolBar )
58 continue; 60 continue;
59 61
@@ -61,71 +63,71 @@ namespace
61 m_needsRebuild = true; 63 m_needsRebuild = true;
62 64
63 m_toolBars.append( toolBar ); 65 m_toolBars.append( toolBar );
64 } 66 }
65*/ 67*/
66 if ( !m_needsRebuild ) 68 if ( !m_needsRebuild )
67 m_needsRebuild = ( oldToolBarList.count() != m_toolBars.count() ); 69 m_needsRebuild = ( oldToolBarList.count() != m_toolBars.count() );
68 70
69 } 71 }
70 72
71 bool needsRebuild() const { return m_needsRebuild; } 73 bool needsRebuild() const { return m_needsRebuild; }
72 74
73 QPtrList<KAction> create() 75 Q3PtrList<KAction> create()
74 { 76 {
75 if ( !m_needsRebuild ) 77 if ( !m_needsRebuild )
76 return QPtrList<KAction>(); 78 return Q3PtrList<KAction>();
77 79
78 QPtrListIterator<KToolBar> toolBarIt( m_toolBars ); 80 Q3PtrListIterator<KToolBar> toolBarIt( m_toolBars );
79 for ( ; toolBarIt.current(); ++toolBarIt ) 81 for ( ; toolBarIt.current(); ++toolBarIt )
80 handleToolBar( toolBarIt.current() ); 82 handleToolBar( toolBarIt.current() );
81 83
82 QPtrList<KAction> actions; 84 Q3PtrList<KAction> actions;
83 85
84 if ( m_toolBarActions.count() == 0 ) 86 if ( m_toolBarActions.count() == 0 )
85 return actions; 87 return actions;
86 88
87 if ( m_toolBarActions.count() == 1 ) { 89 if ( m_toolBarActions.count() == 1 ) {
88 m_toolBarActions.getFirst()->setText( i18n( "Show Toolbar" ) ); 90 m_toolBarActions.getFirst()->setText( i18n( "Show Toolbar" ) );
89 return m_toolBarActions; 91 return m_toolBarActions;
90 } 92 }
91 93
92 KActionMenu *menuAction = new KActionMenu( i18n( "Toolbars" ), m_actionCollection, "toolbars_submenu_action" ); 94 KActionMenu *menuAction = new KActionMenu( i18n( "Toolbars" ), m_actionCollection, "toolbars_submenu_action" );
93 95
94 QPtrListIterator<KAction> actionIt( m_toolBarActions ); 96 Q3PtrListIterator<KAction> actionIt( m_toolBarActions );
95 for ( ; actionIt.current(); ++actionIt ) 97 for ( ; actionIt.current(); ++actionIt )
96 menuAction->insert( actionIt.current() ); 98 menuAction->insert( actionIt.current() );
97 99
98 actions.append( menuAction ); 100 actions.append( menuAction );
99 return actions; 101 return actions;
100 } 102 }
101 103
102 const QPtrList<KToolBar> &toolBars() const { return m_toolBars; } 104 const Q3PtrList<KToolBar> &toolBars() const { return m_toolBars; }
103 105
104 private: 106 private:
105 void handleToolBar( KToolBar *toolBar ) 107 void handleToolBar( KToolBar *toolBar )
106 { 108 {
107 KAction *action = new KToggleToolBarAction( toolBar, 109 KAction *action = new KToggleToolBarAction( toolBar,
108 i18n( "Show %1" ).arg( toolBar->label() ), 110 i18n( "Show %1" ).arg( toolBar->label() ),
109 m_actionCollection, 111 m_actionCollection,
110 toolBar->name() ); 112 toolBar->name() );
111 113
112 m_toolBarActions.append( action ); 114 m_toolBarActions.append( action );
113 } 115 }
114 116
115 KActionCollection *m_actionCollection; 117 KActionCollection *m_actionCollection;
116 KMainWindow *m_mainWindow; 118 KMainWindow *m_mainWindow;
117 119
118 QPtrList<KToolBar> m_toolBars; 120 Q3PtrList<KToolBar> m_toolBars;
119 QPtrList<KAction> m_toolBarActions; 121 Q3PtrList<KAction> m_toolBarActions;
120 122
121 bool m_needsRebuild : 1; 123 bool m_needsRebuild : 1;
122 }; 124 };
123} 125}
124 126
125using namespace KDEPrivate; 127using namespace KDEPrivate;
126 128
127ToolBarHandler::ToolBarHandler( KMainWindow *mainWindow, const char *name ) 129ToolBarHandler::ToolBarHandler( KMainWindow *mainWindow, const char *name )
128 : QObject( mainWindow, name ), KXMLGUIClient( mainWindow ) 130 : QObject( mainWindow, name ), KXMLGUIClient( mainWindow )
129{ 131{
130 init( mainWindow ); 132 init( mainWindow );
131} 133}
@@ -215,39 +217,39 @@ void ToolBarHandler::init( KMainWindow *mainWindow )
215 if ( domDocument().documentElement().isNull() ) { 217 if ( domDocument().documentElement().isNull() ) {
216 218
217 QString completeDescription = QString::fromLatin1( guiDescription ) 219 QString completeDescription = QString::fromLatin1( guiDescription )
218 .arg( actionListName ); 220 .arg( actionListName );
219 221
220 setXML( completeDescription, false*/ /*merge*/ /*); 222 setXML( completeDescription, false*/ /*merge*/ /*);
221 } 223 }
222*/ 224*/
223} 225}
224 226
225void ToolBarHandler::connectToActionContainers() 227void ToolBarHandler::connectToActionContainers()
226{ 228{
227 QPtrListIterator<KAction> actionIt( m_actions ); 229 Q3PtrListIterator<KAction> actionIt( m_actions );
228 for ( ; actionIt.current(); ++actionIt ) 230 for ( ; actionIt.current(); ++actionIt )
229 connectToActionContainer( actionIt.current() ); 231 connectToActionContainer( actionIt.current() );
230} 232}
231 233
232void ToolBarHandler::connectToActionContainer( KAction *action ) 234void ToolBarHandler::connectToActionContainer( KAction *action )
233{ 235{
234 uint containerCount = action->containerCount(); 236 uint containerCount = action->containerCount();
235 for ( uint i = 0; i < containerCount; ++i ) 237 for ( uint i = 0; i < containerCount; ++i )
236 connectToActionContainer( action->container( i ) ); 238 connectToActionContainer( action->container( i ) );
237} 239}
238 240
239void ToolBarHandler::connectToActionContainer( QWidget *container ) 241void ToolBarHandler::connectToActionContainer( QWidget *container )
240{ 242{
241//US QPopupMenu *popupMenu = dynamic_cast<QPopupMenu *>( container ); 243//US QPopupMenu *popupMenu = dynamic_cast<QPopupMenu *>( container );
242 QPopupMenu *popupMenu = (QPopupMenu *)( container ); 244 Q3PopupMenu *popupMenu = (Q3PopupMenu *)( container );
243 if ( !popupMenu ) 245 if ( !popupMenu )
244 return; 246 return;
245 247
246 connect( popupMenu, SIGNAL( aboutToShow() ), 248 connect( popupMenu, SIGNAL( aboutToShow() ),
247 this, SLOT( setupActions() ) ); 249 this, SLOT( setupActions() ) );
248} 250}
249 251
250//US #include "ktoolbarhandler.moc" 252//US #include "ktoolbarhandler.moc"
251 253
252/* vim: et sw=4 ts=4 254/* vim: et sw=4 ts=4
253 */ 255 */