Commit 58edad04 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add support for custom

parent 1b42ce45
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.13.40") set(PIM_VERSION "5.13.41")
project(pimcommon VERSION ${PIM_VERSION}) project(pimcommon VERSION ${PIM_VERSION})
......
...@@ -75,6 +75,7 @@ public: ...@@ -75,6 +75,7 @@ public:
QPushButton *mModifyButton = nullptr; QPushButton *mModifyButton = nullptr;
QPushButton *mUpButton = nullptr; QPushButton *mUpButton = nullptr;
QPushButton *mDownButton = nullptr; QPushButton *mDownButton = nullptr;
QPushButton *mCustomButton = nullptr;
QVBoxLayout *mButtonLayout = nullptr; QVBoxLayout *mButtonLayout = nullptr;
QString mAddDialogLabel; QString mAddDialogLabel;
QString mRemoveDialogLabel; QString mRemoveDialogLabel;
...@@ -129,6 +130,7 @@ SimpleStringListEditor::SimpleStringListEditor(QWidget *parent, ButtonCode butto ...@@ -129,6 +130,7 @@ SimpleStringListEditor::SimpleStringListEditor(QWidget *parent, ButtonCode butto
connect(d->mListBox, &QListWidget::itemDoubleClicked, this, &SimpleStringListEditor::slotModify); connect(d->mListBox, &QListWidget::itemDoubleClicked, this, &SimpleStringListEditor::slotModify);
} }
if (buttons & Remove) { if (buttons & Remove) {
if (removeLabel.isEmpty()) { if (removeLabel.isEmpty()) {
d->mRemoveButton = new QPushButton(i18n("&Remove"), this); d->mRemoveButton = new QPushButton(i18n("&Remove"), this);
...@@ -167,6 +169,14 @@ SimpleStringListEditor::SimpleStringListEditor(QWidget *parent, ButtonCode butto ...@@ -167,6 +169,14 @@ SimpleStringListEditor::SimpleStringListEditor(QWidget *parent, ButtonCode butto
connect(d->mDownButton, &QPushButton::clicked, this, &SimpleStringListEditor::slotDown); connect(d->mDownButton, &QPushButton::clicked, this, &SimpleStringListEditor::slotDown);
} }
if (buttons & Custom) {
d->mCustomButton = new QPushButton(i18n("&Customize..."), this);
d->mCustomButton->setAutoDefault(false);
d->mCustomButton->setEnabled(false); // no selection yet
d->mButtonLayout->addWidget(d->mCustomButton);
connect(d->mCustomButton, &QPushButton::clicked, this, &SimpleStringListEditor::slotCustomize);
}
d->mButtonLayout->addStretch(1); // spacer d->mButtonLayout->addStretch(1); // spacer
connect(d->mListBox, &QListWidget::currentItemChanged, this, &SimpleStringListEditor::slotSelectionChanged); connect(d->mListBox, &QListWidget::currentItemChanged, this, &SimpleStringListEditor::slotSelectionChanged);
...@@ -242,6 +252,12 @@ void SimpleStringListEditor::setButtonText(ButtonCode button, const QString &tex ...@@ -242,6 +252,12 @@ void SimpleStringListEditor::setButtonText(ButtonCode button, const QString &tex
} }
d->mModifyButton->setText(text); d->mModifyButton->setText(text);
return; return;
case Custom:
if (!d->mCustomButton) {
break;
}
d->mCustomButton->setText(text);
return;
case Up: case Up:
case Down: case Down:
qCDebug(PIMCOMMON_LOG) << "SimpleStringListEditor: Cannot change text of" qCDebug(PIMCOMMON_LOG) << "SimpleStringListEditor: Cannot change text of"
...@@ -287,6 +303,16 @@ void SimpleStringListEditor::slotAdd() ...@@ -287,6 +303,16 @@ void SimpleStringListEditor::slotAdd()
addNewEntry(); addNewEntry();
} }
void SimpleStringListEditor::slotCustomize()
{
customEntry();
}
void SimpleStringListEditor::customEntry()
{
//TODO
}
void SimpleStringListEditor::slotRemove() void SimpleStringListEditor::slotRemove()
{ {
const QList<QListWidgetItem *> selectedItems = d->mListBox->selectedItems(); const QList<QListWidgetItem *> selectedItems = d->mListBox->selectedItems();
......
...@@ -59,12 +59,13 @@ class PIMCOMMON_EXPORT SimpleStringListEditor : public QWidget ...@@ -59,12 +59,13 @@ class PIMCOMMON_EXPORT SimpleStringListEditor : public QWidget
Q_OBJECT Q_OBJECT
public: public:
enum ButtonCode { enum ButtonCode {
None = 0x00, None = 0,
Add = 0x01, Add = 1,
Remove = 0x02, Remove = 2,
Modify = 0x04, Modify = 4,
Up = 0x08, Up = 8,
Down = 0x10, Down = 16,
Custom = 32,
All = Add | Remove | Modify | Up | Down, All = Add | Remove | Modify | Up | Down,
Unsorted = Add | Remove | Modify Unsorted = Add | Remove | Modify
}; };
...@@ -90,6 +91,8 @@ public: ...@@ -90,6 +91,8 @@ public:
Q_REQUIRED_RESULT QSize sizeHint() const override; Q_REQUIRED_RESULT QSize sizeHint() const override;
virtual void addNewEntry(); virtual void addNewEntry();
virtual void customEntry();
Q_REQUIRED_RESULT virtual QString modifyEntry(const QString &text); Q_REQUIRED_RESULT virtual QString modifyEntry(const QString &text);
void setAddDialogLabel(const QString &addDialogLabel); void setAddDialogLabel(const QString &addDialogLabel);
...@@ -110,6 +113,7 @@ protected Q_SLOTS: ...@@ -110,6 +113,7 @@ protected Q_SLOTS:
void slotModify(); void slotModify();
void slotUp(); void slotUp();
void slotDown(); void slotDown();
void slotCustomize();
void slotSelectionChanged(); void slotSelectionChanged();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment