mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:47:35 +00:00
LibGUI: Rename GTableModel => GModel.
This commit is contained in:
parent
9d4b4c2689
commit
994cf10b3e
23 changed files with 105 additions and 105 deletions
|
@ -1,4 +1,4 @@
|
|||
#include "DirectoryTableModel.h"
|
||||
#include "DirectoryModel.h"
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
@ -7,7 +7,7 @@
|
|||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
||||
DirectoryTableModel::DirectoryTableModel()
|
||||
DirectoryModel::DirectoryModel()
|
||||
{
|
||||
m_directory_icon = GraphicsBitmap::load_from_file("/res/icons/folder16.png");
|
||||
m_file_icon = GraphicsBitmap::load_from_file("/res/icons/file16.png");
|
||||
|
@ -27,21 +27,21 @@ DirectoryTableModel::DirectoryTableModel()
|
|||
endgrent();
|
||||
}
|
||||
|
||||
DirectoryTableModel::~DirectoryTableModel()
|
||||
DirectoryModel::~DirectoryModel()
|
||||
{
|
||||
}
|
||||
|
||||
int DirectoryTableModel::row_count() const
|
||||
int DirectoryModel::row_count() const
|
||||
{
|
||||
return m_directories.size() + m_files.size();
|
||||
}
|
||||
|
||||
int DirectoryTableModel::column_count() const
|
||||
int DirectoryModel::column_count() const
|
||||
{
|
||||
return Column::__Count;
|
||||
}
|
||||
|
||||
String DirectoryTableModel::column_name(int column) const
|
||||
String DirectoryModel::column_name(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Icon: return "";
|
||||
|
@ -55,7 +55,7 @@ String DirectoryTableModel::column_name(int column) const
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
GTableModel::ColumnMetadata DirectoryTableModel::column_metadata(int column) const
|
||||
GModel::ColumnMetadata DirectoryModel::column_metadata(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Icon: return { 16, TextAlignment::Center };
|
||||
|
@ -69,7 +69,7 @@ GTableModel::ColumnMetadata DirectoryTableModel::column_metadata(int column) con
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
const GraphicsBitmap& DirectoryTableModel::icon_for(const Entry& entry) const
|
||||
const GraphicsBitmap& DirectoryModel::icon_for(const Entry& entry) const
|
||||
{
|
||||
if (S_ISDIR(entry.mode))
|
||||
return *m_directory_icon;
|
||||
|
@ -122,7 +122,7 @@ static String permission_string(mode_t mode)
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
String DirectoryTableModel::name_for_uid(uid_t uid) const
|
||||
String DirectoryModel::name_for_uid(uid_t uid) const
|
||||
{
|
||||
auto it = m_user_names.find(uid);
|
||||
if (it == m_user_names.end())
|
||||
|
@ -130,7 +130,7 @@ String DirectoryTableModel::name_for_uid(uid_t uid) const
|
|||
return (*it).value;
|
||||
}
|
||||
|
||||
String DirectoryTableModel::name_for_gid(uid_t gid) const
|
||||
String DirectoryModel::name_for_gid(uid_t gid) const
|
||||
{
|
||||
auto it = m_user_names.find(gid);
|
||||
if (it == m_user_names.end())
|
||||
|
@ -138,7 +138,7 @@ String DirectoryTableModel::name_for_gid(uid_t gid) const
|
|||
return (*it).value;
|
||||
}
|
||||
|
||||
GVariant DirectoryTableModel::data(const GModelIndex& index, Role role) const
|
||||
GVariant DirectoryModel::data(const GModelIndex& index, Role role) const
|
||||
{
|
||||
ASSERT(is_valid(index));
|
||||
auto& entry = this->entry(index.row());
|
||||
|
@ -168,7 +168,7 @@ GVariant DirectoryTableModel::data(const GModelIndex& index, Role role) const
|
|||
return { };
|
||||
}
|
||||
|
||||
void DirectoryTableModel::update()
|
||||
void DirectoryModel::update()
|
||||
{
|
||||
DIR* dirp = opendir(m_path.characters());
|
||||
if (!dirp) {
|
||||
|
@ -204,7 +204,7 @@ void DirectoryTableModel::update()
|
|||
did_update();
|
||||
}
|
||||
|
||||
void DirectoryTableModel::open(const String& a_path)
|
||||
void DirectoryModel::open(const String& a_path)
|
||||
{
|
||||
FileSystemPath canonical_path(a_path);
|
||||
auto path = canonical_path.string();
|
||||
|
@ -219,7 +219,7 @@ void DirectoryTableModel::open(const String& a_path)
|
|||
set_selected_index({ 0, 0 });
|
||||
}
|
||||
|
||||
void DirectoryTableModel::activate(const GModelIndex& index)
|
||||
void DirectoryModel::activate(const GModelIndex& index)
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return;
|
|
@ -1,13 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGUI/GTableModel.h>
|
||||
#include <LibGUI/GModel.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
class DirectoryTableModel final : public GTableModel {
|
||||
class DirectoryModel final : public GModel {
|
||||
public:
|
||||
static Retained<DirectoryTableModel> create() { return adopt(*new DirectoryTableModel); }
|
||||
virtual ~DirectoryTableModel() override;
|
||||
static Retained<DirectoryModel> create() { return adopt(*new DirectoryModel); }
|
||||
virtual ~DirectoryModel() override;
|
||||
|
||||
enum Column {
|
||||
Icon = 0,
|
||||
|
@ -33,7 +33,7 @@ public:
|
|||
size_t bytes_in_files() const { return m_bytes_in_files; }
|
||||
|
||||
private:
|
||||
DirectoryTableModel();
|
||||
DirectoryModel();
|
||||
|
||||
String name_for_uid(uid_t) const;
|
||||
String name_for_gid(gid_t) const;
|
|
@ -1,12 +1,12 @@
|
|||
#include "DirectoryTableView.h"
|
||||
#include <LibGUI/GSortingProxyTableModel.h>
|
||||
#include <LibGUI/GSortingProxyModel.h>
|
||||
|
||||
DirectoryTableView::DirectoryTableView(GWidget* parent)
|
||||
: GTableView(parent)
|
||||
, m_model(DirectoryTableModel::create())
|
||||
, m_model(DirectoryModel::create())
|
||||
{
|
||||
set_model(GSortingProxyTableModel::create(m_model.copy_ref()));
|
||||
GTableView::model()->set_key_column_and_sort_order(DirectoryTableModel::Column::Name, GSortOrder::Ascending);
|
||||
set_model(GSortingProxyModel::create(m_model.copy_ref()));
|
||||
GTableView::model()->set_key_column_and_sort_order(DirectoryModel::Column::Name, GSortOrder::Ascending);
|
||||
}
|
||||
|
||||
DirectoryTableView::~DirectoryTableView()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <LibGUI/GTableView.h>
|
||||
#include <sys/stat.h>
|
||||
#include "DirectoryTableModel.h"
|
||||
#include "DirectoryModel.h"
|
||||
|
||||
class DirectoryTableView final : public GTableView {
|
||||
public:
|
||||
|
@ -21,10 +21,10 @@ public:
|
|||
private:
|
||||
virtual void model_notification(const GModelNotification&) override;
|
||||
|
||||
DirectoryTableModel& model() { return *m_model; }
|
||||
const DirectoryTableModel& model() const { return *m_model; }
|
||||
DirectoryModel& model() { return *m_model; }
|
||||
const DirectoryModel& model() const { return *m_model; }
|
||||
|
||||
void set_status_message(const String&);
|
||||
|
||||
Retained<DirectoryTableModel> m_model;
|
||||
Retained<DirectoryModel> m_model;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
OBJS = \
|
||||
DirectoryTableModel.o \
|
||||
DirectoryModel.o \
|
||||
DirectoryTableView.o \
|
||||
main.o
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue