From 085d5cd19391921f79bd17e098361bafab73d77d Mon Sep 17 00:00:00 2001 From: Anselme Date: Mon, 24 Aug 2015 23:56:40 +0200 Subject: [PATCH] continued working on todo module --- .gitignore | 3 ++- app/todomodule.cpp | 41 ++++++++++++++++++++++++++++++++++++----- app/todomodule.h | 3 +++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 3a767a6..bc08231 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ release/* *.Release Makefile ui_* -bin/* \ No newline at end of file +bin/* +build* \ No newline at end of file diff --git a/app/todomodule.cpp b/app/todomodule.cpp index f0362b1..fe11d29 100644 --- a/app/todomodule.cpp +++ b/app/todomodule.cpp @@ -1,6 +1,7 @@ #include "todomodule.h" #include "message.h" #include +#include TodoModule::TodoModule() { @@ -13,18 +14,48 @@ bool TodoModule::messageHandler(Message msg) { if(msg.args.startsWith("!todo ")) { + answer = usage(TODO); Task t; + int deltaIndex = 1; t.isPrivate = !msg.target.contains(getChan()); t.emitter = msg.nick; t.date = time(NULL); QStringList splitter = msg.args.split(' '); - // !todo [target] durée/date [every durée_repeat] text - // date(jour/mois-[heure[:minutes[:secondes]]]) - // every day / every month / every heures[:minutes[:secondes]] + if(splitter[deltaIndex].compare("to") == 0) + { + deltaIndex += 2; + t.emitter = splitter[2]; + } + if(splitter.size() < deltaIndex+2) + return true; + QString dateString = splitter[deltaIndex]; + if(dateString.startsWith("date(")) + { + //t.date += dateString; + } + else + { + + } + } - - } + return false; +} + +QString TodoModule::usage(int type) +{ + switch(type) + { + case TODO: + return say("usage = !todo [to TARGET] DATE | DURATION [every DURATION] DESCRIPTION"); + case DURATION: + return say("DURATION = HOURS[:MINUTES[:SECONDS]]"); + case DATE: + return say("DATE = date(DAY/MONTH-[HOUR[:MINUTE[:SECOND]]])"); + } + + } void TodoModule::addTask(unsigned long date, unsigned long repeat, QString description, QString emitter, QString recipient, bool isPrivate) diff --git a/app/todomodule.h b/app/todomodule.h index 0c33b36..623c848 100644 --- a/app/todomodule.h +++ b/app/todomodule.h @@ -19,6 +19,9 @@ class TodoModule : public Module std::vector tasks; + enum {TODO, DURATION, DATE}; + QString usage(int); + public: TodoModule();