Mercurial > octave
annotate libgui/src/find-files-model.cc @ 22022:278fc29b69ca
maint: Eliminate unnecessary double newline blocks (only whitespace changes).
* Figure.cc, annotation-dialog.cc, dialog.cc, dialog.h, files-dock-widget.cc,
find-files-dialog.cc, find-files-model.cc, file-editor-tab.cc, file-editor.cc,
find-dialog.cc, octave-qscintilla.cc, octave-txt-lexer.cc, main-window.cc,
main-window.h, octave-cmd.cc, octave-cmd.h, octave-dock-widget.cc,
octave-qt-link.cc, parser.h, webinfo.cc, settings-dialog.cc,
shortcut-manager.cc, shortcut-manager.h, welcome-wizard.cc, workspace-model.cc,
__ilu__.cc, __lin_interpn__.cc, besselj.cc, bsxfun.cc, cellfun.cc, conv2.cc,
data.cc, debug.cc, debug.h, dynamic-ld.cc, fft2.cc, file-io.cc,
ft-text-renderer.cc, gl-render.cc, gl2ps-print.cc, graphics.cc, graphics.in.h,
help.cc, jit-typeinfo.cc, jit-typeinfo.h, kron.cc, ls-ascii-helper.cc,
ls-hdf5.cc, ls-hdf5.h, ls-mat5.cc, max.cc, oct-map.cc, oct-map.h,
oct-stream.cc, octave-link.h, pr-output.cc, pt-jit.cc, qz.cc, sparse-xdiv.cc,
sparse-xpow.cc, strfind.cc, strfns.cc, symtab.h, toplev.cc, toplev.h,
typecast.cc, utils.cc, variables.cc, xdiv.h, xpow.cc, xpow.h, zfstream.cc,
__eigs__.cc, __init_fltk__.cc, audioread.cc, ccolamd.cc, chol.cc, qr.cc,
ov-base-diag.cc, ov-base-int.cc, ov-base-sparse.cc, ov-base.cc, ov-base.h,
ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc,
ov-bool.h, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-class.cc, ov-class.h,
ov-classdef.cc, ov-complex.cc, ov-complex.h, ov-cs-list.cc, ov-cs-list.h,
ov-cx-diag.cc, ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc,
ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.h, ov-fcn-inline.h,
ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h,
ov-flt-cx-diag.cc, ov-flt-cx-diag.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h,
ov-flt-re-diag.cc, ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-int16.cc,
ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-intx.h, ov-lazy-idx.cc, ov-lazy-idx.h,
ov-mex-fcn.h, ov-null-mat.h, ov-perm.cc, ov-perm.h, ov-range.cc, ov-range.h,
ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc, ov-re-sparse.cc, ov-re-sparse.h,
ov-scalar.cc, ov-scalar.h, ov-str-mat.h, ov-struct.cc, ov-struct.h,
ov-type-conv.h, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc,
ov-usr-fcn.cc, ov-usr-fcn.h, ov.h, op-cm-m.cc, op-fcm-fm.cc, op-fm-fm.cc,
op-int.h, op-m-m.cc, op-pm-template.cc, pt-binop.h, pt-select.cc, pt-stmt.cc,
pt-unop.h, Array-util.cc, Array.cc, Array.h, CColVector.cc, CMatrix.cc,
CMatrix.h, CSparse.cc, MArray.cc, MSparse.cc, MatrixType.cc, PermMatrix.cc,
Range.cc, Sparse-C.cc, Sparse.cc, dMatrix.cc, dim-vector.h, fCColVector.cc,
fCMatrix.cc, fMatrix.cc, fMatrix.h, idx-vector.cc, idx-vector.h, blaswrap.c,
f77-fcn.h, DASPK.cc, eigs-base.cc, hess.cc, lo-specfun.cc, oct-fftw.cc,
oct-norm.cc, oct-rand.cc, oct-rand.h, qr.cc, qrp.cc, randmtzig.cc,
randpoisson.cc, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, Sparse-op-defs.h,
mx-inlines.cc, oct-env.h, cmd-edit.cc, f2c-main.c, lo-array-errwarn.cc,
lo-array-errwarn.h, lo-array-gripes.cc, lo-array-gripes.h, lo-ieee.h,
lo-regexp.cc, oct-binmap.h, oct-inttypes.cc, oct-inttypes.h, oct-sort.cc,
oct-sort.h, mkoctfile.in.cc:
maint: Eliminate unnecessary double newline blocks (only whitespace changes).
author | Rik <rik@octave.org> |
---|---|
date | Fri, 01 Jul 2016 19:48:35 -0700 |
parents | aba2e6293dd8 |
children | bac0d6f07a3e |
rev | line source |
---|---|
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
1 /* |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
2 |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18678
diff
changeset
|
3 Copyright (C) 2013-2015 John Donoghue |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
4 |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
5 This file is part of Octave. |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
6 |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
10 option) any later version. |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
11 |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
15 for more details. |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
16 |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
20 |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
21 */ |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
24 # include "config.h" |
17921
2a4acd6548c6
include config.h in more files in libgui
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
25 #endif |
2a4acd6548c6
include config.h in more files in libgui
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
26 |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
27 #include <QFileIconProvider> |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
28 #include <QtAlgorithms> |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
29 |
17921
2a4acd6548c6
include config.h in more files in libgui
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
30 #include "find-files-model.h" |
2a4acd6548c6
include config.h in more files in libgui
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
31 |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
32 class find_file_less_than |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
33 { |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
34 public: |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
35 find_file_less_than (int ord) |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
36 { |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
37 _sortorder = ord; |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
38 } |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
39 QVariant getValue (const QFileInfo &f) const |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
40 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
41 QVariant val; |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
42 int col = (_sortorder > 0) ? _sortorder : -_sortorder; |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
43 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
44 switch (col-1) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
45 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
46 case 0: |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
47 val = QVariant (f.fileName ()); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
48 break; |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
49 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
50 case 1: |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
51 val = QVariant (f.absolutePath ()); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
52 break; |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
53 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
54 default: |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
55 break; |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
56 } |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
57 return val; |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
58 } |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
59 bool lessThan (const QVariant &left, const QVariant &right) const |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
60 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
61 return |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
62 left.toString ().compare (right.toString (), Qt::CaseInsensitive) < 0; |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
63 } |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
64 bool operator () (const QFileInfo &left, const QFileInfo &right) const |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
65 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
66 QVariant leftval = getValue (left); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
67 QVariant rightval = getValue (right); |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
68 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
69 if (_sortorder > 0) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
70 return lessThan (leftval, rightval); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
71 else |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
72 return ! lessThan (leftval, rightval); |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
73 } |
22022
278fc29b69ca
maint: Eliminate unnecessary double newline blocks (only whitespace changes).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
74 |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
75 private: |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
76 int _sortorder; |
22022
278fc29b69ca
maint: Eliminate unnecessary double newline blocks (only whitespace changes).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
77 |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
78 }; |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
79 |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
80 find_files_model::find_files_model (QObject *p) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
81 : QAbstractListModel (p) |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
82 { |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
83 _columnNames.append (tr ("Filename")); |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
84 _columnNames.append (tr ("Directory")); |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
85 _sortorder = 0; |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
86 } |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
87 |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
88 find_files_model::~find_files_model () |
22022
278fc29b69ca
maint: Eliminate unnecessary double newline blocks (only whitespace changes).
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
89 { } |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
90 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
91 void |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
92 find_files_model::clear () |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
93 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
94 beginResetModel (); |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
95 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
96 _files.clear (); |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
97 |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
98 endResetModel (); |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
99 } |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
100 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
101 void |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
102 find_files_model::addFile (const QFileInfo &info) |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
103 { |
18678
6113e0c6920b
maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents:
17921
diff
changeset
|
104 beginInsertRows (QModelIndex (), _files.size (), _files.size ()); |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
105 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
106 QList<QFileInfo>::Iterator it; |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
107 find_file_less_than less_than (_sortorder); |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
108 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
109 for (it=_files.begin (); it!=_files.end (); it++) |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
110 { |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
111 if (less_than (info, *it)) break; |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
112 } |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
113 |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
114 _files.insert (it, info); |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
115 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
116 endInsertRows (); |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
117 } |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
118 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
119 int |
17377
15e2ad6372f7
maint: Tweaks to remove compiler warnings.
Rik <rik@octave.org>
parents:
16997
diff
changeset
|
120 find_files_model::rowCount (const QModelIndex &) const |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
121 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
122 return _files.size (); |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
123 } |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
124 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
125 int |
17377
15e2ad6372f7
maint: Tweaks to remove compiler warnings.
Rik <rik@octave.org>
parents:
16997
diff
changeset
|
126 find_files_model::columnCount (const QModelIndex &) const |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
127 { |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
128 return _columnNames.size (); |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
129 } |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
130 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
131 QVariant |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
132 find_files_model::data (const QModelIndex& idx, int role) const |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
133 { |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
134 QVariant retval; |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
135 |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
136 if (idx.isValid ()) |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
137 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
138 if (role == Qt::DisplayRole) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
139 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
140 switch (idx.column ()) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
141 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
142 case 0: |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
143 retval = QVariant (_files[idx.row ()].fileName ()); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
144 break; |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
145 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
146 case 1: |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
147 retval = QVariant (_files[idx.row ()].absolutePath ()); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
148 break; |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
149 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
150 default: |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
151 break; |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
152 } |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
153 } |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
154 else if (role == Qt:: DecorationRole) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
155 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
156 switch (idx.column ()) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
157 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
158 case 0: |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
159 retval = fileIcon (idx); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
160 default: |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
161 break; |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
162 } |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
163 } |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
164 } |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
165 |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
166 return retval; |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
167 } |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
168 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
169 QVariant |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
170 find_files_model::headerData (int section, Qt::Orientation orientation, |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
171 int role) const |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
172 { |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
173 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
174 return _columnNames[section]; |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
175 else |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
176 return QVariant (); |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
177 } |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
178 |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
179 void |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
180 find_files_model::sort (int column, Qt::SortOrder order) |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
181 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
182 if (column >= 0) |
16997
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
183 { |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
184 if (order == Qt::DescendingOrder) |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
185 _sortorder = -(column+1); |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
186 else |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
187 _sortorder = column+1; |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
188 } |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
189 else |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
190 _sortorder = 0; |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
191 |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
192 if (_sortorder != 0) |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
193 { |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
194 beginResetModel (); |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
195 qSort (_files.begin (), _files.end (), find_file_less_than (_sortorder)); |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
196 endResetModel (); |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
197 } |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
198 } |
90d50e56a06a
Add sortable table headers to find_files_dialog results
John Donoghue <john.donoghue@ieee.org>
parents:
16519
diff
changeset
|
199 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
200 QFileInfo |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
201 find_files_model::fileInfo (const QModelIndex & p) const |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
202 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
203 if (p.isValid ()) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
204 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
205 return _files[p.row ()]; |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
206 } |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
207 return QFileInfo (); |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
208 } |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
209 |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
210 QIcon |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
211 find_files_model::fileIcon (const QModelIndex &p) const |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
212 { |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
213 QFileIconProvider icon_provider; |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
214 if (p.isValid ()) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
215 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
216 return icon_provider.icon (_files[p.row ()]); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
217 } |
16519
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
218 return QIcon (); |
3e8fd0c479b4
Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
219 } |