void Presenter::on_zoomRatioChanged(ZoomRatio zr) { m_zr = zr; m_view->setDefaultWidth(m_layer.duration().toPixels(m_zr)); for (auto note : m_notes) updateNote(*note); }
void Presenter::setupNote(NoteView& v) { con(v.note, &Note::noteChanged, &v, [&] { updateNote(v); }); con(v, &NoteView::noteChangeFinished, this, [&] { const auto [min, max] = this->m_layer.range(); auto newPos = v.pos(); auto rect = m_view->boundingRect(); auto height = rect.height(); // Snap to grid : we round y to the closest multiple of 127 int note = ossia::clamp( int(max - (qMin(rect.bottom(), qMax(newPos.y(), rect.top())) / height) * this->m_view->visibleCount()), min, max); auto notes = selectedNotes(); auto it = ossia::find(notes, v.note.id()); if (it == notes.end()) { notes = {v.note.id()}; } m_ongoing.submit( m_layer, notes, note - v.note.pitch(), newPos.x() / m_view->defaultWidth() - v.note.start()); m_ongoing.commit(); });
void Presenter::setWidth(qreal val) { m_view->setWidth(val); m_view->setDefaultWidth(m_layer.duration().toPixels(m_zr)); for (auto note : m_notes) updateNote(*note); }
/** * \brief Supprime une ligne d'éditeur des lignes d'éditeur du DocumentEditor * \param row ligne d'éditeur */ void DocumentEditor::supress(DocumentEditorRow* row){ rows.removeOne(row); scrollLayout->removeWidget(row); delete row; enableSave(); updateNote(); }
/** * \brief Sauvegarde la note édité sur le disque dur */ void NoteEditor::saveNote(){ updateNote(); NotesManager::getInstance().saveNote(resource->getId()); save->setEnabled(false); resource->isModified(false); QMessageBox::information(this, "Sauvegarde", "Votre note à bien été sauvegardée."); }
/** * \brief Constructeur de l'éditeur de note binaires * \param b binaire ressource */ BinaryEditor::BinaryEditor(Binary *b, QWidget *parent) : NoteEditor(b, parent), resource(b) { description = new QTextEdit(); description->setText(resource->getDescription()); QObject::connect(description, SIGNAL(textChanged()), this, SLOT(enableSave())); QObject::connect(description, SIGNAL(textChanged()), this, SLOT(updateNote())); layout->addWidget(description); }
/** * \brief Constructeur d'un éditeur d'article * \param note Pointeur sur l'article à éditer */ ArticleEditor::ArticleEditor(Article *a, QWidget *parent) : NoteEditor(a, parent), resource(a) { text = new QTextEdit(); QObject::connect(text, SIGNAL(textChanged()), this, SLOT(enableSave())); QObject::connect(text, SIGNAL(textChanged()), this, SLOT(updateNote())); text->setText(resource->getText()); layout->addWidget(text); }
bool GameLayer::onButtonClicked(CCSprite* button, int index) { if(Sudoku::state == Note && !Sudoku::isCurPosFilled()) { Sudoku::notes[Sudoku::position.x][Sudoku::position.y].toggle(index + 1); updateNote(Sudoku::position.x, Sudoku::position.y); updateBackplane(); return true; } return false; }
BinaryWidget::BinaryWidget(Binary *bin, QWidget *parent):NoteWidget(parent),note(bin) { description = new QTextEdit(note->getDescription()); path = new QLineEdit(note->getPath()); title->setText(note->getTitle()); changePathB = new QPushButton("...", this); QHBoxLayout* pathLayout = new QHBoxLayout; pathLayout->addWidget(path); pathLayout->addWidget(changePathB); binaryLayout = new QHBoxLayout; layout->addLayout(binaryLayout); layout->addLayout(pathLayout); layout->addWidget(description); connect(changePathB, SIGNAL(clicked()), this, SLOT(changePath())); connect(path,SIGNAL(textChanged(QString)),this,SLOT(updateNote())); connect(description,SIGNAL(textChanged()),this,SLOT(updateNote())); }
/** * \brief Constructeur d'un éditeur de note * \details Construit les parties permettant d'associer un tag à une note, * editer le titre de la note et sauvegarder la note * \param note Pointeur sur la note à éditer */ NoteEditor::NoteEditor(Note *note, QWidget *parent) : resource(note) { setParent(parent); // top tag row QLabel* tagsLabel = new QLabel("Tags associés : "); tags = new QComboBox(this); QLabel* deleteTagLabel = new QLabel("Supprimer un tag : "); deleteTag = new QComboBox(this); for(QMultiMap<QString, QString>::iterator it = TagManager::getInstance().getAssociatedTagsBegin() ; it != TagManager::getInstance().getAssociatedTagsEnd(); ++it){ if (it.value() == note->getId()) { tags->addItem(it.key()); deleteTag->addItem(it.key()); } } deleteTagBtn = new QPushButton(this); deleteTagBtn->setIcon(QIcon("supprimer.png")); QObject::connect(deleteTagBtn, SIGNAL(clicked()), this, SLOT(deleteAssociatedTag())); QLabel* addTagLabel = new QLabel("Associer un tag : "); addTag = new QComboBox(this); for(QSet<QString>::iterator it = TagManager::getInstance().getTagsBegin() ; it != TagManager::getInstance().getTagsEnd(); ++it){ addTag->addItem((*it)); } addTagBtn = new QPushButton(this); addTagBtn->setIcon(QIcon("ajouter.png")); QObject::connect(addTagBtn, SIGNAL(clicked()), this, SLOT(addAssociatedTag())); QHBoxLayout* tagRowLayout = new QHBoxLayout; tagRowLayout->addWidget(tagsLabel); tagRowLayout->addWidget(tags); tagRowLayout->addWidget(deleteTagLabel); tagRowLayout->addWidget(deleteTag); tagRowLayout->addWidget(deleteTagBtn); tagRowLayout->addWidget(addTagLabel); tagRowLayout->addWidget(addTag); tagRowLayout->addWidget(addTagBtn); // title and save title = new QLineEdit; save = new QPushButton; save->setIcon(QIcon("sauvegarder.png")); title->setText(note->getTitle()); QObject::connect(title, SIGNAL(textChanged(QString)), this, SLOT(enableSave())); QObject::connect(title, SIGNAL(textChanged(QString)), this, SLOT(updateNote())); save->setEnabled(false); QObject::connect(save, SIGNAL(clicked()), this, SLOT(saveNote())); layout = new QVBoxLayout; QHBoxLayout* hLayout = new QHBoxLayout; hLayout->addWidget(title); hLayout->addWidget(save); layout->addLayout(tagRowLayout); layout->addLayout(hLayout); this->setLayout(layout); QObject::connect(&TagManager::getInstance(), SIGNAL(onTagAdd(QString)), this, SLOT(tagCreated(QString))); QObject::connect(&TagManager::getInstance(), SIGNAL(onTagDelete(QString)), this, SLOT(tagDeleted(QString))); }
/** * \brief Insère une nouvelle ligne d'éditeur dans l'éditeur du document * \param row ligne d'éditeur * \param rowIndex index où la ligne doit être inséré dans la liste des lignes d'éditeurs * \param layoutIndex index où la ligne doit être inséré dans le layout des lignes d'éditeurs */ void DocumentEditor::insertRow(DocumentEditorRow *row, int rowIndex, int layoutIndex){ rows.insert(rowIndex, row); scrollLayout->insertWidget(layoutIndex, row); QObject::connect(row, SIGNAL(onMoveUp(DocumentEditorRow*)), this, SLOT(moveUp(DocumentEditorRow*))); QObject::connect(row, SIGNAL(onMoveDown(DocumentEditorRow*)), this, SLOT(moveDown(DocumentEditorRow*))); QObject::connect(row, SIGNAL(onEdit(DocumentEditorRow*)), this, SLOT(edit(DocumentEditorRow*))); QObject::connect(row, SIGNAL(onSupress(DocumentEditorRow*)), this, SLOT(supress(DocumentEditorRow*))); QObject::connect(row, SIGNAL(onAdd(DocumentEditorRow*)), this, SLOT(add(DocumentEditorRow*))); QObject::connect(row, SIGNAL(onCreate(DocumentEditorRow*)), this, SLOT(create(DocumentEditorRow*))); enableSave(); updateNote(); }
/** * \brief Descend une ligne d'éditeur d'un cran * \param row ligne d'éditeur */ void DocumentEditor::moveDown(DocumentEditorRow* row){ int list_index = rows.indexOf(row); int layout_index = scrollLayout->indexOf(row); if(list_index < rows.count() - 1){ rows.swap(list_index + 1, list_index); } if(layout_index < scrollLayout->count() -1){ // for tag row and title row scrollLayout->removeWidget(row); scrollLayout->insertWidget(layout_index + 1, row); } enableSave(); updateNote(); }
void Presenter::setHeight(qreal val) { m_view->setHeight(val); for (auto note : m_notes) updateNote(*note); }
void EditorWindows::saveNote() { updateNote(); Fenetre::getInstance().getNote()->save(); }