From 74e05d19ff4912fd91fc1a18baab0b7177035c90 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Fri, 14 May 2010 07:36:42 +0000 Subject: [PATCH] * ./hurricane: - Cleanup: In Slot.h, comment out print for debug. - New: In CellViewer, adds a renameCell() method to "rename" the currently loaded Cell "in place". Utility function for SaveCellDialog (see below). --- hurricane/src/hurricane/Library.cpp | 2 +- hurricane/src/hurricane/hurricane/Slot.h | 8 ++-- hurricane/src/viewer/CellViewer.cpp | 16 +++++++- hurricane/src/viewer/ExceptionWidget.cpp | 37 ++++++++++++------- .../src/viewer/hurricane/viewer/CellViewer.h | 5 ++- .../viewer/hurricane/viewer/ExceptionWidget.h | 14 +++---- 6 files changed, 52 insertions(+), 30 deletions(-) diff --git a/hurricane/src/hurricane/Library.cpp b/hurricane/src/hurricane/Library.cpp index c75987e7..2ecab9df 100644 --- a/hurricane/src/hurricane/Library.cpp +++ b/hurricane/src/hurricane/Library.cpp @@ -53,7 +53,7 @@ Library::Library(DataBase* dataBase, Library* library, const Name& name) } else { if (_library->getLibrary(_name)) - throw Error("Can't create " + _TName("Library") + " : already exists"); + throw Error("Can't create Library " + getString(name) + " : already exists"); } } diff --git a/hurricane/src/hurricane/hurricane/Slot.h b/hurricane/src/hurricane/hurricane/Slot.h index b99e56fc..f0e9bddc 100644 --- a/hurricane/src/hurricane/hurricane/Slot.h +++ b/hurricane/src/hurricane/hurricane/Slot.h @@ -328,7 +328,7 @@ namespace Hurricane { template inline Hurricane::Slot* getSlot( std::string& name, Data d ) { - std::cerr << "getSlot( \"" << name << "\" )" << std::endl; +//std::cerr << "getSlot( \"" << name << "\" )" << std::endl; return new Hurricane::SlotTemplate ( name, d ); } @@ -336,7 +336,7 @@ inline Hurricane::Slot* getSlot( std::string& name, Data d ) template inline Hurricane::Slot* getSlot( std::string& name, Data* d ) { - std::cerr << "getSlot( \"" << name << "\" )" << std::endl; +//std::cerr << "getSlot( \"" << name << "\" )" << std::endl; return new Hurricane::SlotTemplate ( name, d ); } @@ -344,7 +344,7 @@ inline Hurricane::Slot* getSlot( std::string& name, Data* d ) template inline Hurricane::Slot* getSlot( const std::string& name, Data d ) { - std::cerr << "getSlot( \"" << name << "\" )" << std::endl; +//std::cerr << "getSlot( \"" << name << "\" )" << std::endl; return new Hurricane::SlotTemplate ( name, d ); } @@ -352,7 +352,7 @@ inline Hurricane::Slot* getSlot( const std::string& name, Data d ) template inline Hurricane::Slot* getSlot( const std::string& name, Data* d ) { - std::cerr << "getSlot( \"" << name << "\" )" << std::endl; +//std::cerr << "getSlot( \"" << name << "\" )" << std::endl; return new Hurricane::SlotTemplate ( name, d ); } diff --git a/hurricane/src/viewer/CellViewer.cpp b/hurricane/src/viewer/CellViewer.cpp index 0ff291fa..e3fdba4c 100644 --- a/hurricane/src/viewer/CellViewer.cpp +++ b/hurricane/src/viewer/CellViewer.cpp @@ -149,7 +149,7 @@ namespace Hurricane { _saveAction = new QAction ( tr("&Save Cell"), this ); _saveAction->setObjectName ( "viewer.menuBar.file.saveCell" ); _saveAction->setIcon ( QIcon(":/images/stock_save.png") ); - _saveAction->setStatusTip ( tr("Save the current Cell") ); + _saveAction->setStatusTip ( tr("Save (write) the current Cell") ); _saveAction->setVisible ( false ); _closeAction = new QAction ( tr("&Close"), this ); @@ -330,7 +330,7 @@ namespace Hurricane { void CellViewer::refreshHistory () { - if ( !getCell() ) return; + if ( getCell() == NULL ) return; shared_ptr activeState = _cellWidget->getState(); _cellHistory.remove ( activeState ); @@ -404,6 +404,18 @@ namespace Hurricane { } + void CellViewer::renameCell ( const char* name ) + { + Cell* cell = getCell(); + if ( cell == NULL ) return; + + cell->setName ( name ); + + refreshTitle (); + refreshHistory (); + } + + void CellViewer::doGoto () { if ( _goto->exec() == QDialog::Accepted ) { diff --git a/hurricane/src/viewer/ExceptionWidget.cpp b/hurricane/src/viewer/ExceptionWidget.cpp index 268eb3e4..153c2bd3 100644 --- a/hurricane/src/viewer/ExceptionWidget.cpp +++ b/hurricane/src/viewer/ExceptionWidget.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -38,18 +38,18 @@ namespace Hurricane { ExceptionWidget::ExceptionWidget ( QWidget* parent ) - : QDialog (parent) - , _message (new QLabel()) + : QDialog (parent) + , _message(new QLabel()) + , _header (new QLabel()) { - setAttribute ( Qt::WA_DeleteOnClose ); - setModal ( true ); - setWindowTitle ( tr("") ); - setToolTip ( tr("Ben mon cochon, t'es dans le bouillon") ); + setAttribute ( Qt::WA_DeleteOnClose ); + setModal ( true ); + setWindowTitle( tr("") ); + setToolTip ( tr("Ben mon cochon, t'es dans le bouillon") ); - QLabel* header = new QLabel (); - header->setMinimumWidth ( 200 ); - header->setTextFormat ( Qt::RichText ); - header->setText ( "[ERROR]" ); + _header->setMinimumWidth ( 200 ); + _header->setTextFormat ( Qt::RichText ); + _header->setText ( "[ERROR]" ); _message->setTextFormat ( Qt::RichText ); _message->setText ( "Oups! I did it again!" ); @@ -78,7 +78,7 @@ namespace Hurricane { QVBoxLayout* vLayout1 = new QVBoxLayout (); vLayout1->setContentsMargins ( 10, 10, 10, 10 ); vLayout1->setSpacing ( 0 ); - vLayout1->addWidget ( header , Qt::AlignCenter ); + vLayout1->addWidget ( _header , Qt::AlignCenter ); vLayout1->addWidget ( _message, Qt::AlignCenter ); vLayout1->addSpacing ( 10 ); vLayout1->addLayout ( hLayout2, Qt::AlignCenter ); @@ -104,7 +104,18 @@ namespace Hurricane { void ExceptionWidget::setMessage ( const QString& message ) { - _message->setText ( message ); + QString contents = message; + + if ( contents.startsWith("[ERROR]")) { + contents.remove ( 0, 8 ); + _header->setText ("[ERROR]"); + } else if ( contents.startsWith("[WARNING]")) { + contents.remove ( 0, 10 ); + _header->setText ("[WARNING]"); + } else + _header->setText ("[UNKNOW]"); + + _message->setText ( contents ); } diff --git a/hurricane/src/viewer/hurricane/viewer/CellViewer.h b/hurricane/src/viewer/hurricane/viewer/CellViewer.h index 22e34916..94b79ec8 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellViewer.h +++ b/hurricane/src/viewer/hurricane/viewer/CellViewer.h @@ -71,9 +71,10 @@ namespace Hurricane { QMenu* createDebugMenu (); inline void setEnableRedrawInterrupt ( bool ); inline void setApplicationName ( const QString& ); - void setCell ( Cell* ); Cell* getCell (); - virtual Cell* getCellFromDb ( const char* name ); + void setCell ( Cell* ); + void renameCell ( const char* ); + virtual Cell* getCellFromDb ( const char* ); inline CellWidget* getCellWidget (); inline ControllerWidget* getControllerWidget (); void select ( Occurrence& ); diff --git a/hurricane/src/viewer/hurricane/viewer/ExceptionWidget.h b/hurricane/src/viewer/hurricane/viewer/ExceptionWidget.h index d5e59248..3fc6e89e 100644 --- a/hurricane/src/viewer/hurricane/viewer/ExceptionWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/ExceptionWidget.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -36,16 +36,14 @@ namespace Hurricane { class ExceptionWidget : public QDialog { Q_OBJECT; - public: - ExceptionWidget ( QWidget* parent=NULL); - void setMessage ( const QString& ); - + ExceptionWidget ( QWidget* parent=NULL); + void setMessage ( const QString& ); private: - QLabel* _message; - + QLabel* _header; + QLabel* _message; protected: - virtual void closeEvent ( QCloseEvent* ); + virtual void closeEvent ( QCloseEvent* ); };