~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

Viewing changes to src/historydlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2010-02-19 09:37:12 UTC
  • mfrom: (6.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100219093712-e225xvm1wjcf1cgi
Tags: 0.14-2
* comment out only function which uses va_list to work around build
  problems on armel
* Set Standards-Version to 3.8.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
};
130
130
 
131
131
HistoryDlg::HistoryDlg(const Jid &jid, PsiAccount *pa)
132
 
        : QWidget(0, 0)
133
132
{
134
133
        setAttribute(Qt::WA_DeleteOnClose);
135
134
        if ( PsiOptions::instance()->getOption("options.ui.mac.use-brushed-metal-windows").toBool() )
148
147
        d->h = new EDBHandle(d->pa->edb());
149
148
        connect(d->h, SIGNAL(finished()), SLOT(edb_finished()));
150
149
 
151
 
        QVBoxLayout *vb1 = new QVBoxLayout(this, 8);
 
150
        QVBoxLayout *vb1 = new QVBoxLayout(this);
152
151
        d->lv = new HistoryView(this);
153
152
        d->lv->setVScrollBarMode(Q3ScrollView::AlwaysOn);
154
153
        connect(d->lv, SIGNAL(aOpenEvent(PsiEvent *)), SLOT(actionOpenEvent(PsiEvent *)));
155
154
        QSizePolicy sp = d->lv->sizePolicy();
156
 
        sp.setVerStretch(1);
 
155
        sp.setVerticalStretch(1);
157
156
        d->lv->setSizePolicy(sp);
158
157
        vb1->addWidget(d->lv);
159
158
 
160
 
        QHBoxLayout *hb1 = new QHBoxLayout(vb1);
161
 
 
162
 
        QVBoxLayout *vb2 = new QVBoxLayout(hb1);
163
 
        QHBoxLayout *hb2 = new QHBoxLayout(vb2);
 
159
        QHBoxLayout *hb1 = new QHBoxLayout;
 
160
        vb1->addLayout(hb1);
 
161
 
 
162
        QVBoxLayout *vb2 = new QVBoxLayout;
 
163
        hb1->addLayout(vb2);
 
164
 
 
165
        QHBoxLayout *hb2 = new QHBoxLayout;
 
166
        vb2->addLayout(hb2);
164
167
 
165
168
        //d->busy = new BusyWidget(this);
166
169
        //hb1->addWidget(d->busy);
180
183
        connect(d->pb_next, SIGNAL(clicked()), SLOT(doNext()));
181
184
        hb2->addWidget(d->pb_next);
182
185
 
183
 
        QHBoxLayout *hb3 = new QHBoxLayout(vb2);
 
186
        QHBoxLayout *hb3 = new QHBoxLayout;
 
187
        vb2->addLayout(hb3);
184
188
 
185
189
        d->le_find = new QLineEdit(this);
186
190
        connect(d->le_find, SIGNAL(textChanged(const QString &)), SLOT(le_textChanged(const QString &)));
196
200
        sep->setFrameShape(QFrame::VLine);
197
201
        hb1->addWidget(sep);
198
202
 
199
 
        QVBoxLayout *vb3 = new QVBoxLayout(hb1);
 
203
        QVBoxLayout *vb3 = new QVBoxLayout;
 
204
        hb1->addLayout(vb3);
 
205
 
200
206
        QPushButton *pb_save = new QPushButton(tr("&Export..."), this);
201
207
        connect(pb_save, SIGNAL(clicked()), SLOT(doSave()));
202
208
        vb3->addWidget(pb_save);
210
216
 
211
217
        hb1->addStretch(1);
212
218
 
213
 
        QVBoxLayout *vb4 = new QVBoxLayout(hb1);
 
219
        QVBoxLayout *vb4 = new QVBoxLayout;
 
220
        hb1->addLayout(vb4);
214
221
        vb4->addStretch(1);
215
222
 
216
223
        QPushButton *pb_close = new QPushButton(tr("&Close"), this);
337
344
{
338
345
        //d->lv->setUpdatesEnabled(false);
339
346
        d->lv->clear();
340
 
        Q3PtrListIterator<EDBItem> it(*r);
341
 
        if(direction == EDB::Forward)
342
 
                it.toLast();
 
347
        int i = (direction == EDB::Forward) ? r->count()-1 : 0;
343
348
        int at = 0;
344
 
        for(EDBItem *i; (i = it.current()) && (max == -1 ? true : at < max);) {
345
 
                PsiEvent *e = i->event();
346
 
/*printf(" id=%s", i->id().latin1());
347
 
if(i->prevId())
348
 
        printf(", prevId=%s", i->prevId().latin1());
349
 
if(i->nextId())
350
 
        printf(", nextId=%s", i->nextId().latin1());
351
 
printf("\n");
352
 
if(e->type() == PsiEvent::Message) {
353
 
        MessageEvent *me = (MessageEvent *)e;
354
 
        printf(" body: [%s]\n", me->message().body().latin1());
355
 
}
356
 
else if(e->type() == PsiEvent::Auth) {
357
 
        AuthEvent *ae = (AuthEvent *)e;
358
 
        printf(" authType: [%s]\n", ae->authType().latin1());
359
 
}
360
 
else {
361
 
        printf(" unknown event type\n");
362
 
}
363
 
printf("\n");*/
364
 
 
365
 
                d->lv->addEvent(e, i->prevId());
 
349
        while (i >= 0 && i <= r->count()-1 && (max == -1 ? true : at < max)) {
 
350
                EDBItem* item = r->value(i);
 
351
                PsiEvent* e = item->event();
 
352
                d->lv->addEvent(e, item->prevId());
366
353
                ++at;
367
 
                if(direction == EDB::Backward)
368
 
                        ++it;
369
 
                else
370
 
                        --it;
 
354
                i += (direction == EDB::Forward) ? -1 : +1;
371
355
        }
372
356
        //d->lv->setUpdatesEnabled(true);
373
357
        //d->lv->repaint(true);
379
363
        if(d->h->lastRequestType() == EDBHandle::Read && r) {
380
364
                //printf("EDB: retrieved %d events:\n", r->count());
381
365
                if(r->count() > 0) {
382
 
                        Q3PtrListIterator<EDBItem> it(*r);
383
366
                        if(d->reqtype == 0 || d->reqtype == 1) {
384
367
                                // events are in backward order
385
368
                                // first entry is the end event
386
 
                                it.toFirst();
387
 
                                d->id_end = it.current()->id();
388
 
                                d->id_next = it.current()->nextId();
 
369
                                EDBItem* it = r->first();
 
370
                                d->id_end = it->id();
 
371
                                d->id_next = it->nextId();
389
372
                                // last entry is the begin event
390
 
                                it.toLast();
391
 
                                d->id_begin = it.current()->id();
392
 
                                d->id_prev = it.current()->prevId();
 
373
                                it = r->last();
 
374
                                d->id_begin = it->id();
 
375
                                d->id_prev = it->prevId();
393
376
                                displayResult(r, EDB::Backward);
394
377
                                //printf("[%s],[%s],[%s],[%s]\n", d->id_prev.latin1(), d->id_begin.latin1(), d->id_end.latin1(), d->id_next.latin1());
395
378
                        }
396
379
                        else if(d->reqtype == 2) {
397
380
                                // events are in forward order
398
381
                                // last entry is the end event
399
 
                                it.toLast();
400
 
                                d->id_end = it.current()->id();
401
 
                                d->id_next = it.current()->nextId();
 
382
                                EDBItem* it = r->last();
 
383
                                d->id_end = it->id();
 
384
                                d->id_next = it->nextId();
402
385
                                // first entry is the begin event
403
 
                                it.toFirst();
404
 
                                d->id_begin = it.current()->id();
405
 
                                d->id_prev = it.current()->prevId();
 
386
                                it = r->first();
 
387
                                d->id_begin = it->id();
 
388
                                d->id_prev = it->prevId();
406
389
                                displayResult(r, EDB::Forward);
407
390
                        }
408
391
                        else if(d->reqtype == 3) {
409
392
                                // should only be one entry
410
 
                                EDBItem *ei = it.current();
 
393
                                EDBItem *ei = r->first();
411
394
                                d->reqtype = 1;
412
395
                                d->h->get(d->jid, ei->id(), EDB::Backward, 50);
413
396
                                //printf("EDB: requesting 50 events backward, starting at %s\n", d->id_prev.latin1());
508
491
                }
509
492
 
510
493
                // events are in forward order
511
 
                Q3PtrListIterator<EDBItem> it(*r);
512
 
                for(EDBItem *i; (i = it.current()); ++it) {
513
 
                        id = it.current()->nextId();
514
 
                        PsiEvent *e = i->event();
 
494
                for(int i = 0; i < r->count(); ++i) {
 
495
                        EDBItem* item = r->value(i);
 
496
                        id = item->nextId();
 
497
                        PsiEvent *e = item->event();
515
498
                        QString txt;
516
499
 
517
500
                        QDateTime dt = e->timeStamp();
531
514
                                MessageEvent *me = (MessageEvent *)e;
532
515
                                stream << heading << endl;
533
516
 
534
 
                                QStringList lines = QStringList::split('\n', me->message().body(), true);
535
 
                                for(QStringList::ConstIterator lit = lines.begin(); lit != lines.end(); ++lit) {
536
 
                                        QStringList sub = wrapString(*lit, 72);
537
 
                                        for(QStringList::ConstIterator lit2 = sub.begin(); lit2 != sub.end(); ++lit2) {
538
 
                                                txt += QString("    ") + *lit2 + '\n';
 
517
                                QStringList lines = me->message().body().split('\n', QString::KeepEmptyParts);
 
518
                                foreach(const QString& str, lines) {
 
519
                                        QStringList sub = wrapString(str, 72);
 
520
                                        foreach(const QString& str2, sub) {
 
521
                                                txt += QString("    ") + str2 + '\n';
539
522
                                        }
540
523
                                }
541
524
                        }
755
738
{
756
739
        QColorGroup mycg = cg;
757
740
        if(e->originLocal())
758
 
                mycg.setColor(QColorGroup::Text, Qt::red);
 
741
{
 
742
                mycg.setColor(QColorGroup::Text, PsiOptions::instance()->getOption("options.ui.look.colors.messages.sent").toString() );
 
743
}
759
744
        else
760
 
                mycg.setColor(QColorGroup::Text, Qt::blue);
 
745
{
 
746
                mycg.setColor(QColorGroup::Text,PsiOptions::instance()->getOption("options.ui.look.colors.messages.received").toString() );
 
747
}
761
748
 
762
749
        if(column == 3) {
763
750
                QBrush br;