summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-05-19 12:45:22 +0000
committerWerner Schweer <ws.seh.de>2006-05-19 12:45:22 +0000
commit6557f11325ade42f5b5d31aa632bc0032ea7c003 (patch)
tree07e0b02d4ccba2c0e3095536ea19c0d3c0ba50d9
parentdb27954e4d480c7917ba4738966b21b7b620ca64 (diff)
updates
-rw-r--r--muse/ChangeLog2
-rw-r--r--muse/TODO4
-rw-r--r--muse/muse/muse.cpp74
-rw-r--r--muse/muse/muse.h2
-rw-r--r--muse/muse/projectdialog.cpp7
-rw-r--r--muse/muse/song.cpp8
-rw-r--r--muse/muse/song.h8
-rw-r--r--muse/muse/songfile.cpp7
8 files changed, 70 insertions, 42 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog
index 7a9303ed..98f6927a 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,5 @@
+19.5 (ws)
+ * added project creation time and song len (in sec) to project file
18.5 (ws)
* added "Muse templates" and "User templates" to template list
in template dialog
diff --git a/muse/TODO b/muse/TODO
index abb73670..b5fd44b7 100644
--- a/muse/TODO
+++ b/muse/TODO
@@ -6,10 +6,6 @@
- create dialog to edit project comment
BUGS
- - if the user creates a new project and later decides to not
- save the project, the created (empty) project directory is
- not deleted on MusE exit
-
- updating the gui during midi recording is too slow;
a new, faster implementation is needed
diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp
index 4be5f45d..6340639e 100644
--- a/muse/muse/muse.cpp
+++ b/muse/muse/muse.cpp
@@ -1067,26 +1067,9 @@ void MusE::loadProject1(const QString& path)
{
QString header(tr("MusE: new project"));
- if (song->dirty) {
- int n = 0;
- n = QMessageBox::warning(this, header,
- tr("The current Project contains unsaved data\n"
- "Load overwrites current Project:\n"
- "Save Current Project?"),
- tr("&Save"), tr("&Overwrite"), tr("&Abort"), 0, 2);
- switch (n) {
- case 0:
- if (!save()) // abort if save failed
- return;
- break;
- case 1:
- break;
- case 2:
- return;
- default:
- printf("InternalError: gibt %d\n", n);
- }
- }
+ if (leaveProject())
+ return;
+
if (mixer1)
mixer1->clear();
if (mixer2)
@@ -1125,6 +1108,7 @@ void MusE::loadProject1(const QString& path)
emit startLoadSong();
song->setProjectPath(path);
song->clear(false);
+ song->setCreated(newProject);
QString s = pd.absoluteFilePath(name + ".med");
@@ -1303,18 +1287,12 @@ void MusE::quitDoc()
}
//---------------------------------------------------------
-// closeEvent
+// leaveProject
+// return false if user aborts operation
//---------------------------------------------------------
-void MusE::closeEvent(QCloseEvent*)
+bool MusE::leaveProject()
{
- song->setStop(true);
- //
- // wait for sequencer
- //
- while (audio->isPlaying()) {
- qApp->processEvents();
- }
//
// delete all wave files created in this session and not
// referenced any more
@@ -1326,12 +1304,10 @@ void MusE::closeEvent(QCloseEvent*)
tr("The current Project contains unsaved data\n"
"Save Current Project?"),
tr("&Save"), tr("&Nosave"), tr("&Abort"), 0, 2);
- if (n == 0) {
- if (!save()) // dont quit if save failed
- return;
- }
+ if (n == 0)
+ return !save();
else if (n == 2)
- return;
+ return true;
//
// delete all wave files created in this session and not
// referenced any more
@@ -1341,6 +1317,36 @@ void MusE::closeEvent(QCloseEvent*)
}
else
SndFile::cleanupRecFiles(true);
+ //
+ // if this is a new created project,
+ // delete project directory
+ //
+ if (song->created()) {
+ // delete project directory
+ QDir pp;
+ if (!pp.rmdir(song->absoluteProjectPath()))
+ printf("cannot remove dir <%s>\n", song->absoluteProjectPath().toLatin1().data());
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void MusE::closeEvent(QCloseEvent*)
+ {
+ song->setStop(true);
+ //
+ // wait for sequencer
+ //
+ while (audio->isPlaying()) {
+ qApp->processEvents();
+ }
+
+ if (leaveProject())
+ return;
+
seqStop();
// save "Open Recent" list
diff --git a/muse/muse/muse.h b/muse/muse/muse.h
index a3bd0749..7fe3742e 100644
--- a/muse/muse/muse.h
+++ b/muse/muse/muse.h
@@ -163,6 +163,8 @@ class MusE : public QMainWindow, public Ui::MuseBase
void writeConfiguration(Xml&) const;
void updateConfiguration();
+ bool leaveProject();
+
virtual void focusInEvent(QFocusEvent*);
signals:
diff --git a/muse/muse/projectdialog.cpp b/muse/muse/projectdialog.cpp
index ebfcacc2..1c5f3219 100644
--- a/muse/muse/projectdialog.cpp
+++ b/muse/muse/projectdialog.cpp
@@ -177,10 +177,10 @@ void ProjectDialog::currentChanged(QTreeWidgetItem* item, QTreeWidgetItem*)
pd += "/" + itemPath(item);
QFileInfo pf(pd + "/" + item->text(0) + ".med");
- createdDate->setDateTime(pf.created());
modifiedDate->setDateTime(pf.lastModified());
QTime time(0, 0, 0);
+ QDateTime date;
QFile f(pf.filePath());
QDomDocument doc;
@@ -213,17 +213,22 @@ void ProjectDialog::currentChanged(QTreeWidgetItem* item, QTreeWidgetItem*)
QString s(e.text());
if (tag == "comment")
comment->setPlainText(s);
+ else if (tag == "createDate")
+ date = QDateTime::fromString(e.text(), Qt::ISODate);
else if (tag == "LenInSec") {
int sec = s.toInt();
time = time.addSecs(sec);
+ break;
}
}
}
}
}
+ break;
}
}
length->setTime(time);
+ createdDate->setDateTime(date);
}
//---------------------------------------------------------
diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp
index 0832e054..f17918de 100644
--- a/muse/muse/song.cpp
+++ b/muse/muse/song.cpp
@@ -1141,6 +1141,12 @@ void Song::panic()
void Song::clear(bool signal)
{
+ _created = false;
+ _backupWritten = false;
+ dirty = false;
+ _comment = "";
+ _createDate = QDateTime::currentDateTime();
+
seekInProgress = false;
bounceTrack = 0;
@@ -1180,8 +1186,6 @@ void Song::clear(bool signal)
_quantize = false;
_len = 1; // song len in ticks
// _tempo = 500000; // default tempo 120
- dirty = false;
- _backupWritten = false;
if (signal) {
emit loopChanged(false);
recordChanged(false);
diff --git a/muse/muse/song.h b/muse/muse/song.h
index f7322c7f..344d1c80 100644
--- a/muse/muse/song.h
+++ b/muse/muse/song.h
@@ -88,11 +88,15 @@ class Song : public QObject {
private:
QString _projectPath;
QString _comment;
+ bool _backupWritten; // set after first "save" operation from
+ // user; used to make sure there will
+ // be only one backup for a session
+ bool _created; // project was created in current session
+ QDateTime _createDate;
MidiFifo eventFifo;
int updateFlags;
- bool _backupWritten;
TrackList _tracks; // tracklist as seen by arranger
MidiTrackList _midis;
@@ -401,6 +405,8 @@ class Song : public QObject {
void setProjectPath(const QString&);
QString comment() const { return _comment; }
void setComment(const QString& s) { _comment = s; }
+ void setCreated(bool val) { _created = val; }
+ bool created() const { return _created; }
bool read(QFile* qf);
void read20(QDomNode node);
diff --git a/muse/muse/songfile.cpp b/muse/muse/songfile.cpp
index 3e62ccaf..751f83a5 100644
--- a/muse/muse/songfile.cpp
+++ b/muse/muse/songfile.cpp
@@ -21,6 +21,7 @@
#include "muse.h"
#include "song.h"
#include "arranger/arranger.h"
+#include "al/al.h"
#include "al/xml.h"
#include "midiedit/drummap.h"
#include "al/marker.h"
@@ -252,6 +253,8 @@ void Song::read(QDomNode node)
DrumEdit::readConfiguration(node);
else if (tag == "comment")
_comment = e.text();
+ else if (tag == "createDate")
+ _createDate = QDateTime::fromString(e.text(), Qt::ISODate);
else
printf("MusE:Song: unknown tag %s\n", tag.toLatin1().data());
}
@@ -266,6 +269,10 @@ void Song::write(Xml& xml) const
{
xml.tag("song");
xml.strTag("comment", _comment);
+ xml.strTag("createDate", _createDate.toString(Qt::ISODate));
+ int n = AL::tempomap.tick2frame(_len);
+ xml.intTag("LenInSec", n / AL::sampleRate);
+
xml.intTag("cpos", cpos());
xml.intTag("rpos", rpos());
xml.intTag("lpos", lpos());