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