summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kmainwindow.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdeui/kmainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kmainwindow.cpp97
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
@@ -12,30 +12,36 @@
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#include <qobjectlist.h>
+#include <qobject.h>
#include <qstringlist.h>
#include <qtimer.h>
#include <qmenubar.h>
#include <qstatusbar.h>
#include <qapplication.h>
+//Added by qt3to4:
+#include <QCloseEvent>
+#include <QPaintEvent>
+#include <QResizeEvent>
+#include <QChildEvent>
+#include <Q3PtrList>
#include "kdebug.h"
#include "kmainwindow.h"
#include "kglobalsettings.h"
#include "kactioncollection.h"
class KMainWindowPrivate {
public:
//US bool showHelpMenu:1;
bool autoSaveSettings:1;
@@ -45,25 +51,25 @@ public:
QString autoSaveGroup;
//US KAccel * kaccel;
//US KMainWindowInterface *m_interface;
KDEPrivate::ToolBarHandler *toolBarHandler;
QTimer* settingsTimer;
KToggleAction *showStatusBarAction;
QRect defaultWindowSize;
};
static bool no_query_exit = false;
KMainWindow::KMainWindow( QWidget* parent, const char *name )
- : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/
+ : Q3MainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/
{
mQToolBar = 0;
initKMainWindow(name);
}
void KMainWindow::parseGeometry(bool parsewidth)
{
//US the following code is not getting used in the embedded version !! So disable it for now
/*US
assert ( !kapp->geometryArgument().isNull() );
assert ( d->care_about_geometry );
@@ -267,25 +273,25 @@ void KMainWindow::setCaption( const QString &caption )
//US setPlainCaption( kapp->makeStdCaption(caption) );
setPlainCaption( caption );
}
void KMainWindow::setCaption( const QString &caption, bool modified )
{
//US setPlainCaption( kapp->makeStdCaption(caption, true, modified) );
setPlainCaption( caption + "modified:" );
}
void KMainWindow::setPlainCaption( const QString &caption )
{
- QMainWindow::setCaption( caption );
+ Q3MainWindow::setCaption( caption );
#ifndef Q_WS_QWS
//US the following is disabled for the embedded version
//US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 );
//US info.setName( caption.utf8().data() );
#endif
}
void KMainWindow::slotStateChanged(const QString &newstate)
{
stateChanged(newstate, KXMLGUIClient::StateNoReverse);
}
@@ -412,73 +418,74 @@ bool KMainWindow::isStandardToolBarMenuEnabled() const
return ( d->toolBarHandler != 0 );
}
void KMainWindow::createStandardStatusBarAction(){
if(!d->showStatusBarAction){
d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection());
connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool)));
if(internalStatusBar())
d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden());
}
}
-QToolBar *KMainWindow::tBar( )
+Q3ToolBar *KMainWindow::tBar( )
{
if ( ! mQToolBar )
- mQToolBar = new QToolBar( this );
+ mQToolBar = new Q3ToolBar( this );
return mQToolBar;
}
KToolBar *KMainWindow::toolBar( const char * name )
{
if (!name)
name = "mainToolBar";
KToolBar *tb = (KToolBar*)child( name, "KToolBar" );
if ( tb )
return tb;
bool honor_mode = (name == "mainToolBar");
/*US
if ( builderClient() )
return new KToolBar(this, name, honor_mode); // XMLGUI constructor
else
*/
- return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI
+ return new KToolBar(this, Qt::Top, false, name, honor_mode ); // non-XMLGUI
}
-QPtrListIterator<KToolBar> KMainWindow::toolBarIterator()
+Q3PtrListIterator<KToolBar> KMainWindow::toolBarIterator()
{
toolbarList.clear();
- QPtrList<QToolBar> lst;
- for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) {
- lst = toolBars( (ToolBarDock)i );
- for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) {
+ QList<Q3ToolBar*> lst;
+ for ( int i = (int)Qt::Unmanaged; i <= (int)Qt::Minimized; ++i ) {
+ lst = toolBars( (Qt::ToolBarDock)i );
+ for(QList<Q3ToolBar*>::iterator i=lst.begin();i!=lst.end();++i) {
+ Q3ToolBar *tb = *i;
if ( !tb->inherits( "KToolBar" ) )
continue;
toolbarList.append( (KToolBar*)tb );
}
}
- return QPtrListIterator<KToolBar>( toolbarList );
+ return Q3PtrListIterator<KToolBar>( toolbarList );
}
void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize )
{
d->autoSaveSettings = true;
d->autoSaveGroup = groupName;
d->autoSaveWindowSize = saveWindowSize;
// Get notified when the user moves a toolbar around
//US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ),
//US this, SLOT( setSettingsDirty() ) );
- connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ),
+ connect( this, SIGNAL( toolBarPositionChanged(Q3ToolBar *) ),
this, SLOT( setSettingsDirty() ) );
// Get default values
//US int scnum = QApplication::desktop()->screenNumber(parentWidget());
//US QRect desk = QApplication::desktop()->screenGeometry(scnum);
QRect desk = KGlobalSettings::desktopGeometry(0);
d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height());
// Now read the previously saved settings
applyMainWindowSettings( KGlobal::config(), groupName );
}
@@ -494,25 +501,25 @@ void KMainWindow::resetAutoSaveSettings()
bool KMainWindow::autoSaveSettings() const
{
return d->autoSaveSettings;
}
QString KMainWindow::autoSaveGroup() const
{
return d->autoSaveGroup;
}
void KMainWindow::saveAutoSaveSettings()
{
- ASSERT( d->autoSaveSettings );
+ Q_ASSERT( d->autoSaveSettings );
//kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl;
saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup );
KGlobal::config()->sync();
d->settingsDirty = false;
if ( d->settingsTimer )
d->settingsTimer->stop();
}
void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory )
{
// disabling the updates prevents unnecessary redraws
setUpdatesEnabled( false );
@@ -630,25 +637,25 @@ void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configG
entryList.append("Enabled");
// By default we don't hide.
if(mb->isHidden())
//US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';');
config->writeEntry(QString::fromLatin1("MenuBar"), entryList);
else
config->deleteEntry(QString::fromLatin1("MenuBar"));
}
int n = 1; // Toolbar counter. toolbars are counted from 1,
KToolBar *toolbar = 0;
- QPtrListIterator<KToolBar> it( toolBarIterator() );
+ Q3PtrListIterator<KToolBar> it( toolBarIterator() );
while ( ( toolbar = it.current() ) ) {
++it;
QString group;
if (!configGroup.isEmpty())
{
// Give a number to the toolbar, but prefer a name if there is one,
// because there's no real guarantee on the ordering of toolbars
group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name());
group.prepend(" Toolbar");
group.prepend(configGroup);
}
toolbar->saveSettings(config, group);
@@ -705,37 +712,39 @@ void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &config
sb->hide();
else
sb->show();
if(d->showStatusBarAction)
d->showStatusBarAction->setChecked(!sb->isHidden());
}
QMenuBar* mb = internalMenuBar();
if (mb) {
entryList.clear();
//US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';');
entryList = config->readListEntry (QString::fromLatin1("MenuBar"));
- entry = entryList.first();
- if (entry==QString::fromLatin1("Disabled"))
- {
- mb->hide();
- } else
- {
- mb->show();
- }
+ if(!entryList.empty()) {
+ entry = entryList.first();
+ if (entry==QString::fromLatin1("Disabled"))
+ {
+ mb->hide();
+ } else
+ {
+ mb->show();
+ }
+ }
}
int n = 1; // Toolbar counter. toolbars are counted from 1,
KToolBar *toolbar;
- QPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator
+ Q3PtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator
for ( ; it.current(); ++it) {
toolbar= it.current();
QString group;
if (!configGroup.isEmpty())
{
// Give a number to the toolbar, but prefer a name if there is one,
// because there's no real guarantee on the ordering of toolbars
group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name());
group.prepend(" Toolbar");
group.prepend(configGroup);
}
@@ -747,25 +756,25 @@ void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &config
}
void KMainWindow::finalizeGUI( bool force )
{
//kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl;
// The whole reason for this is that moveToolBar relies on the indexes
// of the other toolbars, so in theory it should be called only once per
// toolbar, but in increasing order of indexes.
// Since we can't do that immediately, we move them, and _then_
// we call positionYourself again for each of them, but this time
// the toolbariterator should give them in the proper order.
// Both the XMLGUI and applySettings call this, hence "force" for the latter.
- QPtrListIterator<KToolBar> it( toolBarIterator() );
+ Q3PtrListIterator<KToolBar> it( toolBarIterator() );
for ( ; it.current() ; ++ it )
it.current()->positionYourself( force );
d->settingsDirty = false;
}
void KMainWindow::saveWindowSize( KConfig * config ) const
{
/*US
int scnum = QApplication::desktop()->screenNumber(parentWidget());
QRect desk = QApplication::desktop()->screenGeometry(scnum);
*/
@@ -842,117 +851,105 @@ bool KMainWindow::settingsDirty() const
return d->settingsDirty;
}
QString KMainWindow::settingsGroup() const
{
return d->autoSaveGroup;
}
void KMainWindow::resizeEvent( QResizeEvent * e)
{
if ( d->autoSaveWindowSize )
setSettingsDirty();
- QMainWindow::resizeEvent( e );
+ Q3MainWindow::resizeEvent( e );
}
bool KMainWindow::hasMenuBar()
{
return (internalMenuBar());
}
//US KMenuBar *KMainWindow::menuBar()
QMenuBar *KMainWindow::menuBar()
{
//US KMenuBar * mb = internalMenuBar();
QMenuBar * mb = internalMenuBar();
if ( !mb ) {
//US mb = new KMenuBar( this );
mb = new QMenuBar( this );
// trigger a re-layout and trigger a call to the private
// setMenuBar method.
- QMainWindow::menuBar();
+ Q3MainWindow::menuBar();
}
return mb;
}
//US KStatusBar *KMainWindow::statusBar()
QStatusBar *KMainWindow::statusBar()
{
//US KStatusBar * sb = internalStatusBar();
QStatusBar * sb = internalStatusBar();
if ( !sb ) {
//US sb = new KStatusBar( this );
sb = new QStatusBar( this );
// trigger a re-layout and trigger a call to the private
// setStatusBar method.
- QMainWindow::statusBar();
+ Q3MainWindow::statusBar();
}
return sb;
}
void KMainWindow::shuttingDown()
{
// Needed for Qt <= 3.0.3 at least to prevent reentrancy
// when queryExit() shows a dialog. Check before removing!
static bool reentrancy_protection = false;
if (!reentrancy_protection)
{
reentrancy_protection = true;
// call the virtual queryExit
queryExit();
reentrancy_protection = false;
}
}
//US KMenuBar *KMainWindow::internalMenuBar()
QMenuBar *KMainWindow::internalMenuBar()
{
//US QObjectList *l = queryList( "KMenuBar", 0, false, false );
- QObjectList *l = queryList( "QMenuBar", 0, false, false );
- if ( !l || !l->first() ) {
- delete l;
- return 0;
- }
-
-//US KMenuBar *m = (KMenuBar*)l->first();
- QMenuBar *m = (QMenuBar*)l->first();
- delete l;
- return m;
+ QObjectList l = queryList( "QMenuBar", 0, false, false );
+ if(l.empty())
+ return 0;
+ return (QMenuBar*)l.front();
}
//US KStatusBar *KMainWindow::internalStatusBar()
QStatusBar *KMainWindow::internalStatusBar()
{
//US QObjectList *l = queryList( "KStatusBar", 0, false, false );
- QObjectList *l = queryList( "QStatusBar", 0, false, false );
- if ( !l || !l->first() ) {
- delete l;
- return 0;
- }
-
-//US KStatusBar *s = (KStatusBar*)l->first();
- QStatusBar *s = (QStatusBar*)l->first();
- delete l;
- return s;
+ QObjectList l = queryList( "QStatusBar", 0, false, false );
+ if(l.empty())
+ return 0;
+ return (QStatusBar*)l.front();
}
void KMainWindow::childEvent( QChildEvent* e)
{
- QMainWindow::childEvent( e );
+ Q3MainWindow::childEvent( e );
}
void KMainWindow::paintEvent( QPaintEvent * e)
{
- QMainWindow::paintEvent( e );
+ Q3MainWindow::paintEvent( e );
}
QSize KMainWindow::sizeForCentralWidgetSize(QSize size)
{
KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" );
if (tb && !tb->isHidden()) {
switch( tb->barPos() )
{
case KToolBar::Top:
case KToolBar::Bottom:
size += QSize(0, tb->sizeHint().height());
break;