1
/**************************************************************************
2
* Copyright (C) 2005-2015 by Oleksandr Shneyder *
3
* o.shneyder@phoca-gmbh.de *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
16
***************************************************************************/
17
#include "appdialog.h"
18
#include "onmainwindow.h"
20
AppDialog::AppDialog(ONMainWindow* parent):QDialog(parent)
36
startButton->setEnabled(false);
41
AppDialog::~AppDialog()
46
void AppDialog::slotSearchChanged(QString text)
48
QTreeWidgetItemIterator it(treeWidget);
51
QString exec=(*it)->data(0,Qt::UserRole).toString();
52
QString comment=(*it)->data(0,Qt::UserRole+1).toString();
53
QString name=(*it)->text(0);
54
if ((*it)->childCount()==0)
58
(*it)->setHidden(false);
59
(*it)->setSelected(false);
63
if (exec.indexOf(text, 0,Qt::CaseInsensitive)!= -1 ||
64
comment.indexOf(text, 0,Qt::CaseInsensitive)!= -1 ||
65
name.indexOf(text, 0,Qt::CaseInsensitive)!= -1 )
67
treeWidget->clearSelection();
68
(*it)->setSelected(true);
69
(*it)->setHidden(false);
70
treeWidget->scrollToItem((*it));
74
(*it)->setHidden(true);
75
(*it)->setSelected(false);
83
QTreeWidgetItem* AppDialog::initTopItem(QString text, QPixmap icon)
85
QTreeWidgetItem* item;
86
item=new QTreeWidgetItem(treeWidget);
87
item->setText(0,text);
88
item->setFlags(Qt::ItemIsEnabled);
89
item->setIcon(0,icon);
93
void AppDialog::loadApps()
95
QTreeWidgetItem* parent;
96
foreach (Application app, mw->getApplications())
100
case Application::MULTIMEDIA:
102
media=initTopItem(tr("Multimedia"), QPixmap(":/icons/22x22/applications-multimedia.png"));
105
case Application::DEVELOPMENT:
107
dev=initTopItem(tr("Development"), QPixmap(":/icons/22x22/applications-development.png"));
110
case Application::EDUCATION:
112
edu=initTopItem(tr("Education"), QPixmap(":/icons/22x22/applications-education.png"));
115
case Application::GAME:
117
game=initTopItem(tr("Game"), QPixmap(":/icons/22x22/applications-games.png"));
120
case Application::GRAPHICS:
122
graph=initTopItem(tr("Graphics"), QPixmap(":/icons/22x22/applications-graphics.png"));
125
case Application::NETWORK:
127
net=initTopItem(tr("Network"), QPixmap(":/icons/22x22/applications-internet.png"));
130
case Application::OFFICE:
132
office=initTopItem(tr("Office"), QPixmap(":/icons/22x22/applications-office.png"));
135
case Application::SETTINGS:
137
set=initTopItem(tr("Settings"), QPixmap(":/icons/22x22/preferences-system.png"));
140
case Application::SYSTEM:
142
sys=initTopItem(tr("System"), QPixmap(":/icons/22x22/applications-system.png"));
145
case Application::UTILITY:
147
util=initTopItem(tr("Utility"), QPixmap(":/icons/22x22/applications-utilities.png"));
150
case Application::OTHER:
152
other=initTopItem(tr("Other"), QPixmap(":/icons/22x22/applications-other.png"));
158
if (app.category==Application::TOP)
159
it=new QTreeWidgetItem(treeWidget);
161
it=new QTreeWidgetItem(parent);
162
it->setText(0, app.name);
163
it->setToolTip(0,app.comment);
164
it->setIcon(0,app.icon);
165
it->setData(0, Qt::UserRole, app.exec);
166
it->setData(0, Qt::UserRole+1, app.comment);
168
treeWidget->sortItems(0,Qt::AscendingOrder);
171
void AppDialog::slotSelectedChanged()
173
startButton->setEnabled(false);
174
if (treeWidget->selectedItems().count())
176
startButton->setEnabled(true);
180
void AppDialog::slotDoubleClicked(QTreeWidgetItem* item)
182
QString exec=item->data(0,Qt::UserRole).toString();
184
mw->runApplication(exec);
187
void AppDialog::slotStartSelected()
189
if (treeWidget->selectedItems().count()>0)
191
QString exec=treeWidget->selectedItems()[0]->data(0,Qt::UserRole).toString();
193
mw->runApplication(exec);