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
|
/***************************************************************************
* *
* Copyright (C) 2005, 2006 by Kevin Gilbert *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU 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 General Public License for more details. *
* *
* You should have received a copy of the GNU 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 <ntqcheckbox.h>
#include <ntqlabel.h>
#include <ntqlayout.h>
#include <ntqlineedit.h>
#include <kdebug.h>
#include <tdelocale.h>
#include <tdemessagebox.h>
#include "scannamedialog.h"
#include "scanwidget.h"
// constructor
// ===========
ScanNameDialog::ScanNameDialog( ScanWidget* scanWidget, TQWidget* parent, const char* name )
: KDialogBase( Plain, "Scan name", Ok | Cancel, Ok, parent, name )
{ createlayout( );
if( scanWidget != NULL )
{ m_scanNameEdit->setText( scanWidget->scanName( ));
m_useHostNameCheckbox->setChecked( scanWidget->useTargetHost( ));
}
if( !m_useHostNameCheckbox->isChecked( ))
m_scanNameEdit->setFocus( );
}
// createlayout
// ============
void ScanNameDialog::createlayout( )
{ TQGridLayout* gridLayout = new TQGridLayout( plainPage( ));
byte row = 1;
m_useHostNameCheckbox = new TQCheckBox( "Use Target Host name", plainPage( ), "use target checkbox" );
gridLayout->addWidget( m_useHostNameCheckbox, row++, 1 );
byte editRowTop = row++;
m_scanNameEdit = new TQLineEdit( plainPage( ), "name edit" );
gridLayout->addWidget( new TQLabel( "Scan name", plainPage( ), "name label" ), row++, 1 );
gridLayout->addWidget( m_scanNameEdit, row++, 1 );
gridLayout->setColStretch( 0, 1 );
gridLayout->setColStretch( 1, 5 );
gridLayout->setColStretch( 2, 1 );
gridLayout->setRowStretch( 0, 1 );
gridLayout->setRowStretch( editRowTop, 1 );
gridLayout->setRowStretch( row, 1 );
m_useHostNameCheckbox->setChecked( true );
slotUseHostNameToggled( true );
connect( m_useHostNameCheckbox, SIGNAL( toggled( bool )), SLOT( slotUseHostNameToggled( bool )));
}
// slotOk
// ======
void ScanNameDialog::slotOk( )
{ m_scanName = m_scanNameEdit->text( );
m_useHostName = m_useHostNameCheckbox->isChecked( );
if( !m_useHostName && m_scanName.isEmpty( ))
{ KMessageBox::sorry( this, "Please enter a name or select \"Use Target Host name\"", "No scan name" );
return;
}
KDialogBase::slotOk( );
}
// slotUseHostNameToggled
// ======================
void ScanNameDialog::slotUseHostNameToggled( bool on )
{ m_scanNameEdit->setEnabled( !on );
if( !on )
m_scanNameEdit->setFocus( );
}
|