changeset 282:d13d51f7a0e2

Merged
author Sascha Wilde <wilde@intevation.de>
date Wed, 02 Apr 2014 15:22:33 +0200
parents 0f73fe4230c1 (current diff) e265431f3e92 (diff)
children fb9e14f4b4c9
files
diffstat 6 files changed, 103 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ui/CMakeLists.txt	Wed Apr 02 15:22:13 2014 +0200
+++ b/ui/CMakeLists.txt	Wed Apr 02 15:22:33 2014 +0200
@@ -21,6 +21,7 @@
     ${CMAKE_CURRENT_SOURCE_DIR}/aboutdialog.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/statusdialog.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/certificateitemdelegate.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/separatoritemdelegate.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/installwrapper.cpp
     ${CERTIFICATELIST_SOURCES}
     ${DOWNLOADER_SOURCES}
--- a/ui/certificateitemdelegate.h	Wed Apr 02 15:22:13 2014 +0200
+++ b/ui/certificateitemdelegate.h	Wed Apr 02 15:22:33 2014 +0200
@@ -1,4 +1,3 @@
-
 #ifndef CERTIFICATELISTITEM_H
 #define CERTIFICATELISTITEM_H
 /**
--- a/ui/mainwindow.cpp	Wed Apr 02 15:22:13 2014 +0200
+++ b/ui/mainwindow.cpp	Wed Apr 02 15:22:33 2014 +0200
@@ -12,7 +12,6 @@
 #include <QHBoxLayout>
 #include <QVBoxLayout>
 #include <QGroupBox>
-#include <QPushButton>
 #include <QSplitter>
 #include <QLabel>
 #include <QImage>
@@ -33,6 +32,7 @@
 #include "aboutdialog.h"
 #include "statusdialog.h"
 #include "certificateitemdelegate.h"
+#include "separatoritemdelegate.h"
 
 MainWindow::MainWindow() {
     createActions();
@@ -239,10 +239,11 @@
     QHBoxLayout *mainLayout = new QHBoxLayout;
     QVBoxLayout *infoLayout = new QVBoxLayout;
     QVBoxLayout *certLayout = new QVBoxLayout;
+    QVBoxLayout *detailLayout = new QVBoxLayout;
     QHBoxLayout *headerLayout = new QHBoxLayout;
     QVBoxLayout *headerTextLayout = new QVBoxLayout;
     QVBoxLayout *toolLayout = new QVBoxLayout;
-    QHBoxLayout *toolButtonLayout = new QHBoxLayout;
+    QHBoxLayout *bottomLayout = new QHBoxLayout;
 
     // The certificate list
     QGroupBox *certBox = new QGroupBox(tr("Managed Certificates"));
@@ -267,28 +268,37 @@
     headerLayout->setStretch(0, 0);
     headerLayout->setStretch(1, 10);
 
-    // The tools to update the certificate list/software and install
-    // certificates.
+    // The settings.
     QCheckBox *autoUpdateOption = new QCheckBox(tr("autoupdate"));
     toolLayout->addWidget(autoUpdateOption);
 //    connect(autoUpdateOption, SIGNAL(stateChanged()), this, SLOT(setAutoUpdate()));
-    QPushButton *update = new QPushButton(tr("Search for Updates"));
-    connect(update, SIGNAL(clicked()), this, SLOT(checkUpdates()));
-    QPushButton *install = new QPushButton(tr("Install selected"));
-//    connect(update, SIGNAL(clicked()), this, SLOT(installCertificates()));
-    toolButtonLayout->addWidget(update);
-    toolButtonLayout->addWidget(install);
-    toolButtonLayout->insertStretch(2, 10);
-    toolLayout->addLayout(toolButtonLayout);
+
+    // The buttons.
+    bottomLayout->setAlignment(Qt::AlignBottom);
+    installButton = new QPushButton(tr("Install selected"));
+    installButton->setFixedHeight(80);
+    connect(installButton, SIGNAL(clicked()), this, SLOT(resizeButtons()));
+    quitButton = new QPushButton(tr("Quit"));
+    quitButton->setFixedHeight(20);
+    connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
+    bottomLayout->insertStretch(0, 10);
+    bottomLayout->addWidget(installButton);
+    bottomLayout->setAlignment(installButton, Qt::AlignBottom);
+    bottomLayout->addWidget(quitButton);
+    bottomLayout->setAlignment(quitButton, Qt::AlignBottom);
 
     // The certificate details
+    QGroupBox *detailBox = new QGroupBox(tr("Details"));
     certificateDetails = new QTextEdit;
     certificateDetails->setReadOnly(true);
+    detailLayout->addWidget(certificateDetails);
+    detailBox->setLayout(detailLayout);
 
     infoLayout->addSpacing(20);
     infoLayout->addLayout(headerLayout);
     infoLayout->addLayout(toolLayout);
-    infoLayout->addWidget(certificateDetails);
+    infoLayout->addWidget(detailBox);
+    infoLayout->addLayout(bottomLayout);
 
     mainLayout->addWidget(certBox);
     mainLayout->addLayout(infoLayout);
@@ -311,6 +321,7 @@
             continue;
         }
         QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
+        SeparatorItemDelegate *separator = new SeparatorItemDelegate();
         item->setData(Qt::UserRole, cert.details());
         if (cert.isInstallCert()) {
             // This if statements is for testing! @TODO Remove this!
@@ -324,6 +335,12 @@
                 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
                 item->setCheckState(Qt::Checked);
             }
+            if (i == 3) {
+                QListWidgetItem *sep = new QListWidgetItem("New certificates");
+                certificateList->setItemDelegateForRow(i, separator);
+                certificateList->addItem(sep);
+                i++;
+            }
         }
         else {
             // This if statements is for testing! @TODO Remove this!
@@ -375,3 +392,9 @@
     details.append("\rInstalled: 1.1.1971\rRemoved: 1.1.1971");
     certificateDetails->setPlainText(details);
 }
+
+void MainWindow::resizeButtons()
+{
+    installButton->setFixedHeight(20);
+    quitButton->setFixedHeight(80);
+}
--- a/ui/mainwindow.h	Wed Apr 02 15:22:13 2014 +0200
+++ b/ui/mainwindow.h	Wed Apr 02 15:22:33 2014 +0200
@@ -12,6 +12,7 @@
 #include <QMenuBar>
 #include <QListWidget>
 #include <QTextEdit>
+#include <QPushButton>
 
 #include "downloader.h"
 #include "certificatelist.h"
@@ -53,6 +54,7 @@
     void showHelp();
     void showAbout();
     void showDetails(QListWidgetItem*);
+    void resizeButtons();
 
 private:
     /** @brief check the integrity of available files.
@@ -88,6 +90,8 @@
 
     QListWidget *certificateList;
     QTextEdit *certificateDetails;
+    QPushButton *installButton;
+    QPushButton *quitButton;
 };
 
 #endif // MAINWINDOW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/separatoritemdelegate.cpp	Wed Apr 02 15:22:33 2014 +0200
@@ -0,0 +1,34 @@
+#include <QtWidgets>
+
+#include "separatoritemdelegate.h"
+
+void SeparatorItemDelegate::paint(QPainter *painter,
+    const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+    // Save the current painter.
+    painter->save();
+
+    // Get the position for separator line.
+    int topLeftY = option.rect.topLeft().y();
+    int height = option.rect.height();
+    int middle = topLeftY + (height / 2);
+
+    // Draw the first part.
+    QPen linePen(Qt::black, 2, Qt::SolidLine);
+    painter->setPen(linePen);
+    painter->drawLine(10, middle, 80, middle);
+
+    // Draw the text.
+    QString text = index.data().toString();
+    QRect rect = option.rect.adjusted(85, -2, 0, -2);
+    painter->drawText(rect.left(), rect.top(), rect.width(), rect.height(),
+        Qt::AlignVCenter|Qt::AlignLeft, text, &rect);
+
+    // Draw the second part.
+    painter->drawLine(rect.topRight().x() + 5, middle, rect.topRight().x() + 75, middle);
+
+    // Restore the painter to have an unmodified painter for the next draw
+    // action.
+    painter->restore();
+    return;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/separatoritemdelegate.h	Wed Apr 02 15:22:33 2014 +0200
@@ -0,0 +1,28 @@
+#ifndef SEPARATORITEMDELEGATE_H
+#define SEPARATORITEMDELEGATE_H
+/**
+ * @file separatoritemdelegate.h
+ * @brief Item delegate drawing a separator in list widgets.
+ *
+ */
+
+#include <QStyledItemDelegate>
+
+class SeparatorItemDelegate : public QStyledItemDelegate
+{
+Q_OBJECT
+
+public:
+    SeparatorItemDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent){}
+
+    /**
+     * @brief Renders the delegate using the given painter and options.
+     *
+     * @param painter   The painter to draw the item.
+     * @param option    The style options.
+     * @param index     The model index of the item to draw.
+     */
+    void paint(QPainter *painter, const QStyleOptionViewItem &option,
+        const QModelIndex &index) const;
+};
+#endif

http://wald.intevation.org/projects/trustbridge/