TimeEntryEditorWidget::TimeEntryEditorWidget(QWidget *parent) : QWidget(parent),
ui(new Ui::TimeEntryEditorWidget),
guid(""),
timeEntryAutocompleteNeedsUpdate(false),
projectAutocompleteNeedsUpdate(false),
workspaceSelectNeedsUpdate(false),
clientSelectNeedsUpdate(false),
timer(new QTimer(this)),
duration(0),
previousTagList("") {
    ui->setupUi(this);

    ui->description->completer()->setCaseSensitivity(Qt::CaseInsensitive);
    ui->description->completer()->setCompletionMode(
        QCompleter::PopupCompletion);
    ui->description->completer()->setMaxVisibleItems(20);

    ui->project->completer()->setCaseSensitivity(Qt::CaseInsensitive);
    ui->project->completer()->setCompletionMode(QCompleter::PopupCompletion);
    ui->project->completer()->setMaxVisibleItems(20);

    ui->description->installEventFilter(this);
    ui->project->installEventFilter(this);

    toggleNewClientMode(false);

    setVisible(false);

    ui->addNewProject->setText(
        "<a href=\"#add_new_project\">Add new project</a>");

    connect(TogglApi::instance, SIGNAL(displayLogin(bool,uint64_t)),  // NOLINT
            this, SLOT(displayLogin(bool,uint64_t)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayTimeEntryList(bool,QVector<TimeEntryView*>)),  // NOLINT
            this, SLOT(displayTimeEntryList(bool,QVector<TimeEntryView*>)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayTimeEntryEditor(bool,TimeEntryView*,QString)),  // NOLINT
            this, SLOT(displayTimeEntryEditor(bool,TimeEntryView*,QString)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayTags(QVector<GenericView*>)),  // NOLINT
            this, SLOT(displayTags(QVector<GenericView*>)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayWorkspaceSelect(QVector<GenericView*>)),  // NOLINT
            this, SLOT(displayWorkspaceSelect(QVector<GenericView*>)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayProjectAutocomplete(QVector<AutocompleteView*>)),  // NOLINT
            this, SLOT(displayProjectAutocomplete(QVector<AutocompleteView*>)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayTimeEntryAutocomplete(QVector<AutocompleteView*>)),  // NOLINT
            this, SLOT(displayTimeEntryAutocomplete(QVector<AutocompleteView*>)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayClientSelect(QVector<GenericView*>)),  // NOLINT
            this, SLOT(displayClientSelect(QVector<GenericView*>)));  // NOLINT

    connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
}
示例#2
0
TimerWidget::TimerWidget(QWidget *parent) : QWidget(parent),
ui(new Ui::TimerWidget),
timer(new QTimer(this)),
duration(0),
timeEntryAutocompleteNeedsUpdate(false) {
    ui->setupUi(this);

    connect(TogglApi::instance, SIGNAL(displayStoppedTimerState()),
            this, SLOT(displayStoppedTimerState()));

    connect(TogglApi::instance, SIGNAL(displayRunningTimerState(TimeEntryView*)),  // NOLINT
            this, SLOT(displayRunningTimerState(TimeEntryView*)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayTimeEntryAutocomplete(QVector<AutocompleteView*>)),  // NOLINT
            this, SLOT(displayTimeEntryAutocomplete(QVector<AutocompleteView*>)));  // NOLINT

    connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)),
            this, SLOT(focusChanged(QWidget*, QWidget*)));

    connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));

    descriptionPlaceholder = "What are you doing?";
}
示例#3
0
void TimerWidget::focusChanged(QWidget *old, QWidget *now) {
    if (old == ui->description) {
        if (ui->description->currentText().length() == 0) {
            ui->description->setEditText(descriptionPlaceholder);
        }
        if (timeEntryAutocompleteNeedsUpdate) {
            displayTimeEntryAutocomplete(timeEntryAutocompleteUpdate);
        }
    }
    if (now == ui->description &&
            ui->description->currentText() == descriptionPlaceholder) {
        ui->description->setEditText("");
    }
}