diff options
author | Richard Maudsley <richard.maudsley@isode.com> | 2014-07-16 13:47:27 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2014-07-29 09:48:04 (GMT) |
commit | 4ab20a452e0af56c7ee210f863aeae31450954cc (patch) | |
tree | be0a3777eb7bd814e4c6b9660a77dbb8fafb90d3 /Swift/QtUI | |
parent | 9c5c731845881996f45b32ea6de12e0647f4634d (diff) | |
download | swift-contrib-4ab20a452e0af56c7ee210f863aeae31450954cc.zip swift-contrib-4ab20a452e0af56c7ee210f863aeae31450954cc.tar.bz2 |
Add ability to reorder highlight rules list.
Test-Information:
Add several highlight rules. Verify that the up and down buttons reorder the items in the list.
Change-Id: I6272799e2b2767ddfa01068c2ffcd1fb4651e11d
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.cpp | 22 | ||||
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.h | 3 |
2 files changed, 21 insertions, 4 deletions
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp index 8488d7d..134155c 100644 --- a/Swift/QtUI/QtHighlightEditor.cpp +++ b/Swift/QtUI/QtHighlightEditor.cpp @@ -69,21 +69,21 @@ QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* pare connect(ui_.noColorRadio, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.customColorRadio, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.noSoundRadio, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.defaultSoundRadio, SIGNAL(clicked()), SLOT(widgetClick())); connect(ui_.customSoundRadio, SIGNAL(clicked()), SLOT(widgetClick())); /* allow selection of a custom sound file */ connect(ui_.soundFileButton, SIGNAL(clicked()), SLOT(selectSoundFile())); - /* if these are not needed, then they should be removed */ - ui_.moveUpButton->setVisible(false); - ui_.moveDownButton->setVisible(false); + /* allowing reordering items */ + connect(ui_.moveUpButton, SIGNAL(clicked()), this, SLOT(onUpButtonClicked())); + connect(ui_.moveDownButton, SIGNAL(clicked()), this, SLOT(onDownButtonClicked())); setWindowTitle(tr("Highlight Rules")); } QtHighlightEditor::~QtHighlightEditor() { } std::string formatShortDescription(const HighlightRule &rule) @@ -189,18 +189,34 @@ void QtHighlightEditor::onDeleteButtonClicked() } else { if (selectedRow == ui_.listWidget->count()) { selectRow(ui_.listWidget->count() - 1); } else { selectRow(selectedRow); } } } +void QtHighlightEditor::onUpButtonClicked() { + const size_t moveFrom = ui_.listWidget->currentRow(); + const size_t moveTo = moveFrom - 1; + highlightManager_->swapRules(moveFrom, moveTo); + populateList(); + selectRow(moveTo); +} + +void QtHighlightEditor::onDownButtonClicked() { + const size_t moveFrom = ui_.listWidget->currentRow(); + const size_t moveTo = moveFrom + 1; + highlightManager_->swapRules(moveFrom, moveTo); + populateList(); + selectRow(moveTo); +} + void QtHighlightEditor::onCurrentRowChanged(int currentRow) { ui_.deleteButton->setEnabled(currentRow != -1); ui_.moveUpButton->setEnabled(currentRow != -1 && currentRow != 0); ui_.moveDownButton->setEnabled(currentRow != -1 && currentRow != (ui_.listWidget->count()-1)); if (previousRow_ != -1) { if (ui_.listWidget->count() > previousRow_) { highlightManager_->setRule(previousRow_, ruleFromDialog()); diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h index c7db464..e0595ad 100644 --- a/Swift/QtUI/QtHighlightEditor.h +++ b/Swift/QtUI/QtHighlightEditor.h @@ -34,32 +34,33 @@ namespace Swift { virtual void setContactSuggestions(const std::vector<Contact::ref>& suggestions); private slots: void colorOtherSelect(); void colorCustomSelect(); void soundOtherSelect(); void soundCustomSelect(); void onNewButtonClicked(); void onDeleteButtonClicked(); + void onUpButtonClicked(); + void onDownButtonClicked(); void onCurrentRowChanged(int currentRow); void onApplyButtonClick(); void onCancelButtonClick(); void onOkButtonClick(); void setChildWidgetStates(); void widgetClick(); void disableDialog(); void handleContactSuggestionRequested(const QString& text); void selectSoundFile(); private: void handleOnUserSelected(const JID& jid); void populateList(); - void updateChatPreview(); void selectRow(int row); int getSelectedRow() const; HighlightRule ruleFromDialog(); void ruleToDialog(const HighlightRule& rule); Ui::QtHighlightEditor ui_; QtSettingsProvider* settings_; HighlightManager* highlightManager_; QtSuggestingJIDInput* jid_; |