Skip to content

Commit

Permalink
Merge pull request #143 from fxdeniz/1.8.0
Browse files Browse the repository at this point in the history
update to 1.8.0
  • Loading branch information
fxdeniz authored Jul 13, 2023
2 parents 9fc06ea + ec0b479 commit b9e9dcb
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 51 deletions.
45 changes: 23 additions & 22 deletions Backend/FileMonitorSubSystem/FileMonitoringManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ void FileMonitoringManager::slotOnModificationEventDetected(const QString &fileN
{
FileSystemEventDb::ItemStatus status = database->getStatusOfFile(currentPath);

if(status == FileSystemEventDb::ItemStatus::NewAdded)
// Do not count updates for new added and renamed files.
if(status == FileSystemEventDb::ItemStatus::NewAdded || status == FileSystemEventDb::ItemStatus::Renamed)
emit signalEventDbUpdated();
else
{
Expand All @@ -367,11 +368,7 @@ void FileMonitoringManager::slotOnModificationEventDetected(const QString &fileN

if(isFilePersists && !isFileFrozen)
{
if(status == FileSystemEventDb::ItemStatus::Renamed)
database->setStatusOfFile(currentPath, FileSystemEventDb::ItemStatus::UpdatedAndRenamed);
else
database->setStatusOfFile(currentPath, FileSystemEventDb::ItemStatus::Updated);

database->setStatusOfFile(currentPath, FileSystemEventDb::ItemStatus::Updated);
emit signalEventDbUpdated();
}
}
Expand Down Expand Up @@ -420,39 +417,43 @@ void FileMonitoringManager::slotOnMoveEventDetected(const QString &fileName, con
bool isNewFilePersists = newFileJson[JsonKeys::IsExist].toBool();
bool isNewFileFrozen = newFileJson[JsonKeys::File::IsFrozen].toBool();

FileSystemEventDb::ItemStatus oldFileStatus = database->getStatusOfFile(currentOldPath);
bool isOldFileMonitored = database->isFileExist(currentOldPath);
bool isNewFileMonitored = database->isFileExist(currentNewPath);

if(isNewFilePersists && !isNewFileFrozen)
{
if(isNewFilePersists && !isNewFileFrozen)
{
database->deleteFile(currentOldPath);
database->deleteFile(currentNewPath);
database->addFile(currentNewPath);
database->deleteFile(currentOldPath);
database->deleteFile(currentNewPath);
database->addFile(currentNewPath);

database->setOldNameOfFile(currentNewPath, originalFileName);
database->setStatusOfFile(currentNewPath, FileSystemEventDb::ItemStatus::Updated);
database->setOldNameOfFile(currentNewPath, originalFileName);
database->setStatusOfFile(currentNewPath, FileSystemEventDb::ItemStatus::Updated);

emit signalEventDbUpdated();
}
emit signalEventDbUpdated();
}
else if(isNewFilePersists && isNewFileFrozen)
{
database->deleteFile(currentOldPath);
database->deleteFile(currentNewPath);
}
else if(isOldFileMonitored && isNewFileMonitored && statusOfOldFile == FileSystemEventDb::ItemStatus::NewAdded)
{
database->deleteFile(currentOldPath);
database->deleteFile(currentNewPath);
database->addFile(currentNewPath);

database->setOldNameOfFile(currentNewPath, originalFileName);
database->setStatusOfFile(currentNewPath, FileSystemEventDb::ItemStatus::NewAdded);

emit signalEventDbUpdated();
}
else
{
if(originalFileName.isEmpty())
database->setOldNameOfFile(currentOldPath, oldFileName);

if(statusOfOldFile != FileSystemEventDb::ItemStatus::NewAdded) // Keep new added files as new added.
{
if(oldFileStatus == FileSystemEventDb::Updated || oldFileStatus == FileSystemEventDb::ItemStatus::UpdatedAndRenamed)
database->setStatusOfFile(currentOldPath, FileSystemEventDb::ItemStatus::UpdatedAndRenamed);
else
database->setStatusOfFile(currentOldPath, FileSystemEventDb::ItemStatus::Renamed);
}
database->setStatusOfFile(currentOldPath, FileSystemEventDb::ItemStatus::Renamed);

database->setNameOfFile(currentOldPath, fileName);

Expand Down
5 changes: 2 additions & 3 deletions Backend/FileMonitorSubSystem/FileSystemEventDb.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ class FileSystemEventDb
NewAdded = 1,
Updated = 2,
Renamed = 3,
UpdatedAndRenamed = 4,
Deleted = 5,
Missing = 6
Deleted = 4,
Missing = 5
};

FileSystemEventDb(const QSqlDatabase &eventDb);
Expand Down
3 changes: 1 addition & 2 deletions Gui/DataModels/TabFileMonitor/ItemDelegateAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ QWidget *ItemDelegateAction::createEditor(QWidget *parent, const QStyleOptionVie
result->addItem(ITEM_TEXT_SAVE_WITH_CHILDREN);
}
else if(status == FileSystemEventDb::ItemStatus::Updated ||
status == FileSystemEventDb::ItemStatus::Renamed ||
status == FileSystemEventDb::ItemStatus::UpdatedAndRenamed)
status == FileSystemEventDb::ItemStatus::Renamed)
{
item->setAction(TreeItem::Action::Save);

Expand Down
2 changes: 0 additions & 2 deletions Gui/DataModels/TabFileMonitor/TreeModelFileMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@ QString Model::itemStatusToString(FileSystemEventDb::ItemStatus status) const
result = "Updated";
else if(status == FileSystemEventDb::ItemStatus::Renamed)
result = "Renamed";
else if(status == FileSystemEventDb::ItemStatus::UpdatedAndRenamed)
result = "Updated & Renamed";
else if(status == FileSystemEventDb::ItemStatus::Deleted)
result = "Deleted";
else if(status == FileSystemEventDb::ItemStatus::Missing)
Expand Down
2 changes: 1 addition & 1 deletion Gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void MainWindow::on_menuAction_DebugFileMonitor_triggered()
void MainWindow::on_menuAction_AboutApp_triggered()
{
QString title = tr("About NeSync");
QString message = tr("<center><h1>NeSync 1.7.0 [Pre-Alpha]</h1><center/>"
QString message = tr("<center><h1>NeSync 1.8.0 [Pre-Alpha]</h1><center/>"
"<hr>"
"Thanks for using NeSync.<br>"
"This is a <b>pre-alpha version</b>, <b>DO NOT USE</b> for critical things.<br>"
Expand Down
30 changes: 26 additions & 4 deletions Gui/Tabs/TabFileExplorer.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "DataModels/TabFileExplorer/TableModelFileExplorer.h"
#include "DataModels/TabFileExplorer/ListModelFileExplorer.h"
#include "ui_TabFileExplorer.h"
#include "DataModels/TabFileExplorer/ListModelFileExplorer.h"
#include "DataModels/TabFileExplorer/TableModelFileExplorer.h"

#include "TabFileExplorer.h"
#include "Utility/JsonDtoFormat.h"
#include "Backend/FileStorageSubSystem/FileStorageManager.h"

#include <QQueue>
#include <QThread>
#include <QMouseEvent>
#include <QMessageBox>
#include <QFileDialog>
#include <QtConcurrent>
Expand All @@ -31,8 +32,9 @@ TabFileExplorer::TabFileExplorer(QWidget *parent) :
ui->buttonForward->setDisabled(true);
clearDescriptionDetails();

this->ui->tableView->horizontalHeader()->setMinimumSectionSize(110);
this->ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::Interactive);
ui->tableView->horizontalHeader()->setMinimumSectionSize(110);
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::Interactive);
ui->tableView->viewport()->installEventFilter(this); // uses TabFileExplorer::eventFilter();

ui->lineEditWorkingDir->setText(FileStorageManager::separator);
displayFolderInTableViewFileExplorer(FileStorageManager::separator);
Expand Down Expand Up @@ -156,6 +158,26 @@ QString TabFileExplorer::currentSymbolFolderPath() const
return ui->lineEditWorkingDir->text();
}

bool TabFileExplorer::eventFilter(QObject *watched, QEvent *event)
{
QTableView *tableView = ui->tableView;
QListView *listView = ui->listView;

if (watched == tableView->viewport() && event->type() == QEvent::Type::MouseButtonPress)
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
QModelIndex clickedIndex = tableView->indexAt(mouseEvent->pos());

if (!clickedIndex.isValid()) // When user clicked on empty area of the table view.
{
if(listView->model() != nullptr)
delete listView->model();
}
}

return QWidget::eventFilter(watched, event);
}

void TabFileExplorer::refreshFileExplorer()
{
displayFolderInTableViewFileExplorer(ui->lineEditWorkingDir->text());
Expand Down
5 changes: 4 additions & 1 deletion Gui/Tabs/TabFileExplorer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class TabFileExplorer : public QWidget

QString currentSymbolFolderPath() const;

// QObject interface
public:
bool eventFilter(QObject *watched, QEvent *event) override;

public slots:
void refreshFileExplorer();

Expand Down Expand Up @@ -72,7 +76,6 @@ private slots:
QMenu *contextMenuTableFileExplorer;
QMenu *contextMenuListFileExplorer;
QStringList navigationHistoryIndices;

};

#endif // TABFILEEXPLORER_H
10 changes: 1 addition & 9 deletions Gui/Tasks/TaskSaveChanges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,8 @@ void TaskSaveChanges::saveFileChanges()
if(isAdded)
fsEventDb.setStatusOfFile(item->getUserPath(), FileSystemEventDb::ItemStatus::Monitored);
}
else if(status == FileSystemEventDb::ItemStatus::Renamed ||
status == FileSystemEventDb::ItemStatus::UpdatedAndRenamed)
else if(status == FileSystemEventDb::ItemStatus::Renamed)
{
if(status == FileSystemEventDb::ItemStatus::UpdatedAndRenamed)
{
bool isAppended = fsm->appendVersion(symbolFilePath, item->getUserPath(), item->getDescription());
if(!isAppended)
break;
}

// Rename file
fileJson[JsonKeys::File::FileName] = fsEventDb.getNameOfFile(item->getUserPath());
bool isUpdated = fsm->updateFileEntity(fileJson);
Expand Down
4 changes: 2 additions & 2 deletions Installer/nsis_script.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Unicode True
!define BIN_SOURCE_DIR "YOUR_OUTPUT_DIR_HERE"

!define APP_NAME "NeSync"
!define COMP_NAME "Deniz Yilmazok"
!define COMP_NAME "Deniz Yilmazok (github.com/fxdeniz)"
!define WEB_SITE "github.com/fxdeniz/NeSync"
!define VERSION "1.7.0.0"
!define VERSION "1.8.0.0"
!define COPYRIGHT "2023 - Deniz Yilmazok, GPLv3"
!define DESCRIPTION "NeSync Installer"
!define INSTALLER_NAME "${BIN_SOURCE_DIR}\nesync_${VERSION}_win64_setup.exe"
Expand Down
8 changes: 4 additions & 4 deletions Resources/res_win.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
IDI_ICON1 ICON "app_icon.ico"

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,7,0,0
PRODUCTVERSION 1,7,0,0
FILEVERSION 1,8,0,0
PRODUCTVERSION 1,8,0,0
FILEFLAGS 0x0L
FILEFLAGSMASK 0x3fL
FILEOS 0x00040004L
Expand All @@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Deniz Yilmazok (github.com/fxdeniz)"
VALUE "FileDescription", "NeSync - Local file sync & backups"
VALUE "FileVersion", "1.7.0.0"
VALUE "FileVersion", "1.8.0.0"
VALUE "LegalCopyright", "2023 - Deniz Yilmazok, GPLv3"
VALUE "InternalName", "NeSync"
VALUE "OriginalFilename", "NeSync.exe"
VALUE "ProductName", "NeSync"
VALUE "ProductVersion", "1.7.0.0"
VALUE "ProductVersion", "1.8.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit b9e9dcb

Please sign in to comment.