diff --git a/src/fileTree.h b/src/fileTree.h index 04f6beb..1277c0c 100644 --- a/src/fileTree.h +++ b/src/fileTree.h @@ -1,141 +1,141 @@ /*********************************************************************** * Copyright 2003-2004 Max Howell * Copyright 2008-2009 Martin Sandsmark * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . ***********************************************************************/ #ifndef FILETREE_H #define FILETREE_H #include //qstrdup #include //decodeName() #include #include #include #include typedef quint64 FileSize; typedef quint64 Dirsize; //**** currently unused class Folder; class File { public: friend class Folder; public: File(const char *name, FileSize size) : m_parent(0), m_name(qstrdup(name)), m_size(size) {} virtual ~File() { delete [] m_name; } Folder *parent() const { return m_parent; } const char *name8Bit() const { return m_name; } FileSize size() const { return m_size; } QString name() const { return QFile::decodeName(m_name); } virtual bool isFolder() const { return false; } QString fullPath(const Folder* = 0) const; QString humanReadableSize() const { return KFormat().formatByteSize(m_size); } protected: File(const char *name, FileSize size, Folder *parent) : m_parent(parent), m_name(qstrdup(name)), m_size(size) {} Folder *m_parent; //0 if this is treeRoot char *m_name; FileSize m_size; //in units of KiB private: File(const File&); void operator=(const File&); }; class Folder : public File { public: Folder(const char *name) : File(name, 0), m_children(0) {} //DON'T pass the full path! uint children() const { return m_children; } - bool isFolder() const Q_DECL_OVERRIDE { + bool isFolder() const override { return true; } ///appends a Folder void append(Folder *d, const char *name=0) { if (name) { delete [] d->m_name; d->m_name = qstrdup(name); } //directories that had a fullpath copy just their names this way m_children += d->children(); //doesn't include the dir itself d->m_parent = this; append((File*)d); //will add 1 to filecount for the dir itself } ///appends a File void append(const char *name, FileSize size) { append(new File(name, size, this)); } /// removes a file void remove(const File *f) { files.removeAll(const_cast(f)); for (Folder *d = this; d; d = d->parent()) { d->m_size -= f->size(); } } QList files; private: void append(File *p) { m_children++; m_size += p->size(); files.append(p); } uint m_children; private: Folder(const Folder&); //undefined void operator=(const Folder&); //undefined }; #endif diff --git a/src/localLister.h b/src/localLister.h index a93f26e..e39c2c0 100644 --- a/src/localLister.h +++ b/src/localLister.h @@ -1,60 +1,60 @@ /*********************************************************************** * Copyright 2003-2004 Max Howell * Copyright 2008-2009 Martin Sandsmark * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . ***********************************************************************/ #ifndef LOCALLISTER_H #define LOCALLISTER_H #include #include class Folder; namespace Filelight { class ScanManager; class LocalLister : public QThread { Q_OBJECT public: LocalLister(const QString &path, QList *cachedTrees, ScanManager *parent); static void readMounts(); signals: void branchCompleted(Folder* tree); private: QString m_path; QList *m_trees; ScanManager *m_parent; private: - void run() Q_DECL_OVERRIDE; + void run() override; Folder *scan(const QByteArray&, const QByteArray&); private: static QStringList s_localMounts, s_remoteMounts; //TODO namespace }; } #endif diff --git a/src/mainWindow.h b/src/mainWindow.h index 50adbcc..4ca5e28 100644 --- a/src/mainWindow.h +++ b/src/mainWindow.h @@ -1,130 +1,130 @@ /*********************************************************************** * Copyright 2003-2004 Max Howell * Copyright 2008-2009 Martin Sandsmark * Copyright 2017 Harald Sitter * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . ***********************************************************************/ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include #include class QLabel; namespace RadialMap { class Widget; } class Folder; class KSqueezedTextLabel; class KHistoryComboBox; class KRecentFilesAction; class ProgressBox; class HistoryCollection; namespace Filelight { class ScanManager; class SummaryWidget; class MainWindow : public KXmlGuiWindow // Maybe use qmainwindow { Q_OBJECT public: MainWindow(); void scan(const QUrl &u); signals: void started(); // FIXME: Could be replaced by direct func call once merged with mainwindow void completed(); void canceled(QString); void setWindowCaption(QString); private slots: void slotUp(); void slotComboScan(); void slotScanFolder(); void slotScanHomeFolder(); void slotScanRootFolder(); bool slotScanUrl(const QUrl&); bool slotScanPath(const QString&); void slotAbortScan(); void configToolbars(); void configKeys(); void scanStarted(); void scanFailed(); void scanCompleted(); void urlAboutToChange(); bool openUrl(const QUrl&); void configFilelight(); void rescan(); void postInit(); void folderScanCompleted(Folder*); void mapChanged(const Folder*); void updateURL(const QUrl &); protected: - virtual void saveProperties(KConfigGroup&) Q_DECL_OVERRIDE; - virtual void readProperties(const KConfigGroup&) Q_DECL_OVERRIDE; - virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; + void saveProperties(KConfigGroup&) override; + void readProperties(const KConfigGroup&) override; + void closeEvent(QCloseEvent *event) override; private: void setupStatusBar(); void setupActions(); bool closeUrl(); QString prettyUrl() const; void showSummary(); bool start(const QUrl&); KSqueezedTextLabel *m_status[2]; KHistoryComboBox *m_combo; HistoryCollection *m_histories; KRecentFilesAction *m_recentScans; QLayout *m_layout; SummaryWidget *m_summary; RadialMap::Widget *m_map; ProgressBox *m_stateWidget; ScanManager *m_manager; QLabel *m_numberOfFiles; bool m_started; // KPart Compat helper public: QUrl url() const; private: void setUrl(const QUrl &url); QUrl m_url; }; } // namespace Filelight #endif diff --git a/src/progressBox.h b/src/progressBox.h index 027cb5d..1492193 100644 --- a/src/progressBox.h +++ b/src/progressBox.h @@ -1,61 +1,61 @@ /*********************************************************************** * Copyright 2003-2004 Max Howell * Copyright 2008-2009 Martin Sandsmark * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . ***********************************************************************/ #ifndef PROGRESSBOX_H #define PROGRESSBOX_H #include #include #include namespace Filelight { class ScanManager; class MainWindow; } class ProgressBox : public QWidget { Q_OBJECT public: ProgressBox(QWidget *parent, Filelight::MainWindow *mainWindow, Filelight::ScanManager *scanManager); void setText(int); public slots: void start(); void report(); void stop(); void halt(); protected: - void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) override; private: QTimer m_timer; Filelight::ScanManager* m_manager; QString m_text; int m_textWidth; int m_textHeight; KColorScheme m_colorScheme; }; #endif diff --git a/src/radialMap/widget.h b/src/radialMap/widget.h index 4ef535b..a93ab49 100644 --- a/src/radialMap/widget.h +++ b/src/radialMap/widget.h @@ -1,124 +1,124 @@ /*********************************************************************** * Copyright 2003-2004 Max Howell * Copyright 2008-2009 Martin Sandsmark * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . ***********************************************************************/ #ifndef WIDGET_H #define WIDGET_H #include #include #include #include #include #include #include #include #include #include #include "map.h" class Folder; class File; namespace KIO { class Job; } namespace RadialMap { class Segment; class Widget : public QWidget { Q_OBJECT public: explicit Widget(QWidget* = 0, bool = false); - virtual ~Widget(); + ~Widget() override; QString path() const; QUrl url(File const * const = 0) const; bool isValid() const { return m_tree != 0; } bool isSummary() const { return m_isSummary; } friend class Label; //FIXME badness public slots: void zoomIn(); void zoomOut(); void create(const Folder*); void invalidate(); void refresh(int); private slots: void resizeTimeout(); void sendFakeMouseEvent(); void deleteJobFinished(KJob*); void createFromCache(const Folder*); signals: void activated(const QUrl&); void invalidated(const QUrl&); void folderCreated(const Folder*); void mouseHover(const QString&); void giveMeTreeFor(const QUrl&); protected: - void changeEvent(QEvent*) Q_DECL_OVERRIDE; - void dragEnterEvent(QDragEnterEvent*) Q_DECL_OVERRIDE; - void dropEvent(QDropEvent*) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE; - void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE; - void enterEvent(QEvent*) Q_DECL_OVERRIDE; - void leaveEvent(QEvent*) Q_DECL_OVERRIDE; + void changeEvent(QEvent*) override; + void dragEnterEvent(QDragEnterEvent*) override; + void dropEvent(QDropEvent*) override; + void mouseMoveEvent(QMouseEvent*) override; + void mousePressEvent(QMouseEvent*) override; + void paintEvent(QPaintEvent*) override; + void resizeEvent(QResizeEvent*) override; + void enterEvent(QEvent*) override; + void leaveEvent(QEvent*) override; protected: const Segment *segmentAt(QPoint&) const; //FIXME const reference for a library others can use const Segment *rootSegment() const { return m_rootSegment; ///never == 0 } const Segment *focusSegment() const { return m_focus; ///0 == nothing in focus } private: void paintExplodedLabels(QPainter&) const; const Folder *m_tree; const Segment *m_focus; QPoint m_offset; QTimer m_timer; Map m_map; Segment *m_rootSegment; const bool m_isSummary; const Segment *m_toBeDeleted; QLabel m_tooltip; }; } #endif diff --git a/src/remoteLister.h b/src/remoteLister.h index 6f6cb71..e154749 100644 --- a/src/remoteLister.h +++ b/src/remoteLister.h @@ -1,53 +1,53 @@ /*********************************************************************** * Copyright 2003-2004 Max Howell * Copyright 2008-2009 Martin Sandsmark * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . ***********************************************************************/ #ifndef REMOTELISTER_H #define REMOTELISTER_H #include #include "fileTree.h" namespace Filelight { class ScanManager; class RemoteLister : public KDirLister { Q_OBJECT public: RemoteLister(const QUrl &url, QWidget *parent, ScanManager* manager); - ~RemoteLister(); + ~RemoteLister() override; signals: void branchCompleted(Folder* tree); private slots: void completed(); void canceled(); private: struct Store *m_root, *m_store; ScanManager* m_manager; }; } #endif diff --git a/src/scan.h b/src/scan.h index 07b38f1..a3481e1 100644 --- a/src/scan.h +++ b/src/scan.h @@ -1,77 +1,77 @@ /*********************************************************************** * Copyright 2003-2004 Max Howell * Copyright 2008-2009 Martin Sandsmark * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . ***********************************************************************/ #ifndef SCAN_H #define SCAN_H #include #include #include #include class QThread; class Folder; namespace Filelight { class LocalLister; class ScanManager : public QObject { Q_OBJECT friend class LocalLister; friend class RemoteLister; public: explicit ScanManager(QObject *parent); - virtual ~ScanManager(); + ~ScanManager() override; bool start(const QUrl& path); bool running() const; uint files() const { return m_files; } public slots: bool abort(); void emptyCache(); void cacheTree(Folder*); void foundCached(Folder*); signals: void completed(Folder*); void aboutToEmptyCache(); void branchCacheHit(Folder* tree); private: bool m_abort; uint m_files; QMutex m_mutex; LocalLister *m_thread; QList m_cache; }; } #endif diff --git a/src/settingsDialog.h b/src/settingsDialog.h index e295ca1..757663e 100644 --- a/src/settingsDialog.h +++ b/src/settingsDialog.h @@ -1,72 +1,72 @@ /*********************************************************************** * Copyright 2003-2004 Max Howell * Copyright 2008-2009 Martin Sandsmark * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . ***********************************************************************/ #ifndef SETTINGSDIALOG_H #define SETTINGSDIALOG_H #include "ui_dialog.h" //generated by uic #include #include #include class QButtonGroup; class SettingsDialog : public QDialog, public Ui::Dialog { Q_OBJECT public: explicit SettingsDialog(QWidget* = 0); protected: - void closeEvent(QCloseEvent *) Q_DECL_OVERRIDE; - void reject() Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent *) override; + void reject() override; public slots: void addFolder(); void removeFolder(); void toggleScanAcrossMounts(bool); void toggleDontScanRemoteMounts(bool); void toggleDontScanRemovableMedia(bool); void reset(); void startTimer(); void toggleUseAntialiasing(bool = true); void toggleVaryLabelFontSizes(bool); void changeContrast(int); void changeScheme(int); void changeMinFontPitch(int); void toggleShowSmallFiles(bool); void slotSliderReleased(); signals: void mapIsInvalid(); void canvasIsDirty(int); private: QTimer m_timer; static const uint TIMEOUT=1000; QButtonGroup *m_schemaGroup; }; #endif diff --git a/src/summaryWidget.cpp b/src/summaryWidget.cpp index 88d1043..5a01373 100644 --- a/src/summaryWidget.cpp +++ b/src/summaryWidget.cpp @@ -1,182 +1,182 @@ /*********************************************************************** * Copyright 2003-2004 Max Howell * Copyright 2008-2009 Martin Sandsmark * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . ***********************************************************************/ #include "summaryWidget.h" #include "Config.h" #include "fileTree.h" #include "radialMap/radialMap.h" #include "radialMap/widget.h" #include #include #include #include #include #include #include #include #include namespace Filelight { struct Disk { QString mount; QString name; qint64 size; qint64 used; qint64 free; //NOTE used+avail != size (clustersize!) }; struct DiskList : QList { DiskList(); }; class MyRadialMap : public RadialMap::Widget { Q_OBJECT public: MyRadialMap(QWidget *parent) : RadialMap::Widget(parent, true) { } virtual void setCursor(const QCursor &c) { if (focusSegment() && focusSegment()->file()->name() == QLatin1String( "Used" )) RadialMap::Widget::setCursor(c); else unsetCursor(); } - void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE + void mousePressEvent(QMouseEvent *e) override { const RadialMap::Segment *segment = focusSegment(); //we will allow right clicks to the center circle if (segment == rootSegment() && e->button() == Qt::RightButton) RadialMap::Widget::mousePressEvent(e); //and clicks to the used segment else if (e->button() == Qt::LeftButton ) { const QRect rect(e->x() - 20, e->y() - 20, 40, 40); // KIconEffect::visualActivate(this, rect); TODO: Re-enable emit activated(url()); } } }; SummaryWidget::SummaryWidget(QWidget *parent) : QWidget(parent) { qApp->setOverrideCursor(Qt::WaitCursor); setLayout(new QGridLayout(this)); createDiskMaps(); qApp->restoreOverrideCursor(); } void SummaryWidget::createDiskMaps() { DiskList disks; const QByteArray free = i18nc("Free space on the disks/partitions", "Free").toUtf8(); const QByteArray used = i18nc("Used space on the disks/partitions", "Used").toUtf8(); QString text; for (DiskList::ConstIterator it = disks.constBegin(), end = disks.constEnd(); it != end; ++it) { Disk const &disk = *it; if (disk.free == 0 && disk.used == 0) continue; QWidget *volume = new QWidget(this); QVBoxLayout *volumeLayout = new QVBoxLayout(volume); RadialMap::Widget *map = new MyRadialMap(this); QWidget *info = new QWidget(this); info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); QHBoxLayout* horizontalLayout = new QHBoxLayout(info); // Create the text under the radialMap. if (disk.name.isEmpty()) { text = i18nc("Percent used disk space on the partition", "%1
%2% Used", disk.mount, disk.used*100/disk.size); } else { text = i18nc("Percent used disk space on the partition", "%1: %2
%3% Used", disk.name, disk.mount, disk.used*100/disk.size); } QLabel *label = new QLabel(text, this); label->setAlignment(Qt::AlignHCenter); horizontalLayout->addWidget(label); horizontalLayout->setAlignment(Qt::AlignCenter); volumeLayout->addWidget(map); volumeLayout->addWidget(info); // row (=n/2) column (0 or 1) qobject_cast(layout())->addWidget(volume, layout()->count()/2, layout()->count() % 2); Folder *tree = new Folder(disk.mount.toUtf8()); tree->append(free, disk.free); tree->append(used, disk.used); map->create(tree); //must be done when visible connect(map, &RadialMap::Widget::activated, this, &SummaryWidget::activated); } } DiskList::DiskList() { QStringList partitions; for (const QStorageInfo &storage : QStorageInfo::mountedVolumes()) { if (!storage.isReady() || storage.fileSystemType() == "tmpfs") { continue; } Disk disk; disk.mount = storage.rootPath(); disk.name = storage.name(); disk.size = storage.bytesTotal(); disk.free = storage.bytesFree(); disk.used = disk.size - disk.free; *this += disk; } } } #include "summaryWidget.moc"