From 9e1f8fc0ef4923dd8389a746da62dced1b474cf5 Mon Sep 17 00:00:00 2001 From: Werner Schweer Date: Thu, 18 May 2006 13:21:39 +0000 Subject: more template handling code --- muse/ChangeLog | 3 + muse/doc/man/en/CMakeLists.txt | 2 +- muse/muse/muse.cpp | 14 +- muse/muse/templatedialog.cpp | 78 +++--- muse/muse/templatedialog.h | 2 +- muse/share/templates/audio.med | 518 ++++++++++++++++++++---------------- muse/share/templates/monorecord.med | 8 +- 7 files changed, 357 insertions(+), 268 deletions(-) diff --git a/muse/ChangeLog b/muse/ChangeLog index 1031a547..7a9303ed 100644 --- a/muse/ChangeLog +++ b/muse/ChangeLog @@ -1,3 +1,6 @@ +18.5 (ws) + * added "Muse templates" and "User templates" to template list + in template dialog 15.5 (rj) * Fixed hardcoded refs to qt in CMakeLists.txt 11.5 (ws) diff --git a/muse/doc/man/en/CMakeLists.txt b/muse/doc/man/en/CMakeLists.txt index 639c8ccf..a5bc1a8b 100644 --- a/muse/doc/man/en/CMakeLists.txt +++ b/muse/doc/man/en/CMakeLists.txt @@ -36,7 +36,7 @@ add_custom_target ( man-en ALL ) install_files ( /share/${MusE_INSTALL_NAME}/doc/ .pdf - ${CMAKE_CURRENT_SOURCE_DIR}/man-en.pdf ) + ${CMAKE_CURRENT_BINARY_DIR}/man-en.pdf ) set (extraClean man-en.log man-en.tmp man-en.tuo man-en.tui man-en-mpgraph.mp mpgraph.mp ) diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp index ad197e1b..4be5f45d 100644 --- a/muse/muse/muse.cpp +++ b/muse/muse/muse.cpp @@ -1138,19 +1138,23 @@ void MusE::loadProject1(const QString& path) else { TemplateDialog templateDialog; if (templateDialog.exec() == 1) { - QString path = templateDialog.templatePath(); - if (!path.isEmpty()) { - QFile f(path); + s = templateDialog.templatePath(); + if (!s.isEmpty()) { + QFile f(s); if (f.open(QIODevice::ReadOnly)) { rv = song->read(&f); f.close(); } + else { + QString msg(tr("Cannot open template file\n%1")); + QMessageBox::critical(this, header, msg.arg(s)); + } } } } if (!rv) { - QMessageBox::critical(this, QString("MusE"), - tr("File read error")); + QString msg(tr("File <%1> read error")); + QMessageBox::critical(this, header, msg.arg(s)); } tr_id->setChecked(config.transportVisible); diff --git a/muse/muse/templatedialog.cpp b/muse/muse/templatedialog.cpp index dc5efce5..1cb7436d 100644 --- a/muse/muse/templatedialog.cpp +++ b/muse/muse/templatedialog.cpp @@ -26,14 +26,14 @@ // // entry types for templateTree tree widget: // -enum { DIR_TYPE, TEMPLATE_TYPE }; +enum { DIR_TYPE, LOCAL_TEMPLATE_TYPE, GLOBAL_TEMPLATE_TYPE}; //--------------------------------------------------------- // processSubdir //--------------------------------------------------------- void TemplateDialog::processSubdir(QTreeWidgetItem* item, const QString& p, - const QString& subdir) + const QString& subdir, int type) { QDir pd(p + "/" + subdir); pd.setFilter(QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot); @@ -43,12 +43,11 @@ void TemplateDialog::processSubdir(QTreeWidgetItem* item, const QString& p, QTreeWidgetItem* pi; if (s.isDir()) { pi = new QTreeWidgetItem(item, DIR_TYPE); - pi->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon)); itemCollapsed(pi); - processSubdir(pi, pd.absolutePath(), s.fileName()); + processSubdir(pi, pd.absolutePath(), s.fileName(), type); } else { - pi = new QTreeWidgetItem(item, TEMPLATE_TYPE); + pi = new QTreeWidgetItem(item, type); pi->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon)); } pi->setText(0, s.fileName()); @@ -66,25 +65,26 @@ TemplateDialog::TemplateDialog(QWidget* parent) templateTree->setSelectionBehavior(QAbstractItemView::SelectRows); templateTree->setSelectionMode(QAbstractItemView::SingleSelection); - QDir pd(QDir::homePath() + "/" + config.templatePath); - pd.setFilter(QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot); - pd.setNameFilters(QStringList("*.med")); - QFileInfoList el = pd.entryInfoList(); - foreach (QFileInfo s, el) { - QTreeWidgetItem* pi; + // + // add global templates to list + // + QTreeWidgetItem* pi; + pi = new QTreeWidgetItem(templateTree, DIR_TYPE); + templateTree->setItemExpanded(pi, true); + itemExpanded(pi); + pi->setText(0, tr("MusE presets")); + processSubdir(pi, museGlobalShare, "templates", GLOBAL_TEMPLATE_TYPE); + + // + // add local templates to list + // + pi = new QTreeWidgetItem(templateTree, DIR_TYPE); + pi->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon)); + templateTree->setItemExpanded(pi, true); + itemExpanded(pi); + pi->setText(0, tr("User presets")); + processSubdir(pi, QDir::homePath() + "/" + config.templatePath, ".", LOCAL_TEMPLATE_TYPE); - if (s.isDir()) { - pi = new QTreeWidgetItem(templateTree, DIR_TYPE); - pi->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon)); - itemCollapsed(pi); - processSubdir(pi, pd.absolutePath(), s.fileName()); - } - else { - pi = new QTreeWidgetItem(templateTree, TEMPLATE_TYPE); - pi->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon)); - } - pi->setText(0, s.fileName()); - } connect(templateTree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(currentChanged(QTreeWidgetItem*, QTreeWidgetItem*))); @@ -132,10 +132,11 @@ QString TemplateDialog::itemPath(QTreeWidgetItem* item) const dirComponent.prepend(ti->text(0)); ti = ti->parent(); } while (ti); - foreach (QString s, dirComponent) { + size_t n = dirComponent.size(); + for (size_t i = 1; i < n; ++i) { if (!path.isEmpty()) path += "/"; - path += s; + path += dirComponent[i]; } return path; } @@ -146,7 +147,12 @@ QString TemplateDialog::itemPath(QTreeWidgetItem* item) const void TemplateDialog::currentChanged(QTreeWidgetItem* item, QTreeWidgetItem*) { - bool enable = (item != 0) && (item->type() == TEMPLATE_TYPE); + bool enable = (item != 0) && + ( + (item->type() == LOCAL_TEMPLATE_TYPE) + || + (item->type() == GLOBAL_TEMPLATE_TYPE) + ); createdDate->setEnabled(enable); modifiedDate->setEnabled(enable); comment->setEnabled(enable); @@ -155,11 +161,15 @@ void TemplateDialog::currentChanged(QTreeWidgetItem* item, QTreeWidgetItem*) if (!enable) return; - QString pd(QDir::homePath() + "/" + config.templatePath + "/"); + QString pd; + if (item->type() == LOCAL_TEMPLATE_TYPE) + pd = QDir::homePath() + "/" + config.templatePath; + else + pd = museGlobalShare + "/" + "templates"; pd += "/" + itemPath(item); - QFileInfo pf(pd + "/" + item->text(0) + ".med"); + QFileInfo pf(pd); createdDate->setDateTime(pf.created()); modifiedDate->setDateTime(pf.lastModified()); @@ -216,8 +226,13 @@ QString TemplateDialog::templatePath() const { QTreeWidgetItem* item = templateTree->currentItem(); QString s; - if (item) - s = itemPath(item); + if (item) { + if (item->type() == LOCAL_TEMPLATE_TYPE) + s = QDir::homePath() + "/" + config.templatePath; + else + s = museGlobalShare + "/" + "templates"; + s += "/" + itemPath(item); + } return s; } @@ -227,7 +242,8 @@ QString TemplateDialog::templatePath() const void TemplateDialog::itemDoubleClicked(QTreeWidgetItem* item, int) { - if (item->type() == TEMPLATE_TYPE) + if ((item->type() == LOCAL_TEMPLATE_TYPE) || + (item->type() == GLOBAL_TEMPLATE_TYPE)) accept(); } diff --git a/muse/muse/templatedialog.h b/muse/muse/templatedialog.h index 108163d1..d9fd5db9 100644 --- a/muse/muse/templatedialog.h +++ b/muse/muse/templatedialog.h @@ -31,7 +31,7 @@ class TemplateDialog : public QDialog, public Ui_TemplateDialogBase { Q_OBJECT void processSubdir(QTreeWidgetItem*, const QString&, - const QString&); + const QString&, int); QString itemPath(QTreeWidgetItem*) const; diff --git a/muse/share/templates/audio.med b/muse/share/templates/audio.med index 208313ff..e35752d8 100644 --- a/muse/share/templates/audio.med +++ b/muse/share/templates/audio.med @@ -1,20 +1,12 @@ - + - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 127 127 - 1 - -1 1 - 00:00:00:00:00 + + 00:00:00:00:00 + 0 0 0 @@ -24,292 +16,366 @@ 1 0 0 - 0 - - 1 - 298 764 - -
7 6 5 4 3 2 1 0
-
- 0 - 266 - 1 -
- - - 2 - 63 - 127 - 63 - 70 - 9 - 0 - 1 - 1 - 4 - 4 - 0 - 0 - 1 - 0 - - 0 - 28 - 31 - 33 - 29 - - - 96 - 96 - 600 - 400 - 50 - 300 - - - 96 - 96 - 80 - 50 - 0 - 0 - 600 - 400 - 0 - - - 0 - - - - 600 - 400 - + + + 1 + 0 + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 +
- 0 + 0 0 0 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 0 - 1 Track 1 - 0 0 - 0 - 0 1 - 20 - 0 + 0 1 - 0 - 0 + + + + + 31 0 - 0 - 1 - 0 - 0 - - - - Track 2 - 0 0 - 0 - 0 1 - 20 1 - 0 - 0 + 0 + + + + + 31 0 - 0 - 1 - 0 - 0 - - - - Track 3 - 0 0 - 0 - 0 1 - 20 - 0 - 0 - 0 + 0 + + + + + 31 0 - 0 - 1 - 0 - 0 - - - - Track 4 - 0 0 - 0 - 0 1 - 20 - 0 - 0 - 0 + 0 + + + + + 31 0 - 0 - 1 - 0 - 0 - - - - Group 1 - 0 0 - 0 - 0 1 - 20 1 - 0 - 0 + 0 + + + + + 31 0 - 0 - 1 - 0 - 0 - - - - Group 2 - 0 0 - 0 - 0 1 - 20 - 0 - 0 - 0 + 0 + + + + + 31 0 - 0 - 1 - 0 - 0 - - - - Aux 1 - 0 0 - 0 - 0 2 - 20 1 - 0 - 0 + 0 + + + 31 0 - 0 - 1 - - - - Aux 2 - 0 0 - 0 - 0 2 - 20 1 - 0 - 0 + 0 + + + 31 0 - 0 - 1 - - - - Input 1 - 0 1 - 0 - 0 2 - 20 1 - 1 - 0 + 0 + + + + + 31 0 - 0 - 1 - 0 - 0 - - - - Out 1 - 0 0 - 0 - 0 2 - 20 1 - 0 - 0 + 0 + + + 31 0 - 0 - 1 - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 1 + 0.04 + 1 + 0 + 0 + + 144 + 578 + + 0 @@ -323,7 +389,7 @@ 4 - - + +
diff --git a/muse/share/templates/monorecord.med b/muse/share/templates/monorecord.med index 0ee96c59..5b9c57a0 100644 --- a/muse/share/templates/monorecord.med +++ b/muse/share/templates/monorecord.med @@ -345,8 +345,8 @@ 0 0 0 - 0.000000 - 0.000000 + 0.000000 + 0.000000 @@ -366,8 +366,8 @@ 0 0 0 - 0.000000 - 0.000000 + 0.000000 + 0.000000 -- cgit v1.2.3