diff --git a/.gitignore b/.gitignore
index 81b2f720..8f4beb69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+ServerModule/build/
+build-ClientModule-Desktop_Qt_6_1_3_GCC_64bit-Debug/
+*.sqlite
### C++ template
# Compiled Object files
*.slo
@@ -29,4 +32,4 @@
*.app
build-ClientModule-Desktop_Qt_5_13_1_MinGW_64_bit-Debug/
-Lab3/
\ No newline at end of file
+Lab3/
diff --git a/ClientModule/ClientModule.pro b/ClientModule/ClientModule.pro
index a454138c..26174790 100644
--- a/ClientModule/ClientModule.pro
+++ b/ClientModule/ClientModule.pro
@@ -1,4 +1,4 @@
-QT += core gui sql printsupport
+QT += core gui sql printsupport core5compat
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
@@ -96,3 +96,20 @@ win32 {
-lboost_thread-mgw73-mt-x64-1_66 \
-lws2_32
}
+
+unix
+{
+INCLUDEPATH+= /usr/local/boost/include
+#DEPENDPATH+= /usr/local/boost/lib
+#LIBS+= -lboost_serialization\
+#-lboost_filesystem\
+#-lbboost_thread
+
+
+
+}
+
+unix:!macx: LIBS += -L$$PWD/../../../../../usr/local/boost/lib/ -lboost_thread -lboost_serialization -lboost_filesystem
+
+INCLUDEPATH += $$PWD/../../../../../usr/local/boost/include
+DEPENDPATH += $$PWD/../../../../../usr/local/boost/include
diff --git a/ClientModule/ClientModule.pro.user b/ClientModule/ClientModule.pro.user
index e0920f80..86fc1563 100644
--- a/ClientModule/ClientModule.pro.user
+++ b/ClientModule/ClientModule.pro.user
@@ -1,337 +1,262 @@
-
-
-
-
-
- EnvironmentId
- {eebb2615-748c-4e9a-84c9-206e34daa089}
-
-
- ProjectExplorer.Project.ActiveTarget
- 0
-
-
- ProjectExplorer.Project.EditorSettings
-
- true
- false
- true
-
- Cpp
-
- CppGlobal
-
-
-
- QmlJS
-
- QmlJSGlobal
-
-
- 2
- UTF-8
- false
- 4
- false
- 80
- true
- true
- 1
- true
- false
- 0
- true
- true
- 0
- 8
- true
- 1
- true
- true
- true
- false
-
-
-
- ProjectExplorer.Project.PluginSettings
-
-
- -fno-delayed-template-parsing
-
- true
-
-
-
- ProjectExplorer.Project.Target.0
-
- Desktop Qt 5.13.1 MinGW 64-bit
- Desktop Qt 5.13.1 MinGW 64-bit
- qt.qt5.5131.win64_mingw73_kit
- 0
- 0
- 0
-
- C:/Users/giova/CLionProjects/Real time text editor/build-ClientModule-Desktop_Qt_5_13_1_MinGW_64_bit-Debug
-
-
- true
- qmake
-
- QtProjectManager.QMakeBuildStep
- true
-
- false
- false
- false
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- false
-
-
- false
-
- 2
- Build
-
- ProjectExplorer.BuildSteps.Build
-
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- true
- clean
-
- false
-
- 1
- Clean
-
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- Debug
- Debug
- Qt4ProjectManager.Qt4BuildConfiguration
- 2
- true
-
-
- C:/Users/giova/CLionProjects/Real time text editor/build-ClientModule-Desktop_Qt_5_13_1_MinGW_64_bit-Release
-
-
- true
- qmake
-
- QtProjectManager.QMakeBuildStep
- false
-
- false
- false
- true
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- false
-
-
- false
-
- 2
- Build
-
- ProjectExplorer.BuildSteps.Build
-
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- true
- clean
-
- false
-
- 1
- Clean
-
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- Release
- Release
- Qt4ProjectManager.Qt4BuildConfiguration
- 0
- true
-
-
- C:/Users/giova/CLionProjects/Real time text editor/build-ClientModule-Desktop_Qt_5_13_1_MinGW_64_bit-Profile
-
-
- true
- qmake
-
- QtProjectManager.QMakeBuildStep
- true
-
- false
- true
- true
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- false
-
-
- false
-
- 2
- Build
-
- ProjectExplorer.BuildSteps.Build
-
-
-
- true
- Make
-
- Qt4ProjectManager.MakeStep
-
- true
- clean
-
- false
-
- 1
- Clean
-
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- Profile
- Profile
- Qt4ProjectManager.Qt4BuildConfiguration
- 0
- true
-
- 3
-
-
- 0
- Deploy
-
- ProjectExplorer.BuildSteps.Deploy
-
- 1
- Deploy Configuration
-
- ProjectExplorer.DefaultDeployConfiguration
-
- 1
-
-
- dwarf
-
- cpu-cycles
-
-
- 250
- -F
- true
- 4096
- false
- false
- 1000
-
- true
-
- false
- false
- false
- false
- true
- 0.01
- 10
- true
- kcachegrind
- 1
- 25
-
- 1
- true
- false
- true
- valgrind
-
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
-
- 2
-
- ClientModule
-
- Qt4ProjectManager.Qt4RunConfiguration:C:/Users/giova/CLionProjects/Real time text editor/ClientModule/ClientModule.pro
-
- 3768
- false
- true
- true
- false
- false
- true
-
- C:/Users/giova/CLionProjects/Real time text editor/build-ClientModule-Desktop_Qt_5_13_1_MinGW_64_bit-Debug
-
- 1
-
-
-
- ProjectExplorer.Project.TargetCount
- 1
-
-
- ProjectExplorer.Project.Updater.FileVersion
- 22
-
-
- Version
- 22
-
-
+
+
+
+
+
+ EnvironmentId
+ {0545e603-8cc7-40da-83de-fbf2b2d95ba3}
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ false
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ 80
+ true
+ true
+ 1
+ false
+ true
+ false
+ 0
+ true
+ true
+ 0
+ 8
+ true
+ false
+ 1
+ true
+ true
+ true
+ *.md, *.MD, Makefile
+ false
+ true
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+ true
+ false
+ true
+ true
+ true
+ true
+
+
+ 0
+ true
+
+ true
+ Builtin.BuildSystem
+
+ true
+ true
+ Builtin.DefaultTidyAndClazy
+ 8
+
+
+
+ true
+
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ Desktop Qt 6.1.3 GCC 64bit
+ Desktop Qt 6.1.3 GCC 64bit
+ qt.qt6.613.gcc_64_kit
+ 0
+ 0
+ 0
+
+ 0
+ /home/lucas/repos/carte/build-ClientModule-Desktop_Qt_6_1_3_GCC_64bit-Debug
+ /home/lucas/repos/carte/build-ClientModule-Desktop_Qt_6_1_3_GCC_64bit-Debug
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+
+ Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+
+
+ /home/lucas/repos/carte/build-ClientModule-Desktop_Qt_6_1_3_GCC_64bit-Release
+ /home/lucas/repos/carte/build-ClientModule-Desktop_Qt_6_1_3_GCC_64bit-Release
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+
+ Release
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ 0
+
+
+ 0
+ /home/lucas/repos/carte/build-ClientModule-Desktop_Qt_6_1_3_GCC_64bit-Profile
+ /home/lucas/repos/carte/build-ClientModule-Desktop_Qt_6_1_3_GCC_64bit-Profile
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+
+ Profile
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ 0
+ 0
+
+ 3
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ true
+
+ 2
+
+ Qt4ProjectManager.Qt4RunConfiguration:/home/lucas/repos/carte/ClientModule/ClientModule.pro
+ /home/lucas/repos/carte/ClientModule/ClientModule.pro
+ false
+ true
+ true
+ false
+ true
+ /home/lucas/repos/carte/build-ClientModule-Desktop_Qt_6_1_3_GCC_64bit-Debug
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 22
+
+
+ Version
+ 22
+
+
diff --git a/ClientModule/MyQTextEdit.cpp b/ClientModule/MyQTextEdit.cpp
index 927c7db7..a3c34e54 100644
--- a/ClientModule/MyQTextEdit.cpp
+++ b/ClientModule/MyQTextEdit.cpp
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
void MyQTextEdit::insertFromMimeData(const QMimeData* source) {
if (source->hasText() && !source->hasImage() && !source->hasUrls() && !source->html().contains("fontFamilyBox);
qRegisterMetaType>("std::vector");
qRegisterMetaType("std::map");
- showSymbolsAt(0, _client->crdt.getSymbols());
+ showSymbolsAt(0, _client->_crdt.getSymbols());
this->installEventFilter(this);
ui->RealTextEdit->installEventFilter(this);
collabColorsRequest(_client->getFileURI());
@@ -567,7 +567,7 @@ void EditorWindow::on_buttonCut_clicked() {
changeNextCharsAlignment(cursor, startIndex, endIndex);
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localErase(startIndex, endIndex);
+ std::vector symbolsId = _client->_crdt.localErase(startIndex, endIndex);
removeCharRequest(symbolsId);
ui->RealTextEdit->cut();
@@ -589,7 +589,7 @@ void EditorWindow::on_buttonPaste_clicked() {
changeNextCharsAlignment(cursor, startIndex, endIndex);
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localErase(startIndex, endIndex);
+ std::vector symbolsId = _client->_crdt.localErase(startIndex, endIndex);
removeCharRequest(symbolsId);
}
@@ -803,7 +803,7 @@ void EditorWindow::on_RealTextEdit_cursorPositionChanged() {
void EditorWindow::on_RealTextEdit_textChanged() {
int charCount = ui->RealTextEdit->toPlainText().count();
- int wordCount = ui->RealTextEdit->toPlainText().split(QRegExp("(\\s|\\n|\\r)+"), QString::SkipEmptyParts).count();
+ int wordCount = ui->RealTextEdit->toPlainText().split(QRegularExpression("(\\s|\\n|\\r)+"), Qt::SkipEmptyParts).count();
int lineCount = ui->RealTextEdit->document()->blockCount();
QString ZaChar = "Caratteri: "+QString::number(charCount);
QString ZaLine;
@@ -957,7 +957,7 @@ bool EditorWindow::eventFilter(QObject *obj, QEvent *ev) {
changeNextCharsAlignment(cursor, startIndex, endIndex);
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localErase(startIndex, endIndex);
+ std::vector symbolsId = _client->_crdt.localErase(startIndex, endIndex);
removeCharRequest(symbolsId);
}
@@ -980,7 +980,7 @@ bool EditorWindow::eventFilter(QObject *obj, QEvent *ev) {
changeNextCharsAlignment(cursor, startIndex, endIndex);
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localErase(startIndex, endIndex);
+ std::vector symbolsId = _client->_crdt.localErase(startIndex, endIndex);
removeCharRequest(symbolsId);
}
@@ -1105,7 +1105,7 @@ bool EditorWindow::eventFilter(QObject *obj, QEvent *ev) {
ui->fontFamilyBox->setCurrentText(f.fontFamily());
//update symbols of the client
- std::vector symbolsId = _client->crdt.localErase(startIndex, endIndex);
+ std::vector symbolsId = _client->_crdt.localErase(startIndex, endIndex);
//Serialize data
json j;
@@ -1145,7 +1145,7 @@ bool EditorWindow::eventFilter(QObject *obj, QEvent *ev) {
}
//update symbols of the client
- symbol s = _client->crdt.localInsert(pos, c, getCurCharStyle());
+ symbol s = _client->_crdt.localInsert(pos, c, getCurCharStyle());
//Serialize data
json j;
@@ -1180,7 +1180,7 @@ bool EditorWindow::eventFilter(QObject *obj, QEvent *ev) {
changeNextCharsAlignment(cursor, startIndex, endIndex);
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localErase(startIndex, endIndex);
+ std::vector symbolsId = _client->_crdt.localErase(startIndex, endIndex);
removeCharRequest(symbolsId);
}
@@ -1188,7 +1188,7 @@ bool EditorWindow::eventFilter(QObject *obj, QEvent *ev) {
changeNextCharsAlignment(cursor, pos-1, pos);
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localErase(pos-1, pos);
+ std::vector symbolsId = _client->_crdt.localErase(pos-1, pos);
removeCharRequest(symbolsId);
}
@@ -1218,7 +1218,7 @@ bool EditorWindow::eventFilter(QObject *obj, QEvent *ev) {
changeNextCharsAlignment(cursor, startIndex, endIndex);
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localErase(startIndex, endIndex);
+ std::vector symbolsId = _client->_crdt.localErase(startIndex, endIndex);
removeCharRequest(symbolsId);
}
@@ -1226,7 +1226,7 @@ bool EditorWindow::eventFilter(QObject *obj, QEvent *ev) {
changeNextCharsAlignment(cursor, pos, pos+1);
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localErase(pos, pos+1);
+ std::vector symbolsId = _client->_crdt.localErase(pos, pos+1);
removeCharRequest(symbolsId);
}
@@ -2556,7 +2556,7 @@ void EditorWindow::showSymbolsAt(int firstIndex, std::vector symbols) {
/* Insert (formatted) char */
c.setPosition(pos);
c.setCharFormat(newFormat);
- c.insertText(static_cast(letter));
+ c.insertText(static_cast(letter));
c.movePosition(QTextCursor::Right);
c.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
c.setBlockFormat(newBlockFormat);
@@ -2569,7 +2569,7 @@ void EditorWindow::showSymbolsAt(int firstIndex, std::vector symbols) {
/* Insert (formatted) char */
c.setPosition(pos);
c.setCharFormat(newFormat);
- c.insertText(static_cast(letter));
+ c.insertText(QChar(letter));
c.movePosition(QTextCursor::Right);
c.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
c.setBlockFormat(newBlockFormat);
@@ -2623,7 +2623,7 @@ void EditorWindow::showSymbol(std::pair tuple, symbolStyle style)
/* Insert (formatted) char */
cursor.setPosition(pos);
cursor.setCharFormat(format);
- cursor.insertText(static_cast(c));
+ cursor.insertText(static_cast(c));
cursor.movePosition(QTextCursor::Right);
cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
cursor.setBlockFormat(newBlockFormat);
@@ -2636,7 +2636,7 @@ void EditorWindow::showSymbol(std::pair tuple, symbolStyle style)
/* Insert (formatted) char */
cursor.setPosition(pos);
cursor.setCharFormat(format);
- cursor.insertText(static_cast(c));
+ cursor.insertText(static_cast(c));
cursor.movePosition(QTextCursor::Right);
cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
cursor.setBlockFormat(newBlockFormat);
@@ -2653,7 +2653,7 @@ void EditorWindow::showSymbol(std::pair tuple, symbolStyle style)
cursor.endEditBlock();
ui->RealTextEdit->setTextCursor(cursor);
- qDebug() << "Written in pos: " << pos << endl;
+ qDebug() << "Written in pos: " << pos << Qt::endl;
ui->RealTextEdit->setFocus(); //Return focus to textedit
}
@@ -2681,7 +2681,7 @@ void EditorWindow::eraseSymbols(int startIndex, int endIndex) {
cursor.endEditBlock();
- qDebug() << "Deleted char range" << endl;
+ qDebug() << "Deleted char range" << Qt::endl;
ui->RealTextEdit->setFocus(); //Return focus to textedit
}
@@ -2709,7 +2709,7 @@ void EditorWindow::formatSymbols(int startIndex, int endIndex, int format) {
}
cursor.endEditBlock();
- qDebug() << "Formatted char range" << endl;
+ qDebug() << "Formatted char range" << Qt::endl;
ui->RealTextEdit->setFocus();
}
@@ -2757,7 +2757,7 @@ void EditorWindow::changeFontSize(int startIndex, int endIndex, int fontSize) {
}
cursor.endEditBlock();
- qDebug() << "Changed font size in char range" << endl;
+ qDebug() << "Changed font size in char range" << Qt::endl;
ui->RealTextEdit->setFocus();
}
@@ -2780,7 +2780,7 @@ void EditorWindow::changeFontFamily(int startIndex, int endIndex, std::string fo
}
cursor.endEditBlock();
- qDebug() << "Changed font family in char range" << endl;
+ qDebug() << "Changed font family in char range" << Qt::endl;
ui->RealTextEdit->setFocus();
}
@@ -2810,7 +2810,7 @@ void EditorWindow::changeAlignment(int startBlock, int endBlock, int alignment)
ui->RealTextEdit->setAlignment(cursor.blockFormat().alignment());
ui->RealTextEdit->viewport()->update();
- qDebug() << "Changed alignment" << endl;
+ qDebug() << "Changed alignment" << Qt::endl;
ui->RealTextEdit->setFocus();
}
@@ -3036,7 +3036,7 @@ void EditorWindow::sendFormatRequest(int format) {
int endIndex = cursor.selectionEnd();
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localFormat(startIndex, endIndex, format);
+ std::vector symbolsId = _client->_crdt.localFormat(startIndex, endIndex, format);
//Serialize data
json j;
@@ -3065,7 +3065,7 @@ void EditorWindow::sendFontChangeRequest(int fontSize) {
int endIndex = cursor.selectionEnd();
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localFontSizeChange(startIndex, endIndex, fontSize);
+ std::vector symbolsId = _client->_crdt.localFontSizeChange(startIndex, endIndex, fontSize);
//Serialize data
json j;
@@ -3079,7 +3079,7 @@ void EditorWindow::sendFontChangeRequest(int fontSize) {
void EditorWindow::sendAlignChangeRequest(int blockStart, int blockEnd, int alignment) {
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localAlignmentChange(blockStart, blockEnd, alignment);
+ std::vector symbolsId = _client->_crdt.localAlignmentChange(blockStart, blockEnd, alignment);
//Serialize data
json j;
@@ -3097,7 +3097,7 @@ void EditorWindow::sendFontChangeRequest(std::string fontFamily) {
int endIndex = cursor.selectionEnd();
//Update symbols of the client
- std::vector symbolsId = _client->crdt.localFontFamilyChange(startIndex, endIndex, fontFamily);
+ std::vector symbolsId = _client->_crdt.localFontFamilyChange(startIndex, endIndex, fontFamily);
//Serialize data
json j;
@@ -3262,7 +3262,7 @@ void EditorWindow::alignSingleBlock(QTextCursor& cursor, Qt::AlignmentFlag align
//update symbols of the client
cursor.movePosition(QTextCursor::End);
int lastPos = cursor.position();
- int vecSize = static_cast(_client->crdt.getSymbols().size());
+ int vecSize = static_cast(_client->_crdt.getSymbols().size());
bool addNewline = false;
symbol s;
@@ -3288,11 +3288,11 @@ void EditorWindow::alignSingleBlock(QTextCursor& cursor, Qt::AlignmentFlag align
ui->RealTextEdit->setTextCursor(cursor);
/* Insert (formatted) char in symbol vector */
- s = _client->crdt.localInsert(lastPos, '\r', style);
+ s = _client->_crdt.localInsert(lastPos, '\r', style);
addNewline = true;
}
else if(cursor.position() >= lastPos) {
- symbolStyle style = _client->crdt.getSymbols().at(vecSize-1).getStyle();
+ symbolStyle style = _client->_crdt.getSymbols().at(vecSize-1).getStyle();
QTextCharFormat format;
/* Get style */
@@ -3310,7 +3310,7 @@ void EditorWindow::alignSingleBlock(QTextCursor& cursor, Qt::AlignmentFlag align
ui->RealTextEdit->setTextCursor(cursor);
/* Insert (formatted) char in symbol vector */
- s = _client->crdt.localInsert(vecSize, '\r', style);
+ s = _client->_crdt.localInsert(vecSize, '\r', style);
addNewline = true;
}
@@ -3396,10 +3396,10 @@ std::pair EditorWindow::alignBlocks(int startIndex, int endIndex, const
if(lastBlockEmpty || ui->RealTextEdit->document()->lastBlock() == tempCursor.block()) {
int oldPos = tempCursor.position();
tempCursor.movePosition(QTextCursor::End);
- int vecSize = static_cast(_client->crdt.getSymbols().size());
+ int vecSize = static_cast(_client->_crdt.getSymbols().size());
symbol s;
- symbolStyle style = _client->crdt.getSymbols().at(vecSize-1).getStyle();
+ symbolStyle style = _client->_crdt.getSymbols().at(vecSize-1).getStyle();
QTextCharFormat format;
/* Get style */
@@ -3417,7 +3417,7 @@ std::pair EditorWindow::alignBlocks(int startIndex, int endIndex, const
ui->RealTextEdit->setTextCursor(cursor);
/* Insert (formatted) char in symbol vector */
- s = _client->crdt.localInsert(vecSize, '\r', style);
+ s = _client->_crdt.localInsert(vecSize, '\r', style);
//Serialize data
json j;
@@ -3532,7 +3532,7 @@ void EditorWindow::insertCharRangeRequest(int pos, bool cursorHasSelection) noex
}
//Update symbols of the client
- std::vector symbols = _client->crdt.localInsert(initialPos, infoSymbols);
+ std::vector symbols = _client->_crdt.localInsert(initialPos, infoSymbols);
//Serialize data
json j;
@@ -3543,35 +3543,43 @@ void EditorWindow::insertCharRangeRequest(int pos, bool cursorHasSelection) noex
//Send data (header and body)
_client->sendRequestMsg(req);
} else {
- qDebug() << "Cannot paste this." << endl;
+ qDebug() << "Cannot paste this." << Qt::endl;
}
}
QChar EditorWindow::SimplifySingleCharForSorting(QChar c, bool changeToLowerCase) {
- if ( ( c >= 0xC0 && c <= 0xC5 ) || ( c >= 0xE1 && c <= 0xE5 ) || c == 0xAA )
- return ( ( c >= 0xC0 && c <= 0xC5 ) && !changeToLowerCase ) ? 'A' : 'a';
- if ( ( c >= 0xC8 && c <= 0xCB ) || ( c >= 0xE8 && c <= 0xEB ) )
- return ( c > 0xCB || changeToLowerCase ) ? 'e' : 'E';
- if ( ( c >= 0xCC && c <= 0xCF ) || ( c >= 0xEC && c <= 0xEF ) )
- return ( c > 0xCF || changeToLowerCase ) ? 'i' : 'I';
- if ( ( c >= 0xD2 && c <= 0xD6 ) || ( c >= 0xF2 && c <= 0xF6 ) || c == 0xBA )
- return ( ( c >= 0xD2 && c <= 0xD6 ) && !changeToLowerCase ) ? 'O' : 'o';
- if ( ( c >= 0xD9 && c <= 0xDC ) || ( c >= 0xF9 && c <= 0xFC ) )
- return ( c > 0xDC || changeToLowerCase ) ? 'u' : 'U';
- if ( c == 0xA9 || c == 0xC7 || c == 0xE7 )
- return ( c == 0xC7 && !changeToLowerCase ) ? 'C' : 'c';
- if ( c == 0xD1 || c == 0xF1 )
- return ( c == 0xD1 && !changeToLowerCase ) ? 'N' : 'n';
- if ( c == 0xAE )
+ if ( ( c >= QChar(0xC0) && c <= QChar(0xC5) ) || ( c >= QChar(0xE1) && c <= QChar(0xE5) ) || c == QChar(0xAA) )
+ return ( ( c >= QChar(0xC0) && c <= QChar(0xC5) ) && !changeToLowerCase ) ? 'A' : 'a';
+
+ if ( ( c >= QChar(0xC8) && c <= QChar(0xCB) ) || ( c >= QChar(0xE8) && c <= QChar(0xEB) ) )
+ return ( c > QChar(0xCB) || changeToLowerCase ) ? 'e' : 'E';
+
+ if ( ( c >= QChar(0xCC) && c <= QChar(0xCF) ) || ( c >= QChar(0xEC) && c <= QChar(0xEF) ) )
+ return ( c > QChar(0xCF) || changeToLowerCase ) ? 'i' : 'I';
+
+ if ( ( c >= QChar(0xD2) && c <= QChar(0xD6) ) || ( c >= QChar(0xF2) && c <= QChar(0xF6) ) || c == QChar(0xBA) )
+ return ( ( c >= QChar(0xD2) && c <= QChar(0xD6) ) && !changeToLowerCase ) ? 'O' : 'o';
+
+ if ( ( c >= QChar(0xD9) && c <= QChar(0xDC) ) || ( c >= QChar(0xF9) && c <= QChar(0xFC) ) )
+ return ( c > QChar(0xDC) || changeToLowerCase ) ? 'u' : 'U';
+
+ if ( c == QChar(0xA9) || c ==QChar(0xC7) || c == QChar(0xE7) )
+ return ( c == QChar(0xC7) && !changeToLowerCase ) ? 'C' : 'c';
+
+ if ( c == QChar(0xD1) || c == QChar(0xF1) )
+ return ( c == QChar(0xD1) && !changeToLowerCase ) ? 'N' : 'n';
+
+ if ( c == QChar(0xAE) )
return 'r';
- if ( c == 0xDF )
+ if ( c ==QChar( 0xDF) )
return 's';
- if ( c == 0x8E || c == 0x9E )
- return ( c == 0x8E && !changeToLowerCase ) ? 'Z' : 'z';
- if ( c == 0x9F || c == 0xDD || c == 0xFD || c == 0xFF )
- return ( ( c == 0x9F || c == 0xDD ) && !changeToLowerCase ) ? 'Y' : 'y';
+
+ if ( c == QChar(0x8E) || c == QChar(0x9E) )
+ return ( c ==QChar(0x8E) && !changeToLowerCase ) ? 'Z' : 'z';
+ if ( c ==QChar(0x9F) || c == QChar(0xDD) || c == QChar(0xFD) || c == QChar(0xFF) )
+ return ( ( c == QChar(0x9F) || c == QChar(0xDD) ) && !changeToLowerCase ) ? 'Y' : 'y';
return c;
}
diff --git a/ClientModule/main.cpp b/ClientModule/main.cpp
index 20125d30..7fd6307c 100644
--- a/ClientModule/main.cpp
+++ b/ClientModule/main.cpp
@@ -1,5 +1,6 @@
#include
#include "startwindow.h"
+#include
#include
int main(int argc, char *argv[]){
diff --git a/ClientModule/myClient.cpp b/ClientModule/myClient.cpp
index db9aa48a..3daab291 100644
--- a/ClientModule/myClient.cpp
+++ b/ClientModule/myClient.cpp
@@ -1,5 +1,5 @@
#include "myClient.h"
-#include
+
#include
#include
@@ -13,7 +13,7 @@ myClient::myClient()
mail_(""),
color_("#00ffffff"),
fullBody(""),
- crdt(),
+ _crdt(),
fileVector_(std::vector())
{
worker_= std::thread([&](){io_context_.run();}); //boost thread loop start
@@ -52,7 +52,7 @@ void myClient::do_read_header() {
do_read_body();
}
else {
- qDebug() << ec.message().c_str() << endl;
+ qDebug() << ec.message().c_str() << Qt::endl;
closeConnection();
}
});
@@ -80,7 +80,7 @@ void myClient::do_read_body() {
jsonUtility::from_json_resp(jdata_in, db_responseJSON);
if(db_responseJSON == "LOGIN_OK") {
- qDebug() << "Login success" << endl;
+ qDebug() << "Login success" << Qt::endl;
std::string db_usernameLoginJSON;
std::string db_colorJSON;
std::string db_mailJSON;
@@ -94,11 +94,11 @@ void myClient::do_read_body() {
this->setUsername(name_qstring);
this->setColor(color_qstring);
this->setMail(mail_qstring);
- this->crdt.setSiteId(idJSON);
+ this->_crdt.setSiteId(idJSON);
emit formResultSuccess("LOGIN_SUCCESS");
} else {
- qDebug() << "Wrong user or password" << endl;
+ qDebug() << "Wrong user or password" << Qt::endl;
emit formResultFailure("LOGIN_FAILURE");
}
} else if(opJSON == "SIGNUP_RESPONSE") {
@@ -136,7 +136,7 @@ void myClient::do_read_body() {
emit removeRemoteCursor(db_usernameJSON);
emit getUserOffline(db_mapJSON);
} else {
- qDebug() << "Something went wrong with db" << endl;
+ qDebug() << "Something went wrong with db" << Qt::endl;
}
} else if(opJSON == "GET_USER_ONLINE_RESPONSE") {
std::string db_responseJSON;
@@ -148,7 +148,7 @@ void myClient::do_read_body() {
jsonUtility::from_json_user_offline(jdata_in, db_usernameJSON, db_mapJSON);
emit getUserOnline(db_mapJSON);
} else {
- qDebug() << "Something went wrong with db" << endl;
+ qDebug() << "Something went wrong with db" << Qt::endl;
}
} else if(opJSON == "LOGOUTURI_RESPONSE") {
std::string db_responseJSON;
@@ -170,7 +170,7 @@ void myClient::do_read_body() {
//Update client data
this->setFileURI(uriQString);
- this->crdt.setSymbols(std::vector());
+ this->_crdt.setSymbols(std::vector());
emit opResultSuccess("NEWFILE_SUCCESS");
} else
emit opResultFailure("NEWFILE_FAILURE");
@@ -184,12 +184,12 @@ void myClient::do_read_body() {
jsonUtility::from_json_symbols(jdata_in, symbolsJSON);
//Update client data
- this->crdt.setSymbols(symbolsJSON);
+ this->_crdt.setSymbols(symbolsJSON);
emit opResultSuccess("OPENFILE_SUCCESS");
} else if(db_responseJSON == "OPENFILE_FILE_EMPTY") {
//Update client data
- this->crdt.setSymbols(std::vector());
+ this->_crdt.setSymbols(std::vector());
emit opResultSuccess("OPENFILE_SUCCESS");
} else
emit opResultFailure("OPENFILE_FAILURE");
@@ -213,9 +213,9 @@ void myClient::do_read_body() {
//Update client data
this->setFilename(QString::fromStdString(filenameJSON));
- this->crdt.setSymbols(symbolsJSON);
+ this->_crdt.setSymbols(symbolsJSON);
- qDebug() << "OPENWITHURI success" << endl;
+ qDebug() << "OPENWITHURI success" << Qt::endl;
emit opResultSuccess("OPENWITHURI_SUCCESS");
} else if(db_responseJSON == "OPENFILE_FILE_EMPTY") {
std::string filenameJSON;
@@ -223,10 +223,10 @@ void myClient::do_read_body() {
//Update client data
this->setFilename(QString::fromStdString(filenameJSON));
- this->crdt.setSymbols(std::vector());
+ this->_crdt.setSymbols(std::vector());
emit opResultSuccess("OPENFILE_SUCCESS");
} else {
- qDebug() << "Something went wrong" << endl;
+ qDebug() << "Something went wrong" << Qt::endl;
emit opResultFailure("OPENWITHURI_FAILURE");
}
} else if(opJSON == "LISTFILE_RESPONSE") {
@@ -250,13 +250,13 @@ void myClient::do_read_body() {
}
emit listFileResult(files);
- qDebug() << "Listfile success" << endl;
+ qDebug() << "Listfile success" << Qt::endl;
emit opResultSuccess("LISTFILE_SUCCESS");
} else if (db_responseJSON == "LIST_DOESNT_EXIST"){
- qDebug() << "Non ha nessuna lista di file" << endl;
+ qDebug() << "Non ha nessuna lista di file" << Qt::endl;
emit opResultFailure("LISTFILE_FAILURE_LISTNOTEXIST");
} else {
- qDebug() << "Something went wrong" << endl;
+ qDebug() << "Something went wrong" << Qt::endl;
emit opResultFailure("LISTFILE_FAILURE");
}
} else if(opJSON == "INVITE_URI_RESPONSE") {
@@ -281,7 +281,7 @@ void myClient::do_read_body() {
jsonUtility::from_json_insertion(jdata_in, symbolJSON, indexEditorJSON);
//process received symbol and retrieve new calculated index
- int newIndex = this->crdt.process(0, indexEditorJSON, symbolJSON);
+ int newIndex = this->_crdt.process(0, indexEditorJSON, symbolJSON);
std::pair tuple = std::make_pair(newIndex, symbolJSON.getLetter());
emit insertSymbol(tuple, symbolJSON.getStyle());
@@ -303,7 +303,7 @@ void myClient::do_read_body() {
symbols.push_back(*s);
//process received symbol and retrieve new calculated index
- newIndex = this->crdt.process(0, newIndex, *s);
+ newIndex = this->_crdt.process(0, newIndex, *s);
std::pair tuple = std::make_pair(newIndex, s->getLetter());
emit insertSymbol(tuple, s->getStyle());
@@ -332,7 +332,7 @@ void myClient::do_read_body() {
int newIndex;
for(const sId& id : symbolsId) {
//process received symbol and retrieve new calculated index
- newIndex = this->crdt.processErase(id);
+ newIndex = this->_crdt.processErase(id);
if(newIndex != -1) {
emit eraseSymbols(newIndex, newIndex+1);
}
@@ -344,7 +344,7 @@ void myClient::do_read_body() {
int newIndex;
for(const sId& id : symbolsId) {
//process received symbol and retrieve new calculated index
- newIndex = this->crdt.processFormat(id, formatJSON);
+ newIndex = this->_crdt.processFormat(id, formatJSON);
if(newIndex != -1) {
emit formatSymbols(newIndex, newIndex+1, formatJSON);
}
@@ -356,7 +356,7 @@ void myClient::do_read_body() {
int newIndex;
for(const sId& id : symbolsId) {
//process received symbol and retrieve new calculated index
- newIndex = this->crdt.processFontSize(id, fontSizeJSON);
+ newIndex = this->_crdt.processFontSize(id, fontSizeJSON);
if(newIndex != -1) {
emit changeFontSize(newIndex, newIndex+1, fontSizeJSON);
}
@@ -368,7 +368,7 @@ void myClient::do_read_body() {
int newIndex;
for(const sId& id : symbolsId) {
//process received symbol and retrieve new calculated index
- newIndex = this->crdt.processFontFamily(id, fontFamilyJSON);
+ newIndex = this->_crdt.processFontFamily(id, fontFamilyJSON);
if(newIndex != -1) {
emit changeFontFamily(newIndex, newIndex+1, fontFamilyJSON);
}
@@ -384,7 +384,7 @@ void myClient::do_read_body() {
else {
for(const sId& id : symbolsId) {
//process received symbol and retrieve new calculated index
- newIndex = this->crdt.processAlignment(id, alignmentJSON);
+ newIndex = this->_crdt.processAlignment(id, alignmentJSON);
if(newIndex != -1) {
emit changeAlignment(newIndex, newIndex+1, alignmentJSON);
}
@@ -392,7 +392,7 @@ void myClient::do_read_body() {
}
}
else {
- qDebug() << "Something went wrong" << endl;
+ qDebug() << "Something went wrong" << Qt::endl;
emit opResultFailure("RESPONSE_FAILURE");
}
fullBody = "";
@@ -405,7 +405,7 @@ void myClient::do_read_body() {
}
}
else {
- qDebug() << ec.message().c_str() << endl;
+ qDebug() << ec.message().c_str() << Qt::endl;
closeConnection();
}
});
@@ -421,14 +421,14 @@ void myClient::do_write() {
boost::asio::buffer(write_msgs_.front().data(), write_msgs_.front().length()+1),
[this](boost::system::error_code ec, std::size_t /*length*/) {
if (!ec) {
- qDebug() << "Sent:" << write_msgs_.front().data() << "END" << endl;
+ qDebug() << "Sent:" << write_msgs_.front().data() << "END" << Qt::endl;
write_msgs_.pop_front();
if (!write_msgs_.empty()) {
do_write();
}
}
else {
- qDebug() << ec.message().c_str() << endl;
+ qDebug() << ec.message().c_str() << Qt::endl;
closeConnection();
}
});
diff --git a/ClientModule/myClient.h b/ClientModule/myClient.h
index 29573600..597c40f6 100644
--- a/ClientModule/myClient.h
+++ b/ClientModule/myClient.h
@@ -30,7 +30,7 @@ class myClient : public QObject
public:
myClient();
virtual ~myClient();
- crdt crdt;
+ crdt _crdt;
void do_connect();
bool getStatus();
QString getUsername();
diff --git a/ClientModule/startwindow.cpp b/ClientModule/startwindow.cpp
index 1cd1a0ff..26489fd5 100644
--- a/ClientModule/startwindow.cpp
+++ b/ClientModule/startwindow.cpp
@@ -9,7 +9,7 @@
#include "jsonUtility.h"
#include "editorwindow.h"
#include "message.h"
-#include
+//#include
using json = nlohmann::json;
using boost::asio::ip::tcp;
@@ -19,7 +19,8 @@ typedef std::deque message_queue;
StartWindow::StartWindow(QWidget *parent): QMainWindow(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint),
ui(new Ui::StartWindow), _client(new myClient)
{
- QRect screenGeometry = QApplication::desktop()->screenGeometry();
+ //QRect screenGeometry = QApplication::desktop()->screenGeometry();
+ QRect screenGeometry = QGuiApplication::primaryScreen()->availableGeometry();
double width = screenGeometry.width();
int minWidth = 1920;
double scale = width / minWidth;
@@ -61,7 +62,7 @@ void StartWindow::mouseMoveEvent(QMouseEvent *evt){
void StartWindow::on_LoginButton_clicked(){
if(_client->getStatus()==false){
_client ->do_connect();
- Sleep(1000);
+ sleep(1000);
qDebug () << "IL SERVER é connesso?--> " <<_client->getStatus();
if(_client->getStatus()==false){
//secondo controllo se non sono riuscito a ricollegarmi al server
diff --git a/ClientModule/userprofile.cpp b/ClientModule/userprofile.cpp
index e39ecf18..3857e728 100644
--- a/ClientModule/userprofile.cpp
+++ b/ClientModule/userprofile.cpp
@@ -2,6 +2,7 @@
#include "ui_userprofile.h"
#include
#include
+#include
UserProfile::UserProfile(myClient* client, QString nome, QString mail,int files, int myFiles, QWidget *parent):
QWidget(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint), ui(new Ui::UserProfile), _client(client) {
@@ -73,27 +74,34 @@ void UserProfile::mouseMoveEvent(QMouseEvent *evt) {
QChar UserProfile::SimplifySingleCharForSorting(QChar c, bool changeToLowerCase){
- if ( ( c >= 0xC0 && c <= 0xC5 ) || ( c >= 0xE1 && c <= 0xE5 ) || c == 0xAA )
- return ( ( c >= 0xC0 && c <= 0xC5 ) && !changeToLowerCase ) ? 'A' : 'a';
- if ( ( c >= 0xC8 && c <= 0xCB ) || ( c >= 0xE8 && c <= 0xEB ) )
- return ( c > 0xCB || changeToLowerCase ) ? 'e' : 'E';
- if ( ( c >= 0xCC && c <= 0xCF ) || ( c >= 0xEC && c <= 0xEF ) )
- return ( c > 0xCF || changeToLowerCase ) ? 'i' : 'I';
- if ( ( c >= 0xD2 && c <= 0xD6 ) || ( c >= 0xF2 && c <= 0xF6 ) || c == 0xBA )
- return ( ( c >= 0xD2 && c <= 0xD6 ) && !changeToLowerCase ) ? 'O' : 'o';
- if ( ( c >= 0xD9 && c <= 0xDC ) || ( c >= 0xF9 && c <= 0xFC ) )
- return ( c > 0xDC || changeToLowerCase ) ? 'u' : 'U';
- if ( c == 0xA9 || c == 0xC7 || c == 0xE7 )
- return ( c == 0xC7 && !changeToLowerCase ) ? 'C' : 'c';
- if ( c == 0xD1 || c == 0xF1 )
- return ( c == 0xD1 && !changeToLowerCase ) ? 'N' : 'n';
- if ( c == 0xAE )
+ if ( ( c >= QChar(0xC0) && c <= QChar(0xC5) ) || ( c >= QChar(0xE1) && c <= QChar(0xE5) ) || c == QChar(0xAA) )
+ return ( ( c >= QChar(0xC0) && c <= QChar(0xC5) ) && !changeToLowerCase ) ? 'A' : 'a';
+
+ if ( ( c >= QChar(0xC8) && c <= QChar(0xCB) ) || ( c >=QChar( 0xE8) && c <= QChar(0xEB) ) )
+ return ( c > QChar(0xCB) || changeToLowerCase ) ? 'e' : 'E';
+
+ if ( ( c >= QChar(0xCC) && c <= QChar(0xCF) ) || ( c >= QChar(0xEC) && c <= QChar(0xEF) ) )
+ return ( c > QChar(0xCF) || changeToLowerCase ) ? 'i' : 'I';
+
+ if ( ( c >=QChar(0xD2) && c <= QChar(0xD6) ) || ( c >= QChar(0xF2) && c <= QChar(0xF6) ) || c == QChar(0xBA) )
+ return ( ( c >= QChar(0xD2) && c <= QChar(0xD6) ) && !changeToLowerCase ) ? 'O' : 'o';
+
+ if ( ( c >= QChar(0xD9) && c <= QChar(0xDC) ) || ( c >= QChar(0xF9) && c <= QChar(0xFC) ) )
+ return ( c > QChar(0xDC) || changeToLowerCase ) ? 'u' : 'U';
+
+ if ( c == QChar(0xA9) || c == QChar(0xC7) || c == QChar(0xE7) )
+ return ( c == QChar(0xC7) && !changeToLowerCase ) ? 'C' : 'c';
+
+ if ( c ==QChar(0xD1) || c == QChar(0xF1) )
+ return ( c == QChar(0xD1) && !changeToLowerCase ) ? 'N' : 'n';
+
+ if ( c == QChar(0xAE) )
return 'r';
- if ( c == 0xDF )
+ if ( c == QChar(0xDF) )
return 's';
- if ( c == 0x8E || c == 0x9E )
- return ( c == 0x8E && !changeToLowerCase ) ? 'Z' : 'z';
- if ( c == 0x9F || c == 0xDD || c == 0xFD || c == 0xFF )
- return ( ( c == 0x9F || c == 0xDD ) && !changeToLowerCase ) ? 'Y' : 'y';
+ if ( c == QChar(0x8E) || c == QChar(0x9E) )
+ return ( c == QChar(0x8E) && !changeToLowerCase ) ? 'Z' : 'z';
+ if ( c == QChar(0x9F) || c == QChar(0xDD) || c == QChar(0xFD) || c == QChar(0xFF) )
+ return ( ( c == QChar(0x9F) || c == QChar(0xDD) ) && !changeToLowerCase ) ? 'Y' : 'y';
return c;
}
diff --git a/ServerModule/Db/texteditor_users.sqlite b/ServerModule/Db/texteditor_users.sqlite
index 4c8c67c8..01195200 100644
Binary files a/ServerModule/Db/texteditor_users.sqlite and b/ServerModule/Db/texteditor_users.sqlite differ