"Fossies" - the Fresh Open Source Software Archive

Member "cutter-1.8.2/src/dialogs/AttachProcDialog.h" (20 May 2019, 2674 Bytes) of package /linux/privat/cutter-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AttachProcDialog.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.7.4_vs_1.8.0.

    1 #pragma once
    2 
    3 #include "core/Cutter.h"
    4 #include <QDialog>
    5 #include <memory>
    6 #include <QAbstractListModel>
    7 #include <QSortFilterProxyModel>
    8 #include <QTimer>
    9 
   10 namespace Ui {
   11 class AttachProcDialog;
   12 }
   13 
   14 class MainWindow;
   15 class QTreeWidget;
   16 class QTreeWidgetItem;
   17 
   18 
   19 class ProcessModel: public QAbstractListModel
   20 {
   21     Q_OBJECT
   22 
   23 private:
   24     QList<ProcessDescription> processes;
   25 
   26 public:
   27     enum Column { PidColumn = 0, UidColumn, StatusColumn, PathColumn, ColumnCount };
   28     enum Role { ProcDescriptionRole = Qt::UserRole };
   29 
   30     ProcessModel(QObject *parent = 0);
   31 
   32     int rowCount(const QModelIndex &parent = QModelIndex()) const;
   33     int columnCount(const QModelIndex &parent = QModelIndex()) const;
   34 
   35     QVariant data(const QModelIndex &index, int role) const;
   36     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
   37     static bool lessThan(const ProcessDescription &left, const ProcessDescription &right, int column);
   38 
   39 public slots:
   40     void updateData();
   41 };
   42 
   43 
   44 
   45 class ProcessProxyModel : public QSortFilterProxyModel
   46 {
   47     Q_OBJECT
   48 
   49 public:
   50     ProcessProxyModel(ProcessModel *sourceModel, QObject *parent = nullptr);
   51 
   52 protected:
   53     bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
   54     bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
   55 };
   56 
   57 
   58 class ProcessBeingAnalysedProxyModel : public QSortFilterProxyModel
   59 {
   60     Q_OBJECT
   61 
   62 public:
   63     ProcessBeingAnalysedProxyModel(ProcessModel *sourceModel, QObject *parent = nullptr);
   64 
   65 protected:
   66     bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
   67     bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
   68 
   69 private:
   70     QString processBeingAnalysedFilename;
   71     QString processPathToFilename(const QString &path) const;
   72 };
   73 
   74 
   75 
   76 class AttachProcDialog : public QDialog
   77 {
   78     Q_OBJECT
   79 
   80 public:
   81     explicit AttachProcDialog(QWidget *parent = nullptr);
   82     ~AttachProcDialog();
   83 
   84     int getPID();
   85 
   86 private slots:
   87     void on_buttonBox_accepted();
   88     void on_buttonBox_rejected();
   89     void on_allProcView_doubleClicked(const QModelIndex &index);
   90     void on_procBeingAnalyzedView_doubleClicked(const QModelIndex &index);
   91     void updateModelData();
   92 
   93 private:
   94     std::unique_ptr<Ui::AttachProcDialog> ui;
   95     bool eventFilter(QObject *obj, QEvent *event);
   96 
   97     ProcessModel *processModel;
   98     ProcessProxyModel *processProxyModel;
   99     ProcessBeingAnalysedProxyModel *processBeingAnalyzedProxyModel;
  100 
  101     // whether the 'small table' or 'table with all procs' was last focused
  102     bool wasAllProcViewLastPressed = false;
  103 
  104     QTimer *timer;
  105     const int updateIntervalMs = 1000;
  106 };