Commit ea16284a authored by David Faure's avatar David Faure
Browse files

Fix wrong order of sidebar and iconview, when starting up in filemanagement...

Fix wrong order of sidebar and iconview, when starting up in filemanagement mode, due to wrong idAfter() replacement during porting.

svn path=/trunk/KDE/kdebase/konqueror/; revision=599270
parent 6b5288d9
......@@ -215,4 +215,12 @@ void KonqFrameContainer::childEvent( QChildEvent *c )
QSplitter::childEvent(c);
}
bool KonqFrameContainer::hasWidgetAfter( QWidget* w ) const
{
int idx = QSplitter::indexOf( w );
if ( idx == -1 ) // not found
return 0; // not found (in qt3)
return QSplitter::widget( idx + 1 ) != 0;
}
#include "konq_framecontainer.moc"
......@@ -111,8 +111,7 @@ public:
virtual void reparentFrame(QWidget * parent,
const QPoint & p );
//make this one public
int idAfter( QWidget* w ){ return QSplitter::indexOf( w ) + 1; }
bool hasWidgetAfter( QWidget* w ) const;
void setAboutToBeDeleted() { m_bAboutToBeDeleted = true; }
......
......@@ -61,7 +61,7 @@ KonqViewManager::KonqViewManager( KonqMainWindow *mainWindow )
KonqView* KonqViewManager::Initialize( const QString &serviceType, const QString &serviceName )
{
//kDebug(1202) << "KonqViewManager::Initialize()" << endl;
//kDebug(1202) << "KonqViewManager::Initialize() " << serviceName << endl;
KService::Ptr service;
KService::List partServiceOffers, appServiceOffers;
KonqViewFactory newViewFactory = createView( serviceType, serviceName, service, partServiceOffers, appServiceOffers, true /*forceAutoEmbed*/ );
......@@ -120,7 +120,7 @@ KonqView* KonqViewManager::splitView ( Qt::Orientation orientation,
int index= -1;
if (parentContainer->frameType()=="Container") {
moveNewContainer = (static_cast<KonqFrameContainer*>(parentContainer)->idAfter( splitFrame->asQWidget() ) != 0);
moveNewContainer = static_cast<KonqFrameContainer*>(parentContainer)->hasWidgetAfter( splitFrame->asQWidget() );
splitterSizes = static_cast<KonqFrameContainer*>(parentContainer)->sizes();
}
else if (parentContainer->frameType()=="Tabs")
......@@ -278,7 +278,7 @@ void KonqViewManager::convertDocContainer()
bool moveNewContainer = false;
QList<int> splitterSizes;
if (parentContainer->frameType()=="Container") {
moveNewContainer = (static_cast<KonqFrameContainer*>(parentContainer)->idAfter( m_pDocContainer->asQWidget() ) != 0);
moveNewContainer = static_cast<KonqFrameContainer*>(parentContainer)->hasWidgetAfter( m_pDocContainer->asQWidget() );
splitterSizes = static_cast<KonqFrameContainer*>(parentContainer)->sizes();
}
......@@ -302,8 +302,10 @@ void KonqViewManager::convertDocContainer()
static_cast<KonqFrameContainer*>(parentContainer)->insertWidget( 0, newContainer );
static_cast<KonqFrameContainer*>(parentContainer)->swapChildren();
}
if (parentContainer->frameType()=="Container")
if (parentContainer->frameType()=="Container") {
kDebug() << k_funcinfo << "convertDocContainer: setting sizes " << splitterSizes << endl;
static_cast<KonqFrameContainer*>(parentContainer)->setSizes( splitterSizes );
}
newContainer->show();
......@@ -765,7 +767,7 @@ void KonqViewManager::removeView( KonqView *view )
index = static_cast<KonqFrameTabs*>(grandParentContainer)->indexOf( parentContainer->asQWidget() );
else if (grandParentContainer->frameType()=="Container")
{
moveOtherChild = (static_cast<KonqFrameContainer*>(grandParentContainer)->idAfter( parentContainer->asQWidget() ) != 0);
moveOtherChild = static_cast<KonqFrameContainer*>(grandParentContainer)->hasWidgetAfter( parentContainer->asQWidget() );
splitterSizes = static_cast<KonqFrameContainer*>(grandParentContainer)->sizes();
}
......@@ -983,7 +985,7 @@ KonqViewFactory KonqViewManager::createView( const QString &serviceType,
KService::List &appServiceOffers,
bool forceAutoEmbed )
{
kDebug(1202) << "KonqViewManager::createView" << endl;
kDebug(1202) << "KonqViewManager::createView " << serviceName << endl;
KonqViewFactory viewFactory;
if( serviceType.isEmpty() && m_pMainWindow->currentView() ) {
......@@ -1446,7 +1448,7 @@ void KonqViewManager::loadItem( KConfig &cfg, KonqFrameContainerBase *parent,
if( name != "InitialView" )
prefix = name + QLatin1Char( '_' );
//kDebug(1202) << "KonqViewManager::loadItem: begin name " << name << " openUrl " << openURL << endl;
//kDebug(1202) << "KonqViewManager::loadItem: begin name " << name << " openUrl " << openUrl << endl;
if( name.startsWith("View") || name == "empty" ) {
//load view config
......@@ -1461,7 +1463,7 @@ void KonqViewManager::loadItem( KConfig &cfg, KonqFrameContainerBase *parent,
serviceType = cfg.readEntry( QString::fromLatin1( "ServiceType" ).prepend( prefix ), QString("inode/directory"));
serviceName = cfg.readEntry( QString::fromLatin1( "ServiceName" ).prepend( prefix ), QString() );
}
//kDebug(1202) << "KonqViewManager::loadItem: ServiceType " << serviceType << " " << serviceName << endl;
kDebug(1202) << "KonqViewManager::loadItem: ServiceType " << serviceType << " " << serviceName << endl;
KService::Ptr service;
KService::List partServiceOffers, appServiceOffers;
......@@ -1607,6 +1609,7 @@ void KonqViewManager::loadItem( KConfig &cfg, KonqFrameContainerBase *parent,
loadItem( cfg, newContainer, childList.at(0), defaultURL, openUrl );
loadItem( cfg, newContainer, childList.at(1), defaultURL, openUrl );
//kDebug(1202) << "loadItem: setSizes " << sizes << endl;
newContainer->setSizes( sizes );
if (index == 1)
......
......@@ -21,8 +21,9 @@
#include <QApplication>
#include <QLabel>
#include <QTimer>
#include <QSplitter>
MyMainWindow::MyMainWindow( QWidget* parent )
SCWMainWindow::SCWMainWindow( QWidget* parent )
: QMainWindow( parent )
{
QLabel* widget1 = new QLabel( "widget1" );
......@@ -30,19 +31,40 @@ MyMainWindow::MyMainWindow( QWidget* parent )
QTimer::singleShot( 10, this, SLOT( slotSwitchCentralWidget() ) );
}
void MyMainWindow::slotSwitchCentralWidget()
void SCWMainWindow::slotSwitchCentralWidget()
{
QLabel* widget2 = new QLabel( "widget2" );
delete centralWidget(); // ## workaround for the crash
setCentralWidget( widget2 );
}
void testSplitterChildren()
{
// OK, it works; the bug was a wrong insertWidget(0,label2) in konqviewmgr.
QSplitter* container = new QSplitter( 0 );
QLabel* label0 = new QLabel( "Label0, sidebar, should be on left", container );
label0->show();
QLabel* label1 = new QLabel( "Label1, iconview, should be on the right", container );
label1->show();
label1->setParent( 0 ); // should be some toplevel, rather, see convertDocContainer
label1->hide();
QLabel* label2 = new QLabel( "Label2, tabwidget, should be on the right", container );
label2->show();
container->show();
}
int main( int argc, char** argv ) {
QApplication app( argc, argv );
MyMainWindow* mw = new MyMainWindow;
//SCWMainWindow* mw = new SCWMainWindow;
//mw->show();
mw->show();
testSplitterChildren();
return app.exec();
}
......
......@@ -21,11 +21,12 @@
#include <QMainWindow>
class MyMainWindow : public QMainWindow
// SCW == Switch (or Set) Central Widget
class SCWMainWindow : public QMainWindow
{
Q_OBJECT
public:
MyMainWindow( QWidget* parent = 0 );
SCWMainWindow( QWidget* parent = 0 );
private slots:
void slotSwitchCentralWidget();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment