Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 26287f2

Browse files
authored
Merge pull request #66 from RxLaboratory/0.7.0-test
0.7.0 new sync methods
2 parents 08f2912 + fc64d86 commit 26287f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1018
-610
lines changed

src/Ramses.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ SOURCES += \
202202
HEADERS += \
203203
config.h \
204204
progressmanager.h \
205+
ramdatainterface/datastruct.h \
205206
rameditwidgets/objectupdateblocker.h \
206207
rammanagerwidgets/dbmanagerwidget.h \
207208
rammanagerwidgets/objectlistwidget.h \

src/mainwindow.cpp

Lines changed: 79 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ void MainWindow::connectEvents()
360360
connect(Ramses::instance(),&Ramses::userChanged, this, &MainWindow::currentUserChanged);
361361
connect(Ramses::instance(), &Ramses::currentProjectChanged, this, &MainWindow::currentProjectChanged);
362362
connect(DBInterface::instance(),&DBInterface::connectionStatusChanged, this, &MainWindow::dbiConnectionStatusChanged);
363-
connect(DBInterface::instance(), SIGNAL(synced()), this, SLOT(update()));
363+
connect(DBInterface::instance(), SIGNAL(syncFinished()), this, SLOT(finishSync()));
364+
connect(DBInterface::instance(), SIGNAL(syncStarted()), this, SLOT(startSync()));
364365
}
365366

366367
void MainWindow::connectShortCuts()
@@ -818,6 +819,7 @@ void MainWindow::databaseSettingsAction()
818819

819820
void MainWindow::home()
820821
{
822+
mainToolBar->show();
821823
mainStack->setCurrentIndex(0);
822824
}
823825

@@ -834,44 +836,56 @@ void MainWindow::revealUserFolder()
834836

835837
void MainWindow::admin(bool show)
836838
{
839+
mainToolBar->show();
837840
if (show) mainStack->setCurrentIndex(3);
838841
else home();
839842
}
840843

841844
void MainWindow::projectSettings(bool show)
842845
{
846+
mainToolBar->show();
843847
if (show) mainStack->setCurrentIndex(4);
844848
else home();
845849
}
846850

847851
void MainWindow::pipeline(bool show)
848852
{
853+
mainToolBar->show();
849854
if (show) mainStack->setCurrentIndex(5);
850855
else home();
851856
}
852857

853858
void MainWindow::shots(bool show)
854859
{
860+
mainToolBar->show();
855861
if (show) mainStack->setCurrentIndex(7);
856862
else home();
857863
}
858864

859865
void MainWindow::assets(bool show)
860866
{
867+
mainToolBar->show();
861868
if (show) mainStack->setCurrentIndex(6);
862869
else home();
863870
}
864871

865872
void MainWindow::schedule(bool show)
866873
{
874+
mainToolBar->show();
867875
if (show) mainStack->setCurrentIndex(8);
868876
else home();
869877
}
870878

871879
void MainWindow::progress(bool show)
872880
{
873-
if (show) mainStack->setCurrentIndex(9);
874-
else home();
881+
if (show) {
882+
mainStack->setCurrentIndex(9);
883+
mainToolBar->hide();
884+
}
885+
else {
886+
home();
887+
mainToolBar->show();
888+
}
875889
}
876890

877891
void MainWindow::install(bool show)
@@ -985,7 +999,6 @@ void MainWindow::freezeUI(bool f)
985999
if (f)
9861000
{
9871001
m_currentPageIndex = mainStack->currentIndex();
988-
mainToolBar->hide();
9891002
progress();
9901003
}
9911004
else
@@ -1032,11 +1045,23 @@ void MainWindow::dbiConnectionStatusChanged(NetworkUtils::NetworkStatus s)
10321045
}
10331046
}
10341047

1035-
void MainWindow::fullSync()
1048+
void MainWindow::finishSync()
10361049
{
1037-
DBInterface::instance()->generalSync();
1038-
RamProject *proj = Ramses::instance()->currentProject();
1039-
if (proj) DBInterface::instance()->projectSync(proj->uuid());
1050+
if (m_closing) {
1051+
m_readyToClose = true;
1052+
this->close();
1053+
return;
1054+
}
1055+
1056+
ui_refreshButton->show();
1057+
mainStatusBar->showMessage(tr("Sync finished!"), 5000);
1058+
}
1059+
1060+
void MainWindow::startSync()
1061+
{
1062+
ui_refreshButton->hide();
1063+
mainStatusBar->showMessage(tr("Syncing..."));
1064+
10401065
}
10411066

10421067
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
@@ -1089,19 +1114,54 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
10891114

10901115
void MainWindow::closeEvent(QCloseEvent *event)
10911116
{
1092-
// Get to the home page first to make sure all toolbars are hidden
1093-
home();
1117+
if (m_closing && !m_readyToClose)
1118+
{
1119+
QMessageBox::StandardButton r = QMessageBox::question(this,
1120+
tr("Closing Ramses..."),
1121+
tr("I'm already closing, do you want me to force quit?\n\nThis may cause some data loss if the sync is not finished yet.")
1122+
);
1123+
if (r == QMessageBox::Yes) m_readyToClose = true;
1124+
}
10941125

1095-
// Let's save the ui state
1096-
QSettings settings;
1097-
settings.beginGroup("ui");
1098-
settings.setValue("maximized", this->isMaximized());
1099-
settings.setValue("windowState", this->saveState());
1100-
settings.endGroup();
1126+
if (!m_readyToClose)
1127+
{
1128+
// Get to the home page first to make sure all toolbars are hidden
1129+
home();
1130+
1131+
// Let's save the ui state
1132+
QSettings settings;
1133+
settings.beginGroup("ui");
1134+
settings.setValue("maximized", this->isMaximized());
1135+
settings.setValue("windowState", this->saveState());
1136+
settings.endGroup();
1137+
1138+
if (DBInterface::instance()->connectionStatus() == NetworkUtils::Online)
1139+
{
1140+
// Clean before quit!
1141+
m_closing = true;
11011142

1102-
QFontDatabase::removeAllApplicationFonts();
1103-
trayIcon->hide();
1104-
QMainWindow::closeEvent(event);
1143+
ProgressManager *pm = ProgressManager::instance();
1144+
pm->setTitle("Disconnecting...");
1145+
pm->setText("One last sync!");
1146+
pm->setMaximum(3);
1147+
pm->start();
1148+
pm->freeze();
1149+
1150+
DBInterface::instance()->setOffline();
1151+
1152+
event->ignore();
1153+
}
1154+
else m_readyToClose = true;
1155+
1156+
}
1157+
1158+
if (m_readyToClose)
1159+
{
1160+
QFontDatabase::removeAllApplicationFonts();
1161+
trayIcon->hide();
1162+
1163+
QMainWindow::closeEvent(event);
1164+
}
11051165
}
11061166

11071167
void MainWindow::keyPressEvent(QKeyEvent *key)

src/mainwindow.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,18 @@ private slots:
141141
void currentProjectChanged(RamProject *project);
142142
void freezeUI(bool f = true);
143143
void dbiConnectionStatusChanged(NetworkUtils::NetworkStatus s);
144-
void fullSync();
144+
void finishSync();
145+
void startSync();
146+
145147

146148
protected:
147149
void closeEvent(QCloseEvent *event) override;
148150
void keyPressEvent(QKeyEvent *key) override;
149151
void keyReleaseEvent(QKeyEvent *key) override;
150152
bool eventFilter(QObject *obj, QEvent *event) override;
153+
154+
private:
155+
bool m_readyToClose = false;
156+
bool m_closing = false;
151157
};
152158
#endif // MAINWINDOW_H

src/pages/projectpage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void ProjectPage::createStepFromTemplate(RamObject *templateStepObj)
173173
if (!project) return;
174174

175175
RamStep *step = RamStep::createFromTemplate(templateStep, project);
176-
project->steps()->appendObject(step->uuid());
176+
//project->steps()->appendObject(step->uuid());
177177
step->edit();
178178
}
179179

src/pipeline-editor/stepnode.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include "stepnode.h"
22

3-
#include "ramproject.h"
4-
53
StepNode::StepNode(RamStep *step): ObjectNode(step)
64
{
75
_step = step;
@@ -26,8 +24,8 @@ void StepNode::stepChanged()
2624
void StepNode::removeStep()
2725
{
2826
if (!_step) return;
29-
RamProject *p = _step->project();
30-
if (p) p->steps()->removeObjects(QStringList(_step->uuid()));
27+
//RamProject *p = _step->project();
28+
//if (p) p->steps()->removeObjects(QStringList(_step->uuid()));
3129
_step->remove();
3230

3331
}

src/progressmanager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void ProgressManager::reInit()
7676
void ProgressManager::finish()
7777
{
7878
m_busy = false;
79+
freeze(false);
7980
emit finished();
8081
}
8182

src/ramdatainterface/datastruct.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#ifndef DATASTRUCT_H
2+
#define DATASTRUCT_H
3+
4+
struct ServerConfig {
5+
QString address = "";
6+
int updateDelay = 60000;
7+
int timeout = 3000;
8+
bool useSsl = true;
9+
int port = 443;
10+
};
11+
12+
struct Request
13+
{
14+
QNetworkRequest request;
15+
QString body;
16+
QString query;
17+
};
18+
19+
struct TableRow
20+
{
21+
QString uuid;
22+
QString data;
23+
QString userName;
24+
QString modified;
25+
int removed;
26+
};
27+
28+
struct SyncData
29+
{
30+
QHash<QString, QSet<TableRow>> tables;
31+
QHash<QString, QStringList> deletedUuids;
32+
QString syncDate;
33+
};
34+
35+
struct TableFetchData
36+
{
37+
QString name;
38+
int rowCount = 0;
39+
int pageCount = 0;
40+
int deleteCount = 0;
41+
bool pulled = false;
42+
int currentPage = 0;
43+
};
44+
45+
struct FetchData
46+
{
47+
QSet<TableFetchData> tables;
48+
int tableCount;
49+
};
50+
51+
inline bool operator==(const TableFetchData &a, const TableFetchData &b)
52+
{
53+
return a.name == b.name;
54+
}
55+
56+
inline uint qHash(const TableFetchData &a)
57+
{
58+
return qHash(a.name);
59+
}
60+
61+
inline bool operator==(const TableRow &a, const TableRow &b)
62+
{
63+
return a.uuid == b.uuid;
64+
}
65+
66+
inline uint qHash(const TableRow &a)
67+
{
68+
return qHash(a.uuid);
69+
}
70+
71+
#endif // DATASTRUCT_H

0 commit comments

Comments
 (0)