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

Add support for custom

parent 1b42ce45
cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.13.40")
set(PIM_VERSION "5.13.41")
project(pimcommon VERSION ${PIM_VERSION})
......
......@@ -75,6 +75,7 @@ public:
QPushButton *mModifyButton = nullptr;
QPushButton *mUpButton = nullptr;
QPushButton *mDownButton = nullptr;
QPushButton *mCustomButton = nullptr;
QVBoxLayout *mButtonLayout = nullptr;
QString mAddDialogLabel;
QString mRemoveDialogLabel;
......@@ -129,6 +130,7 @@ SimpleStringListEditor::SimpleStringListEditor(QWidget *parent, ButtonCode butto
connect(d->mListBox, &QListWidget::itemDoubleClicked, this, &SimpleStringListEditor::slotModify);
}
if (buttons & Remove) {
if (removeLabel.isEmpty()) {
d->mRemoveButton = new QPushButton(i18n("&Remove"), this);
......@@ -167,6 +169,14 @@ SimpleStringListEditor::SimpleStringListEditor(QWidget *parent, ButtonCode butto
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
connect(d->mListBox, &QListWidget::currentItemChanged, this, &SimpleStringListEditor::slotSelectionChanged);
......@@ -242,6 +252,12 @@ void SimpleStringListEditor::setButtonText(ButtonCode button, const QString &tex
}
d->mModifyButton->setText(text);
return;
case Custom:
if (!d->mCustomButton) {
break;
}
d->mCustomButton->setText(text);
return;
case Up:
case Down:
qCDebug(PIMCOMMON_LOG) << "SimpleStringListEditor: Cannot change text of"
......@@ -287,6 +303,16 @@ void SimpleStringListEditor::slotAdd()
addNewEntry();
}
void SimpleStringListEditor::slotCustomize()
{
customEntry();
}
void SimpleStringListEditor::customEntry()
{
//TODO
}
void SimpleStringListEditor::slotRemove()
{
const QList<QListWidgetItem *> selectedItems = d->mListBox->selectedItems();
......
......@@ -59,12 +59,13 @@ class PIMCOMMON_EXPORT SimpleStringListEditor : public QWidget
Q_OBJECT
public:
enum ButtonCode {
None = 0x00,
Add = 0x01,
Remove = 0x02,
Modify = 0x04,
Up = 0x08,
Down = 0x10,
None = 0,
Add = 1,
Remove = 2,
Modify = 4,
Up = 8,
Down = 16,
Custom = 32,
All = Add | Remove | Modify | Up | Down,
Unsorted = Add | Remove | Modify
};
......@@ -90,6 +91,8 @@ public:
Q_REQUIRED_RESULT QSize sizeHint() const override;
virtual void addNewEntry();
virtual void customEntry();
Q_REQUIRED_RESULT virtual QString modifyEntry(const QString &text);
void setAddDialogLabel(const QString &addDialogLabel);
......@@ -110,6 +113,7 @@ protected Q_SLOTS:
void slotModify();
void slotUp();
void slotDown();
void slotCustomize();
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