28 #include <Q3SyntaxHighlighter>
61 #include "../qucs-lib/qucslib_common.h"
97 setCaption(
"Qucs " PACKAGE_VERSION);
102 tr(
"Schematic") +
" (*.sch);;" +
103 tr(
"Data Display") +
" (*.dpl);;" +
104 tr(
"Qucs Documents") +
" (*.sch *.dpl);;" +
105 tr(
"VHDL Sources") +
" (*.vhdl *.vhd);;" +
106 tr(
"Verilog Sources") +
" (*.v);;" +
107 tr(
"Verilog-A Sources") +
" (*.va);;" +
108 tr(
"Octave Scripts") +
" (*.m *.oct);;" +
110 tr(
"Any File")+
" (*)";
139 Printer =
new QPrinter(QPrinter::HighResolution);
140 #if defined (QT_VERSION) && QT_VERSION > 0x030200
141 Printer->setOptionEnabled(QPrinter::PrintSelection,
true);
142 Printer->setOptionEnabled(QPrinter::PrintPageRange,
false);
143 Printer->setOptionEnabled(QPrinter::PrintToFile,
true);
145 Printer->setColorMode(QPrinter::Color);
161 for(
int z=1; z<qApp->argc(); z++) {
162 QString arg = qApp->argv()[z];
227 setWindowIcon (QPixmap(
":/bitmaps/big.qucs.xpm"));
234 SIGNAL(currentChanged(QWidget*)), SLOT(
slotChangeView(QWidget*)));
241 #ifdef HAVE_QTABWIDGET_SETMOVABLE
247 dock =
new QDockWidget(
this);
250 TabView->setTabPosition(QTabWidget::West);
261 connect(
editText, SIGNAL(textChanged(
const QString&)),
267 QWidget *ProjGroup =
new QWidget();
268 QVBoxLayout *ProjGroupLayout =
new QVBoxLayout();
269 QWidget *ProjButts =
new QWidget();
270 QPushButton *ProjNew =
new QPushButton(tr(
"New"));
272 QPushButton *ProjOpen =
new QPushButton(tr(
"Open"));
274 QPushButton *ProjDel =
new QPushButton(tr(
"Delete"));
277 QHBoxLayout *ProjButtsLayout =
new QHBoxLayout();
278 ProjButtsLayout->addWidget(ProjNew);
279 ProjButtsLayout->addWidget(ProjOpen);
280 ProjButtsLayout->addWidget(ProjDel);
281 ProjButts->setLayout(ProjButtsLayout);
283 ProjGroupLayout->addWidget(ProjButts);
287 ProjGroupLayout->addWidget(
Projects);
288 ProjGroup->setLayout(ProjGroupLayout);
290 TabView->addTab(ProjGroup, tr(
"Projects"));
291 TabView->setTabToolTip(
TabView->indexOf(ProjGroup), tr(
"content of project directory"));
297 Content =
new QTreeWidget(
this);
300 headers << tr(
"Content of") << tr(
"Note");
301 Content->setHeaderLabels(headers);
302 Content->setSortingEnabled(
false);
303 Content->setColumnWidth(0,150);
306 Content->setContextMenuPolicy(Qt::CustomContextMenu);
314 connect(
Content, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,
int)),
317 connect(
Content, SIGNAL(itemPressed(QTreeWidgetItem*,
int)),
322 QWidget *CompGroup =
new QWidget();
323 QVBoxLayout *CompGroupLayout =
new QVBoxLayout();
327 CompComps->setViewMode(QListView::IconMode);
332 CompGroup->setLayout(CompGroupLayout);
334 TabView->addTab(CompGroup,tr(
"Components"));
335 TabView->setTabToolTip(
TabView->indexOf(CompGroup), tr(
"components and diagrams"));
346 QWidget *LibGroup =
new QWidget ();
347 QVBoxLayout *LibGroupLayout =
new QVBoxLayout ();
348 QWidget *LibButts =
new QWidget ();
349 QPushButton *LibManage =
new QPushButton (tr (
"Manage Libraries"));
352 QHBoxLayout *LibButtsLayout =
new QHBoxLayout();
353 LibButtsLayout->addWidget (LibManage);
354 LibButts->setLayout(LibButtsLayout);
356 LibGroupLayout->addWidget(LibButts);
362 headers << tr (
"Libraries");
366 LibGroup->setLayout (LibGroupLayout);
370 TabView->addTab (LibGroup, tr(
"Libraries"));
371 TabView->setTabToolTip (
TabView->indexOf (CompGroup), tr (
"system and user component libraries"));
373 connect(
libTreeWidget, SIGNAL(itemPressed (QTreeWidgetItem*,
int)),
379 dock->setAllowedAreas(Qt::LeftDockWidgetArea);
380 this->addDockWidget(Qt::LeftDockWidgetArea,
dock);
391 this->addDockWidget(Qt::BottomDockWidgetArea,
octDock);
392 this->setCorner(Qt::BottomLeftCorner , Qt::LeftDockWidgetArea);
406 QStringList LibFiles;
407 QStringList::iterator it;
408 QList<QTreeWidgetItem *> topitems;
413 QTreeWidgetItem* newitem =
new QTreeWidgetItem((QTreeWidget*)0, QStringList(
"System Libraries"));
414 newitem->setChildIndicatorPolicy (QTreeWidgetItem::DontShowIndicator);
415 QFont sectionFont = newitem->font(0);
416 sectionFont.setItalic (
true);
417 sectionFont.setBold (
true);
418 newitem->setFont (0, sectionFont);
420 topitems.append (newitem);
423 LibFiles = LibDir.entryList(QStringList(
"*.lib"), QDir::Files, QDir::Name);
426 for(it = LibFiles.begin(); it != LibFiles.end(); it++)
428 ComponentLibrary parsedlibrary;
431 QStringList nameAndFileName;
432 nameAndFileName.append (parsedlibrary.name);
435 QTreeWidgetItem* newlibitem =
new QTreeWidgetItem((QTreeWidget*)0, nameAndFileName);
439 case QUCS_COMP_LIB_IO_ERROR:
440 QMessageBox::critical(0, tr (
"Error"), tr(
"Cannot open \"%1\".").arg (*it));
442 case QUCS_COMP_LIB_CORRUPT:
443 QMessageBox::critical(0, tr(
"Error"), tr(
"Library is corrupt."));
449 for (
int i = 0; i < parsedlibrary.components.count (); i++)
451 QStringList compNameAndDefinition;
453 compNameAndDefinition.append (parsedlibrary.components[i].name);
455 QString s =
"<Qucs Schematic " PACKAGE_VERSION
">\n";
457 s +=
"<Components>\n " +
458 parsedlibrary.components[i].modelString +
"\n" +
461 compNameAndDefinition.append (s);
465 QTreeWidgetItem* newcompitem =
new QTreeWidgetItem(newlibitem, compNameAndDefinition);
468 topitems.append (newlibitem);
473 newitem =
new QTreeWidgetItem((QTreeWidget*)0, QStringList(
"User Libraries"));
474 newitem->setChildIndicatorPolicy (QTreeWidgetItem::DontShowIndicator);
475 newitem->setFont (0, sectionFont);
476 topitems.append (newitem);
481 if(UserLibDir.exists ())
484 LibFiles = UserLibDir.entryList(QStringList(
"*.lib"), QDir::Files, QDir::Name);
485 int UserLibCount = LibFiles.count();
487 if (UserLibCount > 0)
491 for(it = LibFiles.begin(); it != LibFiles.end(); it++)
493 ComponentLibrary parsedlibrary;
495 int result = parseComponentLibrary (UserLibDir.absolutePath() +
"/"+ *it , parsedlibrary);
496 QStringList nameAndFileName;
497 nameAndFileName.append (parsedlibrary.name);
498 nameAndFileName.append (UserLibDir.absolutePath() +
"/"+ *it);
500 QTreeWidgetItem* newlibitem =
new QTreeWidgetItem((QTreeWidget*)0, nameAndFileName);
504 case QUCS_COMP_LIB_IO_ERROR:
505 QMessageBox::critical(0, tr (
"Error"), tr(
"Cannot open \"%1\".").arg (UserLibDir.absolutePath()+
"/" +*it));
507 case QUCS_COMP_LIB_CORRUPT:
508 QMessageBox::critical(0, tr(
"Error"), tr(
"Library is corrupt."));
514 for (
int i = 0; i < parsedlibrary.components.count (); i++)
516 QStringList compNameAndDefinition;
518 compNameAndDefinition.append (parsedlibrary.components[i].name);
520 QString s =
"<Qucs Schematic " PACKAGE_VERSION
">\n";
522 s +=
"<Components>\n " +
523 parsedlibrary.components[i].modelString +
"\n" +
526 compNameAndDefinition.append (s);
530 QTreeWidgetItem* newcompitem =
new QTreeWidgetItem(newlibitem, compNameAndDefinition);
533 topitems.append (newlibitem);
540 newitem =
new QTreeWidgetItem((QTreeWidget*)0, QStringList(
"No User Libraries"));
541 sectionFont.setBold (
false);
542 newitem->setFont (0, sectionFont);
543 topitems.append (newitem);
549 newitem =
new QTreeWidgetItem((QTreeWidget*)0, QStringList(
"No User Libraries"));
550 sectionFont.setBold (
false);
551 newitem->setFont (0, sectionFont);
552 topitems.append (newitem);
586 File = QDir::convertSeparators (File);
587 while ((d =
getDoc (No++)) != 0)
588 if (QDir::convertSeparators (d->
DocName) == File) {
589 if (Pos) *Pos = No - 1;
607 for (QStringList::Iterator it = cats.begin (); it != cats.end (); ++it) {
611 if (*it == QObject::tr(
"paintings"))
625 Q3PtrList<Module> Comps;
641 if (item == QObject::tr(
"paintings"))
655 if (item == QObject::tr(
"verilog-a user devices")) {
657 QListWidgetItem *icon;
659 while (i.hasNext()) {
666 QString Name, vaBitmap;
674 QFile iconFile(iconPath);
677 if(iconFile.exists())
680 vaIcon = QPixmap(iconPath);
684 QMessageBox::information(
this, tr(
"Info"),
685 tr(
"Default icon not found:\n %1.png").arg(vaBitmap));
687 vaIcon = QPixmap(
":/bitmaps/editdelete.png");
691 icon =
new QListWidgetItem(vaIcon, Name);
692 icon->setToolTip(Name);
700 for (Mod = Comps.first(); Mod; Mod = Comps.next ()) {
702 *(Mod->
info) (Name, File,
false);
703 QListWidgetItem *icon =
new QListWidgetItem(QPixmap(
":/bitmaps/" + QString (File) +
".png"), Name);
704 icon->setToolTip(Name);
727 ((Q3ScrollView*)
DocumentTab->currentPage())->viewport()->update();
748 Q3PtrList<Module> Comps;
751 if (
CompChoose->currentText() == QObject::tr(
"paintings"))
755 qDebug() <<
"pressed CompComps id" << i;
756 qDebug() <<
CompComps->item(i)->toolTip();
761 if (
CompChoose->currentText() == QObject::tr(
"verilog-a user devices")){
762 InfosVA = Comps.at(i)->infoVA;
765 QString name =
CompComps->item(i)->toolTip();
771 qDebug() <<
" slotSelectComponent, view->selElem" ;
772 view->
selElem = (*InfosVA) (Dummy1, Dummy2,
true, filename);
777 Infos = Comps.at(i)->info;
831 QTreeWidgetItem *item =
Content->currentItem();
832 if(item->text(1 ).contains(tr(
"-port")))
842 if(item->parent()!= 0) {
863 QTreeWidgetItem *Item =
Content->currentItem();
864 if(Item == 0)
return;
872 QTreeWidgetItem *Item =
Content->currentItem();
873 if(Item == 0)
return;
875 QString Name = Item->text(0);
877 QString Path = currentPath.section(QDir::separator(), 0, -2);
884 int ret = QMessageBox::question(
this, tr(
"Copying Qucs document"),
885 tr(
"The document contains unsaved changes!\n") +
886 tr(
"Do you want to save the changes before copying?"),
887 tr(
"&Ignore"), tr(
"&Save"), 0, 1);
893 QString Suffix = Name.section(
'.',-1);
894 QString Base = Name.section(
'.',0,-2);
895 if(Base.isEmpty()) Base = Name;
902 defaultName = Base +
"_copy" + QString::number(i) +
"." + Suffix;
903 exists = QFile::exists (Path + QDir::separator() + defaultName);
907 QString s = QInputDialog::getText(tr(
"Copy file"), tr(
"Enter new name:"),
908 QLineEdit::Normal, defaultName, &ok,
this);
910 if(s.isEmpty())
return;
916 NewName = s+
"."+Suffix;
918 if (QFile::exists(Path + QDir::separator() + NewName)) {
919 QMessageBox::critical(
this, tr(
"error"), tr(
"Cannot copy file to identical name: ") + Name);
923 if (!QFile::copy(Path + QDir::separator() + Name,
924 Path + QDir::separator() + NewName)) {
925 QMessageBox::critical(
this, tr(
"Error"), tr(
"Cannot copy schematic: ")+Name);
941 QTreeWidgetItem *Item =
Content->currentItem();
944 QString Name = Item->text(0);
946 QMessageBox::critical(
this, tr(
"Error"),
947 tr(
"Cannot rename an open file!"));
951 QString Suffix = Name.section(
'.',-1);
952 QString Base = Name.section(
'.',0,-2);
953 if(Base.isEmpty()) Base = Name;
956 QString s = QInputDialog::getText(tr(
"Rename file"), tr(
"Enter new name:"),
957 QLineEdit::Normal, Base, &ok,
this);
959 if(s.isEmpty())
return;
965 NewName = s+
"."+Suffix;
967 if(!file.rename(Name, NewName)) {
968 QMessageBox::critical(
this, tr(
"Error"), tr(
"Cannot rename file: ")+Name);
971 Item->setText(0, NewName);
977 QTreeWidgetItem *item =
Content->currentItem();
978 if(item == 0)
return;
982 QMessageBox::critical(
this, tr(
"Error"),
983 tr(
"Cannot delete an open file!"));
988 No = QMessageBox::warning(
this, tr(
"Warning"),
989 tr(
"This will delete the file permanently! Continue ?"),
990 tr(
"No"), tr(
"Yes"));
993 if(!QFile::remove(FileName)) {
994 QMessageBox::critical(
this, tr(
"Error"),
995 tr(
"Cannot delete schematic: ")+item->text(0));
1005 QString Type = tr(
"unknown");
1007 Type = tr(
"Verilog source");
1008 else if (Ext ==
"va")
1009 Type = tr(
"Verilog-A source");
1010 else if (Ext ==
"vhd" || Ext ==
"vhdl")
1011 Type = tr(
"VHDL source");
1012 else if (Ext ==
"dat")
1013 Type = tr(
"data file");
1014 else if (Ext ==
"dpl")
1015 Type = tr(
"data display");
1016 else if (Ext ==
"sch")
1017 Type = tr(
"schematic");
1018 else if (Ext ==
"sym")
1019 Type = tr(
"symbol");
1020 else if (Ext ==
"vhdl.cfg" || Ext ==
"vhd.cfg")
1021 Type = tr(
"VHDL configuration");
1022 else if (Ext ==
"cfg")
1023 Type = tr(
"configuration");
1032 QTreeWidgetItem *item =
Content->currentItem();
1035 QString s = item->text (0);
1038 const char * extensions[] =
1039 {
"sch",
"dpl",
"dat",
"vhdl",
"vhd",
"v",
"sym",
1040 "vhdl.cfg",
"vhd.cfg",
"va", 0 };
1043 for (i = 0; extensions[i] != 0; i++) {
1044 QString Short = s +
"." + extensions[i];
1048 QMessageBox::critical(
this, tr(
"Error"), tr(
"Cannot delete the open file \"%1\"!").arg(Short));
1057 for (i = 0; extensions[i] != 0; i++) {
1058 QString Short = s +
"." + extensions[i];
1060 bool exists = QFile::exists (Long);
1062 Str += Short +
"\n";
1065 No = QMessageBox::warning (
this, tr(
"Warning"),
1066 tr(
"This will delete the files%1permanently! Continue ?").arg(Str),
1067 tr(
"No"), tr(
"Yes"));
1072 for (i = 0; extensions[i] != 0; i++) {
1073 QString Short = s +
"." + extensions[i];
1075 bool exists = QFile::exists (Name);
1078 if (!QFile::remove (Name)) {
1079 QMessageBox::critical(
this, tr(
"Error"), tr(
"Cannot delete %1: \"%2\"!").arg(
fileType (extensions[i])).
1112 QMessageBox::warning(
this, tr(
"Warning"),
1113 tr(
"Cannot create work directory !"));
1120 QStringList PrDirs = ProjDir.entryList(
"*", QDir::Dirs, QDir::Name);
1125 QStringList::iterator it;
1127 for(it = PrDirs.begin(); it != PrDirs.end(); it++)
1128 if ((*it).right(4) ==
"_prj") {
1129 (*it) = (*it).left((*it).length()-4);
1141 if(d->exec() != QDialog::Accepted)
return;
1144 if(projDir.mkdir(d->
ProjName->text()+
"_prj")) {
1149 else QMessageBox::information(
this, tr(
"Info"),
1150 tr(
"Cannot create project directory !"));
1158 QFile file(DocName);
1159 if(!file.open(QIODevice::ReadOnly)) {
1167 QTextStream ReadWhole(&file);
1168 QString FileString = ReadWhole.read();
1170 QTextStream stream(&FileString, QIODevice::ReadOnly);
1175 if(stream.atEnd()) {
1179 Line = stream.readLine();
1180 Line = Line.stripWhiteSpace();
1181 }
while(Line.isEmpty());
1183 if(Line.left(16) !=
"<Qucs Schematic ") {
1188 Line = Line.mid(16, Line.length()-17);
1199 while(!stream.atEnd()) {
1200 Line = stream.readLine();
1201 if(Line ==
"<Components>")
break;
1205 while(!stream.atEnd()) {
1206 Line = stream.readLine();
1207 if(Line ==
"</Components>") {
1212 Line = Line.stripWhiteSpace();
1213 QString s = Line.section(
' ',0,0);
1214 if(s ==
"<Port") z++;
1250 QStringList::iterator it;
1253 for(it = Elements.begin(); it != Elements.end(); ++it) {
1260 temp->setText(0, (*it).ascii());
1261 temp->setText(1, QString::number(n)+tr(
"-port"));
1265 temp->setText(0, (*it).ascii());
1269 else if(Str ==
"dpl") {
1270 QTreeWidgetItem *temp =
new QTreeWidgetItem(
ConDisplays);
1271 temp->setText(0, (*it).ascii());
1273 else if(Str ==
"dat") {
1274 QTreeWidgetItem *temp =
new QTreeWidgetItem(
ConDatasets);
1275 temp->setText(0, (*it).ascii());
1277 else if((Str ==
"vhdl") || (Str ==
"vhd")) {
1278 QTreeWidgetItem *temp =
new QTreeWidgetItem(
ConSources);
1279 temp->setText(0, (*it).ascii());
1281 else if(Str ==
"v") {
1282 QTreeWidgetItem *temp =
new QTreeWidgetItem(
ConVerilog);
1283 temp->setText(0, (*it).ascii());
1285 else if(Str ==
"va") {
1286 QTreeWidgetItem *temp =
new QTreeWidgetItem(
ConVerilogA);
1287 temp->setText(0, (*it).ascii());
1289 else if((Str ==
"m") || (Str ==
"oct")) {
1290 QTreeWidgetItem *temp =
new QTreeWidgetItem(
ConOctave);
1291 temp->setText(0, (*it).ascii());
1294 QTreeWidgetItem *temp =
new QTreeWidgetItem(
ConOthers);
1295 temp->setText(0, (*it).ascii());
1312 QDir ProjDir(QDir::cleanDirPath(Path));
1313 if(!ProjDir.exists() || !ProjDir.isReadable()) {
1314 QMessageBox::critical(
this, tr(
"Error"),
1315 tr(
"Cannot access project directory: ")+Path);
1321 QStringList headers;
1322 headers << tr(
"Content of ") + Name << tr(
"Note");
1323 Content->setHeaderLabels(headers);
1331 setCaption(
"Qucs " PACKAGE_VERSION + tr(
" - Project: ")+Name);
1338 QString d = QFileDialog::getExistingDirectory(
this, tr(
"Choose Project Directory for Opening"),
1340 QFileDialog::ShowDirsOnly
1341 | QFileDialog::DontResolveSymlinks);
1343 if(s.isEmpty())
return;
1345 s = s.left(s.length()-1);
1346 int i = s.findRev(
'/');
1347 if(i > 0) s = s.mid(i+1);
1358 QListWidgetItem *item =
Projects->currentItem();
1360 else QMessageBox::information(
this, tr(
"Info"),
1361 tr(
"No project is selected !"));
1382 setCaption(
"Qucs " PACKAGE_VERSION + tr(
" - Project: "));
1386 QStringList headers;
1387 headers << tr(
"Content of") << tr(
"Note");
1388 Content->setHeaderLabels(headers);
1400 QStringList Files = Dir.entryList(
"*", QDir::Files|QDir::Hidden);
1401 QStringList::iterator it;
1402 for(it = Files.begin(); it != Files.end(); it++) {
1403 if(!Dir.remove(*it)) {
1404 QMessageBox::information(
this, tr(
"Info"),
1405 tr(
"Cannot delete file: ")+(*it));
1412 Files = Dir.entryList(
"*", QDir::Dirs);
1415 for(it = Files.begin(); it != Files.end(); it++) {
1420 if(!myDir.rmdir(*it)) {
1421 QMessageBox::information(
this, tr(
"Info"),
1422 tr(
"Cannot remove directory: ")+(*it));
1435 QMessageBox::information(
this, tr(
"Info"),
1436 tr(
"Cannot delete an open project !"));
1441 if(QMessageBox::warning(
this, tr(
"Warning"),
1442 tr(
"This will destroy all the project files permanently ! Continue ?"),
1443 tr(
"&Yes"), tr(
"&No"), 0,1,1))
return false;
1445 QDir projDir = QDir(Path);
1450 if(!projDir.rmdir(Name+
"_prj")) {
1451 QMessageBox::information(
this, tr(
"Info"),
1452 tr(
"Cannot remove project directory !"));
1464 QString d = QFileDialog::getExistingDirectory(
this, tr(
"Choose Project Directory for Deleting"),
1466 QFileDialog::ShowDirsOnly
1467 | QFileDialog::DontResolveSymlinks);
1470 if(s.isEmpty())
return;
1472 if (s.endsWith(QDir::separator())) {
1473 s = s.left(s.length()-1);
1475 int i = s.findRev(QDir::separator());
1476 if(i > 0) s = s.mid(i+1);
1486 QListWidgetItem *item =
Projects->currentItem();
1488 QMessageBox::information(
this, tr(
"Info"),
1489 tr(
"No project is selected !"));
1494 item->text()))
return;
1506 statusBar()->message(tr(
"Creating new schematic..."));
1511 statusBar()->message(tr(
"Ready."));
1517 statusBar()->message(tr(
"Creating new text editor..."));
1521 statusBar()->message(tr(
"Ready."));
1540 QFileInfo Info(Name);
1541 if(Info.extension(
false) ==
"sch" || Info.extension(
false) ==
"dpl" ||
1542 Info.extension(
false) ==
"sym")
1571 statusBar()->message(tr(
"Opening file..."));
1573 QString s = QFileDialog::getOpenFileName(
this, tr(
"Enter a Schematic Name"),
1577 statusBar()->message(tr(
"Opening aborted"), 2000);
1590 statusBar()->message(tr(
"Ready."));
1603 int Result = Doc->
save();
1604 if(Result < 0)
return false;
1613 statusBar()->message(tr(
"Saving file..."));
1619 statusBar()->message(tr(
"Saving aborted"), 2000);
1620 statusBar()->message(tr(
"Ready."));
1625 statusBar()->message(tr(
"Ready."));
1638 bool intoView =
true;
1654 QString ext =
"vhdl;vhd;v;va;sch;dpl;m;oct;net;qnet;txt";
1655 QStringList extlist = QStringList::split (
';', ext);
1658 Filter = tr(
"VHDL Sources")+
" (*.vhdl *.vhd);;" +
1659 tr(
"Verilog Sources")+
" (*.v);;"+
1660 tr(
"Verilog-A Sources")+
" (*.va);;"+
1661 tr(
"Octave Scripts")+
" (*.m *.oct);;"+
1662 tr(
"Qucs Netlist")+
" (*.net *.qnet);;"+
1663 tr(
"Plain Text")+
" (*.txt);;"+
1664 tr(
"Any File")+
" (*)";
1668 s = QFileDialog::getSaveFileName(
this, tr(
"Enter a Document Name"),
1671 if(s.isEmpty())
return false;
1673 ext = Info.extension(
false);
1675 if(ext.isEmpty() || !extlist.contains(ext))
1686 if(QFile::exists(s)) {
1687 n = QMessageBox::warning(
this, tr(
"Warning"),
1688 tr(
"The file '")+Info.fileName()+tr(
"' already exists!\n")+
1689 tr(
"Saving will overwrite the old one! Continue?"),
1690 tr(
"No"), tr(
"Yes"), tr(
"Cancel"));
1691 if(n == 2)
return false;
1692 if(n == 0)
continue;
1699 QMessageBox::information(
this, tr(
"Info"),
1700 tr(
"Cannot overwrite an open document"));
1712 s = Info.fileName();
1713 QString ext = Info.extension (
false);
1736 if(n < 0)
return false;
1745 statusBar()->message(tr(
"Saving file under new filename..."));
1751 statusBar()->message(tr(
"Saving aborted"), 3000);
1752 statusBar()->message(tr(
"Ready."));
1757 statusBar()->message(tr(
"Ready."));
1771 statusBar()->message(tr(
"Saving all files..."));
1777 while((Doc=
getDoc(No++)) != 0) {
1786 QString tabType =
DocumentTab->currentWidget()->className();
1787 if (tabType ==
"Schematic") {
1788 ((Q3ScrollView*)
DocumentTab->currentPage())->viewport()->update();
1791 statusBar()->message(tr(
"Ready."));
1820 statusBar()->message(tr(
"Closing file..."));
1825 switch(QMessageBox::warning(
this,tr(
"Closing Qucs document"),
1826 tr(
"The document contains unsaved changes!\n")+
1827 tr(
"Do you want to save the changes before closing?"),
1828 tr(
"&Save"), tr(
"&Discard"), tr(
"Cancel"), 0, 2)) {
1840 statusBar()->message(tr(
"Ready."));
1856 Result = sd->exec();
1861 while((doc =
getDoc()) != 0)
1872 statusBar()->message(tr(
"Open examples directory..."));
1874 QDesktopServices::openUrl(QUrl(
"file:///" + path.replace(
"\\",
"/")));
1875 statusBar()->message(tr(
"Ready."));
1881 QUrl url = QUrl(
"file:///" + path.replace(
"\\",
"/") +
"tutorial/" + QObject::sender()->objectName());
1882 QDesktopServices::openUrl(url);
1888 QUrl url = QUrl(
"file:///" + path.replace(
"\\",
"/") +
"technical/" + QObject::sender()->objectName());
1889 QDesktopServices::openUrl(url);
1895 QUrl url = QUrl(
"file:///" + path.replace(
"\\",
"/") +
"report/" + QObject::sender()->objectName());
1896 QDesktopServices::openUrl(url);
1914 magAll->setDisabled(
true);
1922 magAll->setDisabled(
false);
1941 popH->setEnabled(
false);
1968 if (ext ==
"m" || ext ==
"oct") {
1971 else if (ext ==
"va") {
2007 msgBox.setText(
"The schematic file path has been refreshed.");
2019 QFileInfo Info (pathName);
2020 QString Model, File, Name = Info.fileName();
2031 if(p->text(0) == Name) {
2032 if(No == 0) p->setText(1,
"");
2033 else p->setText(1,QString::number(No)+tr(
"-port"));
2038 else if (ext ==
"vhdl" || ext ==
"vhd") {
2041 else if (ext ==
"v") {
2055 if(pc->Model == Model) {
2056 File = pc->Props.getFirst()->Value;
2057 if((File == pathName) || (File == Name)) {
2076 statusBar()->message(tr(
"Printing..."));
2082 QPlainTextEdit *temp = (QPlainTextEdit*)w;
2084 QPrintDialog *dialog =
new QPrintDialog(
Printer,
this);
2085 dialog->setWindowTitle(tr(
"Print Document"));
2086 dialog->addEnabledOption(QAbstractPrintDialog::PrintSelection);
2087 if (dialog->exec() == QDialog::Accepted)
2093 Printer->setOrientation(QPrinter::Landscape);
2100 if(!Painter.device())
2103 for(
int z=
Printer->numCopies(); z>0 ; z--) {
2108 Printer->printRange() == QPrinter::AllPages, fitToPage);
2115 statusBar()->message(tr(
"Ready."));
2119 statusBar()->message(tr(
"Printer Error."));
2139 statusBar()->message(tr(
"Exiting application..."));
2142 int exit = QMessageBox::information(
this,
2143 tr(
"Quit..."), tr(
"Do you really want to quit?"),
2144 tr(
"Yes"), tr(
"No"));
2152 statusBar()->message(tr(
"Ready."));
2159 qDebug()<<
"x"<<pos().x()<<
" ,y"<<pos().y();
2160 qDebug()<<
"dx"<<size().width()<<
" ,dy"<<size().height();
2179 statusBar()->message(tr(
"Cutting selection..."));
2183 ((
TextDoc*)Doc)->viewport()->setFocus();
2189 QClipboard *cb = QApplication::clipboard();
2193 cb->setText(s, QClipboard::Clipboard);
2194 Doc->viewport()->update();
2197 statusBar()->message(tr(
"Ready."));
2203 statusBar()->message(tr(
"Copying selection to clipboard..."));
2207 ((
TextDoc*)Doc)->viewport()->setFocus();
2213 QClipboard *cb = QApplication::clipboard();
2217 cb->setText(s, QClipboard::Clipboard);
2219 statusBar()->message(tr(
"Ready."));
2232 QString *ps =
new QString(
"*");
2242 popH->setEnabled(
true);
2263 popH->setEnabled(
false);
2303 if(d->exec() == QDialog::Rejected)
2316 if(Doc->
lastSaved < Info.lastModified()) {
2317 int No = QMessageBox::warning(
this, tr(
"Warning"),
2318 tr(
"The document was modified by another program !") +
'\n' +
2319 tr(
"Do you want to reload or keep this version ?"),
2320 tr(
"Reload"), tr(
"Keep it"));
2328 if(Info.extension(
false) ==
"m" || Info.extension(
false) ==
"oct") {
2340 connect(sim, SIGNAL(SimulationEnded(
int,
SimMessage*)),
this,
2342 connect(sim, SIGNAL(displayDataPage(QString&, QString&)),
2356 if(Status != 0)
return;
2358 if(sim->
ErrText->document()->lineCount() > 1)
2416 if(DataDisplay.isEmpty())
return;
2418 QFileInfo Info(DocName);
2419 QString Name = Info.dirPath() + QDir::separator() + DataDisplay;
2430 if (ext !=
"vhd" && ext !=
"vhdl" && ext !=
"v" && ext !=
"va" &&
2431 ext !=
"oct" && ext !=
"m")
2437 if(file.open(QIODevice::ReadOnly)) {
2446 if(file.open(QIODevice::ReadWrite)) {
2448 QTreeWidgetItem *temp =
new QTreeWidgetItem(
ConDisplays);
2449 temp->setText(0,DataDisplay);
2453 QMessageBox::critical(
this, tr(
"Error"), tr(
"Cannot create ")+Name);
2468 if (Name.right(4) ==
".dpl") {
2481 QMessageBox::critical(
this, tr(
"Error"), tr(
"No page set !"));
2485 if(d->
DocName.right(2) ==
".m" ||
2486 d->
DocName.right(4) ==
".oct")
2498 if(item == 0)
return;
2499 if(item->parent() == 0)
return;
2512 QString Suffix = Info.extension(
false);
2514 if (Suffix ==
"sch" || Suffix ==
"dpl" || Suffix ==
"vhdl" ||
2515 Suffix ==
"vhd" || Suffix ==
"v" || Suffix ==
"va" ||
2516 Suffix ==
"m" || Suffix ==
"oct") {
2521 if(item->text(1).isEmpty())
2522 if(Suffix ==
"sch")
return;
2524 select->blockSignals(
true);
2526 select->blockSignals(
false);
2536 if(Suffix ==
"dat") {
2547 if(Suffix == (*it).section(
'/',0,0)) {
2548 com = QStringList::split(
" ", (*it).section(
'/',1,1));
2549 com << Info.absFilePath();
2550 QProcess *Program =
new QProcess();
2552 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
2553 env.insert(
"PATH", env.value(
"PATH") );
2554 Program->setProcessEnvironment(env);
2555 Program->start(com.join(
" "));
2556 if(Program->state()!=QProcess::Running&&
2557 Program->state()!=QProcess::Starting) {
2558 QMessageBox::critical(
this, tr(
"Error"),
2559 tr(
"Cannot start \"%1\"!").arg(Info.absFilePath()));
2583 bool isVHDL =
false;
2584 bool isVerilog =
false;
2585 if(item->parent() == 0)
return;
2586 if(item->parent()->text(0) == tr(
"Schematics")) {
2587 if(item->text(1).isEmpty())
2590 else if(item->parent()->text(0) == tr(
"VHDL"))
2592 else if(item->parent()->text(0) == tr(
"Verilog"))
2616 Comp->
Props.first()->Value = item->text(0);
2621 ((Q3ScrollView*)
DocumentTab->currentPage())->viewport()->update();
2638 if(!Doc->inherits(
"QPlainTextEdit"))
2650 if(item->parent() == 0)
return;
2652 if(item->text(1).isEmpty())
return;
2655 QClipboard *cb = QApplication::clipboard();
2656 cb->setText(item->text(1));
2673 cursorUp->setEnabled(SchematicMode);
2677 if (!SchematicMode) {
2684 select->blockSignals (
true);
2686 select->blockSignals (
false);
2697 alignTop->setEnabled (SchematicMode);
2703 distrHor->setEnabled (SchematicMode);
2705 onGrid->setEnabled (SchematicMode);
2706 moveText->setEnabled (SchematicMode);
2711 intoH->setEnabled (SchematicMode);
2712 popH->setEnabled (SchematicMode);
2713 dcbias->setEnabled (SchematicMode);
2714 insWire->setEnabled (SchematicMode);
2715 insLabel->setEnabled (SchematicMode);
2716 insPort->setEnabled (SchematicMode);
2723 editFind->setEnabled (!SchematicMode);
2736 intoH->setEnabled(SchematicMode);
2737 popH->setEnabled(SchematicMode);
2742 insPort->setEnabled(SchematicMode);
2743 insWire->setEnabled(SchematicMode);
2744 insLabel->setEnabled(SchematicMode);
2747 simulate->setEnabled(SchematicMode);
2765 if (w->inherits(
"QPlainTextEdit"))
2782 QFileInfo Info(TDoc->
DocName);
2783 QString sym = Info.baseName(
true)+
".sym";
2804 SDoc->viewport()->update();
2811 if(SDoc->
DocName.right(4) ==
".sym") {
2820 SDoc->viewport()->update();
2844 Dia->
S11degEdit->setText(QString::number(Imag));
2848 if(Dia->exec() != QDialog::Accepted)
2862 if(z <= 0) DataSet = Doc->DataSet;
2863 else DataSet = pm->
pGraph->
Var.mid(z+1);
2864 double Freq = pm->
VarPos[0];
2866 QFileInfo Info(Doc->DocName);
2867 DataSet = Info.dirPath()+QDir::separator()+DataSet;
2874 QMessageBox::critical(0, tr(
"Error"), tr(
"Could not load S[1,1]."));
2878 pg =
new Graph(
"S[1,2]");
2881 QMessageBox::critical(0, tr(
"Error"), tr(
"Could not load S[1,2]."));
2885 pg =
new Graph(
"S[2,1]");
2888 QMessageBox::critical(0, tr(
"Error"), tr(
"Could not load S[2,1]."));
2892 pg =
new Graph(
"S[2,2]");
2895 QMessageBox::critical(0, tr(
"Error"), tr(
"Could not load S[2,2]."));
2899 DataX *Data = Diag->
Graphs.getFirst()->cPointsX.first();
2900 if(Data->
Var !=
"frequency") {
2901 QMessageBox::critical(0, tr(
"Error"), tr(
"Wrong dependency!"));
2905 double *Value = Data->
Points;
2907 for(z=0; z<Data->
count; z++)
2908 if(*(Value++) == Freq)
break;
2911 double S11real = *(Diag->
Graphs.first()->cPointsY + 2*z);
2912 double S11imag = *(Diag->
Graphs.current()->cPointsY + 2*z + 1);
2913 double S12real = *(Diag->
Graphs.next()->cPointsY + 2*z);
2914 double S12imag = *(Diag->
Graphs.current()->cPointsY + 2*z + 1);
2915 double S21real = *(Diag->
Graphs.next()->cPointsY + 2*z);
2916 double S21imag = *(Diag->
Graphs.current()->cPointsY + 2*z + 1);
2917 double S22real = *(Diag->
Graphs.next()->cPointsY + 2*z);
2918 double S22imag = *(Diag->
Graphs.current()->cPointsY + 2*z + 1);
2925 Dia->
S11magEdit->setText(QString::number(S11real));
2926 Dia->
S11degEdit->setText(QString::number(S11imag));
2927 Dia->
S12magEdit->setText(QString::number(S12real));
2928 Dia->
S12degEdit->setText(QString::number(S12imag));
2929 Dia->
S21magEdit->setText(QString::number(S21real));
2930 Dia->
S21degEdit->setText(QString::number(S21imag));
2931 Dia->
S22magEdit->setText(QString::number(S22real));
2932 Dia->
S22degEdit->setText(QString::number(S22imag));
2935 if(Dia->exec() != QDialog::Accepted)
2970 QStringList nameFilter;
2971 nameFilter <<
"*.sch";
2977 QDir thispath(qucspath);
2979 QFileInfoList schfilesList = thispath.entryInfoList( nameFilter, QDir::Files );
2982 foreach (QFileInfo schfile, schfilesList) {
2983 QString bn = schfile.completeBaseName();
2984 schNameHash[schfile.completeBaseName()] = schfile.absoluteFilePath();
2990 QFileInfoList schfilesList = thispath.entryInfoList( nameFilter, QDir::Files );
2993 foreach (QFileInfo schfile, schfilesList) {
2994 schNameHash[schfile.completeBaseName()] = schfile.absoluteFilePath();
3003 QString spexts =
" (";
3035 QDir thispath(qucspath);
3037 QFileInfoList spicefilesList = thispath.entryInfoList(
spiceExtensions, QDir::Files );
3040 foreach (QFileInfo spicefile, spicefilesList) {
3041 QString bn = spicefile.completeBaseName();
3042 schNameHash[spicefile.completeBaseName()] = spicefile.absoluteFilePath();
3048 QFileInfoList spicefilesList = thispath.entryInfoList(
spiceExtensions, QDir::Files );
3051 foreach (QFileInfo spicefile, spicefilesList) {
3052 spiceNameHash[spicefile.completeBaseName()] = spicefile.absoluteFilePath();
3062 while (i.hasNext()) {
3064 QDir thispath(i.value());
3065 if (!thispath.exists())
3080 foreach(QString path, newPathList)
3091 QSettings* settings =
new QSettings(
"qucs",
"qucs");
3116 const int bourder = 30;
3119 xmin, ymin, xmin_sel, ymin_sel;
3129 if ((wsel==(bourder+1))&&(hsel==(bourder+1))) noselect =
true;
3130 else noselect =
false;
3154 scal = (float) dlg->
Xpixels()/w;
3162 if (!dlg->
isSvg()) {
3174 QPainter* p =
new QPainter(img);
3175 p->fillRect(0,0,w,h,Qt::white);
3177 vp->
init(p,scal,0,0,xmin*scal-bourder/2,ymin*scal-bourder/2,scal,scal);
3181 img->save(filename);
3187 QSvgGenerator* svg1 =
new QSvgGenerator();
3188 svg1->setResolution(this->physicalDpiX());
3191 svg1->setFileName(filename+
".tmp.svg");
3193 svg1->setFileName(filename);
3197 svg1->setSize(QSize(1.12*w,h));
3198 QPainter *p =
new QPainter(svg1);
3199 p->fillRect(0,0,svg1->size().width(),svg1->size().height(),Qt::white);
3201 vp->
init(p,1.0,0,0,xmin-bourder/2,ymin-bourder/2,1.0,1.0);
3210 QString cmd =
"inkscape -z -D --file=";
3211 cmd += filename+
".tmp.svg ";
3214 QString tmp = filename;
3216 cmd = cmd +
"--export-pdf="+ tmp +
" --export-latex";
3220 cmd = cmd +
"--export-pdf=" + filename;
3224 cmd = cmd +
"--export-eps=" + filename;
3227 int result = QProcess::execute(cmd);
3230 QMessageBox* msg =
new QMessageBox(QMessageBox::Critical,tr(
"Export to image"),
3231 tr(
"Inkscape start error!"),
3236 QFile::remove(filename+
".tmp.svg");
3243 QMessageBox* msg =
new QMessageBox(QMessageBox::Critical,tr(
"Export to image"),
3244 tr(
"Unsupported format of graphics file. \n"
3245 "Use PNG, JPEG or SVG graphics!"),
3261 QMessageBox* msg =
new QMessageBox(QMessageBox::Information,tr(
"Export to image"),
3262 tr(
"Sucessfully exported!"),
3267 QMessageBox* msg =
new QMessageBox(QMessageBox::Critical,tr(
"Export to image"),
3268 tr(
"Disk write error!"),
void slotResizePropEdit(const QString &)
MessageDock * messageDock
Element *(* pInfoVAFunc)(QString &, QString &, bool, QString)
static QString pathName(QString longpath)
void MPressElement(Schematic *, QMouseEvent *, float, float)
void slotMenuOpenProject()
QTreeWidgetItem * ConDatasets
QTreeWidgetItem * ConOthers
void updateSpiceNameHash(void)
QAction * ActionCMenuInsert
Definition of the TextDoc class.
QString fileType(const QString &)
bool gotoPage(const QString &)
void(MouseActions::* MouseMoveAction)(Schematic *, QMouseEvent *)
void MMoveElement(Schematic *, QMouseEvent *)
bool deleteProject(const QString &, const QString &)
void editElement(Schematic *, QMouseEvent *)
tQucsSettings QucsSettings
void slotSelectSubcircuit(QTreeWidgetItem *)
void(MouseActions::* MousePressAction)(Schematic *, QMouseEvent *, float, float)
QTreeWidgetItem * ConOctave
QAction * ActionCMenuOpen
The MessageDock class definiion.
QAction * ActionCMenuCopy
QTreeWidgetItem * ConVerilog
void slotChangeView(QWidget *)
bool checkVersion(QString &Line)
static void registerModules(void)
static QString fileSuffix(const QString &)
void switchEditMode(bool)
void changeSchematicSymbolMode(Schematic *)
Element *(* pInfoFunc)(QString &, char *&, bool)
static void unregisterModules(void)
static QStringList getCategories(void)
void fillLibrariesTreeView(void)
bool deleteDirectoryContent(QDir &Dir)
virtual void print(QPrinter *, QPainter *, bool, bool)
void updatePortNumber(QucsDoc *, int)
QucsDoc * getDoc(int No=-1)
static int getModulesNr(QString)
QucsDoc * findDoc(QString, int *Pos=0)
unsigned int numRecentDocs
Definitions and declarations for the main application.
void slotRefreshSchPath()
QTreeWidgetItem * ConVerilogA
void slotShowContentMenu(const QPoint &)
Q3PtrList< QString > HierarchyHistory
virtual void becomeCurrent(bool)
ExportDialog::ImgFormat getImgFormat()
QStringList spiceExtensions
Q3PtrList< Component > * Components
void MReleaseSelect(Schematic *, QMouseEvent *)
Q3PtrList< Property > Props
void switchSchematicDoc(bool)
void slotSimulate()
QucsApp::slotSimulate is called when the simulate toolbar button is pressed.
virtual void showNoZoom()
void printCurrentDocument(bool)
QTreeWidgetItem * ConDisplays
void runOctaveScript(const QString &)
void successExportMessages(bool ok)
int loadVarData(const QString &, Graph *)
Q3PtrList< Graph > Graphs
QHash< QString, QString > spiceNameHash
bool saveApplSettings(QucsApp *qucs)
void initActions()
QucsApp::initActions Initializes all QActions of the application.
void slotMenuDelProject()
static Q3PtrList< Module > getModules(QString)
void slotOpenContent(QTreeWidgetItem *)
void(MouseActions::* MouseReleaseAction)(Schematic *, QMouseEvent *)
void slotToggleDock(bool)
QString copySelected(bool)
static Element * info(QString &, QString &, bool getNewOne=false, QString filename="")
vacomponent::info is used to either get information or create objects.
void slotSelectLibComponent(QTreeWidgetItem *)
void slotMenuCloseProject()
void initContentListView()
void initView()
QucsApp::initView Setup the layour of all widgets.
QTreeWidget * libTreeWidget
virtual QString getSubcircuitFile()
void getSelAreaWidthAndHeight(int &wsel, int &hsel, int &xmin_sel_, int &ymin_sel_)
virtual float zoomBy(float)
static QMap< QString, QString > vaComponents
void updateRecentFilesList(QString s)
void paintSchToViewpainter(ViewPainter *p, bool printAll, bool toImage, int screenDpiX=96, int printerDpiX=300)
QString getSpiceFileFilter(void)
QTreeWidgetItem * ConSchematics
bool saveFile(QucsDoc *Doc=0)
void openProject(const QString &, const QString &)
bool isTextDocument(QWidget *)
Component * searchSelSubcircuit()
QAction * ActionCMenuDelete
void slotSaveSchematicToGraphicsFile(bool diagram=false)
void slotAfterSimulation(int, SimMessage *)
void slotViewOctaveDock(bool)
void setFrequency(double)
void addUnsavedDoc(QucsDoc *doc)
void slotChangePage(QString &, QString &)
void editFile(const QString &)
void slotUpdateRecentFiles()
virtual void setName(const QString &)
void(MouseActions::* MouseDoubleClickAction)(Schematic *, QMouseEvent *)
The TextDoc class definition.
QAction * ActionCMenuRename
void slotSetCompView(int)
void init(QPainter *, float, int, int, int, int, float FontScale_=0.0, float PrintScale_=1.0)
void recreateComponent(Component *)
QString lastExportFilename
void MDoubleClickSelect(Schematic *, QMouseEvent *)
QMouseEvent * focusMEvent
void updatePathList(void)
void MPressSelect(Schematic *, QMouseEvent *, float, float)
void getSchWidthAndHeight(int &w, int &h, int &xmin_, int &ymin_)
void updateSchNameHash(void)
virtual void recreate(Schematic *)
void slotToggleOctave(bool)
void slotSelectComponent(QListWidgetItem *)
QTreeWidgetItem * ConSources
QHash< QString, QString > schNameHash
static int testFile(const QString &)
void closeEvent(QCloseEvent *)
void slotSaveDiagramToGraphicsFile()
void slotOpenProject(QListWidgetItem *)