summaryrefslogtreecommitdiffstats
path: root/src/gui/profileDialog.cpp
diff options
context:
space:
mode:
authorSebastian2010-05-12 19:42:27 +0200
committerSebastian2010-05-12 19:42:27 +0200
commitce3329047d378a14006ce74ec273ac59e3375303 (patch)
tree782430f270b4c7aca1b35d5b7813518e3797c555 /src/gui/profileDialog.cpp
downloadpvs-ce3329047d378a14006ce74ec273ac59e3375303.tar.gz
pvs-ce3329047d378a14006ce74ec273ac59e3375303.tar.xz
pvs-ce3329047d378a14006ce74ec273ac59e3375303.zip
initial import of latest svn version
Diffstat (limited to 'src/gui/profileDialog.cpp')
-rw-r--r--src/gui/profileDialog.cpp179
1 files changed, 179 insertions, 0 deletions
diff --git a/src/gui/profileDialog.cpp b/src/gui/profileDialog.cpp
new file mode 100644
index 0000000..2cbc155
--- /dev/null
+++ b/src/gui/profileDialog.cpp
@@ -0,0 +1,179 @@
+/*
+ # Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg
+ #
+ # This program is free software distributed under the GPL version 2.
+ # See http://openslx.org/COPYING
+ #
+ # If you have any feedback please consult http://openslx.org/feedback and
+ # send your suggestions, praise, or complaints to feedback@openslx.org
+ #
+ # General information about OpenSLX can be found at http://openslx.org/
+ # -----------------------------------------------------------------------------
+ # profileDialog.cpp
+ # - GUI to define the profile.
+ # -----------------------------------------------------------------------------
+ */
+
+#include "profileDialog.h"
+#include "ui_profileDialog.h"
+#include <src/gui/mainWindow.h>
+#include <iostream>
+
+profileDialog::profileDialog(QWidget * parent):
+ QDialog(parent),
+ uidiag(new Ui::Dialog)
+{
+ uidiag->setupUi(this);
+ content = new QTableView(uidiag->widget);
+ uidiag->gridLayout->addWidget(content);
+
+ /*Das Modelfestlegen, wo die Clientname angezeigt werden.*/
+ model = new QStandardItemModel(0,1,content); //Leere Tabelle mit einer Spalte erstellen
+ model->setHeaderData(0, Qt::Horizontal, tr("Profile")); //Spalte name definieren
+ content->setModel(model);
+
+ QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
+ content->setSelectionModel(selectionModel);
+ QHeaderView *headerView = content->horizontalHeader();
+ headerView->setStretchLastSection(true);
+
+ content->setEditTriggers(QAbstractItemView::NoEditTriggers); //Die Einträge in der Tabelle werden nicht editierbar.
+ content->setSelectionMode(QAbstractItemView::ExtendedSelection); //Damit mehere Einträge selektierbar werden.
+
+ content->resizeColumnToContents(0);
+
+
+
+ uidiag->add->setDisabled(true);
+ uidiag->edit->setDisabled(true);
+ uidiag->edit->setVisible(false);
+ uidiag->remove->setDisabled(true);
+ uidiag->load->setDisabled(true);
+ uidiag->lineEdit->setDisabled(true);
+
+ setUpProfile();
+
+ connect(uidiag->add, SIGNAL(clicked ()), this, SLOT(AddProfile()));
+ connect(uidiag->new_2, SIGNAL(clicked ()), this, SLOT(onNew()));
+ connect(uidiag->load, SIGNAL(clicked ()), this, SLOT(onLoad()));
+ connect(uidiag->remove, SIGNAL(clicked ()), this, SLOT(removeProfile()));
+ connect(uidiag->close, SIGNAL(clicked ()), this, SLOT(accept()));
+ connect(content, SIGNAL(clicked(const QModelIndex)), this, SLOT(selectionChange(const QModelIndex)));
+ //show();
+
+}
+
+profileDialog::~profileDialog()
+{
+ // TODO Auto-generated destructor stub
+}
+
+void profileDialog::setUpProfile()
+{
+ QStringList list = MainWindow::getWindow()->getProfilList();
+ for (int i=0; i<list.size(); i++)
+ {
+ model->insertRow(0, QModelIndex());
+ model->setData(model->index(0, 0, QModelIndex()),list.at(i));
+ }
+}
+
+void profileDialog::AddProfile()
+{
+ QString name = QString(uidiag->lineEdit->text());
+ if (!ProfilList.contains(name))
+ {
+ if (!name.isEmpty())
+ {
+ model->insertRow(0, QModelIndex());
+ model->setData(model->index(0, 0, QModelIndex()),name);
+ ProfilList.append(name);
+ MainWindow::getWindow()->saveSettings(name);
+ uidiag->lineEdit->setText("");
+ }
+ else
+ {
+ QString message = QString(tr("This field can't be empty."));
+ QMessageBox::information(this, "PVS", message);
+ }
+ }
+ else
+ {
+ QString message = QString(tr("This name is already in the list."));
+ QMessageBox::information(this, "PVS", message);
+ }
+}
+
+void profileDialog::removeProfile()
+{
+ QTableView *temp = static_cast<QTableView*>(content);
+ QItemSelectionModel *selectionModel = temp->selectionModel();
+
+ QModelIndexList indexes = selectionModel->selectedRows();
+ QModelIndex index;
+
+ foreach(index, indexes)
+ {
+ int row = content->currentIndex().row();
+ QString current = model->index(content->currentIndex().row(), 0).data(Qt::DisplayRole).toString();
+ model->removeRow(row, QModelIndex());
+ ProfilList.removeOne(current);
+ MainWindow::getWindow()->removeProfil(current);
+ }
+
+
+ /* if (temp->model()->rowCount()<=0)
+ {*/
+ uidiag->remove->setDisabled(true);
+ uidiag->edit->setDisabled(true);
+ uidiag->add->setDisabled(true);
+ uidiag->load->setDisabled(true);
+ //}
+}
+
+void profileDialog::onNew()
+{
+ uidiag->add->setDisabled(false);
+ uidiag->lineEdit->setDisabled(false);
+ uidiag->lineEdit->setFocus();
+}
+
+void profileDialog::onLoad()
+{
+ QTableView *temp = static_cast<QTableView*>(content);
+ QItemSelectionModel *selectionModel = temp->selectionModel();
+
+ QModelIndexList indexes = selectionModel->selectedRows();
+ QModelIndex index;
+ if (indexes.size()>1)
+ {
+ QMessageBox::information(this, "PVS", tr("You can only load one profile at time"));
+ }
+ else if(indexes.size() == 1)
+ {
+ foreach(index, indexes)
+ {
+ //int row = content->currentIndex().row();
+ QString current = model->index(content->currentIndex().row(), 0).data(Qt::DisplayRole).toString();
+ MainWindow::getWindow()->loadSettings(current);
+ }
+ }
+
+ emit accept();
+}
+
+void profileDialog::selectionChange(const QModelIndex & index)
+{
+ uidiag->remove->setDisabled(false);
+ uidiag->edit->setDisabled(false);
+ uidiag->add->setDisabled(false);
+ uidiag->load->setDisabled(false);
+
+}
+
+void profileDialog::close()
+{
+ close();
+}
+
+