Skip to content

Commit

Permalink
Added find and replace function to OMNotebook, resulted in same small…
Browse files Browse the repository at this point in the history
… changes in other files. // Anders F

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2483 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x05andfe committed Aug 24, 2006
1 parent c67a3f7 commit 7831d96
Show file tree
Hide file tree
Showing 19 changed files with 1,989 additions and 23 deletions.
2 changes: 1 addition & 1 deletion OMNotebook/OMNotebookQT4/cell.h
Expand Up @@ -129,7 +129,7 @@ namespace IAEX
virtual void addChild(Cell *){}
virtual void removeChild(Cell *){}
virtual bool isClosed() const{ return false;}
virtual void setClosed(const bool){}
virtual void setClosed(const bool closed, bool update = true){} // Changed 2006-08-24

virtual void addCellWidget(Cell *newCell); //Protected?

Expand Down
37 changes: 35 additions & 2 deletions OMNotebook/OMNotebookQT4/cellcursor.cpp
Expand Up @@ -354,70 +354,103 @@ namespace IAEX
return previous();
}

void CellCursor::moveUp()
// 2006-08-24 AF, changed so the function returns a boolean value, true if
// the cursor is moved.
bool CellCursor::moveUp()
{
// 2006-08-24 AF,
bool moved( false );

// 2006-04-27 AF,
cursorIsMoved();

if( !hasPrevious() )
{
if( parentCell()->hasParentCell() )
{
moveBefore( parentCell() );
moved = true;
}
}
else
{
//previous() exists.
if(previous()->hasChilds())
{
if(!previous()->isClosed())
{
moveToLastChild(previous());
moved = true;
}
else
{
moveBefore(previous());
moved = true;
}
}
else
{
moveBefore(previous());
moved = true;
}
}
emit positionChanged(x(), y(), 5,5);

// TMP EMIT
emit changedPosition();
return moved;
}

/*!
* \bug Segmentationfault when last cell.
*
* \todo It is better that Commands take care of how to change
* state of cells.(Ingemar Axelsson)
*
* 2006-08-24 AF, changed so the function returns a boolean value, true if
* the cursor is moved.
*/
void CellCursor::moveDown()
bool CellCursor::moveDown()
{
// 2006-08-24 AF,
bool moved( false );

// 2006-04-27 AF,
cursorIsMoved();

if( !hasNext() )
{
if( parentCell()->hasParentCell() )
{
moveAfter( parentCell() );
moved = true;
}
}
else //Has next.
{
if(next()->hasChilds())
{
if(!next()->isClosed())
{
moveToFirstChild(next());
moved = true;
}
else
{
moveAfter(next());
moved = true;
}
}
else
{
moveAfter(next());
moved = true;
}
}
// TMP EMIT
emit changedPosition();
emit positionChanged(x(), y(), 5,5);
return moved;
}

/*! Insert this cell as first child of parent.
Expand Down
4 changes: 2 additions & 2 deletions OMNotebook/OMNotebookQT4/cellcursor.h
Expand Up @@ -81,8 +81,8 @@ namespace IAEX
Cell *currentCell();

//Movment
void moveUp();
void moveDown();
bool moveUp(); // Changed 2006-08-24 AF
bool moveDown(); // Changed 2006-08-24 AF

void moveToFirstChild(Cell *parent);
void moveToLastChild(Cell *parent);
Expand Down
43 changes: 43 additions & 0 deletions OMNotebook/OMNotebookQT4/celldocument.cpp
Expand Up @@ -746,6 +746,38 @@ namespace IAEX
return saved_;
}

/*!
* \author Anders Fernström
* \date 2006-08-24
*
* \brief Return true if the document is empty, otherwise false
*/
bool CellDocument::isEmpty() const
{
bool empty( false );
if( workspace_ )
{
if( workspace_->hasChilds() )
{
Cell* cell = workspace_->child();
if( cell )
{
if( !cell->hasNext() )
if( typeid( (*cell) ) == typeid( CellCursor ))
empty = true;
}
else
empty = true;
}
else
empty = true;
}
else
empty = true;

return empty;
}

/*!
* \author Anders Fernström
* \date 2005-11-29
Expand Down Expand Up @@ -1089,6 +1121,17 @@ namespace IAEX
return factory_;
}

/*!
* \author Anders Fernström
* \date 2006-08-24
*
* \brief get the main cell
*/
Cell* CellDocument::getMainCell()
{
return workspace_;
}

QString CellDocument::getFilename()
{
return filename_;
Expand Down
2 changes: 2 additions & 0 deletions OMNotebook/OMNotebookQT4/celldocument.h
Expand Up @@ -139,10 +139,12 @@ namespace IAEX
virtual bool hasChanged() const;
bool isOpen() const;
bool isSaved() const;
bool isEmpty() const; // Added 2006-08-24 AF

//Cursor operations
CellCursor *getCursor();
Factory *cellFactory();
Cell* getMainCell(); // Added 2006-08-24 AF
vector<Cell*> getSelection();

//Command
Expand Down
29 changes: 25 additions & 4 deletions OMNotebook/OMNotebookQT4/cellgroup.cpp
Expand Up @@ -222,6 +222,23 @@ namespace IAEX{
return false;
}

/*!
* \author Anders Fernström
* \date 2005-08-24
*
* \brief Returns the first childs text editor, if the cell is closed. If
* the cell isn't closed, return 0.
*
* \return False
*/
QTextEdit* CellGroup::textEdit()
{
if( isClosed() && hasChilds() )
return child()->textEdit();
else
return 0;
}

/*!
* \author Ingemar Axelsson
*
Expand All @@ -242,16 +259,20 @@ namespace IAEX{
* \bug This function could create a segmentation fault in some
* special cases. Try to find them.
*/
void CellGroup::setClosed(const bool closed)
{
void CellGroup::setClosed(const bool closed, bool update)
{
closed_ = closed;

if( hasChilds() )
child()->hideTreeView( closed );

treeView()->setClosed( closed );
setHeight( height() ); //Sends a signal

closed_ = closed;
emit cellOpened(this, closed_);


if( update )
emit cellOpened(this, closed_);
}

/*!
Expand Down
4 changes: 3 additions & 1 deletion OMNotebook/OMNotebookQT4/cellgroup.h
Expand Up @@ -105,10 +105,12 @@ namespace IAEX{
bool isClosed() const;
bool isEditable(); // Added 2005-10-28 AF

QTextEdit* textEdit(); // Added 2006-08-24 AF


public slots:
virtual void setStyle( CellStyle style ); // Changed 2005-10-28 AF
void setClosed(const bool closed);
void setClosed(const bool closed, bool update = true);
virtual void setFocus(const bool focus);

protected:
Expand Down
2 changes: 2 additions & 0 deletions OMNotebook/OMNotebookQT4/document.h
Expand Up @@ -106,6 +106,7 @@ namespace IAEX
virtual bool hasChanged() const = 0;
virtual bool isOpen() const = 0;
virtual bool isSaved() const = 0; // AF
virtual bool isEmpty() const = 0; // Added 2006-08-24 AF

//File operations
virtual void open( const QString &filename, int readmode ) = 0;
Expand Down Expand Up @@ -156,6 +157,7 @@ namespace IAEX

//Utility operations
virtual Factory *cellFactory() = 0;
virtual Cell* getMainCell() = 0; // Added 2006-08-24 AF
virtual vector<Cell *> getSelection() = 0;
virtual void clearSelection() = 0;

Expand Down
2 changes: 1 addition & 1 deletion OMNotebook/OMNotebookQT4/inputcell.cpp
Expand Up @@ -965,7 +965,7 @@ namespace IAEX
* calculate the new height, to reflect the changes made when
* porting from Q3TextEdit to QTextEdit.
*/
void InputCell::setClosed(const bool closed)
void InputCell::setClosed(const bool closed, bool update)
{
if( closed )
output_->hide();
Expand Down
2 changes: 1 addition & 1 deletion OMNotebook/OMNotebookQT4/inputcell.h
Expand Up @@ -130,7 +130,7 @@ namespace IAEX
QString ChapterCounterHtml(); // Added 2006-03-03 AF
void setReadOnly(const bool readonly); // Added 2005-11-01 AF
void setEvaluated(const bool evaluated); // Added 2006-01-16 AF
void setClosed(const bool closed);
void setClosed(const bool closed, bool update = true); //Changed 2006-08-24
virtual void setFocus(const bool focus);
virtual void setFocusOutput(const bool focus); // Added 2006-02-03 AF

Expand Down

0 comments on commit 7831d96

Please sign in to comment.