Commit 09502650 authored by Martin Pfeiffer's avatar Martin Pfeiffer
Browse files

Q3PtrList ported to QList - still needs a lot of refractoring

- but it compiles and links - we need to find a solution for
replacing setAutoDelete( true )

svn path=/trunk/koffice/; revision=546361
parent be0661f4
......@@ -18,7 +18,6 @@
* Boston, MA 02110-1301, USA.
*/
#include <QString>
#include <kdebug.h>
#include "contextstyle.h"
......
......@@ -21,21 +21,16 @@
#ifndef BASICELEMENT_H
#define BASICELEMENT_H
// Qt Include
#include <qdom.h>
#include <q3ptrlist.h>
#include <QString>
//Added by qt3to4:
#include <QKeyEvent>
#include <QList>
#include <QDomElement>
#include <QDomDocument>
// KDE Include
// Formula include
#include "contextstyle.h"
#include "kformuladefs.h"
class QKeyEvent;
class KCommand;
KFORMULA_NAMESPACE_BEGIN
......@@ -270,13 +265,13 @@ public:
*
* The list will be emptied but stays the property of the caller.
*/
virtual void insert(FormulaCursor*, Q3PtrList<BasicElement>&, Direction) {}
virtual void insert(FormulaCursor*, QList<BasicElement*>&, Direction) {}
/**
* Removes all selected children and returns them. Places the
* cursor to where the children have been.
*/
virtual void remove(FormulaCursor*, Q3PtrList<BasicElement>&, Direction) {}
virtual void remove(FormulaCursor*, QList<BasicElement*>&, Direction) {}
/**
* Moves the cursor to a normal place where new elements
......
......@@ -18,10 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
#include <q3ptrlist.h>
#include <QPainter>
#include <QPen>
#include <q3pointarray.h>
#include <kdebug.h>
#include <klocale.h>
......@@ -132,7 +130,7 @@ void SingleContentElement::moveDown(FormulaCursor* cursor, BasicElement* /*from*
}
void SingleContentElement::remove( FormulaCursor* cursor,
Q3PtrList<BasicElement>& removedChildren,
QList<BasicElement*>& removedChildren,
Direction direction )
{
switch (cursor->getPos()) {
......
......@@ -23,8 +23,7 @@
#include <QPoint>
#include <QSize>
//Added by qt3to4:
#include <Q3PtrList>
#include <QList>
#include "basicelement.h"
......@@ -102,7 +101,7 @@ public:
*
* We remove ourselve if we are requested to remove our content.
*/
virtual void remove(FormulaCursor*, Q3PtrList<BasicElement>&, Direction);
virtual void remove(FormulaCursor*, QList<BasicElement*>&, Direction);
/**
* Moves the cursor to a normal place where new elements
......
......@@ -19,8 +19,6 @@
*/
#include <QPainter>
//Added by qt3to4:
#include <Q3PtrList>
#include <kdebug.h>
#include <assert.h>
......@@ -298,12 +296,12 @@ void FormulaCursor::normalize(Direction direction)
*/
void FormulaCursor::insert(BasicElement* child, Direction direction)
{
Q3PtrList<BasicElement> list;
QList<BasicElement*> list;
list.append(child);
insert(list, direction);
}
void FormulaCursor::insert(Q3PtrList<BasicElement>& children,
void FormulaCursor::insert(QList<BasicElement*>& children,
Direction direction)
{
assert( !isReadOnly() );
......@@ -317,7 +315,7 @@ void FormulaCursor::insert(Q3PtrList<BasicElement>& children,
* The cursor needs to be normal (that is be inside a SequenceElement)
* for this to have any effect.
*/
void FormulaCursor::remove(Q3PtrList<BasicElement>& children,
void FormulaCursor::remove(QList<BasicElement*>& children,
Direction direction)
{
assert( !isReadOnly() );
......@@ -349,7 +347,7 @@ void FormulaCursor::replaceSelectionWith(BasicElement* element,
Direction direction)
{
assert( !isReadOnly() );
Q3PtrList<BasicElement> list;
QList<BasicElement*> list;
// we suppres deletion here to get an error if something
// was left in the list.
//list.setAutoDelete(true);
......@@ -385,8 +383,8 @@ void FormulaCursor::replaceSelectionWith(BasicElement* element,
BasicElement* FormulaCursor::replaceByMainChildContent(Direction direction)
{
assert( !isReadOnly() );
Q3PtrList<BasicElement> childrenList;
Q3PtrList<BasicElement> list;
QList<BasicElement*> childrenList;
QList<BasicElement*> list;
BasicElement* element = getElement();
SequenceElement* mainChild = element->getMainChild();
if ((mainChild != 0) && (mainChild->countChildren() > 0)) {
......@@ -398,7 +396,7 @@ BasicElement* FormulaCursor::replaceByMainChildContent(Direction direction)
remove(list);
insert(childrenList, direction);
if (list.count() > 0) {
return list.take(0);
return list.takeAt(0);
}
return 0;
}
......@@ -660,7 +658,7 @@ void FormulaCursor::copy( QDomDocument& doc )
* Inserts the elements that could be read from the dom into
* the list. Returns true on success.
*/
bool FormulaCursor::buildElementsFromDom( QDomElement root, Q3PtrList<BasicElement>& list )
bool FormulaCursor::buildElementsFromDom( QDomElement root, QList<BasicElement*>& list )
{
assert( !isReadOnly() );
SequenceElement* sequence = normal();
......
......@@ -22,8 +22,7 @@
#define FORMULACURSOR_H
#include <QString>
//Added by qt3to4:
#include <Q3PtrList>
#include <QList>
#include "basicelement.h"
#include "kformuladefs.h"
......@@ -157,7 +156,7 @@ public:
* Ignores the selection.
* The list will be emptied.
*/
void insert(Q3PtrList<BasicElement>&,
void insert(QList<BasicElement*>&,
Direction = beforeCursor);
/**
......@@ -165,7 +164,7 @@ public:
* The cursor needs to be normal (that is be inside a SequenceElement)
* for this to have any effect.
*/
void remove(Q3PtrList<BasicElement>&,
void remove(QList<BasicElement*>&,
Direction = beforeCursor);
......@@ -298,7 +297,7 @@ public:
* Inserts the elements that could be read from the dom into
* the list. Returns true on success.
*/
bool buildElementsFromDom( QDomElement root, Q3PtrList<BasicElement>& list );
bool buildElementsFromDom( QDomElement root, QList<BasicElement*>& list );
// undo/redo support
......
......@@ -23,7 +23,6 @@
// Formula include
#include "sequenceelement.h"
//Added by qt3to4:
#include <QKeyEvent>
KFORMULA_NAMESPACE_BEGIN
......
......@@ -19,8 +19,6 @@
*/
#include <QPainter>
//Added by qt3to4:
#include <Q3PtrList>
#include <kdebug.h>
#include <klocale.h>
......@@ -294,11 +292,11 @@ void FractionElement::moveDown(FormulaCursor* cursor, BasicElement* from)
* Reinserts the denominator if it has been removed.
*/
void FractionElement::insert(FormulaCursor* cursor,
Q3PtrList<BasicElement>& newChildren,
QList<BasicElement*>& newChildren,
Direction direction)
{
if (cursor->getPos() == denominatorPos) {
denominator = static_cast<SequenceElement*>(newChildren.take(0));
denominator = static_cast<SequenceElement*>(newChildren.takeAt(0));
denominator->setParent(this);
if (direction == beforeCursor) {
......@@ -323,7 +321,7 @@ void FractionElement::insert(FormulaCursor* cursor,
* are senseless and the caller is required to replace us.
*/
void FractionElement::remove(FormulaCursor* cursor,
Q3PtrList<BasicElement>& removedChildren,
QList<BasicElement*>& removedChildren,
Direction direction)
{
switch (cursor->getPos()) {
......
......@@ -22,8 +22,7 @@
#define FRACTIONELEMENT_H
#include "basicelement.h"
//Added by qt3to4:
#include <Q3PtrList>
#include <QList>
KFORMULA_NAMESPACE_BEGIN
class SequenceElement;
......@@ -123,7 +122,7 @@ public:
/**
* Reinserts the denominator if it has been removed.
*/
virtual void insert(FormulaCursor*, Q3PtrList<BasicElement>&, Direction);
virtual void insert(FormulaCursor*, QList<BasicElement*>&, Direction);
/**
* Removes all selected children and returns them. Places the
......@@ -134,7 +133,7 @@ public:
* It is possible to remove the denominator. But after this we
* are senseless and the caller is required to replace us.
*/
virtual void remove(FormulaCursor*, Q3PtrList<BasicElement>&, Direction);
virtual void remove(FormulaCursor*, QList<BasicElement*>&, Direction);
// main child
......
......@@ -19,8 +19,6 @@
*/
#include <QPainter>
//Added by qt3to4:
#include <Q3PtrList>
#include <kdebug.h>
#include <klocale.h>
......@@ -867,10 +865,10 @@ void IndexElement::moveDown(FormulaCursor* cursor, BasicElement* from)
* The list will be emptied but stays the property of the caller.
*/
void IndexElement::insert(FormulaCursor* cursor,
Q3PtrList<BasicElement>& newChildren,
QList<BasicElement*>& newChildren,
Direction direction)
{
SequenceElement* index = static_cast<SequenceElement*>(newChildren.take(0));
SequenceElement* index = static_cast<SequenceElement*>(newChildren.takeAt(0));
index->setParent(this);
switch (cursor->getPos()) {
......@@ -920,7 +918,7 @@ void IndexElement::insert(FormulaCursor* cursor,
* The ownership of the list is passed to the caller.
*/
void IndexElement::remove(FormulaCursor* cursor,
Q3PtrList<BasicElement>& removedChildren,
QList<BasicElement*>& removedChildren,
Direction direction)
{
int pos = cursor->getPos();
......
......@@ -23,8 +23,7 @@
// Formula include
#include "basicelement.h"
//Added by qt3to4:
#include <Q3PtrList>
#include <QList>
KFORMULA_NAMESPACE_BEGIN
class SequenceElement;
......@@ -170,7 +169,7 @@ public:
*
* The list will be emptied but stays the property of the caller.
*/
virtual void insert(FormulaCursor*, Q3PtrList<BasicElement>&, Direction);
virtual void insert(FormulaCursor*, QList<BasicElement*>&, Direction);
/**
* Removes all selected children and returns them. Places the
......@@ -183,7 +182,7 @@ public:
*
* The ownership of the list is passed to the caller.
*/
virtual void remove(FormulaCursor*, Q3PtrList<BasicElement>&, Direction);
virtual void remove(FormulaCursor*, QList<BasicElement*>&, Direction);
/**
* Moves the cursor to a normal place where new elements
......
......@@ -20,8 +20,6 @@
#include <klocale.h> //This is for undo descriptions
#include <q3valuelist.h>
#include "formulacursor.h"
#include "formulaelement.h"
#include "indexelement.h"
......@@ -95,7 +93,7 @@ void Command::setUnexecuteCursor(FormulaCursor* cursor)
KFCAdd::KFCAdd(const QString &name, Container *document)
: Command(name, document)
{
addList.setAutoDelete( true );
// addList.setAutoDelete( true );
}
......@@ -127,7 +125,7 @@ KFCRemoveSelection::KFCRemoveSelection(Container *document,
: Command(i18n("Remove Selected Text"), document),
dir(direction)
{
removedList.setAutoDelete( true );
// removedList.setAutoDelete( true );
}
void KFCRemoveSelection::execute()
......@@ -184,7 +182,7 @@ KFCRemove::KFCRemove(Container *document,
: Command(i18n("Remove Selected Text"), document),
element(0), simpleRemoveCursor(0), dir(direction)
{
removedList.setAutoDelete( true );
// removedList.setAutoDelete( true );
}
KFCRemove::~KFCRemove()
......@@ -352,8 +350,8 @@ void KFCChangeBaseSize::unexecute()
FontCommand::FontCommand( const QString& name, Container* document )
: Command( name, document )
{
list.setAutoDelete( false );
elementList.setAutoDelete( false );
// list.setAutoDelete( false );
// elementList.setAutoDelete( false );
}
......@@ -369,8 +367,8 @@ void FontCommand::collectChildren()
void FontCommand::parseSequences( const QMap<SequenceElement*, int>& parents )
{
Q3ValueList<SequenceElement*> sequences = parents.keys();
for ( Q3ValueList<SequenceElement*>::iterator i = sequences.begin();
QList<SequenceElement*> sequences = parents.keys();
for ( QList<SequenceElement*>::iterator i = sequences.begin();
i != sequences.end();
++i ) {
( *i )->parse();
......
......@@ -22,8 +22,8 @@
#define KFORMULACOMMAND_H
#include <QMap>
#include <q3ptrlist.h>
#include <q3valuevector.h>
#include <QList>
#include <QVector>
#include <kcommand.h>
......@@ -179,7 +179,7 @@ private:
* the list where all elements are stored that are removed
* from the tree.
*/
Q3PtrList<BasicElement> addList;
QList<BasicElement*> addList;
};
......@@ -206,7 +206,7 @@ private:
* the list where all elements are stored that are removed
* from the tree.
*/
Q3PtrList<BasicElement> removedList;
QList<BasicElement*> removedList;
Direction dir;
};
......@@ -264,7 +264,7 @@ private:
* the list where all elements are stored that are removed
* from the tree.
*/
Q3PtrList<BasicElement> removedList;
QList<BasicElement*> removedList;
/**
* The element we might have extracted.
......@@ -399,7 +399,7 @@ public:
protected:
Q3PtrList<TextElement>& childrenList() { return list; }
QList<TextElement*>& childrenList() { return list; }
void collectChildren();
......@@ -411,9 +411,9 @@ private:
* the list where all elements are stored that are removed
* from the tree.
*/
Q3PtrList<TextElement> list;
QList<TextElement*> list;
Q3PtrList<BasicElement> elementList;
QList<BasicElement*> elementList;
};
......@@ -429,7 +429,7 @@ public:
private:
typedef Q3ValueVector<CharStyle> StyleList;
typedef QVector<CharStyle> StyleList;
StyleList styleList;
CharStyle charStyle;
......@@ -448,7 +448,7 @@ public:
private:
typedef Q3ValueVector<CharFamily> FamilyList;
typedef QVector<CharFamily> FamilyList;
FamilyList familyList;
CharFamily charFamily;
......
......@@ -25,8 +25,7 @@
#include <QPixmap>
#include <QString>
#include <QTextStream>
//Added by qt3to4:
#include <Q3PtrList>
#include <QList>
#include <QKeyEvent>
#include <kdebug.h>
......@@ -355,15 +354,15 @@ void Container::paste()
void Container::paste( const QDomDocument& document, QString desc )
{
FormulaCursor* cursor = activeCursor();
Q3PtrList<BasicElement> list;
list.setAutoDelete( true );
QList<BasicElement*> list;
// list.setAutoDelete( true );
if ( cursor->buildElementsFromDom( document.documentElement(), list ) ) {
uint count = list.count();
// You must not execute an add command that adds nothing.
if (count > 0) {
KFCReplace* command = new KFCReplace( desc, this );
for (uint i = 0; i < count; i++) {
command->addElement(list.take(0));
command->addElement(list.takeAt(0));
}
execute(command);
}
......
......@@ -23,9 +23,9 @@
#include <QClipboard>
#include <QImage>
#include <q3ptrlist.h>
//#include <q3ptrlist.h>
#include <QObject>
#include <q3ptrstack.h>
#include <QStack>
#include <QString>
//Added by qt3to4:
#include <QTextStream>
......
......@@ -26,8 +26,8 @@
#include <QImage>
#include <QPainter>
#include <QPixmap>
//Added by qt3to4:
#include <Q3PtrList>
#include <QList>
#include <QImageWriter>
#include <kcommand.h>
......@@ -50,8 +50,8 @@ MimeSource::MimeSource(Document* doc, const QDomDocument& formula)
rootElement = new FormulaElement(this);
FormulaCursor cursor(rootElement);
Q3PtrList<BasicElement> list;
list.setAutoDelete(true);
QList<BasicElement*> list;
// list.setAutoDelete(true);
if ( cursor.buildElementsFromDom( document.documentElement(), list ) ) {
cursor.insert(list);
latexString = rootElement->toLatex().toUtf8();
......
......@@ -21,8 +21,8 @@
#ifndef KFORMULAMIMESOURCE_H
#define KFORMULAMIMESOURCE_H
#include <qmime.h>
#include <qdom.h>
#include <QMimeSource>
#include <QDomDocument>
#include "kformulacontainer.h"
#include <koffice_export.h>
......
......@@ -25,12 +25,6 @@
#include <QPixmap>
#include <QPoint>
#include <QWidget>
//Added by qt3to4:
#include <QMouseEvent>
#include <QWheelEvent>
#include <QFocusEvent>
#include <QKeyEvent>
#include <QPaintEvent>
#include "kformuladefs.h"
#include "kformulaview.h"
......@@ -51,11 +45,12 @@ using namespace KFormula;
* The view. A widget that shows the formula. There are methods
* to move the cursor around. To edit the formula use the document.
*/
class KFormulaWidget : public QWidget {
class KFormulaWidget : public QWidget
{
Q_OBJECT
public:
KFormulaWidget(Container*, QWidget* parent=0, const char* name=0, Qt::WFlags f=0);
KFormulaWidget(Container*, QWidget* parent=0, Qt::WFlags f=0);
~KFormulaWidget();
......
This diff is collapsed.
......@@ -21,8 +21,6 @@
#ifndef MATRIXELEMENT_H
#define MATRIXELEMENT_H
#include <q3ptrlist.h>
#include "basicelement.h"
KFORMULA_NAMESPACE_BEGIN
......@@ -41,7 +39,7 @@ class MatrixElement : public BasicElement {
MatrixElement& operator=( const MatrixElement& ) { return *this; }
public:
MatrixElement(uint rows = 1, uint columns = 1, BasicElement* parent = 0);
MatrixElement( int rows = 1, int columns = 1, BasicElement* parent = 0);
~MatrixElement();
MatrixElement( const MatrixElement& );
......@@ -189,10 +187,10 @@ public:
virtual QString formulaString();
uint getRows() const { return content.count(); }
uint getColumns() const { return content.getFirst()->count(); }
int getRows() const { return content.count(); }
int getColumns() const { return content.first()->count(); }
SequenceElement* elementAt(uint row, uint column);
SequenceElement* elementAt( int row, int column );
virtual void writeMathML( QDomDocument& doc, QDomNode parent, bool oasisFormat = false );
......@@ -225,7 +223,7 @@ protected:
private:
MatrixSequenceElement* getElement(uint row, uint column)
MatrixSequenceElement* getElement( int row, int column )
{ return content.at(row)->at(column); }
/**
......@@ -233,12 +231,12 @@ private:
* row and column if found.
* Returns true if the element was found. false otherwise.
*/
bool searchElement(BasicElement* element, uint& row, uint& column);
bool searchElement( BasicElement* element, int& row, int& column );
/**
* The elements we contain.
*/
Q3PtrList< Q3PtrList< MatrixSequenceElement > > content;
QList< QList< MatrixSequenceElement* >* > content;
};
......@@ -338,8 +336,8 @@ public:
*/
virtual void dispatchFontCommand( FontCommand* cmd );
virtual void insert(FormulaCursor*, Q3PtrList<BasicElement>&, Direction);
virtual void remove(FormulaCursor*, Q3PtrList<BasicElement>&, Direction);