Fixes: Make git diff work for staged files, do not launch submit if file list empty, make file model read only, add conveniences

Details: Add a type data field to the git file model
This commit is contained in:
Friedemann Kleint
2009-01-13 10:06:06 +01:00
parent 278ff78040
commit 4741a7282d
14 changed files with 171 additions and 32 deletions

View File

@@ -48,20 +48,47 @@ SubmitFileModel::SubmitFileModel(QObject *parent) :
setHorizontalHeaderLabels(headerLabels);
}
QList<QStandardItem *> SubmitFileModel::addFile(const QString &fileName, const QString &status, bool checked)
QList<QStandardItem *> SubmitFileModel::createFileRow(const QString &fileName, const QString &status, bool checked)
{
if (VCSBase::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << fileName << status << checked;
QStandardItem *statusItem = new QStandardItem(status);
statusItem->setCheckable(true);
statusItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
statusItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
QStandardItem *fileItem = new QStandardItem(fileName);
fileItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
QList<QStandardItem *> row;
row << statusItem << fileItem;
return row;
}
QList<QStandardItem *> SubmitFileModel::addFile(const QString &fileName, const QString &status, bool checked)
{
const QList<QStandardItem *> row = createFileRow(fileName, status, checked);
appendRow(row);
return row;
}
QList<QStandardItem *> SubmitFileModel::rowAt(int row) const
{
const int colCount = columnCount();
QList<QStandardItem *> rc;
for (int c = 0; c < colCount; c++)
rc.push_back(item(row, c));
return rc;
}
QList<QStandardItem *> SubmitFileModel::findRow(const QString &text, int column) const
{
// Single item
const QList<QStandardItem *> items = findItems(text, Qt::MatchExactly, column);
if (items.empty())
return items;
// Compile row
return rowAt(items.front()->row());
}
unsigned SubmitFileModel::filter(const QStringList &filter, int column)
{
unsigned rc = 0;