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/addatt.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/addatt.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mailit/addatt.cpp | 209 |
1 files changed, 209 insertions, 0 deletions
diff --git a/noncore/net/mailit/addatt.cpp b/noncore/net/mailit/addatt.cpp new file mode 100644 index 0000000..c030e36 --- a/dev/null +++ b/noncore/net/mailit/addatt.cpp | |||
@@ -0,0 +1,209 @@ | |||
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 <qlayout.h> | ||
21 | #include <qdir.h> | ||
22 | #include <qstringlist.h> | ||
23 | #include "resource.h" | ||
24 | #include "addatt.h" | ||
25 | |||
26 | FileItem::FileItem(QListView *parent, QFileInfo fileInfo, QString fileType) | ||
27 | : QListViewItem(parent) | ||
28 | { | ||
29 | file = fileInfo; | ||
30 | type = fileType; | ||
31 | |||
32 | setText(0, fileInfo.baseName()); | ||
33 | |||
34 | if (fileType == "Picture") { | ||
35 | setPixmap(0, Resource::loadPixmap("pixmap")); | ||
36 | } else if (fileType == "Document") { | ||
37 | setPixmap(0, Resource::loadPixmap("txt")); | ||
38 | } else if (fileType == "Sound") { | ||
39 | setPixmap(0, Resource::loadPixmap("play")); | ||
40 | } else if (fileType == "Movie") { | ||
41 | setPixmap(0, Resource::loadPixmap("MPEGPlayer")); | ||
42 | } else if (fileType == "File") { | ||
43 | setPixmap(0, Resource::loadPixmap("exec")); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | QFileInfo FileItem::getFileInfo() | ||
48 | { | ||
49 | return file; | ||
50 | } | ||
51 | |||
52 | QString FileItem::getFileType() | ||
53 | { | ||
54 | return type; | ||
55 | } | ||
56 | |||
57 | AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) | ||
58 | : QDialog(parent, name, f) | ||
59 | { | ||
60 | setCaption("Adding attatchments"); | ||
61 | |||
62 | QGridLayout *top = new QGridLayout(this, 3, 2); | ||
63 | |||
64 | fileCategoryButton = new QPushButton(this); | ||
65 | attatchButton = new QPushButton("Attatch ->", this); | ||
66 | removeButton = new QPushButton("Remove", this); | ||
67 | |||
68 | fileCategories = new QPopupMenu(fileCategoryButton); | ||
69 | fileCategoryButton->setPopup(fileCategories); | ||
70 | fileCategories->insertItem("Document"); | ||
71 | fileCategories->insertItem("Picture"); | ||
72 | fileCategories->insertItem("Sound"); | ||
73 | fileCategories->insertItem("Movie"); | ||
74 | fileCategories->insertItem("File"); | ||
75 | |||
76 | fileCategoryButton->setText("Document"); | ||
77 | top->addWidget(fileCategoryButton, 0, 0); | ||
78 | top->addWidget(attatchButton, 2, 0); | ||
79 | top->addWidget(removeButton, 2, 1); | ||
80 | |||
81 | connect(fileCategories, SIGNAL(activated(int)), this, | ||
82 | SLOT(fileCategorySelected(int)) ); | ||
83 | connect(attatchButton, SIGNAL(clicked()), this, | ||
84 | SLOT(addAttatchment()) ); | ||
85 | connect(removeButton, SIGNAL(clicked()), this, | ||
86 | SLOT(removeAttatchment()) ); | ||
87 | |||
88 | listView = new QListView(this, "AttView"); | ||
89 | listView->addColumn("Documents"); | ||
90 | connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, | ||
91 | SLOT(addAttatchment()) ); | ||
92 | |||
93 | attView = new QListView(this, "Selected"); | ||
94 | attView->addColumn("Attatched"); | ||
95 | connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, | ||
96 | SLOT(removeAttatchment()) ); | ||
97 | |||
98 | top->addWidget(listView, 1,0); | ||
99 | top->addWidget(attView, 1,1); | ||
100 | |||
101 | clear(); | ||
102 | } | ||
103 | |||
104 | void AddAtt::clear() | ||
105 | { | ||
106 | attView->clear(); | ||
107 | getFiles(); | ||
108 | modified = FALSE; | ||
109 | } | ||
110 | |||
111 | void AddAtt::fileCategorySelected(int id) | ||
112 | { | ||
113 | fileCategoryButton->setText(fileCategories->text(id)); | ||
114 | getFiles(); | ||
115 | } | ||
116 | |||
117 | void AddAtt::addAttatchment() | ||
118 | { | ||
119 | QFileInfo info; | ||
120 | QString type; | ||
121 | |||
122 | if (listView->selectedItem() != NULL) { | ||
123 | item = (FileItem *) listView->selectedItem(); | ||
124 | info = item->getFileInfo(); | ||
125 | type = item->getFileType(); | ||
126 | item = new FileItem(attView, info, type); | ||
127 | } | ||
128 | modified = TRUE; | ||
129 | } | ||
130 | |||
131 | void AddAtt::removeAttatchment() | ||
132 | { | ||
133 | if (attView->selectedItem() != NULL) { | ||
134 | attView->takeItem(attView->selectedItem()); | ||
135 | } | ||
136 | modified = TRUE; | ||
137 | } | ||
138 | |||
139 | void AddAtt::reject() | ||
140 | { | ||
141 | if (modified) { | ||
142 | attView->clear(); | ||
143 | modified = FALSE; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | void AddAtt::accept() | ||
148 | { | ||
149 | modified = FALSE; | ||
150 | hide(); | ||
151 | } | ||
152 | |||
153 | void AddAtt::getFiles() | ||
154 | { | ||
155 | QString path, selected; | ||
156 | QDir *dir; | ||
157 | |||
158 | listView->clear(); | ||
159 | |||
160 | selected = fileCategoryButton->text(); | ||
161 | if (selected == "Picture") { | ||
162 | path = "../pics/"; | ||
163 | } else if (selected == "Document") { | ||
164 | path = "" ; //sub-dirs not decided | ||
165 | } else if (selected == "Sound") { | ||
166 | path = "../sounds/"; //sub-dirs not decided | ||
167 | } else if (selected == "Movie") { | ||
168 | path = ""; //sub-dirs not decided | ||
169 | } else if (selected == "File") { | ||
170 | path = ""; //sub-dirs not decided | ||
171 | } | ||
172 | |||
173 | dir = new QDir(path); | ||
174 | dir->setFilter(QDir::Files); | ||
175 | const QFileInfoList *dirInfoList = dir->entryInfoList(); | ||
176 | |||
177 | QFileInfoListIterator it(*dirInfoList); // create list iterator | ||
178 | |||
179 | while ( (fi=it.current()) ) { // for each file... | ||
180 | item = new FileItem(listView, *fi, selected); | ||
181 | ++it; // goto next list element | ||
182 | } | ||
183 | } | ||
184 | |||
185 | QStringList AddAtt::returnAttatchedFiles() | ||
186 | { | ||
187 | QFileInfo info; | ||
188 | QStringList list; | ||
189 | |||
190 | item = (FileItem *) attView->firstChild(); | ||
191 | while (item != NULL) { | ||
192 | info = item->getFileInfo(); | ||
193 | list += info.filePath(); | ||
194 | item = (FileItem *) item->nextSibling(); | ||
195 | } | ||
196 | return list; | ||
197 | } | ||
198 | |||
199 | QStringList AddAtt::returnFileTypes() | ||
200 | { | ||
201 | QStringList list; | ||
202 | |||
203 | item = (FileItem *) attView->firstChild(); | ||
204 | while (item != NULL) { | ||
205 | list += item->getFileType(); | ||
206 | item = (FileItem *) item->nextSibling(); | ||
207 | } | ||
208 | return list; | ||
209 | } | ||