/usr/lib/Wt/examples/planner/EntryDialog.C is in witty-examples 3.1.10-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | /*
* Copyright (C) 2010 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#include "EntryDialog.h"
#include "TimeSuggestions.h"
#include "Entry.h"
#include "PlannerApplication.h"
#include <Wt/WTemplate>
#include <Wt/WPushButton>
#include <Wt/WRegExpValidator>
#include <Wt/Dbo/WtSqlTraits>
using namespace Wt;
using namespace Wt::Dbo;
WString EntryDialog::timeFormat = WString::fromUTF8("HH:mm");
EntryDialog::EntryDialog(const WString& title, CalendarCell* cell)
: WDialog(title)
{
cell_ = cell;
WTemplate* t = new WTemplate(contents());
t->setTemplateText(tr("calendar.entry"));
summary_ = new WLineEdit();
summary_->setValidator(new WValidator());
t->bindWidget("summary", summary_);
WValidator* timeValidator =
new WRegExpValidator("^([0-1][0-9]|[2][0-3]):([0-5][0-9])$");
start_ = new WLineEdit();
start_->setTextSize(5);
start_->setValidator(timeValidator);
t->bindWidget("start", start_);
stop_ = new WLineEdit();
stop_->setTextSize(5);
stop_->setValidator(timeValidator);
t->bindWidget("stop", stop_);
description_ = new WTextArea();
t->bindWidget("description", description_);
TimeSuggestions* suggestions = new TimeSuggestions(contents());
suggestions->forEdit(start_);
suggestions->forEdit(stop_);
WPushButton* ok = new WPushButton(tr("calendar.entry.ok"));
t->bindWidget("ok", ok);
ok->clicked().connect(this, &EntryDialog::ok);
WPushButton* cancel = new WPushButton(tr("calendar.entry.cancel"));
t->bindWidget("cancel", cancel);
cancel->clicked().connect(this, &EntryDialog::cancel);
}
WDateTime EntryDialog::timeStamp(const WString& time, const WDate& day)
{
WString timeStamp = day.toString("dd/MM/yyyy ");
timeStamp += time;
return WDateTime::fromString(timeStamp, "dd/MM/yyyy " + timeFormat);
}
WString EntryDialog::description()
{
return description_->text();
}
void EntryDialog::ok()
{
Session& session = PlannerApplication::plannerApplication()->session;
Transaction transaction(session);
ptr<Entry> e =
PlannerApplication::plannerApplication()->session.add(new Entry());
e.modify()->start = timeStamp(start_->text(), cell_->date());
e.modify()->stop = timeStamp(stop_->text(), cell_->date());
e.modify()->summary = summary_->text().toUTF8();
e.modify()->text = description().toUTF8();
e.modify()->user = cell_->user();
cell_->update(cell_->user(), cell_->date());
transaction.commit();
hide();
}
void EntryDialog::cancel()
{
hide();
}
|