void
TrackParameterBox::setDocument(RosegardenDocument *doc)
{
    // No change?  Bail.
    if (m_doc == doc)
        return;

    m_doc = doc;

    m_doc->getComposition().addObserver(this);

    // Populate color combo from the document colors.
    // ??? Now that we actually load these from the new document, we can
    //     see what's actually in .rg files.  Older ones have almost no
    //     colors at all (e.g. the Vivaldi op44 example file).  Since we
    //     don't allow editing of the colors, we should probably just
    //     always put the standard color list into a document when it is
    //     loaded.
    slotDocColoursChanged();

    // Detect when the document colours are updated.
    // ??? Document colors can never be updated.  See explanation in
    //     slotDocColoursChanged().
    //connect(m_doc, SIGNAL(docColoursChanged()),
    //        this, SLOT(slotDocColoursChanged()));

    updateWidgets2();
}
void
TrackParameterBox::slotColorChanged(int index)
{
    //RG_DEBUG << "slotColorChanged(" << index << ")";

    Track *track = getTrack();
    if (!track)
        return;

    track->setColor(index);
    m_doc->slotDocumentModified();

    // Notify observers
    // This will trigger a call to updateWidgets2().
    Composition &comp = m_doc->getComposition();
    comp.notifyTrackChanged(track);

#if 0
// This will never happen since the "Add Color" option is never added.
    if (index == m_addColourPos) {
        ColourMap newMap = m_doc->getComposition().getSegmentColourMap();
        QColor newColour;
        bool ok = false;
        
        QString newName = InputDialog::getText(this,
                                               tr("New Color Name"),
                                               tr("Enter new name:"),
                                               LineEdit::Normal,
                                               tr("New"), &ok);
        
        if ((ok == true) && (!newName.isEmpty())) {
//             QColorDialog box(this, "", true);
//             int result = box.getColor(newColour);
            
            //QRgb QColorDialog::getRgba(0xffffffff, &ok, this);
            QColor newColor = QColorDialog::getColor(Qt::white, this);

            if (newColor.isValid()) {
                Colour newRColour = GUIPalette::convertColour(newColour);
                newMap.addItem(newRColour, qstrtostr(newName));
                slotDocColoursChanged();
            }
        }
        // Else we don't do anything as they either didn't give a name
        // or didn't give a colour
    }
#endif
}
ColourConfigurationPage::ColourConfigurationPage(RosegardenDocument *doc, QWidget *parent)
        : TabbedConfigurationPage(doc, parent)
{
    QFrame *frame = new QFrame(m_tabWidget);
    frame->setContentsMargins(10, 10, 10, 10);
    QGridLayout *layout = new QGridLayout(frame);
    layout->setSpacing(5);

    m_map = m_doc->getComposition().getSegmentColourMap();

    m_colourtable = new ColourTable(frame, m_map, m_listmap);
    m_colourtable->setFixedHeight(280);

    layout->addWidget(m_colourtable, 0, 0, 0- 0+1, 1- 0+1);

    QPushButton* addColourButton = new QPushButton(tr("Add New Color"),
                                   frame);
    layout->addWidget(addColourButton, 1, 0, Qt::AlignHCenter);

    // disable until we can remove it after release
    addColourButton->setEnabled(false);

    QPushButton* deleteColourButton = new QPushButton(tr("Delete Color"),
                                      frame);
    layout->addWidget(deleteColourButton, 1, 1, Qt::AlignHCenter);

    // disable until we can remove it after release
    deleteColourButton->setEnabled(false);

    connect(addColourButton, SIGNAL(clicked()),
            this, SLOT(slotAddNew()));

    connect(deleteColourButton, SIGNAL(clicked()),
            this, SLOT(slotDelete()));

    connect(this, SIGNAL(docColoursChanged()),
            m_doc, SLOT(slotDocColoursChanged()));

    connect(m_colourtable, SIGNAL(entryTextChanged(unsigned int, QString)),
            this, SLOT(slotTextChanged(unsigned int, QString)));

    connect(m_colourtable, SIGNAL(entryColourChanged(unsigned int, QColor)),
            this, SLOT(slotColourChanged(unsigned int, QColor)));

    addTab(frame, tr("Color Map"));

}