Skip to content

Commit

Permalink
io/fileview: add write support
Browse files Browse the repository at this point in the history
FileView is now getting somewhat out of hand. The asynchronous parts
especially need to be redone, but this will work for now.
  • Loading branch information
outfoxxed committed Dec 6, 2024
1 parent 2d05c7a commit 70be74e
Show file tree
Hide file tree
Showing 3 changed files with 541 additions and 124 deletions.
7 changes: 6 additions & 1 deletion src/io/FileView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ FileViewInternal {
property bool preload: this.__preload;
property bool blockLoading: this.__blockLoading;
property bool blockAllReads: this.__blockAllReads;
property bool printErrors: this.__printErrors;
property string path: this.__path;

onPreloadChanged: this.__preload = preload;
onBlockLoadingChanged: this.__blockLoading = this.blockLoading;
onBlockAllReadsChanged: this.__blockAllReads = this.blockAllReads;
onPrintErrorsChanged: this.__printErrors = this.printErrors;

// Unfortunately path can't be kept as an empty string until the file loads
// without using QQmlPropertyValueInterceptor which is private. If we lean fully
// into using private code in the future, there will be no reason not to do it here.

onPathChanged: {
if (!this.preload) this.__preload = false;
this.__printErrors = this.printErrors;
this.__path = this.path;
if (this.preload) this.__preload = true;
}
Expand All @@ -30,16 +33,18 @@ FileViewInternal {
if (!this.preload) this.__preload = false;
this.__blockLoading = this.blockLoading;
this.__blockAllReads = this.blockAllReads;
this.__printErrors = this.printErrors;
this.__path = this.path;
const text = this.__text;
if (this.preload) this.__preload = true;
return text;
}

function data(): string {
function data(): var {
if (!this.preload) this.__preload = false;
this.__blockLoading = this.blockLoading;
this.__blockAllReads = this.blockAllReads;
this.__printErrors = this.printErrors;
this.__path = this.path;
const data = this.__data;
if (this.preload) this.__preload = true;
Expand Down
Loading

0 comments on commit 70be74e

Please sign in to comment.