File: prefmisc.cpp

package info (click to toggle)
kdbg 1.2.4-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,504 kB
  • ctags: 1,945
  • sloc: cpp: 15,961; sh: 8,183; makefile: 481; perl: 71; ansic: 16
file content (94 lines) | stat: -rw-r--r-- 2,714 bytes parent folder | download
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
// $Id: prefmisc.cpp,v 1.4 2000/06/17 11:52:33 jsixt Exp $

// Copyright by Johannes Sixt
// This file is under GPL, the GNU General Public Licence

#include "prefmisc.h"
#if QT_VERSION >= 200
#include <klocale.h>			/* i18n */
#else
#include <kapp.h>			/* i18n */
#endif
#include <stdlib.h>			/* atoi */

PrefMisc::PrefMisc(QWidget* parent) :
	QWidget(parent, "debugger"),
	m_grid(this, 6, 2, 10),
	m_popForeground(this, "pop_fore"),
	m_backTimeoutLabel(this, "back_to_lab"),
	m_backTimeout(this, "back_to"),
	m_tabWidthLabel(this, "tabwidth_lab"),
	m_tabWidth(this, "tabwidth"),
	m_sourceFilterLabel(this, "sourcefilter_lab"),
	m_sourceFilter(this, "sourcefilter"),
	m_headerFilterLabel(this, "headerfilter_lab"),
	m_headerFilter(this, "headerfilter")
{
    m_popForeground.setText(i18n("&Pop into foreground when program stops"));
    m_popForeground.setMinimumSize(m_popForeground.sizeHint());
    m_grid.addMultiCellWidget(&m_popForeground, 0, 0, 0, 1);
    m_grid.addRowSpacing(0, m_popForeground.sizeHint().height());

    m_backTimeoutLabel.setText(i18n("Time until window goes &back (in milliseconds):"));
    m_backTimeoutLabel.setMinimumSize(m_backTimeoutLabel.sizeHint());
    m_backTimeoutLabel.setBuddy(&m_backTimeout);
    m_backTimeout.setMinimumSize(m_backTimeout.sizeHint());
    m_grid.addWidget(&m_backTimeoutLabel, 1, 0);
    m_grid.addWidget(&m_backTimeout, 1, 1);

    setupEditGroup(i18n("&Tabstop every (characters):"),
		   m_tabWidthLabel, m_tabWidth, 2);
    setupEditGroup(i18n("File filter for &source files:"),
		   m_sourceFilterLabel, m_sourceFilter, 3);
    setupEditGroup(i18n("File filter for &header files:"),
		   m_headerFilterLabel, m_headerFilter, 4);

    m_grid.setColStretch(1, 10);
    // last (empty) row gets all the vertical stretch
    m_grid.setRowStretch(5, 10);
}

void PrefMisc::setupEditGroup(const QString& label, QLabel& labWidget, QLineEdit& edit, int row)
{
    labWidget.setText(label);
    labWidget.setMinimumSize(labWidget.sizeHint());
    labWidget.setBuddy(&edit);
    edit.setMinimumSize(edit.sizeHint());
    m_grid.addWidget(&labWidget, row, 0);
    m_grid.addWidget(&edit, row, 1);
}

static int readNumeric(const QLineEdit& edit)
{
    QString str = edit.text();
#if QT_VERSION < 200
    const char* s = str;
#else
    const char* s = str.latin1();
#endif
    return atoi(s);
}

int PrefMisc::backTimeout() const
{
    return readNumeric(m_backTimeout);
}

void PrefMisc::setBackTimeout(int to)
{
    QString str;
    str.setNum(to);
    m_backTimeout.setText(str);
}

int PrefMisc::tabWidth() const
{
    return readNumeric(m_tabWidth);
}

void PrefMisc::setTabWidth(int tw)
{
    QString str;
    str.setNum(tw);
    m_tabWidth.setText(str);
}