pub fn update_position(&mut self, position: u64) -> (bool, Option<gtk::TreeIter>) {
        let has_changed = match self.selected_iter {
            Some(ref selected_iter) => {
                if position >= ChapterEntry::get_start(&self.store, selected_iter)
                    && position < ChapterEntry::get_end(&self.store, selected_iter)
                {
                    // regular case: position in current chapter => don't change anything
                    // this check is here to save time in the most frequent case
                    return (false, None);
                }
                // chapter has changed
                true
            }
            None => false,
        };

        let prev_selected_iter = self.selected_iter.take();

        if let Some(iter) = self.iter.take() {
            // not in selected_iter or selected_iter not defined yet => find current chapter
            let mut searching_forward = true;
            while if position >= ChapterEntry::get_start(&self.store, &iter)
                && position < ChapterEntry::get_end(&self.store, &iter)
            {
                // position is in iter
                self.selected_iter = Some(iter.clone());
                self.iter = Some(iter);
                return (true, prev_selected_iter);
            } else if position >= ChapterEntry::get_end(&self.store, &iter) && searching_forward {
                // position is after iter and we were already searching forward
                self.store.iter_next(&iter)
            } else if position < ChapterEntry::get_start(&self.store, &iter) {
                // position before iter
                searching_forward = false;
                if self.store.iter_previous(&iter) {
                    // iter is still valid
                    true
                } else {
                    // before first chapter
                    self.iter = self.store.get_iter_first();
                    return (has_changed, prev_selected_iter);
                }
            } else {
                // in a gap between two chapters
                self.iter = Some(iter);
                return (has_changed, prev_selected_iter);
            } {}

            // passed the end of the last chapter
            // prevent from searching in subsequent calls
            self.iter = None;
        }

        (has_changed, prev_selected_iter)
    }
// Update chapter according to the given position
// Returns (has_changed, prev_selected_iter)
Update chapter according to the given position
Returns (has_changed, prev_selected_iter)
Update chapter according to the given position Returns ( has_changed prev_selected_iter )
pub fn update_position(&mut self, position: u64) -> (bool, Option<gtk::TreeIter>) {
        let has_changed = match self.selected_iter {
            Some(ref selected_iter) => {
                if position >= ChapterEntry::get_start(&self.store, selected_iter)
                    && position < ChapterEntry::get_end(&self.store, selected_iter)
                {
                    // regular case: position in current chapter => don't change anything
                    // this check is here to save time in the most frequent case
                    return (false, None);
                }
                // chapter has changed
                true
            }
            None => false,
        };
        let prev_selected_iter = self.selected_iter.take();
        if let Some(iter) = self.iter.take() {
            // not in selected_iter or selected_iter not defined yet => find current chapter
            let mut searching_forward = true;
            while if position >= ChapterEntry::get_start(&self.store, &iter)
                && position < ChapterEntry::get_end(&self.store, &iter)
            {
                // position is in iter
                self.selected_iter = Some(iter.clone());
                self.iter = Some(iter);
                return (true, prev_selected_iter);
            } else if position >= ChapterEntry::get_end(&self.store, &iter) && searching_forward {
                // position is after iter and we were already searching forward
                self.store.iter_next(&iter)
            } else if position < ChapterEntry::get_start(&self.store, &iter) {
                // position before iter
                searching_forward = false;
                if self.store.iter_previous(&iter) {
                    // iter is still valid
                    true
                } else {
                    // before first chapter
                    self.iter = self.store.get_iter_first();
                    return (has_changed, prev_selected_iter);
                }
            } else {
                // in a gap between two chapters
                self.iter = Some(iter);
                return (has_changed, prev_selected_iter);
            } {}
            // passed the end of the last chapter
            // prevent from searching in subsequent calls
            self.iter = None;
        }
        (has_changed, prev_selected_iter)
    }
pub fn update_position ( & mut self , position : u64 ) -> ( bool , Option < gtk :: TreeIter > ) { let has_changed = match self . selected_iter { Some ( ref selected_iter ) => { if position >= ChapterEntry :: get_start ( & self . store , selected_iter ) && position < ChapterEntry :: get_end ( & self . store , selected_iter ) { // regular case: position in current chapter => don't change anything // this check is here to save time in the most frequent case return ( false , None ) ; } // chapter has changed true } None => false , } ; let prev_selected_iter = self . selected_iter . take ( ) ; if let Some ( iter ) = self . iter . take ( ) { // not in selected_iter or selected_iter not defined yet => find current chapter let mut searching_forward = true ; while if position >= ChapterEntry :: get_start ( & self . store , & iter ) && position < ChapterEntry :: get_end ( & self . store , & iter ) { // position is in iter self . selected_iter = Some ( iter . clone ( ) ) ; self . iter = Some ( iter ) ; return ( true , prev_selected_iter ) ; } else if position >= ChapterEntry :: get_end ( & self . store , & iter ) && searching_forward { // position is after iter and we were already searching forward self . store . iter_next ( & iter ) } else if position < ChapterEntry :: get_start ( & self . store , & iter ) { // position before iter searching_forward = false ; if self . store . iter_previous ( & iter ) { // iter is still valid true } else { // before first chapter self . iter = self . store . get_iter_first ( ) ; return ( has_changed , prev_selected_iter ) ; } } else { // in a gap between two chapters self . iter = Some ( iter ) ; return ( has_changed , prev_selected_iter ) ; } { } // passed the end of the last chapter // prevent from searching in subsequent calls self . iter = None ; } ( has_changed , prev_selected_iter ) }
Update chapter according to the given position
Returns (has_changed, prev_selected_iter)
Update chapter according to the given position Returns ( has_changed prev_selected_iter )
&mut self
position
u64
&mut self
position
u64