AllEntriesDialog.C 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (C) 2010 Emweb bvba, Kessel-Lo, Belgium.
  3. *
  4. * See the LICENSE file for terms of use.
  5. */
  6. #include "AllEntriesDialog.h"
  7. #include "PlannerApplication.h"
  8. #include "EntryDialog.h"
  9. #include "Entry.h"
  10. #include <Wt/WTemplate>
  11. #include <Wt/WString>
  12. #include <Wt/WText>
  13. #include <Wt/WPushButton>
  14. using namespace Wt;
  15. AllEntriesDialog::AllEntriesDialog(const WString& title, CalendarCell* cell)
  16. : WDialog(title)
  17. {
  18. WTemplate* t = new WTemplate(tr("calendar.all-entries"), contents());
  19. WContainerWidget* wc = new WContainerWidget();
  20. t->bindWidget("entries", wc);
  21. dbo::Session& session = PlannerApplication::plannerApplication()->session;
  22. dbo::Transaction transaction(session);
  23. typedef dbo::collection< dbo::ptr<Entry> > Entries;
  24. Entries entries =
  25. cell->user()->entriesInRange(cell->date(), cell->date().addDays(1));
  26. WString format = EntryDialog::timeFormat;
  27. for (Entries::const_iterator i = entries.begin(); i != entries.end(); ++i) {
  28. wc->addWidget(new WText((*i)->start.toString(format) +
  29. "-" +
  30. (*i)->stop.toString(format) +
  31. ": " + (*i)->summary));
  32. }
  33. transaction.commit();
  34. WPushButton* button = new WPushButton(tr("calendar.cell.all-entries.close"));
  35. t->bindWidget("close", button);
  36. button->clicked().connect(this, &AllEntriesDialog::closeDialog);
  37. }
  38. void AllEntriesDialog::closeDialog()
  39. {
  40. hide();
  41. }