示例#1
0
void QLCFixtureEditor::slotCloneMode()
{
    QLCFixtureMode* mode = NULL;
    bool ok = false;
    QString text;

    mode = currentMode();
    if (mode == NULL)
        return;

    while (1)
    {
        text = QInputDialog::getText(this, tr("Rename new mode"),
                                     tr("Give a unique name for the mode"),
                                     QLineEdit::Normal,
                                     tr("Copy of %1").arg(mode->name()),
                                     &ok);

        if (ok == true && text.isEmpty() == false)
        {
            /* User entered a name that is already found from
               the fixture definition -> again */
            if (mode->fixtureDef()->mode(text) != NULL)
            {
                QMessageBox::information(this,
                                         tr("Invalid name"),
                                         tr("Another mode by that name already exists."));
                ok = false;
                continue;
            }

            /* Create new mode and an item for it */
            QTreeWidgetItem* item;
            QLCFixtureMode* clone;

            clone = new QLCFixtureMode(mode->fixtureDef(), mode);
            clone->setName(text);
            item = new QTreeWidgetItem(m_modeList);

            mode->fixtureDef()->addMode(clone);
            updateModeItem(clone, item);
            m_modeList->setCurrentItem(item);

            setModified();
            break;
        }
        else
        {
            // User pressed cancel
            break;
        }
    }
}
示例#2
0
void QLCFixtureEditor::slotCloneMode()
{
	QLCFixtureMode* mode = NULL;
	QLCFixtureMode* clone = NULL;
	bool ok = false;
	QString text;
	
	mode = currentMode();
	if (mode == NULL)
		return;
	
	while (1)
	{
		text = QInputDialog::getText(this, tr("Rename new mode"),
					     tr("Give a unique name for the mode"),
					     QLineEdit::Normal,
					     "Copy of " + mode->name(),
					     &ok);

		if (ok == true && text.isEmpty() == false)
		{
			/* User entered a name that is already found from
			   the fixture definition -> again */
			if (mode->fixtureDef()->mode(text) != NULL)
			{
				QMessageBox::information(
					this,
					tr("Invalid name"),
					tr("Another mode by that name already exists."));
				ok = false;
				continue;
			}

			clone = new QLCFixtureMode(mode);
			clone->setName(text);
			mode->fixtureDef()->addMode(clone);
			refreshModeList();
			break;
		}
		else
		{
			// User pressed cancel
			break;
		}
	}
}