mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 18:42:43 +00:00 
			
		
		
		
	 6e19ab2bbc
			
		
	
	
		6e19ab2bbc
		
	
	
	
	
		
			
			We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
		
			
				
	
	
		
			61 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
 | |
|  * Copyright (c) 2021, Mustafa Quraish <mustafa@cs.toronto.edu>
 | |
|  * Copyright (c) 2022, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Vector.h>
 | |
| #include <LibConfig/Listener.h>
 | |
| #include <LibCore/DateTime.h>
 | |
| #include <LibGUI/Clipboard.h>
 | |
| #include <LibGUI/Model.h>
 | |
| 
 | |
| class ClipboardHistoryModel final : public GUI::Model
 | |
|     , public GUI::Clipboard::ClipboardClient
 | |
|     , public Config::Listener {
 | |
| public:
 | |
|     static NonnullRefPtr<ClipboardHistoryModel> create();
 | |
| 
 | |
|     enum Column {
 | |
|         Data,
 | |
|         Type,
 | |
|         Size,
 | |
|         Time,
 | |
|         __Count
 | |
|     };
 | |
| 
 | |
|     struct ClipboardItem {
 | |
|         GUI::Clipboard::DataAndType data_and_type;
 | |
|         Core::DateTime time;
 | |
|     };
 | |
| 
 | |
|     virtual ~ClipboardHistoryModel() override = default;
 | |
| 
 | |
|     ClipboardItem const& item_at(int index) const { return m_history_items[index]; }
 | |
|     void remove_item(int index);
 | |
| 
 | |
|     // ^GUI::Model
 | |
|     virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
 | |
| 
 | |
|     // ^Config::Listener
 | |
|     virtual void config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) override;
 | |
| 
 | |
| private:
 | |
|     ClipboardHistoryModel();
 | |
|     void add_item(const GUI::Clipboard::DataAndType& item);
 | |
| 
 | |
|     // ^GUI::Model
 | |
|     virtual int row_count(const GUI::ModelIndex&) const override { return m_history_items.size(); }
 | |
|     virtual DeprecatedString column_name(int) const override;
 | |
|     virtual int column_count(const GUI::ModelIndex&) const override { return Column::__Count; }
 | |
| 
 | |
|     // ^GUI::Clipboard::ClipboardClient
 | |
|     virtual void clipboard_content_did_change(DeprecatedString const&) override { add_item(GUI::Clipboard::the().fetch_data_and_type()); }
 | |
| 
 | |
|     Vector<ClipboardItem> m_history_items;
 | |
|     size_t m_history_limit;
 | |
| };
 |