Fixes: Start a git branch dialog.

This commit is contained in:
Friedemann Kleint
2008-12-19 17:42:08 +01:00
parent 12bcc11389
commit defc270896
9 changed files with 596 additions and 10 deletions

View File

@@ -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