diff options
author | Robert Jonsson <spamatica@gmail.com> | 2011-03-07 19:01:11 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2011-03-07 19:01:11 +0000 |
commit | e40fc849149dd97c248866a4a1d026dda5e57b62 (patch) | |
tree | b12b358f3b3a0608001d30403358f8443118ec5f /attic/muse2-oom/muse2/muse/widgets/comment.cpp | |
parent | 1bd4f2e8d9745cabb667b043171cad22c8577768 (diff) |
clean3
Diffstat (limited to 'attic/muse2-oom/muse2/muse/widgets/comment.cpp')
-rw-r--r-- | attic/muse2-oom/muse2/muse/widgets/comment.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/attic/muse2-oom/muse2/muse/widgets/comment.cpp b/attic/muse2-oom/muse2/muse/widgets/comment.cpp new file mode 100644 index 00000000..36298330 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/comment.cpp @@ -0,0 +1,89 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: comment.cpp,v 1.2 2004/02/08 18:30:00 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include "comment.h" +#include "song.h" +#include "track.h" + +#include <QWidget> + +//--------------------------------------------------------- +// Comment +//--------------------------------------------------------- + +Comment::Comment(QWidget* parent) + : QWidget(parent) + { + setupUi(this); + } + +//--------------------------------------------------------- +// textChanged +//--------------------------------------------------------- + +void Comment::textChanged() + { + setText(textentry->toPlainText()); + } + +//--------------------------------------------------------- +// TrackComment +//--------------------------------------------------------- + +TrackComment::TrackComment(Track* t, QWidget* parent) + : Comment(parent) + { + setAttribute(Qt::WA_DeleteOnClose); + setWindowTitle(tr("MusE: Track Comment")); + track = t; + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + textentry->setText(track->comment()); + textentry->moveCursor(QTextCursor::End); + connect(textentry, SIGNAL(textChanged()), SLOT(textChanged())); + label1->setText(tr("Track Comment:")); + label2->setText(track->name()); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void TrackComment::songChanged(int flags) + { + if ((flags & (SC_TRACK_INSERTED|SC_TRACK_REMOVED|SC_TRACK_MODIFIED)) == 0) + return; + + // check if track still exists: + TrackList* tl = song->tracks(); + iTrack it; + for (it = tl->begin(); it != tl->end(); ++it) { + if (track == *it) + break; + } + if (it == tl->end()) { + close(); + return; + } + label2->setText(track->name()); + if (track->comment() != textentry->toPlainText()) { + disconnect(textentry, SIGNAL(textChanged()), this, SLOT(textChanged())); + textentry->setText(track->comment()); + textentry->moveCursor(QTextCursor::End); + connect(textentry, SIGNAL(textChanged()), this, SLOT(textChanged())); + } + } + +//--------------------------------------------------------- +// setText +//--------------------------------------------------------- + +void TrackComment::setText(const QString& s) + { + track->setComment(s); + song->update(SC_TRACK_MODIFIED); + } + |