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

Split KonqFrameContainer out of konq_frame, added test for Qt bug.

svn path=/trunk/KDE/kdebase/konqueror/; revision=539722
parent 0cd6edee
......@@ -20,8 +20,9 @@ add_subdirectory( remoteencodingplugin )
add_subdirectory( kttsplugin )
add_subdirectory( dirpart )
add_subdirectory( settings )
include_directories( ${CMAKE_SOURCE_DIR}/libkonq ${CMAKE_SOURCE_DIR}/workspace/kcontrol/input ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES} )
add_subdirectory( tests )
include_directories( ${CMAKE_SOURCE_DIR}/libkonq ${CMAKE_SOURCE_DIR}/workspace/kcontrol/input ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES} )
########### next target ###############
......@@ -36,6 +37,7 @@ set(konqueror_KDEINIT_SRCS ${libkonqueror_intern_SRCS}
konq_viewmgr.cc
konq_misc.cc
konq_frame.cc
konq_framecontainer.cc
konq_tabs.cc
konq_actions.cc
konq_profiledlg.cc
......@@ -59,8 +61,6 @@ install_targets(${LIB_INSTALL_DIR} kdeinit_konqueror )
target_link_libraries( konqueror kdeinit_konqueror )
install(TARGETS konqueror DESTINATION bin)
########### next target ###############
########### install files ###############
......
......@@ -37,6 +37,7 @@
#include <kauthorized.h>
#include <algorithm>
#include <QHBoxLayout>
template class QList<KonqHistoryEntry*>;
......
......@@ -16,7 +16,20 @@
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <math.h>
#include "konq_events.h"
#include "konq_frame.h"
#include "konq_tabs.h"
#include "konq_view.h"
#include "konq_viewmgr.h"
#include <konq_pixmapprovider.h>
#include <kactioncollection.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <klocale.h>
#include <ksqueezedtextlabel.h>
#include <kstdaccel.h>
#include <qpainter.h>
#include <QLayout>
......@@ -36,25 +49,8 @@
#include <QVBoxLayout>
#include <QMouseEvent>
#include <kactioncollection.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kglobalsettings.h>
#include <kiconloader.h>
#include <klocale.h>
#include <ksqueezedtextlabel.h>
#include "konq_events.h"
#include "konq_frame.h"
#include "konq_tabs.h"
#include "konq_view.h"
#include "konq_viewmgr.h"
#include <konq_pixmapprovider.h>
#include <kstdaccel.h>
#include <assert.h>
#define DEFAULT_HEADER_HEIGHT 13
void KonqCheckBox::drawButton( QPainter *p )
......@@ -491,199 +487,4 @@ KonqView* KonqFrame::activeChildView()
return m_pView;
}
//###################################################################
void KonqFrameContainerBase::printFrameInfo(const QString& spaces)
{
kDebug(1202) << spaces << "KonqFrameContainerBase " << this << ", this shouldn't happen!" << endl;
}
//###################################################################
KonqFrameContainer::KonqFrameContainer( Qt::Orientation o,
QWidget* parent,
KonqFrameContainerBase* parentContainer )
: QSplitter( o, parent ), m_bAboutToBeDeleted(false)
{
m_pParentContainer = parentContainer;
m_pFirstChild = 0L;
m_pSecondChild = 0L;
m_pActiveChild = 0L;
setOpaqueResize( KGlobalSettings::opaqueResize() );
connect(this, SIGNAL(splitterMoved(int, int)), this, SIGNAL(setRubberbandCalled()));
//### CHECKME
}
KonqFrameContainer::~KonqFrameContainer()
{
//kDebug(1202) << "KonqFrameContainer::~KonqFrameContainer() " << this << " - " << className() << endl;
delete m_pFirstChild;
delete m_pSecondChild;
}
void KonqFrameContainer::listViews( ChildViewList *viewList )
{
if( m_pFirstChild )
m_pFirstChild->listViews( viewList );
if( m_pSecondChild )
m_pSecondChild->listViews( viewList );
}
void KonqFrameContainer::saveConfig( KConfig* config, const QString &prefix, bool saveURLs, KonqFrameBase* docContainer, int id, int depth )
{
int idSecond = id + (int)pow( 2.0, depth );
//write children sizes
config->writeEntry( QString::fromLatin1( "SplitterSizes" ).prepend( prefix ), sizes() );
//write children
QStringList strlst;
if( firstChild() )
strlst.append( QString::fromLatin1( firstChild()->frameType() ) + QString::number(idSecond - 1) );
if( secondChild() )
strlst.append( QString::fromLatin1( secondChild()->frameType() ) + QString::number( idSecond ) );
config->writeEntry( QString::fromLatin1( "Children" ).prepend( prefix ), strlst );
//write orientation
QString o;
if( orientation() == Qt::Horizontal )
o = QString::fromLatin1("Horizontal");
else if( orientation() == Qt::Vertical )
o = QString::fromLatin1("Vertical");
config->writeEntry( QString::fromLatin1( "Orientation" ).prepend( prefix ), o );
//write docContainer
if (this == docContainer) config->writeEntry( QString::fromLatin1( "docContainer" ).prepend( prefix ), true );
if (m_pSecondChild == m_pActiveChild) config->writeEntry( QString::fromLatin1( "activeChildIndex" ).prepend( prefix ), 1 );
else config->writeEntry( QString::fromLatin1( "activeChildIndex" ).prepend( prefix ), 0 );
//write child configs
if( firstChild() ) {
QString newPrefix = QString::fromLatin1( firstChild()->frameType() ) + QString::number(idSecond - 1);
newPrefix.append( QLatin1Char( '_' ) );
firstChild()->saveConfig( config, newPrefix, saveURLs, docContainer, id, depth + 1 );
}
if( secondChild() ) {
QString newPrefix = QString::fromLatin1( secondChild()->frameType() ) + QString::number( idSecond );
newPrefix.append( QLatin1Char( '_' ) );
secondChild()->saveConfig( config, newPrefix, saveURLs, docContainer, idSecond, depth + 1 );
}
}
void KonqFrameContainer::copyHistory( KonqFrameBase *other )
{
assert( other->frameType() == "Container" );
if ( firstChild() )
firstChild()->copyHistory( static_cast<KonqFrameContainer *>( other )->firstChild() );
if ( secondChild() )
secondChild()->copyHistory( static_cast<KonqFrameContainer *>( other )->secondChild() );
}
KonqFrameBase* KonqFrameContainer::otherChild( KonqFrameBase* child )
{
if( firstChild() == child )
return secondChild();
else if( secondChild() == child )
return firstChild();
return 0L;
}
void KonqFrameContainer::printFrameInfo( const QString& spaces )
{
kDebug(1202) << spaces << "KonqFrameContainer " << this << " visible=" << QString("%1").arg(isVisible())
<< " activeChild=" << m_pActiveChild << endl;
if (!m_pActiveChild)
kDebug(1202) << "WARNING: " << this << " has a null active child!" << endl;
KonqFrameBase* child = firstChild();
if (child != 0L)
child->printFrameInfo(spaces + " ");
else
kDebug(1202) << spaces << " Null child" << endl;
child = secondChild();
if (child != 0L)
child->printFrameInfo(spaces + " ");
else
kDebug(1202) << spaces << " Null child" << endl;
}
void KonqFrameContainer::reparentFrame( QWidget* parent, const QPoint & p )
{
setParent( parent );
move( p );
}
void KonqFrameContainer::swapChildren()
{
KonqFrameBase *firstCh = m_pFirstChild;
m_pFirstChild = m_pSecondChild;
m_pSecondChild = firstCh;
}
void KonqFrameContainer::setTitle( const QString &title , QWidget* sender)
{
//kDebug(1202) << "KonqFrameContainer::setTitle( " << title << " , " << sender << " )" << endl;
if (m_pParentContainer && activeChild() && (sender == activeChild()->widget()))
m_pParentContainer->setTitle( title , this);
}
void KonqFrameContainer::setTabIcon( const KUrl &url, QWidget* sender )
{
//kDebug(1202) << "KonqFrameContainer::setTabIcon( " << url << " , " << sender << " )" << endl;
if (m_pParentContainer && activeChild() && (sender == activeChild()->widget()))
m_pParentContainer->setTabIcon( url, this );
}
void KonqFrameContainer::insertChildFrame( KonqFrameBase* frame, int /*index*/ )
{
//kDebug(1202) << "KonqFrameContainer " << this << ": insertChildFrame " << frame << endl;
if (frame)
{
if( !m_pFirstChild )
{
m_pFirstChild = frame;
frame->setParentContainer(this);
//kDebug(1202) << "Setting as first child" << endl;
}
else if( !m_pSecondChild )
{
m_pSecondChild = frame;
frame->setParentContainer(this);
//kDebug(1202) << "Setting as second child" << endl;
}
else
kWarning(1202) << this << " already has two children..."
<< m_pFirstChild << " and " << m_pSecondChild << endl;
} else
kWarning(1202) << "KonqFrameContainer " << this << ": insertChildFrame(0L) !" << endl;
}
void KonqFrameContainer::removeChildFrame( KonqFrameBase * frame )
{
//kDebug(1202) << "KonqFrameContainer::RemoveChildFrame " << this << ". Child " << frame << " removed" << endl;
if( m_pFirstChild == frame )
{
m_pFirstChild = m_pSecondChild;
m_pSecondChild = 0L;
}
else if( m_pSecondChild == frame )
m_pSecondChild = 0L;
else
kWarning(1202) << this << " Can't find this child:" << frame << endl;
}
void KonqFrameContainer::childEvent( QChildEvent *c )
{
// Child events cause layout changes. These are unnecassery if we are going
// to be deleted anyway.
if (!m_bAboutToBeDeleted)
QSplitter::childEvent(c);
}
#include "konq_frame.moc"
......@@ -24,17 +24,13 @@
#include <qpointer.h>
#include <QColor>
#include <QWidget>
#include <qsplitter.h>
#include <QCheckBox>
#include <QLabel>
//Added by qt3to4:
#include <QPixmap>
#include <QPaintEvent>
#include <QChildEvent>
#include <QList>
#include <QEvent>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QResizeEvent>
#include <QMouseEvent>
......@@ -306,111 +302,4 @@ protected:
QString m_title;
};
class KonqFrameContainerBase : public KonqFrameBase
{
public:
virtual ~KonqFrameContainerBase() {}
/**
* Call this after inserting a new frame into the splitter.
*/
virtual void insertChildFrame( KonqFrameBase * frame, int index = -1 ) = 0;
/**
* Call this before deleting one of our children.
*/
virtual void removeChildFrame( KonqFrameBase * frame ) = 0;
//inherited
virtual void printFrameInfo( const QString& spaces );
virtual QByteArray frameType() { return QByteArray("ContainerBase"); }
virtual void reparentFrame(QWidget * parent,
const QPoint & p ) = 0;
virtual KonqFrameBase* activeChild() { return m_pActiveChild; }
virtual void setActiveChild( KonqFrameBase* activeChild ) { m_pActiveChild = activeChild;
m_pParentContainer->setActiveChild( this ); }
virtual void activateChild() { if (m_pActiveChild) m_pActiveChild->activateChild(); }
virtual KonqView* activeChildView() { if (m_pActiveChild) return m_pActiveChild->activeChildView();
else return 0L; }
protected:
KonqFrameContainerBase() {}
KonqFrameBase* m_pActiveChild;
};
/**
* With KonqFrameContainers and @refKonqFrames we can create a flexible
* storage structure for the views. The top most element is a
* KonqFrameContainer. It's a direct child of the MainView. We can then
* build up a binary tree of containers. KonqFrameContainers are the nodes.
* That means that they always have two childs. Which are either again
* KonqFrameContainers or, as leaves, KonqFrames.
*/
class KonqFrameContainer : public QSplitter, public KonqFrameContainerBase
{
Q_OBJECT
friend class KonqFrame; //for emitting ctrlTabPressed() only, aleXXX
public:
KonqFrameContainer( Qt::Orientation o,
QWidget* parent,
KonqFrameContainerBase* parentContainer );
virtual ~KonqFrameContainer();
virtual void listViews( ChildViewList *viewList );
virtual void saveConfig( KConfig* config, const QString &prefix, bool saveURLs, KonqFrameBase* docContainer, int id = 0, int depth = 0 );
virtual void copyHistory( KonqFrameBase *other );
KonqFrameBase* firstChild() { return m_pFirstChild; }
KonqFrameBase* secondChild() { return m_pSecondChild; }
KonqFrameBase* otherChild( KonqFrameBase* child );
virtual void printFrameInfo( const QString& spaces );
void swapChildren();
virtual void setTitle( const QString &title, QWidget* sender );
virtual void setTabIcon( const KUrl &url, QWidget* sender );
virtual QWidget* widget() { return this; }
virtual QByteArray frameType() { return QByteArray("Container"); }
/**
* Call this after inserting a new frame into the splitter.
*/
void insertChildFrame( KonqFrameBase * frame, int index = -1 );
/**
* Call this before deleting one of our children.
*/
void removeChildFrame( KonqFrameBase * frame );
//inherited
virtual void reparentFrame(QWidget * parent,
const QPoint & p );
//make this one public
int idAfter( QWidget* w ){ return QSplitter::indexOf( w ) + 1; }
void setAboutToBeDeleted() { m_bAboutToBeDeleted = true; }
//inherited
virtual void childEvent( QChildEvent * );
Q_SIGNALS:
void ctrlTabPressed();
void setRubberbandCalled();
protected:
KonqFrameBase* m_pFirstChild;
KonqFrameBase* m_pSecondChild;
bool m_bAboutToBeDeleted;
};
#endif
#include "konq_framecontainer.h"
#include <kdebug.h>
#include <kglobalsettings.h>
#include <kconfig.h>
#include <math.h> // pow()
//###################################################################
void KonqFrameContainerBase::printFrameInfo(const QString& spaces)
{
kDebug(1202) << spaces << "KonqFrameContainerBase " << this << ", this shouldn't happen!" << endl;
}
//###################################################################
KonqFrameContainer::KonqFrameContainer( Qt::Orientation o,
QWidget* parent,
KonqFrameContainerBase* parentContainer )
: QSplitter( o, parent ), m_bAboutToBeDeleted(false)
{
m_pParentContainer = parentContainer;
m_pFirstChild = 0L;
m_pSecondChild = 0L;
m_pActiveChild = 0L;
setOpaqueResize( KGlobalSettings::opaqueResize() );
connect(this, SIGNAL(splitterMoved(int, int)), this, SIGNAL(setRubberbandCalled()));
//### CHECKME
}
KonqFrameContainer::~KonqFrameContainer()
{
//kDebug(1202) << "KonqFrameContainer::~KonqFrameContainer() " << this << " - " << className() << endl;
delete m_pFirstChild;
delete m_pSecondChild;
}
void KonqFrameContainer::listViews( ChildViewList *viewList )
{
if( m_pFirstChild )
m_pFirstChild->listViews( viewList );
if( m_pSecondChild )
m_pSecondChild->listViews( viewList );
}
void KonqFrameContainer::saveConfig( KConfig* config, const QString &prefix, bool saveURLs, KonqFrameBase* docContainer, int id, int depth )
{
int idSecond = id + (int)pow( 2.0, depth );
//write children sizes
config->writeEntry( QString::fromLatin1( "SplitterSizes" ).prepend( prefix ), sizes() );
//write children
QStringList strlst;
if( firstChild() )
strlst.append( QString::fromLatin1( firstChild()->frameType() ) + QString::number(idSecond - 1) );
if( secondChild() )
strlst.append( QString::fromLatin1( secondChild()->frameType() ) + QString::number( idSecond ) );
config->writeEntry( QString::fromLatin1( "Children" ).prepend( prefix ), strlst );
//write orientation
QString o;
if( orientation() == Qt::Horizontal )
o = QString::fromLatin1("Horizontal");
else if( orientation() == Qt::Vertical )
o = QString::fromLatin1("Vertical");
config->writeEntry( QString::fromLatin1( "Orientation" ).prepend( prefix ), o );
//write docContainer
if (this == docContainer) config->writeEntry( QString::fromLatin1( "docContainer" ).prepend( prefix ), true );
if (m_pSecondChild == m_pActiveChild) config->writeEntry( QString::fromLatin1( "activeChildIndex" ).prepend( prefix ), 1 );
else config->writeEntry( QString::fromLatin1( "activeChildIndex" ).prepend( prefix ), 0 );
//write child configs
if( firstChild() ) {
QString newPrefix = QString::fromLatin1( firstChild()->frameType() ) + QString::number(idSecond - 1);
newPrefix.append( QLatin1Char( '_' ) );
firstChild()->saveConfig( config, newPrefix, saveURLs, docContainer, id, depth + 1 );
}
if( secondChild() ) {
QString newPrefix = QString::fromLatin1( secondChild()->frameType() ) + QString::number( idSecond );
newPrefix.append( QLatin1Char( '_' ) );
secondChild()->saveConfig( config, newPrefix, saveURLs, docContainer, idSecond, depth + 1 );
}
}
void KonqFrameContainer::copyHistory( KonqFrameBase *other )
{
Q_ASSERT( other->frameType() == "Container" );
if ( firstChild() )
firstChild()->copyHistory( static_cast<KonqFrameContainer *>( other )->firstChild() );
if ( secondChild() )
secondChild()->copyHistory( static_cast<KonqFrameContainer *>( other )->secondChild() );
}
KonqFrameBase* KonqFrameContainer::otherChild( KonqFrameBase* child )
{
if( firstChild() == child )
return secondChild();
else if( secondChild() == child )
return firstChild();
return 0L;
}
void KonqFrameContainer::printFrameInfo( const QString& spaces )
{
kDebug(1202) << spaces << "KonqFrameContainer " << this << " visible=" << QString("%1").arg(isVisible())
<< " activeChild=" << m_pActiveChild << endl;
if (!m_pActiveChild)
kDebug(1202) << "WARNING: " << this << " has a null active child!" << endl;
KonqFrameBase* child = firstChild();
if (child != 0L)
child->printFrameInfo(spaces + " ");
else
kDebug(1202) << spaces << " Null child" << endl;
child = secondChild();
if (child != 0L)
child->printFrameInfo(spaces + " ");
else
kDebug(1202) << spaces << " Null child" << endl;
}
void KonqFrameContainer::reparentFrame( QWidget* parent, const QPoint & p )
{
setParent( parent );
move( p );
}
void KonqFrameContainer::swapChildren()
{
KonqFrameBase *firstCh = m_pFirstChild;
m_pFirstChild = m_pSecondChild;
m_pSecondChild = firstCh;
}
void KonqFrameContainer::setTitle( const QString &title , QWidget* sender)
{
//kDebug(1202) << "KonqFrameContainer::setTitle( " << title << " , " << sender << " )" << endl;
if (m_pParentContainer && activeChild() && (sender == activeChild()->widget()))
m_pParentContainer->setTitle( title , this);
}
void KonqFrameContainer::setTabIcon( const KUrl &url, QWidget* sender )
{
//kDebug(1202) << "KonqFrameContainer::setTabIcon( " << url << " , " << sender << " )" << endl;
if (m_pParentContainer && activeChild() && (sender == activeChild()->widget()))
m_pParentContainer->setTabIcon( url, this );
}
void KonqFrameContainer::insertChildFrame( KonqFrameBase* frame, int /*index*/ )
{
//kDebug(1202) << "KonqFrameContainer " << this << ": insertChildFrame " << frame << endl;
if (frame)
{
if( !m_pFirstChild )
{
m_pFirstChild = frame;
frame->setParentContainer(this);
//kDebug(1202) << "Setting as first child" << endl;
}
else if( !m_pSecondChild )
{
m_pSecondChild = frame;
frame->setParentContainer(this);
//kDebug(1202) << "Setting as second child" << endl;
}
else
kWarning(1202) << this << " already has two children..."
<< m_pFirstChild << " and " << m_pSecondChild << endl;
} else
kWarning(1202) << "KonqFrameContainer " << this << ": insertChildFrame(0L) !" << endl;
}
void KonqFrameContainer::removeChildFrame( KonqFrameBase * frame )
{
//kDebug(1202) << "KonqFrameContainer::RemoveChildFrame " << this << ". Child " << frame << " removed" << endl;
if( m_pFirstChild == frame )
{
m_pFirstChild = m_pSecondChild;
m_pSecondChild = 0L;
}
else if( m_pSecondChild == frame )
m_pSecondChild = 0L;