~ubuntu-branches/ubuntu/trusty/muse/trusty

« back to all changes in this revision

Viewing changes to muse/helper.cpp

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2013-08-28 16:25:57 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20130828162557-27ulrksfvm64td50
Tags: 2.1.2-1
* New upstream bugfix release.
* Refresh patches.
* Fix doc links.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#include <QFileInfo>
50
50
#include <QFileDialog>
51
51
#include <QString>
 
52
#include <QLine>
 
53
#include <QRect>
52
54
 
53
55
using std::set;
54
56
 
253
255
}
254
256
 
255
257
void read_new_style_drummap(Xml& xml, const char* tagname,
256
 
                            DrumMap* drummap, bool* drummap_hidden)
 
258
                            DrumMap* drummap, bool* drummap_hidden, bool compatibility)
257
259
{
258
260
        for (;;)
259
261
        {
266
268
                        case Xml::TagStart:
267
269
                                if (tag == "entry")  // then read that entry with a nested loop
268
270
        {
269
 
                                        DrumMap* dm=NULL;
 
271
          DrumMap* dm=NULL;
 
272
          DrumMap temporaryMap;
270
273
          bool* hidden=NULL;
271
274
          for (;;) // nested loop
272
275
          {
293
296
                break;
294
297
              
295
298
              case Xml::TagStart:
296
 
                if (dm==NULL)
 
299
                if (dm==NULL && compatibility == false)
297
300
                  printf("ERROR: THIS SHOULD NEVER HAPPEN: no valid 'pitch' attribute in <entry> tag, but sub-tags follow in read_new_style_drummap()!\n");
298
 
                else if (tag == "name")
 
301
                else if (dm ==NULL && compatibility == true)
 
302
                {
 
303
                   dm = &temporaryMap;
 
304
                }
 
305
                if (tag == "name")
299
306
                  dm->name = xml.parse(QString("name"));
300
307
                else if (tag == "vol")
301
308
                  dm->vol = (unsigned char)xml.parseInt();
311
318
                  dm->lv3 = xml.parseInt();
312
319
                else if (tag == "lv4")
313
320
                  dm->lv4 = xml.parseInt();
314
 
                else if (tag == "enote")
 
321
                else if (tag == "enote") {
315
322
                  dm->enote = xml.parseInt();
 
323
                  if (compatibility) {
 
324
                      int pitch = temporaryMap.enote;
 
325
                      drummap[pitch] = temporaryMap;
 
326
                      dm = &drummap[pitch];
 
327
                      hidden = drummap_hidden ? &drummap_hidden[pitch] : NULL;
 
328
                      dm->anote = pitch;
 
329
                  }
 
330
                }
316
331
                else if (tag == "mute")
317
332
                  dm->mute = xml.parseInt();
318
333
                else if (tag == "hide")
457
472
 
458
473
        if (!evenIgnoreDrumPreference && (MusEGlobal::config.drumTrackPreference==MusEGlobal::PREFER_NEW || MusEGlobal::config.drumTrackPreference==MusEGlobal::ONLY_NEW))
459
474
        {
460
 
          QAction* newdrum = addTrack->addAction(QIcon(*addtrack_drumtrackIcon),
 
475
          QAction* newdrum = addTrack->addAction(QIcon(*addtrack_newDrumtrackIcon),
461
476
                                            qApp->translate("@default", QT_TRANSLATE_NOOP("@default", "Add Drum Track")));
462
477
          newdrum->setData(MusECore::Track::NEW_DRUM);
463
478
          grp->addAction(newdrum);
472
487
        }
473
488
        if (evenIgnoreDrumPreference || MusEGlobal::config.drumTrackPreference==MusEGlobal::PREFER_OLD)
474
489
        {
475
 
          QAction* newdrum = addTrack->addAction(QIcon(*addtrack_drumtrackIcon),
 
490
          QAction* newdrum = addTrack->addAction(QIcon(*addtrack_newDrumtrackIcon),
476
491
                                            qApp->translate("@default", QT_TRANSLATE_NOOP("@default", "Add New Style Drum Track")));
477
492
          newdrum->setData(MusECore::Track::NEW_DRUM);
478
493
          grp->addAction(newdrum);
1099
1114
      return est_width;
1100
1115
      }
1101
1116
 
 
1117
//---------------------------------------------------
 
1118
//  clipQLine
 
1119
//---------------------------------------------------
 
1120
 
 
1121
QLine clipQLine(int x1, int y1, int x2, int y2, const QRect& rect)
 
1122
{
 
1123
  const int rect_x     = rect.x();
 
1124
  const int rect_y     = rect.y();
 
1125
  const int rect_right = rect_x + rect.width();
 
1126
  const int rect_bot   = rect_y + rect.height();
 
1127
  
 
1128
  if(x1 < rect_x)
 
1129
  {
 
1130
    if(x2 < rect_x)
 
1131
      return QLine();
 
1132
    x1 = rect_x;
 
1133
  }
 
1134
  else
 
1135
  if(x1 > rect_right)
 
1136
  {
 
1137
    if(x2 > rect_right)
 
1138
      return QLine();
 
1139
    x1 = rect_right;
 
1140
  }
 
1141
  
 
1142
  if(x2 < rect_x)
 
1143
    x2 = rect_x;
 
1144
  else
 
1145
  if(x2 > rect_right)
 
1146
    x2 = rect_right;
 
1147
  
 
1148
  if(y1 < rect_y)
 
1149
  {
 
1150
    if(y2 < rect_y)
 
1151
      return QLine();
 
1152
    y1 = rect_y;
 
1153
  }
 
1154
  else
 
1155
  if(y1 > rect_bot)
 
1156
  {
 
1157
    if(y2 > rect_bot)
 
1158
      return QLine();
 
1159
    y1 = rect_bot;
 
1160
  }
 
1161
  
 
1162
  if(y2 < rect_y)
 
1163
    y2 = rect_y;
 
1164
  if(y2 > rect_bot)
 
1165
    y2 = rect_bot;
 
1166
 
 
1167
  return QLine(x1, y1, x2, y2);
 
1168
}
1102
1169
 
1103
1170
 
1104
1171
} // namespace MusEGui