Пример #1
0
// The current item in the scene's view has changed.
void GenericHID::onSelectionChanged()
{
    RetrieveProperties();

    QList<ShapeItem *> selectedShapes;
    foreach ( QGraphicsItem *pItem, m_pScene->selectedItems() )
        if ( pItem->type() == ShapeItem::Type )
            selectedShapes.append( qgraphicsitem_cast<ShapeItem *>(pItem) );

    if ( selectedShapes.count() == 1 )
    {
        ui.listView->clear();
        if ( m_pLastSelectedShape != selectedShapes[0] )
        {
            m_pLastSelectedShape = selectedShapes[0];

            const ShapeProperties &pProps = m_pLastSelectedShape->shapeData()->properties();
            ShapeProperty::SetBrowserFactory( ui.listView, m_pScene->CPUClockFrequency() );
            ui.listView->addProperty(pProps.topItem());
            m_pLastSelectedShape->populateProperties();
            if ( ui.listView->topLevelItems().count() > 0 )
                ui.listView->setCurrentItem( ui.listView->topLevelItems()[0] );
        }
    }
    else
    {
        m_pLastSelectedShape = NULL;
        ui.listView->clear();
    }
}
Пример #2
0
void GenericHID::onFileSave()
{
    RetrieveProperties();

    if ( m_sLastFile.isEmpty() )
        DoSaveAs();
    else
        DoSave();
}
Пример #3
0
intptr_t FarDialog::Execute()
{
  std::vector<FarDialogItem> Items;
  std::vector<RetCode> RetCodes;
  FarDialogItem frame;
  ::ZeroMemory(&frame, sizeof(frame));
  frame.Type = DI_DOUBLEBOX;
  String p = (*this)(L"Title");
  if (p.empty())
  {
    p = LOC(getName());
  }
  SetItemText(frame, p);
  Items.push_back(frame);

  intptr_t w, h, f;
  DefSize(w, h, f);
  AddToItems(Items, RetCodes, 5, 2, w);

  Items[0].X1 = 3;
  Items[0].Y1 = 1;
  Items[0].X2 = w + 6;
  Items[0].Y2 = h + 2;
  String HelpTopic = Property((*this)(L"HelpTopic"));

  HANDLE hnd = Info.DialogInit(&MainGuid, &MainGuid, -1, -1, w + 10, h + 4,
                               HelpTopic.c_str(),
                               Items.data(), Items.size(),
                               0, bool((*this)(L"Warning")) ? FDLG_WARNING : 0,
                               Info.DefDlgProc, 0
                              );  // !!! Need real Dialog GUID, instead of MainDialog
  intptr_t ret = -1;
  if (hnd != INVALID_HANDLE_VALUE)
  {
    intptr_t res = Info.DialogRun(hnd);
    for (size_t Index = 0; Index < RetCodes.size(); Index++)
    {
      if (RetCodes[Index].itemNo == res)
      {
        if (RetCodes[Index].retCode != -1)
        {
          RetrieveProperties(hnd);
        }
        ret = RetCodes[Index].retCode;
        break;
      }
    }
    Info.DialogFree(hnd);
  }
  ClearDialogItems(Items);
  return ret;
}
Пример #4
0
void GenericHID::closeEvent( QCloseEvent * event )
{
    RetrieveProperties();

    // check for changes
    if ( !CheckDataChanged() )
    {
        event->ignore();
        return;
    }

    writeSettings();
}
Пример #5
0
void GenericHID::onMicrocontrollerExport()
{
    RetrieveProperties();

    // Verify
    QString sError;
    if ( !m_pScene->VerifyShapes( sError ) )
    {
        QMessageBox msg(QMessageBox::Critical, "Errors Found", "Errors were found processing the device configuration", QMessageBox::Ok, this );
        msg.setDetailedText( sError );
        msg.exec();
        return;
    }
    // make xml
    QString s = m_pScene->MakeDeviceXML();
    if ( s.isEmpty() )
    {
        QMessageBox msg(QMessageBox::Critical, "Errors Found", "Failed to create the device configuration", QMessageBox::Ok, this );
        msg.exec();
        return;
    }

    // Save
    for (;;)
    {
        QString sFilename = QFileDialog::getSaveFileName( this, "Save microcontroller configuration description", m_sLastExportFile, QString("Microcontroller Config Description file (*.mcd);;All files (*)") );
        if ( sFilename.isEmpty() || sFilename.isNull() )
            return;

        QFileInfo fi(sFilename);
        if ( fi.suffix().isEmpty() )
            sFilename.append( ".mcd" );

        QFile file(sFilename.toLatin1().constData());
        if ( !file.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
        {
            QMessageBox::critical( this, "Can't save", QString("Failed to save file '%1':%2").arg(sFilename).arg(file.errorString()) );
        }
        else
        {
            m_sLastExportFile = sFilename;
            file.write( s.toLatin1() );
            file.close();
            break;
        }
    }
}
Пример #6
0
void GenericHID::onMicrocontrollerProgram()
{
    RetrieveProperties();

    // Verify
    QString sError;
    if ( !m_pScene->VerifyShapes( sError ) )
    {
        QMessageBox msg(QMessageBox::Critical, "Errors Found", "Errors were found processing the device configuration", QMessageBox::Ok, this );
        msg.setDetailedText( sError );
        msg.exec();
        return;
    }
    // make xml
    QString s = m_pScene->MakeDeviceXML();
    if ( s.isEmpty() )
    {
        QMessageBox msg(QMessageBox::Critical, "Errors Found", "Failed to create the device configuration", QMessageBox::Ok, this );
        msg.exec();
        return;
    }

    // make eeprom
    MakeEEPROM eeprom;
    if ( !eeprom.loadXML( s ) )
    {
        QMessageBox::critical( this, "Error", eeprom.lastError() );
        return;
    }

    ByteArray buf = eeprom.makeEEPROM();
    if ( buf.isEmpty() )
    {
        QMessageBox::critical( this, "Error", eeprom.lastError() );
        return;
    }

    QString sIntelHex = MakeEEPROM::MakeIntelHexFormat( DYNAMIC_HIDDATA_ADDRESS, buf );

    LOG_DEBUG( m_Logger, "Program HexFile - " );
    LOG_DEBUG( m_Logger, sIntelHex );

    // program
    DoProgram( sIntelHex );
}
Пример #7
0
void GenericHID::onFileSaveAs()
{
    RetrieveProperties();

    DoSaveAs();
}