diff edtimeline.cpp @ 398:8660c6005032

More work.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 19 Oct 2012 09:46:05 +0300
parents 9993873ff655
children 2fdf440ea66a
line wrap: on
line diff
--- a/edtimeline.cpp	Fri Oct 19 07:22:09 2012 +0300
+++ b/edtimeline.cpp	Fri Oct 19 09:46:05 2012 +0300
@@ -124,20 +124,23 @@
     QFrame *infoLayoutContainer = new QFrame(this);
     infoLayoutContainer->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
     infoLayoutContainer->setLineWidth(2);
-//    infoLayoutContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
-//    infoLayoutContainer->resize(250, 60);
+    infoLayoutContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
+    infoLayoutContainer->setFixedWidth(200);
 
     QVBoxLayout *infoLayout = new QVBoxLayout(infoLayoutContainer);
     infoLayout->setMargin(0);
 //    QVBoxLayout *infoLayout = new QVBoxLayout();
-    infoName = new QLabel("-");
-    infoName->setStyleSheet("QLabel { background-color: black; color: white; padding: 2px; }");
+    infoName = new QLineEdit();
+    infoName->setFrame(false);
+    infoName->setMaxLength(DT_MAX_NAME_LENGTH);
+    infoName->setStyleSheet("QLineEdit { background-color: black; color: white; padding: 2px; }");
+    connect(infoName, SIGNAL(textEdited(const QString&)), this, SLOT(slotTrackNameChanged(const QString&)));
     infoLayout->addWidget(infoName);
 
 
     enabledCheck = new QCheckBox("Enabled");
     infoLayout->addWidget(enabledCheck);
-    connect(enabledCheck, SIGNAL(toggled(bool)), this, SLOT(slotTrackChanged(bool)));
+    connect(enabledCheck, SIGNAL(toggled(bool)), this, SLOT(slotTrackEnabledChanged(bool)));
     
     infoData = new QLabel();
     infoData->setStyleSheet("QLabel { padding: 2px; }");
@@ -146,31 +149,47 @@
     mainLayout->addWidget(infoLayoutContainer);
 //    mainLayout->addLayout(infoLayout);
     mainLayout->addWidget(track);
+}
 
+
+void QTimelineTrackView::update()
+{
+    if (track != NULL && track->track)
+    {
+        infoName->setText(QString(track->track->name));
+        enabledCheck->setChecked(track->track->enabled);
+        infoData->setText(QString("<b>%1</b> events").arg(track->track->nevents));
+    }
+    else
+    {
+        infoName->setText("");
+        infoData->setText("-");
+        enabledCheck->setChecked(false);
+    }
+
+    QWidget::update();
 }
 
 
 void QTimelineTrackView::setTrack(DMTimelineTrack *mtrack)
 {
-    if (mtrack != NULL)
-    {
-        infoName->setText(QString(mtrack->name));
-        infoData->setText("-");
-//        infoData->setText(QString("<b>%1</b>, <b>%2</b> ch, <b>%3</b> Hz").arg(fmt).arg(mchannels).arg(mfreq));
-    }
-    else
-    {
-        infoData->setText("-");
-    }
     track->setTrack(mtrack);
     update();
 }
 
 
-void QTimelineTrackView::slotTrackChanged(bool value)
+void QTimelineTrackView::slotTrackEnabledChanged(bool value)
 {
     track->track->enabled = value;
-    emit trackChanged(value);
+    emit trackChanged();
+}
+
+
+void QTimelineTrackView::slotTrackNameChanged(const QString & text)
+{
+    QByteArray ba = text.toUtf8();
+    track->track->name = dm_strdup(ba.constData());
+    emit trackChanged();
 }
 
 
@@ -188,6 +207,8 @@
 
     delete layout;
     layout = new QVBoxLayout(this);
+    layout->setMargin(0);
+    
     tracks.clear();
 
     if (tl != NULL && tl->tl != NULL)
@@ -198,7 +219,7 @@
             vtr->setTrack(tl->tl->tracks[track]);
             tracks.append(vtr);
             layout->addWidget(vtr);
-            connect(vtr, SIGNAL(trackChanged(bool)), this, SLOT(slotTimelineChanged()));
+            connect(vtr, SIGNAL(trackChanged()), this, SLOT(slotTimelineChanged()));
         }
     }
     update();
@@ -214,6 +235,7 @@
     }
 }
 
+
 void QTimelineView::setTime(const int mtime)
 {
     if (tl != NULL && tl->tl != NULL)
@@ -228,7 +250,6 @@
 }
 
 
-
 void QTimelineView::setOffset(const int moffs)
 {
     if (tl != NULL && tl->tl != NULL)