1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of Qt Creator.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
41 #include "maemoremoteprocessesdialog.h"
42 #include "ui_maemoremoteprocessesdialog.h"
44 #include "maemodeviceconfigurations.h"
45 #include "maemoremoteprocesslist.h"
47 #include <QtGui/QMessageBox>
48 #include <QtGui/QSortFilterProxyModel>
50 namespace Qt4ProjectManager {
53 MaemoRemoteProcessesDialog::MaemoRemoteProcessesDialog(const MaemoDeviceConfig::ConstPtr &devConfig,
56 m_ui(new Ui::MaemoRemoteProcessesDialog),
57 m_processList(new MaemoRemoteProcessList(devConfig, this)),
58 m_proxyModel(new QSortFilterProxyModel(this))
61 m_ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
62 m_proxyModel->setSourceModel(m_processList);
63 m_proxyModel->setDynamicSortFilter(true);
64 m_proxyModel->setFilterKeyColumn(1);
65 m_ui->tableView->setModel(m_proxyModel);
66 connect(m_ui->processFilterLineEdit, SIGNAL(textChanged(QString)),
67 m_proxyModel, SLOT(setFilterRegExp(QString)));
69 // Manually gathered process information is missing the command line for
70 // some system processes. Dont's show these lines by default.
71 if (devConfig->osVersion() == MaemoGlobal::Maemo5)
72 m_ui->processFilterLineEdit->setText(QLatin1String("[^ ]+"));
74 connect(m_ui->tableView->selectionModel(),
75 SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
76 SLOT(handleSelectionChanged()));
77 connect(m_ui->updateListButton, SIGNAL(clicked()),
78 SLOT(updateProcessList()));
79 connect(m_ui->killProcessButton, SIGNAL(clicked()), SLOT(killProcess()));
80 connect(m_processList, SIGNAL(error(QString)),
81 SLOT(handleRemoteError(QString)));
82 connect(m_processList, SIGNAL(modelReset()),
83 SLOT(handleProcessListUpdated()));
84 connect(m_processList, SIGNAL(processKilled()),
85 SLOT(handleProcessKilled()), Qt::QueuedConnection);
86 connect(m_proxyModel, SIGNAL(layoutChanged()),
87 SLOT(handleProcessListUpdated()));
88 handleSelectionChanged();
92 MaemoRemoteProcessesDialog::~MaemoRemoteProcessesDialog()
97 void MaemoRemoteProcessesDialog::handleRemoteError(const QString &errorMsg)
99 QMessageBox::critical(this, tr("Remote Error"), errorMsg);
100 m_ui->updateListButton->setEnabled(true);
101 handleSelectionChanged();
104 void MaemoRemoteProcessesDialog::handleProcessListUpdated()
106 m_ui->updateListButton->setEnabled(true);
107 m_ui->tableView->resizeRowsToContents();
108 handleSelectionChanged();
111 void MaemoRemoteProcessesDialog::updateProcessList()
113 m_ui->updateListButton->setEnabled(false);
114 m_ui->killProcessButton->setEnabled(false);
115 m_processList->update();
118 void MaemoRemoteProcessesDialog::killProcess()
120 const QModelIndexList &indexes
121 = m_ui->tableView->selectionModel()->selectedIndexes();
124 m_ui->updateListButton->setEnabled(false);
125 m_ui->killProcessButton->setEnabled(false);
126 m_processList->killProcess(m_proxyModel->mapToSource(indexes.first()).row());
129 void MaemoRemoteProcessesDialog::handleProcessKilled()
134 void MaemoRemoteProcessesDialog::handleSelectionChanged()
136 m_ui->killProcessButton->setEnabled(m_ui->tableView->selectionModel()->hasSelection());
139 } // namespace Internal
140 } // namespace Qt4ProjectManager