Skip to content

Commit ba0b214

Browse files
author
x05andfe
committed
fixed some bugs in omnotebook,
// Anders Fernström git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2081 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 794e64d commit ba0b214

25 files changed

+889
-257
lines changed

OMNotebook/OMNotebookQT4/cell.cpp

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,15 @@ namespace IAEX
258258
}
259259

260260
/*!
261-
* \author Ingemar Axelsson
261+
* \author Ingemar Axelsson and Anders Fernström
262+
* \date 2006-02-03 AF
262263
*
263264
* \brief Adds a rule to the cell
264265
*
266+
*
267+
* 2006-02-03 AF, check and see if rule already existes, if it dose
268+
* only replace the value
269+
*
265270
* \param r The rule that will be added
266271
*
267272
*
@@ -273,6 +278,7 @@ namespace IAEX
273278
{
274279
// TODO: DEBUG code: Remove when doing release,
275280
// just a check to find new rules
281+
276282
/*
277283
QRegExp expression( "InitializationCell|CellTags|FontSlant|TextAlignment|TextJustification|FontSize|FontWeight|FontFamily|PageWidth" );
278284
if( 0 > r->attribute().indexOf( expression ))
@@ -307,11 +313,28 @@ namespace IAEX
307313
}
308314
}
309315
*/
316+
310317

311318

312319

313320
// *** THE REAL FUNCTION ***
314-
rules_.push_back(r);
321+
322+
// check if rule already existes
323+
bool found = false;
324+
rules_t::iterator iter = rules_.begin();
325+
while( iter != rules_.end() )
326+
{
327+
if( 0 == (*iter)->attribute().indexOf( r->attribute(), 0, Qt::CaseInsensitive ) )
328+
{
329+
found = true;
330+
(*iter)->setValue( r->value() );
331+
break;
332+
}
333+
++iter;
334+
}
335+
336+
if( !found )
337+
rules_.push_back(r);
315338
}
316339

317340

@@ -340,7 +363,9 @@ namespace IAEX
340363
else if( (*current)->value() == "Right" )
341364
style_.setAlignment( Qt::AlignRight );
342365
else if( (*current)->value() == "Center" )
343-
style_.setAlignment( Qt::AlignCenter );
366+
style_.setAlignment( Qt::AlignHCenter );
367+
else if( (*current)->value() == "Justify" )
368+
style_.setAlignment( Qt::AlignJustify );
344369
}
345370
else if( (*current)->attribute() == "TextJustification" )
346371
{
@@ -374,6 +399,39 @@ namespace IAEX
374399
{
375400
celltag_ = (*current)->value();
376401
}
402+
else if( (*current)->attribute() == "OMNotebook_Margin" )
403+
{
404+
bool ok;
405+
int value = (*current)->value().toInt(&ok);
406+
407+
if(ok)
408+
{
409+
if( value > 0 )
410+
style_.textFrameFormat()->setMargin( value );
411+
}
412+
}
413+
else if( (*current)->attribute() == "OMNotebook_Padding" )
414+
{
415+
bool ok;
416+
int value = (*current)->value().toInt(&ok);
417+
418+
if(ok)
419+
{
420+
if( value > 0 )
421+
style_.textFrameFormat()->setPadding( value );
422+
}
423+
}
424+
else if( (*current)->attribute() == "OMNotebook_Border" )
425+
{
426+
bool ok;
427+
int value = (*current)->value().toInt(&ok);
428+
429+
if(ok)
430+
{
431+
if( value > 0 )
432+
style_.textFrameFormat()->setBorder( value );
433+
}
434+
}
377435

378436
++current;
379437
}

OMNotebook/OMNotebookQT4/cellapplication.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ namespace IAEX
133133
{
134134
QString msg = e.what();
135135
msg += "\nWas unable to start OMC! Closeing OMNotebook!";
136-
QMessageBox::warning( 0, "Error", msg, "OK" );
136+
QMessageBox::critical( 0, "Error", msg, "OK" );
137137
std::exit(-1);
138138
}
139139
#else
140140
QString msg = e.what();
141141
msg += "\nOMC not started! Closeing OMNotebook!";
142-
QMessageBox::warning( 0, "Error", msg, "OK" );
142+
QMessageBox::critical( 0, "Error", msg, "OK" );
143143
std::exit(-1);
144144
#endif
145145
}
@@ -424,17 +424,17 @@ namespace IAEX
424424
// correct size. Ugly way!
425425
v->resize( 810, 610 );
426426

427-
// 2005-11-30 AF, apply hide() and show() to closed groupcells
428-
// childs in the documentview
429-
UpdateGroupcellVisitor visitor;
430-
v->document()->runVisitor( visitor );
431-
432427
// 2006-01-17 AF, when the document have been opened, set the
433428
// changed variable to false.
434429
v->document()->setChanged( false );
435430

436431
// 2006-01-31 AF, show window again
437432
v->showNormal();
433+
434+
// 2005-11-30 AF, apply hide() and show() to closed groupcells
435+
// childs in the documentview
436+
UpdateGroupcellVisitor visitor;
437+
v->document()->runVisitor( visitor );
438438
}
439439
catch( exception &e )
440440
{

OMNotebook/OMNotebookQT4/cellcommands.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ namespace IAEX
106106

107107
// 2005-11-21 AF, Added check if the current cell is a
108108
// inputcell, set style to 'text' insted.
109-
if( style.name() == "input" || style.name() == "Input" || style.name() == "ModelicaInput" )
109+
// 2006-02-03 AF, added check if the current cell is a
110+
// groupcell
111+
if( style.name() == "input" || style.name() == "Input" || style.name() == "ModelicaInput" ||
112+
style.name() == "cellgroup" )
110113
cursor->addBefore(fac->createCell( "Text" ));
111114
else
112115
cursor->addBefore(fac->createCell(style.name()));

OMNotebook/OMNotebookQT4/celldocument.cpp

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -770,16 +770,49 @@ namespace IAEX
770770
emit contentChanged();
771771
}
772772

773+
/*!
774+
* \author Ingemar Axelsson
775+
*/
776+
void CellDocument::mouseClickedOnCell(Cell *clickedCell)
777+
{
778+
//Deselect all selection
779+
clearSelection();
773780

781+
//Remove focus from old cell.
782+
if(getCursor()->currentCell()->isClosed())
783+
{
784+
getCursor()->currentCell()->child()->setReadOnly(true);
785+
getCursor()->currentCell()->child()->setFocus(false);
786+
}
787+
else
788+
{
789+
getCursor()->currentCell()->setReadOnly(true);
790+
}
774791

792+
//Add focus to the cell clicked on.
793+
if(clickedCell->parentCell()->isClosed())
794+
{
795+
getCursor()->moveAfter(clickedCell->parentCell());
796+
}
797+
else
798+
{
799+
getCursor()->moveAfter(clickedCell); //Results in bus error why?
800+
}
775801

802+
clickedCell->setReadOnly(false);
803+
clickedCell->setFocus(true);
776804

777-
// ***************************************************************
778-
805+
emit cursorChanged();
806+
}
779807

780-
void CellDocument::mouseClickedOnCell(Cell *clickedCell)
808+
/*!
809+
* \author Anders Fernström
810+
* \date 2006-02-03
811+
*
812+
* \brief set focus on output part in inputcell
813+
*/
814+
void CellDocument::mouseClickedOnCellOutput(Cell *clickedCell)
781815
{
782-
//Deselect all selection
783816
clearSelection();
784817

785818
//Remove focus from old cell.
@@ -803,13 +836,29 @@ namespace IAEX
803836
getCursor()->moveAfter(clickedCell); //Results in bus error why?
804837
}
805838

806-
clickedCell->setReadOnly(false);
807-
clickedCell->setFocus(true);
839+
if( typeid(InputCell) == typeid(*clickedCell) )
840+
{
841+
InputCell *inputcell = dynamic_cast<InputCell*>(clickedCell);
842+
inputcell->setReadOnly(false);
843+
inputcell->setFocusOutput(true);
844+
}
845+
else
846+
{
847+
clickedCell->setReadOnly(false);
848+
clickedCell->setFocus(true);
849+
}
808850

809851
emit cursorChanged();
810-
//qDebug("Clicked on cell");
811852
}
812853

854+
855+
856+
// ***************************************************************
857+
858+
859+
860+
861+
813862
/*! What to do when a link is clicked?
814863
*/
815864
void CellDocument::linkClicked(const QUrl *link)

OMNotebook/OMNotebookQT4/celldocument.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ namespace IAEX
157157
void selectedACell(Cell *selected, Qt::KeyboardModifiers);
158158
void clearSelection();
159159
void mouseClickedOnCell(Cell *clickedCell);
160+
void mouseClickedOnCellOutput(Cell *clickedCell); //Added 2006-02-03
160161
void linkClicked(const QUrl *url);
161162
virtual void cursorMoveAfter(Cell *aCell, const bool open);
162163
void showHTML(bool b);

OMNotebook/OMNotebookQT4/cellfactory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ namespace IAEX
125125
doc_, SLOT(selectedACell(Cell*,Qt::KeyboardModifiers)));
126126
QObject::connect(text, SIGNAL(clicked(Cell *)),
127127
doc_, SLOT(mouseClickedOnCell(Cell*)));
128+
QObject::connect(text, SIGNAL(clickedOutput(Cell *)),
129+
doc_, SLOT(mouseClickedOnCellOutput(Cell*)));
128130

129131
// 2005-11-29 AF
130132
QObject::connect( text, SIGNAL( textChanged() ),

0 commit comments

Comments
 (0)