~ubuntu-branches/ubuntu/wily/muse/wily-proposed

« back to all changes in this revision

Viewing changes to muse/widgets/function_dialogs/move.cpp

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2011-12-03 17:12:54 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20111203171254-28b1j4lpb46r5jtl
Tags: 2.0~rc1-1
* New upstream RC release.
* Refresh patches, remove those patches not needed anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=========================================================
 
2
//  MusE
 
3
//  Linux Music Editor
 
4
//    $Id: move.cpp,v 1.1.1.1 2011/05/05 18:51:04 flo93 Exp $
 
5
//  (C) Copyright 2011 Florian Jung (flo93@sourceforge.net)
 
6
//
 
7
//  This program is free software; you can redistribute it and/or
 
8
//  modify it under the terms of the GNU General Public License
 
9
//  as published by the Free Software Foundation; version 2 of
 
10
//  the License, or (at your option) any later version.
 
11
//
 
12
//  This program is distributed in the hope that it will be useful,
 
13
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
//  GNU General Public License for more details.
 
16
//
 
17
//  You should have received a copy of the GNU General Public License
 
18
//  along with this program; if not, write to the Free Software
 
19
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
20
//
 
21
//=========================================================
 
22
 
 
23
#include <QButtonGroup>
 
24
#include "move.h"
 
25
#include "xml.h"
 
26
 
 
27
namespace MusEGui {
 
28
 
 
29
Move::Move(QWidget* parent)
 
30
        : QDialog(parent)
 
31
{
 
32
        setupUi(this);
 
33
        range_group = new QButtonGroup;
 
34
        range_group->addButton(all_events_button,0);
 
35
        range_group->addButton(selected_events_button,1);
 
36
        range_group->addButton(looped_events_button,2);
 
37
        range_group->addButton(selected_looped_button,3);
 
38
        
 
39
        pull_values();
 
40
}
 
41
 
 
42
void Move::pull_values()
 
43
{
 
44
        range = range_group->checkedId();
 
45
        amount = amount_spinbox->value();
 
46
}
 
47
 
 
48
void Move::accept()
 
49
{
 
50
        pull_values();
 
51
        QDialog::accept();
 
52
}
 
53
 
 
54
int Move::exec()
 
55
{
 
56
        if ((range < 0) || (range > 3)) range=0;
 
57
        
 
58
        range_group->button(range)->setChecked(true);
 
59
        amount_spinbox->setValue(amount);
 
60
        
 
61
        return QDialog::exec();
 
62
}
 
63
 
 
64
 
 
65
void Move::read_configuration(MusECore::Xml& xml)
 
66
{
 
67
        for (;;)
 
68
        {
 
69
                MusECore::Xml::Token token = xml.parse();
 
70
                if (token == MusECore::Xml::Error || token == MusECore::Xml::End)
 
71
                        break;
 
72
                        
 
73
                const QString& tag = xml.s1();
 
74
                switch (token)
 
75
                {
 
76
                        case MusECore::Xml::TagStart:
 
77
                                if (tag == "range")
 
78
                                        range=xml.parseInt();
 
79
                                else if (tag == "amount")
 
80
                                        amount=xml.parseInt();
 
81
                                else
 
82
                                        xml.unknown("Move");
 
83
                                break;
 
84
                                
 
85
                        case MusECore::Xml::TagEnd:
 
86
                                if (tag == "move")
 
87
                                        return;
 
88
                                
 
89
                        default:
 
90
                                break;
 
91
                }
 
92
        }
 
93
}
 
94
 
 
95
void Move::write_configuration(int level, MusECore::Xml& xml)
 
96
{
 
97
        xml.tag(level++, "move");
 
98
        xml.intTag(level, "range", range);
 
99
        xml.intTag(level, "amount", amount);
 
100
        xml.tag(level, "/move");
 
101
}
 
102
 
 
103
} // namespace MusEGui