Skip to content

Commit b381dcd

Browse files
committed
Make file dialog show files on Qt6
1 parent deeb256 commit b381dcd

File tree

1 file changed

+47
-12
lines changed

1 file changed

+47
-12
lines changed

interface/resources/qml/dialogs/FileDialog.qml

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ModalWindow {
3434

3535
HifiConstants { id: hifi }
3636

37-
property var filesModel: ListModel { }
37+
property var filesModel: TableModel { }
3838

3939
Settings {
4040
category: "FileDialog"
@@ -72,12 +72,14 @@ ModalWindow {
7272
signal canceled();
7373
signal selected(int button);
7474
function click(button) {
75+
// QT6TODO
7576
clickedButton = button;
7677
selected(button);
7778
destroy();
7879
}
79-
80-
property int clickedButton: OriginalDialogs.StandardButton.NoButton;
80+
81+
// QT6TODO
82+
//property int clickedButton: OriginalDialogs.StandardButton.NoButton;
8183

8284
Component.onCompleted: {
8385
fileDialogItem.keyboardEnabled = HMD.active;
@@ -311,8 +313,9 @@ ModalWindow {
311313
}
312314

313315
function clearSelection() {
314-
fileTableView.selection.clear();
315-
fileTableView.currentRow = -1;
316+
// QT6TODO
317+
//fileTableView.selection.clear();
318+
//fileTableView.currentRow = -1;
316319
update();
317320
}
318321
}
@@ -374,7 +377,25 @@ ModalWindow {
374377

375378
Component {
376379
id: filesModelBuilder
377-
ListModel { }
380+
TableModel {
381+
TableModelColumn {
382+
//id: fileNameColumn
383+
display: "fileName"
384+
//title: "Name"
385+
//width: (selectDirectory ? 1.0 : 0.5) * fileTableView.width
386+
}
387+
TableModelColumn {
388+
//id: fileModifiedColumn
389+
display: "fileModified"
390+
//title: "Date"
391+
//width: 0.3 * fileTableView.width
392+
}
393+
TableModelColumn {
394+
display: "fileSize"
395+
//title: "Size"
396+
//width: fileTableView.width - fileNameColumn.width - fileModifiedColumn.width
397+
}
398+
}
378399
}
379400

380401
QtObject {
@@ -429,11 +450,11 @@ ModalWindow {
429450
if (row === -1) {
430451
return false;
431452
}
432-
return filesModel.get(row).fileIsDir;
453+
return filesModel.getRow(row).fileIsDir;
433454
}
434455

435456
function get(row) {
436-
return filesModel.get(row)
457+
return filesModel.getRow(row)
437458
}
438459

439460
function update() {
@@ -473,7 +494,7 @@ ModalWindow {
473494
while (lower < upper) {
474495
middle = Math.floor((lower + upper) / 2);
475496
var lessThan;
476-
if (comparisonFunction(sortValue, filesModel.get(middle)[sortField])) {
497+
if (comparisonFunction(sortValue, filesModel.getRow(middle)[sortField])) {
477498
lessThan = true;
478499
upper = middle;
479500
} else {
@@ -482,7 +503,7 @@ ModalWindow {
482503
}
483504
}
484505

485-
filesModel.insert(lower, {
506+
filesModel.insertRow(lower, {
486507
fileName: fileName,
487508
fileModified: (fileIsDir ? new Date(0) : model.getItem(i, "fileModified")),
488509
fileSize: model.getItem(i, "fileSize"),
@@ -518,6 +539,7 @@ ModalWindow {
518539
property var sortIndicatorOrder: Qt.AscendingOrder
519540
property bool sortIndicatorVisible: true
520541

542+
// QT6TODO
521543
model: filesModel
522544

523545
function updateSort() {
@@ -530,7 +552,20 @@ ModalWindow {
530552

531553
onSortIndicatorOrderChanged: { updateSort(); }
532554

533-
delegate: Item {
555+
delegate: TextInput {
556+
text: model.display
557+
padding: 12
558+
selectByMouse: true
559+
560+
onAccepted: model.display = text
561+
562+
Rectangle {
563+
anchors.fill: parent
564+
color: "#efefef"
565+
z: -1
566+
}
567+
}
568+
/*delegate: Item {
534569
clip: true
535570
536571
FiraSansSemiBold {
@@ -573,7 +608,7 @@ ModalWindow {
573608
return size + " " + suffixes[suffixIndex];
574609
}
575610
}
576-
}
611+
}*/
577612

578613
/*model: TableModel {
579614
TableModelColumn {

0 commit comments

Comments
 (0)