• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

rocs/App

  • sources
  • kde-4.14
  • kdeedu
  • rocs
  • App
  • Ui
IncludeManagerSettings.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Rocs.
3  Copyright 2010 Wagner Reck <wagner.reck@gmail.com>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License as
7  published by the Free Software Foundation; either version 2 of
8  the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include "IncludeManagerSettings.h"
20 #include <QGridLayout>
21 #include <settings.h>
22 #include <QListView>
23 #include <KIconButton>
24 #include <kurlrequester.h>
25 
26 
27 IncludeManagerSettings::IncludeManagerSettings(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f)
28 {
29 
30  _list_View = new QListWidget(this);
31  QGridLayout * lay = new QGridLayout(this);
32  _url = new KUrlRequester(this);
33  _url->setMode(KFile::Directory | KFile::LocalOnly | KFile::ExistingOnly);;
34  KPushButton * add = new KPushButton(KIcon("list-add"), QString(), this);
35  KPushButton * del = new KPushButton(KIcon("list-remove"), QString(), this);
36 
37  lay->addWidget(_url, 0, 0);
38  lay->addWidget(_list_View, 1, 0);
39  lay->addWidget(add, 0, 1);
40  lay->addWidget(del, 1, 1, Qt::AlignTop | Qt::AlignLeft);
41  add->setDefault(true);
42  this->setLayout(lay);
43  readConfig();
44 
45 // editing = 0;
46  connect(add, SIGNAL(clicked(bool)), this, SLOT(insertUrl()));
47  connect(del, SIGNAL(clicked(bool)), this, SLOT(removeURL()));
48 // connect(_list_View, SIGNAL(currentTextChanged(QString)), this, SLOT(includeChanged()));
49 // connect(_list_View, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(editItem(QListWidgetItem*)));
50 
51 }
52 
53 
54 IncludeManagerSettings::~IncludeManagerSettings()
55 {
56 
57 }
58 
59 // void IncludeManagerSettings::editItem(QListWidgetItem* item )
60 // {
61 // _list_View->editItem(item);
62 //
63 // // editing = item;
64 // // _url->setText(item->text());
65 // }
66 
67 
68 void IncludeManagerSettings::readConfig()
69 {
70 
71  QStringList list(Settings::includePath());
72  for (int i = 0 ; i < list.count(); ++i) {
73  QListWidgetItem * item = new QListWidgetItem(list.at(i), _list_View);
74  _list_View->addItem(item);
75  }
76 }
77 void IncludeManagerSettings::saveSettings()
78 {
79  QStringList list;
80  for (int i = 0 ; i < _list_View->count(); ++i) {
81  list.append(_list_View->item(i)->text());
82  }
83 
84  Settings::setIncludePath(list);
85 }
86 
87 void IncludeManagerSettings::insertUrl()
88 {
89  if (_url->text().isEmpty()) {
90 // if (editing != 0){
91 // _list_View->takeItem(_list_View->row(editing));
92 // delete editing;
93 // editing = 0;
94 // }
95  return;
96  }
97 
98  QString text = _url->text().startsWith(QDir::rootPath())
99  ? _url->text()
100  : QDir::homePath() + '/' + _url->text();
101 
102  if (!text.endsWith('/')) {
103  text.append('/');
104  }
105 
106  if (_list_View->findItems(text, Qt::MatchExactly).count() != 0) {
107  return; // Already have this item.
108  }
109 
110  QListWidgetItem * item = new QListWidgetItem(text, _list_View);
111 // item->setFlags(Qt::ItemIsEditable);
112  _list_View->addItem(item);
113  _url->clear();
114  includeChanged();
115 
116 }
117 
118 void IncludeManagerSettings::removeURL()
119 {
120  QListWidgetItem * itm = _list_View->takeItem(_list_View->currentRow());
121  delete itm;
122  includeChanged();
123 
124 }
125 
126 
127 void IncludeManagerSettings::includeChanged()
128 {
129 
130  emit changed(true);
131 }
QWidget
QString::append
QString & append(QChar ch)
QGridLayout::addWidget
void addWidget(QWidget *widget, int row, int column, QFlags< Qt::AlignmentFlag > alignment)
QList::at
const T & at(int i) const
QListWidgetItem
Settings::includePath
static QStringList includePath()
Get Path where include manager seek for includes.
Definition: settings.h:220
QGridLayout
QListWidget
QDir::homePath
QString homePath()
QListWidget::addItem
void addItem(const QString &label)
IncludeManagerSettings::changed
void changed(bool)
QList::count
int count(const T &value) const
QList::append
void append(const T &value)
QWidget::setLayout
void setLayout(QLayout *layout)
QListWidget::takeItem
QListWidgetItem * takeItem(int row)
IncludeManagerSettings::readConfig
void readConfig()
Definition: IncludeManagerSettings.cpp:68
IncludeManagerSettings::~IncludeManagerSettings
virtual ~IncludeManagerSettings()
Definition: IncludeManagerSettings.cpp:54
QString::endsWith
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
QString
QListWidget::item
QListWidgetItem * item(int row) const
QListWidget::count
count
QListWidget::currentRow
currentRow
QStringList
IncludeManagerSettings::IncludeManagerSettings
IncludeManagerSettings(QWidget *parent=0, Qt::WindowFlags f=0)
Definition: IncludeManagerSettings.cpp:27
settings.h
QDir::rootPath
QString rootPath()
Settings::setIncludePath
static void setIncludePath(const QStringList &v)
Set Path where include manager seek for includes.
Definition: settings.h:210
IncludeManagerSettings::saveSettings
void saveSettings()
Definition: IncludeManagerSettings.cpp:77
QListWidget::findItems
QList< QListWidgetItem * > findItems(const QString &text, QFlags< Qt::MatchFlag > flags) const
Qt::WindowFlags
typedef WindowFlags
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QListWidgetItem::text
QString text() const
IncludeManagerSettings.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:16:13 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

rocs/App

Skip menu "rocs/App"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal