Diffstat (limited to 'noncore/net/mail/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index b25db97..f19f93d 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -50,127 +50,135 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
50 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, | 50 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, |
51 | 0, 0, this, 0, true ); | 51 | 0, 0, this, 0, true ); |
52 | showFolders->addTo( toolBar ); | 52 | showFolders->addTo( toolBar ); |
53 | showFolders->addTo( mailMenu ); | 53 | showFolders->addTo( mailMenu ); |
54 | connect(showFolders, SIGNAL( toggled( bool ) ), | 54 | connect(showFolders, SIGNAL( toggled( bool ) ), |
55 | SLOT( slotShowFolders( bool ) ) ); | 55 | SLOT( slotShowFolders( bool ) ) ); |
56 | 56 | ||
57 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, | 57 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, |
58 | 0, 0, this ); | 58 | 0, 0, this ); |
59 | searchMails->addTo( toolBar ); | 59 | searchMails->addTo( toolBar ); |
60 | searchMails->addTo( mailMenu ); | 60 | searchMails->addTo( mailMenu ); |
61 | 61 | ||
62 | 62 | ||
63 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, | 63 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, |
64 | 0, 0, this ); | 64 | 0, 0, this ); |
65 | editSettings->addTo( settingsMenu ); | 65 | editSettings->addTo( settingsMenu ); |
66 | 66 | ||
67 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, | 67 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, |
68 | 0, 0, this ); | 68 | 0, 0, this ); |
69 | editAccounts->addTo( settingsMenu ); | 69 | editAccounts->addTo( settingsMenu ); |
70 | 70 | ||
71 | QWidget *view = new QWidget( this ); | 71 | QWidget *view = new QWidget( this ); |
72 | setCentralWidget( view ); | 72 | setCentralWidget( view ); |
73 | 73 | ||
74 | 74 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | |
75 | QWidget *d = QApplication::desktop(); | ||
76 | QBoxLayout *layout; | ||
77 | |||
78 | if ( d->width() < d->height() ) { | ||
79 | layout = new QVBoxLayout( view ); | ||
80 | } else { | ||
81 | layout = new QHBoxLayout( view ); | ||
82 | } | ||
83 | 75 | ||
84 | folderView = new AccountView( view ); | 76 | folderView = new AccountView( view ); |
85 | folderView->header()->hide(); | 77 | folderView->header()->hide(); |
86 | folderView->addColumn( tr( "Mailbox" ) ); | 78 | folderView->addColumn( tr( "Mailbox" ) ); |
87 | folderView->hide(); | 79 | folderView->hide(); |
88 | 80 | ||
89 | layout->addWidget( folderView ); | 81 | layout->addWidget( folderView ); |
90 | 82 | ||
91 | mailView = new QListView( view ); | 83 | mailView = new QListView( view ); |
92 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 84 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
93 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 85 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
94 | mailView->addColumn( tr( "Date" )); | 86 | mailView->addColumn( tr( "Date" )); |
95 | mailView->setAllColumnsShowFocus(true); | 87 | mailView->setAllColumnsShowFocus(true); |
96 | mailView->setSorting(-1); | 88 | mailView->setSorting(-1); |
97 | 89 | ||
98 | layout->addWidget( mailView ); | 90 | layout->addWidget( mailView ); |
99 | layout->setStretchFactor( folderView, 1 ); | 91 | layout->setStretchFactor( folderView, 1 ); |
100 | layout->setStretchFactor( mailView, 2 ); | 92 | layout->setStretchFactor( mailView, 2 ); |
101 | 93 | ||
94 | slotAdjustLayout(); | ||
95 | |||
102 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, | 96 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, |
103 | SLOT( displayMail( QListViewItem * ) ) ); | 97 | SLOT( displayMail( QListViewItem * ) ) ); |
104 | 98 | ||
105 | connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 99 | connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
106 | 100 | ||
107 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 101 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
108 | } | 102 | } |
109 | 103 | ||
104 | |||
105 | void MainWindow::slotAdjustLayout() { | ||
106 | |||
107 | QWidget *d = QApplication::desktop(); | ||
108 | |||
109 | if ( d->width() < d->height() ) { | ||
110 | layout->setDirection( QBoxLayout::TopToBottom ); | ||
111 | } else { | ||
112 | layout->setDirection( QBoxLayout::LeftToRight ); | ||
113 | } | ||
114 | delete d; | ||
115 | } | ||
116 | |||
110 | void MainWindow::slotAdjustColumns() | 117 | void MainWindow::slotAdjustColumns() |
111 | { | 118 | { |
112 | bool hidden = folderView->isHidden(); | 119 | bool hidden = folderView->isHidden(); |
113 | if ( hidden ) folderView->show(); | 120 | if ( hidden ) folderView->show(); |
114 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 121 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
115 | if ( hidden ) folderView->hide(); | 122 | if ( hidden ) folderView->hide(); |
116 | 123 | ||
117 | mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 ); | 124 | mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 ); |
118 | mailView->setColumnWidth( 1, 80 ); | 125 | mailView->setColumnWidth( 1, 80 ); |
119 | mailView->setColumnWidth( 2, 50 ); | 126 | mailView->setColumnWidth( 2, 50 ); |
120 | } | 127 | } |
121 | 128 | ||
122 | void MainWindow::slotShowFolders( bool show ) | 129 | void MainWindow::slotShowFolders( bool show ) |
123 | { | 130 | { |
124 | qDebug( "Show Folders" ); | 131 | qDebug( "Show Folders" ); |
125 | if ( show && folderView->isHidden() ) { | 132 | if ( show && folderView->isHidden() ) { |
126 | qDebug( "-> showing" ); | 133 | qDebug( "-> showing" ); |
127 | folderView->show(); | 134 | folderView->show(); |
128 | } else if ( !show && !folderView->isHidden() ) { | 135 | } else if ( !show && !folderView->isHidden() ) { |
129 | qDebug( "-> hiding" ); | 136 | qDebug( "-> hiding" ); |
130 | folderView->hide(); | 137 | folderView->hide(); |
131 | } | 138 | } |
132 | } | 139 | } |
133 | 140 | ||
134 | void MainWindow::refreshMailView(QList<RecMail>*list) | 141 | void MainWindow::refreshMailView(QList<RecMail>*list) |
135 | { | 142 | { |
136 | MailListViewItem*item = 0; | 143 | MailListViewItem*item = 0; |
137 | mailView->clear(); | 144 | mailView->clear(); |
138 | for (unsigned int i = 0; i < list->count();++i) { | 145 | for (unsigned int i = 0; i < list->count();++i) { |
139 | item = new MailListViewItem(mailView,item); | 146 | item = new MailListViewItem(mailView,item); |
140 | item->storeData(*(list->at(i))); | 147 | item->storeData(*(list->at(i))); |
141 | item->showEntry(); | 148 | item->showEntry(); |
142 | } | 149 | } |
143 | } | 150 | } |
144 | void MainWindow::displayMail(QListViewItem*item) | 151 | void MainWindow::displayMail(QListViewItem*item) |
145 | { | 152 | { |
146 | if (!item) return; | 153 | if (!item) return; |
147 | qDebug("View mail"); | 154 | qDebug("View mail"); |
148 | RecMail mail = ((MailListViewItem*)item)->data(); | 155 | RecMail mail = ((MailListViewItem*)item)->data(); |
149 | RecBody body = folderView->fetchBody(mail); | 156 | RecBody body = folderView->fetchBody(mail); |
150 | 157 | ||
151 | ViewMail readMail( this ); | 158 | ViewMail readMail( this ); |
152 | readMail.setMailInfo( mail.getFrom(), "", mail.getSubject(), "", "", body.Bodytext() ); | 159 | |
160 | readMail.setMailInfo( mail.getFrom(), mail.To(), mail.getSubject(), mail.CC(), mail.Bcc(), mail.getDate(), body.Bodytext() ); | ||
153 | readMail.showMaximized(); | 161 | readMail.showMaximized(); |
154 | readMail.exec(); | 162 | readMail.exec(); |
155 | } | 163 | } |
156 | 164 | ||
157 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * after ) | 165 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * after ) |
158 | :QListViewItem(parent,after),mail_data() | 166 | :QListViewItem(parent,after),mail_data() |
159 | { | 167 | { |
160 | } | 168 | } |
161 | 169 | ||
162 | void MailListViewItem::showEntry() | 170 | void MailListViewItem::showEntry() |
163 | { | 171 | { |
164 | setText(0,mail_data.getSubject()); | 172 | setText(0,mail_data.getSubject()); |
165 | setText(1,mail_data.getFrom()); | 173 | setText(1,mail_data.getFrom()); |
166 | setText(2,mail_data.getDate()); | 174 | setText(2,mail_data.getDate()); |
167 | } | 175 | } |
168 | 176 | ||
169 | void MailListViewItem::storeData(const RecMail&data) | 177 | void MailListViewItem::storeData(const RecMail&data) |
170 | { | 178 | { |
171 | mail_data = data; | 179 | mail_data = data; |
172 | } | 180 | } |
173 | 181 | ||
174 | const RecMail& MailListViewItem::data()const | 182 | const RecMail& MailListViewItem::data()const |
175 | { | 183 | { |
176 | return mail_data; | 184 | return mail_data; |