#include "ui_pirselectmacrodialog.h"
#include "macros/pirmacropack.h"
+#include "macros/pirmacro.h"
#include "macros/pirreversemultitap.h"
#include "mainwindow.h"
+#include <QMaemo5InformationBox>
+
+// Debugging includes:
+#include <iostream>
/*
PIRSelectMacroDialog::PIRSelectMacroDialog(QWidget *parent) :
*/
-PIRSelectMacroDialog::PIRSelectMacroDialog(
- MainWindow *mw)
- : QDialog(mw),
+PIRSelectMacroDialog::PIRSelectMacroDialog()
+ : QDialog(0),
ui(new Ui::PIRSelectMacroDialog)
-// mainWindow(mw)
{
ui->setupUi(this);
-
- userPack = new PIRMacroPack(ui->macroTreeWidget, "User Defined Macros");
- multitapPack = new PIRReverseMultitap(ui->macroTreeWidget, mw);
}
PIRSelectMacroDialog::~PIRSelectMacroDialog()
{
+ // This is a hack to get around object ownership issues:
+ while (ui->macroTreeWidget->topLevelItemCount())
+ {
+ ui->macroTreeWidget->takeTopLevelItem(0);
+ }
+
delete ui;
+}
- delete userPack;
- delete multitapPack;
+
+void PIRSelectMacroDialog::addPack(
+ PIRMacroPack *pack)
+{
+ ui->macroTreeWidget->addTopLevelItem(pack);
}
}
*/
+
+void PIRSelectMacroDialog::on_newButton_clicked()
+{
+ emit newMacroRequested();
+ accept();
+}
+
+
+void PIRSelectMacroDialog::on_editButton_clicked()
+{
+ // Find the first selected macro, if any:
+ QList<QTreeWidgetItem *> items = ui->macroTreeWidget->selectedItems();
+
+ if (items.size() > 0)
+ {
+ if (items[0]->parent() == 0)
+ {
+ QMaemo5InformationBox::information(0, "Cannot Edit MacroPacks");
+ }
+ else
+ {
+ emit editMacroRequested(items[0]);
+ }
+ }
+
+ accept();
+}
+
+
+void PIRSelectMacroDialog::on_deleteButton_clicked()
+{
+ // Find the first selected macro, if any:
+ QList<QTreeWidgetItem *> items = ui->macroTreeWidget->selectedItems();
+
+ if (items.size() > 0)
+ {
+ if (items[0]->parent() == 0)
+ {
+ QMaemo5InformationBox::information(0, "Cannot Delete MacroPacks");
+ }
+ else
+ {
+ emit deleteMacroRequested(items[0]);
+ }
+ }
+
+ accept();
+}
+
+
+void PIRSelectMacroDialog::resetIndices()
+{
+ ui->macroTreeWidget->setCurrentItem(
+ ui->macroTreeWidget->topLevelItem(0));
+}