diff options
author | Friedemann Kleint <[email protected]> | 2008-12-19 17:42:08 +0100 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2008-12-19 17:42:08 +0100 |
commit | defc270896bfc852faa7cad19b154a314b2661e7 (patch) | |
tree | dc2efbdbefb534c56eaf91fca2356388eab56804 /src/plugins/git/branchmodel.h | |
parent | 12bcc11389ff7946615ea306dd9a70c7eebbf8bc (diff) |
Fixes: Start a git branch dialog.
Diffstat (limited to 'src/plugins/git/branchmodel.h')
-rw-r--r-- | src/plugins/git/branchmodel.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/plugins/git/branchmodel.h b/src/plugins/git/branchmodel.h new file mode 100644 index 00000000000..5083a1c377c --- /dev/null +++ b/src/plugins/git/branchmodel.h @@ -0,0 +1,58 @@ +#ifndef BRANCHMODEL_H +#define BRANCHMODEL_H + +#include <QtCore/QAbstractListModel> +#include <QtCore/QList> + +namespace Git { + namespace Internal { + +class GitClient; + +/* A model to list git branches in a simple list of branch names. Local + * branches will have a read-only checkbox indicating the current one. The + * [delayed] tooltip describes the latest commit. */ + +class BranchModel : public QAbstractListModel { +public: + enum Type { LocalBranches, RemoteBranches }; + + explicit BranchModel(GitClient *client, + Type type = LocalBranches, + QObject *parent = 0); + + bool refresh(const QString &workingDirectory, QString *errorMessage); + + int currentBranch() const; + QString branchName(int row) const; + + // QAbstractListModel + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + +private: + QString toolTip(const QString &sha) const; + + struct Branch { + bool parse(const QString &line, bool *isCurrent); + + QString name; + QString currentSHA; + mutable QString toolTip; + }; + typedef QList<Branch> BranchList; + + const Type m_type; + const Qt::ItemFlags m_flags; + GitClient *m_client; + + QString m_workingDirectory; + BranchList m_branches; + int m_currentBranch; +}; + +} +} + +#endif // BRANCHMODEL_H |