-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
601 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "dictcommands.h" | ||
#include "commands.h" | ||
#include "skrdata.h" | ||
|
||
DictCommands::DictCommands(QObject *parent, QUndoStack *undoStack) | ||
: QObject{parent}, m_undoStack(undoStack) | ||
{ | ||
m_instance = this; | ||
commands->subscribe(this); | ||
} | ||
// ---------------------------------------------------------------------------- | ||
|
||
|
||
DictCommands *DictCommands::m_instance = nullptr; | ||
|
||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
|
||
|
||
QUndoStack *DictCommands::undoStack() const | ||
{ | ||
return m_undoStack; | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
|
||
void DictCommands::addWordToProjectDict(int projectId, const QString &word) | ||
{ | ||
m_undoStack->push(new AddWordToProjectDictCommand(projectId, word)); | ||
|
||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
|
||
|
||
Command *DictCommands::getCommand(const QString &action, const QVariantMap ¶meters) | ||
{ | ||
//TODO: fill | ||
} | ||
|
||
|
||
//------------------------------------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------------------------------------ | ||
|
||
AddWordToProjectDictCommand::AddWordToProjectDictCommand(int projectId, const QString &word) : Command("Add word to project dictionary"), | ||
m_projectId(projectId), m_word(word) | ||
{ | ||
|
||
} | ||
|
||
void AddWordToProjectDictCommand::undo() | ||
{ | ||
skrdata->projectDictHub()->removeWordFromProjectDict(m_projectId, m_word); | ||
} | ||
|
||
void AddWordToProjectDictCommand::redo() | ||
{ | ||
skrdata->projectDictHub()->addWordToProjectDict(m_projectId, m_word); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#ifndef DICTCOMMANDS_H | ||
#define DICTCOMMANDS_H | ||
|
||
#include <QObject> | ||
#include <QUndoCommand> | ||
#include "skribisto_backend_global.h" | ||
#include "interfaces/invokablecommandgroupinterface.h" | ||
|
||
#define dictCommands DictCommands::instance() | ||
|
||
class SKRBACKENDEXPORT DictCommands : public QObject, public InvokableCommandGroupInterface | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit DictCommands(QObject *parent, QUndoStack *undoStack); | ||
|
||
static DictCommands* instance() | ||
{ | ||
return m_instance; | ||
} | ||
QUndoStack *undoStack() const; | ||
void addWordToProjectDict(int projectId, const QString &word); | ||
|
||
signals: | ||
private: | ||
static DictCommands *m_instance; | ||
QUndoStack *m_undoStack; | ||
|
||
// InvokableCommandGroupInterface interface | ||
public: | ||
Command *getCommand(const QString &action, const QVariantMap ¶meters) override; | ||
QString address() const override | ||
{ | ||
return "dict"; | ||
} | ||
|
||
}; | ||
|
||
|
||
//------------------------------------------------------------------------------------------------------------ | ||
//------------------------------------------------------------------------------------------------------------ | ||
|
||
class AddWordToProjectDictCommand : public Command | ||
{ | ||
public: | ||
AddWordToProjectDictCommand(int projectId, const QString &word); | ||
void undo(); | ||
void redo(); | ||
private: | ||
QString m_word; | ||
int m_projectId; | ||
}; | ||
|
||
#endif // DICTCOMMANDS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.