author | zautrix <zautrix> | 2004-07-04 12:40:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-04 12:40:46 (UTC) |
commit | deb87bff56cd9cbb41e352c2ccfa97be142d6e48 (patch) (side-by-side diff) | |
tree | d711d6085e4143e1731da440732e823e69c092a3 /kmicromail | |
parent | 4a947dbc08cc7640dda4f8a89ddb3c80ecc5f9ea (diff) | |
download | kdepimpi-deb87bff56cd9cbb41e352c2ccfa97be142d6e48.zip kdepimpi-deb87bff56cd9cbb41e352c2ccfa97be142d6e48.tar.gz kdepimpi-deb87bff56cd9cbb41e352c2ccfa97be142d6e48.tar.bz2 |
Make sorting in KM working
-rw-r--r-- | kmicromail/composemail.cpp | 24 | ||||
-rw-r--r-- | kmicromail/mailistviewitem.cpp | 77 | ||||
-rw-r--r-- | kmicromail/mailistviewitem.h | 7 | ||||
-rw-r--r-- | kmicromail/mainwindow.cpp | 10 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 2 |
5 files changed, 75 insertions, 45 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index ca4f247..c1b58a4 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp @@ -34,26 +34,26 @@ //using namespace Opie::Core; //using namespace Opie::Ui; ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) : ComposeMailUI( parent, name, modal, flags ) { settings = s; m_replyid = ""; KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); QStringList mails = con.emails(); QString defmail = con.preferredEmail(); if ( mails.count() == 0) - QMessageBox::information( parentWidget(), tr( "Hint" ), - tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!" ), + QMessageBox::information( 0, tr( "Hint" ), + tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), tr( "Ok" ) ); if (defmail.length()!=0) { fromBox->insertItem(defmail); } QStringList::ConstIterator sit = mails.begin(); for (;sit!=mails.end();++sit) { if ( (*sit)==defmail) continue; fromBox->insertItem((*sit)); } senderNameEdit->setText(con.formattedName()); Config cfg( "mail" ); @@ -64,42 +64,42 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m attList->addColumn( tr( "Size" ) ); QList<Account> accounts = settings->getAccounts(); Account *it; for ( it = accounts.first(); it; it = accounts.next() ) { if ( it->getType()==MAILLIB::A_SMTP ) { SMTPaccount *smtp = static_cast<SMTPaccount *>(it); smtpAccountBox->insertItem( smtp->getAccountName() ); smtpAccounts.append( smtp ); } } - if ( smtpAccounts.count() > 0 ) { - fillValues( smtpAccountBox->currentItem() ); - } else { - QMessageBox::information( parentWidget(), tr( "Problem" ), - tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail." ), - tr( "Ok" ) ); - return; - } connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); mMail = 0; warnAttach = true; + if ( smtpAccounts.count() > 0 ) { + fillValues( smtpAccountBox->currentItem() ); + } else { + QMessageBox::information( 0, tr( "Problem" ), + tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), + tr( "Ok" ) ); + return; + } } void ComposeMail::saveAsDraft() { Opie::Core::OSmartPointer<Mail> mail= new Mail(); mail->setMail(fromBox->currentText()); mail->setTo( toLine->text() ); mail->setName(senderNameEdit->text()); mail->setCC( ccLine->text() ); mail->setBCC( bccLine->text() ); mail->setReply( replyLine->text() ); mail->setSubject( subjectLine->text() ); @@ -311,26 +311,26 @@ void ComposeMail::accept() else { setStatus( tr ("Error: Something went wrong. Nothing sent")); return; } QDialog::accept(); } void ComposeMail::reject() { //qDebug("ComposeMail::reject() "); - int yesno = QMessageBox::warning(0,tr("Stop editing message"), - tr("Store message into drafts?"), + int yesno = QMessageBox::warning(0,tr("Store message?"), + tr("Store message into drafts?\n"), tr("Yes"), tr("No")); //qDebug("button %d ", yesno); if (yesno == 0) { saveAsDraft(); } if (yesno == 2) { qDebug("return "); return; } QDialog::reject(); diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp index b9b4cd9..1ca0ada 100644 --- a/kmicromail/mailistviewitem.cpp +++ b/kmicromail/mailistviewitem.cpp @@ -12,56 +12,60 @@ MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) void MailListViewItem::showEntry() { if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { setPixmap( 0, SmallIcon ( "kmmsgreplied") ); } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { /* I think it looks nicer if there are not such a log of icons but only on mails replied or new - Alwin*/ //setPixmap( 0,SmallIcon ("kmmsgunseen") ); } else { setPixmap( 0,SmallIcon ( "kmmsgnew") ); } double s = mail_data->Msgsize(); - int w; - w=0; - - while (s>1024) { - s/=1024; + int w = 0; + s/=1024; + if (s>999.0) { + s/=1024.0; ++w; - if (w>=2) break; } - - QString q=""; - QString fsize=""; - switch(w) { - case 1: - q="k"; + QString fsort; + fsort.sprintf( "%.2f", s ); + QString fsize = QString::number( s, 'f', 2 ); + // 1.23 + // 11.23 + // 111.23 + // 999.23 maxlen + switch(fsize.length() ) { + case 4: + fsort = "00" + fsize ; break; - case 2: - q="M"; + case 5: + fsort = "0" + fsize ; break; default: - break; + fsort = fsize ; + break; + } - - { - QTextOStream o(&fsize); - if (w>0) o.precision(2); else o.precision(0); - o.setf(QTextStream::fixed); - o << s << " " << q << "Byte"; + if ( w == 0 ) { + setText(3, fsize + "kB" ); + mKeyMap.insert(3, "k" + fsort); + //setText(3, "kB" + fsort ); // test only + } else { + //setText(3, fsize + "MB"); + mKeyMap.insert(4, "M" +fsort ); } - setText(1,mail_data->getSubject()); setText(2,mail_data->getFrom()); - setText(3,fsize); + QString date = mail_data->getDate(); int kom = date.find( ",")+2; if ( kom == 1 ) kom = 0; if ( date.mid(kom,1) == " ") ++kom; if ( date.mid(kom+1,1) == " " ) date = "0" + date.mid( kom ); else if ( kom ) date = date.mid( kom ); if ( kom || date.mid(2,1 ) == " ") { @@ -82,34 +86,57 @@ void MailListViewItem::showEntry() else if ( mon == "Jul" ) so = "07"; else if ( mon == "Aug" ) so = "08"; else if ( mon == "Sep" ) so = "09"; else if ( mon == "Oct" ) so = "10"; else if ( mon == "Nov" ) so = "11"; else if ( mon == "Dec" ) so = "12"; - date = date.mid(7,4)+"-"+so+"-"+date.left(2)+" "+date.mid(12,14); + date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); } // if ( date.left(1) != "1" || date.left(1) != "2" ) // date = date.mid(5); - setText(4,date); + mKeyMap.insert(4,date); + setText(4,mail_data->getDate()); } void MailListViewItem::storeData(const RecMailP&data) { mail_data = data; } +void MailListViewItem::setSortKey(int column,const QString &key) +{ + mKeyMap.insert(column,key); +} +QString MailListViewItem::key(int column, bool) const +{ + // to make is fast, we use here special cases + if ( column == 3 || column == 4 ) { + return *mKeyMap.find(column); + } + if ( column == 1 ) { + if ( text(1).left(4).lower() == "re: " ) + return text(1).mid(4); + + } + return text(column); + /* + QMap<int,QString>::ConstIterator it = mKeyMap.find(column); + if (it == mKeyMap.end()) return text(column); + else return *it; + */ +} const RecMailP& MailListViewItem::data()const { return mail_data; } MAILLIB::ATYPE MailListViewItem::wrapperType() { if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; return mail_data->Wrapper()->getType(); } diff --git a/kmicromail/mailistviewitem.h b/kmicromail/mailistviewitem.h index d953d83..cf8040b 100644 --- a/kmicromail/mailistviewitem.h +++ b/kmicromail/mailistviewitem.h @@ -6,18 +6,21 @@ #include <libmailwrapper/maildefines.h> class MailListViewItem:public QListViewItem { public: MailListViewItem(QListView * parent, MailListViewItem * after ); virtual ~MailListViewItem(){} void storeData(const RecMailP&data); const RecMailP&data()const; void showEntry(); MAILLIB::ATYPE wrapperType(); - + QString key(int column, bool) const; + void setSortKey(int column,const QString &key); protected: - RecMailP mail_data; + RecMailP mail_data; + private: + QMap<int,QString> mKeyMap; }; #endif diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 78377ea..ddc7b3e 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp @@ -86,38 +86,38 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) //setCentralWidget( view ); QVBox* wrapperBox = new QVBox( this ); setCentralWidget( wrapperBox ); // QWidget *view = new QWidget( wrapperBox ); KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); folderView = new AccountView( split ); folderView->header()->hide(); - folderView->setRootIsDecorated( true ); + folderView->setRootIsDecorated( false ); folderView->addColumn( tr( "Mailbox" ) ); //layout->addWidget( folderView ); mailView = new QListView( split ); - mailView->addColumn( tr( "" ) ); + mailView->addColumn( tr( " " ) ); mailView->addColumn( tr( "Subject" ),QListView::Manual ); mailView->addColumn( tr( "Sender" ),QListView::Manual ); mailView->addColumn( tr( "Size" ),QListView::Manual); - mailView->addColumn( tr( "Date" )); + mailView->addColumn( tr( "Date" ),QListView::Manual); mailView->setAllColumnsShowFocus(true); //mailView->setSorting(-1); - + mailView->setRootIsDecorated( false ); statusWidget = new StatusWidget( wrapperBox ); statusWidget->hide(); //layout->addWidget( mailView ); //layout->setStretchFactor( folderView, 1 ); //layout->setStretchFactor( mailView, 2 ); slotAdjustLayout(); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); #endif @@ -167,25 +167,25 @@ void MainWindow::slotAdjustLayout() { } */ } void MainWindow::slotAdjustColumns() { bool hidden = folderView->isHidden(); if ( hidden ) folderView->show(); folderView->setColumnWidth( 0, folderView->visibleWidth() ); if ( hidden ) folderView->hide(); mailView->setColumnWidth( 0, 10 ); - mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); + mailView->setColumnWidth( 1, 80 ); mailView->setColumnWidth( 2, 80 ); mailView->setColumnWidth( 3, 50 ); mailView->setColumnWidth( 4, 50 ); } void MainWindow::slotEditSettings() { } void MainWindow::slotShowFolders( bool ) { qDebug("not implemented: "); diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index b1992ec..bdbd93a 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp @@ -139,25 +139,25 @@ void OpieMail::slotSendQueued() smtpList.setAutoDelete(false); Account *it; for ( it = list.first(); it; it = list.next() ) { if ( it->getType() == MAILLIB::A_SMTP ) { smtp = static_cast<SMTPaccount *>(it); smtpList.append(smtp); } } if (smtpList.count()==0) { - QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); + QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); return; } if (smtpList.count()==1) { smtp = smtpList.at(0); } else { smtp = 0; selectsmtp selsmtp; selsmtp.setSelectionlist(&smtpList); selsmtp.showMaximized(); |