yhkylin-backup-tools/kybackup/component/backuplistwidget.h

51 lines
1.3 KiB
C++
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef REMOVABLELISTWIDGET_H
#define REMOVABLELISTWIDGET_H
#include <QListWidget>
#include <QStringList>
#include <QDropEvent>
#include "myiconlabel.h"
class BackupListWidget : public QListWidget
{
Q_OBJECT
public:
explicit BackupListWidget(QWidget *parent = nullptr);
virtual ~BackupListWidget();
// 添加列表项注意使用本类的功能不能用addItem等基类添加项的方法
bool appendItem(const QString &text);
// 根据QListWidgetItem*查找项对应的索引序号
int findIndexOfItem(QListWidgetItem *item);
// 判断列表项是否包含text注意使用时不能用findItems等基类查找方法
bool contains(const QString &text);
// 获取备份路径列表
QStringList getBackupPaths() { return m_List; }
// 设置备份路径限制为只能是pathLimit或其子路径
void setPathLimit(const QStringList &pathLimit) { m_pathLimit.append(pathLimit); }
// 清空
void clearData() {
this->clear();
m_List.clear();
}
protected:
void dropEvent(QDropEvent *e);
private:
bool checkPathLimit(const QString &path);
private:
MyIconLabel *m_plusLogo;
int m_type = QListWidgetItem::ItemType::UserType + 1;
QStringList m_List;
QStringList m_pathLimit;
};
#endif // REMOVABLELISTWIDGET_H