X-Git-Url: http://git.maemo.org/git/?p=pierogi;a=blobdiff_plain;f=dialogs%2Fpirselectmacrodialog.cpp;h=96c353f0f7f660b9f11548c6339d2da2ed6c2cfc;hp=6d58a3a184d2b027de4250c5a849350b2bd83437;hb=afbbd0cd07a3f63c95969633bae56fcdd58c71b8;hpb=6331b1b21bde2a80e6a0895d9cce865c8b558bc5 diff --git a/dialogs/pirselectmacrodialog.cpp b/dialogs/pirselectmacrodialog.cpp index 6d58a3a..96c353f 100644 --- a/dialogs/pirselectmacrodialog.cpp +++ b/dialogs/pirselectmacrodialog.cpp @@ -2,8 +2,13 @@ #include "ui_pirselectmacrodialog.h" #include "macros/pirmacropack.h" +#include "macros/pirmacro.h" #include "macros/pirreversemultitap.h" #include "mainwindow.h" +#include + +// Debugging includes: +#include /* PIRSelectMacroDialog::PIRSelectMacroDialog(QWidget *parent) : @@ -15,25 +20,30 @@ 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); } @@ -65,3 +75,58 @@ void PIRSelectMacroDialog::on_buttonBox_rejected() } */ + +void PIRSelectMacroDialog::on_newButton_clicked() +{ + emit newMacroRequested(); + accept(); +} + + +void PIRSelectMacroDialog::on_editButton_clicked() +{ + // Find the first selected macro, if any: + QList 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 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)); +}