-
Notifications
You must be signed in to change notification settings - Fork 2
/
DocumentEditor.cpp
70 lines (63 loc) · 3.03 KB
/
DocumentEditor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "DocumentEditor.h"
#include "Document.h"
#include <QWidget>
#include <QToolBar>
#include "NotesManager.h"
#include "NoteTypeSignalAction.h"
#include "mainwindow.h"
DocumentEditor::DocumentEditor(Document* doc, QWidget *parent)
:Editor(doc, parent)
{
NoteTypeSignalAction *actionNewArticle = new NoteTypeSignalAction(article, "&Article", this);
NoteTypeSignalAction *actionNewAudioNote = new NoteTypeSignalAction(audioNote, "&AudioNote", this);
NoteTypeSignalAction *actionNewVideoNote = new NoteTypeSignalAction(videoNote, "&VideoNote", this);
NoteTypeSignalAction *actionNewDocument = new NoteTypeSignalAction(document, "&Document", this);
NoteTypeSignalAction *actionNewImageNote = new NoteTypeSignalAction(imageNote, "&ImageNote", this);
actionNewAudioNote->setIcon(QIcon(":images/music"));
actionNewArticle->setIcon(QIcon(":images/article"));
actionNewDocument->setIcon(QIcon(":images/document"));
actionNewImageNote->setIcon(QIcon(":images/image"));
actionNewVideoNote->setIcon(QIcon(":images/video"));
toolBar = new QToolBar();
// toolBar->setBackgroundRole(QPalette::NColorRoles);
toolBar->addAction(actionNewArticle);
toolBar->addAction(actionNewImageNote);
toolBar->addAction(actionNewAudioNote);
toolBar->addAction(actionNewVideoNote);
toolBar->addAction(actionNewDocument);
for(QList<Note*>::const_iterator it = doc->begin(); it != doc->end(); ++it){
contentLayout->addWidget((*it)->createAndAttachEditor());
}
QObject::connect(actionNewArticle, SIGNAL(triggeredWithId(const int)), this, SLOT(UI_NEW_NOTE_EDITOR(const int)));
QObject::connect(actionNewDocument, SIGNAL(triggeredWithId(const int)), this, SLOT(UI_NEW_NOTE_EDITOR(const int)));
QObject::connect(actionNewImageNote, SIGNAL(triggeredWithId(const int)), this, SLOT(UI_NEW_NOTE_EDITOR(const int)));
QObject::connect(actionNewAudioNote, SIGNAL(triggeredWithId(const int)), this, SLOT(UI_NEW_NOTE_EDITOR(const int)));
QObject::connect(actionNewVideoNote, SIGNAL(triggeredWithId(const int)), this, SLOT(UI_NEW_NOTE_EDITOR(const int)));
contentLayout->addWidget(toolBar);
}
void DocumentEditor::BACKEND_SET_CONTENT()
{
}
void DocumentEditor::UI_NEW_NOTE_EDITOR(const int type)
{
NoteType nt;
try{
nt = static_cast<NoteType>(type);
}catch(std::bad_cast& bc){
QMessageBox::critical(this, "Error", "something serious happenned during creation of new editor..."+QString(bc.what()));
}
try{
Note* temp = &NotesManager::getInstance().getNewNote(nt);
Editor* noteEditor = temp->createAndAttachEditor();
noteEditor->setDocumentBtnText(this->getRessource()->getTitle());
this->getRessource()->addNote(temp);
contentLayout->removeWidget(toolBar);
contentLayout->addWidget(noteEditor);
contentLayout->addWidget(toolBar);
MainWindow::getInstance()->addRessources(temp);
}
catch(NotesException e){
QMessageBox::critical(this, "Error", e.getInfo());
}
MainWindow::getInstance()->updateSideBar();
}