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

Commit 106bb66

Browse files
committed
fixed several issues on removing objects and added "copy uuid" context menu for devs
1 parent f2da9d4 commit 106bb66

File tree

16 files changed

+165
-16
lines changed

16 files changed

+165
-16
lines changed

src/duqf-app/app-version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#define VERSION_MAJOR 0
55
#define VERSION_MINOR 8
6-
#define VERSION_BUILD 0
6+
#define VERSION_BUILD 1
77
#define VERSION_SUFFIX "Beta"
88

99
#define STRINGIFY_VERSION(A, B, C) CONCAT(A, B, C )

src/pipeline-editor/pipelinewidget.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ void PipelineWidget::newPipe(RamObject *p)
457457
{
458458
RamPipe *pipe = qobject_cast<RamPipe*>(p);
459459
if (!pipe) return;
460+
if (!pipe->inputStep()) return;
461+
if (!pipe->outputStep()) return;
460462

461463
// Get nodes
462464
DuQFNode *inputNode = nullptr;
@@ -537,8 +539,10 @@ void PipelineWidget::connectionRemoved(DuQFConnection *co)
537539
if (!input) return;
538540

539541
RamPipe *p = project->pipe(output, input);
540-
project->pipeline()->removeObjects(QStringList(p->uuid()));
541-
if (p) p->remove();
542+
if (p) {
543+
project->pipeline()->removeObjects(QStringList(p->uuid()));
544+
p->remove();
545+
}
542546
}
543547

544548
void PipelineWidget::loadProjectLayout()

src/ramdatainterface/dbinterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ QSet<QString> DBInterface::tableUuids(QString table)
6666
return m_ldi->tableUuids(table);
6767
}
6868

69-
bool DBInterface::contains(QString uuid, QString table)
69+
bool DBInterface::contains(QString uuid, QString table, bool includeRemoved)
7070
{
71-
return m_ldi->contains(uuid, table);
71+
return m_ldi->contains(uuid, table, includeRemoved);
7272
}
7373

7474
void DBInterface::createObject(QString uuid, QString table, QString data)

src/ramdatainterface/dbinterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class DBInterface : public DuQFLoggerObject
5353
// DATA INTERFACE //
5454

5555
QSet<QString> tableUuids(QString table);
56-
bool contains(QString uuid, QString table);
56+
bool contains(QString uuid, QString table, bool includeRemoved = false);
5757

5858
void createObject(QString uuid, QString table, QString data);
5959

src/ramdatainterface/localdatainterface.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ QString LocalDataInterface::getRamsesPath(QString dbFile)
160160
QSet<QString> LocalDataInterface::tableUuids(QString table, bool includeRemoved)
161161
{
162162
// If we've got the info in the cache, use it.
163-
if (CACHE_LOCAL_DATA && m_uuids.contains(table) ) return m_uuids.value(table);
163+
if (includeRemoved && CACHE_LOCAL_DATA && m_uuids.contains(table) ) return m_uuids.value(table);
164+
if (!includeRemoved && CACHE_LOCAL_DATA && m_uuidsWithoutRemoved.contains(table) ) return m_uuidsWithoutRemoved.value(table);
164165

165166
QString q = "SELECT uuid FROM '%1'";
166167
if (!includeRemoved) q += " WHERE removed = 0";
@@ -172,7 +173,8 @@ QSet<QString> LocalDataInterface::tableUuids(QString table, bool includeRemoved)
172173
while (qry.next()) data << qry.value(0).toString();
173174

174175
// Cache
175-
m_uuids.insert(table, data);
176+
if (includeRemoved) m_uuids.insert(table, data);
177+
else m_uuidsWithoutRemoved.insert(table, data);
176178

177179
return data;
178180
}
@@ -237,10 +239,10 @@ QVector<QStringList> LocalDataInterface::tableData(QString table, QHash<QString,
237239
return tData;
238240
}
239241

240-
bool LocalDataInterface::contains(QString uuid, QString table)
242+
bool LocalDataInterface::contains(QString uuid, QString table, bool includeRemoved)
241243
{
242244
// Get all UUIDS
243-
QSet<QString> uuids = tableUuids(table, true);
245+
QSet<QString> uuids = tableUuids(table, includeRemoved);
244246
return uuids.contains(uuid);
245247

246248

@@ -269,6 +271,7 @@ void LocalDataInterface::createObject(QString uuid, QString table, QString data)
269271
{
270272
// Remove table cache
271273
m_uuids.remove(table);
274+
m_uuidsWithoutRemoved.remove(table);
272275

273276
QString newData = data;
274277

@@ -489,6 +492,7 @@ ServerConfig LocalDataInterface::setDataFile(const QString &file)
489492
{
490493
// Clear all cache
491494
m_uuids.clear();
495+
m_uuidsWithoutRemoved.clear();
492496

493497
ProgressManager *pm = ProgressManager::instance();
494498
pm->addToMaximum(2);
@@ -641,6 +645,7 @@ void LocalDataInterface::saveSync(SyncData syncData)
641645

642646
// Clear cache
643647
m_uuids.remove(tableName);
648+
m_uuidsWithoutRemoved.remove(tableName);
644649

645650
// We're going to need the uuids and dates of the table
646651
QMap<QString, QString> uuidDates = modificationDates( tableName );
@@ -717,6 +722,7 @@ void LocalDataInterface::saveSync(SyncData syncData)
717722

718723
// Clear cache
719724
m_uuids.remove(tableName);
725+
m_uuidsWithoutRemoved.remove(tableName);
720726

721727
QSet<TableRow> incomingRows = i.value();
722728

@@ -932,6 +938,7 @@ QString LocalDataInterface::cleanDataBase(int deleteDataOlderThan)
932938

933939
// Clear cache
934940
m_uuids.clear();
941+
m_uuidsWithoutRemoved.clear();
935942

936943
// Get needed data
937944

src/ramdatainterface/localdatainterface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class LocalDataInterface : public DuQFLoggerObject
3434
QSet<QString> tableUuids(QString table, bool includeRemoved = false);
3535
// Returns a vector instead of set: tabledata may be sorted later
3636
QVector<QStringList> tableData(QString table, QHash<QString, QStringList> filters = QHash<QString, QStringList>(), bool includeRemoved = false);
37-
bool contains(QString uuid, QString table);
37+
bool contains(QString uuid, QString table, bool includeRemoved = false);
3838
QMap<QString, QString> modificationDates(QString table);
3939

4040
void createObject(QString uuid, QString table, QString data);
@@ -121,6 +121,7 @@ private slots:
121121

122122
// Cache UUIDS to check their existence faster
123123
QHash<QString, QSet<QString>> m_uuids;
124+
QHash<QString, QSet<QString>> m_uuidsWithoutRemoved;
124125

125126
// The UUIDS to delete when cleaning the database
126127
QHash<QString, QSet<QString>> m_uuidsToRemove;

src/rammanagerwidgets/itemmanagerwidget.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ void ItemManagerWidget::setupUi()
853853

854854
ui_table = new RamItemView(this);
855855
ui_table->setEditableObjects(false);
856-
ui_table->setContextMenuPolicy(Qt::CustomContextMenu);
856+
ui_table->setContextMenuDisabled(true);
857857
ui_header = new RamStepHeaderView(ui_table);
858858
ui_table->setHorizontalHeader( ui_header );
859859
ui_table->setSelectionMode(QAbstractItemView::ExtendedSelection);
@@ -900,6 +900,12 @@ void ItemManagerWidget::setupUi()
900900
completionContextMenu->addAction(ui_completion90 );
901901
completionContextMenu->addAction(ui_completion100);
902902
ui_contextMenu->addMenu(completionContextMenu);
903+
904+
ui_contextMenu->addSeparator();
905+
906+
ui_actionCopyUuid = new QAction(tr("Copy UUID"));
907+
ui_actionCopyUuid->setIcon(QIcon(":/icons/code"));
908+
ui_contextMenu->addAction(ui_actionCopyUuid);
903909
}
904910

905911
void ItemManagerWidget::connectEvents()
@@ -956,6 +962,8 @@ void ItemManagerWidget::connectEvents()
956962
connect(ui_copyComment, SIGNAL(triggered()), this, SLOT(copyComment()));
957963
connect(ui_cutComment, SIGNAL(triggered()), this, SLOT(cutComment()));
958964
connect(ui_pasteComment, SIGNAL(triggered()), this, SLOT(pasteComment()));
965+
// Dev tools
966+
connect(ui_actionCopyUuid, SIGNAL(triggered()), ui_table, SLOT(copyUuid()));
959967
// search
960968
connect(ui_searchEdit, SIGNAL(changing(QString)), ui_table, SLOT(search(QString)));
961969
connect(ui_searchEdit, SIGNAL(changed(QString)), ui_table, SLOT(search(QString)));

src/rammanagerwidgets/itemmanagerwidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ private slots:
159159
QAction *ui_pasteComment;
160160
RamObjectMenu *ui_assignUserContextMenu;
161161
RamObjectMenu *ui_changeStateContextMenu;
162+
QAction *ui_actionCopyUuid;
162163

163164

164165
RamProject *m_project = nullptr;

src/ramobjectmodels/dbtablemodel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "dbtablemodel.h"
22
#include "localdatainterface.h"
3+
#include "dbinterface.h"
34
#include "progressmanager.h"
45

56
DBTableModel::DBTableModel(RamObject::ObjectType type, bool projectTable, QObject *parent):
@@ -232,6 +233,9 @@ void DBTableModel::insertObject(QString uuid, QString data, QString table)
232233
{
233234
if (table != m_table) return;
234235

236+
// Removed
237+
if (DBInterface::instance()->isRemoved(uuid, table)) return;
238+
235239
// Filter
236240
if (!checkFilters(data)) return;
237241

src/ramobjects/ramabstractobject.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ void RamAbstractObject::createData(QString data)
616616
m_created = true;
617617
}
618618

619-
bool RamAbstractObject::checkUuid(QString uuid, ObjectType type, bool mayBeVirtual)
619+
bool RamAbstractObject::checkUuid(QString uuid, ObjectType type, bool mayBeVirtual, bool includeRemoved)
620620
{
621621
QString table = objectTypeName(type);
622622
if (uuid == "")
@@ -628,13 +628,16 @@ bool RamAbstractObject::checkUuid(QString uuid, ObjectType type, bool mayBeVirtu
628628
if (mayBeVirtual) return true;
629629

630630
// Check if the uuid exists in the DB
631-
if (!DBInterface::instance()->contains(uuid, table))
631+
if (!DBInterface::instance()->contains(uuid, table, includeRemoved))
632632
{
633633
qCritical() << QString("%1::get - This uuid can't be found in the database: %2").arg(table, uuid);
634634
// Don't do anything, let the caller handle it
635635
return false;
636636
}
637637

638+
// Check if it's removed
639+
//if (!includeRemoved && DBInterface::instance()->isRemoved(uuid, table)) return false;
640+
638641
return true;
639642
}
640643

0 commit comments

Comments
 (0)