Bugfixes and Keysets
[pierogi] / dialogs / pirselectmacrodialog.cpp
1 #include "pirselectmacrodialog.h"
2 #include "ui_pirselectmacrodialog.h"
3
4 #include "macros/pirmacropack.h"
5 #include "macros/pirreversemultitap.h"
6 #include "mainwindow.h"
7
8 /*
9 PIRSelectMacroDialog::PIRSelectMacroDialog(QWidget *parent) :
10   QDialog(parent),
11   ui(new Ui::PIRSelectMacroDialog)
12 {
13   ui->setupUi(this);
14 }
15 */
16
17
18 PIRSelectMacroDialog::PIRSelectMacroDialog(
19   MainWindow *mw)
20   : QDialog(mw),
21     ui(new Ui::PIRSelectMacroDialog)
22 //    mainWindow(mw)
23 {
24   ui->setupUi(this);
25
26   userPack = new PIRMacroPack(ui->macroTreeWidget, "User Defined Macros");
27   multitapPack = new PIRReverseMultitap(ui->macroTreeWidget, mw);
28 }
29
30
31 PIRSelectMacroDialog::~PIRSelectMacroDialog()
32 {
33   delete ui;
34
35   delete userPack;
36   delete multitapPack;
37 }
38
39
40 void PIRSelectMacroDialog::on_buttonBox_accepted()
41 {
42   // Try to find a usable macro in the list of selected items.  (There should
43   // only be one item in the list anyway.)
44   QList<QTreeWidgetItem *> items = ui->macroTreeWidget->selectedItems();
45
46   int index = 0;
47   int size = items.size();
48
49   while (index < size)
50   {
51     if (items[index]->parent() != 0)
52     {
53       emit macroChosen(items[index]);
54       return;
55     }
56
57     ++index;
58   }
59 }
60
61
62 /*
63 void PIRSelectMacroDialog::on_buttonBox_rejected()
64 {
65
66 }
67 */