ladybird/Applications/ChanViewer/ThreadCatalogModel.h
Andreas Kling d6abfbdc5a LibCore: Remove ObjectPtr in favor of RefPtr
Now that CObject is fully ref-counted, just use RefPtr everywhere! :^)
2019-09-22 00:31:54 +02:00

41 lines
1.2 KiB
C++

#pragma once
#include <AK/JsonArray.h>
#include <LibCore/CHttpJob.h>
#include <LibGUI/GModel.h>
class ThreadCatalogModel final : public GModel {
public:
enum Column {
ThreadNumber,
Subject,
Text,
ReplyCount,
ImageCount,
PostTime,
__Count,
};
static NonnullRefPtr<ThreadCatalogModel> create() { return adopt(*new ThreadCatalogModel); }
virtual ~ThreadCatalogModel() override;
virtual int row_count(const GModelIndex& = GModelIndex()) const override;
virtual int column_count(const GModelIndex& = GModelIndex()) const override { return Column::__Count; }
virtual String column_name(int) const override;
virtual ColumnMetadata column_metadata(int) const override;
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
virtual void update() override;
const String& board() const { return m_board; }
void set_board(const String&);
Function<void()> on_load_started;
Function<void(bool success)> on_load_finished;
private:
ThreadCatalogModel();
String m_board { "g" };
JsonArray m_catalog;
RefPtr<CHttpJob> m_pending_job;
};