15bf2b6ebSBrian Hill/*
25bf2b6ebSBrian Hill * Copyright 2017 Haiku Inc. All rights reserved.
35bf2b6ebSBrian Hill * Distributed under the terms of the MIT License.
45bf2b6ebSBrian Hill *
55bf2b6ebSBrian Hill * Authors:
65bf2b6ebSBrian Hill *		Brian Hill
75bf2b6ebSBrian Hill */
85bf2b6ebSBrian Hill
95bf2b6ebSBrian Hill
105bf2b6ebSBrian Hill#include "RepoRow.h"
115bf2b6ebSBrian Hill
12bc622f6bSHumdinger#include <Catalog.h>
135bf2b6ebSBrian Hill#include <ColumnTypes.h>
145bf2b6ebSBrian Hill
155bf2b6ebSBrian Hill#include "constants.h"
165bf2b6ebSBrian Hill
175bf2b6ebSBrian Hill
18bc622f6bSHumdinger#undef B_TRANSLATION_CONTEXT
19bc622f6bSHumdinger#define B_TRANSLATION_CONTEXT "RepoRow"
20bc622f6bSHumdinger
21bc622f6bSHumdinger
225bf2b6ebSBrian HillRepoRow::RepoRow(const char* repo_name, const char* repo_url, bool enabled)
235bf2b6ebSBrian Hill	:
245bf2b6ebSBrian Hill	BRow(),
255bf2b6ebSBrian Hill	fName(repo_name),
265bf2b6ebSBrian Hill	fUrl(repo_url),
275bf2b6ebSBrian Hill	fEnabled(enabled),
285bf2b6ebSBrian Hill	fTaskState(STATE_NOT_IN_QUEUE)
295bf2b6ebSBrian Hill{
305bf2b6ebSBrian Hill	SetField(new BStringField(""), kEnabledColumn);
315bf2b6ebSBrian Hill	SetField(new BStringField(fName.String()), kNameColumn);
325bf2b6ebSBrian Hill	SetField(new BStringField(fUrl.String()), kUrlColumn);
335bf2b6ebSBrian Hill	if (enabled)
345bf2b6ebSBrian Hill		SetEnabled(enabled);
355bf2b6ebSBrian Hill}
365bf2b6ebSBrian Hill
375bf2b6ebSBrian Hill
385bf2b6ebSBrian Hillvoid
395bf2b6ebSBrian HillRepoRow::SetName(const char* name)
405bf2b6ebSBrian Hill{
415bf2b6ebSBrian Hill	BStringField* field = (BStringField*)GetField(kNameColumn);
425bf2b6ebSBrian Hill	field->SetString(name);
435bf2b6ebSBrian Hill	fName.SetTo(name);
445bf2b6ebSBrian Hill	Invalidate();
455bf2b6ebSBrian Hill}
465bf2b6ebSBrian Hill
475bf2b6ebSBrian Hill
485bf2b6ebSBrian Hillvoid
495bf2b6ebSBrian HillRepoRow::SetEnabled(bool enabled)
505bf2b6ebSBrian Hill{
515bf2b6ebSBrian Hill	fEnabled = enabled;
525bf2b6ebSBrian Hill	RefreshEnabledField();
535bf2b6ebSBrian Hill}
545bf2b6ebSBrian Hill
555bf2b6ebSBrian Hill
565bf2b6ebSBrian Hillvoid
575bf2b6ebSBrian HillRepoRow::RefreshEnabledField()
585bf2b6ebSBrian Hill{
595bf2b6ebSBrian Hill	BStringField* field = (BStringField*)GetField(kEnabledColumn);
605bf2b6ebSBrian Hill	if (fTaskState == STATE_NOT_IN_QUEUE)
61bc622f6bSHumdinger		field->SetString(fEnabled ? B_TRANSLATE_COMMENT("Enabled",
62bc622f6bSHumdinger			"Tag in the Status column") : "");
635bf2b6ebSBrian Hill	else
645bf2b6ebSBrian Hill		field->SetString(B_UTF8_ELLIPSIS);
655bf2b6ebSBrian Hill	Invalidate();
665bf2b6ebSBrian Hill}
675bf2b6ebSBrian Hill
685bf2b6ebSBrian Hill
695bf2b6ebSBrian Hillvoid
705bf2b6ebSBrian HillRepoRow::SetTaskState(uint32 state)
715bf2b6ebSBrian Hill{
725bf2b6ebSBrian Hill	fTaskState = state;
735bf2b6ebSBrian Hill	RefreshEnabledField();
745bf2b6ebSBrian Hill}
75