Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
290 changes: 290 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
/cmake-build-debug
cmake_install.cmake
/CMakeFiles
*.cbp
Client
/Client_autogen
project_lib_autogen/
CMakeCache.txt
CTestTestfile.cmake

.idea
!core/
*.*#
*.a
*.app
*.autosave
*.core
*.debug
*.embed.manifest
*.moc
*.o
*.obj
*.orig
*.prl
*.qm
*.rc
*.rej
*.res
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*_wrapper.bat
*_wrapper.sh
*~
.#*
.DS_Store
.qmake.cache
.qmake.stash
Makefile*
Thumbs.db
core
moc_*.cpp
qrc_*.cpp
tags
ui_*.h
wrapper.bat
wrapper.sh

# qtcreator generated files
*.creator.user*
*.pro.user*
*.pyqtc.user*
*.qbs.user*
*.qmlproject.user*
CMakeLists.txt.user*
/share/qtcreator/examples/
/share/qtcreator/externaltools/
/share/qtcreator/fonts/
/share/qtcreator/generic-highlighter/
/share/qtcreator/qmldesigner/QtProject/
/src/app/Info.plist
/src/plugins/**/*.json
/src/plugins/coreplugin/ide_version.h
/src/libs/qt-breakpad/bin
app_version.h
phony.c

# xemacs temporary files
*.flc

# Vim temporary files
.*.swp

# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.ncb
*.opensdf
*.pdb
*.sdf
*.sln
*.suo
*.vcproj
*.vcxproj
*vcproj.*.*.user
*vcxproj.*

# gcov files
*.gcda
*.gcno
*.gcov

# MinGW generated files
*.Debug
*.Release

# Python byte code
*.pyc

# translation related:
/share/qtcreator/translations/*_tr.h
/share/qtcreator/translations/qtcreator_untranslated.ts

# Qml caching files
*.jsc
*.qmlc

# Squish generated files
/tests/system/suite_*/config.xml

# Clang tooling files
compile_commands.json

# Directories to ignore
# ---------------------

.moc/
.obj/
.pch/
.rcc/
.uic/
/*-debug/
/*-release/
/dist/gdb/*.gz
/dist/gdb/python/
/dist/gdb/qtcreator-*/
/dist/gdb/source/
/dist/gdb/staging/
/doc/qbs/
/doc/qtcreator/
/doc/qtcreator-dev/
/doc/pluginhowto/html/
/lib/
/lib64/
/libexec/
debug/
ipch/
release/
tmp/
# ignore both a directory as well as a symlink
/share/qtcreator/QtProject

# Binaries
# --------
*.dll
*.exe
/bin/buildoutputparser
/bin/clangbackend
/bin/cpaster
/bin/cplusplus-ast2png
/bin/cplusplus-frontend
/bin/cplusplus-keywordgen
/bin/cplusplus-mkvisitor
/bin/cplusplus-update-frontend
/bin/qbs*
/bin/qml2puppet
/bin/qmlpuppet
/bin/qtcreator
/bin/qtcreator_crash_handler
/bin/qtcreator_ctrlc_stub
/bin/qtcreator_process_stub
/bin/qtpromaker
/bin/sdktool
/share/doc/qtcreator/*.qch
/share/qtcreator/qbs/
/src/tools/examplesscanner/examplesscanner
/src/tools/qml/qmldump/qmldump
/src/tools/valgrindfake/valgrind-fake

# Tests
#------
/tests/auto/aggregation/tst_aggregation
/tests/auto/algorithm/tst_algorithm
/tests/auto/changeset/tst_changeset
/tests/auto/cplusplus/ast/tst_ast
/tests/auto/cplusplus/c99/tst_c99
/tests/auto/cplusplus/checksymbols/tst_checksymbols
/tests/auto/cplusplus/codeformatter/tst_codeformatter
/tests/auto/cplusplus/codegen/tst_codegen
/tests/auto/cplusplus/cppselectionchanger/tst_cppselectionchanger
/tests/auto/cplusplus/cxx11/tst_c99
/tests/auto/cplusplus/cxx11/tst_cxx11
/tests/auto/cplusplus/fileiterationorder/tst_fileiterationorder
/tests/auto/cplusplus/findusages/tst_findusages
/tests/auto/cplusplus/lexer/tst_lexer
/tests/auto/cplusplus/lookup/tst_lookup
/tests/auto/cplusplus/misc/tst_misc
/tests/auto/cplusplus/preprocessor/tst_preprocessor
/tests/auto/cplusplus/semantic/tst_semantic
/tests/auto/cplusplus/simplifytypes/tst_simplifytypes
/tests/auto/cplusplus/translationunit/tst_translationunit
/tests/auto/cplusplus/typeprettyprinter/tst_typeprettyprinter
/tests/auto/debugger/qt_tst_dumpers_*
/tests/auto/debugger/tst_disassembler
/tests/auto/debugger/tst_dumpers
/tests/auto/debugger/tst_gdb
/tests/auto/debugger/tst_namedemangler
/tests/auto/debugger/tst_offsets
/tests/auto/debugger/tst_olddumpers
/tests/auto/debugger/tst_simplifytypes
/tests/auto/debugger/tst_version
/tests/auto/diff/differ/tst_differ
/tests/auto/environment/tst_environment
/tests/auto/extensionsystem/pluginmanager/tst_pluginmanager
/tests/auto/extensionsystem/pluginspec/tst_pluginspec
/tests/auto/externaltool/tst_externaltool
/tests/auto/fakevim/tst_fakevim
/tests/auto/filesearch/tst_filesearch
/tests/auto/flamegraph/tst_flamegraph
/tests/auto/generichighlighter/highlighterengine/tst_highlighterengine
/tests/auto/generichighlighter/specificrules/tst_specificrules
/tests/auto/ioutils/tst_ioutils
/tests/auto/json/tst_json
/tests/auto/mapreduce/tst_mapreduce
/tests/auto/profilewriter/tst_profilewriter
/tests/auto/qml/codemodel/check/tst_codemodel_check
/tests/auto/qml/codemodel/dependencies/tst_dependencies
/tests/auto/qml/codemodel/importscheck/tst_qml_imports_check
/tests/auto/qml/persistenttrie/tst_trie_check
/tests/auto/qml/qmldesigner/bauhaustests/tst_bauhaus
/tests/auto/qml/qmldesigner/coretests/tst_coretests
/tests/auto/qml/qmldesigner/coretests/tst_qmldesigner_core
/tests/auto/qml/qmldesigner/propertyeditortests/tst_propertyeditor
/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter
/tests/auto/qml/qmljssimplereader/tst_qmljssimplereader
/tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat
/tests/auto/qml/qrcparser/tst_qrcparser
/tests/auto/qml/reformatter/tst_reformatter
/tests/auto/qtcprocess/tst_qtcprocess
/tests/auto/runextensions/tst_runextensions
/tests/auto/sdktool/tst_sdktool
/tests/auto/ssh/tst_ssh
/tests/auto/timeline/timelineabstractrenderer/tst_timelineabstractrenderer
/tests/auto/timeline/timelineitemsrenderpass/tst_timelineitemsrenderpass
/tests/auto/timeline/timelinemodel/tst_timelinemodel
/tests/auto/timeline/timelinemodelaggregator/tst_timelinemodelaggregator
/tests/auto/timeline/timelinenotesmodel/tst_timelinenotesmodel
/tests/auto/timeline/timelinenotesrenderpass/tst_timelinenotesrenderpass
/tests/auto/timeline/timelineoverviewrenderer/tst_timelineoverviewrenderer
/tests/auto/timeline/timelinerenderer/tst_timelinerenderer
/tests/auto/timeline/timelinerenderpass/tst_timelinerenderpass
/tests/auto/timeline/timelinerenderstate/tst_timelinerenderstate
/tests/auto/timeline/timelineselectionrenderpass/tst_timelineselectionrenderpass
/tests/auto/timeline/timelinezoomcontrol/tst_timelinezoomcontrol
/tests/auto/treeviewfind/tst_treeviewfind
/tests/auto/utils/ansiescapecodehandler/tst_ansiescapecodehandler
/tests/auto/utils/fileutils/tst_fileutils
/tests/auto/utils/stringutils/tst_stringutils
/tests/auto/utils/templateengine/tst_templateengine
/tests/auto/utils/treemodel/tst_treemodel
/tests/auto/valgrind/callgrind/tst_callgrindparsertests
/tests/auto/valgrind/memcheck/modeldemo
/tests/auto/valgrind/memcheck/testapps/free1/free1
/tests/auto/valgrind/memcheck/testapps/free2/free2
/tests/auto/valgrind/memcheck/testapps/invalidjump/invalidjump
/tests/auto/valgrind/memcheck/testapps/leak1/leak1
/tests/auto/valgrind/memcheck/testapps/leak2/leak2
/tests/auto/valgrind/memcheck/testapps/leak3/leak3
/tests/auto/valgrind/memcheck/testapps/leak4/leak4
/tests/auto/valgrind/memcheck/testapps/overlap/overlap
/tests/auto/valgrind/memcheck/testapps/syscall/syscall
/tests/auto/valgrind/memcheck/testapps/uninit1/uninit1
/tests/auto/valgrind/memcheck/testapps/uninit2/uninit2
/tests/auto/valgrind/memcheck/testapps/uninit3/uninit3
/tests/auto/valgrind/memcheck/tst_parsertests
/tests/auto/valgrind/memcheck/tst_testrunner
/tests/manual/debugger/gui/gui
/tests/manual/debugger/helper/helper
/tests/manual/debugger/simple/libsimple_test_plugin.*dylib
/tests/manual/debugger/simple/simple_test_app
/tests/manual/fakevim/tst_fakevim
/tests/manual/pluginview/tst_plugindialog
/tests/manual/preprocessor/pp
/tests/manual/process/process
/tests/manual/proparser/testreader
/tests/manual/qml-ast2dot/qml-ast2dot
/tests/manual/shootout/shootout
/tests/manual/ssh/sftpfsmodel/sftpfsmodel
/tests/manual/ssh/shell/shell
/tests/tools/qml-ast2dot/qml-ast2dot
/tests/unit/echoserver/echo
/tests/unit/unittest/unittest

# qbs builds
/*-debug/
/*-release/
45 changes: 45 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 3.13)
project(TextEditor)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR "YES")
set(CMAKE_AUTOMOC YES)
set(CMAKE_AUTOUIC YES)
set(SOURCES main.cpp
src/NoteBook.ui
src/NoteBook.cpp
headers/NoteBook.h
src/jsonTypes.cpp
headers/jsonTypes.h
src/Message.cpp
headers/Message.h
src/ClientConnector.cpp
headers/ClientConnector.h
src/Symbol.cpp
headers/Symbol.h
json.hpp
src/CRDT.cpp
headers/CRDT.h
)

find_package(Boost 1.67.0 REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
find_package(Qt5 COMPONENTS Core WebSockets REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

list(APPEND LIBRARIES
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::PrintSupport
)
list(REMOVE_DUPLICATES LIBRARIES)

add_executable(Client ${SOURCES} ${Boost_INCLUDE_DIRS})
find_package(Boost 1.57.0 COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(Client ${Boost_LIBRARIES})
target_link_libraries(Client ${LIBRARIES} ${Boost_LIBRARIES})

2 changes: 0 additions & 2 deletions README.md

This file was deleted.

35 changes: 35 additions & 0 deletions headers/CRDT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef HEADERS_CRDT_H_
#define HEADERS_CRDT_H_
#include <vector>
#include "Symbol.h"
#include <QDebug>

typedef std::pair<int,int> int_pair;

class CRDT {

public:
CRDT() = default;
virtual ~CRDT() = default;
Symbol localInsert(int index, wchar_t value);
std::vector<Symbol> localInsert(int startIndex, std::vector<Symbol> symbols);
std::vector<int_pair> localErase(int startIndex, int endIndex);
int process(int type, int indexEditor, const Symbol& newSym);
int process(int type, int indexEditor, std::vector<Symbol> newSymbols);
int processErase(int_pair id);
void set_symbols(std::vector<Symbol> symbols);

std::vector<Symbol> get_symbols();

private:
std::vector<Symbol> _symbols;
int _counter = 0;
int _siteId;
std::vector<int> generate_pos(int index);
std::vector<int> generate_pos_between(std::vector<int> pos1, std::vector<int> pos2, std::vector<int> new_pos = {});
int compare_posdx(std::vector<int> cur_sym_pos, std::pair<int, int> cur_sym_id, std::vector<int> new_sym_pos,
std::pair<int, int> newSymId, int posIndex);
int compare_pos(std::vector<int> curSymPos, std::pair<int, int> curSymId, std::vector<int> newSymPos,
std::pair<int, int> newSymId, int posIndex);
};
#endif // HEADERS_CRDT_H_
Loading