author | llornkcor <llornkcor> | 2003-04-06 17:45:00 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-04-06 17:45:00 (UTC) |
commit | 70b1ff1a3f134d75d1539f269d52b34e6762684d (patch) (unidiff) | |
tree | 28c1b3d0c03e8c0188f014dfe094645d1ddfef5f /noncore/net/mailit/viewatt.cpp | |
parent | 75e8f29020e267d1013a79839831035073b4eeae (diff) | |
download | opie-70b1ff1a3f134d75d1539f269d52b34e6762684d.zip opie-70b1ff1a3f134d75d1539f269d52b34e6762684d.tar.gz opie-70b1ff1a3f134d75d1539f269d52b34e6762684d.tar.bz2 |
move malit to head again, since it is working
Diffstat (limited to 'noncore/net/mailit/viewatt.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mailit/viewatt.cpp | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/noncore/net/mailit/viewatt.cpp b/noncore/net/mailit/viewatt.cpp new file mode 100644 index 0000000..86f119f --- a/dev/null +++ b/noncore/net/mailit/viewatt.cpp | |||
@@ -0,0 +1,109 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qt Palmtop Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include "resource.h" | ||
21 | #include "viewatt.h" | ||
22 | #include <qpe/applnk.h> | ||
23 | |||
24 | ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) | ||
25 | : QMainWindow(parent, name, f) | ||
26 | { | ||
27 | setCaption("Exploring attatchments"); | ||
28 | |||
29 | setToolBarsMovable( FALSE ); | ||
30 | bar = new QToolBar(this); | ||
31 | installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); | ||
32 | connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); | ||
33 | |||
34 | listView = new QListView(this, "AttView"); | ||
35 | listView->addColumn( "Attatchment" ); | ||
36 | listView->addColumn( "Type" ); | ||
37 | listView->addColumn( "Installed" ); | ||
38 | setCentralWidget(listView); | ||
39 | } | ||
40 | |||
41 | void ViewAtt::update(Email *mailIn, bool inbox) | ||
42 | { | ||
43 | QListViewItem *item; | ||
44 | Enclosure *ePtr; | ||
45 | |||
46 | listView->clear(); | ||
47 | if (inbox) { | ||
48 | bar->clear(); | ||
49 | installButton->addTo( bar ); | ||
50 | bar->show(); | ||
51 | } else { | ||
52 | bar->hide(); | ||
53 | } | ||
54 | |||
55 | mail = mailIn; | ||
56 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | ||
57 | |||
58 | QString isInstalled = "No"; | ||
59 | if (ePtr->installed) | ||
60 | isInstalled = "Yes"; | ||
61 | item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); | ||
62 | |||
63 | if (ePtr->contentType == "TEXT") { | ||
64 | actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); | ||
65 | actions->addTo(bar); | ||
66 | item->setPixmap(0, Resource::loadPixmap("txt")); | ||
67 | } | ||
68 | if (ePtr->contentType == "AUDIO") { | ||
69 | actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); | ||
70 | actions->addTo(bar); | ||
71 | item->setPixmap(0, Resource::loadPixmap("play")); | ||
72 | } | ||
73 | if (ePtr->contentType == "IMAGE") { | ||
74 | actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); | ||
75 | actions->addTo(bar); | ||
76 | item->setPixmap(0, Resource::loadPixmap("pixmap")); | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | void ViewAtt::install() | ||
82 | { | ||
83 | Enclosure *ePtr, *selPtr; | ||
84 | QListViewItem *item; | ||
85 | QString filename; | ||
86 | DocLnk d; | ||
87 | |||
88 | item = listView->selectedItem(); | ||
89 | if (item != NULL) { | ||
90 | filename = item->text(0); | ||
91 | selPtr = NULL; | ||
92 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | ||
93 | if (ePtr->originalName == filename) | ||
94 | selPtr = ePtr; | ||
95 | } | ||
96 | |||
97 | if (selPtr == NULL) { | ||
98 | qWarning("Internal error, file is not installed to documents"); | ||
99 | return; | ||
100 | } | ||
101 | |||
102 | d.setName(selPtr->originalName); | ||
103 | d.setFile(selPtr->path + selPtr->name); | ||
104 | d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); | ||
105 | d.writeLink(); | ||
106 | selPtr->installed = TRUE; | ||
107 | item->setText(2, "Yes"); | ||
108 | } | ||
109 | } | ||