~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to kioslave/digikamsearch.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
 
51
51
kio_digikamsearch::kio_digikamsearch(const QByteArray& pool_socket,
52
52
                                     const QByteArray& app_socket)
53
 
                 : SlaveBase("kio_digikamsearch", pool_socket, app_socket)
 
53
    : SlaveBase("kio_digikamsearch", pool_socket, app_socket)
54
54
{
55
55
}
56
56
 
67
67
 
68
68
    QDataStream ds(data);
69
69
    ds >> kurl;
 
70
 
70
71
    if (!ds.atEnd())
 
72
    {
71
73
        ds >> listingType;
 
74
    }
72
75
 
73
76
    kDebug() << "kio_digikamsearch::special " << kurl;
74
77
 
87
90
        {
88
91
            // send data every 200 images to be more responsive
89
92
            Digikam::ImageListerSlaveBasePartsSendingReceiver receiver(this, 200);
 
93
 
90
94
            if (info.type == Digikam::DatabaseSearch::HaarSearch)
 
95
            {
91
96
                lister.listHaarSearch(&receiver, info.query);
 
97
            }
92
98
            else
 
99
            {
93
100
                lister.listSearch(&receiver, info.query);
 
101
            }
 
102
 
94
103
            if (!receiver.hasError)
 
104
            {
95
105
                receiver.sendData();
 
106
            }
96
107
        }
97
108
        else
98
109
        {
99
110
            Digikam::ImageListerSlaveBaseReceiver receiver(this);
100
111
            // fast mode: limit results to 500
101
112
            lister.listSearch(&receiver, info.query, 500);
 
113
 
102
114
            if (!receiver.hasError)
 
115
            {
103
116
                receiver.sendData();
 
117
            }
104
118
        }
105
119
    }
106
120
    else
122
136
            foreach(const QString& idString, albumIdsStringList)
123
137
            {
124
138
                id = idString.toInt(&ok);
 
139
 
125
140
                if (ok)
 
141
                {
126
142
                    albumIds << id;
 
143
                }
127
144
            }
128
145
 
129
146
            foreach(const QString& idString, tagIdsStringList)
130
147
            {
131
148
                id = idString.toInt(&ok);
 
149
 
132
150
                if (ok)
 
151
                {
133
152
                    tagIds << id;
 
153
                }
134
154
            }
135
155
        }
136
156
 
146
166
        // 40% sound like the minimum value to use to have suitable results.
147
167
        bool ok;
148
168
        double threshold = thresholdString.toDouble(&ok);
 
169
 
149
170
        if (!ok)
 
171
        {
150
172
            threshold = 0.4;
 
173
        }
151
174
 
152
175
        // route progress info to KIOSlave facilities
153
176
        class DuplicatesProgressObserver : public Digikam::HaarProgressObserver
154
177
        {
155
 
            public:
156
 
                DuplicatesProgressObserver(KIO::SlaveBase *slave) : m_slave(slave) {}
157
 
 
158
 
                virtual void totalNumberToScan(int number)
159
 
                {
160
 
                    m_slave->totalSize(number);
161
 
                }
162
 
                virtual void processedNumber(int number)
163
 
                {
164
 
                    m_slave->processedSize(number);
165
 
                }
166
 
 
167
 
            private:
168
 
                KIO::SlaveBase *m_slave;
 
178
        public:
 
179
            DuplicatesProgressObserver(KIO::SlaveBase* slave) : m_slave(slave) {}
 
180
 
 
181
            virtual void totalNumberToScan(int number)
 
182
            {
 
183
                m_slave->totalSize(number);
 
184
            }
 
185
            virtual void processedNumber(int number)
 
186
            {
 
187
                m_slave->processedSize(number);
 
188
            }
 
189
 
 
190
        private:
 
191
            KIO::SlaveBase* m_slave;
169
192
        };
170
193
        DuplicatesProgressObserver observer(this);
171
194
 
173
196
        Digikam::HaarIface iface;
174
197
        iface.rebuildDuplicatesAlbums(albumIds, tagIds, threshold, &observer);
175
198
    }
 
199
 
176
200
    finished();
177
201
}
178
202
 
180
204
 
181
205
extern "C"
182
206
{
183
 
    KDE_EXPORT int kdemain(int argc, char **argv)
 
207
    KDE_EXPORT int kdemain(int argc, char** argv)
184
208
    {
185
209
        // Needed to load SQL driver plugins
186
210
        QCoreApplication app(argc, argv);