diff options
| author | MattV <qt-info@nokia.com> | 2009-03-27 11:27:29 +1000 |
|---|---|---|
| committer | MattV <qt-info@nokia.com> | 2009-03-27 11:27:29 +1000 |
| commit | c416c4d706e5ed7b3aa1bcc707f2fd83d5657a9b (patch) | |
| tree | 7b438e55f0f1cc15d4066663dcf328dc514ebdee | |
| parent | d0d783ebab347c1f84f2c1cb19f71e36b3cb250b (diff) | |
Close the attachment dialog once the part it refers to is destroyed.2009W13
| -rw-r--r-- | src/plugins/viewers/generic/genericviewer.cpp | 27 | ||||
| -rw-r--r-- | src/plugins/viewers/generic/genericviewer.h | 3 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/plugins/viewers/generic/genericviewer.cpp b/src/plugins/viewers/generic/genericviewer.cpp index 7313f96a..c008e475 100644 --- a/src/plugins/viewers/generic/genericviewer.cpp +++ b/src/plugins/viewers/generic/genericviewer.cpp @@ -23,6 +23,7 @@ GenericViewer::GenericViewer(QWidget* parent) : QMailViewerInterface(parent), browser(new Browser(parent)), + attachmentDialog(0), message(0), plainTextMode(false) { @@ -82,6 +83,11 @@ QList<int> GenericViewer::types() const { return QList<int>() << QMailMessage::P bool GenericViewer::setMessage(const QMailMessage& mail) { + if (attachmentDialog) { + attachmentDialog->close(); + attachmentDialog = 0; + } + message = &mail; setPlainTextMode(plainTextMode); @@ -96,6 +102,11 @@ void GenericViewer::setResource(const QUrl& name, QVariant var) void GenericViewer::clear() { + if (attachmentDialog) { + attachmentDialog->close(); + attachmentDialog = 0; + } + plainTextMode = false; browser->setPlainText(""); @@ -134,11 +145,14 @@ void GenericViewer::linkClicked(const QUrl& link) QMailMessagePart::Location partLocation(location); // Show the attachment dialog - AttachmentOptions options(widget()); - options.setAttachment(message->partAt(partLocation)); + attachmentDialog = new AttachmentOptions(widget()); + attachmentDialog->setAttribute(Qt::WA_DeleteOnClose); - connect(&options, SIGNAL(retrieve(QMailMessagePart)), this, SIGNAL(retrieveMessagePart(QMailMessagePart))); - options.exec(); + attachmentDialog->setAttachment(message->partAt(partLocation)); + connect(attachmentDialog, SIGNAL(retrieve(QMailMessagePart)), this, SIGNAL(retrieveMessagePart(QMailMessagePart))); + connect(attachmentDialog, SIGNAL(finished(int)), this, SLOT(dialogFinished(int))); + + attachmentDialog->exec(); return; } } @@ -177,5 +191,10 @@ bool GenericViewer::eventFilter(QObject*, QEvent* event) return false; } +void GenericViewer::dialogFinished(int) +{ + attachmentDialog = 0; +} + Q_EXPORT_PLUGIN2(generic,GenericViewer) diff --git a/src/plugins/viewers/generic/genericviewer.h b/src/plugins/viewers/generic/genericviewer.h index 87b931bc..4fb9305d 100644 --- a/src/plugins/viewers/generic/genericviewer.h +++ b/src/plugins/viewers/generic/genericviewer.h @@ -19,6 +19,7 @@ class QAction; class QMailMessage; class QPushButton; class QToolButton; +class AttachmentOptions; class Browser; // A generic viewer able to show email, SMS or basic MMS @@ -51,6 +52,7 @@ public slots: protected slots: virtual void linkHighlighted(const QUrl& link); + virtual void dialogFinished(int); private: virtual void setPlainTextMode(bool plainTextMode); @@ -60,6 +62,7 @@ private: Browser* browser; QAction* plainTextModeAction; QAction* richTextModeAction; + AttachmentOptions* attachmentDialog; const QMailMessage* message; bool plainTextMode; bool containsNumbers; |
