~ubuntu-branches/ubuntu/lucid/ktorrent/lucid

« back to all changes in this revision

Viewing changes to plugins/scanfolder/scanfolderprefpagewidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Richard Birnie
  • Date: 2008-06-03 20:32:46 UTC
  • mfrom: (1.1.20 upstream)
  • Revision ID: james.westby@ubuntu.com-20080603203246-dfyemn010uhsf433
Tags: 3.1~rc1+dfsg.1-1ubuntu1
* New upstream development release      
 - Dropped 01_support_external_libbtcore.diffm,
   97_fix_target_link_libraries.diff,
   99_libbtcore_scramble_soname.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2006 by Ivan Vasić                                                                      *
3
 
 *   ivasic@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
 
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
19
 
 ***************************************************************************/
20
 
#include "scanfolderprefpagewidget.h"
21
 
#include "scanfolderpluginsettings.h"
22
 
 
23
 
#include <qwidget.h>
24
 
#include <qstring.h>
25
 
#include <qcheckbox.h>
26
 
#include <qfile.h>
27
 
 
28
 
#include <kglobal.h>
29
 
#include <klocale.h>
30
 
#include <kmessagebox.h>
31
 
#include <kurlrequester.h>
32
 
 
33
 
namespace kt
34
 
{
35
 
        ScanFolderPrefPageWidget::ScanFolderPrefPageWidget(QWidget *parent, const char *name)
36
 
                        :SfPrefPageWidgetBase(parent, name)
37
 
        {
38
 
                use1->setChecked(ScanFolderPluginSettings::useFolder1());
39
 
                use2->setChecked(ScanFolderPluginSettings::useFolder2());
40
 
                use3->setChecked(ScanFolderPluginSettings::useFolder3());
41
 
 
42
 
                url1->setURL(ScanFolderPluginSettings::folder1());
43
 
                url2->setURL(ScanFolderPluginSettings::folder2());
44
 
                url3->setURL(ScanFolderPluginSettings::folder3());
45
 
 
46
 
                openSilently->setChecked(ScanFolderPluginSettings::openSilently());
47
 
                deleteCheck->setChecked(ScanFolderPluginSettings::actionDelete());
48
 
                moveCheck->setChecked(ScanFolderPluginSettings::actionMove());
49
 
 
50
 
                url1->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly);
51
 
                url2->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly);
52
 
                url3->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly);
53
 
        }
54
 
 
55
 
        void ScanFolderPrefPageWidget::apply()
56
 
        {
57
 
                bool usesf1 = use1->isChecked();
58
 
                bool usesf2 = use2->isChecked();
59
 
                bool usesf3 = use3->isChecked();
60
 
 
61
 
                QString sfPath1 = url1->url();
62
 
                QString sfPath2 = url2->url();
63
 
                QString sfPath3 = url3->url();
64
 
 
65
 
                bool silently = openSilently->isChecked();
66
 
                bool deleteChecked = deleteCheck->isChecked();
67
 
                bool moveChecked = moveCheck->isChecked();
68
 
 
69
 
                ScanFolderPluginSettings::setOpenSilently(silently);
70
 
                ScanFolderPluginSettings::setActionDelete(deleteChecked);
71
 
                ScanFolderPluginSettings::setActionMove(moveChecked);
72
 
                
73
 
                QString message = i18n( "ScanFolder - Folder %1: Invalid URL or folder does not exist. Please, choose a valid directory." );
74
 
                if(!QFile::exists(sfPath1) && usesf1)
75
 
                {
76
 
                        KMessageBox::sorry(0, message.arg( 1 ) );
77
 
                        usesf1 = false;
78
 
                }
79
 
                else
80
 
                        ScanFolderPluginSettings::setFolder1(sfPath1);
81
 
 
82
 
                if(!QFile::exists(sfPath2) && usesf2)
83
 
                {
84
 
                        KMessageBox::sorry(0, message.arg( 2 ) );
85
 
                        usesf2 = false;
86
 
                }
87
 
                else
88
 
                        ScanFolderPluginSettings::setFolder2(sfPath2);
89
 
 
90
 
                if(!QFile::exists(sfPath3) && usesf3)
91
 
                {
92
 
                        KMessageBox::sorry(0, message.arg( 3 ) );
93
 
                        usesf3 = false;
94
 
                }
95
 
                else
96
 
                        ScanFolderPluginSettings::setFolder3(sfPath3);
97
 
 
98
 
 
99
 
                ScanFolderPluginSettings::setUseFolder1(usesf1);
100
 
                ScanFolderPluginSettings::setUseFolder2(usesf2);
101
 
                ScanFolderPluginSettings::setUseFolder3(usesf3);
102
 
 
103
 
                ScanFolderPluginSettings::writeConfig();
104
 
        }
105
 
 
106
 
}
107
 
#include "scanfolderprefpagewidget.moc"