cyrille / braindump

Braindump is a tool to dump and organize the content of your brain (ideas, drawings, images, texts...) to your computer.

Clone this repository (size: 744.2 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/cyrille/braindump/
commit 454: b0055b346166
parent 453: 5a3af1af22b9
branch: default
push sections to be saved when duplicated
Cyrille Berger
7 months ago

Changed (Δ449 bytes):

raw changeset »

src/DocumentModel.cpp (1 lines added, 1 lines removed)

src/SectionsBoxDock.cpp (4 lines added, 4 lines removed)

src/commands/InsertSectionCommand.cpp (4 lines added, 2 lines removed)

src/commands/InsertSectionCommand.h (4 lines added, 2 lines removed)

Up to file-list src/DocumentModel.cpp:

@@ -237,7 +237,7 @@ bool DocumentModel::dropMimeData( const
237
237
      if(row < 0) {
238
238
        row = group->sections().count();
239
239
      }
240
      m_document->addCommand(section, new InsertSectionCommand(new Section(*section), group, this, row));
240
      m_document->addCommand(section, new InsertSectionCommand( m_document->sectionsIO(), new Section(*section), group, this, row));
241
241
    } else {
242
242
      int idx =group->indexOf(section);
243
243
      if( 0 <= idx and idx < row ) {

Up to file-list src/SectionsBoxDock.cpp:

@@ -171,7 +171,7 @@ void SectionsBoxDock::slotDuplicateClick
171
171
{
172
172
  Section* section = new Section(*m_view->activeSection());
173
173
  m_view->rootSection()->addCommand( section,
174
          new InsertSectionCommand(section, m_view->activeSection()->sectionParent(), m_model,
174
          new InsertSectionCommand(m_view->rootSection()->sectionsIO(), section, m_view->activeSection()->sectionParent(), m_model,
175
175
                          m_view->activeSection()->sectionParent()->nextSection(m_view->activeSection())) );
176
176
}
177
177
@@ -180,7 +180,7 @@ void SectionsBoxDock::slotNewSectionAsCh
180
180
  Q_ASSERT(m_view->activeSection());
181
181
  Section* section = new Section();
182
182
  section->setName(SectionGroup::nextName());
183
  m_view->rootSection()->addCommand(section, new InsertSectionCommand(section, m_view->activeSection(), m_model, 0));
183
  m_view->rootSection()->addCommand(section, new InsertSectionCommand(m_view->rootSection()->sectionsIO(), section, m_view->activeSection(), m_model, 0));
184
184
}
185
185
186
186
void SectionsBoxDock::slotNewSectionAboveCurrent()
@@ -188,7 +188,7 @@ void SectionsBoxDock::slotNewSectionAbov
188
188
  SectionGroup* parentSection = m_view->activeSection() ? m_view->activeSection()->sectionParent() : m_view->rootSection();
189
189
  Section* section = new Section();
190
190
  section->setName(SectionGroup::nextName());
191
  m_view->rootSection()->addCommand(section, new InsertSectionCommand(section, parentSection, m_model, m_view->activeSection()));
191
  m_view->rootSection()->addCommand(section, new InsertSectionCommand(m_view->rootSection()->sectionsIO(), section, parentSection, m_model, m_view->activeSection()));
192
192
}
193
193
194
194
void SectionsBoxDock::slotNewSectionBellowCurrent()
@@ -197,7 +197,7 @@ void SectionsBoxDock::slotNewSectionBell
197
197
  Section* above = parentSection->nextSection( m_view->activeSection() );
198
198
  Section* section = new Section();
199
199
  section->setName(SectionGroup::nextName());
200
  m_view->rootSection()->addCommand(section, new InsertSectionCommand(section, parentSection, m_model, above));
200
  m_view->rootSection()->addCommand(section, new InsertSectionCommand(m_view->rootSection()->sectionsIO(), section, parentSection, m_model, above));
201
201
}
202
202
203
203
void SectionsBoxDock::selectSection(Section* section)

Up to file-list src/commands/InsertSectionCommand.cpp:

20
20
#include "InsertSectionCommand.h"
21
21
#include "DocumentModel.h"
22
22
#include "Section.h"
23
#include <SectionsIO.h>
23
24
24
InsertSectionCommand::InsertSectionCommand( Section* _section, SectionGroup* _parent, DocumentModel* _model, Section* _above ) : m_section(_section), m_parent(_parent), m_model(_model), m_above(_above), m_idx(-1)
25
InsertSectionCommand::InsertSectionCommand( SectionsIO* _sectionIO, Section* _section, SectionGroup* _parent, DocumentModel* _model, Section* _above ) : m_sectionIO(_sectionIO), m_section(_section), m_parent(_parent), m_model(_model), m_above(_above), m_idx(-1)
25
26
{
26
27
  Q_ASSERT( _above == 0 or _parent == _above->sectionParent());
27
28
}
28
29
29
InsertSectionCommand::InsertSectionCommand( Section* _section, SectionGroup* _parent, DocumentModel* _model, int _idx ) : m_section(_section), m_parent(_parent), m_model(_model), m_above(0), m_idx(_idx)
30
InsertSectionCommand::InsertSectionCommand( SectionsIO* _sectionIO, Section* _section, SectionGroup* _parent, DocumentModel* _model, int _idx ) : m_sectionIO(_sectionIO), m_section(_section), m_parent(_parent), m_model(_model), m_above(0), m_idx(_idx)
30
31
{
31
32
  Q_ASSERT( _idx >= 0 and _idx <= _parent->sections().count());
32
33
}
@@ -38,6 +39,7 @@ void InsertSectionCommand::undo()
38
39
39
40
void InsertSectionCommand::redo()
40
41
{
42
  m_sectionIO->push(m_section, SectionsIO::RecursivePush);
41
43
  if(m_above or m_idx == -1) {
42
44
    m_model->insertSection(m_section, m_parent, m_above);
43
45
  } else {

Up to file-list src/commands/InsertSectionCommand.h:

24
24
25
25
class DocumentModel;
26
26
class Section;
27
class SectionsIO;
27
28
class SectionGroup;
28
29
29
30
class InsertSectionCommand : public QUndoCommand {
30
31
public:
31
  InsertSectionCommand( Section* _section, SectionGroup* _parent, DocumentModel* _model, Section* _above );
32
  InsertSectionCommand( Section* _section, SectionGroup* _parent, DocumentModel* _model, int _idx );
32
  InsertSectionCommand( SectionsIO* _sectionIO, Section* _section, SectionGroup* _parent, DocumentModel* _model, Section* _above );
33
  InsertSectionCommand( SectionsIO* _sectionIO, Section* _section, SectionGroup* _parent, DocumentModel* _model, int _idx );
33
34
  virtual void undo();
34
35
  virtual void redo();
35
36
private:
37
  SectionsIO* m_sectionIO;
36
38
  Section* m_section;
37
39
  SectionGroup *m_parent;
38
40
  DocumentModel* m_model;