summaryrefslogtreecommitdiffstats
path: root/src/widget/wlibrarytableview.h
blob: ae7c77aaf379cd731716c559d9376d8f448200e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// wlibrarytableview.h
// Created 10/19/2009 by RJ Ryan (rryan@mit.edu)

#pragma once

#include <QFont>
#include <QString>
#include <QTableView>

#include "library/libraryview.h"
#include "preferences/usersettings.h"
#include "track/track_decl.h"

class TrackModel;

class WLibraryTableView : public QTableView, public virtual LibraryView {
    Q_OBJECT

  public:
    WLibraryTableView(QWidget* parent,
                      UserSettingsPointer pConfig,
                      ConfigKey vScrollBarPosKey);
    ~WLibraryTableView() override;

    void moveSelection(int delta) override;

    /**
     * Saves current position of scrollbar using string key
     * can be any value but should invariant for model
     * @param key unique for trackmodel
     */
    void saveVScrollBarPos(TrackModel* key);
    /**
     * Finds scrollbar value associated with model by given key and restores it
     * @param key unique for trackmodel
     */
    void restoreVScrollBarPos(TrackModel* key);

  signals:
    void loadTrack(TrackPointer pTrack);
    void loadTrackToPlayer(TrackPointer pTrack, QString group,
            bool play = false);
    void trackSelected(TrackPointer pTrack);
    void onlyCachedCoverArt(bool);
    void scrollValueChanged(int);

  public slots:
    void setTrackTableFont(const QFont& font);
    void setTrackTableRowHeight(int rowHeight);
    void setSelectedClick(bool enable);

  protected:
    void focusInEvent(QFocusEvent* event) override;

    void saveNoSearchVScrollBarPos();
    void restoreNoSearchVScrollBarPos();

  private:
    void loadVScrollBarPosState();
    void saveVScrollBarPosState();

    const UserSettingsPointer m_pConfig;
    const ConfigKey m_vScrollBarPosKey;

    QMap<TrackModel*, int> m_vScrollBarPosValues;

    // The position of the vertical scrollbar slider, eg. before a search is
    // executed
    int m_noSearchVScrollBarPos;
};