krita/ui
kis_bookmarked_configurations_editor.ccGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "kis_bookmarked_configurations_editor.h"
00020 #include "ui_wdgbookmarkedconfigurationseditor.h"
00021
00022 #include "kis_bookmarked_configurations_model.h"
00023
00024 struct KisBookmarkedConfigurationsEditor::Private {
00025 Ui_WdgBookmarkedConfigurationsEditor editorUi;
00026 KisBookmarkedConfigurationsModel* model;
00027 const KisSerializableConfiguration* currentConfig;
00028 };
00029
00030
00031 KisBookmarkedConfigurationsEditor::KisBookmarkedConfigurationsEditor(QWidget* parent, KisBookmarkedConfigurationsModel* model, const KisSerializableConfiguration* currentConfig) : QDialog(parent), d(new Private)
00032 {
00033 d->editorUi.setupUi(this);
00034 d->model = model;
00035 d->currentConfig = currentConfig;
00036 d->editorUi.listConfigurations->setModel(d->model);
00037 connect(d->editorUi.pushButtonClose, SIGNAL(pressed()), SLOT(accept()));
00038
00039 connect(d->editorUi.listConfigurations->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
00040 this, SLOT(currentConfigChanged(const QItemSelection&, const QItemSelection&)));
00041 currentConfigChanged(d->editorUi.listConfigurations->selectionModel()->selection(),
00042 d->editorUi.listConfigurations->selectionModel()->selection());
00043
00044 connect(d->editorUi.pushButtonDelete, SIGNAL(pressed()), SLOT(deleteConfiguration()));
00045 connect(d->editorUi.pushButtonBookmarkCurrent, SIGNAL(pressed()), SLOT(addCurrentConfiguration()));
00046
00047 if (!d->currentConfig) {
00048 d->editorUi.pushButtonBookmarkCurrent->setEnabled(false);
00049 }
00050 }
00051
00052 KisBookmarkedConfigurationsEditor::~KisBookmarkedConfigurationsEditor()
00053 {
00054 delete d;
00055 }
00056
00057 void KisBookmarkedConfigurationsEditor::currentConfigChanged(const QItemSelection& selected, const QItemSelection&)
00058 {
00059 if (d->model) {
00060 d->editorUi.pushButtonDelete->setEnabled(!(selected.indexes().isEmpty()) ?
00061 d->model->isIndexDeletable(selected.indexes().first()) :
00062 false);
00063 }
00064 }
00065
00066 void KisBookmarkedConfigurationsEditor::addCurrentConfiguration()
00067 {
00068 if (d->model) {
00069 d->model->newConfiguration(ki18n("New configuration %1"), d->currentConfig);
00070 }
00071 }
00072
00073 void KisBookmarkedConfigurationsEditor::deleteConfiguration()
00074 {
00075 if (d->model) {
00076 d->model->deleteIndex(d->editorUi.listConfigurations->currentIndex());
00077 }
00078 }
00079
00080 #include "kis_bookmarked_configurations_editor.moc"
|