00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <qlayout.h>
00021 #include <qhbox.h>
00022 #include <qdir.h>
00023 #include <qstringlist.h>
00024 #include <qpe/resource.h>
00025 #include "addatt.h"
00026
00027 FileItem::FileItem(QListView *parent, DocLnk* dl)
00028 : QListViewItem(parent)
00029 {
00030
00031
00032
00033 doclnk=dl;
00034
00035 setText(0, doclnk->name());
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 }
00049
00050 FileItem::~FileItem()
00051 {
00052 if (doclnk!=NULL) delete doclnk;
00053 doclnk=NULL;
00054 }
00055
00056 AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f)
00057 : QDialog(parent, name, f)
00058 {
00059 setCaption(tr("Adding attachments") );
00060
00061 QGridLayout *top = new QGridLayout(this, 1,1 );
00062
00063 QHBox *buttons=new QHBox(this);
00064
00065 attachButton = new QPushButton(tr("attach..."), buttons);
00066 removeButton = new QPushButton(tr("Remove"), buttons);
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 top->addWidget(buttons,1,0);
00081
00082
00083
00084
00085
00086 connect(attachButton, SIGNAL(clicked()), this,
00087 SLOT(addattachment()) );
00088 connect(removeButton, SIGNAL(clicked()), this,
00089 SLOT(removeattachment()) );
00090
00091
00092
00093
00094
00095
00096
00097 attView = new QListView(this, "Selected");
00098 attView->addColumn(tr("Attached"));
00099 attView->addColumn(tr("File type"));
00100 connect(attView, SIGNAL(doubleClicked(QListViewItem*)), this,
00101 SLOT(removeattachment()) );
00102
00103
00104 top->addWidget(attView, 0,0);
00105
00106 clear();
00107
00108
00109 }
00110
00111 void AddAtt::clear()
00112 {
00113 attView->clear();
00114
00115 modified = FALSE;
00116 }
00117
00118
00119
00120
00121
00122
00123
00124 void AddAtt::addattachment()
00125 {
00126 OFileDialog ofs("Attachments",this,0,0,"/root/Documents");
00127
00128 ofs.showMaximized();
00129
00130 if (ofs.exec()==QDialog::Accepted)
00131 {
00132 DocLnk* dl=new DocLnk(ofs.selectedDocument());
00133 FileItem* fi=new FileItem(attView,dl);
00134 fi->setPixmap(0,dl->pixmap());
00135 fi->setText(1,dl->type());
00136 attView->insertItem(fi);
00137 modified = TRUE;
00138 }
00139 }
00140
00141 void AddAtt::removeattachment()
00142 {
00143 if (attView->selectedItem() != NULL)
00144 {
00145 attView->takeItem(attView->selectedItem());
00146 }
00147 modified = TRUE;
00148 }
00149
00150 void AddAtt::reject()
00151 {
00152 if (modified) {
00153 attView->clear();
00154 modified = FALSE;
00155 }
00156 }
00157
00158 void AddAtt::accept()
00159 {
00160 modified = FALSE;
00161 hide();
00162 }
00163
00164 void AddAtt::getFiles()
00165 {
00166 QString path, selected;
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 }
00194
00195 QStringList AddAtt::returnattachedFiles()
00196 {
00197 QFileInfo info;
00198 QStringList list;
00199
00200 item = (FileItem *) attView->firstChild();
00201
00202
00203 while (item != NULL) {
00204 DocLnk* dl=item->getDocLnk();
00205 list+=dl->file();
00206
00207
00208 item = (FileItem *) item->nextSibling();
00209 }
00210 return list;
00211 }
00212
00213 QStringList AddAtt::returnFileTypes()
00214 {
00215 QStringList list;
00216
00217 item = (FileItem *) attView->firstChild();
00218
00219 while (item != NULL) {
00220 list += item->getDocLnk()->type();
00221 item = (FileItem *) item->nextSibling();
00222 }
00223 return list;
00224 }