summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mail2/attachdiag.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/mail2/attachdiag.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/attachdiag.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/noncore/unsupported/mail2/attachdiag.cpp b/noncore/unsupported/mail2/attachdiag.cpp
new file mode 100644
index 0000000..6e6c3d4
--- a/dev/null
+++ b/noncore/unsupported/mail2/attachdiag.cpp
@@ -0,0 +1,71 @@
1#include <qmessagebox.h>
2#include <qpushbutton.h>
3#include <qlistbox.h>
4#include <qlayout.h>
5
6#include <qpe/fileselector.h>
7#include <qpe/resource.h>
8
9#include <stdlib.h>
10
11#include "attachdiag.h"
12
13AttachDiag::AttachDiag(QWidget* parent = 0, const char* name = 0, bool modal, WFlags fl = 0)
14 : QDialog(parent, name, modal, fl)
15{
16 setCaption(tr("Attach File"));
17
18 QGridLayout *layout = new QGridLayout(this);
19 layout->setSpacing(3);
20 layout->setMargin(4);
21
22 FileSelector *fileSelector = new FileSelector("*", this, "FileSelector");
23 fileSelector->setCloseVisible(false);
24 fileSelector->setNewVisible(false);
25
26 layout->addMultiCellWidget(fileSelector, 0, 0, 0, 1);
27
28 QPushButton *attachButton = new QPushButton(this);
29 attachButton->setText(tr("Ok"));
30 attachButton->setIconSet(Resource::loadPixmap("enter"));
31
32 layout->addWidget(attachButton, 1, 0);
33
34 QPushButton *cancelButton = new QPushButton(this);
35 cancelButton->setText(tr("Cancel"));
36 cancelButton->setIconSet(Resource::loadPixmap("editdelete"));
37
38 layout->addWidget(cancelButton, 1, 1);
39
40 connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), SLOT(fileSelected(const DocLnk &)));
41 connect(attachButton, SIGNAL(clicked()), SLOT(accept()));
42 connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
43
44 if (fileSelector->selected() != NULL)
45 currentFile = *fileSelector->selected();
46
47 if (fileSelector->fileCount() == 0) {
48 attachButton->setEnabled(false);
49 fileSelector->setEnabled(false);
50 }
51}
52
53void AttachDiag::fileSelected(const DocLnk &file)
54{
55 currentFile = file;
56}
57
58DocLnk AttachDiag::getFile()
59{
60 AttachDiag *attach = new AttachDiag(0, 0, true);
61 attach->showMaximized();
62 attach->show();
63
64 if (QDialog::Accepted == attach->exec()) {
65 return attach->currentFile;
66 }
67
68 return DocLnk();
69 }
70
71