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