Limo
A simple mod manager
Loading...
Searching...
No Matches
modlistview.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <QDragEnterEvent>
9#include <QDragLeaveEvent>
10#include <QDropEvent>
11#include <QTableView>
12#include <QWidget>
13#include <QtCore>
14#include <set>
15
16
20class ModListView : public QTableView
21{
22 Q_OBJECT
23public:
28 explicit ModListView(QWidget* parent = nullptr);
29
34 bool enableButtons() const;
39 void setEnableButtons(bool enabled);
44 int getHoverRow() const;
49 bool isInDragDrop() const;
54 bool mouseInUpperHalfOfRow() const;
59 int getNumSelectedRows() const;
64 std::vector<int> getSelectedModIds() const;
69 QModelIndexList getSelectedRowIndices() const;
70
71protected:
77 bool enable_buttons_ = true;
79 bool is_in_drag_drop_ = false;
82
87 void dropEvent(QDropEvent* event) override;
92 void dragEnterEvent(QDragEnterEvent* event) override;
97 void dragLeaveEvent(QDragLeaveEvent* event) override;
102 void dragMoveEvent(QDragMoveEvent* event) override;
109 void mousePressEvent(QMouseEvent* event) override;
117 void mouseReleaseEvent(QMouseEvent* event) override;
124 void mouseMoveEvent(QMouseEvent* event) override;
131 void mouseDoubleClickEvent(QMouseEvent* event) override;
136 void leaveEvent(QEvent* event) override;
141 void focusOutEvent(QFocusEvent* event) override;
146 void focusInEvent(QFocusEvent* event) override;
153 QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction,
154 Qt::KeyboardModifiers modifiers) override;
160 bool rowIndexIsValid(int row) const;
165 void updateMouseHoverRow(int row);
170 void updateMouseDownRow(int row);
175 void updateRow(int row);
176
177signals:
182 void modAdded(QList<QUrl> path);
188 void modStatusChanged(int mod_id, bool status);
194 void modRemoved(int mod_id, QString name);
195};
void updateMouseHoverRow(int row)
Sets mouse_hover_row_ to the given row and updates the view accordingly.
Definition modlistview.cpp:109
bool mouseInUpperHalfOfRow() const
Returns true iff mouse is currently in the upper half of a row.
Definition modlistview.cpp:143
void focusOutEvent(QFocusEvent *event) override
Gets called when this widget loses focus. Changes highlight color to inactive.
Definition modlistview.cpp:210
void mouseDoubleClickEvent(QMouseEvent *event) override
Gets called when a double click has been performed in this widget.
Definition modlistview.cpp:188
void dropEvent(QDropEvent *event) override
If dropped item was a file or a list of files, emit modAdded.
Definition modlistview.cpp:16
int getHoverRow() const
Returns the row currently under the mouse, or -1 if no row is under the mouse.
Definition modlistview.cpp:177
void mouseReleaseEvent(QMouseEvent *event) override
Gets called when the mouse has been released while in this widget.
Definition modlistview.cpp:85
void mouseMoveEvent(QMouseEvent *event) override
Gets called when the mouse has been moved while in this widget.
Definition modlistview.cpp:182
void modAdded(QList< QUrl > path)
Signals files have been dropped into this widget.
void dragLeaveEvent(QDragLeaveEvent *event) override
Enables drag leave events.
Definition modlistview.cpp:28
bool mouse_in_upper_half_of_row_
Stores if mouse is currently in the upper half of a row.
Definition modlistview.h:81
void mousePressEvent(QMouseEvent *event) override
Gets called when the mouse has been pressed while in this widget.
Definition modlistview.cpp:38
int mouse_down_row_
Last row on which a mouse button has been pressed.
Definition modlistview.h:73
void modStatusChanged(int mod_id, bool status)
Signals that a mods activation status has been changed.
bool enable_buttons_
Determines if buttons react to inputs.
Definition modlistview.h:77
void focusInEvent(QFocusEvent *event) override
Gets called when this widget gains focus. Changes highlight color to active.
Definition modlistview.cpp:218
void dragMoveEvent(QDragMoveEvent *event) override
Enables drag move events.
Definition modlistview.cpp:33
int mouse_hover_row_
Last row over which the cursor hovered.
Definition modlistview.h:75
void leaveEvent(QEvent *event) override
Gets called when the cursor leaves this widget. Resets mouse over highlighting.
Definition modlistview.cpp:201
void updateMouseDownRow(int row)
Sets mouse_down_row_ to the given row and updates the view accordingly.
Definition modlistview.cpp:119
QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
Disables moving the cursor with keyboard inputs.
Definition modlistview.cpp:223
void updateRow(int row)
Repaints the given rows.
Definition modlistview.cpp:129
ModListView(QWidget *parent=nullptr)
Simply calls QTableview's constructor with parent as argument.
Definition modlistview.cpp:11
std::vector< int > getSelectedModIds() const
Returns a vector of selected mod ids.
Definition modlistview.cpp:153
QModelIndexList getSelectedRowIndices() const
Returns one index for every selected row. Columns will be set to 0.
Definition modlistview.cpp:166
bool enableButtons() const
Returns true iff buttons in this view will react to mouse inputs.
Definition modlistview.cpp:228
void setEnableButtons(bool enabled)
Sets whether buttons in this view will react to mouse inputs.
Definition modlistview.cpp:233
bool rowIndexIsValid(int row) const
Checks if given row index refers to an existing row.
Definition modlistview.cpp:104
bool is_in_drag_drop_
Indicates if an item is currently being moved by drag and drop.
Definition modlistview.h:79
void modRemoved(int mod_id, QString name)
Signals that a mod has been removed.
int getNumSelectedRows() const
Returns the number of currently selected rows.
Definition modlistview.cpp:148
bool isInDragDrop() const
Returns true iff an item is currently being moved by drag and drop.
Definition modlistview.cpp:138
void dragEnterEvent(QDragEnterEvent *event) override
Enables drag enter events.
Definition modlistview.cpp:23
char path[256]
Path to which to extract the file.
Definition lspakfilelistentry.h:1