"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/c2bCiterHistory.h" (12 Feb 2021, 3126 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "c2bCiterHistory.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.0.0_vs_2.0.1.

    1 /***************************************************************************
    2  *   Copyright (C) 2004-2021 by Pere Constans
    3  *   constans@molspaces.com
    4  *   cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
    5  *   See the LICENSE file that comes with this distribution.
    6  ***************************************************************************/
    7 #ifndef C2BCITERHISTORY_H
    8 #define C2BCITERHISTORY_H
    9 
   10 #include "c2bCiter.h"
   11 
   12 #include <QModelIndex>
   13 #include <QVarLengthArray>
   14 
   15 
   16 class c2bCiterHistory
   17 {
   18 
   19 public:
   20     c2bCiterHistory();
   21     inline ~c2bCiterHistory() {}
   22 
   23     void clear();
   24     void saveCurrentState(const c2bCiter::Format format, const c2bCiter::Filter filter, const int iindex,
   25                           const int vindex, const QString fstring);
   26 
   27     inline void saveCurrentState(const c2bCiter::Format format, const c2bCiter::Filter filter, const int iindex,
   28                                  const QModelIndex* const index, const QString fstring)
   29     {
   30         if (index)
   31             saveCurrentState(format, filter, iindex, index->row(), fstring);
   32     }
   33     inline void saveCurrentItemIndex(const c2bCiter::Format format, const c2bCiter::Filter filter, const int iindex)
   34     {
   35         if (format == c2bCiter::K)
   36             _last_keyword = iindex;
   37         else if (filter == c2bCiter::Selected)
   38             _last_selection_citation = iindex;
   39         else
   40             _last_citation = iindex;
   41     }
   42     inline const c2bCiter::State& lastState() const
   43     {
   44         return _states[_index[_nstates]];
   45     }
   46     inline const c2bCiter::State& previousState()
   47     {
   48         if (_cstate == -1)
   49             _cstate = _nstates;
   50         else if (_cstate == 0)
   51             _cstate = 1;
   52         return _states[_index[--_cstate]];
   53     }
   54     inline const c2bCiter::State& nextState()
   55     {
   56         if (_cstate == _nstates)
   57             _cstate = _nstates - 1;
   58         return _states[_index[++_cstate]];
   59     }
   60     inline int currentState() const
   61     {
   62         return _cstate;
   63     }
   64     inline const c2bCiter::State& lastNonKeywordState() const
   65     {
   66         return _last_nonkeyword_state;
   67     }
   68     inline const c2bCiter::State& lastNonSelectedState() const
   69     {
   70         return _last_nonselected_state;
   71     }
   72     inline void saveCurrentCitationFormat(const c2bCiter::Format format)
   73     {
   74         _last_citation_format = (format == c2bCiter::R || format == c2bCiter::K) ? _last_citation_format : format;
   75     }
   76     inline c2bCiter::Format lastCitationFormat() const
   77     {
   78         return _last_citation_format;
   79     }
   80     inline int lastCitation() const
   81     {
   82         return _last_citation;
   83     }
   84     inline int lastSelectionCitation() const
   85     {
   86         return _last_selection_citation;
   87     }
   88     inline int lastKeyword() const
   89     {
   90         return _last_keyword;
   91     }
   92 
   93 
   94 private:
   95     c2bCiter::Format _last_citation_format;
   96     int _cstate;
   97     int _last_citation;
   98     int _last_keyword;
   99     int _last_selection_citation;
  100     int _nstates;
  101 
  102     c2bCiter::State _last_nonkeyword_state;
  103     c2bCiter::State _last_nonselected_state;
  104 
  105     QVarLengthArray<c2bCiter::State> _states;
  106     QVarLengthArray<int> _index;
  107 };
  108 
  109 #endif