[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/qma/src
From: Tom Albers <tomalbers () kde ! nl>
Date: 2006-10-23 16:10:26
Message-ID: 1161619826.754415.14407.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 598455 by toma:
Composer attachment experiment failed. Show attachments in a separate listview next \
to the addresses. Sort of Thunderbird solution. Hide/Show automatically.
M +63 -61 composer.cpp
M +6 -5 composer.h
--- trunk/playground/pim/qma/src/composer.cpp #598454:598455
@@ -40,6 +40,7 @@
#include <kabc/stdaddressbook.h>
#include <kapplication.h>
#include <kmessagebox.h>
+#include <krun.h>
#include "setup.h"
#include "sidebar.h"
@@ -104,8 +105,12 @@
// -------------- The second column is split in two rows ----//
m_vsplitter = new QSplitter(m_hsplitter);
m_vsplitter->setOrientation(Qt::Vertical);
+
+ // and the top part is in two parts....
+ QSplitter* leftsplitter = new QSplitter(m_vsplitter);
+ leftsplitter->setOrientation(Qt::Horizontal);
- QWidget* widg = new QWidget(m_vsplitter);
+ QWidget* widg = new QWidget(leftsplitter);
QGridLayout* grid = new QGridLayout(widg,2,2,5,5);
m_edit = new KLineEdit( widg, "AddressCompletion" );
@@ -146,6 +151,16 @@
connect(m_lv, SIGNAL(clicked(QListViewItem*, const QPoint&, int)),
SLOT(slotEditAddress(QListViewItem*, const QPoint&, int)));
+ m_attachlv = new KListView(leftsplitter);
+ m_attachlv->hide();
+ m_attachlv->addColumn(i18n("File"));
+ m_attachlv->addColumn(i18n("del"));
+ m_attachlv->setSorting(500, false); // no sort by default, but do when clicked..
+ connect(m_attachlv, SIGNAL(doubleClicked(QListViewItem*, const QPoint&, int)),
+ SLOT(slotShowFile(QListViewItem*, const QPoint&, int)));
+ connect(m_attachlv, SIGNAL(clicked(QListViewItem*, const QPoint&, int)),
+ SLOT(slotEditFile(QListViewItem*, const QPoint&, int)));
+
grid->addWidget(m_edit,0,0);
grid->addWidget(m_add,0,1);
grid->addMultiCellWidget(m_lv,1,1,0,1);
@@ -165,16 +180,10 @@
this, SLOT(slotSend()),
actionCollection(),"send_message");
- m_attachmentButton = new QPushButton(i18n("Attachments (0)"), widg2);
- m_attachmentButton->setEnabled(false);
- connect(m_attachmentButton, SIGNAL(clicked()),
- SLOT(slotShowAttachments()));
-
grid2->addWidget(label,0,0);
- grid2->addMultiCellWidget(m_subject,0,0,1,3);
- grid2->addMultiCellWidget(m_text,1,1,0,3);
- grid2->addWidget(m_attachmentButton,2,2);
- grid2->addWidget(send,2,3);
+ grid2->addMultiCellWidget(m_subject,0,0,1,2);
+ grid2->addMultiCellWidget(m_text,1,1,0,2);
+ grid2->addWidget(send,2,2);
grid2->setColStretch(1,10);
//--------------------------------------------------------
@@ -235,14 +244,12 @@
m_text->setFocus();
}
-void Composer::addAttachment(const KURL& attachment)
+void Composer::addAttachment(const QString& attachment)
{
m_attachments.append(attachment);
- m_attachmentButton->setEnabled(true);
- m_attachmentButton->setText(
- i18n("Argument is the amount of attachments",
- "Attachments (%1)")
- .arg(QString::number(m_attachments.count())));
+ m_attachlv->show();
+ KListViewItem* i = new KListViewItem(m_attachlv, KURL(attachment).fileName(), \
QString::null, KURL(attachment).url()); + i->setPixmap(1, \
KGlobal::iconLoader()->loadIcon("cancel",KIcon::Small)); }
void Composer::inReplyTo(const QString& messageID)
@@ -351,47 +358,14 @@
for (KFileItemListIterator it(*list); (tmp = it.current()); ++it)
{
kdDebug() << tmp->url() << endl;
- if (m_attachments.find(tmp->url()) != m_attachments.end())
+ if (m_attachments.find(tmp->url().url()) != m_attachments.end())
continue;
- addAttachment(tmp->url());
+ addAttachment(tmp->url().url());
m_filebrowser->dirOperator()->view()->setSelected(tmp,false);
}
}
-void Composer::slotShowAttachments()
-{
- QPopupMenu* p = new QPopupMenu(0);
- QLabel* t = new QLabel(i18n("Click to delete"),p);
- p->insertItem(t);
- QValueList<KURL>::Iterator it = m_attachments.begin();
- int i = 1;
- while (it != m_attachments.end())
- {
- p->insertItem((*it).prettyURL(), i);
- i++;
- it++;
- }
- int res = p->exec(QCursor::pos(), i-1);
-
- // hmm, hmm.
- it = m_attachments.begin();
- i = 1;
- while (it != m_attachments.end())
- {
- if (i == res)
- it = m_attachments.remove((it));
- else
- it++;
- i++;
- }
- m_attachmentButton->setEnabled(m_attachments.count()>0);
- m_attachmentButton->setText(
- i18n("Argument is the amount of attachments",
- "Attachments (%1)")
- .arg(QString::number(m_attachments.count())));
-}
-
void Composer::slotEditAddress(QListViewItem* lvi, const QPoint&, int c )
{
if (!lvi)
@@ -413,6 +387,34 @@
m_lastState=c;
}
+void Composer::slotEditFile(QListViewItem* lvi, const QPoint&, int c )
+{
+ if (!lvi)
+ return;
+
+ if (c != 1)
+ return;
+
+ m_attachments.remove(lvi->text(2));
+ delete lvi;
+
+ kdDebug() << m_attachments << endl;
+
+ if (m_attachments.count() == 0)
+ m_attachlv->hide();
+}
+
+void Composer::slotShowFile(QListViewItem* lvi, const QPoint&, int c )
+{
+ if (!lvi)
+ return;
+
+ if (c != 0)
+ return;
+
+ new KRun(lvi->text(2));
+}
+
void Composer::slotSetAddress(const QString& address)
{
m_edit->setText(address);
@@ -496,6 +498,13 @@
++it;
}
+ if (!m_tos.count())
+ {
+ KMessageBox::error(this, i18n("There are no receipients..."));
+ return;
+ }
+
+ KMime::Headers::Subject* Subject = new KMime::Headers::Subject;
if (!ccAddress->isEmpty())
m->setHeader( ccAddress );
if (!bccAddress->isEmpty())
@@ -511,13 +520,6 @@
return;
}
- if (!m_tos.count())
- {
- KMessageBox::error(this, i18n("There are no receipients..."));
- return;
- }
-
- KMime::Headers::Subject* Subject = new KMime::Headers::Subject;
Subject->from7BitString( m_subject->text().latin1() );
m->setHeader( Subject );
@@ -548,11 +550,11 @@
m->setHeader( ct ); // without it, i get a invalid/invalid... bug?
// Hook in the attachments
- QValueList<KURL>::Iterator its = m_attachments.begin();
+ QStringList::Iterator its = m_attachments.begin();
while (its != m_attachments.end())
{
//TODO: network transparency....
- QFile file( (*its).path() );
+ QFile file( (*its) );
if (file.open(IO_ReadOnly))
{
QByteArray data(file.size());
@@ -570,7 +572,7 @@
KMimeType::Ptr type = KMimeType::findByURL(*its);
KMime::Headers::ContentType* ctt= new KMime::Headers::ContentType(c);
ctt->fromUnicodeString(type->name(),"");
- ctt->setName((*its).filename(),"");
+ ctt->setName( file.name(),"");
c->setHeader( ctt );
// Set the encoding.
--- trunk/playground/pim/qma/src/composer.h #598454:598455
@@ -31,7 +31,6 @@
class Sidebar;
class QSplitter;
class FileBrowser;
-class KURL;
#include "../libkmime/kmime_message.h"
#include <qsyntaxhighlighter.h>
@@ -102,7 +101,7 @@
/**
* add @p attachment to the message
*/
- void addAttachment(const KURL& attachment);
+ void addAttachment(const QString& attachment);
/**
* set a In-reply-to header with the value @p messageID
@@ -143,8 +142,8 @@
QString m_replyTo;
FileBrowser* m_filebrowser;
- QValueList<KURL> m_attachments;
- QPushButton* m_attachmentButton;
+ QValueList<QString> m_attachments;
+ KListView* m_attachlv;
void updateLineEdit();
void addAddress(const QString& text);
@@ -153,9 +152,11 @@
private slots:
void slotAddAddress();
void slotAddFile(const KFileItem*);
- void slotShowAttachments();
void slotTextChanged(const QString& text);
void slotEditAddress(QListViewItem*, const QPoint&, int);
+ void slotEditFile(QListViewItem*, const QPoint&, int);
+ void slotShowFile(QListViewItem*, const QPoint&, int);
+
void slotSetAddress(const QString& address);
void slotLineLostFocus();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic