add ability to load todo.txt from any shared location, resolves #4

This commit is contained in:
Morgan McMillian 2018-01-21 12:22:05 -08:00
parent 778ab326d8
commit ed466b428b
3 changed files with 69 additions and 36 deletions

View file

@ -181,46 +181,60 @@ Page {
} }
} }
} }
// Divider {}
// Container {
// layout: DockLayout {}
// horizontalAlignment: HorizontalAlignment.Fill
// Container {
// leftPadding: 30.0
// rightPadding: 30.0
// DropDown {
// title: "Storage:"
// preferredWidth: 1440.0
// onSelectedIndexChanged: {
// if (sync != selectedValue) {
// modifySetting("sync", selectedValue)
// }
// }
// Option {
// text: "Local only"
// value: "local"
// selected: sync == "local"
// }
// }
// }
// }
// Container {
// layout: DockLayout {}
// horizontalAlignment: HorizontalAlignment.Fill
// Container {
// leftPadding: 30.0
// rightPadding: 30.0
// topPadding: 10.0
// TextField {
// id: dboxPath
// hintText: "Dropbox location"
// text: dboxpath
// visible: sync == "dropbox"
// onTextChanged: {
// if (dboxPath.text.length > 0) {
// modifySetting("dbox_path", dboxPath.text)
// }
// }
// }
// }
// }
Divider {} Divider {}
Container { Container {
layout: DockLayout {} layout: DockLayout {}
horizontalAlignment: HorizontalAlignment.Fill horizontalAlignment: HorizontalAlignment.Fill
Container { leftPadding: 30.0
leftPadding: 30.0 rightPadding: 30.0
rightPadding: 30.0 Button {
DropDown { preferredWidth: 1440.0
title: "Storage:" text: "Open shared todo.txt"
preferredWidth: 1440.0 onClicked: {
onSelectedIndexChanged: { sharedPicker.open()
if (sync != selectedValue) {
modifySetting("sync", selectedValue)
}
}
Option {
text: "Local only"
value: "local"
selected: sync == "local"
}
}
}
}
Container {
layout: DockLayout {}
horizontalAlignment: HorizontalAlignment.Fill
Container {
leftPadding: 30.0
rightPadding: 30.0
topPadding: 10.0
TextField {
id: dboxPath
hintText: "Dropbox location"
text: dboxpath
visible: sync == "dropbox"
onTextChanged: {
if (dboxPath.text.length > 0) {
modifySetting("dbox_path", dboxPath.text)
}
}
} }
} }
} }
@ -267,6 +281,16 @@ Page {
console.log("FileSelected signal received : " + selectedFiles); console.log("FileSelected signal received : " + selectedFiles);
taskModel.exportFiles(selectedFiles) taskModel.exportFiles(selectedFiles)
} }
},
FilePicker {
id: sharedPicker
title: "Select shared todo.txt"
type: FileType.Document
viewMode: FilePickerViewMode.ListView
onFileSelected: {
console.log("FileSelected signal: " + selectedFiles);
taskModel.openSharedFiles(selectedFiles);
}
} }
] ]
} }

View file

@ -268,6 +268,14 @@ void TaskModel::exportFiles(const QStringList &files) {
exportto.saveArchive(done); exportto.saveArchive(done);
} }
void TaskModel::openSharedFiles(QString filepath) {
QRegExp pathrgx("^/accounts/1000/");
QRegExp filergx("/(todo|done).txt$");
filepath.replace(pathrgx, "");
filepath.replace(filergx, "");
modifySetting("path", filepath);
}
void TaskModel::promptPurgeSandbox() { void TaskModel::promptPurgeSandbox() {
dialog = new SystemDialog("PURGE", "CANCEL"); dialog = new SystemDialog("PURGE", "CANCEL");
dialog->setTitle("Purge local sandbox"); dialog->setTitle("Purge local sandbox");

View file

@ -59,6 +59,7 @@ public:
Q_INVOKABLE QString formatDate(const QDateTime &date) const; Q_INVOKABLE QString formatDate(const QDateTime &date) const;
Q_INVOKABLE void promptPurgeSandbox(); Q_INVOKABLE void promptPurgeSandbox();
Q_INVOKABLE void exportFiles(const QStringList &files); Q_INVOKABLE void exportFiles(const QStringList &files);
Q_INVOKABLE void openSharedFiles(QString filepath);
Q_SLOT void setView(); Q_SLOT void setView();
Q_SLOT void setValue(int idx, const QString &key, const QVariant &value); Q_SLOT void setValue(int idx, const QString &key, const QVariant &value);
Q_SLOT void updateTask(int idx, const QString &task); Q_SLOT void updateTask(int idx, const QString &task);