Skip to content

Commit

Permalink
fixed some small bugs in OMNotebook and added automatic chapter numbe…
Browse files Browse the repository at this point in the history
…ring to the stylesheet.

// Anders Fernström

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2182 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x05andfe committed Mar 3, 2006
1 parent 992ae37 commit 673590f
Show file tree
Hide file tree
Showing 29 changed files with 981 additions and 171 deletions.
23 changes: 18 additions & 5 deletions OMNotebook/OMNotebookQT4/cell.cpp
Expand Up @@ -144,7 +144,7 @@ namespace IAEX
// PORT >> setBackgroundMode(Qt::PaletteBase);
setBackgroundRole( QPalette::Base );
setTreeWidget(new TreeView(this));
setStyle( c.style() ); // Added 2005-10-27 AF
setStyle( *c.style() ); // Added 2005-10-27 AF


QPalette palette;
Expand Down Expand Up @@ -213,9 +213,9 @@ namespace IAEX
*
* \return current cell style
*/
CellStyle Cell::style()
CellStyle *Cell::style()
{
return style_;
return &style_;
}

/*!
Expand Down Expand Up @@ -278,7 +278,7 @@ namespace IAEX
{
// TODO: DEBUG code: Remove when doing release,
// just a check to find new rules
QRegExp expression( "InitializationCell|CellTags|FontSlant|TextAlignment|TextJustification|FontSize|FontWeight|FontFamily|PageWidth|CellMargins|CellDingbat|ImageSize|ImageMargins|ImageRegion" );
QRegExp expression( "InitializationCell|CellTags|FontSlant|TextAlignment|TextJustification|FontSize|FontWeight|FontFamily|PageWidth|CellMargins|CellDingbat|ImageSize|ImageMargins|ImageRegion|OMNotebook_Margin|OMNotebook_Padding|OMNotebook_Border" );
if( 0 > r->attribute().indexOf( expression ))
{
cout << "[NEW] Rule <" << r->attribute().toStdString() << "> <" << r->value().toStdString() << ">" << endl;
Expand Down Expand Up @@ -475,7 +475,20 @@ namespace IAEX
}
}


/*!
* \author Anders Fernström
* \date 2006-03-02
*
* \brief Update the cell layout with a chapter counter
*/
void Cell::addChapterCounter(QWidget *counter)
{
mainlayout_->removeWidget( mainWidget_ );
mainlayout_->removeWidget( treeView_ );
mainlayout_->addWidget( counter, 1, 1 );
mainlayout_->addWidget( mainWidget_, 1, 2 );
mainlayout_->addWidget( treeView_, 1, 3, Qt::AlignTop );
}



Expand Down
15 changes: 8 additions & 7 deletions OMNotebook/OMNotebookQT4/cell.h
Expand Up @@ -148,7 +148,7 @@ namespace IAEX

//Properties
const QColor backgroundColor() const;
virtual CellStyle style(); // Changed 2005-10-27 AF
virtual CellStyle *style(); // Changed 2005-10-27 AF
QString cellTag(); // Added 2006-01-16 AF
virtual rules_t rules() const;
QWidget *mainWidget();
Expand All @@ -160,14 +160,14 @@ namespace IAEX
public slots:
virtual void addRule(Rule *r);
virtual void setText(QString text){}
virtual void setText(QString text, QTextCharFormat format){} // Added 2005-10-27 AF
virtual void setTextHtml(QString html){} // Added 2005-10-27 AF
virtual void setStyle(const QString &stylename); // Changed 2005-10-28 AF
virtual void setStyle(CellStyle style); // Changed 2005-10-27 AF
void setCellTag(QString tagname); // Added 2006-01-16 AF
virtual void setText(QString text, QTextCharFormat format){} // Added 2005-10-27 AF
virtual void setTextHtml(QString html){} // Added 2005-10-27 AF
virtual void setStyle(const QString &stylename); // Changed 2005-10-28 AF
virtual void setStyle(CellStyle style); // Changed 2005-10-27 AF
void setCellTag(QString tagname); // Added 2006-01-16 AF
virtual void setReadOnly(const bool){}
virtual void setFocus(const bool focus) = 0;
virtual void applyLinksToText(){} // Added 2005-11-09 AF
virtual void applyLinksToText(){} // Added 2005-11-09 AF

virtual void setBackgroundColor(const QColor color);
virtual void setSelected(const bool selected);
Expand All @@ -180,6 +180,7 @@ namespace IAEX
void setLabel(QLabel *label);
void setTreeWidget(TreeView *newTreeWidget);
void setMainWidget(QWidget *newWidget);
void addChapterCounter(QWidget *counter); // Added 2006-02-03 AF

signals:
void clicked(Cell*);
Expand Down
4 changes: 2 additions & 2 deletions OMNotebook/OMNotebookQT4/cellapplication.cpp
Expand Up @@ -119,8 +119,8 @@ namespace IAEX
{
if( !OmcInteractiveEnvironment::startOMC() )
{
QMessageBox::critical( 0, "OMC Error", "Was unable to start OMC, therefore OMNotebook will close." );
exit( -1 );
QMessageBox::critical( 0, "OMC Error", "Was unable to start OMC, OMNotebook will therefore be unable to evaluate Modelica expressions." );
//exit( -1 );
}
}

Expand Down
6 changes: 3 additions & 3 deletions OMNotebook/OMNotebookQT4/cellcommands.cpp
Expand Up @@ -84,9 +84,9 @@ namespace IAEX
CellStyle style;

if(cursor->currentCell()->hasChilds())
style = cursor->currentCell()->child()->style();
style = *cursor->currentCell()->child()->style();
else
style = cursor->currentCell()->style();
style = *cursor->currentCell()->style();


//This does not work.
Expand Down Expand Up @@ -333,7 +333,7 @@ namespace IAEX
Factory *fac = document()->cellFactory();

// 2005-10-28 AF, changed style from QString to CellStyle
CellStyle style = cell->style();
CellStyle style = *cell->style();

//Create a new cell.
if(cursor->currentCell()->isClosed())
Expand Down
10 changes: 9 additions & 1 deletion OMNotebook/OMNotebookQT4/celldocument.cpp
Expand Up @@ -710,14 +710,16 @@ namespace IAEX
/*!
* \author Anders Fernström
* \date 2005-11-29
* \date 2005-12-08 (update)
* \date 2006-03-03 (update)
*
* \brief Update the scrollarea so the correct area is displayed
*
* 2005-12-08 AF, remade function becuase the earlier version hade
* some large bugs. Didn't calculate cells position correct, becuase
* qt:s layout system reset position to 0 in every groupcell and
* layout are probobly not set correctly.
* 2006-03-03 AF, ignore move if the cursor it at the end of the
* document
*/
void CellDocument::updateScrollArea()
{
Expand Down Expand Up @@ -757,6 +759,12 @@ namespace IAEX
// cell so big that it span over entire viewarea
return;
}
// END OF DOCUMENT
else if( scrollBottom > (scroll_->widget()->height() - 10 ))
{
// 2006-03-03 AF, ignore if cursor at end of document
return;
}
// UP
else if( (pos - height) < scrollTop )
{
Expand Down
7 changes: 6 additions & 1 deletion OMNotebook/OMNotebookQT4/cellfactory.cpp
Expand Up @@ -119,7 +119,12 @@ namespace IAEX
QMessageBox::warning( 0, "Warrning", e.what(), "OK" );
}

text->setDelegate(new OmcInteractiveEnvironment());
try
{
text->setDelegate(new OmcInteractiveEnvironment());
}
catch( exception e )
{}

QObject::connect(text, SIGNAL(cellselected(Cell *,Qt::KeyboardModifiers)),
doc_, SLOT(selectedACell(Cell*,Qt::KeyboardModifiers)));
Expand Down
4 changes: 2 additions & 2 deletions OMNotebook/OMNotebookQT4/cellgroup.cpp
Expand Up @@ -146,15 +146,15 @@ namespace IAEX{
*
* \return The cells style
*/
CellStyle CellGroup::style()
CellStyle *CellGroup::style()
{
if(closed_)
return child()->style();
else
{
CellStyle tmp;
tmp.setName( "cellgroup" );
return tmp;
return &tmp;
}
}

Expand Down
2 changes: 1 addition & 1 deletion OMNotebook/OMNotebookQT4/cellgroup.h
Expand Up @@ -96,7 +96,7 @@ namespace IAEX{
virtual void removeCellWidgets();

int height();
CellStyle style(); // Changed 2005-10-28
CellStyle *style(); // Changed 2005-10-28
virtual QString text(){return QString::null;}

void closeChildCells(); // Added 2005-11-30 AF
Expand Down
19 changes: 18 additions & 1 deletion OMNotebook/OMNotebookQT4/cellstyle.h
Expand Up @@ -67,13 +67,17 @@ namespace IAEX
* \class CellStyle
* \author Anders Fernström
* \date 2005-10-26
* \date 2005-11-15 (update)
* \date 2006-03-02 (update)
*
* \brief A class that store the different styleoptions that
* can be changed in a cell.
*
* 2005-11-10 AF, Added some default values in the constructor
* 2005-11-15 AF, Added some more default values
* 2006-03-02 AF, Added a variable and functions that allows the
* style to be hidden from the style menu
* 2006-03-02 AF, Added a variable and functions that holds the
* styles chapter level, if any
*/
class CellStyle
{
Expand All @@ -89,24 +93,37 @@ namespace IAEX
textFormat_.setFontPointSize( 12 );

textFormat_.setForeground( QBrush( QColor(0,0,0) ));

// 2006-03-02 AF, defalut visibliity
visible_ = true;

// 2006-03-02 AF, defalut chapter level
chapterLevel_ = 0;
}
virtual ~CellStyle(){}

QString name(){ return name_; }
QTextCharFormat* textCharFormat(){ return &textFormat_; }
QTextFrameFormat* textFrameFormat(){ return &frameFormat_; }
int alignment(){ return alignment_; }
bool visible(){ return visible_; } // Added 2006-03-02 AF
int chapterLevel(){ return chapterLevel_; } // Added 2006-03-02 AF

void setName( QString name ){ name_ = name; }
void setTextCharFormat( QTextCharFormat format ){ textFormat_ = format; }
void setTextFrameFormat( QTextFrameFormat format ){ frameFormat_ = format; }
void setAlignment( int alignment ){ alignment_ = alignment; }
void setVisible( bool visible ){ visible_ = visible; } // Added 2006-03-02 AF
void setChapterLevel( int level ){ chapterLevel_ = level; } // Added 2006-03-02 AF

private:
QString name_;
QTextCharFormat textFormat_;
QTextFrameFormat frameFormat_;
int alignment_;

bool visible_; // Added 2006-03-02 AF
int chapterLevel_; // Added 2006-03-02 AF
};
}

Expand Down

0 comments on commit 673590f

Please sign in to comment.