Example #1
0
int main ()
{
    QList<QString> first;
    list<QString> second;
    first << "A" << "B" << "C" << "D" << "E" << "F";
    second = first.toStdList();
    assert(second.size() == 6);
  return 0;
}
bool FxSelection::insertPasteSelection() {
  QClipboard *clipboard  = QApplication::clipboard();
  const FxsData *fxsData = dynamic_cast<const FxsData *>(clipboard->mimeData());

  m_pastePosition = TConst::nowhere;

  if (!fxsData || !fxsData->isConnected()) return false;

  if (m_selectedLinks.isEmpty()) return true;

  // Start an undo block and ensure it is appropriately destroyed
  struct Auto {
    bool m_destruct;
    ~Auto() {
      if (m_destruct) TUndoManager::manager()->endBlock();
    }
  } auto_ = {false};

  // Need to make a temporary copy of selected links. It's necessary since the
  // selection will
  // be updated (cleared) after each insertion.
  QList<TFxCommand::Link> selectedLinks(m_selectedLinks);

  int i, size = selectedLinks.size();
  for (i = 0; i < size; ++i) {
    // Clone the fxs to be inserted
    QList<TFxP> fxs;
    QMap<TFx *, int> zeraryFxColumnSize;
    QList<TXshColumnP> columns;

    fxsData->getFxs(fxs, zeraryFxColumnSize, columns);
    if (fxs.empty() && columns.empty()) return true;

    if (!auto_.m_destruct)
      auto_.m_destruct = true, TUndoManager::manager()->beginBlock();

    TFxCommand::insertPasteFxs(selectedLinks[i], fxs.toStdList(),
                               zeraryFxColumnSize.toStdMap(),
                               columns.toStdList(), m_xshHandle, m_fxHandle);
  }

  return true;
}
void FxSelection::pasteSelection() {
  /*--- Fxノードを1つだけ選択していた場合、Replace paste ---*/
  if (m_selectedFxs.size() >= 1 && m_selectedLinks.size() == 0 &&
      m_selectedColIndexes.isEmpty())
    replacePasteSelection();
  /*--- Linkを1つだけ選択していた場合、Insert paste ---*/
  else if (m_selectedFxs.size() == 0 && m_selectedLinks.size() >= 1 &&
           m_selectedColIndexes.isEmpty())
    insertPasteSelection();
  else {
    QClipboard *clipboard = QApplication::clipboard();
    const FxsData *fxsData =
        dynamic_cast<const FxsData *>(clipboard->mimeData());
    if (!fxsData) return;
    QList<TFxP> fxs;
    QMap<TFx *, int> zeraryFxColumnSize;
    QList<TXshColumnP> columns;
    fxsData->getFxs(fxs, zeraryFxColumnSize, columns);
    if (fxs.isEmpty() && columns.isEmpty()) return;

    // in case of the paste command triggered from short cut key
    if (m_pastePosition == TConst::nowhere && m_schematicScene) {
      SchematicSceneViewer *ssv =
          dynamic_cast<SchematicSceneViewer *>(m_schematicScene->views().at(0));
      if (ssv)
        m_pastePosition =
            TPointD(ssv->getOldScenePos().x(), ssv->getOldScenePos().y());
    }

    TFxCommand::pasteFxs(fxs.toStdList(), zeraryFxColumnSize.toStdMap(),
                         columns.toStdList(), m_pastePosition, m_xshHandle,
                         m_fxHandle);

    if (m_schematicScene) {
      selectNone();
      for (int i = 0; i < (int)fxs.size(); i++) select(fxs[i]);
      m_schematicScene->selectNodes(fxs);
    }
  }
  m_pastePosition = TConst::nowhere;
}
bool FxSelection::replacePasteSelection() {
  QClipboard *clipboard  = QApplication::clipboard();
  const FxsData *fxsData = dynamic_cast<const FxsData *>(clipboard->mimeData());

  m_pastePosition = TConst::nowhere;

  if (!fxsData || !fxsData->isConnected()) return false;

  if (m_selectedFxs.isEmpty()) return true;

  struct Auto {
    bool m_destruct;
    ~Auto() {
      if (m_destruct) TUndoManager::manager()->endBlock();
    }
  } auto_ = {false};

  QList<TFxP> selectedFxs(m_selectedFxs);

  int i, size = selectedFxs.size();
  for (i = 0; i < size; ++i) {
    // Clone the fxs to be inserted
    QList<TFxP> fxs;
    QMap<TFx *, int> zeraryFxColumnSize;
    QList<TXshColumnP> columns;

    fxsData->getFxs(fxs, zeraryFxColumnSize, columns);
    if (fxs.empty() && columns.empty()) return true;

    if (!auto_.m_destruct)
      auto_.m_destruct = true, TUndoManager::manager()->beginBlock();

    TFx *inFx = m_selectedFxs[i].getPointer();
    TFxCommand::replacePasteFxs(inFx, fxs.toStdList(),
                                zeraryFxColumnSize.toStdMap(),
                                columns.toStdList(), m_xshHandle, m_fxHandle);
  }

  return true;
}
Example #5
0
QString PluginManagerImpl::parsePluginsRequest(const QString &templ, QList<PluginRequest> &plugins, QStringList & names)
{
    if (templ.trimmed().isEmpty()) {
        return "Plugins template is empty";
    }
    bool inBr = false;
    PluginRequest cur;
    QString argument;
    cur.start = false;
    for (int i=0 ; i<templ.size(); i++) {
        if (templ[i]=='!' && cur.name.isEmpty() && !inBr) {
            cur.start = true;
        }
        else if (templ[i]=='(' && !inBr) {
            inBr = true;
        }
        else if (templ[i]==')' && inBr) {
            inBr = false;
            cur.arguments << argument;
            argument = "";
        }
        else if (templ[i]==',' && inBr) {
            cur.arguments << argument;
            argument = "";
        }
        else if (templ[i]==',' && !inBr) {
            plugins << cur;
            cur.start = false;
            cur.arguments.clear();
            cur.name = "";
        }
        else if (inBr) {
            argument += templ[i];
        }
        else {
            cur.name += templ[i];
        }
    }
    plugins << cur;
    int starts = 0;
    // Qt bug !!! Use STL instead and then convert back to QList
    std::list<PluginRequest> stdPlugins = plugins.toStdList();
    std::list<PluginRequest>::iterator it=stdPlugins.begin();
    while (it!=stdPlugins.end()) {
        PluginRequest p = (*it);
        if (p.name.contains("*") || p.name.contains("?")) {
            if (p.start) {
                return "Entry point defined for masked by * name in plugins template";
            }
            QDir dir(path);
            QStringList entries = dir.entryList(QStringList() << p.name+".pluginspec", QDir::Files);
            it = stdPlugins.erase(it);
            foreach (const QString & e, entries) {
                PluginRequest pp;
                pp.name = e.left(e.size()-11);
                pp.arguments = p.arguments;
                pp.start = false;
                stdPlugins.insert(it, pp);
            }
        }
        else {
            ++it;