forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
|
||||
@@ -49,9 +49,16 @@ class VCSBASE_EXPORT SubmitFileModel : public QStandardItemModel
|
||||
public:
|
||||
explicit SubmitFileModel(QObject *parent = 0);
|
||||
|
||||
// Convenience to add a file plus status text.
|
||||
// Convenience to create and add rows containing a file plus status text.
|
||||
static QList<QStandardItem *> createFileRow(const QString &fileName, const QString &status = QString(), bool checked = true);
|
||||
QList<QStandardItem *> addFile(const QString &fileName, const QString &status = QString(), bool checked = true);
|
||||
|
||||
// Find convenience that returns the whole row (as opposed to QStandardItemModel::find).
|
||||
QList<QStandardItem *> findRow(const QString &text, int column = 0) const;
|
||||
|
||||
// Convenience to obtain a row
|
||||
QList<QStandardItem *> rowAt(int row) const;
|
||||
|
||||
// Filter for entries contained in the filter list. Returns the
|
||||
// number of deleted entries.
|
||||
unsigned filter(const QStringList &filter, int column);
|
||||
|
||||
@@ -139,6 +139,17 @@ void VCSBaseSubmitEditor::setFileNameColumn(int c)
|
||||
m_d->m_widget->setFileNameColumn(c);
|
||||
}
|
||||
|
||||
QAbstractItemView::SelectionMode VCSBaseSubmitEditor::fileListSelectionMode() const
|
||||
{
|
||||
return m_d->m_widget->fileListSelectionMode();
|
||||
}
|
||||
|
||||
void VCSBaseSubmitEditor::setFileListSelectionMode(QAbstractItemView::SelectionMode sm)
|
||||
{
|
||||
m_d->m_widget->setFileListSelectionMode(sm);
|
||||
}
|
||||
|
||||
|
||||
void VCSBaseSubmitEditor::slotDescriptionChanged()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QtGui/QAbstractItemView>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QIcon;
|
||||
@@ -92,6 +93,7 @@ class VCSBASE_EXPORT VCSBaseSubmitEditor : public Core::IEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int fileNameColumn READ fileNameColumn WRITE setFileNameColumn DESIGNABLE false)
|
||||
Q_PROPERTY(QAbstractItemView::SelectionMode fileListSelectionMode READ fileListSelectionMode WRITE setFileListSelectionMode DESIGNABLE true)
|
||||
public:
|
||||
typedef QList<int> Context;
|
||||
|
||||
@@ -105,6 +107,9 @@ public:
|
||||
int fileNameColumn() const;
|
||||
void setFileNameColumn(int c);
|
||||
|
||||
QAbstractItemView::SelectionMode fileListSelectionMode() const;
|
||||
void setFileListSelectionMode(QAbstractItemView::SelectionMode sm);
|
||||
|
||||
// Core::IEditor
|
||||
virtual bool createNew(const QString &contents);
|
||||
virtual bool open(const QString &fileName);
|
||||
|
||||
Reference in New Issue
Block a user