Skip to content

Commit

Permalink
Add documentation to gui/widgets/delegates/
Browse files Browse the repository at this point in the history
  • Loading branch information
KraTuX31 committed Mar 14, 2015
1 parent 0784240 commit fcf982d
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 80 deletions.
2 changes: 1 addition & 1 deletion fact-team.github.io
2 changes: 1 addition & 1 deletion src/gui/widgets/contributorieswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void ContributoriesWidget::updateUi()
_modelProjects->getSelectedProjects().count()
< ((Delegates::ProjectComboDelegate*)
ui->tblProjects->itemDelegateForColumn(0))->getProjects().count()
&& _modelProjects->allProjectsChose());
&& _modelProjects->allProjectsChosen());

ui->btnRemoveProject->setEnabled(
ui->tblProjects->currentIndex().row() != -1);
Expand Down
50 changes: 30 additions & 20 deletions src/gui/widgets/delegates/comboboxdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,59 @@ class ComboBoxDelegate : public QItemDelegate
ComboBoxDelegate(QObject* parent=0);

/**
* @brief ComboBoxDelegate::createEditor
* @param parent
* @param option
* @param index
* @return
* @brief ComboBoxDelegate::createEditor Return a ComboBox specified by
* <i>index</i> item defined by the <i>parent</i> widget and style
* <i>option</i> which are used to control how the editor widgets appears
* @param parent Widget parent
* @param option Option style
* @param index Index for editing
* @return ComboBox
*/
virtual QWidget *createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const = 0;

/**
* @brief ComboBoxDelegate::paint
* @param painter
* @param option
* @param index
* @brief ComboBoxDelegate::paint Renders the delegate using the given
* <i>painter</i> and style <i>option</i> for the item specified by
* <i>index</i>
*@param parent Widget parent
* @param option Option style
* @param index Index for editing
*/
void paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const = 0;

/**
* @brief ComboBoxDelegate::setEditorData
* @param editor
* @param index
* @brief ComboBoxDelegate::setEditorData Sets the data to be displayed and
* edited by the <i>editor</i> from the data model item specified by the
* model <i>index</i>
* @param editor Data edited
* @param index Index of the model to edit
*/
void setEditorData(QWidget *editor, const QModelIndex &index) const;

/**
* @brief ComboBoxDelegate::setModelData
* @param editor
* @param model
* @param index
* @brief ComboBoxDelegate::setModelData Gets data from the <i>editor</i>
* widget and stores it in the specified <i>model</i> at the item
* <i>index</i>
* @param editor Editor Widget
* @param model Model to store data
* @param index Item index
*/
void setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const;

/**
* @brief ComboBoxDelegate::updateEditorGeometry
* @param editor
* @param option
* @param index
* @brief ComboBoxDelegate::updateEditorGeometry Update the <i>editor</i>
* for the item specified by <i>index</i> according to the style
* <i>option</i> given.
* @param editor Editor widget to update
* @param option Style option
* @param index Item index
*/
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
Expand Down
39 changes: 23 additions & 16 deletions src/gui/widgets/delegates/doublespinboxdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,45 @@ class DoubleSpinBoxDelegate : public QItemDelegate
DoubleSpinBoxDelegate(QObject *parent = 0);

/**
* @brief DoubleSpinBoxDelegate::createEditor
* @param parent
* @param option
* @param index
* @return
* @brief DoubleSpinBoxDelegate::createEditor Return a ComboBox specified
* by <i>index</i> item defined by the <i>parent</i> widget and style
* <i>option</i> which are used to control how the editor widgets appears
* @param parent Widget parent
* @param option Option style
* @param index Index for editing
* @return DoubleSpinBoxDelegate
*/
QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;

/**
* @brief DoubleSpinBoxDelegate::setEditorData
* @param editor
* @param index
* @brief DoubleSpinBoxDelegate::setEditorData Sets the data to be
* displayed and edited by the <i>editor</i> from the data model item
* specified by the model <i>index</i>
* @param editor Data edited
* @param index Index of the model to edit
*/
void setEditorData(QWidget *editor, const QModelIndex &index) const;

/**
* @brief DoubleSpinBoxDelegate::setModelData
* @param editor
* @param model
* @param index
* @brief DoubleSpinBoxDelegate::setEditorData Sets the data to be
* displayed and edited by the <i>editor</i> from the data model item
* specified by the model <i>index</i>
* @param editor Data edited
* @param index Index of the model to edit
*/
void setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const;

/**
* @brief DoubleSpinBoxDelegate::updateEditorGeometry
* @param editor
* @param option
* @param index
* @brief DoubleSpinBoxDelegate::updateEditorGeometry Update the
* <i>editor</i> for the item specified by <i>index</i> according to the
* style <i>option</i> given.
* @param editor Editor widget to update
* @param option Style option
* @param index Item index
*/
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
Expand Down
24 changes: 17 additions & 7 deletions src/gui/widgets/delegates/projectcombodelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ namespace Gui {
namespace Widgets {
namespace Delegates {

ProjectComboDelegate::ProjectComboDelegate(QSharedPointer<Models::Customer> c, QObject *parent) : ComboBoxDelegate(parent)
ProjectComboDelegate::ProjectComboDelegate(
QSharedPointer<Models::Customer> c, QObject *parent)
: ComboBoxDelegate(parent)
{
_projects = Databases::ProjectDatabase::instance()->getProjectsOfCustomer(c);
_projects =
Databases::ProjectDatabase::instance()->getProjectsOfCustomer(c);
_locked = false;
}

QWidget *ProjectComboDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */,
const QModelIndex & index) const
QWidget *ProjectComboDelegate::createEditor(
QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex & index) const
{
if(_locked && index.model()->data(index, Qt::EditRole).toUInt() != 0) {
return 0;
Expand All @@ -31,14 +36,19 @@ QWidget *ProjectComboDelegate::createEditor(QWidget *parent, const QStyleOptionV
return editor;
}

void ProjectComboDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
void ProjectComboDelegate::paint(
QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyleOptionViewItemV4 myOption = option;
int value = index.model()->data(index, Qt::EditRole).toInt();
QString text = _projects[value].getName();
myOption.text = text;

QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &myOption, painter);
QApplication::style()->drawControl(QStyle::CE_ItemViewItem,
&myOption,
painter);
}

void ProjectComboDelegate::removeInCombo(QList<int> &l)
Expand All @@ -55,7 +65,7 @@ void ProjectComboDelegate::setLocked(bool locked)
_locked = locked;
}

bool ProjectComboDelegate::getLocked() const
bool ProjectComboDelegate::isLocked() const
{
return _locked;
}
Expand Down
53 changes: 31 additions & 22 deletions src/gui/widgets/delegates/projectcombodelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,62 @@ Q_OBJECT
ProjectComboDelegate(QSharedPointer<Models::Customer> c, QObject* parent=0);

/**
* @brief ProjectComboDelegate::createEditor
* @param parent
* @param option
* @param index
* @return
* @brief ProjectComboDelegate:createEditor Return a ComboBox specified by
* <i>index</i> item defined by the <i>parent</i> widget and style
* <i>option</i> which are used to control how the editor widgets appears
* @param parent Widget parent
* @param option Option style
* @param index Index for editing
* @return ComboBox
*/
QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;

/**
* @brief ProjectComboDelegate::paint
* @param painter
* @param option
* @param index
* @brief ProjectComboDelegate::paint Renders the delegate using the given
* <i>painter</i> and style <i>option</i> for the item specified by
* <i>index</i>
*@param parent Widget parent
* @param option Option style
* @param index Index for editing
*/
void paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;

/**
* @brief ProjectComboDelegate::removeInCombo
* @brief ProjectComboDelegate::removeInCombo Remove the items contained in
* the list <i>l</i> into the current ComboBox
*/
void removeInCombo(QList<int>&);
void removeInCombo(QList<int>&l);

/**
* @brief ProjectComboDelegate::getProjects
* @return
* @brief ProjectComboDelegate::getProjects Return a list of projects
* linked to a Customer ID
* @return Projets of a Customer
*/
QMap<int, Models::Project> getProjects() const;

/**
* @brief ProjectComboDelegate::getLocked
* @return
* @brief ProjectComboDelegate::isLocked Return TRUE if is locked else
* FALSE
* @return boolean
*/
bool getLocked() const;
bool isLocked() const;

/**
* @brief ProjectComboDelegate::setLocked
* @param getLlocked
* @brief ProjectComboDelegate::setLocked Change the state of the lock by a
* new value <i>locked</i>
* @param locked
*/
void setLocked(bool getLlocked);
void setLocked(bool locked);

private:
QMap<int, Models::Project> _projects; //!<
QList<int> _removeInCombo; //!<
bool _locked; //!<
QMap<int, Models::Project> _projects; /** List of projects linked to an
Customer ID */
QList<int> _removeInCombo; //!< Items to remove in the current ComboBox
bool _locked; //!< element is locked
};
}
}
Expand Down
22 changes: 13 additions & 9 deletions src/gui/widgets/delegates/unitcombodelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,25 @@ class UnitComboDelegate : public ComboBoxDelegate
UnitComboDelegate(QObject* parent=0);

/**
* @brief UnitComboDelegate::createEditor
* @param parent
* @param option
* @param index
* @return
* @brief UnitComboDelegate::createEditor Return a ComboBox specified by
* <i>index</i> item defined by the <i>parent</i> widget and style
* <i>option</i> which are used to control how the editor widgets appears
* @param parent Widget parent
* @param option Option style
* @param index Index for editing
* @return ComboBox
*/
QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;

/**
* @brief UnitComboDelegate::paint
* @param painter
* @param option
* @param index
* @brief UnitComboDelegate::paint Renders the delegate using the given
* <i>painter</i> and style <i>option</i> for the item specified by
* <i>index</i>
*@param parent Widget parent
* @param option Option style
* @param index Index for editing
*/
void paint(QPainter *painter,
const QStyleOptionViewItem &option,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ProjectContributoriesTableModel : public QAbstractTableModel
* all projects have been selected else FALSE
* @return boolean All projects selected
*/
bool allProjectsChose();
bool allProjectsChosen();

/**
* @brief ProjectContributoriesTableModel::getSelectedProjects Return the
Expand Down
2 changes: 1 addition & 1 deletion src/models/contributorieslist.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ContributoriesList

private:
int _idBilling; //!< Billing ID
bool _insert; //!< an element is inserting
bool _insert; //!< an element is inserted
};
}
#endif // CONTRIBUTORIESLIST_H
2 changes: 1 addition & 1 deletion tests/QTestRunner
Submodule QTestRunner updated 1 files
+1 −6 main.cpp

0 comments on commit fcf982d

Please sign in to comment.