void GitoriousRepositoryWizardPage::initializePage()
{
    // Populate the model
    ui->repositoryTreeView->selectionModel()->clearSelection();
    if (const int oldRowCount = m_model->rowCount())
        m_model->removeRows(0, oldRowCount);
    ui->filterLineEdit->clear();
    // fill model
    const QSharedPointer<GitoriousProject> proj = m_projectPage->project();
    setSubTitle(tr("Choose a repository of the project '%1'.").arg(proj->name));
    // Create a hierarchical list by repository type, sort by type
    QList<GitoriousRepository> repositories = proj->repositories;
    QStandardItem *firstEntry = 0;
    if (!repositories.empty()) {
        int lastRepoType = -1;
        QStandardItem *header = 0;
        qStableSort(repositories.begin(), repositories.end(), gitRepoLessThanByType);
        const QString types[GitoriousRepository::PersonalRepository + 1] =
            { tr("Mainline Repositories"), tr("Clones"), tr("Baseline Repositories"), tr("Shared Project Repositories"), tr("Personal Repositories") };
        foreach(const GitoriousRepository &r, repositories) {
            // New Header?
            if (r.type != lastRepoType || !header) {
                lastRepoType = r.type;
                const QList<QStandardItem *> headerRow = headerEntry(types[r.type]);
                m_model->appendRow(headerRow);
                header = headerRow.front();
            }
            // Repository row
            const QList<QStandardItem *> row = repositoryEntry(r);
            header->appendRow(row);
            if (!firstEntry)
                firstEntry = row.front();
        }
    }
Ejemplo n.º 2
0
void DlgCustomToolbarsImp::addCustomCommand(const QString& name, const QByteArray& cmd)
{
    QVariant data = workbenchBox->itemData(workbenchBox->currentIndex(), Qt::UserRole);
    Workbench* w = WorkbenchManager::instance()->active();
    if (w && w->name() == std::string((const char*)data.toByteArray())) {
        QList<QToolBar*> bars = getMainWindow()->findChildren<QToolBar*>(name);
        if (bars.size() != 1)
            return;

        if (cmd == "Separator") {
            QAction* action = bars.front()->addSeparator();
            action->setData(QByteArray("Separator"));
        }
        else {
            CommandManager& mgr = Application::Instance->commandManager();
            if (mgr.addTo(cmd, bars.front())) {
                QAction* action = bars.front()->actions().last();
                // See ToolBarManager::setup(ToolBarItem* , QToolBar* )
                // We have to add the user data in order to identify the command in
                // removeCustomCommand(), moveUpCustomCommand() or moveDownCustomCommand()
                if (action && action->data().isNull())
                    action->setData(cmd);
            }
        }
    }
}
Ejemplo n.º 3
0
void QmitkDicomInspectorView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*source*/,
  const QList<mitk::DataNode::Pointer>& nodes)
{
  if (nodes.size() > 0)
  {
    if (nodes.front() != this->m_currentSelectedNode)
    {
      m_internalUpdateFlag = true;
      this->m_currentSelectedNode = nodes.front();
      this->m_currentSelectedData = this->m_currentSelectedNode->GetData();
      m_internalUpdateFlag = false;

      m_selectedNodeTime.Modified();
      UpdateData();
      OnSliceChangedDelayed();
    }
  }
  else
  {
    if (this->m_currentSelectedNode.IsNotNull())
    {
      m_internalUpdateFlag = true;
      this->m_currentSelectedNode = nullptr;
      this->m_currentSelectedData = nullptr;
      m_internalUpdateFlag = false;

      m_selectedNodeTime.Modified();
      UpdateData();
      OnSliceChangedDelayed();
    }
  }

}
Ejemplo n.º 4
0
void TestPJobFile::writeResultDefintions(){
	PJobResultFile file;
	file.setFilename("ParameterVariation.txt");
	PJobResult result;
	result.setName("EOP");
	file.addResult(result);
	result.setName("Q");
	result.setUnit("dB");
	file.addResult(result);

	QList<PJobResultFile> resultFiles;
	resultFiles << file;
	PJobFile::writeResultDefinitions(resultFiles,"testWriteResultDefinitions.xml");
	resultFiles = PJobFile::readResultDefintions("testWriteResultDefinitions.xml");

	QCOMPARE(resultFiles.size(), 1);

	PJobResultFile p = resultFiles.front();
	QList<PJobResult> results = p.results();

	QCOMPARE(p.filename(), QString("ParameterVariation.txt"));
	QCOMPARE(results.size(), 2);

	PJobResult r1  = results.front();
	results.pop_front();
	PJobResult r2 = results.front();

	QCOMPARE(r1.name(), QString("EOP"));
	QCOMPARE(r1.unit(), QString(""));
	QCOMPARE(r2.name(), QString("Q"));
	QCOMPARE(r2.unit(), QString("dB"));
}
Ejemplo n.º 5
0
void TestPJobFile::writeParameterCombination(){
	QList<PJobFileParameter> parameters;

	PJobFileParameter p;
	p.setName("length");
	p.setValue(100.);
	parameters << p;
	p.setName("power");
	p.setVariation(1.,15.,1.);
	parameters << p;

	PJobFile::writeParameterCombination(parameters, "testReadParameterCombination.xml");
	parameters = PJobFile::readParameterCombination("testReadParameterCombination.xml");

	QFile::remove("testReadParameterCombination.xml");

	QCOMPARE(parameters.size(), 2);

	PJobFileParameter p1 = parameters.front();
	parameters.pop_front();
	PJobFileParameter p2 = parameters.front();

	QCOMPARE(p1.name(), QString("length"));
	QCOMPARE(p1.isVariation(), false);
	QCOMPARE(p1.value(), 100.);

	QCOMPARE(p2.name(), QString("power"));
	QCOMPARE(p2.isVariation(), true);
	QCOMPARE(p2.minValue(), 1.);
	QCOMPARE(p2.maxValue(), 15.);
	QCOMPARE(p2.step(), 1.);
}
Ejemplo n.º 6
0
void TestSpanners::spanners05()
{
    MasterScore* score = readScore(DIR + "glissando-cloning02.mscx");
    QVERIFY(score);
    score->doLayout();

    // create parts
    // (copied and adapted from void TestParts::createParts() in mtest/libmscore/parts/tst_parts.cpp)
    QList<Part*> parts;
    parts.append(score->parts().at(0));
    Score* nscore = new Score(score);

    Excerpt ex(score);
    ex.setPartScore(nscore);
    ex.setTitle(parts.front()->longName());
    ex.setParts(parts);
    ::createExcerpt(&ex);
    QVERIFY(nscore);

    nscore->setName(parts.front()->partName());
    score->undo(new AddExcerpt(nscore));

    QVERIFY(saveCompareScore(score, "glissando-cloning02.mscx", DIR + "glissando-cloning02-ref.mscx"));
    delete score;
}
Ejemplo n.º 7
0
void DlgCustomToolbarsImp::removeCustomCommand(const QString& name, const QByteArray& userdata)
{
    QVariant data = workbenchBox->itemData(workbenchBox->currentIndex(), Qt::UserRole);
    Workbench* w = WorkbenchManager::instance()->active();
    if (w && w->name() == std::string((const char*)data.toByteArray())) {
        QList<QToolBar*> bars = getMainWindow()->findChildren<QToolBar*>(name);
        if (bars.size() != 1)
            return;

        QByteArray cmd = userdata;
        int numSep = 0, indexSep = 0;
        if (cmd.startsWith("Separator")) {
            numSep = cmd.mid(9).toInt();
            cmd = "Separator";
        }
        QList<QAction*> actions = bars.front()->actions();
        for (QList<QAction*>::ConstIterator it = actions.begin(); it != actions.end(); ++it) {
            if ((*it)->data().toByteArray() == cmd) {
                // if we move a separator then make sure to pick up the right one
                if (numSep > 0) {
                    if (++indexSep < numSep)
                        continue;
                }
                bars.front()->removeAction(*it);
                break;
            }
        }
    }
}
Ejemplo n.º 8
0
SmartPointer<Expression> RegistryPersistence::ReadWhenElement(
    const SmartPointer<IConfigurationElement>& parentElement,
    const QString& whenElementName, const QString& id,
    QList<SmartPointer<IStatus> >& warningsToLog)
{
  // Check to see if we have an when expression.
  const QList<IConfigurationElement::Pointer> whenElements = parentElement
      ->GetChildren(whenElementName);
  Expression::Pointer whenExpression;
  if (!whenElements.isEmpty())
  {
    // Check if we have too many when elements.
    if (whenElements.size() > 1)
    {
      // There should only be one when element
      AddWarning(warningsToLog,
                 "There should only be one when element", parentElement,
                 id, "whenElementName", whenElementName);
      return ERROR_EXPRESSION;
    }

    const IConfigurationElement::Pointer whenElement = whenElements.front();
    const QList<IConfigurationElement::Pointer> expressionElements = whenElement->GetChildren();
    if (!expressionElements.isEmpty())
    {
      // Check if we have too many expression elements
      if (expressionElements.size() > 1)
      {
        // There should only be one expression element
        AddWarning(warningsToLog, "There should only be one expression element", parentElement,
                   id, "whenElementName", whenElementName);
        return ERROR_EXPRESSION;
      }

      // Convert the activeWhen element into an expression.
      const ElementHandler::Pointer elementHandler = ElementHandler::GetDefault();
      ExpressionConverter* const converter = ExpressionConverter::GetDefault();
      const IConfigurationElement::Pointer expressionElement = expressionElements.front();
      try
      {
        whenExpression = elementHandler->Create(converter, expressionElement);
      }
      catch (const CoreException& /*e*/)
      {
        // There when expression could not be created.
        AddWarning(warningsToLog, "Problem creating when element",
                   parentElement, id, "whenElementName", whenElementName);
        return ERROR_EXPRESSION;
      }
    }
  }

  return whenExpression;
}
Ejemplo n.º 9
0
void QmitkVolumetryView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, const QList<mitk::DataNode::Pointer> &nodes)
{
  m_SelectedDataNode = nullptr;
  if (!nodes.isEmpty() && dynamic_cast<mitk::Image*>(nodes.front()->GetData()))
  {
    m_SelectedDataNode = nodes.front();
    m_ParentWidget->setEnabled(true);
  }

  if (m_SelectedDataNode.IsNull() || m_SelectedDataNode.GetPointer() == m_OverlayNode.GetPointer())
  {
    m_SelectedDataNode = nullptr;
    m_ParentWidget->setEnabled(false);
    return;
  }

  if (m_OverlayNode)
  {
    this->GetDataStorage()->Remove(m_OverlayNode);
    m_OverlayNode = nullptr;
  }

  this->CreateOverlayChild();

  m_Controls->m_CalcButton->setEnabled(false);
  m_Controls->m_TimeSeriesButton->setEnabled(false);
  m_Controls->m_SaveCsvButton->setEnabled(false);
  m_Controls->m_TextEdit->clear();

  mitk::Image* image = dynamic_cast<mitk::Image*>(m_SelectedDataNode->GetData());
  image->Update();
  if (image && image->IsInitialized())
  {
    if (image->GetDimension() == 4)
    {
      m_Controls->m_TimeSeriesButton->setEnabled(true);
    }
    else
    {
      m_Controls->m_CalcButton->setEnabled(true);
    }
    int minVal = (int)image->GetStatistics()->GetScalarValue2ndMin();
    int maxVal = (int)image->GetStatistics()->GetScalarValueMaxNoRecompute();
    if (minVal == maxVal)
      --minVal;
    m_Controls->m_ThresholdSlider->setMinimum(minVal);
    m_Controls->m_ThresholdSlider->setMaximum(maxVal);
    m_Controls->m_ThresholdSlider->setEnabled(true);
    this->UpdateSlider();
    mitk::RenderingManager::GetInstance()->RequestUpdateAll();
  }
}
Ejemplo n.º 10
0
int TabbedStackPresentation::GetSizeFlags(bool width)
{
  int flags = 0;
  // If there is exactly one part in the stack,
  // then take into account the size flags of the part.
  QList<IPresentablePart::Pointer> parts = this->GetSite()->GetPartList();
  if (parts.size() == 1 && parts.front() != 0)
  {
    flags |= parts.front()->GetSizeFlags(width);
  }

  return flags | StackPresentation::GetSizeFlags(width);
}
Ejemplo n.º 11
0
int main ()
{
  QList<int> myQList;

  myQList.push_back(77);
  myQList.push_back(22);
  assert(myQList.front() != 77);
  // now front equals 77, and back 22

  myQList.front() -= myQList.back();
  assert(myQList.front() == 55);
  cout << "myQList.front() is now " << myQList.front() << endl;

  return 0;
}
Ejemplo n.º 12
0
int TabbedStackPresentation::ComputePreferredSize(bool width,
    int availableParallel, int availablePerpendicular, int preferredResult)
{

  // If there is exactly one part in the stack, this just returns the
  // preferred size of the part as the preferred size of the stack.
  QList<IPresentablePart::Pointer> parts = this->GetSite()->GetPartList();
  if (parts.size() == 1 && parts.front() != 0 && !(this->GetSite()->GetState()
      == IStackPresentationSite::STATE_MINIMIZED))
  {
    int partSize = parts.front()->ComputePreferredSize(width, availableParallel,
        availablePerpendicular, preferredResult);

    if (partSize == INF)
      return partSize;

    // Adjust preferred size to take into account tab and border trim.
    int minSize = this->ComputePreferredMinimumSize(width, availablePerpendicular);
    if (width)
    {
      // PaneFolder adds some bogus tab spacing, so just find the maximum width.
      partSize = std::max<int>(minSize, partSize);
    }
    else
    {
      // Add them (but only if there's enough room)
      if (INF - minSize > partSize)
        partSize += minSize;
    }

    return partSize;
  }

  if (preferredResult != INF || this->GetSite()->GetState()
      == IStackPresentationSite::STATE_MINIMIZED)
  {
    int minSize = this->ComputePreferredMinimumSize(width, availablePerpendicular);

    if (this->GetSite()->GetState() == IStackPresentationSite::STATE_MINIMIZED)
    {
      return minSize;
    }

    return std::max<int>(minSize, preferredResult);
  }

  return INF;
}
Ejemplo n.º 13
0
void chanFileSystemDockWidget::createFolder() {

    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();

    QString folderName;
    QString path;
    QDir dir;

    folderName = QInputDialog::getText(this, "set folder's name", "enter name:");
    path = m_home + QDir::separator() + folderName;

    //修改硬盘中的数据
    if (!dir.mkdir(path)) {
        QMessageBox::warning(this, tr("error"),
                             tr("make directory %1 failed").arg(folderName));
        return;
    }

    QTreeWidgetItem* item = items.empty() ?
                            new QTreeWidgetItem(m_fileSystemTree) :
                            new QTreeWidgetItem(items.front());

    item->setData(0, ITEM_TYPE_KEY, Folder);
    item->setData(0, FOLDER_NAME_KEY,path);
    item->setText(0, folderName);

    item->setIcon(0, QIcon(resourceFileName::pFolder));
}
Ejemplo n.º 14
0
void chanFileSystemDockWidget::renameFolder() {

    //之前这里一直获得的都是size == 0 原因在于context menu设置不正确
    //那个错误的设置是remove folder 但是却导致了这里始终接受的items.size() == 0
    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();
    QTreeWidgetItem* item = items.front();

    //根节点不可修改名字
    if (m_fileSystemTree->itemAbove(item) == NULL) {
        return;
    }

    QString folderName;
    QString path;
    QDir dir;

    folderName = QInputDialog::getText(this, "set folder's name", "enter name:");
    path = m_home + QDir::separator() + folderName;

    if (!QDir().rename(item->data(0, FOLDER_NAME_KEY).toString(), (path))) {
        QMessageBox::warning(this, tr("error"),
                             tr("failed to rename the folder!"));
        return;
    }

    item->setData(0, FOLDER_NAME_KEY, path);
    item->setText(0, folderName);
}
void MotionPlanningFrame::computeDeleteQueryButtonClicked()
{
  if (planning_scene_storage_)
  {
    QList<QTreeWidgetItem *> sel = ui_->planning_scene_tree->selectedItems();
    if (!sel.empty())
    {
      QTreeWidgetItem *s = sel.front();
      if (s->type() == ITEM_TYPE_QUERY)
      {
        std::string scene = s->parent()->text(0).toStdString();
        std::string query_name = s->text(0).toStdString();
        try
        {
          planning_scene_storage_->removePlanningQuery(scene, query_name);
        }
        catch (std::runtime_error &ex)
        {
          ROS_ERROR("%s", ex.what());
        }
        planning_display_->addMainLoopJob(boost::bind(&MotionPlanningFrame::computeDeleteQueryButtonClickedHelper, this, s));
      }
    }
  }
}
Ejemplo n.º 16
0
void AbstractInputTool::deleteAbstractInputItem(const QString& id, 
        InterfaceDescriptor_ptr reflective,
        const QList< int >& path)
{
    OperationDescriptor_ptr op =
        reflective->get_reflective_by_index(path.front());

    const key_t key(id, op->get_tag());
    QList< AbstractInputItem * >& list = m_map[key];

    for (int i = 0; i < list.size(); i++) 
    {
        AbstractInputItem * item = list[i];
        if (item->getPath() == path)
        {
            list.removeAt(i);
            m_inverse_map.erase(item);

            // Notify to the processor
            item->reset();

            m_group->deleteItem(
                    qobject_cast< qt::SortableGroupItem * >
                        (item->parent()));

            delete item;
            break;
        }
    }
}
void MotionPlanningFrame::checkPlanningSceneTreeEnabledButtons()
{
  QList<QTreeWidgetItem *> sel = ui_->planning_scene_tree->selectedItems();
  if (sel.empty())
  {
    ui_->load_scene_button->setEnabled(false);
    ui_->load_query_button->setEnabled(false);
    ui_->save_query_button->setEnabled(false);
    ui_->delete_scene_button->setEnabled(false);
  }
  else
  {
    ui_->save_query_button->setEnabled(true);

    QTreeWidgetItem *s = sel.front();

    // if the item is a PlanningScene
    if (s->type() == ITEM_TYPE_SCENE)
    {
      ui_->load_scene_button->setEnabled(true);
      ui_->load_query_button->setEnabled(false);
      ui_->delete_scene_button->setEnabled(true);
      ui_->delete_query_button->setEnabled(false);
      ui_->save_query_button->setEnabled(true);
    }
    else
    {
      // if the item is a query
      ui_->load_scene_button->setEnabled(false);
      ui_->load_query_button->setEnabled(true);
      ui_->delete_scene_button->setEnabled(false);
      ui_->delete_query_button->setEnabled(true);
    }
  }
}
Ejemplo n.º 18
0
ImapPartAttachmentItem::ImapPartAttachmentItem(Model *model, const QString &mailbox, const uint uidValidity, const uint uid,
                                               const QByteArray &trojitaPath)
{
    TreeItemMailbox *mboxPtr = model->findMailboxByName(mailbox);
    if (!mboxPtr)
        throw Imap::UnknownMessageIndex("No such mailbox");

    if (mboxPtr->syncState.uidValidity() != uidValidity)
        throw Imap::UnknownMessageIndex("UIDVALIDITY mismatch");

    QList<TreeItemMessage*> messages = model->findMessagesByUids(mboxPtr, Imap::Uids() << uid);
    if (messages.isEmpty())
        throw Imap::UnknownMessageIndex("UID not found");

    Q_ASSERT(messages.size() == 1);

    QModelIndex partIndex = Imap::Network::MsgPartNetAccessManager::pathToPart(messages.front()->toIndex(model), trojitaPath);
    if (!partIndex.isValid())
        throw Imap::UnknownMessageIndex("No such part");

    if (partIndex.data(Imap::Mailbox::RolePartMimeType).toString().startsWith(QLatin1String("multipart/"))) {
        // Yes, we absolutely do abuse this exception now. Any better ideas?
        throw Imap::UnknownMessageIndex("Cannot attach multipart/* MIME containers");
    }
    index = partIndex;
}
Ejemplo n.º 19
0
void Qtilities::Testing::DebugWidget::handle_objectPoolSelectionChanged(QList<QObject*> objects) {
    if (objects.count() == 1) {
        QObject* obj = objects.front();
        if (!obj)
            return;

        d->current_object = obj;
        d->object_scope_widget.setObject(obj);

        #ifdef QTILITIES_PROPERTY_BROWSER
        if (ui->chkRefreshProperties->isChecked()) {
            d->object_property_browser->setObject(obj);
            d->object_dynamic_property_browser->setObject(obj);
        }
        #else
        // Inheritance Data:
        QStringList inheritance_list;
        const QMetaObject* metaObject = obj->metaObject();
        while (metaObject) {
            inheritance_list.append(metaObject->className());
            metaObject = metaObject->superClass();
        }
        d->inheritanceModel.setStringList(inheritance_list);
        #endif
    }
}
Ejemplo n.º 20
0
QString Qtilities::Logging::FormattingEngine_QtMsgEngineFormat::formatMessage(Logger::MessageType message_type, const QList<QVariant>& messages) const {
    Q_UNUSED(message_type)

    QString message = QString();
    message.append(QString("%1").arg(messages.front().toString()));
    return message;
}
Ejemplo n.º 21
0
void TestSpanners::spanners14()
      {
      MasterScore* score = readScore(DIR + "glissando-cloning05.mscx");
      QVERIFY(score);
      score->doLayout();

      // create parts
      // (copied and adapted from void TestParts::createParts() in mtest/libmscore/parts/tst_parts.cpp)
      QList<Part*> parts;
      parts.append(score->parts().at(0));
      Score* nscore = new Score(score);

      Excerpt* ex = new Excerpt(score);
      ex->setPartScore(nscore);
      ex->setTitle(parts.front()->longName());
      ex->setParts(parts);
      Excerpt::createExcerpt(ex);
      QVERIFY(nscore);

//      nscore->setName(parts.front()->partName());

//      QMultiMap<int, int> tracks;
      score->Score::undo(new AddExcerpt(ex));

      QVERIFY(saveCompareScore(score, "glissando-cloning05.mscx", DIR + "glissando-cloning05-ref.mscx"));
      delete score;
      }
Ejemplo n.º 22
0
int
Splitter::getLeftChildrenSize() const
{
    QList<int> list = sizes();
    assert(list.size() == 2);
    return list.front();
}
Ejemplo n.º 23
0
    void Core::start(QList<bt::TorrentInterface*> & todo)
    {
        if (todo.isEmpty())
            return;

        // unpause paused torrents
        for (QList<bt::TorrentInterface*>::iterator i = todo.begin(); i != todo.end();)
        {
            if ((*i)->getStats().paused)
            {
                (*i)->unpause();
                i = todo.erase(i);
            }
            else
                i++;
        }

        if (todo.count() == 1)
        {
            start(todo.front());
        }
        else
        {
            qman->start(todo);
        }

        startUpdateTimer(); // restart update timer
    }
Ejemplo n.º 24
0
void InstrumentWizard::on_addButton_clicked()
      {
      QList<QTreeWidgetItem*> wi = instrumentList->selectedItems();
      if (wi.isEmpty())
            return;
      InstrumentTemplateListItem* item = (InstrumentTemplateListItem*)wi.front();
      const InstrumentTemplate* it     = item->instrumentTemplate();
      if (it == 0)
            return;
      PartListItem* pli = new PartListItem(it, partiturList);
      pli->op = ITEM_ADD;

      int n = it->staves;
      for (int i = 0; i < n; ++i) {
            StaffListItem* sli = new StaffListItem(pli);
            sli->op       = ITEM_ADD;
            sli->staff    = 0;
            sli->setPartIdx(i);
            sli->staffIdx = -1;
            if (i > MAX_STAVES)
                  sli->setClef(CLEF_G);
            else
                  sli->setClef(it->clefIdx[i]);
            }
      partiturList->setItemExpanded(pli, true);
      partiturList->clearSelection();     // should not be necessary
      partiturList->setItemSelected(pli, true);
      emit completeChanged(true);
      }
Ejemplo n.º 25
0
void chanFileSystemDockWidget::createFile() {

    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();

    if (items.isEmpty()) return;

    QTreeWidgetItem* parent = items.front();

    QString fileName = QFileDialog::getSaveFileName(this, tr("edit name"), ".",
                       tr("c/c++ header file(*.h)\n"
                          "c/c++ header file(*.hpp)\n"
                          "c source file(*.c)\n"
                          "c++ source file(*.cpp)"
                         ));

    if (!QFile(fileName).open(QIODevice::WriteOnly)) {
        QMessageBox::warning(this, "error",
                             tr("create the file %1 failed").arg(fileName));

        return;
    }

    createTreeWidgetItem(fileName, parent);

    emit createdFile(fileName);
}
Ejemplo n.º 26
0
void InstrumentWizard::on_downButton_clicked()
      {
      QList<QTreeWidgetItem*> wi = partiturList->selectedItems();
      if (wi.isEmpty())
            return;
      QTreeWidgetItem* item = wi.front();
      if (item->type() == PART_LIST_ITEM) {
            bool isExpanded = partiturList->isItemExpanded(item);
            int idx = partiturList->indexOfTopLevelItem(item);
            int n = partiturList->topLevelItemCount();
            if (idx < (n-1)) {
                  partiturList->selectionModel()->clear();
                  QTreeWidgetItem* item = partiturList->takeTopLevelItem(idx);
                  partiturList->insertTopLevelItem(idx+1, item);
                  partiturList->setItemExpanded(item, isExpanded);
                  partiturList->setItemSelected(item, true);
                  }
            }
      else {
            QTreeWidgetItem* parent = item->parent();
            int idx = parent->indexOfChild(item);
            int n = parent->childCount();
            if (idx < (n-1)) {
                  partiturList->selectionModel()->clear();
                  QTreeWidgetItem* item = parent->takeChild(idx);
                  parent->insertChild(idx+1, item);
                  partiturList->setItemSelected(item, true);
                  }
            }
      }
Ejemplo n.º 27
0
void InstrumentWizard::on_removeButton_clicked()
      {
      QList<QTreeWidgetItem*> wi = partiturList->selectedItems();
      if (wi.isEmpty())
            return;
      QTreeWidgetItem* item = wi.front();
      QTreeWidgetItem* parent = item->parent();

      if (parent) {
            if (((StaffListItem*)item)->op == ITEM_ADD) {
                  if (parent->childCount() == 1) {
                        partiturList->takeTopLevelItem(partiturList->indexOfTopLevelItem(parent));
                        delete parent;
                        }
                  else {
                        parent->takeChild(parent->indexOfChild(item));
                        delete item;
                        }
                  }
            else {
                  ((StaffListItem*)item)->op = ITEM_DELETE;
                  partiturList->setItemHidden(item, true);
                  }
            }
      else {
            if (((PartListItem*)item)->op == ITEM_ADD)
                  delete item;
            else {
                  ((PartListItem*)item)->op = ITEM_DELETE;
                  partiturList->setItemHidden(item, true);
                  }
            }
      partiturList->clearSelection();
      emit completeChanged(partiturList->topLevelItemCount() > 0);
      }
Ejemplo n.º 28
0
void PropertiesEditorDialog::valueChanged(QtProperty *property, const QVariant &value)
{
    if (!m_property_to_id.contains(property))
    {
        return;
    }

    if (!m_canvas)
    {
        return;
    }
    QList<QGraphicsSvgItem *> list = m_canvas->selectedGeneralItems();

    m_canvas->beginUndoMacro(tr("Change Property"));
    if (list.empty())
    {
        // Set the property directly on the canvas:
        m_canvas->setProperty(m_property_to_id[property].toLatin1().constData(), value);
    }
    else
    {
        // Otherwise, set it on the first item in the selection:
        QGraphicsSvgItem *item = list.front();
        item->setProperty(m_property_to_id[property].toLatin1().constData(), value);
    }
}
Ejemplo n.º 29
0
    void GUI::openTorrent(bool silently)
    {
        QString recentDirClass;
        QUrl defaultUrl = KFileWidget::getStartUrl(QUrl(QStringLiteral("kfiledialog:///openTorrent")), recentDirClass);
        if (!QDir(defaultUrl.toLocalFile()).exists())
            defaultUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
        QList<QUrl> urls = QFileDialog::getOpenFileUrls(this, i18n("Open Location"), defaultUrl, kt::TorrentFileFilter(true));

        if (urls.isEmpty())
            return;

        if (!recentDirClass.isEmpty() && defaultUrl.toLocalFile()!=urls.first().toLocalFile())
            KRecentDirs::add(recentDirClass, QFileInfo(urls.first().toLocalFile()).absolutePath());

        if (urls.count() == 1 && !silently)
        {
            QUrl url = urls.front();
            if (url.isValid())
                load(url);
        }
        else
        {
            // load multiple torrents silently
            foreach (const QUrl& url, urls)
            {
                if (url.isValid())
                {
                    if (silently || Settings::openMultipleTorrentsSilently())
                        loadSilently(url);
                    else
                        load(url);
                }
            }
        }
    }
Ejemplo n.º 30
0
void TestChordSymbol::testNoSystem()
      {
      MasterScore* score = test_pre("no-system");

      //
      // create first part
      //
      QList<Part*> parts;
      parts.append(score->parts().at(0));

      Score* nscore = new Score(score);
      score->Score::undo(new AddExcerpt(nscore));

      {
      Excerpt ex(score);
      ex.setPartScore(nscore);
      ex.setTitle(parts.front()->longName());
      ex.setParts(parts);
      ::createExcerpt(&ex);
      QVERIFY(nscore);
      }

      nscore->setName(parts.front()->partName());
      nscore->style()->set(StyleIdx::createMultiMeasureRests, true);

      //
      // create second part
      //
      parts.clear();
      parts.append(score->parts().at(1));
      nscore = new Score(score);
      score->Score::undo(new AddExcerpt(nscore));
      {
      Excerpt ex(score);
      ex.setTitle(parts.front()->longName());
      ex.setParts(parts);
      ex.setPartScore(nscore);
      ::createExcerpt(&ex);
      QVERIFY(nscore);
      }

      nscore->setName(parts.front()->partName());
      nscore->style()->set(StyleIdx::createMultiMeasureRests, true);

      score->doLayout();
      test_post(score, "no-system");
      }