mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
LibGUI: Add GAbstractView base class for GTableView.
This is in preparation for adding a new view class.
This commit is contained in:
parent
994cf10b3e
commit
5707d7f547
7 changed files with 100 additions and 64 deletions
|
@ -1,14 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGUI/GModel.h>
|
||||
#include <LibGUI/GScrollableWidget.h>
|
||||
#include <LibGUI/GAbstractView.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
|
||||
class GScrollBar;
|
||||
class Painter;
|
||||
|
||||
class GTableView : public GScrollableWidget {
|
||||
class GTableView : public GAbstractView {
|
||||
public:
|
||||
explicit GTableView(GWidget* parent);
|
||||
virtual ~GTableView() override;
|
||||
|
@ -16,31 +16,22 @@ public:
|
|||
int header_height() const { return m_headers_visible ? 16 : 0; }
|
||||
int item_height() const { return 16; }
|
||||
|
||||
void set_model(RetainPtr<GModel>&&);
|
||||
GModel* model() { return m_model.ptr(); }
|
||||
const GModel* model() const { return m_model.ptr(); }
|
||||
|
||||
bool headers_visible() const { return m_headers_visible; }
|
||||
void set_headers_visible(bool headers_visible) { m_headers_visible = headers_visible; }
|
||||
|
||||
bool alternating_row_colors() const { return m_alternating_row_colors; }
|
||||
void set_alternating_row_colors(bool b) { m_alternating_row_colors = b; }
|
||||
|
||||
void did_update_model();
|
||||
|
||||
int content_width() const;
|
||||
int horizontal_padding() const { return m_horizontal_padding; }
|
||||
|
||||
virtual bool accepts_focus() const override { return true; }
|
||||
|
||||
void scroll_into_view(const GModelIndex&, Orientation);
|
||||
|
||||
bool is_column_hidden(int) const;
|
||||
void set_column_hidden(int, bool);
|
||||
|
||||
private:
|
||||
virtual void model_notification(const GModelNotification&);
|
||||
|
||||
virtual void did_update_model() override;
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
virtual void keydown_event(GKeyEvent&) override;
|
||||
|
@ -53,7 +44,6 @@ private:
|
|||
void update_content_size();
|
||||
|
||||
Vector<bool> m_column_visibility;
|
||||
RetainPtr<GModel> m_model;
|
||||
int m_horizontal_padding { 5 };
|
||||
bool m_headers_visible { true };
|
||||
bool m_alternating_row_colors { true };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue