Diffstat (limited to 'noncore/unsupported/qashmoney/memorydialog.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/unsupported/qashmoney/memorydialog.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/noncore/unsupported/qashmoney/memorydialog.cpp b/noncore/unsupported/qashmoney/memorydialog.cpp new file mode 100755 index 0000000..ba11540 --- a/dev/null +++ b/noncore/unsupported/qashmoney/memorydialog.cpp | |||
@@ -0,0 +1,86 @@ | |||
1 | #include "memorydialog.h" | ||
2 | #include "memory.h" | ||
3 | #include <qmessagebox.h> | ||
4 | |||
5 | extern Memory *memory; | ||
6 | |||
7 | MemoryDialog::MemoryDialog () : QDialog ( 0, 0, TRUE ) | ||
8 | { | ||
9 | setCaption ( tr ( "Edit Memory" ) ); | ||
10 | |||
11 | listbox = new QListBox ( this, "listbox" ); | ||
12 | memory->displayMemoryItems ( listbox ); | ||
13 | listbox->clearSelection(); | ||
14 | |||
15 | secondline = new QHBox ( this ); | ||
16 | |||
17 | newbutton = new QPushButton ( secondline ); | ||
18 | newbutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/new.png") ); | ||
19 | connect ( newbutton, SIGNAL ( released() ), this, SLOT ( addItem() ) ); | ||
20 | |||
21 | editbutton = new QPushButton ( secondline ); | ||
22 | editbutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); | ||
23 | connect ( editbutton, SIGNAL ( released() ), this, SLOT ( editItem() ) ); | ||
24 | |||
25 | deletebutton = new QPushButton( secondline ); | ||
26 | deletebutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/delete.png") ); | ||
27 | connect ( deletebutton, SIGNAL ( released() ), this, SLOT ( deleteItem() ) ); | ||
28 | |||
29 | lineedit = new QLineEdit ( this ); | ||
30 | |||
31 | layout = new QVBoxLayout ( this, 2, 2 ); | ||
32 | layout->addWidget ( listbox ); | ||
33 | layout->addWidget ( secondline ); | ||
34 | layout->addWidget ( lineedit ); | ||
35 | } | ||
36 | |||
37 | MemoryDialog::~MemoryDialog() | ||
38 | { | ||
39 | } | ||
40 | |||
41 | void MemoryDialog::addItem () | ||
42 | { | ||
43 | if ( lineedit->text().length() != 0 ) | ||
44 | { | ||
45 | memory->addMemoryItem ( lineedit->text() ); | ||
46 | listbox->clear (); | ||
47 | memory->displayMemoryItems ( listbox ); | ||
48 | listbox->clearFocus(); | ||
49 | listbox->clearSelection (); | ||
50 | lineedit->clear(); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | void MemoryDialog::editItem () | ||
55 | { | ||
56 | if ( listbox->currentItem() != -1 ) | ||
57 | { | ||
58 | lineedit->setText ( listbox->currentText() ); | ||
59 | memory->deleteMemoryItem ( listbox->currentText() ); | ||
60 | listbox->clear (); | ||
61 | memory->displayMemoryItems ( listbox ); | ||
62 | listbox->clearSelection(); | ||
63 | } | ||
64 | else | ||
65 | QMessageBox::warning ( this, "QashMoney", "Please select an item to edit." ); | ||
66 | } | ||
67 | |||
68 | void MemoryDialog::deleteItem () | ||
69 | { | ||
70 | if ( listbox->currentItem() != -1 ) | ||
71 | { | ||
72 | memory->deleteMemoryItem ( listbox->currentText() ); | ||
73 | listbox->clear (); | ||
74 | memory->displayMemoryItems ( listbox ); | ||
75 | listbox->clearSelection(); | ||
76 | } | ||
77 | else | ||
78 | QMessageBox::warning ( this, "QashMoney", "Please select an item to delete." ); | ||
79 | } | ||
80 | |||
81 | |||
82 | |||
83 | |||
84 | |||
85 | |||
86 | |||