~ubuntu-branches/ubuntu/lucid/konversation/lucid-updates

« back to all changes in this revision

Viewing changes to src/viewer/chatwindow.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Modestas Vainius
  • Date: 2009-05-15 11:24:24 UTC
  • mfrom: (1.15.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 47.
  • Revision ID: james.westby@ubuntu.com-20090515112424-b74i26lciabf4qnk
Tags: 1.1.75+svn968012-1
* New upstream development snapshot:
  - Last Changed Author: hein
  - Last Changed Rev: 968012
  - Last Changed Date: 2009-05-14 21:03:55 +0300
* Update README.source.
* Use dh --quilt instead of custom patch handling, build depend on
  quilt 0.46-7~.
* Update patches to upstream changes.
* Update konversation.install: remove docs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
    textView->appendRaw(message, suppressTimestamps);
142
142
}
143
143
 
 
144
void ChatWindow::appendLog(const QString& message)
 
145
{
 
146
    if(!textView) return;
 
147
    textView->appendLog(message);
 
148
}
 
149
 
144
150
void ChatWindow::append(const QString& nickname,const QString& message)
145
151
{
146
152
    if(!textView) return ;
248
254
                    if(backlog.device()->size() > packetSize * ( offset + 1 ))
249
255
                    {
250
256
                        // Set file pointer to the packet size above the offset
251
 
                        backlog.device()->seek(backlog.device()->size() - packetSize * ( offset + 1 ));
 
257
                        backlog.seek(backlog.device()->size() - packetSize * ( offset + 1 ));
252
258
                        // Skip first line, since it may be incomplete
253
259
                        backlog.readLine();
254
260
                    }
255
261
                    else
256
262
                    {
257
263
                        // Set file pointer to the head
258
 
                        backlog.device()->reset();
 
264
 
 
265
                        // Qt 4.5 Doc: Note that when using a QTextStream on a
 
266
                        // QFile, calling reset() on the QFile will not have the
 
267
                        // expected result because QTextStream buffers the  file.
 
268
                        // Use the QTextStream::seek() function instead.
 
269
                        // backlog.device()->reset();
 
270
                        backlog.seek( 0 );
259
271
                    }
260
272
 
261
 
                    qint64 currentPacketHeadPosition = backlog.device()->pos();
 
273
                    qint64 currentPacketHeadPosition = backlog.pos();
262
274
 
263
275
                    // Loop until end of file reached
264
 
                    while(!backlog.atEnd() && backlog.device()->pos() < lastPacketHeadPosition)
 
276
                    while(!backlog.atEnd() && backlog.pos() < lastPacketHeadPosition)
265
277
                    {
266
278
                        // remember actual file position to check for deadlocks
267
 
                        filePosition = backlog.device()->pos();
 
279
                        filePosition = backlog.pos();
268
280
                        backlogLine = backlog.readLine();
269
281
 
270
282
                        // check for deadlocks
271
 
                        if(backlog.device()->pos() == filePosition) backlog.device()->seek(filePosition + 1);
 
283
                        if(backlog.pos() == filePosition)
 
284
                        {
 
285
                            backlog.seek(filePosition + 1);
 
286
                        }
272
287
 
273
 
                        // if a tab character is present in the line
 
288
                        // if a tab character is present in the line, meaning it is a valid chatline
274
289
                        if (backlogLine.contains('\t'))
275
290
                        {
276
291
                            // extract first column from log
309
324
                QStringList::Iterator itFirstColumn = firstColumns.begin();
310
325
                QStringList::Iterator itMessage = messages.begin();
311
326
                for( ; itFirstColumn != firstColumns.end() ; ++itFirstColumn, ++itMessage )
 
327
                {
312
328
                    appendBacklogMessage(*itFirstColumn, *itMessage);
 
329
                }
313
330
            }
314
331
        } // if(Preferences::showBacklog())
315
332
    }
349
366
            // close file
350
367
            logfile.close();
351
368
        }
352
 
        else kWarning() << "ChatWindow::logText(): open(QIODevice::Append) for " << logfile.fileName() << " failed!" << endl;
 
369
        else kWarning() << "open(QIODevice::Append) for " << logfile.fileName() << " failed!";
353
370
    }
354
371
}
355
372