⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 markereditor.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: *//*    Rosegarden    A MIDI and audio sequencer and musical notation editor.     This program is Copyright 2000-2007        Guillaume Laurent   <glaurent@telegraph-road.org>,        Chris Cannam        <cannam@all-day-breakfast.com>,        Richard Bown        <richard.bown@ferventsoftware.com>     The moral rights of Guillaume Laurent, Chris Cannam, and Richard    Bown to claim authorship of this work have been asserted.     Other copyrights also apply to some parts of this work.  Please    see the AUTHORS file and individual file headers for details.     This program is free software; you can redistribute it and/or    modify it under the terms of the GNU General Public License as    published by the Free Software Foundation; either version 2 of the    License, or (at your option) any later version.  See the file    COPYING included with this distribution for more information.*/#include "MarkerEditor.h"#include "MarkerEditorViewItem.h"#include <qlayout.h>#include <kapplication.h>#include <klocale.h>#include <kstddirs.h>#include <kstdaccel.h>#include <kconfig.h>#include "misc/Debug.h"#include "misc/Strings.h"#include "base/Composition.h"#include "base/Marker.h"#include "base/RealTime.h"#include "commands/edit/AddMarkerCommand.h"#include "commands/edit/ModifyMarkerCommand.h"#include "commands/edit/RemoveMarkerCommand.h"#include "document/MultiViewCommandHistory.h"#include "document/RosegardenGUIDoc.h"#include "document/ConfigGroups.h"#include "gui/dialogs/MarkerModifyDialog.h"#include <kaction.h>#include <kcommand.h>#include <kglobal.h>#include <klistview.h>#include <kmainwindow.h>#include <kstdaccel.h>#include <kstdaction.h>#include <qaccel.h>#include <qdialog.h>#include <qframe.h>#include <qgroupbox.h>#include <qiconset.h>#include <qlabel.h>#include <qlistview.h>#include <qptrlist.h>#include <qpushbutton.h>#include <qsizepolicy.h>#include <qstring.h>#include <qtooltip.h>#include <qvbox.h>#include <qwidget.h>#include <qcanvas.h>namespace Rosegarden{MarkerEditor::MarkerEditor(QWidget *parent,                                       RosegardenGUIDoc *doc):        KMainWindow(parent, "markereditordialog"),        m_doc(doc),        m_modified(false){    QVBox* mainFrame = new QVBox(this);    setCentralWidget(mainFrame);    setCaption(i18n("Manage Markers"));    m_listView = new KListView(mainFrame);    m_listView->addColumn(i18n("Marker time  "));    m_listView->addColumn(i18n("Marker name  "));    m_listView->addColumn(i18n("Marker description "));    // Align centrally    for (int i = 0; i < 3; ++i)        m_listView->setColumnAlignment(i, Qt::AlignHCenter);    QGroupBox *posGroup = new QGroupBox(2, Horizontal,                                        i18n("Pointer position"), mainFrame);    new QLabel(i18n("Absolute time:"), posGroup);    m_absoluteTime = new QLabel(posGroup);    new QLabel(i18n("Real time:"), posGroup);    m_realTime = new QLabel(posGroup);    new QLabel(i18n("In measure:"), posGroup);    m_barTime = new QLabel(posGroup);    QFrame* btnBox = new QFrame(mainFrame);    btnBox->setSizePolicy(        QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));    QHBoxLayout* layout = new QHBoxLayout(btnBox, 4, 10);    m_addButton = new QPushButton(i18n("Add"), btnBox);    m_deleteButton = new QPushButton(i18n("Delete"), btnBox);    m_deleteAllButton = new QPushButton(i18n("Delete All"), btnBox);    m_closeButton = new QPushButton(i18n("Close"), btnBox);    QToolTip::add        (m_addButton,                i18n("Add a Marker"));    QToolTip::add        (m_deleteButton,                i18n("Delete a Marker"));    QToolTip::add        (m_deleteAllButton,                i18n("Delete All Markers"));    QToolTip::add        (m_closeButton,                i18n("Close the Marker Editor"));    layout->addStretch(10);    layout->addWidget(m_addButton);    layout->addWidget(m_deleteButton);    layout->addWidget(m_deleteAllButton);    layout->addSpacing(30);    layout->addWidget(m_closeButton);    layout->addSpacing(5);    connect(m_addButton, SIGNAL(released()),            SLOT(slotAdd()));    connect(m_deleteButton, SIGNAL(released()),            SLOT(slotDelete()));    connect(m_closeButton, SIGNAL(released()),            SLOT(slotClose()));    connect(m_deleteAllButton, SIGNAL(released()),            SLOT(slotDeleteAll()));    setupActions();    m_doc->getCommandHistory()->attachView(actionCollection());    connect(m_doc->getCommandHistory(), SIGNAL(commandExecuted()),            this, SLOT(slotUpdate()));    connect(m_listView, SIGNAL(doubleClicked(QListViewItem *)),            SLOT(slotEdit(QListViewItem *)));    connect(m_listView, SIGNAL(pressed(QListViewItem *)),            this, SLOT(slotItemClicked(QListViewItem *)));    // Highlight all columns - enable extended selection mode    //    m_listView->setAllColumnsShowFocus(true);    m_listView->setSelectionMode(QListView::Extended);    m_listView->setItemsRenameable(true);    initDialog();    setAutoSaveSettings(MarkerEditorConfigGroup, true);    m_accelerators = new QAccel(this);}voidMarkerEditor::updatePosition(){    timeT pos = m_doc->getComposition().getPosition();    m_absoluteTime->setText(QString("%1").arg(pos));    RealTime rT = m_doc->getComposition().getElapsedRealTime(pos);    long hours = rT.sec / (60 * 60);    long mins = rT.sec / 60;    long secs = rT.sec;    long msecs = rT.msec();    QString realTime, secsStr;    if (hours)        realTime += QString("%1h ").arg(hours);    if (mins)        realTime += QString("%1m ").arg(mins);    secsStr.sprintf("%ld.%03lds", secs, msecs);    realTime += secsStr;    // only update if we need to to try and avoid flickering    if (m_realTime->text() != realTime)        m_realTime->setText(realTime);    QString barTime =        QString("%1").arg(m_doc->getComposition().getBarNumber(pos) + 1);    // again only update if needed    if (m_barTime->text() != barTime)        m_barTime->setText(barTime);    /*    // Don't allow us to add another marker if there's already one    // at the current position.    //    if (m_doc->getComposition().            isMarkerAtPosition(m_doc->getComposition().getPosition()))        m_addButton->setEnabled(false);    else        m_addButton->setEnabled(true);        */}MarkerEditor::~MarkerEditor(){    RG_DEBUG << "MarkerEditor::~MarkerEditor" << endl;    m_listView->saveLayout(kapp->config(), MarkerEditorConfigGroup);    if (m_doc)        m_doc->getCommandHistory()->detachView(actionCollection());}voidMarkerEditor::initDialog(){    RG_DEBUG << "MarkerEditor::initDialog" << endl;    slotUpdate();}voidMarkerEditor::slotUpdate(){    RG_DEBUG << "MarkerEditor::slotUpdate" << endl;    //QPtrList<QListViewItem> selection = m_listView->selectedItems();    MarkerEditorViewItem *item;    m_listView->clear();    Composition::markercontainer markers =        m_doc->getComposition().getMarkers();    Composition::markerconstiterator it;    kapp->config()->setGroup(MarkerEditorConfigGroup);    int timeMode = kapp->config()->readNumEntry("timemode", 0);    for (it = markers.begin(); it != markers.end(); ++it) {        QString timeString = makeTimeString((*it)->getTime(), timeMode);        item = new               MarkerEditorViewItem(m_listView,                                    timeString,                                    strtoqstr((*it)->getName()),                                    strtoqstr((*it)->getDescription()));        // Set this for the MarkerEditor        //        item->setRawTime((*it)->getTime());        m_listView->insertItem(item);    }    if (m_listView->childCount() == 0) {        QListViewItem *item =            new MarkerEditorViewItem(m_listView, i18n("<none>"));        ((MarkerEditorViewItem *)item)->setFake(true);        m_listView->insertItem(item);        m_listView->setSelectionMode(QListView::NoSelection);    } else {        m_listView->setSelectionMode(QListView::Extended);    }    updatePosition();}voidMarkerEditor::slotDeleteAll(){    RG_DEBUG << "MarkerEditor::slotDeleteAll" << endl;    KMacroCommand *command = new KMacroCommand(i18n("Remove all markers"));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -