10 #ifndef PROFILE_MODEL_H
11 #define PROFILE_MODEL_H
18 #include <QAbstractTableModel>
19 #include <QSortFilterProxyModel>
20 #include <QLoggingCategory>
21 #include <QFileInfoList>
23 Q_DECLARE_LOGGING_CATEGORY(profileLogger)
38 void setFilterType(FilterType ft);
39 void setFilterString(QString txt = QString());
41 static QStringList filterTypes();
44 virtual bool lessThan(
const QModelIndex &source_left,
const QModelIndex &source_right)
const;
45 virtual bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent)
const;
66 DATA_STATUS = Qt::UserRole,
71 DATA_PATH_IS_NOT_DESCRIPTION,
72 DATA_INDEX_VALUE_IS_URL
76 virtual int rowCount(
const QModelIndex & parent = QModelIndex())
const;
77 virtual int columnCount(
const QModelIndex & parent = QModelIndex())
const;
78 virtual QVariant data(
const QModelIndex & idx,
int role = Qt::DisplayRole)
const;
79 virtual bool setData(
const QModelIndex &index,
const QVariant &value,
int role);
80 virtual QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const;
81 virtual Qt::ItemFlags flags(
const QModelIndex &index)
const;
83 void deleteEntry(QModelIndex idx);
84 void deleteEntries(QModelIndexList idcs);
86 int findByName(QString name);
87 QModelIndex addNewProfile(QString name);
88 QModelIndex duplicateEntry(QModelIndex idx,
int new_status = PROF_STAT_COPY);
90 void doResetModel(
bool reset_import =
false);
91 bool resetDefault()
const;
93 QModelIndex activeProfile()
const;
94 static QString activeProfileName();
95 static QString activeProfilePath();
97 GList * at(
int row)
const;
99 bool changesPending()
const;
100 bool importPending()
const;
102 bool userProfilesExist()
const;
105 bool exportProfiles(QString filename, QModelIndexList items, QString * err = Q_NULLPTR);
106 int importProfilesFromZip(QString filename,
int *skippedCnt = Q_NULLPTR, QStringList *result = Q_NULLPTR);
108 int importProfilesFromDir(QString filename,
int *skippedCnt = Q_NULLPTR,
bool fromZip =
false, QStringList *result = Q_NULLPTR);
110 static bool checkNameValidity(QString name, QString *msg = Q_NULLPTR);
111 QList<int> findAllByNameAndVisibility(QString name,
bool isGlobal =
false,
bool searchReference =
false)
const;
112 void markAsImported(QStringList importedItems);
113 bool clearImported(QString *msg = Q_NULLPTR);
115 int lastSetRow()
const;
117 bool checkInvalid(
const QModelIndex &index)
const;
118 bool checkIfDeleted(
const QModelIndex &index)
const;
119 bool checkIfDeleted(
int row)
const;
120 bool checkDuplicate(
const QModelIndex &index,
bool isOriginalToDuplicate =
false)
const;
123 void itemChanged(
const QModelIndex &idx);
126 static QString illegalCharacters();
129 QList<profile_def *> profiles_;
130 QStringList profile_files_;
131 QString set_profile_;
133 bool profiles_imported_;
138 profile_def * guard(
const QModelIndex &index)
const;
142 int findByNameAndVisibility(QString name,
bool isGlobal =
false,
bool searchReference =
false)
const;
143 int findAsReference(QString reference)
const;
146 static bool acceptFile(QString fileName,
int fileSize);
147 static QString cleanName(QString fileName);
150 QVariant dataDisplay(
const QModelIndex & idx)
const;
151 QVariant dataFontRole(
const QModelIndex & idx)
const;
152 QVariant dataBackgroundRole(
const QModelIndex & idx)
const;
153 QVariant dataToolTipRole(
const QModelIndex & idx)
const;
154 QVariant dataPath(
const QModelIndex & idx)
const;
157 QStringList exportFileList(QModelIndexList items);
159 bool copyTempToProfile(QString tempPath, QString profilePath,
bool *wasEmpty = Q_NULLPTR);
160 QFileInfoList filterProfilePath(QString, QFileInfoList ent,
bool fromZip);
161 QFileInfoList uniquePaths(QFileInfoList lst);
Definition: profile_model.h:53
Definition: profile_model.h:26