From a0f117d6a07475e5b53dccb7dd93ff52555dcfec Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Tue, 25 Dec 2012 12:03:18 +0000 Subject: [PATCH] LTM Sidebar add season It wasn't possible to add a season until a user defined season was available!! This fixes that. We need to make the sidebar Splitter have titled handles with actions like this on it (ala QtCreator). There is a feature request open for this. --- src/LTMSidebar.cpp | 58 +++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/src/LTMSidebar.cpp b/src/LTMSidebar.cpp index 96160e160..961235213 100644 --- a/src/LTMSidebar.cpp +++ b/src/LTMSidebar.cpp @@ -246,31 +246,47 @@ LTMSidebar::dateRangePopup(QPoint pos) // out of bounds or not user defined int index = allDateRanges->indexOfChild(item); if (index == -1 || index >= seasons->seasons.count() - || seasons->seasons[index].getType() == Season::temporary) - return; + || seasons->seasons[index].getType() == Season::temporary) { + // on system date we just offer to add a Season, since its + // the only way of doing it when no seasons are defined!! + activeDateRange = NULL; - // save context - activeDateRange = item; + // create context menu + QMenu menu(dateRangeTree); + QAction *add = new QAction(tr("Add season"), dateRangeTree); + menu.addAction(add); - // create context menu - QMenu menu(dateRangeTree); - QAction *add = new QAction(tr("Add season"), dateRangeTree); - QAction *edit = new QAction(tr("Edit season"), dateRangeTree); - QAction *del = new QAction(tr("Delete season"), dateRangeTree); - QAction *event = new QAction(tr("Add Event"), dateRangeTree); - menu.addAction(add); - menu.addAction(edit); - menu.addAction(del); - menu.addAction(event); + // connect menu to functions + connect(add, SIGNAL(triggered(void)), this, SLOT(addRange(void))); - // connect menu to functions - connect(add, SIGNAL(triggered(void)), this, SLOT(addRange(void))); - connect(edit, SIGNAL(triggered(void)), this, SLOT(editRange(void))); - connect(del, SIGNAL(triggered(void)), this, SLOT(deleteRange(void))); - connect(event, SIGNAL(triggered(void)), this, SLOT(addEvent(void))); + // execute the menu + menu.exec(dateRangeTree->mapToGlobal(pos)); - // execute the menu - menu.exec(dateRangeTree->mapToGlobal(pos)); + } else { + + // save context + activeDateRange = item; + + // create context menu + QMenu menu(dateRangeTree); + QAction *add = new QAction(tr("Add season"), dateRangeTree); + QAction *edit = new QAction(tr("Edit season"), dateRangeTree); + QAction *del = new QAction(tr("Delete season"), dateRangeTree); + QAction *event = new QAction(tr("Add Event"), dateRangeTree); + menu.addAction(add); + menu.addAction(edit); + menu.addAction(del); + menu.addAction(event); + + // connect menu to functions + connect(add, SIGNAL(triggered(void)), this, SLOT(addRange(void))); + connect(edit, SIGNAL(triggered(void)), this, SLOT(editRange(void))); + connect(del, SIGNAL(triggered(void)), this, SLOT(deleteRange(void))); + connect(event, SIGNAL(triggered(void)), this, SLOT(addEvent(void))); + + // execute the menu + menu.exec(dateRangeTree->mapToGlobal(pos)); + } } }