Today’s topic is how to use Qt basic library to create a birthday reminder with support from the Linux Terminal command.
The reminder shall be:
- Store all the pair of birthdays in a text file.
- If the command has no argument, then the file shall be open and the nearest 30 birthdays will be enlist.
- Commands in forman -v <Name>,<yyyy-mm-dd> add name and the date in the text file.
- Commands in the format -n <Number> will show the “n+1” older persons.
- Comands with the format <Name> will show the most searched person
To store the pairs <Birthday Date><Name>, the QMap containers will be used, this is due this container organize its elements by function of the birthday date, that will avoid the algorithm of organization.
To handle the procedures of writing and reading between QMap and the text file, the QTextStream (Serializer Pattern) will be used. QTextStream contains the text of the file to perform its filtering and insertion in the QMap(m_subjets).
The arguments are obtained from the unique instance of the application, they are saved in a QString and the inspection is performed to determine its functionality. As an example, the case with no arguments and -v is showed below.
The ending closes the text file and the instance (to return the cursor back to the terminal).
Ezust, A., & Ezust, P. (2012). An introduction to design patterns in C with Qt. Upper Saddle River, NJ: Prentice Hall.