25 #include <QPushButton> 
   26 #include <QHBoxLayout> 
   27 #include <QVBoxLayout> 
   28 #include <QScrollArea> 
   30 #include <QFileDialog> 
   32 #include <QScriptEngine> 
   33 #include <QScriptValue> 
   34 #include <QScriptValueIterator> 
   42    : QDialog( parent, name, modal, fl )
 
   45       setWindowTitle( tr( 
"Load Verilog-A symbols" ) );
 
   61    QVBoxLayout *all = 
new QVBoxLayout(
this);
 
   66    QHBoxLayout *hGroups = 
new QHBoxLayout();
 
   67    all->addLayout(hGroups);
 
   70    QGroupBox *group1 = 
new QGroupBox( tr( 
"Choose Verilog-A symbol files:" ) );
 
   71    hGroups->addWidget(group1);
 
   73    QScrollArea *scrollArea = 
new QScrollArea(group1);
 
   74    scrollArea->setWidgetResizable(
true);
 
   80    QVBoxLayout *areaLayout = 
new QVBoxLayout();
 
   81    areaLayout->addWidget(scrollArea);
 
   82    group1->setLayout(areaLayout);
 
   86    QGridLayout *gridButts = 
new QGridLayout();
 
   87    all->addLayout(gridButts);
 
   99    ButtOk = 
new QPushButton(tr(
"Ok"));
 
  100    gridButts->addWidget(
ButtOk, 1, 1);
 
  105    QVBoxLayout *iconLayout = 
new QVBoxLayout();
 
  107    QGroupBox *group2 = 
new QGroupBox( );
 
  109    QVBoxLayout *group2Layout = 
new QVBoxLayout();
 
  112    iconPixmap->setSizePolicy(QSizePolicy::Expanding,
 
  113                              QSizePolicy::Expanding);
 
  117    group2->setLayout(group2Layout);
 
  118    iconLayout->addWidget(group2);
 
  122    hGroups->addLayout(iconLayout);
 
  126    QGroupBox *group3 = 
new QGroupBox();
 
  127    QVBoxLayout *group3Layout = 
new QVBoxLayout();
 
  128    group3->setLayout(group3Layout);
 
  129    iconLayout->addWidget(group3);
 
  132    QCheckBox *autoLoadSelCheck = 
new QCheckBox(tr(
"auto-load selected"));
 
  133    autoLoadSelCheck->setToolTip(
 
  134                tr(
"Load the selected symbols when opening the project."));
 
  136    autoLoadSelCheck->setDisabled(
true); 
 
  138    group3Layout->addWidget(autoLoadSelCheck);
 
  147    connect(
fileView, SIGNAL(itemPressed(QListWidgetItem*)),
 
  154      item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
 
  155      item->setCheckState(Qt::Checked);
 
  171     for(
int i = 0; i < 
fileView->count(); ++i)
 
  173         QListWidgetItem* item = 
fileView->item(i);
 
  174         item->setCheckState(Qt::Checked);
 
  181     for(
int i = 0; i < 
fileView->count(); ++i)
 
  183         QListWidgetItem* item = 
fileView->item(i);
 
  184         item->setCheckState(Qt::Unchecked);
 
  194   QString JSON = 
projDir.filePath(item->text());
 
  199   QString Name, vaBitmap;
 
  207   QString iconPath = QString(
projDir.absFilePath(vaBitmap+
".png"));
 
  208   QFile iconFile(iconPath);
 
  210   if(iconFile.exists())
 
  217     QMessageBox::information(
this, tr(
"Info"),
 
  218                  tr(
"Icon not found:\n %1.png").arg(vaBitmap));
 
  220     iconPixmap->setPixmap(QPixmap(
":/bitmaps/editdelete.png"));
 
  237   for(
int i = 0; i < 
fileView->count(); ++i)
 
  239     QListWidgetItem* item = 
fileView->item(i);
 
  241     if (item->checkState() == Qt::Checked){
 
  242         QString key = item->text().split(
"_symbol.json").at(0);
 
  243         QString value = 
projDir.absoluteFilePath(item->text());
 
  245         qDebug() << 
"key" << key;
 
  246         qDebug() << 
"file " << value;
 
  263   QString iconFileName =
 
  264           QFileDialog::getOpenFileName(
this,
 
  266                                         QString(
projDir.absolutePath()),
 
  267                                         tr(
"Icon image (*.png)"));
 
  269   QString newIcon =  QFileInfo(iconFileName).baseName();
 
  272   QString filename = 
fileView->currentItem()->text();
 
  273   filename = 
projDir.absoluteFilePath(filename);
 
  281   QFile file(filename);
 
  284   if (!file.open(QIODevice::ReadWrite | QIODevice::Text)){
 
  285     QMessageBox::critical(
this, tr(
"Error"),
 
  286                           tr(
"File not found: %1").arg(filename));
 
  289     QTextStream in(&file);
 
  290     while ( !in.atEnd() )
 
  292       QString line = in.readLine();
 
  293       if (line.contains(
"BitmapFile")){
 
  295                   QString(
"  \"BitmapFile\" : \"%1\",").arg(newIcon);
 
  296           ba.append(change+
"\n");
 
  299           ba.append(line+
"\n");
 
  315   if (event->type() == QEvent::KeyPress) {
 
  316     QKeyEvent* keyEvent = 
static_cast<QKeyEvent*
>(event);
 
  318     if (keyEvent->key() == Qt::Key_Up) {
 
  324     if (keyEvent->key() == Qt::Key_Down) {
 
QPushButton * ButtSelectNone
void slotSymbolFileClicked(QListWidgetItem *item)
LoadDialog(QWidget *p=0, const char *n=0, bool modal=true, Qt::WFlags fl=0)
QPushButton * ButtChangeIcon
QMap< QString, QString > selectedComponents
QPushButton * ButtSelectAll
static Element * info(QString &, QString &, bool getNewOne=false, QString filename="")
vacomponent::info is used to either get information or create objects. 
bool eventFilter(QObject *obj, QEvent *event)