114 lines
3.3 KiB
C++
114 lines
3.3 KiB
C++
/*
|
|
* Copyright 2012-2018 Morgan McMillian <gilag@monkeystew.com>
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef TASKMODEL_H_
|
|
#define TASKMODEL_H_
|
|
|
|
#include <bb/cascades/QListDataModel>
|
|
#include <bb/system/SystemDialog>
|
|
#include <bb/system/SystemUiButton>
|
|
#include <bb/system/SystemToast>
|
|
#include <QRegExp>
|
|
#include <QSettings>
|
|
|
|
#include "LocalFile.h"
|
|
|
|
using namespace bb::cascades;
|
|
using namespace bb::system;
|
|
|
|
class TaskModel: public bb::cascades::QVariantListDataModel {
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(int sort READ sort WRITE setSort NOTIFY sortChanged)
|
|
Q_PROPERTY(QVariantList filters READ filters FINAL)
|
|
Q_PROPERTY(QVariantList tododata READ tododata FINAL)
|
|
|
|
public:
|
|
TaskModel(QObject* parent = 0);
|
|
virtual ~TaskModel();
|
|
|
|
enum SortType { PRIORITY, ID, TEXT, DUE };
|
|
Q_ENUMS(SortType);
|
|
|
|
int sort() const;
|
|
void setSort(const int &sort);
|
|
QVariantList filters() const;
|
|
QVariantList tododata();
|
|
|
|
Q_INVOKABLE void refresh();
|
|
Q_INVOKABLE void commit();
|
|
Q_INVOKABLE void load();
|
|
Q_INVOKABLE void save();
|
|
Q_INVOKABLE void archive();
|
|
Q_INVOKABLE void search(const QString &text);
|
|
Q_INVOKABLE QVariant setting(const QString &setting, const QVariant &defVal) const;
|
|
Q_INVOKABLE QString activeFilters();
|
|
Q_INVOKABLE QString formatDate(const QDateTime &date) const;
|
|
Q_INVOKABLE void promptPurgeSandbox();
|
|
Q_INVOKABLE void exportFiles(const QStringList &files);
|
|
Q_INVOKABLE void openSharedFiles(QString filepath);
|
|
Q_SLOT void setView();
|
|
Q_SLOT void setValue(int idx, const QString &key, const QVariant &value);
|
|
Q_SLOT void updateTask(int idx, const QString &task);
|
|
Q_SLOT void addFullTask(const QString &task);
|
|
Q_SLOT void promptDelete(int idx);
|
|
Q_SLOT void delTask(int idx);
|
|
Q_SLOT void changeFilter(const QString &filter, const bool &enabled);
|
|
Q_SLOT void resetFilter();
|
|
Q_SLOT void modifySetting(const QString &setting, const QVariant &value);
|
|
Q_SLOT void onFileDataChanged(QStringList data);
|
|
Q_SLOT void onArchiveData(QStringList data);
|
|
Q_SLOT void onDeleteTask(bb::system::SystemUiResult::Type value);
|
|
Q_SLOT void onConfirmPurge(bb::system::SystemUiResult::Type value);
|
|
|
|
Q_SIGNAL void sortChanged(SortType sort);
|
|
Q_SIGNAL void listUpdated();
|
|
|
|
private:
|
|
|
|
QVariantMap parseTask(QString rawTask);
|
|
QString buildTask(const QVariantMap &task);
|
|
static bool sortByPriority(const QString &a, const QString &b);
|
|
static bool sortByText(const QString &a, const QString &b);
|
|
static bool sortByDueDate(const QString &a, const QString &b);
|
|
|
|
QRegExp regxComp;
|
|
QRegExp regxPri;
|
|
QRegExp regxDate;
|
|
QRegExp regxProj;
|
|
QRegExp regxCtx;
|
|
|
|
QSettings *ts_settings;
|
|
LocalFile localfile;
|
|
SystemDialog *dialog;
|
|
SystemToast *toast;
|
|
|
|
QStringList mProjects;
|
|
QStringList mContexts;
|
|
QStringList mDueDates;
|
|
QStringList mFilters;
|
|
QStringList mTodoList;
|
|
QStringList mArchiveData;
|
|
QVariantList mTodoData;
|
|
QString mSearch;
|
|
int mSort;
|
|
int mDelete;
|
|
bool mOffline;
|
|
|
|
};
|
|
|
|
#endif /* TASKMODEL_H_ */
|