Kitlist  1.1.0
main.cpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of Kitlist, a program to maintain a simple list
4  of items and assign items to one or more categories.
5 
6  Copyright (C) 2008-2021 Frank Dean
7 
8  Kitlist is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  Kitlist is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Kitlist. If not, see <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #include <config.h>
24 #include <locale.h>
25 #include <iostream>
26 #include <getopt.h>
27 #ifndef WIN32
28 #include <libintl.h>
29 #endif
30 #include "kitlistgui.hpp"
31 #include "kitlistpgsqldao.hpp"
32 #include "xmldao.hpp"
33 
63 using namespace std;
64 
66 static int verbose_flag = 0;
67 
69 static int html_flag = 0;
70 
78 class KitList {
79 protected:
81 public :
82  KitList(const string dbname, const string user, const string port, bool verbose = false);
83  ~KitList();
84  KitListDao* get_dao() { return m_dao; }
85  void add_item(const string name);
86  void add_item(const string name, long cat_id);
87  void append_items_to_category(long from_cat_id, long to_cat_id, item_choice choice);
88  void associate_item_with_category(long id, long cat_id);
89  void list_items_start(bool empty_list);
90  void list_item(Item& item);
91  void list_items_end(bool empty_list, size_t count);
92  void list_items(Category& c);
93  bool on_list_item(Item& item);
94  void list_items(ItemContainer& items);
95  void list_items(long cat_id, item_choice choice);
96  void execute(ItemContainer& items, ItemFunctor& functor);
97  void tick_items(Category& c);
98  void tick_items(ItemContainer& items);
99  void tick_items(long cat_id, item_choice choice);
100  void list_categories();
101  void new_category(const string name);
102  void delete_category(long id);
103  void delete_item(long id);
104  void remove_item_from_category(long id, long cat_id);
105  void set_item_flag(long id);
106  void unset_item_flag(long id);
107  void set_category_flag(long id);
108  void unset_category_flag(long id);
109  void set_all_flags();
110  void unset_all_flags();
111 };
112 
113 
114 class TickItem : public ItemFunctor {
116 public:
117  TickItem(ItemContainer& changed) : ItemFunctor(), m_changed(changed) {}
118  bool operator()(Item& item) {
119  string s;
120  cout << "Ticking item " << item.get_id() << " " << item.get_description() << endl;
121  cout.width(6);
122  cout << right << item.get_id()
123  << '\t';
124  cout.width(40);
125  cout << left << item.get_description()
126  << '\t' << " (" << (item.get_checked() ? "Yn" : "yN") << "q): ";
127  getline(cin, s);
128  bool checked = false;
129  if (!s.empty()) {
130  if (s == "y" || s == "Y") {
131  checked = true;
132  } else if (s == "n" || s == "N") {
133  checked = false;
134  } else if (s == "q" || s == "Q") {
135  return true;
136  }
137  if (checked != item.get_checked()) {
138  item.set_checked(checked);
139  m_changed.push_back(&item);
140  }
141  }
142  return false;
143  }
144 
145 };
146 
147 
162 KitList::KitList(const string dbname, const string user, string port, bool verbose) {
163 #ifdef XML_DAO
164  m_dao = new XmlDao(verbose);
165 #else
166  m_dao = new KitListPgsqlDao(dbname, user, port, verbose);
167 #endif
168 }
169 
170 
172  delete m_dao;
173 }
174 
175 
184 void KitList::add_item(const string name, long cat_id) {
185  if (cat_id >= 0) {
186  long id = m_dao->add_item(name, cat_id);
187  cout << "Added item with id " << id << " to category " << cat_id << endl << endl;
188  } else {
189  long id = m_dao->add_item(name);
190  cout << "Added item with id " << id << endl << endl;
191  }
192 }
193 
194 
203 void KitList::append_items_to_category(long from_cat_id, long to_cat_id, item_choice choice) {
204  m_dao->append_items_to_category(to_cat_id, from_cat_id, choice);
205 }
206 
207 
214 void KitList::associate_item_with_category(long id, long cat_id) {
215  m_dao->associate_item_with_category(id, cat_id);
216  cout << "Associated item " << id << " with category " << cat_id << endl << endl;
217 }
218 
219 
224  list_item(item);
225  return false;
226 }
227 
228 
238 void KitList::list_items_start(bool empty_list) {
239  if (html_flag)
240  cout << "<html>" << endl
241  << "<head>" << endl
242  << "<title>Items</title>" << endl
243  << "</head>" << endl
244  << "<body>" << endl;
245 
246  if (!empty_list) {
247  if (html_flag) {
248  cout << "<table cellpadding=\"3\" cellspacing=\"0\" border=\"1\">" << endl
249  << "<tr><th>ID</th><th>Description</th></tr>" << endl;
250  } else {
251  cout.width(6);
252  cout << right << "ID" << "\tDescription" << endl;
253  cout << right << "======" << "\t===========" << endl;
254  }
255  }
256 }
257 
258 
269 void KitList::list_items_end(bool empty_list, size_t count) {
270  if (!empty_list) {
271  if (html_flag)
272  cout << "</table>" << endl;
273  }
274 
275  if (html_flag) {
276  cout << "<p>" << count << " items</p>" << endl
277  << "</body>" << endl << "</html>" << endl;
278  } else {
279  cout << endl;
280  cout.width(6);
281  cout << count << " items" << endl << endl;
282  }
283 }
284 
285 
293  if (html_flag) {
294  cout << "<tr><td>" << item.get_id() << "</td>"
295  << "<td>" << item.get_description() << "</td></tr>" << endl;
296  } else {
297  cout.width(6);
298  cout << item.get_id();
299  cout << '\t' << item.get_description()
300  << endl;
301  }
302 }
303 
304 
309  list_items_start(!c.has_items());
310  c.foreach_item( sigc::mem_fun(*this, &KitList::on_list_item) );
311  list_items_end(!c.has_items(), c.item_count());
312 }
313 
314 
319  list_items_start(items.empty());
320  for (ItemIter i = items.begin(); i != items.end(); ++i ) {
321  list_item(**i);
322  }
323  list_items_end(items.empty(), items.size());
324 }
325 
326 
336 void KitList::list_items(long cat_id, item_choice choice = ALL_ITEMS) {
337  if (cat_id >=0 ) {
338  Category* cat = m_dao->get_category(cat_id, choice);
339  list_items(*cat);
340  delete cat;
341  } else {
342  ItemContainer* items = m_dao->get_all_items(choice);
343  list_items(*items);
344  for (ItemIter i = items->begin(); i != items->end(); ++i) {
345  delete (*i);
346  }
347  delete items;
348  }
349 }
350 
351 
357  for (ItemIter i = items.begin(); i != items.end(); ++i) {
358  if (functor(**i))
359  break;
360  }
361 }
362 
363 
368  ItemContainer changed;
369  TickItem t(changed);
370  execute(items, t);
371  m_dao->update_item_checked_state(changed);
372 }
373 
374 
379  ItemContainer changed;
380  TickItem t(changed);
381  c.execute(t);
382  m_dao->update_item_checked_state(changed);
383 }
384 
385 
394 void KitList::tick_items(long cat_id, item_choice choice = ALL_ITEMS) {
395  if (cat_id >=0 ) {
396  Category* cat = m_dao->get_category(cat_id, choice);
397  tick_items(*cat);
398  delete cat;
399  } else {
400  ItemContainer* items = m_dao->get_all_items(choice);
401  tick_items(*items);
402  for (ItemIter i = items->begin(); i != items->end(); ++i) {
403  delete (*i);
404  }
405  delete items;
406  }
407 }
408 
409 
413 void KitList::delete_item(long id) {
414  m_dao->delete_item(id);
415  cout << "Deleted item with id " << id << endl << endl;
416 }
417 
418 
425 void KitList::remove_item_from_category(long id, long cat_id) {
426  m_dao->remove_item_from_category(id, cat_id);
427  cout << "Removed item " << id << " from category " << cat_id << endl << endl;
428 }
429 
430 
436  m_dao->delete_category(id);
437  cout << "Deleted category with id " << id << endl << endl;
438 }
439 
440 
448  CategoryContainer c = m_dao->get_categories();
449 
450  if (html_flag)
451  cout << "<html>" << endl
452  << "<head>" << endl
453  << "<title>Categories</title>" << endl
454  << "</head>" << endl
455  << "<body>" << endl;
456 
457  if (!c.empty()) {
458  if (html_flag) {
459  cout << "<table cellpadding=\"3\" cellspacing=\"0\" border=\"1\">" << endl
460  << "<tr><th>ID</th><th>Description</th></tr>" << endl;
461  } else {
462  cout.width(6);
463  cout << right << "ID" << "\tDescription" << endl;
464  cout << right << "======" << "\t===========" << endl;
465  }
466  for (CategoryIter i = c.begin(); i != c.end(); ++i) {
467  if (html_flag) {
468  cout << "<tr><td>" << (*i)->get_id() << "</td>"
469  << "<td>" << (*i)->get_name() << "</td></tr>" << endl;
470  } else {
471  cout.width(6);
472  cout << (*i)->get_id()
473  << "\t" << (*i)->get_name() << endl;
474  }
475  delete (*i);
476  }
477 
478  if (html_flag)
479  cout << "</table>" << endl;
480 
481  }
482  if (html_flag) {
483  cout << "<p>" << c.size() << " categories</p>" << endl
484  << "</body>" << endl << "</html>" << endl;
485  } else {
486  cout << endl;
487  cout.width(6);
488  cout << c.size() << " categories" << endl << endl;
489  }
490 }
491 
492 
496 void KitList::new_category(const string name) {
497  long id = m_dao->new_category(name);
498  cout << "Added category id " << id << " named \"" << name << '"' << endl << endl;
499 }
500 
501 
505 void KitList::set_item_flag(long id) {
506  m_dao->set_item_flag(id);
507  cout << "Checked item with id " << id << endl << endl;
508 }
509 
510 
515  m_dao->unset_item_flag(id);
516  cout << "Unchecked items with id " << id << endl << endl;
517 }
518 
519 
524  m_dao->set_category_flag(id);
525  cout << "Checked items with category id " << id << endl << endl;
526 }
527 
528 
533  m_dao->unset_category_flag(id);
534  cout << "Unchecked items with category id " << id << endl << endl;
535 }
536 
537 
542  m_dao->set_all_flags();
543  cout << "Checked all items" << endl << endl;
544 }
545 
546 
551  m_dao->unset_all_flags();
552  cout << "Unchecked all items" << endl << endl;
553 }
554 
555 
559 int main(int argc, char **argv) {
560  setlocale(LC_CTYPE, "");
561 
562 #ifndef WIN32
563  // i18n initialisation
564  bindtextdomain(GETTEXT_PACKAGE, PROGRAMNAME_LOCALEDIR);
565  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
566  textdomain(GETTEXT_PACKAGE);
567 #endif //WIN32
568  int c;
569  string port;
570  string item_desc;
571  string cat_desc;
572  int option_index = 0;
573  int invalid_opt = false;
574  long cat_n = -1;
575  long dest_cat_n = -1;
576  long item_n = -1;;
577  int force_flag = 0;
578  item_choice checked_items_flag = ALL_ITEMS;
579  enum actions {NOP,
580  SHOW_GUI,
581  ADD_ITEM,
582  COPY_ITEMS,
583  ASSOCIATE_ITEM,
584  LIST,
585  LIST_CHECKED,
586  LIST_UNCHECKED,
587  TICK_CHECKED,
588  TICK_UNCHECKED,
589  NEW_CATEGORY,
590  LIST_CATEGORIES,
591  DELETE,
592  SET,
593  CLEAR,
594  SET_ALL,
595  CLEAR_ALL};
596  enum actions action = NOP;
597 
598  while (1) {
599  static struct option long_options[] = {
600 #ifndef XML_DAO
601  {"port", required_argument, 0, 'p'},
602  {"html", no_argument, &html_flag, 1},
603  {"no-html", no_argument, &html_flag, 0},
604  {"force", no_argument, &force_flag, 1},
605  {"add", required_argument, 0, 'a'},
606  {"add-to-category", no_argument, 0, 'A'},
607  {"category", required_argument, 0, 'c'},
608  {"copy-to-category", required_argument, 0, 'C'},
609  {"only-unchecked", no_argument, 0, 'k'},
610  {"only-checked", no_argument, 0, 'K'},
611  {"item", required_argument, 0, 'i'},
612  {"list", no_argument, 0, 'l'},
613  {"list-checked", no_argument, 0, 'X'},
614  {"list-unchecked", no_argument, 0, 'U'},
615  {"list-categories", no_argument, 0, 'q'},
616  {"tick-unchecked", no_argument, 0, 't'},
617  {"tick-checked", no_argument, 0, 'T'},
618  {"new-category", required_argument, 0, 'n'},
619  {"delete", no_argument, 0, 'd'},
620  {"set", no_argument, 0, 'x'},
621  {"clear", no_argument, 0, 'u'},
622  {"set-all", no_argument, 0, 's'},
623  {"clear-all", no_argument, 0, 'z'},
624  {"interactive", no_argument, 0, 'g'},
625 #endif
626  {"verbose", no_argument, &verbose_flag, 1},
627  {"brief", no_argument, &verbose_flag, 0},
628  {"help", no_argument, 0, 'h'},
629  {"version", no_argument, 0, 'v'},
630  {0, 0, 0, 0}
631  };
632 #ifndef XML_DAO
633  c = getopt_long(argc, argv, "hvVHp:fa:Ac:C:i:lXUqtTn:dxuszkKg",
634  long_options, &option_index);
635 #else
636  c = getopt_long(argc, argv, "hvV",
637  long_options, &option_index);
638 #endif
639  if (c == -1)
640  break;
641 
642  switch (c) {
643  case 0:
644  break;
645 
646  case 'p':
647  port = optarg;
648  break;
649 
650  case 'h':
651  cout << "Usage:" << endl
652 #ifndef XML_DAO
653  << " " << argv[0] << " [OPTIONS] [DBNAME [USERNAME]]" << endl << endl
654 #else
655  << " " << argv[0] << " [FILENAME]" << endl << endl
656 #endif
657  << "Options:" << endl
658  << " -h, --help\t\t\t\tshow this help, then exit" << endl
659  << " -v, --version\t\t\t\tshow version information, then exit" << endl
660  << " -V, --verbose\t\t\t\tverbose output" << endl
661 #ifndef XML_DAO
662  << " -g, --interactive\t\t\tDisplay interactive GUI" << endl
663  << " -p, --port=PORT\t\tspecify the port to connect to, default 5432" << endl
664  << " -a, --add=NAME\t\t\tcreate item named NAME," << endl
665  << " \t\t\tif -c specified, associates item with that category" << endl
666  << " -A, --add-to-category\t\tadd existing item to category" << endl
667  << " \t\t\t\t\tboth -i and -c must be specified" << endl
668  << " -l, --list\t\t\t\tlist all items, limit to category, if -c specified" << endl
669  << " -X, --list-checked\t\tsame as -l, except only checked items" << endl
670  << " -U, --list-unchecked\t\tsame as -l, except only unchecked items" << endl
671  << " -T, --tick-checked\t\tinteratively choose to tick/untick checked items" << endl
672  << " -t, --tick-unchecked\t\tinteratively choose to tick/untick unchecked items" << endl
673  << " -q, --list-categories\t\tlist categories" << endl
674  << " -n, --new-category=CATEGORY\tcreate category named CATEGORY" << endl
675  << " -c, --category=NUMBER\t\tspecify category number for action" << endl
676  << " -C, --copy-to-category=NUMBER\t\tcopy all or specific category to" << endl
677  << " \t\t\t\t\tcategory NUMBER. Specify source category with -c" << endl
678  << " \t\t\t\t\tor omit to copy all items" << endl
679  << " -k, --only-unchecked\t\tWhen using -C, operate on unchecked items only" << endl
680  << " -K, --only-checked\t\tWhen using -C, operate on checked items only" << endl
681  << " -i, --item=NUMBER\t\t\tspecify item number for action" << endl
682  << " -d, --delete\t\t\t\tdelete category or item specified by -c or -i, if" << endl
683  << " \t\t\t\t\tboth -i and -c are specifed, simply removes the " << endl
684  << " \t\t\t\t\tassociation between them" << endl
685  << " -x, --set\t\t\t\t\tset flag for item specified by -i" << endl
686  << " -u, --clear\t\t\t\tclear flag for item specified by -i" << endl
687  << " -s, --set-all\t\t\t\tsets all flags" << endl
688  << " -z, --clear-all\t\t\tclears all flags" << endl
689  << " -H, --html\t\t\t\thtml formatted output" << endl
690 #endif
691  ;
692  return 0;
693 
694  case 'v':
695  cout << "kitlist " << VERSION << endl;
696  return 0;
697 
698  case 'V':
699  verbose_flag = 1;
700  break;
701 
702  case 'H':
703  html_flag = 1;
704  break;
705 
706  case '?':
707  invalid_opt = true;
708  break;
709 
710  case 'i':
711  item_n = strtol(optarg, NULL, 0);
712  break;
713  case 'c':
714  cat_n = strtol(optarg, NULL, 0);
715  break;
716  case 'C':
717  action = COPY_ITEMS;
718  dest_cat_n = strtol(optarg, NULL, 0);
719  break;
720  case 'a':
721  action = ADD_ITEM;
722  item_desc = optarg;
723  break;
724  case 'A':
725  action = ASSOCIATE_ITEM;
726  break;
727  case 'l':
728  action = LIST;
729  break;
730  case 'X':
731  action = LIST_CHECKED;
732  break;
733  case 'U':
734  action = LIST_UNCHECKED;
735  break;
736  case 'T':
737  action = TICK_CHECKED;
738  break;
739  case 't':
740  action = TICK_UNCHECKED;
741  break;
742  case 'q':
743  action = LIST_CATEGORIES;
744  break;
745 
746  case 'n':
747  action = NEW_CATEGORY;
748  cat_desc = optarg;
749  break;
750 
751  case 'd':
752  action = DELETE;
753  break;
754 
755  case 'x':
756  action = SET;
757  break;
758 
759  case 'u':
760  action = CLEAR;
761  break;
762 
763  case 's':
764  action = SET_ALL;
765  break;
766 
767  case 'z':
768  action = CLEAR_ALL;
769  break;
770 
771  case 'f':
772  force_flag = 1;
773  break;
774 
775  case 'k':
776  checked_items_flag = UNCHECKED_ITEMS;
777  break;
778 
779  case 'K':
780  checked_items_flag = CHECKED_ITEMS;
781  break;
782 
783  case 'g':
784  action = SHOW_GUI;
785  break;
786 
787  default:
788  abort();
789  }
790  }
791  if (invalid_opt)
792  return 1;
793  int index;
794  index = optind;
795  string dbname = (index < argc) ? argv[index++] : "";
796  string user = (index < argc) ? argv[index++] : "";
797 
798  KitList kit(dbname, user, port, verbose_flag);
799 
800 #ifndef XML_DAO
801  // No options, run GUI
802  action = (argc == 1) ? SHOW_GUI : action;
803 #else
804  // Always show the GUI
805  action = SHOW_GUI;
806 #endif
807 
808  switch (action) {
809  case ADD_ITEM:
810  kit.add_item(item_desc, cat_n);
811  break;
812  case COPY_ITEMS:
813  if (cat_n >= 0 || force_flag) {
814  kit.append_items_to_category(cat_n, dest_cat_n, checked_items_flag);
815  } else {
816  cerr << "Specify -f (--force) to copy all items to a category" << endl << endl;
817  }
818  break;
819  case ASSOCIATE_ITEM:
820  if (item_n >= 0 && cat_n >=0) {
821  kit.associate_item_with_category(item_n, cat_n);
822  } else {
823  cerr << "You must specify the item and category using -i and -c" << endl << endl;
824  }
825  break;
826  case LIST:
827  kit.list_items(cat_n);
828  break;
829  case LIST_CHECKED:
830  kit.list_items(cat_n, CHECKED_ITEMS);
831  break;
832  case LIST_UNCHECKED:
833  kit.list_items(cat_n, UNCHECKED_ITEMS);
834  break;
835  case TICK_CHECKED:
836  kit.tick_items(cat_n, CHECKED_ITEMS);
837  break;
838  case TICK_UNCHECKED:
839  kit.tick_items(cat_n, UNCHECKED_ITEMS);
840  break;
841  case LIST_CATEGORIES:
842  kit.list_categories();
843  break;
844  case NEW_CATEGORY:
845  kit.new_category(cat_desc);
846  break;
847  case DELETE:
848  if (cat_n >= 0 && item_n >=0) {
849  kit.remove_item_from_category(item_n, cat_n);
850  } else if (item_n >=0) {
851  kit.delete_item(item_n);
852  } else {
853  if (force_flag) {
854  kit.delete_category(cat_n);
855  } else {
856  cerr << "Specify -f (--force) to delete a category" << endl << endl;
857  return 1;
858  }
859  }
860  break;
861 
862  case SET:
863  if (item_n >=0) {
864  kit.set_item_flag(item_n);
865  } else {
866  cerr << "Specify an item set using -i or --item" << endl << endl;
867  return 1;
868  }
869  break;
870  case CLEAR:
871  if (item_n >=0) {
872  kit.unset_item_flag(item_n);
873  } else {
874  cerr << "Specify an item to clear using -i or --item" << endl << endl;
875  return 1;
876  }
877  break;
878  case SET_ALL:
879  if (cat_n >=1) {
880  kit.set_category_flag(cat_n);
881  } else {
882  if (force_flag) {
883  kit.set_all_flags();
884  } else {
885  cerr << "Specify -f (--force) to set all flags" << endl << endl;
886  }
887  }
888  break;
889  case CLEAR_ALL:
890  if (cat_n >=1) {
891  kit.unset_category_flag(cat_n);
892  } else {
893  if (force_flag) {
894  kit.unset_all_flags();
895  } else {
896  cerr << "Specify -f (--force) to clear all flags" << endl << endl;
897  }
898  }
899  break;
900  case SHOW_GUI:
901  Service service(*kit.get_dao());
902  KitListGui gui(argc, argv, service);
903 #ifdef XML_DAO
904  // When we're not using the database dbname, actually
905  // contains the first non-option argument, which in this
906  // case is the filename
907  if (dbname.length() > 0)
908  gui.open_file(dbname);
909 #endif
910  gui.run();
911  break;
912  } // case
913 
914 }
TickItem(ItemContainer &changed)
Definition: main.cpp:117
long get_id()
Definition: item.hpp:46
void delete_item(long id)
Definition: main.cpp:413
void tick_items(Category &c)
Definition: main.cpp:378
void list_item(Item &item)
Outputs details of the passed item to STDOUT.
Definition: main.cpp:292
void set_category_flag(long id)
Definition: main.cpp:523
virtual bool has_items()
Returns true if there are any items associated with this category.
Definition: category.hpp:53
int main(int argc, char **argv)
Definition: main.cpp:559
ItemContainer::iterator ItemIter
Definition: item.hpp:92
CategoryContainer::iterator CategoryIter
Definition: category.hpp:85
~KitList()
Definition: main.cpp:171
STL namespace.
void unset_category_flag(long id)
Definition: main.cpp:532
KitListDao * m_dao
Reference to an implementation DAO class.
Definition: main.cpp:80
void append_items_to_category(long from_cat_id, long to_cat_id, item_choice choice)
Copies items from one category to another.
Definition: main.cpp:203
std::vector< Item * > ItemContainer
Definition: item.hpp:91
void set_all_flags()
Definition: main.cpp:541
void delete_category(long id)
Definition: main.cpp:435
void add_item(const string name)
void foreach_item(const SlotForeachItem &slot)
Executes a callback function for each associated item.
Definition: category.cpp:55
virtual void set_checked(bool checked)
Definition: item.hpp:49
virtual size_t item_count()
Returns the number of items associated with this category.
Definition: category.hpp:51
void execute(ItemContainer &items, ItemFunctor &functor)
Definition: main.cpp:356
void list_items(Category &c)
Definition: main.cpp:308
bool operator()(Item &item)
Definition: main.cpp:118
void unset_item_flag(long id)
Definition: main.cpp:514
void list_items_end(bool empty_list, size_t count)
Called after writing a list of items to STDOUT.
Definition: main.cpp:269
Defines the methods that an implementation of this class must implement.
Definition: kitlistdao.hpp:46
void set_item_flag(long id)
Definition: main.cpp:505
Represents an Item.
Definition: item.hpp:37
Encapsulates the methods for the application&#39;s GUI front end.
Definition: kitlistgui.hpp:99
void remove_item_from_category(long id, long cat_id)
Definition: main.cpp:425
void associate_item_with_category(long id, long cat_id)
Associates an existing item with an existing category.
Definition: main.cpp:214
Main application class.
Definition: main.cpp:78
static int verbose_flag
Flag set by `–verbose&#39;.
Definition: main.cpp:66
Represents a Category.
Definition: category.hpp:37
ItemContainer & m_changed
Definition: main.cpp:115
bool on_list_item(Item &item)
Definition: main.cpp:223
void execute(ItemFunctor &functor)
Executes the passed ItemFunctor.
Definition: category.cpp:71
std::string get_description()
Definition: item.hpp:48
bool get_checked()
Definition: item.hpp:50
Implementation of a KitListDao using XML as the persistence store.
Definition: xmldao.hpp:42
KitList(const string dbname, const string user, const string port, bool verbose=false)
Constructor specifying Postgresql database connection parameters.
Definition: main.cpp:162
void list_items_start(bool empty_list)
Called before writing a list of items to STDOUT.
Definition: main.cpp:238
std::vector< Category * > CategoryContainer
Definition: category.hpp:84
item_choice
Definition: kitlistdao.hpp:36
void new_category(const string name)
Definition: main.cpp:496
KitListDao * get_dao()
Definition: main.cpp:84
void list_categories()
Lists details of all categories to STDOUT.
Definition: main.cpp:447
Functor for processing items.
Definition: item.hpp:85
Business/service layer implementation.
Definition: service.hpp:38
void unset_all_flags()
Definition: main.cpp:550
static int html_flag
Flag set by `–html&#39;.
Definition: main.cpp:69

Copyright 2008-2021 Frank Dean