Browse Source

add some methode on xinxlistwidgetimpl

master
Ulrich Van Den Hekke 10 years ago
parent
commit
63668db8af
  1. 16
      components/xinxlistwidgetimpl.cpp
  2. 7
      components/xinxlistwidgetimpl.h
  3. 5
      plugins/generix/docks/dictionary/addmodifylabeldialog.ui

16
components/xinxlistwidgetimpl.cpp

@ -93,6 +93,8 @@ void XinxListWidgetImplPrivate::on_m_btnAdd_clicked()
_ui->m_btnDef->setEnabled(_ui->m_list->count() > 0);
_ui->m_btnUp->setEnabled(_ui->m_list->currentRow() > 0);
_ui->m_btnDown->setEnabled((_ui->m_list->currentRow() >= 0) && (_ui->m_list->currentRow() < _ui->m_list->count() - 1));
emit _parent->itemAdded(item->text());
}
}
@ -100,12 +102,15 @@ void XinxListWidgetImplPrivate::on_m_btnDel_clicked()
{
Q_ASSERT(_ui->m_list->currentRow() >= 0);
QString value = _ui->m_list->currentItem()->text();
delete _ui->m_list->currentItem();
_ui->m_btnDel->setEnabled(_ui->m_list->count() > 0);
_ui->m_btnDef->setEnabled(_ui->m_list->count() > 0);
_ui->m_btnUp->setEnabled(_ui->m_list->currentRow() > 0);
_ui->m_btnDown->setEnabled((_ui->m_list->currentRow() >= 0) && (_ui->m_list->currentRow() < _ui->m_list->count() - 1));
emit _parent->itemRemoved(value);
}
void XinxListWidgetImplPrivate::on_m_btnUp_clicked()
@ -116,6 +121,8 @@ void XinxListWidgetImplPrivate::on_m_btnUp_clicked()
QListWidgetItem * item = _ui->m_list->takeItem(_ui->m_list->currentRow());
_ui->m_list->insertItem(row - 1, item);
_ui->m_list->setCurrentItem(item);
emit _parent->itemMoved(row, row - 1);
}
void XinxListWidgetImplPrivate::on_m_btnDown_clicked()
@ -126,6 +133,8 @@ void XinxListWidgetImplPrivate::on_m_btnDown_clicked()
QListWidgetItem * item = _ui->m_list->takeItem(_ui->m_list->currentRow());
_ui->m_list->insertItem(row + 1, item);
_ui->m_list->setCurrentItem(item);
emit _parent->itemMoved(row, row + 1);
}
void XinxListWidgetImplPrivate::on_m_list_currentRowChanged(int row)
@ -304,6 +313,13 @@ void XinxListWidgetImpl::setValues(const QStringList & values)
d->updateDefault(def);
}
//! Remove all element of the list. Update the default value to blank too.
void XinxListWidgetImpl::clear()
{
d->_ui->m_list->clear();
d->m_defaultValue = -1;
}
//! Add a value in the list
void XinxListWidgetImpl::add(const QString & value)
{

7
components/xinxlistwidgetimpl.h

@ -53,15 +53,20 @@ public:
QStringList values() const;
void setValues(const QStringList & values);
void add(const QString & value);
void clear();
QString defaultProposedValue() const;
void setDefaultProposedValue(const QString & value);
void add(const QString & value);
QString currentItem() const;
signals:
void defaultValueChanged(QString value);
void currentRowChanged(int value);
void itemChanged(const QString & text);
void itemAdded(const QString & value);
void itemRemoved(const QString & value);
void itemMoved(int orig, int dest);
protected:
virtual QString addNewValue();
private:

5
plugins/generix/docks/dictionary/addmodifylabeldialog.ui

@ -2,6 +2,9 @@
<ui version="4.0">
<class>AddModifyLabelDialog</class>
<widget class="QDialog" name="AddModifyLabelDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
@ -11,7 +14,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Adding/Modify dictionary label</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">

Loading…
Cancel
Save