summaryrefslogtreecommitdiff
path: root/packages/portabase/portabase-1.9/fileselector.patch
blob: 7f70c347e5c9ed260fa3e978e00412c01bf526cf (plain)
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
diff -urN portabase.orig/fileselector.cpp portabase/fileselector.cpp
--- portabase.orig/fileselector.cpp	2004-09-02 20:06:38.000000000 +0200
+++ portabase/fileselector.cpp	2004-09-02 20:59:22.000000000 +0200
@@ -43,8 +43,8 @@
 
 bool PBFileSelector::duplicate()
 {
-    const DocLnk *selection = selected();
-    if (selection == 0) {
+    DocLnk selection(selectedDocument());
+    if (!selection.isValid()) {
         return FALSE;
     }
     bool ok;
@@ -56,7 +56,7 @@
         DocLnk copy;
         configureDocLnk(copy, name);
         FileManager fm;
-        ok = fm.copyFile(*selection, copy);
+        ok = fm.copyFile(selection, copy);
     }
     if (ok) {
         reread();
@@ -65,14 +65,13 @@
         QMessageBox::warning(this, QQDialog::tr("PortaBase"),
                              tr("Unable to create new file"));
     }
-    delete selection;
     return ok;
 }
 
 bool PBFileSelector::rename()
 {
-    const DocLnk *selection = selected();
-    if (selection == 0) {
+    DocLnk selection(selectedDocument());
+    if (!selection.isValid()) {
         return FALSE;
     }
     bool ok;
@@ -88,9 +87,9 @@
         configureDocLnk(copy, name);
         // actual moving would be more efficient, but harder to implement...
         FileManager fm;
-        if (fm.copyFile(*selection, copy)) {
-            QFile::remove(selection->file());
-            QFile::remove(selection->linkFile());
+        if (fm.copyFile(selection, copy)) {
+            QFile::remove(selection.file());
+            QFile::remove(selection.linkFile());
             ok = TRUE;
         }
         else {
@@ -104,7 +103,6 @@
         QMessageBox::warning(this, QQDialog::tr("PortaBase"),
                              tr("Unable to rename the file"));
     }
-    delete selection;
     return ok;
 }
 
diff -urN portabase.orig/importdialog.cpp portabase/importdialog.cpp
--- portabase.orig/importdialog.cpp	2004-09-02 20:06:38.000000000 +0200
+++ portabase/importdialog.cpp	2004-09-02 20:54:47.000000000 +0200
@@ -130,14 +130,13 @@
     int result = QDialog::exec();
     if (result && !importDone) {
         // "OK" was clicked...see if there is a selected file
-        const DocLnk *f = selector->selected();
-        if (!f) {
+        DocLnk f(selector->selectedDocument());
+        if (!f.isValid()) {
             return QDialog::Rejected;
         }
-        if (!import(f->file())) {
+        if (!import(f.file())) {
             result = QDialog::Rejected;
         }
-        delete f;
     }
     return result;
 }
diff -urN portabase.orig/portabase.cpp portabase/portabase.cpp
--- portabase.orig/portabase.cpp	2004-09-02 20:06:38.000000000 +0200
+++ portabase/portabase.cpp	2004-09-02 20:56:58.000000000 +0200
@@ -527,12 +527,11 @@
 
 void PortaBase::openFile()
 {
-    const DocLnk *selection = fileSelector->selected();
-    if (selection == 0) {
+    DocLnk selection (fileSelector->selectedDocument());
+    if (!selection.isValid()) {
         return;
     }
-    openFile(*selection);
-    delete selection;
+    openFile(selection);
 }
 
 void PortaBase::openFile(const QString &f)
@@ -591,21 +590,19 @@
 
 void PortaBase::deleteFile()
 {
-    const DocLnk *selection = fileSelector->selected();
-    if (selection == 0) {
+    DocLnk selection(fileSelector->selectedDocument());
+    if (!selection.isValid()) {
         return;
     }
     if (QMessageBox::warning(this, QQDialog::tr("PortaBase"), tr("Delete")
-                             + " \"" + selection->name() + "\"\n"
+                             + " \"" + selection.name() + "\"\n"
                              + tr("Are you sure?"),
                              QObject::tr("Yes"), QObject::tr("No"),
                              QString::null, 1) > 0) {
-        delete selection;
         return;
     }
-    QFile::remove(selection->file());
-    QFile::remove(selection->linkFile());
-    delete selection;
+    QFile::remove(selection.file());
+    QFile::remove(selection.linkFile());
     fileSelector->reread();
 }