diff options
author | Pino Toscano <pino@kde.org> | 2009-07-04 00:07:12 +0200 |
---|---|---|
committer | Pino Toscano <pino@kde.org> | 2009-07-04 00:07:12 +0200 |
commit | 97094d13bc0f144b25e13c1de7a5328608ab13e3 (patch) | |
tree | a2d2f62851c92237c228d6cb51eb9760d6880a82 /qt4 | |
parent | 0d8f2ee0f03a14e7b8477c4b787c3441a758f26b (diff) |
[Qt4 demo] show a list of checked/unchecked items for the document permissions
Diffstat (limited to 'qt4')
-rw-r--r-- | qt4/demos/permissions.cpp | 25 | ||||
-rw-r--r-- | qt4/demos/permissions.h | 6 |
2 files changed, 11 insertions, 20 deletions
diff --git a/qt4/demos/permissions.cpp b/qt4/demos/permissions.cpp index 0ac3a573..38205b2e 100644 --- a/qt4/demos/permissions.cpp +++ b/qt4/demos/permissions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, Pino Toscano <pino@kde.org> + * Copyright (C) 2008-2009, Pino Toscano <pino@kde.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,21 +20,14 @@ #include <poppler-qt4.h> -#include <QtGui/QTableWidget> - -static QString yesNoStatement(bool value) -{ - return value ? QString::fromLatin1("yes") : QString::fromLatin1("no"); -} +#include <QtGui/QListWidget> PermissionsDock::PermissionsDock(QWidget *parent) : AbstractInfoDock(parent) { - m_table = new QTableWidget(this); + m_table = new QListWidget(this); setWidget(m_table); setWindowTitle(tr("Permissions")); - m_table->setColumnCount(2); - m_table->setHorizontalHeaderLabels(QStringList() << tr("Permission") << tr("Value")); m_table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); } @@ -44,14 +37,13 @@ PermissionsDock::~PermissionsDock() void PermissionsDock::fillInfo() { - m_table->setHorizontalHeaderLabels(QStringList() << tr("Permission") << tr("Value")); - int i = 0; #define ADD_ROW(title, function) \ do { \ - m_table->setRowCount(i + 1); \ - m_table->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1(title))); \ - m_table->setItem(i, 1, new QTableWidgetItem(yesNoStatement(document()->function()))); \ - ++i; \ + QListWidgetItem *item = new QListWidgetItem(); \ + item->setFlags(item->flags() & ~Qt::ItemIsEnabled); \ + item->setText(title); \ + item->setCheckState(document()->function() ? Qt::Checked : Qt::Unchecked); \ + m_table->addItem(item); \ } while (0) ADD_ROW("Print", okToPrint); ADD_ROW("PrintHiRes", okToPrintHighRes); @@ -68,7 +60,6 @@ do { \ void PermissionsDock::documentClosed() { m_table->clear(); - m_table->setRowCount(0); AbstractInfoDock::documentClosed(); } diff --git a/qt4/demos/permissions.h b/qt4/demos/permissions.h index 147f8620..13bcbbf0 100644 --- a/qt4/demos/permissions.h +++ b/qt4/demos/permissions.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, Pino Toscano <pino@kde.org> + * Copyright (C) 2008-2009, Pino Toscano <pino@kde.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ #include "abstractinfodock.h" -class QTableWidget; +class QListWidget; class PermissionsDock : public AbstractInfoDock { @@ -37,7 +37,7 @@ protected: /*virtual*/ void fillInfo(); private: - QTableWidget *m_table; + QListWidget *m_table; }; #endif |