author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdeui/kmainwindow.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kdeui/kmainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/kmainwindow.cpp | 97 |
1 files changed, 47 insertions, 50 deletions
diff --git a/microkde/kdeui/kmainwindow.cpp b/microkde/kdeui/kmainwindow.cpp index fa678f2..bac0db8 100644 --- a/microkde/kdeui/kmainwindow.cpp +++ b/microkde/kdeui/kmainwindow.cpp | |||
@@ -21,12 +21,18 @@ | |||
21 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
22 | Boston, MA 02111-1307, USA. | 22 | Boston, MA 02111-1307, USA. |
23 | */ | 23 | */ |
24 | #include <qobjectlist.h> | 24 | #include <qobject.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | #include <qtimer.h> | 26 | #include <qtimer.h> |
27 | #include <qmenubar.h> | 27 | #include <qmenubar.h> |
28 | #include <qstatusbar.h> | 28 | #include <qstatusbar.h> |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | //Added by qt3to4: | ||
31 | #include <QCloseEvent> | ||
32 | #include <QPaintEvent> | ||
33 | #include <QResizeEvent> | ||
34 | #include <QChildEvent> | ||
35 | #include <Q3PtrList> | ||
30 | 36 | ||
31 | 37 | ||
32 | #include "kdebug.h" | 38 | #include "kdebug.h" |
@@ -54,7 +60,7 @@ public: | |||
54 | static bool no_query_exit = false; | 60 | static bool no_query_exit = false; |
55 | 61 | ||
56 | KMainWindow::KMainWindow( QWidget* parent, const char *name ) | 62 | KMainWindow::KMainWindow( QWidget* parent, const char *name ) |
57 | : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/ | 63 | : Q3MainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/ |
58 | { | 64 | { |
59 | mQToolBar = 0; | 65 | mQToolBar = 0; |
60 | initKMainWindow(name); | 66 | initKMainWindow(name); |
@@ -276,7 +282,7 @@ void KMainWindow::setCaption( const QString &caption, bool modified ) | |||
276 | 282 | ||
277 | void KMainWindow::setPlainCaption( const QString &caption ) | 283 | void KMainWindow::setPlainCaption( const QString &caption ) |
278 | { | 284 | { |
279 | QMainWindow::setCaption( caption ); | 285 | Q3MainWindow::setCaption( caption ); |
280 | #ifndef Q_WS_QWS | 286 | #ifndef Q_WS_QWS |
281 | //US the following is disabled for the embedded version | 287 | //US the following is disabled for the embedded version |
282 | //US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); | 288 | //US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); |
@@ -421,10 +427,10 @@ void KMainWindow::createStandardStatusBarAction(){ | |||
421 | } | 427 | } |
422 | } | 428 | } |
423 | 429 | ||
424 | QToolBar *KMainWindow::tBar( ) | 430 | Q3ToolBar *KMainWindow::tBar( ) |
425 | { | 431 | { |
426 | if ( ! mQToolBar ) | 432 | if ( ! mQToolBar ) |
427 | mQToolBar = new QToolBar( this ); | 433 | mQToolBar = new Q3ToolBar( this ); |
428 | return mQToolBar; | 434 | return mQToolBar; |
429 | } | 435 | } |
430 | 436 | ||
@@ -443,22 +449,23 @@ KToolBar *KMainWindow::toolBar( const char * name ) | |||
443 | return new KToolBar(this, name, honor_mode); // XMLGUI constructor | 449 | return new KToolBar(this, name, honor_mode); // XMLGUI constructor |
444 | else | 450 | else |
445 | */ | 451 | */ |
446 | return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI | 452 | return new KToolBar(this, Qt::Top, false, name, honor_mode ); // non-XMLGUI |
447 | } | 453 | } |
448 | 454 | ||
449 | QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() | 455 | Q3PtrListIterator<KToolBar> KMainWindow::toolBarIterator() |
450 | { | 456 | { |
451 | toolbarList.clear(); | 457 | toolbarList.clear(); |
452 | QPtrList<QToolBar> lst; | 458 | QList<Q3ToolBar*> lst; |
453 | for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) { | 459 | for ( int i = (int)Qt::Unmanaged; i <= (int)Qt::Minimized; ++i ) { |
454 | lst = toolBars( (ToolBarDock)i ); | 460 | lst = toolBars( (Qt::ToolBarDock)i ); |
455 | for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) { | 461 | for(QList<Q3ToolBar*>::iterator i=lst.begin();i!=lst.end();++i) { |
462 | Q3ToolBar *tb = *i; | ||
456 | if ( !tb->inherits( "KToolBar" ) ) | 463 | if ( !tb->inherits( "KToolBar" ) ) |
457 | continue; | 464 | continue; |
458 | toolbarList.append( (KToolBar*)tb ); | 465 | toolbarList.append( (KToolBar*)tb ); |
459 | } | 466 | } |
460 | } | 467 | } |
461 | return QPtrListIterator<KToolBar>( toolbarList ); | 468 | return Q3PtrListIterator<KToolBar>( toolbarList ); |
462 | } | 469 | } |
463 | 470 | ||
464 | void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) | 471 | void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) |
@@ -469,7 +476,7 @@ void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindo | |||
469 | // Get notified when the user moves a toolbar around | 476 | // Get notified when the user moves a toolbar around |
470 | //US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), | 477 | //US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), |
471 | //US this, SLOT( setSettingsDirty() ) ); | 478 | //US this, SLOT( setSettingsDirty() ) ); |
472 | connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ), | 479 | connect( this, SIGNAL( toolBarPositionChanged(Q3ToolBar *) ), |
473 | this, SLOT( setSettingsDirty() ) ); | 480 | this, SLOT( setSettingsDirty() ) ); |
474 | 481 | ||
475 | 482 | ||
@@ -503,7 +510,7 @@ QString KMainWindow::autoSaveGroup() const | |||
503 | 510 | ||
504 | void KMainWindow::saveAutoSaveSettings() | 511 | void KMainWindow::saveAutoSaveSettings() |
505 | { | 512 | { |
506 | ASSERT( d->autoSaveSettings ); | 513 | Q_ASSERT( d->autoSaveSettings ); |
507 | //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; | 514 | //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; |
508 | saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); | 515 | saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); |
509 | KGlobal::config()->sync(); | 516 | KGlobal::config()->sync(); |
@@ -639,7 +646,7 @@ void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configG | |||
639 | 646 | ||
640 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 647 | int n = 1; // Toolbar counter. toolbars are counted from 1, |
641 | KToolBar *toolbar = 0; | 648 | KToolBar *toolbar = 0; |
642 | QPtrListIterator<KToolBar> it( toolBarIterator() ); | 649 | Q3PtrListIterator<KToolBar> it( toolBarIterator() ); |
643 | while ( ( toolbar = it.current() ) ) { | 650 | while ( ( toolbar = it.current() ) ) { |
644 | ++it; | 651 | ++it; |
645 | QString group; | 652 | QString group; |
@@ -714,19 +721,21 @@ void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &config | |||
714 | entryList.clear(); | 721 | entryList.clear(); |
715 | //US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); | 722 | //US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); |
716 | entryList = config->readListEntry (QString::fromLatin1("MenuBar")); | 723 | entryList = config->readListEntry (QString::fromLatin1("MenuBar")); |
717 | entry = entryList.first(); | 724 | if(!entryList.empty()) { |
718 | if (entry==QString::fromLatin1("Disabled")) | 725 | entry = entryList.first(); |
719 | { | 726 | if (entry==QString::fromLatin1("Disabled")) |
720 | mb->hide(); | 727 | { |
721 | } else | 728 | mb->hide(); |
722 | { | 729 | } else |
723 | mb->show(); | 730 | { |
724 | } | 731 | mb->show(); |
732 | } | ||
733 | } | ||
725 | } | 734 | } |
726 | 735 | ||
727 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 736 | int n = 1; // Toolbar counter. toolbars are counted from 1, |
728 | KToolBar *toolbar; | 737 | KToolBar *toolbar; |
729 | QPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator | 738 | Q3PtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator |
730 | 739 | ||
731 | for ( ; it.current(); ++it) { | 740 | for ( ; it.current(); ++it) { |
732 | toolbar= it.current(); | 741 | toolbar= it.current(); |
@@ -756,7 +765,7 @@ void KMainWindow::finalizeGUI( bool force ) | |||
756 | // we call positionYourself again for each of them, but this time | 765 | // we call positionYourself again for each of them, but this time |
757 | // the toolbariterator should give them in the proper order. | 766 | // the toolbariterator should give them in the proper order. |
758 | // Both the XMLGUI and applySettings call this, hence "force" for the latter. | 767 | // Both the XMLGUI and applySettings call this, hence "force" for the latter. |
759 | QPtrListIterator<KToolBar> it( toolBarIterator() ); | 768 | Q3PtrListIterator<KToolBar> it( toolBarIterator() ); |
760 | for ( ; it.current() ; ++ it ) | 769 | for ( ; it.current() ; ++ it ) |
761 | it.current()->positionYourself( force ); | 770 | it.current()->positionYourself( force ); |
762 | 771 | ||
@@ -851,7 +860,7 @@ void KMainWindow::resizeEvent( QResizeEvent * e) | |||
851 | { | 860 | { |
852 | if ( d->autoSaveWindowSize ) | 861 | if ( d->autoSaveWindowSize ) |
853 | setSettingsDirty(); | 862 | setSettingsDirty(); |
854 | QMainWindow::resizeEvent( e ); | 863 | Q3MainWindow::resizeEvent( e ); |
855 | } | 864 | } |
856 | 865 | ||
857 | bool KMainWindow::hasMenuBar() | 866 | bool KMainWindow::hasMenuBar() |
@@ -869,7 +878,7 @@ QMenuBar *KMainWindow::menuBar() | |||
869 | mb = new QMenuBar( this ); | 878 | mb = new QMenuBar( this ); |
870 | // trigger a re-layout and trigger a call to the private | 879 | // trigger a re-layout and trigger a call to the private |
871 | // setMenuBar method. | 880 | // setMenuBar method. |
872 | QMainWindow::menuBar(); | 881 | Q3MainWindow::menuBar(); |
873 | } | 882 | } |
874 | return mb; | 883 | return mb; |
875 | } | 884 | } |
@@ -884,7 +893,7 @@ QStatusBar *KMainWindow::statusBar() | |||
884 | sb = new QStatusBar( this ); | 893 | sb = new QStatusBar( this ); |
885 | // trigger a re-layout and trigger a call to the private | 894 | // trigger a re-layout and trigger a call to the private |
886 | // setStatusBar method. | 895 | // setStatusBar method. |
887 | QMainWindow::statusBar(); | 896 | Q3MainWindow::statusBar(); |
888 | } | 897 | } |
889 | return sb; | 898 | return sb; |
890 | } | 899 | } |
@@ -908,42 +917,30 @@ void KMainWindow::shuttingDown() | |||
908 | QMenuBar *KMainWindow::internalMenuBar() | 917 | QMenuBar *KMainWindow::internalMenuBar() |
909 | { | 918 | { |
910 | //US QObjectList *l = queryList( "KMenuBar", 0, false, false ); | 919 | //US QObjectList *l = queryList( "KMenuBar", 0, false, false ); |
911 | QObjectList *l = queryList( "QMenuBar", 0, false, false ); | 920 | QObjectList l = queryList( "QMenuBar", 0, false, false ); |
912 | if ( !l || !l->first() ) { | 921 | if(l.empty()) |
913 | delete l; | 922 | return 0; |
914 | return 0; | 923 | return (QMenuBar*)l.front(); |
915 | } | ||
916 | |||
917 | //US KMenuBar *m = (KMenuBar*)l->first(); | ||
918 | QMenuBar *m = (QMenuBar*)l->first(); | ||
919 | delete l; | ||
920 | return m; | ||
921 | } | 924 | } |
922 | 925 | ||
923 | //US KStatusBar *KMainWindow::internalStatusBar() | 926 | //US KStatusBar *KMainWindow::internalStatusBar() |
924 | QStatusBar *KMainWindow::internalStatusBar() | 927 | QStatusBar *KMainWindow::internalStatusBar() |
925 | { | 928 | { |
926 | //US QObjectList *l = queryList( "KStatusBar", 0, false, false ); | 929 | //US QObjectList *l = queryList( "KStatusBar", 0, false, false ); |
927 | QObjectList *l = queryList( "QStatusBar", 0, false, false ); | 930 | QObjectList l = queryList( "QStatusBar", 0, false, false ); |
928 | if ( !l || !l->first() ) { | 931 | if(l.empty()) |
929 | delete l; | 932 | return 0; |
930 | return 0; | 933 | return (QStatusBar*)l.front(); |
931 | } | ||
932 | |||
933 | //US KStatusBar *s = (KStatusBar*)l->first(); | ||
934 | QStatusBar *s = (QStatusBar*)l->first(); | ||
935 | delete l; | ||
936 | return s; | ||
937 | } | 934 | } |
938 | 935 | ||
939 | void KMainWindow::childEvent( QChildEvent* e) | 936 | void KMainWindow::childEvent( QChildEvent* e) |
940 | { | 937 | { |
941 | QMainWindow::childEvent( e ); | 938 | Q3MainWindow::childEvent( e ); |
942 | } | 939 | } |
943 | 940 | ||
944 | void KMainWindow::paintEvent( QPaintEvent * e) | 941 | void KMainWindow::paintEvent( QPaintEvent * e) |
945 | { | 942 | { |
946 | QMainWindow::paintEvent( e ); | 943 | Q3MainWindow::paintEvent( e ); |
947 | } | 944 | } |
948 | 945 | ||
949 | QSize KMainWindow::sizeForCentralWidgetSize(QSize size) | 946 | QSize KMainWindow::sizeForCentralWidgetSize(QSize size) |