aboutsummaryrefslogtreecommitdiffstats
path: root/attachments.cpp
diff options
context:
space:
mode:
authorubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-05-14 11:22:44 +0000
committerubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-05-14 11:22:44 +0000
commit38d40c5aed23ba76add8fc421f26380c9973401e (patch)
tree30b55db0433c14a8a841eb0a49f865f3e2381117 /attachments.cpp
parentupdate attachment-todo (diff)
downloadgpg4usb-38d40c5aed23ba76add8fc421f26380c9973401e.tar.gz
gpg4usb-38d40c5aed23ba76add8fc421f26380c9973401e.zip
start of using own model for attachment-table-view, not all functionality (saving / icons) back in place
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@328 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to 'attachments.cpp')
-rw-r--r--attachments.cpp54
1 files changed, 32 insertions, 22 deletions
diff --git a/attachments.cpp b/attachments.cpp
index 4223043..cb62cbd 100644
--- a/attachments.cpp
+++ b/attachments.cpp
@@ -24,6 +24,11 @@
* - check memory usage, use less copy operations / more references
* - try table-model-view for mimeparts
* - possibility to clear attachment-view , e.g. with decryption or encrypting a new message
+ * - clean header-file (remove dep. on keylist.h)
+ */
+
+/* implement model for mime, based on qabstracttablemodel
+ *
*/
#include "attachments.h"
@@ -34,25 +39,22 @@ Attachments::Attachments(QString iconpath, QWidget *parent)
this->iconPath = iconpath;
- mAttachmentTable = new QTableWidget(this);
- mAttachmentTable->setColumnCount(2);
- mAttachmentTable->setSelectionBehavior(QAbstractItemView::SelectRows);
- mAttachmentTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
- mAttachmentTable->setFocusPolicy(Qt::NoFocus);
- mAttachmentTable->setAlternatingRowColors(true);
- mAttachmentTable->verticalHeader()->hide();
- mAttachmentTable->setShowGrid(false);
- mAttachmentTable->setColumnWidth(0, 300);
-
- attachmentBodys = new QList<QByteArray>();
+ table = new AttachmentTableModel(this);
- QStringList labels;
- labels << "filename" << "content-type";
- mAttachmentTable->setHorizontalHeaderLabels(labels);
- mAttachmentTable->horizontalHeader()->setStretchLastSection(true);
+ tableView = new QTableView;
+ tableView->setModel(table);
+ tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
+ tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ tableView->setFocusPolicy(Qt::NoFocus);
+ tableView->setAlternatingRowColors(true);
+ tableView->verticalHeader()->hide();
+ tableView->setShowGrid(false);
+ tableView->setColumnWidth(0, 300);
+ tableView->horizontalHeader()->setStretchLastSection(true);
QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(mAttachmentTable);
+ //layout->addWidget(mAttachmentTable);
+ layout->addWidget(tableView);
setLayout(layout);
createActions();
@@ -110,11 +112,13 @@ QStringList *Attachments::getSelected()
QStringList *ret = new QStringList();
- for (int i = 0; i < mAttachmentTable->rowCount(); i++) {
+ // TODO
+
+ /*for (int i = 0; i < mAttachmentTable->rowCount(); i++) {
if (mAttachmentTable->item(i, 0)->isSelected() == 1) {
*ret << mAttachmentTable->item(i, 0)->text();
}
- }
+ }*/
return ret;
}
@@ -123,11 +127,13 @@ QList<int> Attachments::getSelectedPos () {
QList<int> ret;
- for (int i = 0; i < mAttachmentTable->rowCount(); i++) {
+ // TODO
+
+ /*for (int i = 0; i < mAttachmentTable->rowCount(); i++) {
if (mAttachmentTable->item(i, 0)->isSelected() == 1) {
ret << i;
}
- }
+ }*/
return ret;
}
@@ -135,9 +141,12 @@ QList<int> Attachments::getSelectedPos () {
void Attachments::addMimePart(MimePart *mp)
{
- QString icon = mp->getValue("Content-Type").replace("/", "-");
- icon = iconPath + "/mimetypes/" + icon + ".png";
+ //QString icon = mp->getValue("Content-Type").replace("/", "-");
+ //icon = iconPath + "/mimetypes/" + icon + ".png";
+ table->add(*mp);
+ //tableView->update();
+ /*
mAttachmentTable->setRowCount(mAttachmentTable->rowCount()+1);
QTableWidgetItem *tmp = new QTableWidgetItem(QIcon(icon) , mp->getParam("Content-Type", "name"));
mAttachmentTable->setItem(mAttachmentTable->rowCount()-1, 0, tmp);
@@ -147,6 +156,7 @@ void Attachments::addMimePart(MimePart *mp)
//TODO: check, if content-encoding is base64 (get from header)
attachmentBodys->append(QByteArray::fromBase64(mp->body));
+ */
}