Changeset 5b7fa79


Ignore:
Timestamp:
07/28/21 23:41:39 (11 months ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master
Children:
e4dcafe
Parents:
280f29b
git-author:
Philipp Spitzer <philipp@…> (07/28/21 23:41:14)
git-committer:
Philipp Spitzer <philipp@…> (07/28/21 23:41:39)
Message:

Adjust shown event time when displayTimeShift is set.

Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/gui/daynavigatorwidget.cpp

    r280f29b r5b7fa79  
    2222#include <QPainter>
    2323#include <QLabel>
     24#include <conference.h>
     25#include <application.h>
    2426
    2527
     
    108110void DayNavigatorWidget::paintEvent(QPaintEvent *aEvent) {
    109111    Q_UNUSED(aEvent);
    110 
    111     QString selectedDateStr = mCurDate.isValid() ? mCurDate.toString("dddd\nyyyy-MM-dd") : tr("No date");
     112    QString selectedDateStr;
     113    if (mCurDate.isValid()) {
     114        selectedDateStr = mCurDate.toString("dddd\nyyyy-MM-dd");
     115        bool hasConference = ((Application*) qApp)->hasActiveConference();
     116        if (hasConference) {
     117            Conference& conference = ((Application*) qApp)->activeConference();
     118            if (conference.hasDisplayTimeShift() && conference.displayTimeShift() != 0) {
     119                QTime shift(0, 0);
     120                bool minus = conference.displayTimeShift() < 0;
     121                shift = shift.addSecs(conference.displayTimeShift() * 60 * (minus ? -1 : 1));
     122                selectedDateStr += " (" + (minus ? QString("-") : "+") + shift.toString("HH:mm") + ")";
     123            }
     124        }
     125    } else {
     126        selectedDateStr = tr("No date");
     127    }
    112128    QPainter painter(this);
    113129    painter.save();
  • src/gui/mainwindow.cpp

    r280f29b r5b7fa79  
    3838#include <QDialog>
    3939#include <QMessageBox>
     40#include <application.h>
    4041
    4142#include "ui_about.h"
     
    239240void MainWindow::onAlarmTimerTimeout() {
    240241    // determine if an alarm is set on an event that's starting soon
    241     QList<Event> events = Event::getImminentAlarmEvents(AppSettings::preEventAlarmSec(), Conference::activeConference());
     242    int conferenceId = Conference::activeConference();
     243    QList<Event> events = Event::getImminentAlarmEvents(AppSettings::preEventAlarmSec(), conferenceId);
    242244    if (events.empty()) return;
    243245
    244246    // build a message string
     247    const Conference conference = Conference::getById(conferenceId);
    245248    Event event;
    246249    QString title;
     
    248251    if (events.size() == 1) {
    249252        event = events.first();
    250         title = tr("Next event at %1").arg(event.start().toString("HH:mm"));
     253        title = tr("Next event at %1").arg(conference.shiftTime(event.start().time()).toString("HH:mm"));
    251254        message = tr("\"%1\"\n(%2)").arg(event.title()).arg(event.room()->name());
    252255    } else {
     
    254257        QStringList messages;
    255258        foreach (event, events) {
    256             messages += tr("%1: \"%2\" (%3)").arg(event.start().toString("HH:mm")).arg(event.title()).arg(event.room()->name());
     259            messages += tr("%1: \"%2\" (%3)").arg(conference.shiftTime(event.start().time()).toString("HH:mm")).arg(event.title()).arg(event.room()->name());
    257260        }
    258261        message = messages.join("\n");
     
    323326    {
    324327        Conference active = Conference::getById(confId);
     328        ((Application*) qApp)->setActiveConference(active);
    325329        QDate startDate = active.start();
    326330        QDate endDate = active.end();
     
    346350    dayNavigator->unsetDates();
    347351    setWindowTitle(saved_title);
     352    ((Application*) qApp)->unsetActiveConference();
    348353}
    349354
  • src/mvc/conference.cpp

    r280f29b r5b7fa79  
    6161
    6262
     63QTime Conference::shiftTime(const QTime& value) const {
     64    return value.addSecs(displayTimeShift() * 60);
     65}
  • src/mvc/conference.h

    r280f29b r5b7fa79  
    5656    bool hasDisplayTimeShift() const {return !value("display_time_shift").isNull();}
    5757    int displayTimeShift() const {return value("display_time_shift").toInt();}
     58    void setDisplayTimeShift(int newValue) {setValue("display_time_shift", newValue); update("display_time_shift");}
     59
    5860    bool isActive() const { return value("active").toBool(); }
    5961    QString url() const { return stringFromNullable(value("url")); }
     
    6466        update("url");
    6567    }
     68
     69    /// Returns a QTime that is shifted by displayTimeShift minutes
     70    QTime shiftTime(const QTime& value) const;
    6671
    6772private:
  • src/mvc/conferencemodel.cpp

    r280f29b r5b7fa79  
    4040        return QVariant();
    4141    }
    42 
    4342    return conferences[index.row()].title();
    44 
    45     try {
    46         const Conference& c = conferenceFromIndex(index);
    47         return c.title();
    48     } catch (OrmNoObjectException&) {
    49         return QVariant();
    50     }
    51 
    5243}
    5344
    5445const Conference& ConferenceModel::conferenceFromIndex(const QModelIndex& index) const
     46{
     47    if (index.parent().isValid()
     48        or index.column() != 0
     49        or index.row() >= conferences.size())
     50    {
     51        throw OrmNoObjectException();
     52    }
     53    return conferences[index.row()];
     54}
     55
     56Conference& ConferenceModel::conferenceFromIndex(const QModelIndex& index)
    5557{
    5658    if (index.parent().isValid()
  • src/mvc/conferencemodel.h

    r280f29b r5b7fa79  
    3030It also provides typed access to the conferences from ConferenceEditor.
    3131
    32 It does not actually modify anything in DB, this is performed by other classes.
     32It does not actually modify anything in DB (unless methods changing the conference instance returned by conferenceFromIndex are used),
     33this is performed by other classes.
    3334
    3435\see ConferenceEditor, MainWindow::showConferences()
     
    4445
    4546    const Conference& conferenceFromIndex(const QModelIndex&) const;
     47    Conference& conferenceFromIndex(const QModelIndex&);
    4648    QModelIndex indexFromId(int id) const;
    4749public slots:
  • src/mvc/delegate.cpp

    r280f29b r5b7fa79  
    2424#include <QDebug>
    2525#include <QPainter>
    26 
     26#include <application.h>
     27
     28#include "conference.h"
    2729#include "room.h"
    2830
     
    148150        QPointF titlePointF(option.rect.x() + SPACER,
    149151                            option.rect.y() + SPACER + mControls[FavouriteControlStrong]->image()->height());
    150         QTime start = event->start().time();
     152        Conference& conference = ((Application*) qApp)->activeConference();
     153        QTime start = conference.shiftTime(event->start().time());
    151154        painter->setFont(fontBig);
    152155        painter->drawText(titlePointF,start.toString("hh:mm") + "-" + start.addSecs(event->duration()).toString("hh:mm") + ", " + event->roomName());
  • src/mvc/eventmodel.cpp

    r280f29b r5b7fa79  
    2323#include "room.h"
    2424
     25#include <application.h>
     26
    2527const QString EventModel::COMMA_SEPARATOR = ", ";
    2628
     
    3537        endTime = qMax(mEvents.at(i).start().addSecs(mEvents.at(i).duration()), endTime);
    3638    }
    37     mTitle = QString("%1 - %2").arg(startTime.toString("HH:mm")).arg(endTime.toString("HH:mm"));
     39    Conference& conference = ((Application*) qApp)->activeConference();
     40    QTime s = conference.shiftTime(startTime.time());
     41    QTime e = conference.shiftTime(endTime.time());
     42    mTitle = QString("%1 - %2").arg(s.toString("HH:mm")).arg(e.toString("HH:mm"));
    3843}
    3944
Note: See TracChangeset for help on using the changeset viewer.