some stuff and added a funny randomy segfault I cant trace because funny

This commit is contained in:
2024-06-26 17:18:10 +02:00
parent 5c9a49e634
commit a3cabf4e82
66 changed files with 137 additions and 77042 deletions

View File

@@ -2,35 +2,30 @@
#include <iostream>
GridItemView::GridItemView(QWidget* parent)
: QFrame(parent), fileController(std::make_shared<FileController>( )) {
: QFrame(parent), fileController(FileController::instance( )) {
QGridLayout* mainLayout = new QGridLayout( );
this->setLayout(mainLayout);
connect(fileController.get( ), &FileController::pathChanged, this,
[this, mainLayout](const std::unordered_map<std::filesystem::path, std::filesystem::file_time_type> paths) {
/* int r{ 0 }, c{ 0 };
for (auto path : paths) {
auto w = new GridItem(path.first);
gridMap[path.first] = w;
mainLayout->addWidget(w, r, c);
w->show( );
++r;
if ((r % 8) == 0) {
++c;
r = 0;
connect(fileController, &FileController::pathChanged, this,
[this, mainLayout](const std::filesystem::path path) {
while (mainLayout->count( )) {
QWidget* widget = mainLayout->itemAt(0)->widget( );
if (widget) {
mainLayout->removeWidget(widget);
delete widget;
}
} */
}
});
fileController.get( )->updatePath("/home/crylia/Dokumente");
connect(fileController.get( ), &FileController::contentChanged, this, [this, mainLayout](std::filesystem::path path, FileEvent event) {
connect(fileController, &FileController::contentChanged, this, [this, mainLayout](std::filesystem::path path, FileEvent event) {
if (event == FileEvent::created) {
auto w = new GridItem(path);
gridMap[path] = w;
connect(w, &GridItem::clicked, this, [this, path]( ) {
emit fileController->updatePath(path);
});
int pos = gridMap.size( ) - 1;
mainLayout->addWidget(w, pos / 8, pos % 8);
w->show( );
@@ -39,7 +34,6 @@ GridItemView::GridItemView(QWidget* parent)
delete gridMap[path];
gridMap.erase(path);
// Re-layout the remaining widgets
int pos = 0;
for (const auto& [key, widget] : gridMap) {
mainLayout->addWidget(widget, pos / 8, pos % 8);
@@ -47,7 +41,6 @@ GridItemView::GridItemView(QWidget* parent)
}
} else if (event == FileEvent::modified) {
std::cout << "modified" << std::endl;
// Do nothing ig? In theory nothing has to update unless we show the time
}
});