1 #include "pirselectmacrodialog.h"
2 #include "ui_pirselectmacrodialog.h"
4 #include "macros/pirmacropack.h"
5 #include "macros/pirmacro.h"
6 #include "macros/pirreversemultitap.h"
7 #include "mainwindow.h"
8 #include <QMaemo5InformationBox>
10 // Debugging includes:
14 PIRSelectMacroDialog::PIRSelectMacroDialog(QWidget *parent) :
16 ui(new Ui::PIRSelectMacroDialog)
23 PIRSelectMacroDialog::PIRSelectMacroDialog()
25 ui(new Ui::PIRSelectMacroDialog)
31 PIRSelectMacroDialog::~PIRSelectMacroDialog()
33 // This is a hack to get around object ownership issues:
34 while (ui->macroTreeWidget->topLevelItemCount())
36 ui->macroTreeWidget->takeTopLevelItem(0);
43 void PIRSelectMacroDialog::addPack(
46 ui->macroTreeWidget->addTopLevelItem(pack);
50 void PIRSelectMacroDialog::on_buttonBox_accepted()
52 // Try to find a usable macro in the list of selected items. (There should
53 // only be one item in the list anyway.)
54 QList<QTreeWidgetItem *> items = ui->macroTreeWidget->selectedItems();
57 int size = items.size();
61 if (items[index]->parent() != 0)
63 emit macroChosen(items[index]);
73 void PIRSelectMacroDialog::on_buttonBox_rejected()
79 void PIRSelectMacroDialog::on_newButton_clicked()
81 emit newMacroRequested();
86 void PIRSelectMacroDialog::on_editButton_clicked()
88 // Find the first selected macro, if any:
89 QList<QTreeWidgetItem *> items = ui->macroTreeWidget->selectedItems();
93 if (items[0]->parent() == 0)
95 QMaemo5InformationBox::information(0, "Cannot Edit MacroPacks");
99 emit editMacroRequested(items[0]);
107 void PIRSelectMacroDialog::on_deleteButton_clicked()
109 // Find the first selected macro, if any:
110 QList<QTreeWidgetItem *> items = ui->macroTreeWidget->selectedItems();
112 if (items.size() > 0)
114 if (items[0]->parent() == 0)
116 QMaemo5InformationBox::information(0, "Cannot Delete MacroPacks");
120 emit deleteMacroRequested(items[0]);
128 void PIRSelectMacroDialog::resetIndices()
130 ui->macroTreeWidget->setCurrentItem(
131 ui->macroTreeWidget->topLevelItem(0));