Skip to content
Snippets Groups Projects
Commit 611df80e authored by hjk's avatar hjk
Browse files

code cosmetics

parent 5f5d6c20
No related branches found
No related tags found
No related merge requests found
...@@ -40,10 +40,10 @@ class HistoryListModel : public QAbstractListModel ...@@ -40,10 +40,10 @@ class HistoryListModel : public QAbstractListModel
public: public:
HistoryListModel(HistoryCompleter *parent); HistoryListModel(HistoryCompleter *parent);
void fetchHistory(); void fetchHistory();
int rowCount(const QModelIndex & parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data( const QModelIndex & index, int role = Qt::DisplayRole) const; QVariant data( const QModelIndex &index, int role = Qt::DisplayRole) const;
void clearHistory(); void clearHistory();
void saveEntry(const QString & str); void saveEntry(const QString &str);
QStringList list; QStringList list;
HistoryCompleter *q; HistoryCompleter *q;
...@@ -76,7 +76,7 @@ void HistoryListModel::fetchHistory() ...@@ -76,7 +76,7 @@ void HistoryListModel::fetchHistory()
reset(); reset();
} }
int HistoryListModel::rowCount(const QModelIndex & parent) const int HistoryListModel::rowCount(const QModelIndex &parent) const
{ {
if (lastSeenWidget != q->widget()) { if (lastSeenWidget != q->widget()) {
if (qobject_cast<QLineEdit *>(lastSeenWidget)) if (qobject_cast<QLineEdit *>(lastSeenWidget))
...@@ -94,11 +94,13 @@ int HistoryListModel::rowCount(const QModelIndex & parent) const ...@@ -94,11 +94,13 @@ int HistoryListModel::rowCount(const QModelIndex & parent) const
return list.count(); return list.count();
} }
QVariant HistoryListModel::data(const QModelIndex & index, int role) const QVariant HistoryListModel::data(const QModelIndex &index, int role) const
{ {
if (index.row() >= list.count() || index.column() != 0 || (role != Qt::DisplayRole && role != Qt::EditRole)) if (index.row() >= list.count() || index.column() != 0)
return QVariant(); return QVariant();
return list.at(index.row()); if (role == Qt::DisplayRole || role == Qt::EditRole)
return list.at(index.row());
return QVariant();
} }
void HistoryListModel::clearHistory() void HistoryListModel::clearHistory()
...@@ -107,7 +109,7 @@ void HistoryListModel::clearHistory() ...@@ -107,7 +109,7 @@ void HistoryListModel::clearHistory()
reset(); reset();
} }
void HistoryListModel::saveEntry(const QString & str) void HistoryListModel::saveEntry(const QString &str)
{ {
if (list.contains(str)) if (list.contains(str))
return; return;
......
...@@ -39,20 +39,25 @@ QT_FORWARD_DECLARE_CLASS(QSettings) ...@@ -39,20 +39,25 @@ QT_FORWARD_DECLARE_CLASS(QSettings)
namespace Utils { namespace Utils {
class HistoryCompleterPrivate; class HistoryCompleterPrivate;
class QTCREATOR_UTILS_EXPORT HistoryCompleter : public QCompleter class QTCREATOR_UTILS_EXPORT HistoryCompleter : public QCompleter
{ {
Q_OBJECT Q_OBJECT
public: public:
HistoryCompleter(QObject *parent = 0); HistoryCompleter(QObject *parent = 0);
QSettings *settings() const; QSettings *settings() const;
int historySize() const; int historySize() const;
int maximalHistorySize() const; int maximalHistorySize() const;
void setMaximalHistorySize(int numberOfEntries); void setMaximalHistorySize(int numberOfEntries);
public Q_SLOTS: public Q_SLOTS:
void clearHistory(); void clearHistory();
void saveHistory(); void saveHistory();
protected: protected:
HistoryCompleterPrivate *d_ptr; HistoryCompleterPrivate *d_ptr;
private: private:
Q_DECLARE_PRIVATE(HistoryCompleter); Q_DECLARE_PRIVATE(HistoryCompleter);
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment