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
|
/***************************************************************************
begin : Tue Aug 31 21:59:58 EST 2004
copyright : (C) 2004 by Michael Pyne <michael.pyne@kdemail.net>
(C) 2006 by Ian Monroe <ian@monroe.nu>
(C) 2006 by Aurelien Gateau <aurelien.gateau@free.fr>
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include <tdeconfig.h>
#include <tdeversion.h>
#include <kdialogbase.h>
#include <tdeglobal.h>
#include <kiconloader.h>
#include <tdeio/job.h>
#include <tdelocale.h>
#include <kstdguiitem.h>
#include <kurl.h>
#include <tqstringlist.h>
#include <tqcheckbox.h>
#include <tqlayout.h>
#include <tqlabel.h>
#include <tqtimer.h>
#include <tqvbox.h>
#include <tqhbox.h>
#include <tqpushbutton.h>
#include "fileoperationconfig.h"
#include "deletedialog.h"
#include "deletedialogbase.h"
namespace Gwenview {
DeleteDialog::DeleteDialog(TQWidget *parent, const char *name) :
KDialogBase(Swallow, WStyle_DialogBorder, parent, name,
true /* modal */, i18n("About to delete selected files"),
Ok | Cancel, Cancel /* Default */, true /* separator */),
m_trashGuiItem(i18n("&Send to Trash"), "trashcan_full")
{
m_widget = new DeleteDialogBase(this, "delete_dialog_widget");
setMainWidget(m_widget);
m_widget->setMinimumSize(400, 300);
actionButton(Ok)->setFocus();
bool deleteInstead = ! FileOperationConfig::deleteToTrash();
m_widget->ddShouldDelete->setChecked(deleteInstead);
connect(m_widget->ddShouldDelete, TQT_SIGNAL(toggled(bool)), TQT_SLOT(updateUI()));
}
void DeleteDialog::setURLList(const KURL::List &files)
{
m_widget->ddFileList->clear();
for( KURL::List::ConstIterator it = files.begin(); it != files.end(); it++) {
m_widget->ddFileList->insertItem( (*it).pathOrURL() );
}
m_widget->ddNumFiles->setText(i18n("<b>1</b> item selected.", "<b>%n</b> items selected.", files.count()));
updateUI();
}
void DeleteDialog::accept()
{
FileOperationConfig::setDeleteToTrash( ! shouldDelete() );
FileOperationConfig::writeConfig();
KDialogBase::accept();
}
void DeleteDialog::updateUI()
{
TQString msg, iconName;
int fileCount = m_widget->ddFileList->count();
bool reallyDelete = m_widget->ddShouldDelete->isChecked();
if(reallyDelete) {
msg = i18n(
"<qt>This item will be <b>permanently deleted</b> from your hard disk.</qt>",
"<qt>These items will be <b>permanently deleted</b> from your hard disk.</qt>",
fileCount);
iconName = "messagebox_warning";
}
else {
msg = i18n(
"<qt>This item will be moved to the trash bin.</qt>",
"<qt>These items will be moved to the trash bin.</qt>",
fileCount);
iconName = "trashcan_full";
}
TQPixmap icon = TDEGlobal::iconLoader()->loadIcon(iconName, TDEIcon::NoGroup, TDEIcon::SizeMedium);
m_widget->ddDeleteText->setText(msg);
m_widget->ddWarningIcon->setPixmap(icon);
setButtonGuiItem(Ok, reallyDelete ? KStdGuiItem::del() : m_trashGuiItem);
adjustSize();
}
bool DeleteDialog::shouldDelete() const {
return m_widget->ddShouldDelete->isChecked();
}
TQSize DeleteDialog::sizeHint() const {
m_widget->adjustSize();
TQSize hint = m_widget->minimumSize();
hint = calculateSize(hint.width(), hint.height());
// For some reason calculateSize does not return a correct height. As I'm
// fed up fighting with it, let's just add a few more pixels.
hint.rheight() += 50;
return hint;
}
} // namespace
#include "deletedialog.moc"
// vim: set et ts=4 sw=4:
|