Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: HaikuArchives/Calendar
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3ea1580e2177
Choose a base ref
...
head repository: HaikuArchives/Calendar
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f0ab3dcc2098
Choose a head ref
  • 1 commit
  • 17 files changed
  • 1 contributor

Commits on Oct 26, 2021

  1. Differentiate between "canceling" and "deleting" (#88)

    Now two menu options are shown― one for canceling an event, which will
    mark it as "cancelled" (changing the list item's font-face to strikeout
    and disabling notification), and another for deletion, which will send
    it to the system Trash folder.
    
    The structure of events' status has changed to be a little more
    flexible, and the way the file attribute Event:Status is parsed has been
    changed (to be a list, e.g., "Cancelled, Notified"). And thanks
    to the new dichotomy between "Cancelled" and "Deleted", all previously
    deleted events have to be migrated over, which is done on the first
    start-up after this update.
    JadedCtrl authored Oct 26, 2021

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    f0ab3dc View commit details
58 changes: 38 additions & 20 deletions src/DayView.cpp
Original file line number Diff line number Diff line change
@@ -98,32 +98,47 @@ DayView::MessageReceived(BMessage* message)
}
break;
}

case kDeleteEventMessage:
case kCancelEventMessage:
{

int32 selection = fEventListView->CurrentSelection();
if (selection >= 0) {
Event* event = ((Event*)fEventList->ItemAt(selection));

BAlert* alert = new BAlert(B_TRANSLATE("Confirm delete"),
B_TRANSLATE("Are you sure you want to delete the selected event?"),
NULL, B_TRANSLATE("OK"), B_TRANSLATE("Cancel"), B_WIDTH_AS_USUAL, B_WARNING_ALERT);
if (selection < 0)
return;
Event* event = ((Event*)fEventList->ItemAt(selection));
bool isCancelled = (event->GetStatus() & EVENT_CANCELLED);

BString title(B_TRANSLATE("Confirm delete"));
BString label(B_TRANSLATE("Are you sure you want to move the selected event to Trash?"));
if (message->what == kCancelEventMessage) {
title = B_TRANSLATE("Confirm cancellation");
label = B_TRANSLATE("Are you sure you want to cancel the selected event?");
}

// If disabling a previous cancellation, the confirmation dialogue
// doesn't really make sense.
int32 button_index = 0;
if (!(message->what == kCancelEventMessage && isCancelled == true)) {
BAlert* alert = new BAlert(title, label, NULL, B_TRANSLATE("OK"),
B_TRANSLATE("Cancel"), B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(1, B_ESCAPE);
int32 button_index = alert->Go();

if (button_index == 0) {
Event newEvent(*event);
newEvent.SetStatus(false);
newEvent.SetUpdated(time(NULL));
fDBManager->UpdateEvent(event, &newEvent);
Window()->LockLooper();
LoadEvents();
Window()->UnlockLooper();
}
button_index = alert->Go();
}

if (button_index == 0) {
Event newEvent(*event);
newEvent.SetUpdated(time(NULL));
if (message->what == kCancelEventMessage && isCancelled == false)
newEvent.SetStatus(newEvent.GetStatus() | EVENT_CANCELLED);
else if (message->what == kCancelEventMessage)
newEvent.SetStatus(newEvent.GetStatus() & ~EVENT_CANCELLED);
else
newEvent.SetStatus(newEvent.GetStatus() | EVENT_DELETED);

fDBManager->UpdateEvent(event, &newEvent);
Window()->LockLooper();
LoadEvents();
Window()->UnlockLooper();
}
break;
}
case kDayView:
@@ -236,8 +251,11 @@ DayView::_PopulateEvents()

eventName << event->GetName();
rgb_color color = event->GetCategory()->GetColor();
uint16 face = -1;
if (event->GetStatus() & EVENT_CANCELLED)
face = 0 | B_ITALIC_FACE | B_LIGHT_FACE | B_STRIKEOUT_FACE;

item = new EventListItem(eventName, timePeriod , color);
item = new EventListItem(eventName, timePeriod , color, face);
fEventListView->AddItem(item);
}

7 changes: 4 additions & 3 deletions src/DayView.h
Original file line number Diff line number Diff line change
@@ -18,11 +18,12 @@ class QueryDBManager;

const uint32 kEditEventMessage = 'ksem';
const uint32 kDeleteEventMessage = 'kdem';
const uint32 kCancelEventMessage = 'kcem';
const uint32 kLaunchEventManagerToModify = 'klem';

static const int kDayView = 1005;
static const int kWeekView = 1006;
static const int kAgendaView = 1007;
static const int kDayView = 1006;
static const int kWeekView = 1007;
static const int kAgendaView = 1008;

class DayView: public BView {
public:
6 changes: 5 additions & 1 deletion src/EventListItem.cpp
Original file line number Diff line number Diff line change
@@ -12,13 +12,15 @@
#include "EventListItem.h"


EventListItem::EventListItem(BString name, BString timeText, rgb_color color)
EventListItem::EventListItem(BString name, BString timeText, rgb_color color,
uint16 font_face)
:
BListItem()
{
fName = name;
fTimeText = timeText;
fColor = color;
fFace = font_face;
}


@@ -96,6 +98,8 @@ EventListItem::DrawItem(BView* view, BRect rect, bool complete)

namefont.SetSize(timefont.Size() + 2);
namefont.GetHeight(&finfo);
if (fFace > -1)
namefont.SetFace(fFace);
view->SetFont(&namefont);

view->MovePenTo(offset, rect.top + ((rect.Height()
3 changes: 2 additions & 1 deletion src/EventListItem.h
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
class EventListItem: public BListItem {
public:
EventListItem(BString name, BString timeText,
rgb_color color);
rgb_color color, uint16 font_face = -1);
~EventListItem();

virtual void DrawItem(BView*, BRect, bool);
@@ -28,6 +28,7 @@ class EventListItem: public BListItem {
BString fName;
BString fTimeText;
rgb_color fColor;
uint16 fFace;
};

#endif // EVENTLLISTITEM_H
6 changes: 6 additions & 0 deletions src/EventListView.cpp
Original file line number Diff line number Diff line change
@@ -124,11 +124,14 @@ EventListView::MessageReceived(BMessage* message)
}

case kDeleteActionInvoked:
case kCancelActionInvoked:
{
fShowingPopUpMenu = false;
BView* view = Window()->FindView("DayView");
BMessenger msgr(view);
BMessage msg(kDeleteEventMessage);
if (message->what == kCancelActionInvoked)
msg.what = kCancelEventMessage;
msgr.SendMessage(&msg);
break;
}
@@ -213,6 +216,9 @@ EventListView::_ShowPopUpMenu(BPoint screen)
item = new BMenuItem(B_TRANSLATE("Delete"),
new BMessage(kDeleteActionInvoked), 'D');
menu->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Cancel"),
new BMessage(kCancelActionInvoked));
menu->AddItem(item);

if (!fPopUpMenuEnabled) {
menu->SetEnabled(false);
1 change: 1 addition & 0 deletions src/EventListView.h
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ class EventListView : public BListView {
private:
static const int32 kEditActionInvoked = 1000;
static const int32 kDeleteActionInvoked = 1001;
static const int32 kCancelActionInvoked = 1002;

void _ShowPopUpMenu(BPoint screen);

4 changes: 2 additions & 2 deletions src/EventWindow.cpp
Original file line number Diff line number Diff line change
@@ -351,15 +351,15 @@ void
EventWindow::OnDeleteClick()
{
BAlert* alert = new BAlert(B_TRANSLATE("Confirm delete"),
B_TRANSLATE("Are you sure you want to delete this event?"),
B_TRANSLATE("Are you sure you want to move this event to Trash?"),
NULL, B_TRANSLATE("OK"), B_TRANSLATE("Cancel"), B_WIDTH_AS_USUAL, B_WARNING_ALERT);

alert->SetShortcut(1, B_ESCAPE);
int32 button_index = alert->Go();

if (button_index == 0) {
Event newEvent(*fEvent);
newEvent.SetStatus(false);
newEvent.SetStatus(newEvent.GetStatus() | EVENT_DELETED);
newEvent.SetUpdated(time(NULL));
fDBManager->UpdateEvent(fEvent, &newEvent);
CloseWindow();
8 changes: 8 additions & 0 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -97,6 +97,13 @@ MainWindow::MessageReceived(BMessage* message)
break;
}

case kMenuEventCancel:
{
BMessage msg(kCancelEventMessage);
fDayView->MessageReceived(&msg);
break;
}

case kWeekView:
case kDayView:
{
@@ -276,6 +283,7 @@ MainWindow::_InitInterface()
fEventMenu->AddItem(new BMenuItem(B_TRANSLATE("Add event"), new BMessage(kAddEvent)));
fEventMenu->AddItem(new BMenuItem(B_TRANSLATE("Edit event"), new BMessage(kMenuEventEdit)));
fEventMenu->AddItem(new BMenuItem(B_TRANSLATE("Remove event"), new BMessage(kMenuEventDelete)));
fEventMenu->AddItem(new BMenuItem(B_TRANSLATE("Cancel event"), new BMessage(kMenuEventCancel)));

fCategoryMenu = new BMenu(B_TRANSLATE("Category"));
fCategoryMenu->AddItem(new BMenuItem(B_TRANSLATE("Manage categories" B_UTF8_ELLIPSIS),
9 changes: 5 additions & 4 deletions src/MainWindow.h
Original file line number Diff line number Diff line change
@@ -51,10 +51,11 @@ class MainWindow: public BWindow {
static const int kMenuAppQuit = 1000;
static const int kMenuEventEdit = 1002;
static const int kMenuEventDelete = 1003;
static const int kAddEvent = 1004;
static const int kDayView = 1005;
static const int kWeekView = 1006;
static const int kAgendaView = 1007;
static const int kMenuEventCancel = 1004;
static const int kAddEvent = 1005;
static const int kDayView = 1006;
static const int kWeekView = 1007;
static const int kAgendaView = 1008;


MainView* fMainView;
4 changes: 3 additions & 1 deletion src/NotificationLoop.cpp
Original file line number Diff line number Diff line change
@@ -37,7 +37,9 @@ NotificationLoop(void* data)
event = ((Event*)events->ItemAt(i));
startTime = "";
notificationContent = B_TRANSLATE("%event% is starting at %time%.");
if (!event->IsNotified()) {
if (!(event->GetStatus() & EVENT_NOTIFIED)
&& !(event->GetStatus() & EVENT_CANCELLED))
{
BTimeFormat().Format(startTime, event->GetStartDateTime(),
B_SHORT_TIME_FORMAT);
notificationContent.ReplaceAll("%event%", event->GetName());
Loading