PageRenderTime 28ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/rosegarden-12.04/src/gui/dialogs/FileMergeDialog.cpp

#
C++ | 119 lines | 72 code | 19 blank | 28 comment | 5 complexity | e05b7a5bc026a59066ee00a0cb6906a7 MD5 | raw file
Possible License(s): GPL-2.0
  1. /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
  2. /*
  3. Rosegarden
  4. A MIDI and audio sequencer and musical notation editor.
  5. Copyright 2000-2012 the Rosegarden development team.
  6. Other copyrights also apply to some parts of this work. Please
  7. see the AUTHORS file and individual file headers for details.
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public License as
  10. published by the Free Software Foundation; either version 2 of the
  11. License, or (at your option) any later version. See the file
  12. COPYING included with this distribution for more information.
  13. */
  14. #include "FileMergeDialog.h"
  15. #include <QComboBox>
  16. #include <QDialog>
  17. #include <QDialogButtonBox>
  18. #include <QCheckBox>
  19. #include <QLabel>
  20. #include <QString>
  21. #include <QWidget>
  22. #include <QVBoxLayout>
  23. #include <QHBoxLayout>
  24. #include <QUrl>
  25. #include <QDesktopServices>
  26. #include "document/RosegardenDocument.h"
  27. namespace Rosegarden
  28. {
  29. FileMergeDialog::FileMergeDialog(QWidget *parent,
  30. QString /*fileName*/,
  31. bool timingsDiffer) :
  32. QDialog(parent)
  33. {
  34. //###
  35. //&&&
  36. // This one will take some thought. We're going to have to figure out some
  37. // new help system. This //setHelp() call is from KDialog, which we are no
  38. // longer using. Until we have the new help system sorted, I don't see
  39. // anything useful to do with this, so I'm disabling it for now.
  40. //
  41. ////setHelp("file-merge");
  42. setModal(true);
  43. setWindowTitle(tr("Merge File"));
  44. QGridLayout *metagrid = new QGridLayout;
  45. setLayout(metagrid);
  46. QWidget *vbox = new QWidget(this);
  47. QVBoxLayout *vboxLayout = new QVBoxLayout;
  48. metagrid->addWidget(vbox, 0, 0);
  49. QWidget *hbox = new QWidget( vbox );
  50. vboxLayout->addWidget(hbox);
  51. QHBoxLayout *hboxLayout = new QHBoxLayout;
  52. QLabel *child_3 = new QLabel(tr("Merge new file "), hbox );
  53. hboxLayout->addWidget(child_3);
  54. m_choice = new QComboBox( hbox );
  55. hboxLayout->addWidget(m_choice);
  56. hbox->setLayout(hboxLayout);
  57. m_choice->addItem(tr("At start of existing composition"));
  58. m_choice->addItem(tr("From end of existing composition"));
  59. m_useTimings = 0;
  60. if (timingsDiffer) {
  61. new QLabel(tr("The file has different time signatures or tempos."), vbox);
  62. m_useTimings = new QCheckBox(tr("Import these as well"), vbox );
  63. vboxLayout->addWidget(m_useTimings);
  64. vbox->setLayout(vboxLayout);
  65. m_useTimings->setChecked(false);
  66. }
  67. QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
  68. metagrid->addWidget(buttonBox, 1, 0);
  69. metagrid->setRowStretch(0, 10);
  70. connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
  71. connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
  72. connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(slotHelpRequested()));
  73. }
  74. int
  75. FileMergeDialog::getMergeOptions()
  76. {
  77. int options = MERGE_KEEP_OLD_TIMINGS | MERGE_IN_NEW_TRACKS;
  78. if (m_choice->currentIndex() == 1) {
  79. options |= MERGE_AT_END;
  80. }
  81. if (m_useTimings && m_useTimings->isChecked()) {
  82. options |= MERGE_KEEP_NEW_TIMINGS;
  83. }
  84. return options;
  85. }
  86. void
  87. FileMergeDialog::slotHelpRequested()
  88. {
  89. // TRANSLATORS: if the manual is translated into your language, you can
  90. // change the two-letter language code in this URL to point to your language
  91. // version, eg. "http://rosegardenmusic.com/wiki/doc:fileMergeDialog-es" for the
  92. // Spanish version. If your language doesn't yet have a translation, feel
  93. // free to create one.
  94. QString helpURL = tr("http://rosegardenmusic.com/wiki/doc:fileMergeDialog-en");
  95. QDesktopServices::openUrl(QUrl(helpURL));
  96. }
  97. }
  98. #include "FileMergeDialog.moc"