diff --git a/NEWS b/NEWS index c825a1ed..0dbd6be6 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,8 @@ files. Version 0.0.15 -------------- + * simulation time for digital files (Verilog and VHDL) now stored in + additional configuration file * Czech translation of the internal help system * new components: EPFL-EKV NMOS/PMOS V2.6, rectangular waveguide * new libraries added: PMOSFETs, NMOSFETs, Regulators, Varistors and diff --git a/qucs/ChangeLog b/qucs/ChangeLog index 3d642495..7bec7da4 100644 --- a/qucs/ChangeLog +++ b/qucs/ChangeLog @@ -1,3 +1,11 @@ +2008-08-06 Stefan Jahn + + * dialogs/digisettingsdialog.cpp (slotOk): Transfering digital + setting into the appropriate textdoc. + + * textdoc.cpp (saveSettings, loadSettings): Implemented load/save + functionality for digital setting (e.g. simulation time). + 2008-05-05 Stefan Jahn * qucs.cpp (saveAs): Using single directory variable for both Open diff --git a/qucs/dialogs/digisettingsdialog.cpp b/qucs/dialogs/digisettingsdialog.cpp index 0e8d6f15..d142adba 100644 --- a/qucs/dialogs/digisettingsdialog.cpp +++ b/qucs/dialogs/digisettingsdialog.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include "digisettingsdialog.h" #include "textdoc.h" @@ -48,7 +50,7 @@ DigiSettingsDialog::DigiSettingsDialog(TextDoc *Doc_) QButtonGroup *toggleGroup = new QButtonGroup(); simRadio = new QRadioButton(tr("Simulation"), setGroup); - simRadio->setChecked(true); + simRadio->setChecked(Doc->simulation); QHBox *hb1 = new QHBox(setGroup); hb1->setSpacing(5); @@ -67,12 +69,14 @@ DigiSettingsDialog::DigiSettingsDialog(TextDoc *Doc_) hb3->setSpacing(5); NameLabel = new QLabel(tr("Library Name:"), hb3); NameEdit = new QLineEdit(hb3); + NameEdit->setText(Doc->Library); setGroup->addSpace(15); QHBox *hb2 = new QHBox(setGroup); hb2->setSpacing(5); LibLabel = new QLabel(tr("Libraries:"), hb2); LibEdit = new QLineEdit(hb2); + LibEdit->setText(Doc->Libraries); all->addSpacing(5); all->addStretch(); @@ -83,6 +87,10 @@ DigiSettingsDialog::DigiSettingsDialog(TextDoc *Doc_) connect(ButtonOk, SIGNAL(clicked()), SLOT(slotOk())); connect(ButtonCancel, SIGNAL(clicked()), SLOT(reject())); + simRadio->setChecked(Doc->simulation); + comRadio->setChecked(!Doc->simulation); + slotChangeMode(!Doc->simulation); + ButtonOk->setDefault(true); setFocusProxy(TimeEdit); TimeEdit->setFocus(); @@ -107,9 +115,25 @@ void DigiSettingsDialog::slotOk() changed = true; } } + if(Doc->Libraries != LibEdit->text()) { + QStringList lst = QStringList::split(' ',LibEdit->text()); + Doc->Libraries = lst.join(" "); + changed = true; + } + if(Doc->simulation != simRadio->isChecked()) { + Doc->simulation = simRadio->isChecked(); + changed = true; + } + if(Doc->Libraries != NameEdit->text()) { + QString lib = NameEdit->text().stripWhiteSpace(); + Doc->Library = lib; + changed = true; + } - if(changed) + if(changed) { + Doc->SetChanged = true; Doc->slotSetChanged(); + } accept(); } diff --git a/qucs/main.cpp b/qucs/main.cpp index e81ed622..1c109062 100644 --- a/qucs/main.cpp +++ b/qucs/main.cpp @@ -110,7 +110,6 @@ bool saveApplSettings(QucsApp *qucs) return false; } - QString Line; QTextStream stream(&file); stream << "Settings file, Qucs " PACKAGE_VERSION "\n" diff --git a/qucs/textdoc.cpp b/qucs/textdoc.cpp index a851713c..90875f0b 100644 --- a/qucs/textdoc.cpp +++ b/qucs/textdoc.cpp @@ -43,6 +43,11 @@ TextDoc::TextDoc(QucsApp *App_, const QString& Name_) : QucsDoc(App_, Name_) setFont(TextFont); setCurrentFont(TextFont); + simulation = true; + Library = ""; + Libraries = ""; + SetChanged = false; + tmpPosX = tmpPosY = 1; // set to 1 to trigger line highlighting Scale = (float)TextFont.pointSize(); setUndoDepth(QucsSettings.maxUndo); @@ -77,6 +82,58 @@ TextDoc::~TextDoc() } } +// --------------------------------------------------- +bool TextDoc::saveSettings(void) +{ + QFile file(DocName + ".cfg"); + if(!file.open(IO_WriteOnly)) + return false; + + QTextStream stream(&file); + + stream << "VHDL settings file, Qucs " PACKAGE_VERSION "\n" + << "Simulation=" << simulation << "\n" + << "Duration=" << SimTime << "\n" + << "Module=" << (!simulation) << "\n" + << "Library=" << Library << "\n" + << "Libraries=" << Libraries << "\n"; + + file.close(); + SetChanged = false; + return true; +} + +// --------------------------------------------------- +bool TextDoc::loadSettings(void) +{ + QFile file(DocName + ".cfg"); + if(!file.open(IO_ReadOnly)) + return false; + + QTextStream stream(&file); + QString Line, Setting; + + bool ok; + while(!stream.atEnd()) { + Line = stream.readLine(); + Setting = Line.section('=',0,0); + Line = Line.section('=',1).stripWhiteSpace(); + if(Setting == "Simulation") { + simulation = Line.toInt(&ok); + } else if(Setting == "Duration") { + SimTime = Line; + } else if(Setting == "Module") { + } else if(Setting == "Library") { + Library = Line; + } else if(Setting == "Libraries") { + Libraries = Line; + } + } + + file.close(); + return true; +} + // --------------------------------------------------- void TextDoc::setName(const QString& Name_) { @@ -122,11 +179,9 @@ void TextDoc::slotCursorPosChanged(int x, int y) // --------------------------------------------------- void TextDoc::slotSetChanged() { - if(isModified()) { - if(!DocChanged) { - App->DocumentTab->setTabIconSet(this, QPixmap(smallsave_xpm)); - DocChanged = true; - } + if((isModified() && !DocChanged) || SetChanged) { + App->DocumentTab->setTabIconSet(this, QPixmap(smallsave_xpm)); + DocChanged = true; } else if(DocChanged) { App->DocumentTab->setTabIconSet(this, QPixmap(empty_xpm)); @@ -150,12 +205,16 @@ bool TextDoc::load() slotSetChanged(); file.close(); lastSaved = QDateTime::currentDateTime(); + + loadSettings(); return true; } // --------------------------------------------------- int TextDoc::save() { + saveSettings(); + QFile file(DocName); if(!file.open(IO_WriteOnly)) return -1; diff --git a/qucs/textdoc.h b/qucs/textdoc.h index def77b15..35724de6 100644 --- a/qucs/textdoc.h +++ b/qucs/textdoc.h @@ -48,6 +48,14 @@ public: void outcommmentSelected(); QFont TextFont; + bool simulation; // simulation or module + QString Library; // library this document belongs to + QString Libraries; // libraries to be linked with + bool SetChanged; + + bool loadSettings(void); + bool saveSettings(void); + public slots: void slotCursorPosChanged(int, int); void slotSetChanged();