ui/listing: use MailListingTrait instead of ListingTrait

async
Manos Pitsidianakis 2019-12-01 16:09:39 +02:00
parent 8e27b86453
commit e5da10093d
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
3 changed files with 23 additions and 2 deletions

View File

@ -136,7 +136,7 @@ pub enum ListingComponent {
use crate::ListingComponent::*;
impl core::ops::Deref for ListingComponent {
type Target = dyn ListingTrait;
type Target = dyn MailListingTrait;
fn deref(&self) -> &Self::Target {
match &self {
@ -149,7 +149,7 @@ impl core::ops::Deref for ListingComponent {
}
impl core::ops::DerefMut for ListingComponent {
fn deref_mut(&mut self) -> &mut (dyn ListingTrait + 'static) {
fn deref_mut(&mut self) -> &mut (dyn MailListingTrait + 'static) {
match self {
Compact(l) => l,
Plain(l) => l,

View File

@ -70,11 +70,20 @@ pub struct PlainListing {
unfocused: bool,
view: MailView,
row_updates: StackVec<EnvelopeHash>,
_row_updates: StackVec<ThreadHash>,
movement: Option<PageMovement>,
id: ComponentId,
}
impl MailListingTrait for PlainListing {
fn row_updates(&mut self) -> &mut StackVec<ThreadHash> {
&mut self._row_updates
}
fn update_line(&mut self, _context: &Context, _thread_hash: ThreadHash) {}
}
impl ListingTrait for PlainListing {
fn coordinates(&self) -> (usize, usize) {
(self.new_cursor_pos.0, self.new_cursor_pos.1)
@ -467,6 +476,7 @@ impl PlainListing {
filtered_order: FnvHashMap::default(),
selection: FnvHashMap::default(),
row_updates: StackVec::new(),
_row_updates: StackVec::new(),
data_columns: DataColumns::default(),
dirty: true,
force_draw: true,

View File

@ -37,6 +37,7 @@ pub struct ThreadListing {
/// Cache current view.
content: CellBuffer,
row_updates: StackVec<ThreadHash>,
locations: Vec<EnvelopeHash>,
/// If we must redraw on next redraw event
dirty: bool,
@ -48,6 +49,14 @@ pub struct ThreadListing {
id: ComponentId,
}
impl MailListingTrait for ThreadListing {
fn row_updates(&mut self) -> &mut StackVec<ThreadHash> {
&mut self.row_updates
}
fn update_line(&mut self, _context: &Context, _thread_hash: ThreadHash) {}
}
impl ListingTrait for ThreadListing {
fn coordinates(&self) -> (usize, usize) {
(self.new_cursor_pos.0, self.new_cursor_pos.1)
@ -56,6 +65,7 @@ impl ListingTrait for ThreadListing {
self.new_cursor_pos = (coordinates.0, coordinates.1, 0);
self.unfocused = false;
self.locations.clear();
self.row_updates.clear();
self.initialised = false;
}
fn draw_list(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
@ -230,6 +240,7 @@ impl ThreadListing {
sort: (Default::default(), Default::default()),
subsort: (Default::default(), Default::default()),
content,
row_updates: StackVec::new(),
locations: Vec::new(),
dirty: true,
unfocused: false,