mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:37:34 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
0376c127f6
commit
086969277e
1665 changed files with 8479 additions and 8479 deletions
|
@ -34,7 +34,7 @@ Mesh::Mesh(Vector<Vertex> vertices, Vector<TexCoord> tex_coords, Vector<Vertex>
|
|||
void Mesh::draw(float uv_scale)
|
||||
{
|
||||
for (u32 i = 0; i < m_triangle_list.size(); i++) {
|
||||
const auto& triangle = m_triangle_list[i];
|
||||
auto const& triangle = m_triangle_list[i];
|
||||
|
||||
const FloatVector3 vertex_a(
|
||||
m_vertex_list.at(triangle.a).x,
|
||||
|
|
|
@ -10,17 +10,17 @@
|
|||
|
||||
namespace Assistant {
|
||||
|
||||
static constexpr const int RECURSION_LIMIT = 10;
|
||||
static constexpr const int MAX_MATCHES = 256;
|
||||
static constexpr int const RECURSION_LIMIT = 10;
|
||||
static constexpr int const MAX_MATCHES = 256;
|
||||
|
||||
// Bonuses and penalties are used to build up a final score for the match.
|
||||
static constexpr const int SEQUENTIAL_BONUS = 15; // bonus for adjacent matches (needle: 'ca', haystack: 'cat')
|
||||
static constexpr const int SEPARATOR_BONUS = 30; // bonus if match occurs after a separator ('_' or ' ')
|
||||
static constexpr const int CAMEL_BONUS = 30; // bonus if match is uppercase and prev is lower (needle: 'myF' haystack: '/path/to/myFile.txt')
|
||||
static constexpr const int FIRST_LETTER_BONUS = 20; // bonus if the first letter is matched (needle: 'c' haystack: 'cat')
|
||||
static constexpr const int LEADING_LETTER_PENALTY = -5; // penalty applied for every letter in str before the first match
|
||||
static constexpr const int MAX_LEADING_LETTER_PENALTY = -15; // maximum penalty for leading letters
|
||||
static constexpr const int UNMATCHED_LETTER_PENALTY = -1; // penalty for every letter that doesn't matter
|
||||
static constexpr int const SEQUENTIAL_BONUS = 15; // bonus for adjacent matches (needle: 'ca', haystack: 'cat')
|
||||
static constexpr int const SEPARATOR_BONUS = 30; // bonus if match occurs after a separator ('_' or ' ')
|
||||
static constexpr int const CAMEL_BONUS = 30; // bonus if match is uppercase and prev is lower (needle: 'myF' haystack: '/path/to/myFile.txt')
|
||||
static constexpr int const FIRST_LETTER_BONUS = 20; // bonus if the first letter is matched (needle: 'c' haystack: 'cat')
|
||||
static constexpr int const LEADING_LETTER_PENALTY = -5; // penalty applied for every letter in str before the first match
|
||||
static constexpr int const MAX_LEADING_LETTER_PENALTY = -15; // maximum penalty for leading letters
|
||||
static constexpr int const UNMATCHED_LETTER_PENALTY = -1; // penalty for every letter that doesn't matter
|
||||
|
||||
static int calculate_score(String const& string, u8* index_points, size_t index_points_size)
|
||||
{
|
||||
|
|
|
@ -123,7 +123,7 @@ FileProvider::FileProvider()
|
|||
build_filesystem_cache();
|
||||
}
|
||||
|
||||
void FileProvider::query(const String& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
|
||||
void FileProvider::query(String const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
|
||||
{
|
||||
build_filesystem_cache();
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ class Provider : public RefCounted<Provider> {
|
|||
public:
|
||||
virtual ~Provider() = default;
|
||||
|
||||
virtual void query(const String&, Function<void(NonnullRefPtrVector<Result>)> on_complete) = 0;
|
||||
virtual void query(String const&, Function<void(NonnullRefPtrVector<Result>)> on_complete) = 0;
|
||||
};
|
||||
|
||||
class AppProvider final : public Provider {
|
||||
|
|
|
@ -100,7 +100,7 @@ BookmarksBarWidget& BookmarksBarWidget::the()
|
|||
return *s_the;
|
||||
}
|
||||
|
||||
BookmarksBarWidget::BookmarksBarWidget(const String& bookmarks_file, bool enabled)
|
||||
BookmarksBarWidget::BookmarksBarWidget(String const& bookmarks_file, bool enabled)
|
||||
{
|
||||
s_the = this;
|
||||
set_layout<GUI::HorizontalBoxLayout>();
|
||||
|
@ -255,7 +255,7 @@ void BookmarksBarWidget::update_content_size()
|
|||
}
|
||||
}
|
||||
|
||||
bool BookmarksBarWidget::contains_bookmark(const String& url)
|
||||
bool BookmarksBarWidget::contains_bookmark(String const& url)
|
||||
{
|
||||
for (int item_index = 0; item_index < model()->row_count(); ++item_index) {
|
||||
|
||||
|
@ -268,7 +268,7 @@ bool BookmarksBarWidget::contains_bookmark(const String& url)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BookmarksBarWidget::remove_bookmark(const String& url)
|
||||
bool BookmarksBarWidget::remove_bookmark(String const& url)
|
||||
{
|
||||
for (int item_index = 0; item_index < model()->row_count(); ++item_index) {
|
||||
|
||||
|
@ -277,7 +277,7 @@ bool BookmarksBarWidget::remove_bookmark(const String& url)
|
|||
if (item_url == url) {
|
||||
auto& json_model = *static_cast<GUI::JsonArrayModel*>(model());
|
||||
|
||||
const auto item_removed = json_model.remove(item_index);
|
||||
auto const item_removed = json_model.remove(item_index);
|
||||
if (item_removed)
|
||||
json_model.store();
|
||||
|
||||
|
@ -288,7 +288,7 @@ bool BookmarksBarWidget::remove_bookmark(const String& url)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BookmarksBarWidget::add_bookmark(const String& url, const String& title)
|
||||
bool BookmarksBarWidget::add_bookmark(String const& url, String const& title)
|
||||
{
|
||||
Vector<JsonValue> values;
|
||||
values.append(title);
|
||||
|
@ -302,7 +302,7 @@ bool BookmarksBarWidget::add_bookmark(const String& url, const String& title)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BookmarksBarWidget::edit_bookmark(const String& url)
|
||||
bool BookmarksBarWidget::edit_bookmark(String const& url)
|
||||
{
|
||||
for (int item_index = 0; item_index < model()->row_count(); ++item_index) {
|
||||
auto item_title = model()->index(item_index, 0).data().to_string();
|
||||
|
|
|
@ -26,16 +26,16 @@ public:
|
|||
GUI::Model* model() { return m_model.ptr(); }
|
||||
const GUI::Model* model() const { return m_model.ptr(); }
|
||||
|
||||
Function<void(const String& url, unsigned modifiers)> on_bookmark_click;
|
||||
Function<void(const String&, const String&)> on_bookmark_hover;
|
||||
Function<void(String const& url, unsigned modifiers)> on_bookmark_click;
|
||||
Function<void(String const&, String const&)> on_bookmark_hover;
|
||||
|
||||
bool contains_bookmark(const String& url);
|
||||
bool remove_bookmark(const String& url);
|
||||
bool add_bookmark(const String& url, const String& title);
|
||||
bool edit_bookmark(const String& url);
|
||||
bool contains_bookmark(String const& url);
|
||||
bool remove_bookmark(String const& url);
|
||||
bool add_bookmark(String const& url, String const& title);
|
||||
bool edit_bookmark(String const& url);
|
||||
|
||||
private:
|
||||
BookmarksBarWidget(const String&, bool enabled);
|
||||
BookmarksBarWidget(String const&, bool enabled);
|
||||
|
||||
// ^GUI::ModelClient
|
||||
virtual void model_did_update(unsigned) override;
|
||||
|
|
|
@ -93,7 +93,7 @@ void ConsoleWidget::notify_about_new_console_message(i32 message_index)
|
|||
request_console_messages();
|
||||
}
|
||||
|
||||
void ConsoleWidget::handle_console_messages(i32 start_index, const Vector<String>& message_types, const Vector<String>& messages)
|
||||
void ConsoleWidget::handle_console_messages(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages)
|
||||
{
|
||||
i32 end_index = start_index + message_types.size() - 1;
|
||||
if (end_index <= m_highest_received_message_index) {
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
void print_html(StringView);
|
||||
void reset();
|
||||
|
||||
Function<void(const String&)> on_js_input;
|
||||
Function<void(String const&)> on_js_input;
|
||||
Function<void(i32)> on_request_messages;
|
||||
|
||||
private:
|
||||
|
|
|
@ -26,7 +26,7 @@ String CookieJar::get_cookie(const URL& url, Web::Cookie::Source source)
|
|||
auto cookie_list = get_matching_cookies(url, domain.value(), source);
|
||||
StringBuilder builder;
|
||||
|
||||
for (const auto& cookie : cookie_list) {
|
||||
for (auto const& cookie : cookie_list) {
|
||||
// If there is an unprocessed cookie in the cookie-list, output the characters %x3B and %x20 ("; ")
|
||||
if (!builder.is_empty())
|
||||
builder.append("; ");
|
||||
|
@ -38,7 +38,7 @@ String CookieJar::get_cookie(const URL& url, Web::Cookie::Source source)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
void CookieJar::set_cookie(const URL& url, const Web::Cookie::ParsedCookie& parsed_cookie, Web::Cookie::Source source)
|
||||
void CookieJar::set_cookie(const URL& url, Web::Cookie::ParsedCookie const& parsed_cookie, Web::Cookie::Source source)
|
||||
{
|
||||
auto domain = canonicalize_domain(url);
|
||||
if (!domain.has_value())
|
||||
|
@ -57,7 +57,7 @@ void CookieJar::dump_cookies() const
|
|||
StringBuilder builder;
|
||||
builder.appendff("{} cookies stored\n", m_cookies.size());
|
||||
|
||||
for (const auto& cookie : m_cookies) {
|
||||
for (auto const& cookie : m_cookies) {
|
||||
builder.appendff("{}{}{} - ", key_color, cookie.key.name, no_color);
|
||||
builder.appendff("{}{}{} - ", key_color, cookie.key.domain, no_color);
|
||||
builder.appendff("{}{}{}\n", key_color, cookie.key.path, no_color);
|
||||
|
@ -96,7 +96,7 @@ Optional<String> CookieJar::canonicalize_domain(const URL& url)
|
|||
return url.host().to_lowercase();
|
||||
}
|
||||
|
||||
bool CookieJar::domain_matches(const String& string, const String& domain_string)
|
||||
bool CookieJar::domain_matches(String const& string, String const& domain_string)
|
||||
{
|
||||
// https://tools.ietf.org/html/rfc6265#section-5.1.3
|
||||
|
||||
|
@ -120,7 +120,7 @@ bool CookieJar::domain_matches(const String& string, const String& domain_string
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CookieJar::path_matches(const String& request_path, const String& cookie_path)
|
||||
bool CookieJar::path_matches(String const& request_path, String const& cookie_path)
|
||||
{
|
||||
// https://tools.ietf.org/html/rfc6265#section-5.1.4
|
||||
|
||||
|
@ -165,7 +165,7 @@ String CookieJar::default_path(const URL& url)
|
|||
return uri_path.substring(0, last_separator);
|
||||
}
|
||||
|
||||
void CookieJar::store_cookie(const Web::Cookie::ParsedCookie& parsed_cookie, const URL& url, String canonicalized_domain, Web::Cookie::Source source)
|
||||
void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, const URL& url, String canonicalized_domain, Web::Cookie::Source source)
|
||||
{
|
||||
// https://tools.ietf.org/html/rfc6265#section-5.3
|
||||
|
||||
|
@ -251,7 +251,7 @@ void CookieJar::store_cookie(const Web::Cookie::ParsedCookie& parsed_cookie, con
|
|||
m_cookies.set(key, move(cookie));
|
||||
}
|
||||
|
||||
Vector<Web::Cookie::Cookie&> CookieJar::get_matching_cookies(const URL& url, const String& canonicalized_domain, Web::Cookie::Source source)
|
||||
Vector<Web::Cookie::Cookie&> CookieJar::get_matching_cookies(const URL& url, String const& canonicalized_domain, Web::Cookie::Source source)
|
||||
{
|
||||
// https://tools.ietf.org/html/rfc6265#section-5.4
|
||||
|
||||
|
@ -305,12 +305,12 @@ void CookieJar::purge_expired_cookies()
|
|||
time_t now = Core::DateTime::now().timestamp();
|
||||
Vector<CookieStorageKey> keys_to_evict;
|
||||
|
||||
for (const auto& cookie : m_cookies) {
|
||||
for (auto const& cookie : m_cookies) {
|
||||
if (cookie.value.expiry_time.timestamp() < now)
|
||||
keys_to_evict.append(cookie.key);
|
||||
}
|
||||
|
||||
for (const auto& key : keys_to_evict)
|
||||
for (auto const& key : keys_to_evict)
|
||||
m_cookies.remove(key);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace Browser {
|
||||
|
||||
struct CookieStorageKey {
|
||||
bool operator==(const CookieStorageKey&) const = default;
|
||||
bool operator==(CookieStorageKey const&) const = default;
|
||||
|
||||
String name;
|
||||
String domain;
|
||||
|
@ -27,18 +27,18 @@ struct CookieStorageKey {
|
|||
class CookieJar {
|
||||
public:
|
||||
String get_cookie(const URL& url, Web::Cookie::Source source);
|
||||
void set_cookie(const URL& url, const Web::Cookie::ParsedCookie& parsed_cookie, Web::Cookie::Source source);
|
||||
void set_cookie(const URL& url, Web::Cookie::ParsedCookie const& parsed_cookie, Web::Cookie::Source source);
|
||||
void dump_cookies() const;
|
||||
Vector<Web::Cookie::Cookie> get_all_cookies() const;
|
||||
|
||||
private:
|
||||
static Optional<String> canonicalize_domain(const URL& url);
|
||||
static bool domain_matches(const String& string, const String& domain_string);
|
||||
static bool path_matches(const String& request_path, const String& cookie_path);
|
||||
static bool domain_matches(String const& string, String const& domain_string);
|
||||
static bool path_matches(String const& request_path, String const& cookie_path);
|
||||
static String default_path(const URL& url);
|
||||
|
||||
void store_cookie(const Web::Cookie::ParsedCookie& parsed_cookie, const URL& url, String canonicalized_domain, Web::Cookie::Source source);
|
||||
Vector<Web::Cookie::Cookie&> get_matching_cookies(const URL& url, const String& canonicalized_domain, Web::Cookie::Source source);
|
||||
void store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, const URL& url, String canonicalized_domain, Web::Cookie::Source source);
|
||||
Vector<Web::Cookie::Cookie&> get_matching_cookies(const URL& url, String const& canonicalized_domain, Web::Cookie::Source source);
|
||||
void purge_expired_cookies();
|
||||
|
||||
HashMap<CookieStorageKey, Web::Cookie::Cookie> m_cookies;
|
||||
|
@ -50,7 +50,7 @@ namespace AK {
|
|||
|
||||
template<>
|
||||
struct Traits<Browser::CookieStorageKey> : public GenericTraits<Browser::CookieStorageKey> {
|
||||
static unsigned hash(const Browser::CookieStorageKey& key)
|
||||
static unsigned hash(Browser::CookieStorageKey const& key)
|
||||
{
|
||||
unsigned hash = 0;
|
||||
hash = pair_int_hash(hash, string_hash(key.name.characters(), key.name.length()));
|
||||
|
|
|
@ -58,7 +58,7 @@ GUI::Variant CookiesModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
|
|||
if (role != GUI::ModelRole::Display)
|
||||
return {};
|
||||
|
||||
const auto& cookie = m_cookies[index.row()];
|
||||
auto const& cookie = m_cookies[index.row()];
|
||||
|
||||
switch (index.column()) {
|
||||
case Column::Domain:
|
||||
|
|
|
@ -18,7 +18,7 @@ void History::dump() const
|
|||
}
|
||||
}
|
||||
|
||||
void History::push(const URL& url, const String& title)
|
||||
void History::push(const URL& url, String const& title)
|
||||
{
|
||||
if (!m_items.is_empty() && m_items[m_current].url == url)
|
||||
return;
|
||||
|
@ -55,12 +55,12 @@ void History::clear()
|
|||
m_current = -1;
|
||||
}
|
||||
|
||||
void History::update_title(const String& title)
|
||||
void History::update_title(String const& title)
|
||||
{
|
||||
m_items[m_current].title = title;
|
||||
}
|
||||
|
||||
const Vector<StringView> History::get_back_title_history()
|
||||
Vector<StringView> const History::get_back_title_history()
|
||||
{
|
||||
Vector<StringView> back_title_history;
|
||||
for (int i = m_current - 1; i >= 0; i--) {
|
||||
|
@ -69,7 +69,7 @@ const Vector<StringView> History::get_back_title_history()
|
|||
return back_title_history;
|
||||
}
|
||||
|
||||
const Vector<StringView> History::get_forward_title_history()
|
||||
Vector<StringView> const History::get_forward_title_history()
|
||||
{
|
||||
Vector<StringView> forward_title_history;
|
||||
for (int i = m_current + 1; i < static_cast<int>(m_items.size()); i++) {
|
||||
|
|
|
@ -19,12 +19,12 @@ public:
|
|||
};
|
||||
void dump() const;
|
||||
|
||||
void push(const URL& url, const String& title);
|
||||
void update_title(const String& title);
|
||||
void push(const URL& url, String const& title);
|
||||
void update_title(String const& title);
|
||||
URLTitlePair current() const;
|
||||
|
||||
const Vector<StringView> get_back_title_history();
|
||||
const Vector<StringView> get_forward_title_history();
|
||||
Vector<StringView> const get_back_title_history();
|
||||
Vector<StringView> const get_forward_title_history();
|
||||
|
||||
void go_back(int steps = 1);
|
||||
void go_forward(int steps = 1);
|
||||
|
|
|
@ -183,7 +183,7 @@ void InspectorWidget::update_node_box_model(Optional<String> node_box_sizing_jso
|
|||
return;
|
||||
}
|
||||
auto json_value = json_or_error.release_value();
|
||||
const auto& json_object = json_value.as_object();
|
||||
auto const& json_object = json_value.as_object();
|
||||
|
||||
m_node_box_sizing.margin.top = json_object.get("margin_top").to_float();
|
||||
m_node_box_sizing.margin.right = json_object.get("margin_right").to_float();
|
||||
|
|
|
@ -66,7 +66,7 @@ void Tab::start_download(const URL& url)
|
|||
window->show();
|
||||
}
|
||||
|
||||
void Tab::view_source(const URL& url, const String& source)
|
||||
void Tab::view_source(const URL& url, String const& source)
|
||||
{
|
||||
auto window = GUI::Window::construct(&this->window());
|
||||
auto& editor = window->set_main_widget<GUI::TextEditor>();
|
||||
|
@ -282,7 +282,7 @@ Tab::Tab(BrowserWindow& window)
|
|||
m_image_context_menu->add_separator();
|
||||
m_image_context_menu->add_action(window.inspect_dom_node_action());
|
||||
|
||||
hooks().on_image_context_menu_request = [this](auto& image_url, auto& screen_position, const Gfx::ShareableBitmap& shareable_bitmap) {
|
||||
hooks().on_image_context_menu_request = [this](auto& image_url, auto& screen_position, Gfx::ShareableBitmap const& shareable_bitmap) {
|
||||
m_image_context_menu_url = image_url;
|
||||
m_image_context_menu_bitmap = shareable_bitmap;
|
||||
m_image_context_menu->popup(screen_position);
|
||||
|
@ -469,7 +469,7 @@ void Tab::bookmark_current_url()
|
|||
update_bookmark_button(url);
|
||||
}
|
||||
|
||||
void Tab::update_bookmark_button(const String& url)
|
||||
void Tab::update_bookmark_button(String const& url)
|
||||
{
|
||||
if (BookmarksBarWidget::the().contains_bookmark(url)) {
|
||||
m_bookmark_button->set_icon(g_icon_bag.bookmark_filled);
|
||||
|
@ -503,7 +503,7 @@ void Tab::did_become_active()
|
|||
update_actions();
|
||||
}
|
||||
|
||||
void Tab::context_menu_requested(const Gfx::IntPoint& screen_position)
|
||||
void Tab::context_menu_requested(Gfx::IntPoint const& screen_position)
|
||||
{
|
||||
m_tab_context_menu->popup(screen_position);
|
||||
}
|
||||
|
|
|
@ -50,19 +50,19 @@ public:
|
|||
void go_forward(int steps = 1);
|
||||
|
||||
void did_become_active();
|
||||
void context_menu_requested(const Gfx::IntPoint& screen_position);
|
||||
void context_menu_requested(Gfx::IntPoint const& screen_position);
|
||||
void content_filters_changed();
|
||||
|
||||
void action_entered(GUI::Action&);
|
||||
void action_left(GUI::Action&);
|
||||
|
||||
Function<void(const String&)> on_title_change;
|
||||
Function<void(String const&)> on_title_change;
|
||||
Function<void(const URL&)> on_tab_open_request;
|
||||
Function<void(Tab&)> on_tab_close_request;
|
||||
Function<void(Tab&)> on_tab_close_other_request;
|
||||
Function<void(const Gfx::Bitmap&)> on_favicon_change;
|
||||
Function<void(Gfx::Bitmap const&)> on_favicon_change;
|
||||
Function<String(const URL&, Web::Cookie::Source source)> on_get_cookie;
|
||||
Function<void(const URL&, const Web::Cookie::ParsedCookie& cookie, Web::Cookie::Source source)> on_set_cookie;
|
||||
Function<void(const URL&, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source)> on_set_cookie;
|
||||
Function<void()> on_dump_cookies;
|
||||
Function<Vector<Web::Cookie::Cookie>()> on_want_cookies;
|
||||
|
||||
|
@ -75,8 +75,8 @@ public:
|
|||
void show_console_window();
|
||||
void show_storage_inspector();
|
||||
|
||||
const String& title() const { return m_title; }
|
||||
const Gfx::Bitmap* icon() const { return m_icon; }
|
||||
String const& title() const { return m_title; }
|
||||
Gfx::Bitmap const* icon() const { return m_icon; }
|
||||
|
||||
GUI::AbstractScrollableWidget& view();
|
||||
|
||||
|
@ -89,9 +89,9 @@ private:
|
|||
Web::WebViewHooks& hooks();
|
||||
void update_actions();
|
||||
void bookmark_current_url();
|
||||
void update_bookmark_button(const String& url);
|
||||
void update_bookmark_button(String const& url);
|
||||
void start_download(const URL& url);
|
||||
void view_source(const URL& url, const String& source);
|
||||
void view_source(const URL& url, String const& source);
|
||||
void update_status(Optional<String> text_override = {}, i32 count_waiting = 0);
|
||||
|
||||
enum class MayAppendTLD {
|
||||
|
@ -134,6 +134,6 @@ private:
|
|||
bool m_is_history_navigation { false };
|
||||
};
|
||||
|
||||
URL url_from_user_input(const String& input);
|
||||
URL url_from_user_input(String const& input);
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(Core::System::pledge("stdio recvfd sendfd unix cpath rpath wpath proc exec"));
|
||||
|
||||
const char* specified_url = nullptr;
|
||||
char const* specified_url = nullptr;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(specified_url, "URL to open", "url", Core::ArgsParser::Required::No);
|
||||
|
|
|
@ -22,7 +22,7 @@ KeypadValue::KeypadValue(i64 value)
|
|||
|
||||
KeypadValue::KeypadValue(StringView sv)
|
||||
{
|
||||
String str = sv.to_string(); //TODO: Once we have a StringView equivalent for this C API, we won't need to create a copy for this anymore.
|
||||
String str = sv.to_string(); // TODO: Once we have a StringView equivalent for this C API, we won't need to create a copy for this anymore.
|
||||
size_t first_index = 0;
|
||||
char* dot_ptr;
|
||||
i64 int_part = strtoll(&str[first_index], &dot_ptr, 10);
|
||||
|
|
|
@ -136,7 +136,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto app = TRY(GUI::Application::try_create(arguments));
|
||||
|
||||
const char* coredump_path = nullptr;
|
||||
char const* coredump_path = nullptr;
|
||||
bool unlink_on_exit = false;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
|
|
|
@ -37,7 +37,7 @@ static void handle_sigint(int)
|
|||
g_debug_session = nullptr;
|
||||
}
|
||||
|
||||
static void handle_print_registers(const PtraceRegisters& regs)
|
||||
static void handle_print_registers(PtraceRegisters const& regs)
|
||||
{
|
||||
#if ARCH(I386)
|
||||
outln("eax={:p} ebx={:p} ecx={:p} edx={:p}", regs.eax, regs.ebx, regs.ecx, regs.edx);
|
||||
|
@ -52,7 +52,7 @@ static void handle_print_registers(const PtraceRegisters& regs)
|
|||
#endif
|
||||
}
|
||||
|
||||
static bool handle_disassemble_command(const String& command, FlatPtr first_instruction)
|
||||
static bool handle_disassemble_command(String const& command, FlatPtr first_instruction)
|
||||
{
|
||||
auto parts = command.split(' ');
|
||||
size_t number_of_instructions_to_disassemble = 5;
|
||||
|
@ -90,7 +90,7 @@ static bool handle_disassemble_command(const String& command, FlatPtr first_inst
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool handle_backtrace_command(const PtraceRegisters& regs)
|
||||
static bool handle_backtrace_command(PtraceRegisters const& regs)
|
||||
{
|
||||
#if ARCH(I386)
|
||||
auto ebp_val = regs.ebp;
|
||||
|
@ -122,7 +122,7 @@ static bool insert_breakpoint_at_address(FlatPtr address)
|
|||
return g_debug_session->insert_breakpoint(address);
|
||||
}
|
||||
|
||||
static bool insert_breakpoint_at_source_position(const String& file, size_t line)
|
||||
static bool insert_breakpoint_at_source_position(String const& file, size_t line)
|
||||
{
|
||||
auto result = g_debug_session->insert_breakpoint(file, line);
|
||||
if (!result.has_value()) {
|
||||
|
@ -133,7 +133,7 @@ static bool insert_breakpoint_at_source_position(const String& file, size_t line
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool insert_breakpoint_at_symbol(const String& symbol)
|
||||
static bool insert_breakpoint_at_symbol(String const& symbol)
|
||||
{
|
||||
auto result = g_debug_session->insert_breakpoint(symbol);
|
||||
if (!result.has_value()) {
|
||||
|
@ -144,7 +144,7 @@ static bool insert_breakpoint_at_symbol(const String& symbol)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool handle_breakpoint_command(const String& command)
|
||||
static bool handle_breakpoint_command(String const& command)
|
||||
{
|
||||
auto parts = command.split(' ');
|
||||
if (parts.size() != 2)
|
||||
|
@ -171,7 +171,7 @@ static bool handle_breakpoint_command(const String& command)
|
|||
return insert_breakpoint_at_symbol(argument);
|
||||
}
|
||||
|
||||
static bool handle_examine_command(const String& command)
|
||||
static bool handle_examine_command(String const& command)
|
||||
{
|
||||
auto parts = command.split(' ');
|
||||
if (parts.size() != 2)
|
||||
|
@ -214,7 +214,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(Core::System::pledge("stdio proc ptrace exec rpath tty sigaction cpath unix", nullptr));
|
||||
|
||||
const char* command = nullptr;
|
||||
char const* command = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(command,
|
||||
"The program to be debugged, along with its arguments",
|
||||
|
|
|
@ -34,10 +34,10 @@ Optional<GUI::ModelIndex> ManualModel::index_from_path(StringView path) const
|
|||
auto parent_index = index(section, 0);
|
||||
for (int row = 0; row < row_count(parent_index); ++row) {
|
||||
auto child_index = index(row, 0, parent_index);
|
||||
auto* node = static_cast<const ManualNode*>(child_index.internal_data());
|
||||
auto* node = static_cast<ManualNode const*>(child_index.internal_data());
|
||||
if (!node->is_page())
|
||||
continue;
|
||||
auto* page = static_cast<const ManualPageNode*>(node);
|
||||
auto* page = static_cast<ManualPageNode const*>(node);
|
||||
if (page->path() != path)
|
||||
continue;
|
||||
return child_index;
|
||||
|
@ -50,10 +50,10 @@ String ManualModel::page_name(const GUI::ModelIndex& index) const
|
|||
{
|
||||
if (!index.is_valid())
|
||||
return {};
|
||||
auto* node = static_cast<const ManualNode*>(index.internal_data());
|
||||
auto* node = static_cast<ManualNode const*>(index.internal_data());
|
||||
if (!node->is_page())
|
||||
return {};
|
||||
auto* page = static_cast<const ManualPageNode*>(node);
|
||||
auto* page = static_cast<ManualPageNode const*>(node);
|
||||
return page->name();
|
||||
}
|
||||
|
||||
|
@ -61,10 +61,10 @@ String ManualModel::page_path(const GUI::ModelIndex& index) const
|
|||
{
|
||||
if (!index.is_valid())
|
||||
return {};
|
||||
auto* node = static_cast<const ManualNode*>(index.internal_data());
|
||||
auto* node = static_cast<ManualNode const*>(index.internal_data());
|
||||
if (!node->is_page())
|
||||
return {};
|
||||
auto* page = static_cast<const ManualPageNode*>(node);
|
||||
auto* page = static_cast<ManualPageNode const*>(node);
|
||||
return page->path();
|
||||
}
|
||||
|
||||
|
@ -91,11 +91,11 @@ String ManualModel::page_and_section(const GUI::ModelIndex& index) const
|
|||
{
|
||||
if (!index.is_valid())
|
||||
return {};
|
||||
auto* node = static_cast<const ManualNode*>(index.internal_data());
|
||||
auto* node = static_cast<ManualNode const*>(index.internal_data());
|
||||
if (!node->is_page())
|
||||
return {};
|
||||
auto* page = static_cast<const ManualPageNode*>(node);
|
||||
auto* section = static_cast<const ManualSectionNode*>(page->parent());
|
||||
auto* page = static_cast<ManualPageNode const*>(node);
|
||||
auto* section = static_cast<ManualSectionNode const*>(page->parent());
|
||||
return String::formatted("{}({})", page->name(), section->section_name());
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ GUI::ModelIndex ManualModel::index(int row, int column, const GUI::ModelIndex& p
|
|||
{
|
||||
if (!parent_index.is_valid())
|
||||
return create_index(row, column, &s_sections[row]);
|
||||
auto* parent = static_cast<const ManualNode*>(parent_index.internal_data());
|
||||
auto* parent = static_cast<ManualNode const*>(parent_index.internal_data());
|
||||
auto* child = &parent->children()[row];
|
||||
return create_index(row, column, child);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ GUI::ModelIndex ManualModel::parent_index(const GUI::ModelIndex& index) const
|
|||
{
|
||||
if (!index.is_valid())
|
||||
return {};
|
||||
auto* child = static_cast<const ManualNode*>(index.internal_data());
|
||||
auto* child = static_cast<ManualNode const*>(index.internal_data());
|
||||
auto* parent = child->parent();
|
||||
if (parent == nullptr)
|
||||
return {};
|
||||
|
@ -135,7 +135,7 @@ int ManualModel::row_count(const GUI::ModelIndex& index) const
|
|||
{
|
||||
if (!index.is_valid())
|
||||
return sizeof(s_sections) / sizeof(s_sections[0]);
|
||||
auto* node = static_cast<const ManualNode*>(index.internal_data());
|
||||
auto* node = static_cast<ManualNode const*>(index.internal_data());
|
||||
return node->children().size();
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ int ManualModel::column_count(const GUI::ModelIndex&) const
|
|||
|
||||
GUI::Variant ManualModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||
{
|
||||
auto* node = static_cast<const ManualNode*>(index.internal_data());
|
||||
auto* node = static_cast<ManualNode const*>(index.internal_data());
|
||||
switch (role) {
|
||||
case GUI::ModelRole::Search:
|
||||
if (!node->is_page())
|
||||
|
@ -165,7 +165,7 @@ GUI::Variant ManualModel::data(const GUI::ModelIndex& index, GUI::ModelRole role
|
|||
}
|
||||
}
|
||||
|
||||
void ManualModel::update_section_node_on_toggle(const GUI::ModelIndex& index, const bool open)
|
||||
void ManualModel::update_section_node_on_toggle(const GUI::ModelIndex& index, bool const open)
|
||||
{
|
||||
auto* node = static_cast<ManualSectionNode*>(index.internal_data());
|
||||
node->set_open(open);
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
String page_and_section(const GUI::ModelIndex&) const;
|
||||
ErrorOr<StringView> page_view(String const& path) const;
|
||||
|
||||
void update_section_node_on_toggle(const GUI::ModelIndex&, const bool);
|
||||
void update_section_node_on_toggle(const GUI::ModelIndex&, bool const);
|
||||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
virtual ~ManualNode() = default;
|
||||
|
||||
virtual NonnullOwnPtrVector<ManualNode>& children() const = 0;
|
||||
virtual const ManualNode* parent() const = 0;
|
||||
virtual ManualNode const* parent() const = 0;
|
||||
virtual String name() const = 0;
|
||||
virtual bool is_page() const { return false; }
|
||||
virtual bool is_open() const { return false; }
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "ManualPageNode.h"
|
||||
#include "ManualSectionNode.h"
|
||||
|
||||
const ManualNode* ManualPageNode::parent() const
|
||||
ManualNode const* ManualPageNode::parent() const
|
||||
{
|
||||
return &m_section;
|
||||
}
|
||||
|
|
|
@ -14,20 +14,20 @@ class ManualPageNode : public ManualNode {
|
|||
public:
|
||||
virtual ~ManualPageNode() override = default;
|
||||
|
||||
ManualPageNode(const ManualSectionNode& section, StringView page)
|
||||
ManualPageNode(ManualSectionNode const& section, StringView page)
|
||||
: m_section(section)
|
||||
, m_page(page)
|
||||
{
|
||||
}
|
||||
|
||||
virtual NonnullOwnPtrVector<ManualNode>& children() const override;
|
||||
virtual const ManualNode* parent() const override;
|
||||
virtual ManualNode const* parent() const override;
|
||||
virtual String name() const override { return m_page; };
|
||||
virtual bool is_page() const override { return true; }
|
||||
|
||||
String path() const;
|
||||
|
||||
private:
|
||||
const ManualSectionNode& m_section;
|
||||
ManualSectionNode const& m_section;
|
||||
String m_page;
|
||||
};
|
||||
|
|
|
@ -25,12 +25,12 @@ public:
|
|||
return m_children;
|
||||
}
|
||||
|
||||
virtual const ManualNode* parent() const override { return nullptr; }
|
||||
virtual ManualNode const* parent() const override { return nullptr; }
|
||||
virtual String name() const override { return m_full_name; }
|
||||
virtual bool is_open() const override { return m_open; }
|
||||
void set_open(bool open);
|
||||
|
||||
const String& section_name() const { return m_section; }
|
||||
String const& section_name() const { return m_section; }
|
||||
String path() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
explicit HexDocumentFile(NonnullRefPtr<Core::File> file);
|
||||
virtual ~HexDocumentFile() = default;
|
||||
|
||||
HexDocumentFile(const HexDocumentFile&) = delete;
|
||||
HexDocumentFile(HexDocumentFile const&) = delete;
|
||||
|
||||
void set_file(NonnullRefPtr<Core::File> file);
|
||||
NonnullRefPtr<Core::File> file() const;
|
||||
|
|
|
@ -570,11 +570,11 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
|||
if (byte_position >= m_document->size())
|
||||
return;
|
||||
|
||||
const bool edited_flag = m_document->get(byte_position).modified;
|
||||
bool const edited_flag = m_document->get(byte_position).modified;
|
||||
|
||||
const bool selection_inbetween_start_end = byte_position >= m_selection_start && byte_position < m_selection_end;
|
||||
const bool selection_inbetween_end_start = byte_position >= m_selection_end && byte_position < m_selection_start;
|
||||
const bool highlight_flag = selection_inbetween_start_end || selection_inbetween_end_start;
|
||||
bool const selection_inbetween_start_end = byte_position >= m_selection_start && byte_position < m_selection_end;
|
||||
bool const selection_inbetween_end_start = byte_position >= m_selection_end && byte_position < m_selection_start;
|
||||
bool const highlight_flag = selection_inbetween_start_end || selection_inbetween_end_start;
|
||||
|
||||
Gfx::IntRect hex_display_rect {
|
||||
frame_thickness() + offset_margin_width() + static_cast<int>(j) * cell_width() + 2 * m_padding,
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
Value
|
||||
};
|
||||
|
||||
explicit SearchResultsModel(const Vector<Match>&& matches)
|
||||
explicit SearchResultsModel(Vector<Match> const&& matches)
|
||||
: m_matches(move(matches))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ bool ViewWidget::is_previous_available() const
|
|||
return false;
|
||||
}
|
||||
|
||||
Vector<String> ViewWidget::load_files_from_directory(const String& path) const
|
||||
Vector<String> ViewWidget::load_files_from_directory(String const& path) const
|
||||
{
|
||||
Vector<String> files_in_directory;
|
||||
|
||||
|
@ -90,7 +90,7 @@ Vector<String> ViewWidget::load_files_from_directory(const String& path) const
|
|||
return files_in_directory;
|
||||
}
|
||||
|
||||
void ViewWidget::set_path(const String& path)
|
||||
void ViewWidget::set_path(String const& path)
|
||||
{
|
||||
m_path = path;
|
||||
m_files_in_same_dir = load_files_from_directory(path);
|
||||
|
@ -151,7 +151,7 @@ void ViewWidget::mouseup_event(GUI::MouseEvent& event)
|
|||
GUI::AbstractZoomPanWidget::mouseup_event(event);
|
||||
}
|
||||
|
||||
void ViewWidget::load_from_file(const String& path)
|
||||
void ViewWidget::load_from_file(String const& path)
|
||||
{
|
||||
auto show_error = [&] {
|
||||
GUI::MessageBox::show(window(), String::formatted("Failed to open {}", path), "Cannot open image", GUI::MessageBox::Type::Error);
|
||||
|
@ -186,7 +186,7 @@ void ViewWidget::load_from_file(const String& path)
|
|||
on_image_change(m_bitmap);
|
||||
|
||||
if (m_decoded_image->is_animated && m_decoded_image->frames.size() > 1) {
|
||||
const auto& first_frame = m_decoded_image->frames[0];
|
||||
auto const& first_frame = m_decoded_image->frames[0];
|
||||
m_timer->set_interval(first_frame.duration);
|
||||
m_timer->on_timeout = [this] { animate(); };
|
||||
m_timer->start();
|
||||
|
@ -229,7 +229,7 @@ void ViewWidget::resize_window()
|
|||
window()->resize(new_size);
|
||||
}
|
||||
|
||||
void ViewWidget::set_bitmap(const Gfx::Bitmap* bitmap)
|
||||
void ViewWidget::set_bitmap(Gfx::Bitmap const* bitmap)
|
||||
{
|
||||
if (m_bitmap == bitmap)
|
||||
return;
|
||||
|
@ -246,7 +246,7 @@ void ViewWidget::animate()
|
|||
|
||||
m_current_frame_index = (m_current_frame_index + 1) % m_decoded_image->frames.size();
|
||||
|
||||
const auto& current_frame = m_decoded_image->frames[m_current_frame_index];
|
||||
auto const& current_frame = m_decoded_image->frames[m_current_frame_index];
|
||||
set_bitmap(current_frame.bitmap);
|
||||
|
||||
if ((int)current_frame.duration != m_timer->interval()) {
|
||||
|
|
|
@ -29,13 +29,13 @@ public:
|
|||
|
||||
virtual ~ViewWidget() override = default;
|
||||
|
||||
const Gfx::Bitmap* bitmap() const { return m_bitmap.ptr(); }
|
||||
const String& path() const { return m_path; }
|
||||
Gfx::Bitmap const* bitmap() const { return m_bitmap.ptr(); }
|
||||
String const& path() const { return m_path; }
|
||||
void set_toolbar_height(int height) { m_toolbar_height = height; }
|
||||
int toolbar_height() { return m_toolbar_height; }
|
||||
bool scaled_for_first_image() { return m_scaled_for_first_image; }
|
||||
void set_scaled_for_first_image(bool val) { m_scaled_for_first_image = val; }
|
||||
void set_path(const String& path);
|
||||
void set_path(String const& path);
|
||||
void resize_window();
|
||||
void set_scaling_mode(Gfx::Painter::ScalingMode);
|
||||
|
||||
|
@ -46,11 +46,11 @@ public:
|
|||
void flip(Gfx::Orientation);
|
||||
void rotate(Gfx::RotationDirection);
|
||||
void navigate(Directions);
|
||||
void load_from_file(const String&);
|
||||
void load_from_file(String const&);
|
||||
|
||||
Function<void()> on_doubleclick;
|
||||
Function<void(const GUI::DropEvent&)> on_drop;
|
||||
Function<void(const Gfx::Bitmap*)> on_image_change;
|
||||
Function<void(Gfx::Bitmap const*)> on_image_change;
|
||||
|
||||
private:
|
||||
ViewWidget();
|
||||
|
@ -60,9 +60,9 @@ private:
|
|||
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||
virtual void drop_event(GUI::DropEvent&) override;
|
||||
|
||||
void set_bitmap(const Gfx::Bitmap* bitmap);
|
||||
void set_bitmap(Gfx::Bitmap const* bitmap);
|
||||
void animate();
|
||||
Vector<String> load_files_from_directory(const String& path) const;
|
||||
Vector<String> load_files_from_directory(String const& path) const;
|
||||
|
||||
String m_path;
|
||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
|
|
|
@ -45,7 +45,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto app_icon = GUI::Icon::default_icon("filetype-image");
|
||||
|
||||
const char* path = nullptr;
|
||||
char const* path = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(path, "The image file to be displayed.", "file", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
@ -244,7 +244,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
widget->set_scaling_mode(Gfx::Painter::ScalingMode::BilinearBlend);
|
||||
});
|
||||
|
||||
widget->on_image_change = [&](const Gfx::Bitmap* bitmap) {
|
||||
widget->on_image_change = [&](Gfx::Bitmap const* bitmap) {
|
||||
bool should_enable_image_actions = (bitmap != nullptr);
|
||||
bool should_enable_forward_actions = (widget->is_next_available() && should_enable_image_actions);
|
||||
bool should_enable_backward_actions = (widget->is_previous_available() && should_enable_image_actions);
|
||||
|
|
|
@ -127,7 +127,7 @@ u32* KeyboardMapperWidget::map_from_name(const StringView map_name)
|
|||
return map;
|
||||
}
|
||||
|
||||
ErrorOr<void> KeyboardMapperWidget::load_map_from_file(const String& filename)
|
||||
ErrorOr<void> KeyboardMapperWidget::load_map_from_file(String const& filename)
|
||||
{
|
||||
auto character_map = TRY(Keyboard::CharacterMapFile::load_from_file(filename));
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
virtual ~KeyboardMapperWidget() override = default;
|
||||
|
||||
void create_frame();
|
||||
ErrorOr<void> load_map_from_file(const String&);
|
||||
ErrorOr<void> load_map_from_file(String const&);
|
||||
ErrorOr<void> load_map_from_system();
|
||||
ErrorOr<void> save();
|
||||
ErrorOr<void> save_to_file(StringView);
|
||||
|
|
|
@ -268,7 +268,7 @@ void KeyboardSettingsWidget::set_keymaps(Vector<String> const& keymaps, String c
|
|||
pid_t child_pid;
|
||||
|
||||
auto keymaps_string = String::join(',', keymaps);
|
||||
const char* argv[] = { "/bin/keymap", "-s", keymaps_string.characters(), "-m", active_keymap.characters(), nullptr };
|
||||
char const* argv[] = { "/bin/keymap", "-s", keymaps_string.characters(), "-m", active_keymap.characters(), nullptr };
|
||||
if ((errno = posix_spawn(&child_pid, "/bin/keymap", nullptr, nullptr, const_cast<char**>(argv), environ))) {
|
||||
perror("posix_spawn");
|
||||
exit(1);
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
#include "OutlineModel.h"
|
||||
#include <LibGfx/FontDatabase.h>
|
||||
|
||||
NonnullRefPtr<OutlineModel> OutlineModel::create(const NonnullRefPtr<PDF::OutlineDict>& outline)
|
||||
NonnullRefPtr<OutlineModel> OutlineModel::create(NonnullRefPtr<PDF::OutlineDict> const& outline)
|
||||
{
|
||||
return adopt_ref(*new OutlineModel(outline));
|
||||
}
|
||||
|
||||
OutlineModel::OutlineModel(const NonnullRefPtr<PDF::OutlineDict>& outline)
|
||||
OutlineModel::OutlineModel(NonnullRefPtr<PDF::OutlineDict> const& outline)
|
||||
: m_outline(outline)
|
||||
{
|
||||
m_closed_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png").release_value_but_fixme_should_propagate_errors());
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
class OutlineModel final : public GUI::Model {
|
||||
public:
|
||||
static NonnullRefPtr<OutlineModel> create(const NonnullRefPtr<PDF::OutlineDict>& outline);
|
||||
static NonnullRefPtr<OutlineModel> create(NonnullRefPtr<PDF::OutlineDict> const& outline);
|
||||
|
||||
void set_index_open_state(const GUI::ModelIndex& index, bool is_open);
|
||||
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override;
|
||||
|
||||
private:
|
||||
OutlineModel(const NonnullRefPtr<PDF::OutlineDict>& outline);
|
||||
OutlineModel(NonnullRefPtr<PDF::OutlineDict> const& outline);
|
||||
|
||||
GUI::Icon m_closed_item_icon;
|
||||
GUI::Icon m_open_item_icon;
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
ALWAYS_INLINE u32 current_page() const { return m_current_page_index; }
|
||||
ALWAYS_INLINE void set_current_page(u32 current_page) { m_current_page_index = current_page; }
|
||||
|
||||
ALWAYS_INLINE const RefPtr<PDF::Document>& document() const { return m_document; }
|
||||
ALWAYS_INLINE RefPtr<PDF::Document> const& document() const { return m_document; }
|
||||
void set_document(RefPtr<PDF::Document>);
|
||||
|
||||
Function<void(u32 new_page)> on_page_change;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
const char* file_path = nullptr;
|
||||
char const* file_path = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(file_path, "PDF file to open", "path", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
|
|
@ -235,7 +235,7 @@ static inline int note_from_white_keys(int white_keys)
|
|||
return note;
|
||||
}
|
||||
|
||||
int KeysWidget::note_for_event_position(const Gfx::IntPoint& a_point) const
|
||||
int KeysWidget::note_for_event_position(Gfx::IntPoint const& a_point) const
|
||||
{
|
||||
if (!frame_inner_rect().contains(a_point))
|
||||
return -1;
|
||||
|
|
|
@ -32,7 +32,7 @@ private:
|
|||
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||
|
||||
int note_for_event_position(const Gfx::IntPoint&) const;
|
||||
int note_for_event_position(Gfx::IntPoint const&) const;
|
||||
|
||||
TrackManager& m_track_manager;
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ constexpr int beats_per_bar = 4;
|
|||
constexpr int notes_per_beat = 4;
|
||||
constexpr int roll_length = (sample_rate / (beats_per_minute / 60)) * beats_per_bar;
|
||||
|
||||
constexpr const char* note_names[] = {
|
||||
constexpr char const* note_names[] = {
|
||||
"C",
|
||||
"C#",
|
||||
"D",
|
||||
|
|
|
@ -152,7 +152,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event)
|
|||
}
|
||||
|
||||
Gfx::IntRect note_name_rect(3, y, 1, note_height);
|
||||
const char* note_name = note_names[note % notes_per_octave];
|
||||
char const* note_name = note_names[note % notes_per_octave];
|
||||
|
||||
painter.draw_text(note_name_rect, note_name, Gfx::TextAlignment::CenterLeft);
|
||||
note_name_rect.translate_by(Gfx::FontDatabase::default_font().width(note_name) + 2, 0);
|
||||
|
|
|
@ -22,8 +22,8 @@ class RollWidget final : public GUI::AbstractScrollableWidget {
|
|||
public:
|
||||
virtual ~RollWidget() override = default;
|
||||
|
||||
const KeysWidget* keys_widget() const { return m_keys_widget; }
|
||||
void set_keys_widget(const KeysWidget* widget) { m_keys_widget = widget; }
|
||||
KeysWidget const* keys_widget() const { return m_keys_widget; }
|
||||
void set_keys_widget(KeysWidget const* widget) { m_keys_widget = widget; }
|
||||
|
||||
private:
|
||||
explicit RollWidget(TrackManager&);
|
||||
|
@ -36,7 +36,7 @@ private:
|
|||
bool viewport_changed() const;
|
||||
|
||||
TrackManager& m_track_manager;
|
||||
const KeysWidget* m_keys_widget;
|
||||
KeysWidget const* m_keys_widget;
|
||||
|
||||
int m_roll_width { 0 };
|
||||
int m_num_notes { 0 };
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <LibDSP/Music.h>
|
||||
#include <math.h>
|
||||
|
||||
Track::Track(const u32& time)
|
||||
Track::Track(u32 const& time)
|
||||
: m_time(time)
|
||||
, m_temporary_transport(LibDSP::Transport::construct(120, 4))
|
||||
, m_delay(make_ref_counted<LibDSP::Effects::Delay>(m_temporary_transport))
|
||||
|
|
|
@ -26,11 +26,11 @@ class Track {
|
|||
AK_MAKE_NONMOVABLE(Track);
|
||||
|
||||
public:
|
||||
explicit Track(const u32& time);
|
||||
explicit Track(u32 const& time);
|
||||
~Track() = default;
|
||||
|
||||
const Vector<Audio::Sample>& recorded_sample() const { return m_recorded_sample; }
|
||||
const SinglyLinkedList<RollNote>& roll_notes(int note) const { return m_roll_notes[note]; }
|
||||
Vector<Audio::Sample> const& recorded_sample() const { return m_recorded_sample; }
|
||||
SinglyLinkedList<RollNote> const& roll_notes(int note) const { return m_roll_notes[note]; }
|
||||
int volume() const { return m_volume; }
|
||||
NonnullRefPtr<LibDSP::Synthesizers::Classic> synth() { return m_synth; }
|
||||
NonnullRefPtr<LibDSP::Effects::Delay> delay() { return m_delay; }
|
||||
|
@ -51,7 +51,7 @@ private:
|
|||
|
||||
int m_volume;
|
||||
|
||||
const u32& m_time;
|
||||
u32 const& m_time;
|
||||
|
||||
NonnullRefPtr<LibDSP::Transport> m_temporary_transport;
|
||||
NonnullRefPtr<LibDSP::Effects::Delay> m_delay;
|
||||
|
|
|
@ -76,7 +76,7 @@ EditGuideDialog::EditGuideDialog(GUI::Window* parent_window, String const& offse
|
|||
};
|
||||
}
|
||||
|
||||
Optional<float> EditGuideDialog::offset_as_pixel(const ImageEditor& editor)
|
||||
Optional<float> EditGuideDialog::offset_as_pixel(ImageEditor const& editor)
|
||||
{
|
||||
float offset = 0;
|
||||
if (m_offset.ends_with('%')) {
|
||||
|
|
|
@ -64,7 +64,7 @@ GUI::ModelIndex FilterModel::index(int row, int column, const GUI::ModelIndex& p
|
|||
return {};
|
||||
return create_index(row, column, &m_filters[row]);
|
||||
}
|
||||
auto* parent = static_cast<const FilterInfo*>(parent_index.internal_data());
|
||||
auto* parent = static_cast<FilterInfo const*>(parent_index.internal_data());
|
||||
if (static_cast<size_t>(row) >= parent->children.size())
|
||||
return {};
|
||||
auto* child = &parent->children[row];
|
||||
|
@ -76,7 +76,7 @@ GUI::ModelIndex FilterModel::parent_index(const GUI::ModelIndex& index) const
|
|||
if (!index.is_valid())
|
||||
return {};
|
||||
|
||||
auto* child = static_cast<const FilterInfo*>(index.internal_data());
|
||||
auto* child = static_cast<FilterInfo const*>(index.internal_data());
|
||||
auto* parent = child->parent;
|
||||
if (parent == nullptr)
|
||||
return {};
|
||||
|
@ -99,13 +99,13 @@ int FilterModel::row_count(const GUI::ModelIndex& index) const
|
|||
{
|
||||
if (!index.is_valid())
|
||||
return m_filters.size();
|
||||
auto* node = static_cast<const FilterInfo*>(index.internal_data());
|
||||
auto* node = static_cast<FilterInfo const*>(index.internal_data());
|
||||
return node->children.size();
|
||||
}
|
||||
|
||||
GUI::Variant FilterModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||
{
|
||||
auto* filter = static_cast<const FilterInfo*>(index.internal_data());
|
||||
auto* filter = static_cast<FilterInfo const*>(index.internal_data());
|
||||
switch (role) {
|
||||
case GUI::ModelRole::Display:
|
||||
return filter->text;
|
||||
|
|
|
@ -21,7 +21,7 @@ FilterPreviewWidget::~FilterPreviewWidget()
|
|||
{
|
||||
}
|
||||
|
||||
void FilterPreviewWidget::set_bitmap(const RefPtr<Gfx::Bitmap>& bitmap)
|
||||
void FilterPreviewWidget::set_bitmap(RefPtr<Gfx::Bitmap> const& bitmap)
|
||||
{
|
||||
m_bitmap = bitmap;
|
||||
clear_filter();
|
||||
|
|
|
@ -19,7 +19,7 @@ class FilterPreviewWidget final : public GUI::Frame {
|
|||
|
||||
public:
|
||||
virtual ~FilterPreviewWidget() override;
|
||||
void set_bitmap(const RefPtr<Gfx::Bitmap>& bitmap);
|
||||
void set_bitmap(RefPtr<Gfx::Bitmap> const& bitmap);
|
||||
void set_filter(Filter* filter);
|
||||
void clear_filter();
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ void Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json) const
|
|||
MUST(json.add("height", m_size.height()));
|
||||
{
|
||||
auto json_layers = MUST(json.add_array("layers"));
|
||||
for (const auto& layer : m_layers) {
|
||||
for (auto const& layer : m_layers) {
|
||||
Gfx::BMPWriter bmp_writer;
|
||||
auto json_layer = MUST(json_layers.add_object());
|
||||
MUST(json_layer.add("width", layer.size().width()));
|
||||
|
@ -147,7 +147,7 @@ void Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json) const
|
|||
}
|
||||
}
|
||||
|
||||
ErrorOr<void> Image::write_to_file(const String& file_path) const
|
||||
ErrorOr<void> Image::write_to_file(String const& file_path) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
auto json = MUST(JsonObjectSerializer<>::try_create(builder));
|
||||
|
@ -228,7 +228,7 @@ void Image::add_layer(NonnullRefPtr<Layer> layer)
|
|||
ErrorOr<NonnullRefPtr<Image>> Image::take_snapshot() const
|
||||
{
|
||||
auto snapshot = TRY(try_create_with_size(m_size));
|
||||
for (const auto& layer : m_layers) {
|
||||
for (auto const& layer : m_layers) {
|
||||
auto layer_snapshot = TRY(Layer::try_create_snapshot(*snapshot, layer));
|
||||
snapshot->add_layer(move(layer_snapshot));
|
||||
}
|
||||
|
|
|
@ -162,49 +162,49 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
|
|||
m_selection.paint(painter);
|
||||
|
||||
if (m_show_rulers) {
|
||||
const auto ruler_bg_color = palette().color(Gfx::ColorRole::InactiveSelection);
|
||||
const auto ruler_fg_color = palette().color(Gfx::ColorRole::Ruler);
|
||||
const auto ruler_text_color = palette().color(Gfx::ColorRole::InactiveSelectionText);
|
||||
const auto mouse_indicator_color = Color::White;
|
||||
auto const ruler_bg_color = palette().color(Gfx::ColorRole::InactiveSelection);
|
||||
auto const ruler_fg_color = palette().color(Gfx::ColorRole::Ruler);
|
||||
auto const ruler_text_color = palette().color(Gfx::ColorRole::InactiveSelectionText);
|
||||
auto const mouse_indicator_color = Color::White;
|
||||
|
||||
// Ruler background
|
||||
painter.fill_rect({ { 0, 0 }, { m_ruler_thickness, rect().height() } }, ruler_bg_color);
|
||||
painter.fill_rect({ { 0, 0 }, { rect().width(), m_ruler_thickness } }, ruler_bg_color);
|
||||
|
||||
const auto ruler_step = calculate_ruler_step_size();
|
||||
const auto editor_origin_to_image = frame_to_content_position({ 0, 0 });
|
||||
const auto editor_max_to_image = frame_to_content_position({ width(), height() });
|
||||
auto const ruler_step = calculate_ruler_step_size();
|
||||
auto const editor_origin_to_image = frame_to_content_position({ 0, 0 });
|
||||
auto const editor_max_to_image = frame_to_content_position({ width(), height() });
|
||||
|
||||
// Horizontal ruler
|
||||
painter.draw_line({ 0, m_ruler_thickness }, { rect().width(), m_ruler_thickness }, ruler_fg_color);
|
||||
const auto x_start = floor(editor_origin_to_image.x()) - ((int)floor(editor_origin_to_image.x()) % ruler_step) - ruler_step;
|
||||
auto const x_start = floor(editor_origin_to_image.x()) - ((int)floor(editor_origin_to_image.x()) % ruler_step) - ruler_step;
|
||||
for (int x = x_start; x < editor_max_to_image.x(); x += ruler_step) {
|
||||
const int num_sub_divisions = min(ruler_step, 10);
|
||||
int const num_sub_divisions = min(ruler_step, 10);
|
||||
for (int x_sub = 0; x_sub < num_sub_divisions; ++x_sub) {
|
||||
const int x_pos = x + (int)(ruler_step * x_sub / num_sub_divisions);
|
||||
const int editor_x_sub = content_to_frame_position({ x_pos, 0 }).x();
|
||||
const int line_length = (x_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6;
|
||||
int const x_pos = x + (int)(ruler_step * x_sub / num_sub_divisions);
|
||||
int const editor_x_sub = content_to_frame_position({ x_pos, 0 }).x();
|
||||
int const line_length = (x_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6;
|
||||
painter.draw_line({ editor_x_sub, m_ruler_thickness - line_length }, { editor_x_sub, m_ruler_thickness }, ruler_fg_color);
|
||||
}
|
||||
|
||||
const int editor_x = content_to_frame_position({ x, 0 }).x();
|
||||
int const editor_x = content_to_frame_position({ x, 0 }).x();
|
||||
painter.draw_line({ editor_x, 0 }, { editor_x, m_ruler_thickness }, ruler_fg_color);
|
||||
painter.draw_text({ { editor_x + 2, 0 }, { m_ruler_thickness, m_ruler_thickness - 2 } }, String::formatted("{}", x), painter.font(), Gfx::TextAlignment::CenterLeft, ruler_text_color);
|
||||
}
|
||||
|
||||
// Vertical ruler
|
||||
painter.draw_line({ m_ruler_thickness, 0 }, { m_ruler_thickness, rect().height() }, ruler_fg_color);
|
||||
const auto y_start = floor(editor_origin_to_image.y()) - ((int)floor(editor_origin_to_image.y()) % ruler_step) - ruler_step;
|
||||
auto const y_start = floor(editor_origin_to_image.y()) - ((int)floor(editor_origin_to_image.y()) % ruler_step) - ruler_step;
|
||||
for (int y = y_start; y < editor_max_to_image.y(); y += ruler_step) {
|
||||
const int num_sub_divisions = min(ruler_step, 10);
|
||||
int const num_sub_divisions = min(ruler_step, 10);
|
||||
for (int y_sub = 0; y_sub < num_sub_divisions; ++y_sub) {
|
||||
const int y_pos = y + (int)(ruler_step * y_sub / num_sub_divisions);
|
||||
const int editor_y_sub = content_to_frame_position({ 0, y_pos }).y();
|
||||
const int line_length = (y_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6;
|
||||
int const y_pos = y + (int)(ruler_step * y_sub / num_sub_divisions);
|
||||
int const editor_y_sub = content_to_frame_position({ 0, y_pos }).y();
|
||||
int const line_length = (y_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6;
|
||||
painter.draw_line({ m_ruler_thickness - line_length, editor_y_sub }, { m_ruler_thickness, editor_y_sub }, ruler_fg_color);
|
||||
}
|
||||
|
||||
const int editor_y = content_to_frame_position({ 0, y }).y();
|
||||
int const editor_y = content_to_frame_position({ 0, y }).y();
|
||||
painter.draw_line({ 0, editor_y }, { m_ruler_thickness, editor_y }, ruler_fg_color);
|
||||
painter.draw_text({ { 0, editor_y - m_ruler_thickness }, { m_ruler_thickness, m_ruler_thickness } }, String::formatted("{}", y), painter.font(), Gfx::TextAlignment::BottomRight, ruler_text_color);
|
||||
}
|
||||
|
@ -222,8 +222,8 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
int ImageEditor::calculate_ruler_step_size() const
|
||||
{
|
||||
const auto step_target = 80 / scale();
|
||||
const auto max_factor = 5;
|
||||
auto const step_target = 80 / scale();
|
||||
auto const max_factor = 5;
|
||||
for (int factor = 0; factor < max_factor; ++factor) {
|
||||
int ten_to_factor = AK::pow<int>(10, factor);
|
||||
if (step_target <= 1 * ten_to_factor)
|
||||
|
@ -619,7 +619,7 @@ Result<void, String> ImageEditor::save_project_to_file(Core::File& file) const
|
|||
auto json = MUST(JsonObjectSerializer<>::try_create(builder));
|
||||
m_image->serialize_as_json(json);
|
||||
auto json_guides = MUST(json.add_array("guides"));
|
||||
for (const auto& guide : m_guides) {
|
||||
for (auto const& guide : m_guides) {
|
||||
auto json_guide = MUST(json_guides.add_object());
|
||||
MUST(json_guide.add("offset"sv, (double)guide.offset()));
|
||||
if (guide.orientation() == Guide::Orientation::Vertical)
|
||||
|
|
|
@ -101,7 +101,7 @@ MainWidget::MainWidget()
|
|||
}
|
||||
|
||||
// Note: Update these together! v
|
||||
static const Vector<String> s_suggested_zoom_levels { "25%", "50%", "100%", "200%", "300%", "400%", "800%", "1600%", "Fit to width", "Fit to height", "Fit entire image" };
|
||||
static Vector<String> const s_suggested_zoom_levels { "25%", "50%", "100%", "200%", "300%", "400%", "800%", "1600%", "Fit to width", "Fit to height", "Fit entire image" };
|
||||
static constexpr int s_zoom_level_fit_width = 8;
|
||||
static constexpr int s_zoom_level_fit_height = 9;
|
||||
static constexpr int s_zoom_level_fit_image = 10;
|
||||
|
|
|
@ -36,7 +36,7 @@ void BrushTool::on_mousedown(Layer* layer, MouseEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
const int first_draw_opacity = 10;
|
||||
int const first_draw_opacity = 10;
|
||||
|
||||
for (int i = 0; i < first_draw_opacity; ++i)
|
||||
draw_point(layer->currently_edited_bitmap(), color_for(layer_event), layer_event.position());
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
RefPtr<Guide> GuideTool::closest_guide(const Gfx::IntPoint& point)
|
||||
RefPtr<Guide> GuideTool::closest_guide(Gfx::IntPoint const& point)
|
||||
{
|
||||
auto guides = editor()->guides();
|
||||
Guide* closest_guide = nullptr;
|
||||
|
|
|
@ -157,7 +157,7 @@ GUI::Widget* RectangleSelectTool::get_properties_widget()
|
|||
feather_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
feather_label.set_fixed_size(80, 20);
|
||||
|
||||
const int feather_slider_max = 100;
|
||||
int const feather_slider_max = 100;
|
||||
auto& feather_slider = feather_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%");
|
||||
feather_slider.set_range(0, feather_slider_max);
|
||||
feather_slider.set_value((int)floorf(m_edge_feathering * (float)feather_slider_max));
|
||||
|
|
|
@ -43,13 +43,13 @@ void SprayTool::paint_it()
|
|||
auto& bitmap = layer->currently_edited_bitmap();
|
||||
GUI::Painter painter(bitmap);
|
||||
VERIFY(bitmap.bpp() == 32);
|
||||
const double minimal_radius = 2;
|
||||
const double base_radius = minimal_radius * m_thickness;
|
||||
double const minimal_radius = 2;
|
||||
double const base_radius = minimal_radius * m_thickness;
|
||||
for (int i = 0; i < M_PI * base_radius * base_radius * (m_density / 100.0); i++) {
|
||||
double radius = base_radius * nrand();
|
||||
double angle = 2 * M_PI * nrand();
|
||||
const int xpos = m_last_pos.x() + radius * AK::cos(angle);
|
||||
const int ypos = m_last_pos.y() - radius * AK::sin(angle);
|
||||
int const xpos = m_last_pos.x() + radius * AK::cos(angle);
|
||||
int const ypos = m_last_pos.y() - radius * AK::sin(angle);
|
||||
if (xpos < 0 || xpos >= bitmap.width())
|
||||
continue;
|
||||
if (ypos < 0 || ypos >= bitmap.height())
|
||||
|
|
|
@ -26,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto app = GUI::Application::construct(arguments);
|
||||
Config::pledge_domain("PixelPaint");
|
||||
|
||||
const char* image_file = nullptr;
|
||||
char const* image_file = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(image_file, "Image file to open", "path", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
|
|
@ -107,11 +107,11 @@ void RunWindow::do_run()
|
|||
show();
|
||||
}
|
||||
|
||||
bool RunWindow::run_as_command(const String& run_input)
|
||||
bool RunWindow::run_as_command(String const& run_input)
|
||||
{
|
||||
pid_t child_pid;
|
||||
const char* shell_executable = "/bin/Shell"; // TODO query and use the user's preferred shell.
|
||||
const char* argv[] = { shell_executable, "-c", run_input.characters(), nullptr };
|
||||
char const* shell_executable = "/bin/Shell"; // TODO query and use the user's preferred shell.
|
||||
char const* argv[] = { shell_executable, "-c", run_input.characters(), nullptr };
|
||||
|
||||
if ((errno = posix_spawn(&child_pid, shell_executable, nullptr, nullptr, const_cast<char**>(argv), environ))) {
|
||||
perror("posix_spawn");
|
||||
|
@ -136,7 +136,7 @@ bool RunWindow::run_as_command(const String& run_input)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool RunWindow::run_via_launch(const String& run_input)
|
||||
bool RunWindow::run_via_launch(String const& run_input)
|
||||
{
|
||||
auto url = URL::create_with_url_or_path(run_input);
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ private:
|
|||
RunWindow();
|
||||
|
||||
void do_run();
|
||||
bool run_as_command(const String& run_input);
|
||||
bool run_via_launch(const String& run_input);
|
||||
bool run_as_command(String const& run_input);
|
||||
bool run_via_launch(String const& run_input);
|
||||
|
||||
String history_file_path();
|
||||
void load_history();
|
||||
|
|
|
@ -24,7 +24,7 @@ NonnullOwnPtr<M3UParser> M3UParser::from_file(const String path)
|
|||
return from_memory(String { contents, NoChomp }, use_utf8);
|
||||
}
|
||||
|
||||
NonnullOwnPtr<M3UParser> M3UParser::from_memory(const String& m3u_contents, bool utf8)
|
||||
NonnullOwnPtr<M3UParser> M3UParser::from_memory(String const& m3u_contents, bool utf8)
|
||||
{
|
||||
auto parser = make<M3UParser>();
|
||||
VERIFY(!m3u_contents.is_null() && !m3u_contents.is_empty() && !m3u_contents.is_whitespace());
|
||||
|
@ -38,7 +38,7 @@ NonnullOwnPtr<Vector<M3UEntry>> M3UParser::parse(bool include_extended_info)
|
|||
auto vec = make<Vector<M3UEntry>>();
|
||||
|
||||
if (m_use_utf8) {
|
||||
//TODO: Implement M3U8 parsing
|
||||
// TODO: Implement M3U8 parsing
|
||||
TODO();
|
||||
return vec;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ NonnullOwnPtr<Vector<M3UEntry>> M3UParser::parse(bool include_extended_info)
|
|||
auto display_name = ext_inf.value().substring_view(seconds.length() + 1);
|
||||
VERIFY(!display_name.is_empty() && !display_name.is_null() && !display_name.is_empty());
|
||||
metadata_for_next_file.track_display_title = display_name;
|
||||
//TODO: support the alternative, non-standard #EXTINF value of a key=value dictionary
|
||||
// TODO: support the alternative, non-standard #EXTINF value of a key=value dictionary
|
||||
continue;
|
||||
}
|
||||
if (auto playlist = tag("#PLAYLIST:"); playlist.has_value())
|
||||
|
@ -88,7 +88,7 @@ NonnullOwnPtr<Vector<M3UEntry>> M3UParser::parse(bool include_extended_info)
|
|||
metadata_for_next_file.album_artist = move(ext_art.value());
|
||||
else if (auto ext_genre = tag("#EXTGENRE:"); ext_genre.has_value())
|
||||
metadata_for_next_file.album_genre = move(ext_genre.value());
|
||||
//TODO: Support M3A files (M3U files with embedded mp3 files)
|
||||
// TODO: Support M3A files (M3U files with embedded mp3 files)
|
||||
}
|
||||
|
||||
return vec;
|
||||
|
|
|
@ -33,7 +33,7 @@ struct M3UEntry {
|
|||
class M3UParser {
|
||||
public:
|
||||
static NonnullOwnPtr<M3UParser> from_file(String path);
|
||||
static NonnullOwnPtr<M3UParser> from_memory(const String& m3u_contents, bool utf8);
|
||||
static NonnullOwnPtr<M3UParser> from_memory(String const& m3u_contents, bool utf8);
|
||||
|
||||
NonnullOwnPtr<Vector<M3UEntry>> parse(bool include_extended_info);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ void PlaybackManager::loop(bool loop)
|
|||
m_loop = loop;
|
||||
}
|
||||
|
||||
void PlaybackManager::seek(const int position)
|
||||
void PlaybackManager::seek(int const position)
|
||||
{
|
||||
if (!m_loader)
|
||||
return;
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
void play();
|
||||
void stop();
|
||||
void pause();
|
||||
void seek(const int position);
|
||||
void seek(int const position);
|
||||
void loop(bool);
|
||||
bool toggle_pause();
|
||||
void set_loader(NonnullRefPtr<Audio::Loader>&&);
|
||||
|
|
|
@ -51,12 +51,12 @@ void Playlist::try_fill_missing_info(Vector<M3UEntry>& entries, StringView path)
|
|||
entry.extended_info->track_display_title = LexicalPath::title(entry.path);
|
||||
|
||||
if (!entry.extended_info->track_length_in_seconds.has_value()) {
|
||||
//TODO: Implement embedded metadata extractor for other audio formats
|
||||
// TODO: Implement embedded metadata extractor for other audio formats
|
||||
if (auto reader = Audio::Loader::create(entry.path); !reader.is_error())
|
||||
entry.extended_info->track_length_in_seconds = reader.value()->total_samples() / reader.value()->sample_rate();
|
||||
}
|
||||
|
||||
//TODO: Implement a metadata parser for the uncomfortably numerous popular embedded metadata formats
|
||||
// TODO: Implement a metadata parser for the uncomfortably numerous popular embedded metadata formats
|
||||
}
|
||||
|
||||
for (auto& entry : to_delete)
|
||||
|
|
|
@ -19,7 +19,7 @@ PlaylistWidget::PlaylistWidget()
|
|||
m_table_view->set_selection_mode(GUI::AbstractView::SelectionMode::SingleSelection);
|
||||
m_table_view->set_selection_behavior(GUI::AbstractView::SelectionBehavior::SelectRows);
|
||||
m_table_view->set_highlight_selected_rows(true);
|
||||
m_table_view->on_doubleclick = [&](const Gfx::Point<int>& point) {
|
||||
m_table_view->on_doubleclick = [&](Gfx::Point<int> const& point) {
|
||||
auto player = dynamic_cast<Player*>(window()->main_widget());
|
||||
auto index = m_table_view->index_at_event_position(point);
|
||||
if (!index.is_valid())
|
||||
|
@ -50,7 +50,7 @@ GUI::Variant PlaylistModel::data(const GUI::ModelIndex& index, GUI::ModelRole ro
|
|||
}
|
||||
if (role == GUI::ModelRole::Sort)
|
||||
return data(index, GUI::ModelRole::Display);
|
||||
if (role == static_cast<GUI::ModelRole>(PlaylistModelCustomRole::FilePath)) //path
|
||||
if (role == static_cast<GUI::ModelRole>(PlaylistModelCustomRole::FilePath)) // path
|
||||
return m_playlist_items[index.row()].path;
|
||||
|
||||
return {};
|
||||
|
|
|
@ -39,7 +39,7 @@ class PlaylistTableView : public GUI::TableView {
|
|||
public:
|
||||
void doubleclick_event(GUI::MouseEvent& event) override;
|
||||
|
||||
Function<void(const Gfx::Point<int>&)> on_doubleclick;
|
||||
Function<void(Gfx::Point<int> const&)> on_doubleclick;
|
||||
|
||||
private:
|
||||
PlaylistTableView();
|
||||
|
|
|
@ -35,17 +35,17 @@ static float get_normalized_aspect_ratio(float a, float b)
|
|||
}
|
||||
}
|
||||
|
||||
static bool node_is_leaf(const TreeMapNode& node)
|
||||
static bool node_is_leaf(TreeMapNode const& node)
|
||||
{
|
||||
return node.num_children() == 0;
|
||||
}
|
||||
|
||||
bool TreeMapWidget::rect_can_contain_label(const Gfx::IntRect& rect) const
|
||||
bool TreeMapWidget::rect_can_contain_label(Gfx::IntRect const& rect) const
|
||||
{
|
||||
return rect.height() >= font().presentation_size() && rect.width() > 20;
|
||||
}
|
||||
|
||||
void TreeMapWidget::paint_cell_frame(GUI::Painter& painter, const TreeMapNode& node, const Gfx::IntRect& cell_rect, const Gfx::IntRect& inner_rect, int depth, HasLabel has_label) const
|
||||
void TreeMapWidget::paint_cell_frame(GUI::Painter& painter, TreeMapNode const& node, Gfx::IntRect const& cell_rect, Gfx::IntRect const& inner_rect, int depth, HasLabel has_label) const
|
||||
{
|
||||
if (cell_rect.width() <= 2 || cell_rect.height() <= 2) {
|
||||
painter.fill_rect(cell_rect, Color::Black);
|
||||
|
@ -101,7 +101,7 @@ void TreeMapWidget::paint_cell_frame(GUI::Painter& painter, const TreeMapNode& n
|
|||
}
|
||||
|
||||
template<typename Function>
|
||||
void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect& rect, int depth, Function callback)
|
||||
void TreeMapWidget::lay_out_children(TreeMapNode const& node, Gfx::IntRect const& rect, int depth, Function callback)
|
||||
{
|
||||
if (node.num_children() == 0) {
|
||||
return;
|
||||
|
@ -179,7 +179,7 @@ void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect
|
|||
inner_rect = cell_rect;
|
||||
inner_rect.shrink(4, 4); // border and shading
|
||||
if (rect_can_contain_label(inner_rect)) {
|
||||
const int margin = 5;
|
||||
int const margin = 5;
|
||||
has_label = HasLabel::Yes;
|
||||
inner_rect.set_y(inner_rect.y() + font().presentation_size() + margin);
|
||||
inner_rect.set_height(inner_rect.height() - (font().presentation_size() + margin * 2));
|
||||
|
@ -214,11 +214,11 @@ void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect
|
|||
}
|
||||
}
|
||||
|
||||
const TreeMapNode* TreeMapWidget::path_node(size_t n) const
|
||||
TreeMapNode const* TreeMapWidget::path_node(size_t n) const
|
||||
{
|
||||
if (!m_tree.ptr())
|
||||
return nullptr;
|
||||
const TreeMapNode* iter = &m_tree->root();
|
||||
TreeMapNode const* iter = &m_tree->root();
|
||||
size_t path_index = 0;
|
||||
while (iter && path_index < m_path.size() && path_index < n) {
|
||||
size_t child_index = m_path[path_index];
|
||||
|
@ -238,13 +238,13 @@ void TreeMapWidget::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
m_selected_node_cache = path_node(m_path.size());
|
||||
|
||||
const TreeMapNode* node = path_node(m_viewpoint);
|
||||
TreeMapNode const* node = path_node(m_viewpoint);
|
||||
if (!node) {
|
||||
painter.fill_rect(frame_inner_rect(), Color::MidGray);
|
||||
} else if (node_is_leaf(*node)) {
|
||||
paint_cell_frame(painter, *node, frame_inner_rect(), Gfx::IntRect(), m_viewpoint - 1, HasLabel::Yes);
|
||||
} else {
|
||||
lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](const TreeMapNode& node, int, const Gfx::IntRect& rect, const Gfx::IntRect& inner_rect, int depth, HasLabel has_label, IsRemainder remainder) {
|
||||
lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](TreeMapNode const& node, int, Gfx::IntRect const& rect, Gfx::IntRect const& inner_rect, int depth, HasLabel has_label, IsRemainder remainder) {
|
||||
if (remainder == IsRemainder::No) {
|
||||
paint_cell_frame(painter, node, rect, inner_rect, depth, has_label);
|
||||
} else {
|
||||
|
@ -258,14 +258,14 @@ void TreeMapWidget::paint_event(GUI::PaintEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
Vector<int> TreeMapWidget::path_to_position(const Gfx::IntPoint& position)
|
||||
Vector<int> TreeMapWidget::path_to_position(Gfx::IntPoint const& position)
|
||||
{
|
||||
const TreeMapNode* node = path_node(m_viewpoint);
|
||||
TreeMapNode const* node = path_node(m_viewpoint);
|
||||
if (!node) {
|
||||
return {};
|
||||
}
|
||||
Vector<int> path;
|
||||
lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](const TreeMapNode&, int index, const Gfx::IntRect& rect, const Gfx::IntRect&, int, HasLabel, IsRemainder is_remainder) {
|
||||
lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](TreeMapNode const&, int index, Gfx::IntRect const& rect, Gfx::IntRect const&, int, HasLabel, IsRemainder is_remainder) {
|
||||
if (is_remainder == IsRemainder::No && rect.contains(position)) {
|
||||
path.append(index);
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ Vector<int> TreeMapWidget::path_to_position(const Gfx::IntPoint& position)
|
|||
|
||||
void TreeMapWidget::mousedown_event(GUI::MouseEvent& event)
|
||||
{
|
||||
const TreeMapNode* node = path_node(m_viewpoint);
|
||||
TreeMapNode const* node = path_node(m_viewpoint);
|
||||
if (node && !node_is_leaf(*node)) {
|
||||
Vector<int> path = path_to_position(event.position());
|
||||
if (!path.is_empty()) {
|
||||
|
@ -293,7 +293,7 @@ void TreeMapWidget::doubleclick_event(GUI::MouseEvent& event)
|
|||
{
|
||||
if (event.button() != GUI::MouseButton::Primary)
|
||||
return;
|
||||
const TreeMapNode* node = path_node(m_viewpoint);
|
||||
TreeMapNode const* node = path_node(m_viewpoint);
|
||||
if (node && !node_is_leaf(*node)) {
|
||||
Vector<int> path = path_to_position(event.position());
|
||||
m_path.shrink(m_viewpoint);
|
||||
|
|
|
@ -15,7 +15,7 @@ struct TreeMapNode {
|
|||
virtual String name() const = 0;
|
||||
virtual i64 area() const = 0;
|
||||
virtual size_t num_children() const = 0;
|
||||
virtual const TreeMapNode& child_at(size_t i) const = 0;
|
||||
virtual TreeMapNode const& child_at(size_t i) const = 0;
|
||||
virtual void sort_children_by_area() const = 0;
|
||||
|
||||
protected:
|
||||
|
@ -24,7 +24,7 @@ protected:
|
|||
|
||||
struct TreeMap : public RefCounted<TreeMap> {
|
||||
virtual ~TreeMap() = default;
|
||||
virtual const TreeMapNode& root() const = 0;
|
||||
virtual TreeMapNode const& root() const = 0;
|
||||
};
|
||||
|
||||
class TreeMapWidget final : public GUI::Frame {
|
||||
|
@ -35,7 +35,7 @@ public:
|
|||
Function<void()> on_path_change;
|
||||
Function<void(GUI::ContextMenuEvent&)> on_context_menu_request;
|
||||
size_t path_size() const;
|
||||
const TreeMapNode* path_node(size_t n) const;
|
||||
TreeMapNode const* path_node(size_t n) const;
|
||||
size_t viewpoint() const;
|
||||
void set_viewpoint(size_t);
|
||||
void set_tree(RefPtr<TreeMap> tree);
|
||||
|
@ -49,8 +49,8 @@ private:
|
|||
virtual void context_menu_event(GUI::ContextMenuEvent&) override;
|
||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
|
||||
bool rect_can_contain_children(const Gfx::IntRect& rect) const;
|
||||
bool rect_can_contain_label(const Gfx::IntRect& rect) const;
|
||||
bool rect_can_contain_children(Gfx::IntRect const& rect) const;
|
||||
bool rect_can_contain_label(Gfx::IntRect const& rect) const;
|
||||
|
||||
enum class HasLabel {
|
||||
Yes,
|
||||
|
@ -62,14 +62,14 @@ private:
|
|||
};
|
||||
|
||||
template<typename Function>
|
||||
void lay_out_children(const TreeMapNode&, const Gfx::IntRect&, int depth, Function);
|
||||
void paint_cell_frame(GUI::Painter&, const TreeMapNode&, const Gfx::IntRect&, const Gfx::IntRect&, int depth, HasLabel has_label) const;
|
||||
Vector<int> path_to_position(const Gfx::IntPoint&);
|
||||
void lay_out_children(TreeMapNode const&, Gfx::IntRect const&, int depth, Function);
|
||||
void paint_cell_frame(GUI::Painter&, TreeMapNode const&, Gfx::IntRect const&, Gfx::IntRect const&, int depth, HasLabel has_label) const;
|
||||
Vector<int> path_to_position(Gfx::IntPoint const&);
|
||||
|
||||
RefPtr<TreeMap> m_tree;
|
||||
Vector<int> m_path;
|
||||
size_t m_viewpoint { 0 };
|
||||
const void* m_selected_node_cache;
|
||||
void const* m_selected_node_cache;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ struct TreeNode : public SpaceAnalyzer::TreeMapNode {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
virtual const TreeNode& child_at(size_t i) const override { return m_children->at(i); }
|
||||
virtual TreeNode const& child_at(size_t i) const override { return m_children->at(i); }
|
||||
virtual void sort_children_by_area() const override
|
||||
{
|
||||
if (m_children) {
|
||||
|
@ -65,7 +65,7 @@ struct Tree : public SpaceAnalyzer::TreeMap {
|
|||
: m_root(move(root_name)) {};
|
||||
virtual ~Tree() {};
|
||||
TreeNode m_root;
|
||||
virtual const SpaceAnalyzer::TreeMapNode& root() const override
|
||||
virtual SpaceAnalyzer::TreeMapNode const& root() const override
|
||||
{
|
||||
return m_root;
|
||||
};
|
||||
|
@ -278,7 +278,7 @@ static void analyze(RefPtr<Tree> tree, SpaceAnalyzer::TreeMapWidget& treemapwidg
|
|||
treemapwidget.set_tree(tree);
|
||||
}
|
||||
|
||||
static bool is_removable(const String& absolute_path)
|
||||
static bool is_removable(String const& absolute_path)
|
||||
{
|
||||
VERIFY(!absolute_path.is_empty());
|
||||
int access_result = access(LexicalPath::dirname(absolute_path).characters(), W_OK);
|
||||
|
@ -287,14 +287,14 @@ static bool is_removable(const String& absolute_path)
|
|||
return access_result == 0;
|
||||
}
|
||||
|
||||
static String get_absolute_path_to_selected_node(const SpaceAnalyzer::TreeMapWidget& treemapwidget, bool include_last_node = true)
|
||||
static String get_absolute_path_to_selected_node(SpaceAnalyzer::TreeMapWidget const& treemapwidget, bool include_last_node = true)
|
||||
{
|
||||
StringBuilder path_builder;
|
||||
for (size_t k = 0; k < treemapwidget.path_size() - (include_last_node ? 0 : 1); k++) {
|
||||
if (k != 0) {
|
||||
path_builder.append('/');
|
||||
}
|
||||
const SpaceAnalyzer::TreeMapNode* node = treemapwidget.path_node(k);
|
||||
SpaceAnalyzer::TreeMapNode const* node = treemapwidget.path_node(k);
|
||||
path_builder.append(node->name());
|
||||
}
|
||||
return path_builder.build();
|
||||
|
|
|
@ -47,7 +47,7 @@ void Cell::set_data(JS::Value new_data)
|
|||
m_evaluated_data = move(new_data);
|
||||
}
|
||||
|
||||
void Cell::set_type(const CellType* type)
|
||||
void Cell::set_type(CellType const* type)
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ void Cell::set_type_metadata(CellTypeMetadata&& metadata)
|
|||
m_type_metadata = move(metadata);
|
||||
}
|
||||
|
||||
const CellType& Cell::type() const
|
||||
CellType const& Cell::type() const
|
||||
{
|
||||
if (m_type)
|
||||
return *m_type;
|
||||
|
@ -171,13 +171,13 @@ void Cell::reference_from(Cell* other)
|
|||
if (!other || other == this)
|
||||
return;
|
||||
|
||||
if (!m_referencing_cells.find_if([other](const auto& ptr) { return ptr.ptr() == other; }).is_end())
|
||||
if (!m_referencing_cells.find_if([other](auto const& ptr) { return ptr.ptr() == other; }).is_end())
|
||||
return;
|
||||
|
||||
m_referencing_cells.append(other->make_weak_ptr());
|
||||
}
|
||||
|
||||
void Cell::copy_from(const Cell& other)
|
||||
void Cell::copy_from(Cell const& other)
|
||||
{
|
||||
m_dirty = true;
|
||||
m_evaluated_externally = other.m_evaluated_externally;
|
||||
|
|
|
@ -58,16 +58,16 @@ struct Cell : public Weakable<Cell> {
|
|||
return m_thrown_value;
|
||||
}
|
||||
|
||||
const String& data() const { return m_data; }
|
||||
String const& data() const { return m_data; }
|
||||
const JS::Value& evaluated_data() const { return m_evaluated_data; }
|
||||
Kind kind() const { return m_kind; }
|
||||
const Vector<WeakPtr<Cell>>& referencing_cells() const { return m_referencing_cells; }
|
||||
Vector<WeakPtr<Cell>> const& referencing_cells() const { return m_referencing_cells; }
|
||||
|
||||
void set_type(StringView name);
|
||||
void set_type(const CellType*);
|
||||
void set_type(CellType const*);
|
||||
void set_type_metadata(CellTypeMetadata&&);
|
||||
|
||||
const Position& position() const { return m_position; }
|
||||
Position const& position() const { return m_position; }
|
||||
void set_position(Position position, Badge<Sheet>)
|
||||
{
|
||||
if (position != m_position) {
|
||||
|
@ -76,9 +76,9 @@ struct Cell : public Weakable<Cell> {
|
|||
}
|
||||
}
|
||||
|
||||
const Format& evaluated_formats() const { return m_evaluated_formats; }
|
||||
Format const& evaluated_formats() const { return m_evaluated_formats; }
|
||||
Format& evaluated_formats() { return m_evaluated_formats; }
|
||||
const Vector<ConditionalFormat>& conditional_formats() const { return m_conditional_formats; }
|
||||
Vector<ConditionalFormat> const& conditional_formats() const { return m_conditional_formats; }
|
||||
void set_conditional_formats(Vector<ConditionalFormat>&& fmts)
|
||||
{
|
||||
m_dirty = true;
|
||||
|
@ -88,8 +88,8 @@ struct Cell : public Weakable<Cell> {
|
|||
JS::ThrowCompletionOr<String> typed_display() const;
|
||||
JS::ThrowCompletionOr<JS::Value> typed_js_data() const;
|
||||
|
||||
const CellType& type() const;
|
||||
const CellTypeMetadata& type_metadata() const { return m_type_metadata; }
|
||||
CellType const& type() const;
|
||||
CellTypeMetadata const& type_metadata() const { return m_type_metadata; }
|
||||
CellTypeMetadata& type_metadata() { return m_type_metadata; }
|
||||
|
||||
String source() const;
|
||||
|
@ -99,10 +99,10 @@ struct Cell : public Weakable<Cell> {
|
|||
void update();
|
||||
void update_data(Badge<Sheet>);
|
||||
|
||||
const Sheet& sheet() const { return *m_sheet; }
|
||||
Sheet const& sheet() const { return *m_sheet; }
|
||||
Sheet& sheet() { return *m_sheet; }
|
||||
|
||||
void copy_from(const Cell&);
|
||||
void copy_from(Cell const&);
|
||||
|
||||
private:
|
||||
bool m_dirty { false };
|
||||
|
@ -113,7 +113,7 @@ private:
|
|||
Kind m_kind { LiteralString };
|
||||
WeakPtr<Sheet> m_sheet;
|
||||
Vector<WeakPtr<Cell>> m_referencing_cells;
|
||||
const CellType* m_type { nullptr };
|
||||
CellType const* m_type { nullptr };
|
||||
CellTypeMetadata m_type_metadata;
|
||||
Position m_position;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
void CellSyntaxHighlighter::rehighlight(const Palette& palette)
|
||||
void CellSyntaxHighlighter::rehighlight(Palette const& palette)
|
||||
{
|
||||
auto text = m_client->get_text();
|
||||
m_client->spans().clear();
|
||||
|
|
|
@ -16,11 +16,11 @@ public:
|
|||
CellSyntaxHighlighter() = default;
|
||||
virtual ~CellSyntaxHighlighter() override = default;
|
||||
|
||||
virtual void rehighlight(const Palette&) override;
|
||||
void set_cell(const Cell* cell) { m_cell = cell; }
|
||||
virtual void rehighlight(Palette const&) override;
|
||||
void set_cell(Cell const* cell) { m_cell = cell; }
|
||||
|
||||
private:
|
||||
const Cell* m_cell { nullptr };
|
||||
Cell const* m_cell { nullptr };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ DateCell::DateCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> DateCell::display(Cell& cell, const CellTypeMetadata& metadata) const
|
||||
JS::ThrowCompletionOr<String> DateCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<String> {
|
||||
auto timestamp = TRY(js_value(cell, metadata));
|
||||
|
@ -30,7 +30,7 @@ JS::ThrowCompletionOr<String> DateCell::display(Cell& cell, const CellTypeMetada
|
|||
});
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Value> DateCell::js_value(Cell& cell, const CellTypeMetadata&) const
|
||||
JS::ThrowCompletionOr<JS::Value> DateCell::js_value(Cell& cell, CellTypeMetadata const&) const
|
||||
{
|
||||
auto js_data = cell.js_data();
|
||||
auto value = TRY(js_data.to_double(cell.sheet().global_object()));
|
||||
|
|
|
@ -16,8 +16,8 @@ class DateCell : public CellType {
|
|||
public:
|
||||
DateCell();
|
||||
virtual ~DateCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -21,23 +21,23 @@ struct SingleEntryListNext {
|
|||
|
||||
template<typename PutChFunc, typename ArgumentListRefT, template<typename T, typename U = ArgumentListRefT> typename NextArgument, typename CharType>
|
||||
struct PrintfImpl : public PrintfImplementation::PrintfImpl<PutChFunc, ArgumentListRefT, NextArgument, CharType> {
|
||||
ALWAYS_INLINE PrintfImpl(PutChFunc& putch, char*& bufptr, const int& nwritten)
|
||||
ALWAYS_INLINE PrintfImpl(PutChFunc& putch, char*& bufptr, int const& nwritten)
|
||||
: PrintfImplementation::PrintfImpl<PutChFunc, ArgumentListRefT, NextArgument>(putch, bufptr, nwritten)
|
||||
{
|
||||
}
|
||||
|
||||
// Disallow pointer formats.
|
||||
ALWAYS_INLINE int format_n(const PrintfImplementation::ModifierState&, ArgumentListRefT&) const
|
||||
ALWAYS_INLINE int format_n(PrintfImplementation::ModifierState const&, ArgumentListRefT&) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
ALWAYS_INLINE int format_s(const PrintfImplementation::ModifierState&, ArgumentListRefT&) const
|
||||
ALWAYS_INLINE int format_s(PrintfImplementation::ModifierState const&, ArgumentListRefT&) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
String format_double(const char* format, double value)
|
||||
String format_double(char const* format, double value)
|
||||
{
|
||||
StringBuilder builder;
|
||||
auto putch = [&](auto, auto ch) { builder.append(ch); };
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
String format_double(const char* format, double value);
|
||||
String format_double(char const* format, double value);
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ IdentityCell::IdentityCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> IdentityCell::display(Cell& cell, const CellTypeMetadata& metadata) const
|
||||
JS::ThrowCompletionOr<String> IdentityCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
auto data = cell.js_data();
|
||||
if (!metadata.format.is_empty())
|
||||
|
@ -24,7 +24,7 @@ JS::ThrowCompletionOr<String> IdentityCell::display(Cell& cell, const CellTypeMe
|
|||
return data.to_string(cell.sheet().global_object());
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Value> IdentityCell::js_value(Cell& cell, const CellTypeMetadata&) const
|
||||
JS::ThrowCompletionOr<JS::Value> IdentityCell::js_value(Cell& cell, CellTypeMetadata const&) const
|
||||
{
|
||||
return cell.js_data();
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ class IdentityCell : public CellType {
|
|||
public:
|
||||
IdentityCell();
|
||||
virtual ~IdentityCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ NumericCell::NumericCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> NumericCell::display(Cell& cell, const CellTypeMetadata& metadata) const
|
||||
JS::ThrowCompletionOr<String> NumericCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<String> {
|
||||
auto value = TRY(js_value(cell, metadata));
|
||||
|
@ -34,7 +34,7 @@ JS::ThrowCompletionOr<String> NumericCell::display(Cell& cell, const CellTypeMet
|
|||
});
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Value> NumericCell::js_value(Cell& cell, const CellTypeMetadata&) const
|
||||
JS::ThrowCompletionOr<JS::Value> NumericCell::js_value(Cell& cell, CellTypeMetadata const&) const
|
||||
{
|
||||
return propagate_failure(cell, [&]() {
|
||||
return cell.js_data().to_number(cell.sheet().global_object());
|
||||
|
|
|
@ -26,8 +26,8 @@ class NumericCell : public CellType {
|
|||
public:
|
||||
NumericCell();
|
||||
virtual ~NumericCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ StringCell::StringCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> StringCell::display(Cell& cell, const CellTypeMetadata& metadata) const
|
||||
JS::ThrowCompletionOr<String> StringCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
auto string = TRY(cell.js_data().to_string(cell.sheet().global_object()));
|
||||
if (metadata.length >= 0)
|
||||
|
@ -24,7 +24,7 @@ JS::ThrowCompletionOr<String> StringCell::display(Cell& cell, const CellTypeMeta
|
|||
return string;
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Value> StringCell::js_value(Cell& cell, const CellTypeMetadata& metadata) const
|
||||
JS::ThrowCompletionOr<JS::Value> StringCell::js_value(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
auto string = TRY(display(cell, metadata));
|
||||
return JS::js_string(cell.sheet().interpreter().heap(), string);
|
||||
|
|
|
@ -15,8 +15,8 @@ class StringCell : public CellType {
|
|||
public:
|
||||
StringCell();
|
||||
virtual ~StringCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ static Spreadsheet::DateCell s_date_cell;
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
const CellType* CellType::get_by_name(StringView name)
|
||||
CellType const* CellType::get_by_name(StringView name)
|
||||
{
|
||||
return s_cell_types.get(name).value_or(nullptr);
|
||||
}
|
||||
|
|
|
@ -32,15 +32,15 @@ enum class MetadataName {
|
|||
|
||||
class CellType {
|
||||
public:
|
||||
static const CellType* get_by_name(StringView);
|
||||
static CellType const* get_by_name(StringView);
|
||||
static Vector<StringView> names();
|
||||
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const = 0;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const = 0;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const = 0;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const = 0;
|
||||
virtual String metadata_hint(MetadataName) const { return {}; }
|
||||
virtual ~CellType() = default;
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
String const& name() const { return m_name; }
|
||||
|
||||
protected:
|
||||
CellType(StringView name);
|
||||
|
|
|
@ -29,7 +29,7 @@ REGISTER_WIDGET(Spreadsheet, ConditionsView);
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
CellTypeDialog::CellTypeDialog(const Vector<Position>& positions, Sheet& sheet, GUI::Window* parent)
|
||||
CellTypeDialog::CellTypeDialog(Vector<Position> const& positions, Sheet& sheet, GUI::Window* parent)
|
||||
: GUI::Dialog(parent)
|
||||
{
|
||||
VERIFY(!positions.is_empty());
|
||||
|
@ -62,8 +62,8 @@ CellTypeDialog::CellTypeDialog(const Vector<Position>& positions, Sheet& sheet,
|
|||
ok_button.on_click = [&](auto) { done(ExecOK); };
|
||||
}
|
||||
|
||||
const Vector<String> g_horizontal_alignments { "Left", "Center", "Right" };
|
||||
const Vector<String> g_vertical_alignments { "Top", "Center", "Bottom" };
|
||||
Vector<String> const g_horizontal_alignments { "Left", "Center", "Right" };
|
||||
Vector<String> const g_vertical_alignments { "Top", "Center", "Bottom" };
|
||||
Vector<String> g_types;
|
||||
|
||||
constexpr static CellTypeDialog::VerticalAlignment vertical_alignment_from(Gfx::TextAlignment alignment)
|
||||
|
@ -110,7 +110,7 @@ constexpr static CellTypeDialog::HorizontalAlignment horizontal_alignment_from(G
|
|||
return CellTypeDialog::HorizontalAlignment::Right;
|
||||
}
|
||||
|
||||
void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& positions, Sheet& sheet)
|
||||
void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& positions, Sheet& sheet)
|
||||
{
|
||||
g_types.clear();
|
||||
for (auto& type_name : CellType::names())
|
||||
|
|
|
@ -18,7 +18,7 @@ class CellTypeDialog : public GUI::Dialog {
|
|||
|
||||
public:
|
||||
CellTypeMetadata metadata() const;
|
||||
const CellType* type() const { return m_type; }
|
||||
CellType const* type() const { return m_type; }
|
||||
Vector<ConditionalFormat> conditional_formats() { return m_conditional_formats; }
|
||||
|
||||
enum class HorizontalAlignment : int {
|
||||
|
@ -33,10 +33,10 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
CellTypeDialog(const Vector<Position>&, Sheet&, GUI::Window* parent = nullptr);
|
||||
void setup_tabs(GUI::TabWidget&, const Vector<Position>&, Sheet&);
|
||||
CellTypeDialog(Vector<Position> const&, Sheet&, GUI::Window* parent = nullptr);
|
||||
void setup_tabs(GUI::TabWidget&, Vector<Position> const&, Sheet&);
|
||||
|
||||
const CellType* m_type { nullptr };
|
||||
CellType const* m_type { nullptr };
|
||||
|
||||
int m_length { -1 };
|
||||
String m_format;
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
#include <unistd.h>
|
||||
|
||||
// This is defined in ImportDialog.cpp, we can't include it twice, since the generated symbol is exported.
|
||||
extern const char select_format_page_gml[];
|
||||
extern char const select_format_page_gml[];
|
||||
|
||||
namespace Spreadsheet {
|
||||
|
||||
CSVExportDialogPage::CSVExportDialogPage(const Sheet& sheet)
|
||||
CSVExportDialogPage::CSVExportDialogPage(Sheet const& sheet)
|
||||
: m_data(sheet.to_xsv())
|
||||
{
|
||||
m_headers.extend(m_data.take_first());
|
||||
|
@ -213,7 +213,7 @@ void CSVExportDialogPage::update_preview()
|
|||
m_data_preview_text_editor->update();
|
||||
}
|
||||
|
||||
Result<void, String> CSVExportDialogPage::move_into(const String& target)
|
||||
Result<void, String> CSVExportDialogPage::move_into(String const& target)
|
||||
{
|
||||
auto& source = m_temp_output_file_path;
|
||||
|
||||
|
|
|
@ -20,11 +20,11 @@ class Workbook;
|
|||
struct CSVExportDialogPage {
|
||||
using XSV = Writer::XSV<Vector<Vector<String>>, Vector<String>>;
|
||||
|
||||
explicit CSVExportDialogPage(const Sheet&);
|
||||
explicit CSVExportDialogPage(Sheet const&);
|
||||
|
||||
NonnullRefPtr<GUI::WizardPage> page() { return *m_page; }
|
||||
Optional<XSV>& writer() { return m_previously_made_writer; }
|
||||
Result<void, String> move_into(const String& target);
|
||||
Result<void, String> move_into(String const& target);
|
||||
|
||||
protected:
|
||||
void update_preview();
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
String key(const GUI::ModelIndex& index) const { return m_keys[index.row()]; }
|
||||
|
||||
void set_from(const JsonObject& object)
|
||||
void set_from(JsonObject const& object)
|
||||
{
|
||||
m_keys.clear();
|
||||
object.for_each_member([this](auto& name, auto&) {
|
||||
|
|
|
@ -186,7 +186,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents)
|
|||
if (!position.has_value())
|
||||
return vm.throw_completion<JS::TypeError>(global_object, "Invalid cell name");
|
||||
|
||||
const auto* cell = sheet_object->m_sheet.at(position.value());
|
||||
auto const* cell = sheet_object->m_sheet.at(position.value());
|
||||
if (!cell)
|
||||
return JS::js_undefined();
|
||||
|
||||
|
|
|
@ -32,18 +32,18 @@ struct Position {
|
|||
return m_hash;
|
||||
}
|
||||
|
||||
bool operator==(const Position& other) const
|
||||
bool operator==(Position const& other) const
|
||||
{
|
||||
return row == other.row && column == other.column;
|
||||
}
|
||||
|
||||
bool operator!=(const Position& other) const
|
||||
bool operator!=(Position const& other) const
|
||||
{
|
||||
return !(other == *this);
|
||||
}
|
||||
|
||||
String to_cell_identifier(const Sheet& sheet) const;
|
||||
URL to_url(const Sheet& sheet) const;
|
||||
String to_cell_identifier(Sheet const& sheet) const;
|
||||
URL to_url(Sheet const& sheet) const;
|
||||
|
||||
size_t column { 0 };
|
||||
size_t row { 0 };
|
||||
|
|
|
@ -274,7 +274,7 @@ XSV::Field XSV::read_one_unquoted_field()
|
|||
StringView XSV::Row::operator[](StringView name) const
|
||||
{
|
||||
VERIFY(!m_xsv.m_names.is_empty());
|
||||
auto it = m_xsv.m_names.find_if([&](const auto& entry) { return name == entry; });
|
||||
auto it = m_xsv.m_names.find_if([&](auto const& entry) { return name == entry; });
|
||||
VERIFY(!it.is_end());
|
||||
|
||||
return (*this)[it.index()];
|
||||
|
|
|
@ -146,11 +146,11 @@ public:
|
|||
}
|
||||
|
||||
bool is_end() const { return m_index == m_xsv.m_rows.size(); }
|
||||
bool operator==(const RowIterator& other) const
|
||||
bool operator==(RowIterator const& other) const
|
||||
{
|
||||
return m_index == other.m_index && &m_xsv == &other.m_xsv;
|
||||
}
|
||||
bool operator==(const RowIterator<!const_>& other) const
|
||||
bool operator==(RowIterator<!const_> const& other) const
|
||||
{
|
||||
return m_index == other.m_index && &m_xsv == &other.m_xsv;
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ Cell* Sheet::at(StringView name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Cell* Sheet::at(const Position& position)
|
||||
Cell* Sheet::at(Position const& position)
|
||||
{
|
||||
auto it = m_cells.find(position);
|
||||
|
||||
|
@ -271,7 +271,7 @@ Optional<Position> Sheet::position_from_url(const URL& url) const
|
|||
return parse_cell_name(url.fragment());
|
||||
}
|
||||
|
||||
Position Sheet::offset_relative_to(const Position& base, const Position& offset, const Position& offset_base) const
|
||||
Position Sheet::offset_relative_to(Position const& base, Position const& offset, Position const& offset_base) const
|
||||
{
|
||||
if (offset.column >= m_columns.size()) {
|
||||
dbgln("Column '{}' does not exist!", offset.column);
|
||||
|
@ -361,7 +361,7 @@ void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Posi
|
|||
}
|
||||
}
|
||||
|
||||
RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
|
||||
RefPtr<Sheet> Sheet::from_json(JsonObject const& object, Workbook& workbook)
|
||||
{
|
||||
auto sheet = adopt_ref(*new Sheet(workbook));
|
||||
auto rows = object.get("rows").to_u32(default_row_count);
|
||||
|
@ -391,7 +391,7 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
|
|||
auto json = sheet->interpreter().global_object().get_without_side_effects("JSON");
|
||||
auto& parse_function = json.as_object().get_without_side_effects("parse").as_function();
|
||||
|
||||
auto read_format = [](auto& format, const auto& obj) {
|
||||
auto read_format = [](auto& format, auto const& obj) {
|
||||
if (auto value = obj.get("foreground_color"); value.is_string())
|
||||
format.foreground_color = Color::from_string(value.as_string());
|
||||
if (auto value = obj.get("background_color"); value.is_string())
|
||||
|
@ -519,7 +519,7 @@ JsonObject Sheet::to_json() const
|
|||
JsonObject object;
|
||||
object.set("name", m_name);
|
||||
|
||||
auto save_format = [](const auto& format, auto& obj) {
|
||||
auto save_format = [](auto const& format, auto& obj) {
|
||||
if (format.foreground_color.has_value())
|
||||
obj.set("foreground_color", format.foreground_color.value().to_string());
|
||||
if (format.background_color.has_value())
|
||||
|
@ -629,7 +629,7 @@ Vector<Vector<String>> Sheet::to_xsv() const
|
|||
return data;
|
||||
}
|
||||
|
||||
RefPtr<Sheet> Sheet::from_xsv(const Reader::XSV& xsv, Workbook& workbook)
|
||||
RefPtr<Sheet> Sheet::from_xsv(Reader::XSV const& xsv, Workbook& workbook)
|
||||
{
|
||||
auto cols = xsv.headers();
|
||||
auto rows = xsv.size();
|
||||
|
@ -736,12 +736,12 @@ String Sheet::generate_inline_documentation_for(StringView function, size_t argu
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
String Position::to_cell_identifier(const Sheet& sheet) const
|
||||
String Position::to_cell_identifier(Sheet const& sheet) const
|
||||
{
|
||||
return String::formatted("{}{}", sheet.column(column), row);
|
||||
}
|
||||
|
||||
URL Position::to_url(const Sheet& sheet) const
|
||||
URL Position::to_url(Sheet const& sheet) const
|
||||
{
|
||||
URL url;
|
||||
url.set_protocol("spreadsheet");
|
||||
|
|
|
@ -36,37 +36,37 @@ public:
|
|||
Optional<String> column_arithmetic(StringView column_name, int offset);
|
||||
|
||||
Cell* from_url(const URL&);
|
||||
const Cell* from_url(const URL& url) const { return const_cast<Sheet*>(this)->from_url(url); }
|
||||
Cell const* from_url(const URL& url) const { return const_cast<Sheet*>(this)->from_url(url); }
|
||||
Optional<Position> position_from_url(const URL& url) const;
|
||||
|
||||
/// Resolve 'offset' to an absolute position assuming 'base' is at 'offset_base'.
|
||||
/// Effectively, "Walk the distance between 'offset' and 'offset_base' away from 'base'".
|
||||
Position offset_relative_to(const Position& base, const Position& offset, const Position& offset_base) const;
|
||||
Position offset_relative_to(Position const& base, Position const& offset, Position const& offset_base) const;
|
||||
|
||||
JsonObject to_json() const;
|
||||
static RefPtr<Sheet> from_json(const JsonObject&, Workbook&);
|
||||
static RefPtr<Sheet> from_json(JsonObject const&, Workbook&);
|
||||
|
||||
Vector<Vector<String>> to_xsv() const;
|
||||
static RefPtr<Sheet> from_xsv(const Reader::XSV&, Workbook&);
|
||||
static RefPtr<Sheet> from_xsv(Reader::XSV const&, Workbook&);
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
String const& name() const { return m_name; }
|
||||
void set_name(StringView name) { m_name = name; }
|
||||
|
||||
JsonObject gather_documentation() const;
|
||||
|
||||
const HashTable<Position>& selected_cells() const { return m_selected_cells; }
|
||||
HashTable<Position> const& selected_cells() const { return m_selected_cells; }
|
||||
HashTable<Position>& selected_cells() { return m_selected_cells; }
|
||||
const HashMap<Position, NonnullOwnPtr<Cell>>& cells() const { return m_cells; }
|
||||
HashMap<Position, NonnullOwnPtr<Cell>> const& cells() const { return m_cells; }
|
||||
HashMap<Position, NonnullOwnPtr<Cell>>& cells() { return m_cells; }
|
||||
|
||||
Cell* at(const Position& position);
|
||||
const Cell* at(const Position& position) const { return const_cast<Sheet*>(this)->at(position); }
|
||||
Cell* at(Position const& position);
|
||||
Cell const* at(Position const& position) const { return const_cast<Sheet*>(this)->at(position); }
|
||||
|
||||
const Cell* at(StringView name) const { return const_cast<Sheet*>(this)->at(name); }
|
||||
Cell const* at(StringView name) const { return const_cast<Sheet*>(this)->at(name); }
|
||||
Cell* at(StringView);
|
||||
|
||||
const Cell& ensure(const Position& position) const { return const_cast<Sheet*>(this)->ensure(position); }
|
||||
Cell& ensure(const Position& position)
|
||||
Cell const& ensure(Position const& position) const { return const_cast<Sheet*>(this)->ensure(position); }
|
||||
Cell& ensure(Position const& position)
|
||||
{
|
||||
if (auto cell = at(position))
|
||||
return *cell;
|
||||
|
@ -80,8 +80,8 @@ public:
|
|||
|
||||
size_t row_count() const { return m_rows; }
|
||||
size_t column_count() const { return m_columns.size(); }
|
||||
const Vector<String>& columns() const { return m_columns; }
|
||||
const String& column(size_t index)
|
||||
Vector<String> const& columns() const { return m_columns; }
|
||||
String const& column(size_t index)
|
||||
{
|
||||
for (size_t i = column_count(); i < index; ++i)
|
||||
add_column();
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
VERIFY(column_count() > index);
|
||||
return m_columns[index];
|
||||
}
|
||||
const String& column(size_t index) const
|
||||
String const& column(size_t index) const
|
||||
{
|
||||
VERIFY(column_count() > index);
|
||||
return m_columns[index];
|
||||
|
@ -114,7 +114,7 @@ public:
|
|||
Cell*& current_evaluated_cell() { return m_current_cell_being_evaluated; }
|
||||
bool has_been_visited(Cell* cell) const { return m_visited_cells_in_update.contains(cell); }
|
||||
|
||||
const Workbook& workbook() const { return m_workbook; }
|
||||
Workbook const& workbook() const { return m_workbook; }
|
||||
|
||||
enum class CopyOperation {
|
||||
Copy,
|
||||
|
@ -160,7 +160,7 @@ namespace AK {
|
|||
template<>
|
||||
struct Traits<Spreadsheet::Position> : public GenericTraits<Spreadsheet::Position> {
|
||||
static constexpr bool is_trivial() { return false; }
|
||||
static unsigned hash(const Spreadsheet::Position& p)
|
||||
static unsigned hash(Spreadsheet::Position const& p)
|
||||
{
|
||||
return p.hash();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
|
|||
return {};
|
||||
|
||||
if (role == GUI::ModelRole::Display) {
|
||||
const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
if (!cell)
|
||||
return String::empty();
|
||||
|
||||
|
@ -63,7 +63,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
|
|||
return Position { (size_t)index.column(), (size_t)index.row() }.to_url(m_sheet).to_string();
|
||||
|
||||
if (role == GUI::ModelRole::TextAlignment) {
|
||||
const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
if (!cell)
|
||||
return {};
|
||||
|
||||
|
@ -71,7 +71,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
|
|||
}
|
||||
|
||||
if (role == GUI::ModelRole::ForegroundColor) {
|
||||
const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
if (!cell)
|
||||
return {};
|
||||
|
||||
|
@ -90,7 +90,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
|
|||
}
|
||||
|
||||
if (role == GUI::ModelRole::BackgroundColor) {
|
||||
const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
if (!cell)
|
||||
return {};
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ void SpreadsheetView::EditingDelegate::set_value(GUI::Variant const& value, GUI:
|
|||
return StringModelEditingDelegate::set_value(value, selection_behavior);
|
||||
|
||||
m_has_set_initial_value = true;
|
||||
const auto option = m_sheet.at({ (size_t)index().column(), (size_t)index().row() });
|
||||
auto const option = m_sheet.at({ (size_t)index().column(), (size_t)index().row() });
|
||||
if (option)
|
||||
return StringModelEditingDelegate::set_value(option->source(), selection_behavior);
|
||||
|
||||
|
@ -461,7 +461,7 @@ void SpreadsheetView::move_cursor(GUI::AbstractView::CursorMovement direction)
|
|||
m_table_view->move_cursor(direction, GUI::AbstractView::SelectionUpdate::Set);
|
||||
}
|
||||
|
||||
void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, const Gfx::IntRect& rect, const Gfx::Palette& palette, const GUI::ModelIndex& index)
|
||||
void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, Gfx::IntRect const& rect, Gfx::Palette const& palette, const GUI::ModelIndex& index)
|
||||
{
|
||||
// Draw a border.
|
||||
// Undo the horizontal padding done by the table view...
|
||||
|
|
|
@ -121,7 +121,7 @@ private:
|
|||
|
||||
class EditingDelegate final : public GUI::StringModelEditingDelegate {
|
||||
public:
|
||||
EditingDelegate(const Sheet& sheet)
|
||||
EditingDelegate(Sheet const& sheet)
|
||||
: m_sheet(sheet)
|
||||
{
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ private:
|
|||
|
||||
private:
|
||||
bool m_has_set_initial_value { false };
|
||||
const Sheet& m_sheet;
|
||||
Sheet const& m_sheet;
|
||||
};
|
||||
|
||||
class TableCellPainter final : public GUI::TableCellPaintingDelegate {
|
||||
|
@ -157,7 +157,7 @@ private:
|
|||
: m_table_view(view)
|
||||
{
|
||||
}
|
||||
void paint(GUI::Painter&, const Gfx::IntRect&, const Gfx::Palette&, const GUI::ModelIndex&) override;
|
||||
void paint(GUI::Painter&, Gfx::IntRect const&, Gfx::Palette const&, const GUI::ModelIndex&) override;
|
||||
|
||||
private:
|
||||
const GUI::TableView& m_table_view;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue