mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 13:33:50 +03:00
provide reset button functionality
This commit is contained in:
parent
e50d9e33a7
commit
fcfcf8ca51
@ -73,8 +73,6 @@ void ExportTemplateDialog::initButtons()
|
||||
{
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
|
||||
this, &ExportTemplateDialog::onCancel);
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked,
|
||||
this, &ExportTemplateDialog::onCancel);
|
||||
}
|
||||
|
||||
void ExportTemplateDialog::initExtractButton(const QString &tooltip)
|
||||
|
@ -79,7 +79,7 @@ void ExportTemplateHandler::init()
|
||||
m_ui->appletsTable->horizontalHeader()->setStretchLastSection(true);
|
||||
m_ui->appletsTable->verticalHeader()->setVisible(false);
|
||||
|
||||
//! Layouts
|
||||
//! Applets Model
|
||||
m_appletsProxyModel = new QSortFilterProxyModel(this);
|
||||
m_appletsProxyModel->setSourceModel(m_appletsModel);
|
||||
m_appletsProxyModel->setSortRole(Model::Applets::SORTINGROLE);
|
||||
@ -87,6 +87,10 @@ void ExportTemplateHandler::init()
|
||||
m_appletsProxyModel->sort(Model::Applets::NAMECOLUMN, Qt::AscendingOrder);
|
||||
|
||||
m_ui->appletsTable->setModel(m_appletsProxyModel);
|
||||
|
||||
//! Reset
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked,
|
||||
this, &ExportTemplateHandler::onReset);
|
||||
}
|
||||
|
||||
void ExportTemplateHandler::initDefaults()
|
||||
@ -117,6 +121,12 @@ void ExportTemplateHandler::loadViewApplets(Latte::View *view)
|
||||
m_parentDialog->setWindowTitle(i18n("Export View Template"));
|
||||
}
|
||||
|
||||
void ExportTemplateHandler::onReset()
|
||||
{
|
||||
m_appletsModel->setSelected(o_data);
|
||||
c_data = o_data;
|
||||
}
|
||||
|
||||
bool ExportTemplateHandler::dataAreChanged() const
|
||||
{
|
||||
return o_data != c_data;
|
||||
|
@ -85,6 +85,9 @@ private:
|
||||
void loadLayoutApplets(const QString &layoutName, const QString &layoutId);
|
||||
void loadViewApplets(Latte::View *view);
|
||||
|
||||
private slots:
|
||||
void onReset();
|
||||
|
||||
private:
|
||||
Dialog::ExportTemplateDialog *m_parentDialog{nullptr};
|
||||
Ui::ExportTemplateDialog *m_ui{nullptr};
|
||||
|
@ -93,6 +93,21 @@ void Applets::setData(const Latte::Data::AppletsTable &applets)
|
||||
}
|
||||
}
|
||||
|
||||
void Applets::setSelected(const Latte::Data::AppletsTable &applets)
|
||||
{
|
||||
for(int i=0; i<applets.rowCount(); ++i) {
|
||||
int pos = m_appletsTable.indexOf(applets[i].id);
|
||||
|
||||
if (pos>=0 && applets[i].isSelected != m_appletsTable[pos].isSelected) {
|
||||
QVector<int> roles;
|
||||
roles << Qt::CheckStateRole;
|
||||
|
||||
m_appletsTable[pos].isSelected = applets[i].isSelected;
|
||||
emit dataChanged(index(pos, NAMECOLUMN), index(pos, NAMECOLUMN), roles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags Applets::flags(const QModelIndex &index) const
|
||||
{
|
||||
const int column = index.column();
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
void setData(const Latte::Data::AppletsTable &applets);
|
||||
void setSelected(const Latte::Data::AppletsTable &applets);
|
||||
|
||||
private:
|
||||
void clear();
|
||||
|
Loading…
Reference in New Issue
Block a user