• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ossia / score / 34039060546

06 Sep 2026 02:24PM UTC coverage: 26.369% (+1.8%) from 24.579%
34039060546

push

github

jcelerier
3rdparty: updat libossia

60871 of 230846 relevant lines covered (26.37%)

63602.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.62
/src/plugins/score-lib-process/Process/Script/MultiScriptEditor.hpp
1
#pragma once
2
#include <score/command/Dispatchers/CommandDispatcher.hpp>
3
#include <score/command/PropertyCommand.hpp>
4
#include <score/document/DocumentContext.hpp>
5
#include <score/tools/Bind.hpp>
6

7
#include <QCloseEvent>
8
#include <QDialog>
9

10
#include <score_lib_process_export.h>
11

12
class QPlainTextEdit;
13
class QTextEdit;
14
class QTabWidget;
15

16
namespace Process
17
{
18
class ProcessModel;
19
class SCORE_LIB_PROCESS_EXPORT MultiScriptDialog : public QDialog
20
{
21
public:
22
  MultiScriptDialog(const score::DocumentContext& ctx, QWidget* parent);
23

24
  QSize sizeHint() const override { return {800, 300}; }
×
25
  std::vector<QString> text() const noexcept;
26

27
  void addTab(const QString& name, const QString& text, const std::string_view language);
28
  void setText(int idx, const QString& str);
29
  void setError(const QString& str);
30
  void clearError();
31
  void openInExternalEditor(const QString& editorPath);
32

33
protected:
34
  virtual void on_accepted() = 0;
35

36
  void hideEvent(QHideEvent* event) override;
37
  void keyPressEvent(QKeyEvent* event) override;
38

39
  const score::DocumentContext& m_context;
40
  QObject* m_compileFilter{};
41
  QTabWidget* m_tabs{};
42
  struct EditorTab
43
  {
44
    QTextEdit* textedit{};
45
  };
46
  std::vector<EditorTab> m_editors;
47
  QPlainTextEdit* m_error{};
48
};
49

50
template <typename Process_T, typename Property_T>
51
class ProcessMultiScriptEditDialog : public MultiScriptDialog
52
{
53
public:
54
  using param_type = typename Property_T::param_type;
55
  ProcessMultiScriptEditDialog(
66✔
56
      const Process_T& process, const score::DocumentContext& ctx, QWidget* parent)
57
      : MultiScriptDialog{ctx, parent}
66✔
58
      , m_process{process}
66✔
59
  {
66✔
60
    const auto& prop = (m_process.*Property_T::get)();
66✔
61
    for(auto& [name, addr, lang] : param_type::specification)
198✔
62
    {
63
      addTab(name, prop.*addr, lang);
396✔
64
    }
65

66
    con(m_process, Property_T::notify, this, [this]() {
78✔
67
      const auto& prop = (m_process.*Property_T::get)();
12✔
68
      int i = 0;
12✔
69
      for(auto& [name, addr, lang] : param_type::specification)
36✔
70
      {
71
        setText(i, prop.*addr);
48✔
72
        i++;
24✔
73
      }
74
    });
12✔
75

76
    con(m_process, &Process_T::errorMessage, this,
132✔
77
        &ProcessMultiScriptEditDialog::setError);
66✔
78
    // The process goes first when its document closes: the dialog can still
79
    // get closed after that (with the document's view) and must not look at
80
    // it any more.
81
    con(m_process, &IdentifiedObjectAbstract::identified_object_destroying, this,
132✔
82
        [this] {
71✔
83
      m_processGone = true;
5✔
84
      deleteLater();
5✔
85
    });
5✔
86
  }
66✔
87

88
  void on_accepted() override
6✔
89
  {
90
    this->clearError();
6✔
91
    if(this->text() != (m_process.*Property_T::get)())
6✔
92
    {
93
      // TODO try to see if we can make this a bit more efficient,
94
      // by passing the validated / transformed data to the command maybe ?
95
      if(m_process.validate(this->text()))
6✔
96
      {
97
        CommandDispatcher<>{m_context.commandStack}.submit(
12✔
98
            new score::StaticPropertyCommand<Property_T>{
6✔
99
                m_process, this->text(), m_context});
6✔
100
      }
6✔
101
    }
6✔
102
  }
6✔
103

104
protected:
105
  const Process_T& m_process;
106
  bool m_processGone{};
66✔
107

108
  // See ProcessScriptEditDialog
109
  void reject() override { close(); }
1✔
110

111
  void closeEvent(QCloseEvent* event) override
62✔
112
  {
113
    if(!m_processGone && m_process.scriptUI == this)
62✔
114
    {
115
      const_cast<QWidget*&>(m_process.scriptUI) = nullptr;
61✔
116
      m_process.scriptUIVisible(false);
61✔
117
    }
61✔
118
    event->accept();
62✔
119
  }
62✔
120
};
121

122
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc