File indexing completed on 2024-05-12 16:34:17
0001 /* This file is part of the KDE project 0002 * Copyright 2007,2009 Marijn Kruisselbrink <mkruisselbrink@kde.org> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 #ifndef SIMPLEENTRY_TOOL 0020 #define SIMPLEENTRY_TOOL 0021 0022 #include <QPointF> 0023 #include <KoToolBase.h> 0024 #include "core/Chord.h" 0025 0026 class MusicShape; 0027 class KUndo2Command; 0028 class AbstractMusicAction; 0029 class MusicCursor; 0030 class QMenu; 0031 0032 namespace MusicCore { 0033 class Staff; 0034 } 0035 0036 /** 0037 * Tool that provides functionality to insert/remove notes/rests. Named after Finale's Simple Entry tool. 0038 */ 0039 class SimpleEntryTool : public KoToolBase 0040 { 0041 Q_OBJECT 0042 public: 0043 explicit SimpleEntryTool( KoCanvasBase* canvas ); 0044 ~SimpleEntryTool() override; 0045 0046 void paint( QPainter& painter, const KoViewConverter& converter ) override; 0047 0048 void mousePressEvent( KoPointerEvent* event ) override ; 0049 void mouseMoveEvent( KoPointerEvent* event ) override; 0050 void mouseReleaseEvent( KoPointerEvent* event ) override; 0051 0052 void keyPressEvent( QKeyEvent *event ) override; 0053 0054 void activate(ToolActivation toolActivation, const QSet<KoShape*> &shapes) override; 0055 void deactivate() override; 0056 0057 void addCommand(KUndo2Command* command); 0058 0059 MusicShape* shape(); 0060 int voice(); 0061 0062 void setSelection(int startBar, int endBar, MusicCore::Staff* startStaff, MusicCore::Staff* endStaff); 0063 protected: 0064 QWidget * createOptionWidget() override; 0065 protected Q_SLOTS: 0066 void activeActionChanged(QAction* action); 0067 void voiceChanged(int voice); 0068 void addBars(); 0069 void actionTriggered(); 0070 void importSheet(); 0071 void exportSheet(); 0072 private: 0073 MusicShape *m_musicshape; 0074 AbstractMusicAction* m_activeAction; 0075 QPointF m_point; 0076 int m_voice; 0077 0078 MusicCore::Staff* m_contextMenuStaff; 0079 int m_contextMenuBar; 0080 QPointF m_contextMenuPoint; 0081 0082 int m_selectionStart, m_selectionEnd; 0083 MusicCore::Staff *m_selectionStaffStart, *m_selectionStaffEnd; 0084 0085 MusicCursor* m_cursor; 0086 QList<QMenu*> m_menus; 0087 }; 0088 0089 #endif 0090