~ubuntu-branches/ubuntu/dapper/ksystemlog/dapper

« back to all changes in this revision

Viewing changes to ksystemlog/src/cups/cupsOptions.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-07-07 16:00:00 UTC
  • Revision ID: james.westby@ubuntu.com-20050707160000-a104d769ph3yfkg4
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2005 by Nicolas Ternisien                               *
 
3
 *   nicolas.ternisien@gmail.com                                           *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, write to the                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
 ***************************************************************************/
 
20
 
 
21
//Qt includes
 
22
#include <qlayout.h>
 
23
#include <qvgroupbox.h>
 
24
#include <qbuttongroup.h>
 
25
#include <qlabel.h>
 
26
#include <qpushbutton.h>
 
27
#include <qvbox.h>
 
28
#include <qhbox.h>
 
29
 
 
30
//KDE includes
 
31
#include <klocale.h>
 
32
#include <kactioncollection.h>
 
33
#include <kbuttonbox.h>
 
34
#include <klistbox.h>
 
35
#include <kfiledialog.h>
 
36
#include <kurl.h>
 
37
#include <kmessagebox.h>
 
38
#include <kiconloader.h>
 
39
#include <kdebug.h>
 
40
 
 
41
//Project includes
 
42
#include "cupsOptions.h"
 
43
#include "ksystemlogConfig.h"
 
44
 
 
45
CupsOptions::CupsOptions(QWidget *parent) :
 
46
        QWidget(parent),
 
47
        tabs(this, "tabs"),
 
48
        cupsFileList(this, i18n("<qt><p>These files will be analyzed to display <b>Cups log</b>. This list also determines the order in which the files are read.</p></qt>")),
 
49
        cupsAccessFileList(this, i18n("<qt><p>These files will be analyzed to display <b>Cups Web Server log</b>. This list also determines the order in which the files are read.</p></qt>"))
 
50
        {
 
51
        
 
52
        QHBoxLayout *layout = new QHBoxLayout(this);
 
53
        layout->setAutoAdd(true);
 
54
 
 
55
        tabs.addTab(&cupsFileList, Globals::cupsMode->pixmap, Globals::cupsMode->name);
 
56
        tabs.addTab(&cupsAccessFileList, Globals::cupsAccessMode->pixmap, Globals::cupsAccessMode->name);
 
57
        
 
58
        connect(&cupsFileList, SIGNAL(fileListChanged(int)), this, SLOT(slotFileListChanged(int)));
 
59
        connect(&cupsAccessFileList, SIGNAL(fileListChanged(int)), this, SLOT(slotFileListChanged(int)));
 
60
        
 
61
        readConfig();
 
62
        
 
63
 
 
64
}
 
65
 
 
66
CupsOptions::~CupsOptions() {
 
67
 
 
68
}
 
69
 
 
70
bool CupsOptions::isValid() {
 
71
        if (cupsFileList.count()>0 && cupsAccessFileList.count()>0)
 
72
                return(true);
 
73
        else
 
74
                return(false);
 
75
}
 
76
 
 
77
void CupsOptions::slotFileListChanged(int itemLeft) {
 
78
        if (itemLeft==0)
 
79
                emit optionsChanged(false);
 
80
        else
 
81
                emit optionsChanged(true);
 
82
}
 
83
 
 
84
void CupsOptions::saveConfig() {
 
85
        kdDebug() << "Save config from CupsOptions" << endl;
 
86
        
 
87
        QStringList list;
 
88
        
 
89
        int count=cupsFileList.count();
 
90
        
 
91
        for (int i=0; i<count; i++) {
 
92
                list.push_back(cupsFileList.getText(i));
 
93
        }
 
94
        
 
95
        KSystemLogConfig::setCupsPaths(list);
 
96
 
 
97
        list.clear();
 
98
        
 
99
        count=cupsAccessFileList.count();
 
100
        
 
101
        for (int i=0; i<count; i++) {
 
102
                list.push_back(cupsAccessFileList.getText(i));
 
103
        }
 
104
        
 
105
        KSystemLogConfig::setCupsAccessPaths(list);
 
106
 
 
107
}
 
108
 
 
109
void CupsOptions::readConfig() {
 
110
        QStringList cupsFiles(KSystemLogConfig::cupsPaths());
 
111
                
 
112
        QStringList::iterator it;
 
113
        for(it=cupsFiles.begin(); it!=cupsFiles.end(); ++it) {
 
114
                cupsFileList.insertItem(*it);
 
115
        }
 
116
 
 
117
        QStringList cupsAccessFiles(KSystemLogConfig::cupsAccessPaths());
 
118
                
 
119
        for(it=cupsAccessFiles.begin(); it!=cupsAccessFiles.end(); ++it) {
 
120
                cupsAccessFileList.insertItem(*it);
 
121
        }
 
122
}
 
123
 
 
124
#include "cupsOptions.moc"