Permalink
Browse files

:J, Permission forms

  • Loading branch information...
nycholas committed Oct 16, 2010
1 parent 35e7e10 commit d94e65e0136adff93dc71db5606c87a01c145c2f
View
@@ -27,6 +27,8 @@ syntax: glob
ui_*.h
*.cproject
*.project
+*.settings
+Debug
bin/c-project
moc_*
*.rcc
@@ -35,6 +35,7 @@ ContentTypesModel::ContentTypesModel(int id, QObject *parent, QSqlDatabase db) :
_f = "";
_begin = 0;
_limit = 25;
+ setTable("app_content_type");
}
void ContentTypesModel::paginator(void) {
@@ -81,7 +82,7 @@ void ContentTypesModel::setLimit(int limit) {
_limit = limit;
}
-void ContentTypesModel::selectAll(QList<ContentTypesModel> *list) {
+/*void ContentTypesModel::selectAll(QList<ContentTypesModel> *list) {
QSqlQuery query;
query.prepare("SELECT * FROM app_content_type");
if (!query.exec())
@@ -91,14 +92,14 @@ void ContentTypesModel::selectAll(QList<ContentTypesModel> *list) {
int appLabelCol = query.record().indexOf("app_label");
int modelCol = query.record().indexOf("model");
while (query.next()) {
- //ContentTypesModel m = new ContentTypesModel();
- /*m.setId(query.value(idCol).toInt());
+ ContentTypesModel m = new ContentTypesModel();
+ m.setId(query.value(idCol).toInt());
m.setName(query.value(nameCol).toString());
m.setAppLabel(query.value(appLabelCol).toString());
m.setModel(query.value(modelCol).toString());
- list->append(m);*/
+ list->append(m);
}
-}
+}*/
void ContentTypesModel::selectById(int id, ContentTypesModel *m) {
QSqlQuery query;
@@ -66,7 +66,7 @@ Q_OBJECT
int limit(void);
void setLimit(int limit);
- static void selectAll(QList<ContentTypesModel> *list);
+ //static void selectAll(QList<ContentTypesModel> *list);
static void selectById(int id, ContentTypesModel *contenttypesModel);
bool save(void);
bool insert(void);
@@ -31,6 +31,7 @@
PermissionForm::PermissionForm(PermissionModel *model, QDialog *parent) :
QDialog(parent) {
+ qDebug() << "In PermissionForm::PermissionForm()";
setupUi(this);
permissionModel = model;
contentTypesModel = new ContentTypesModel();
@@ -40,15 +41,17 @@ PermissionForm::PermissionForm(PermissionModel *model, QDialog *parent) :
}
PermissionForm::~PermissionForm(void) {
+ qDebug() << "In PermissionForm::~PermissionForm()";
}
void PermissionForm::timerStatusAction(void) {
+ qDebug() << "In PermissionForm::timerStatusAction()";
statusLabel->hide();
statusLabel->setText("");
}
void PermissionForm::nextAction(void) {
- qDebug() << "next";
+ qDebug() << "In PermissionForm::nextAction()";
QSqlQuery query = permissionModel->query();
if (!query.next())
return;
@@ -68,7 +71,7 @@ void PermissionForm::nextAction(void) {
}
void PermissionForm::previousAction(void) {
- qDebug() << "pre";
+ qDebug() << "In PermissionForm::previousAction()";
QSqlQuery query = permissionModel->query();
if (!query.previous())
return;
@@ -88,6 +91,7 @@ void PermissionForm::previousAction(void) {
}
void PermissionForm::saveAction(void) {
+ qDebug() << "In PermissionForm::saveAction()";
if (!save()) {
errorStatus(qApp->tr("Failure trying to register the record."));
} else {
@@ -109,6 +113,7 @@ void PermissionForm::saveAction(void) {
}
void PermissionForm::saveAndContinueSavingAction(void) {
+ qDebug() << "In PermissionForm::saveAndContinueSavingAction()";
if (!save()) {
errorStatus(qApp->tr("Failure trying to register the record."));
} else {
@@ -129,6 +134,7 @@ void PermissionForm::saveAndContinueSavingAction(void) {
}
void PermissionForm::removeAction(void) {
+ qDebug() << "In PermissionForm::removeAction()";
QMessageBox msgBox;
msgBox.setText(qApp->tr("Are you sure?"));
msgBox.setInformativeText(
@@ -168,10 +174,12 @@ void PermissionForm::removeAction(void) {
}
void PermissionForm::cancelAction(void) {
+ qDebug() << "In PermissionForm::cancelAction()";
close();
}
void PermissionForm::createActions(void) {
+ qDebug() << "In PermissionForm::createActions()";
connect(statusTimer, SIGNAL(timeout()), this, SLOT(timerStatusAction()));
connect(nextPushButton, SIGNAL(released()), this, SLOT(nextAction()));
@@ -186,11 +194,13 @@ void PermissionForm::createActions(void) {
}
void PermissionForm::updateWidgets(void) {
+ qDebug() << "In PermissionForm::updateWidgets()";
updateForms();
statusLabel->hide();
}
void PermissionForm::updateModels(void) {
+ qDebug() << "In PermissionForm::updateModels()";
permissionModel = new PermissionModel(0, this);
int begin = permissionModel->begin();
@@ -202,9 +212,11 @@ void PermissionForm::updateModels(void) {
}
void PermissionForm::updateForms(void) {
+ qDebug() << "In PermissionForm::updateForms()";
clear();
focusDefault();
updateContentTypesComboBox();
+ updateCodenameComboBox();
if (permissionModel->getId() > 0) {
select();
titleLabel->setText(qApp->tr("Change Permission"));
@@ -227,42 +239,61 @@ void PermissionForm::updateForms(void) {
}
void PermissionForm::updateContentTypesComboBox(void) {
+ qDebug() << "In PermissionForm::updateContentTypesComboBox()";
contentTypesModel->select();
contentTypesComboBox->clear();
- contentTypesComboBox->addItem("Select");
contentTypesComboBox->setModel(contentTypesModel);
+ contentTypesComboBox->setModelColumn(1);
+}
+
+void PermissionForm::updateCodenameComboBox(void) {
+ qDebug() << "In PermissionForm::updateCodenameComboBox()";
+ codenameComboBox->clear();
+ codenameComboBox->addItem(qApp->tr("Add"), "add");
+ codenameComboBox->addItem(qApp->tr("Change"), "change");
+ codenameComboBox->addItem(qApp->tr("Delete"), "delete");
}
void PermissionForm::select(void) {
+ qDebug() << "In PermissionForm::select()";
PermissionModel::selectById(permissionModel->getId(), permissionModel);
nameLineEdit->setText(permissionModel->getName());
- codenameLineEdit->setText(permissionModel->getCodename());
+ //codenameComboBox->setim(permissionModel->getCodename());
}
bool PermissionForm::save(void) {
+ qDebug() << "In PermissionForm::save()";
+ //ContentTypesModel::selectById(contentTypesComboBox->rootModelIndex(),
+ // contentTypesModel);
+ permissionModel->setContentTypes(contentTypesModel);
permissionModel->setName(nameLineEdit->text());
- permissionModel->setCodename(codenameLineEdit->text());
+ permissionModel->setCodename(codenameComboBox->currentText());
return permissionModel->save();
}
bool PermissionForm::remove(void) {
+ qDebug() << "In PermissionForm::remove()";
return permissionModel->remove();
}
void PermissionForm::clear(void) {
+ qDebug() << "In PermissionForm::clear()";
nameLineEdit->clear();
- codenameLineEdit->clear();
+ codenameComboBox->clear();
}
void PermissionForm::focusDefault(void) {
+ qDebug() << "In PermissionForm::focusDefault()";
nameLineEdit->setFocus();
}
void PermissionForm::timerStatus(void) {
+ qDebug() << "In PermissionForm::timerStatus()";
statusTimer->start(3000);
}
void PermissionForm::okStatus(const QString &msg) {
+ qDebug() << "In PermissionForm::okStatus()";
statusLabel->setText(msg);
statusLabel->setStyleSheet("color: green; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid green;");
@@ -271,6 +302,7 @@ void PermissionForm::okStatus(const QString &msg) {
}
void PermissionForm::infoStatus(const QString &msg) {
+ qDebug() << "In PermissionForm::infoStatus()";
statusLabel->setText(msg);
statusLabel->setStyleSheet("color: blue; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid blue;");
@@ -279,6 +311,7 @@ void PermissionForm::infoStatus(const QString &msg) {
}
void PermissionForm::alertStatus(const QString &msg) {
+ qDebug() << "In PermissionForm::alertStatus()";
statusLabel->setText(msg);
statusLabel->setStyleSheet("color: yellow; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid yellow;");
@@ -287,6 +320,7 @@ void PermissionForm::alertStatus(const QString &msg) {
}
void PermissionForm::errorStatus(const QString &msg) {
+ qDebug() << "In PermissionForm::errorStatus()";
statusLabel->setText(msg);
statusLabel->setStyleSheet("color: red; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid red;");
@@ -62,6 +62,7 @@ private slots:
void updateModels(void);
void updateForms(void);
void updateContentTypesComboBox(void);
+ void updateCodenameComboBox(void);
void select(void);
bool save(void);
Oops, something went wrong.

0 comments on commit d94e65e

Please sign in to comment.