~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kmidi/log.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *        kmidi
 
3
 *
 
4
 * $Id: log.cpp,v 1.18 2001/05/13 01:55:26 gebauer Exp $
 
5
 *            Copyright (C) 1997  Bernd Wuebben
 
6
 *                 wuebben@math.cornel.edu 
 
7
 *
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or
 
10
 * modify it under the terms of the GNU Library General Public
 
11
 * License as published by the Free Software Foundation; either
 
12
 * version 2 of the License, or (at your option) any later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
17
 * Library General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU Library General Public
 
20
 * License along with this program; if not, write to the Free
 
21
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
22
 */
 
23
 
 
24
#include <stdio.h>
 
25
//#include <kapp.h>
 
26
#include <klocale.h>
 
27
 
 
28
#include "log.moc"
 
29
 
 
30
 
 
31
LogWindow::LogWindow(QWidget *parent, const char *name)
 
32
  : QWidget(parent, name)
 
33
{
 
34
  setCaption(i18n("Info Window"));
 
35
 
 
36
  text_window = new QMultiLineEdit(this,"logwindow");
 
37
  text_window->setFocusPolicy ( QWidget::NoFocus );
 
38
  text_window->setReadOnly( TRUE );
 
39
  text_window->setUndoEnabled( FALSE );
 
40
  //text_window->setMaxLineLength( 24 );
 
41
  text_window->setMaxLines( 110 ); // text_window->numRows() ??
 
42
 
 
43
  stringlist = new QStringList;
 
44
 
 
45
  sltimer = new QTimer(this);
 
46
  connect(sltimer,SIGNAL(timeout()),this,SLOT(updatewindow()));
 
47
  timerset = false;
 
48
 
 
49
}
 
50
 
 
51
 
 
52
LogWindow::~LogWindow() {
 
53
}
 
54
 
 
55
void LogWindow::updatewindow(){
 
56
 
 
57
  static int line = 0, col = 0;
 
58
  timerset = false;
 
59
 
 
60
 
 
61
 
 
62
  if (stringlist->count() != 0){
 
63
 
 
64
    text_window->setAutoUpdate(FALSE);
 
65
 
 
66
    for ( QStringList::Iterator it = stringlist->begin();
 
67
          it != stringlist->end();
 
68
          ++it )
 
69
    {
 
70
      /* after a string starting with "~", don't start a new line --gl */
 
71
        static int tildaflag = 0;
 
72
        int futuretilda, len;
 
73
        QString s = *it;
 
74
        if (s.at(0) == '~') {
 
75
            futuretilda = 1;
 
76
            s = s.remove(0, 1);
 
77
        }
 
78
        else futuretilda = 0;
 
79
        len = s.length();
 
80
        if (tildaflag && len) {
 
81
            text_window->insertAt(s, line, col);
 
82
            col += len;
 
83
        }
 
84
        else {
 
85
            if (line > 100) text_window->removeLine(0);
 
86
            else line++;
 
87
            text_window->insertLine(s,line);
 
88
            col = len;
 
89
        }
 
90
        tildaflag = futuretilda;
 
91
    }
 
92
    text_window->setAutoUpdate(TRUE);
 
93
 
 
94
    text_window->setCursorPosition(line+1,0,FALSE);
 
95
    text_window->repaint(FALSE);
 
96
 
 
97
    stringlist->clear();
 
98
 
 
99
  }
 
100
 
 
101
}
 
102
 
 
103
void LogWindow::insertStr(const QString &string){
 
104
 
 
105
  //if(string.find("Lyric:",0,TRUE) != -1)
 
106
  //  return;
 
107
  
 
108
  if(string.find("MIDI file",0,TRUE) != -1){
 
109
    stringlist->append(" ");
 
110
  }
 
111
 
 
112
  stringlist->append(string);
 
113
 
 
114
  if(!timerset){
 
115
    sltimer->start(10,TRUE); // sinlge shot TRUE
 
116
    timerset = true;
 
117
  }
 
118
 
 
119
}
 
120
void LogWindow::clear(){
 
121
 
 
122
  if(text_window){
 
123
    
 
124
    text_window->clear();
 
125
 
 
126
  }
 
127
 
 
128
}
 
129
 
 
130
void LogWindow::resizeEvent(QResizeEvent* ){
 
131
 
 
132
  int w = width() ;
 
133
  int h = height();
 
134
 
 
135
  text_window->resize(w, h);
 
136
}