[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/base/print-manager/add-printer
From:       Daniel Nicoletti <dantti85-kde () yahoo ! com ! br>
Date:       2010-05-07 20:54:49
Message-ID: 20100507205449.989D4AC8B0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1124126 by dantti:

Trying to do the assistant correctly


 M  +2 -50     AddPrinter.cpp  
 M  +2 -0      CMakeLists.txt  
 M  +2 -0      DevicesModel.cpp  
 A             GenericPage.cpp   [License: GPL (v2+)]
 A             GenericPage.h   [License: GPL (v2+)]
 M  +9 -5      PageDestinations.cpp  
 M  +10 -1     PageDestinations.h  


--- trunk/playground/base/print-manager/add-printer/AddPrinter.cpp #1124125:1124126
@@ -21,13 +21,8 @@
 #include "AddPrinter.h"
 
 #include "AddPrinterInterface.h"
-#include "PageIntro.h"
-#include "PageDestinations.h"
+#include "AddPrinterAssistant.h"
 
-#include <KAssistantDialog>
-#include <QLabel>
-#include <QVBoxLayout>
-
 #include <KCmdLineArgs>
 #include <KDebug>
 
@@ -39,53 +34,10 @@
 //     connect(m_pqInterface, SIGNAL(quit()), this, SLOT(quit()));
 }
 
-QWidget *createIntroPage()
-{
-    QWidget *page = new QWidget;
-//     page->setTitle("Introduction");
-
-    PageIntro *label = new PageIntro;
-//     label->setWordWrap(true);
-
-    QVBoxLayout *layout = new QVBoxLayout;
-    layout->addWidget(label);
-    page->setLayout(layout);
-
-    return page;
-}
-
-QWidget *createRegistrationPage()
-{
-    QWidget *page = new QWidget;
-//     page->setTitle("Introduction");
-
-    PageDestinations *label = new PageDestinations;
-
-
-    QVBoxLayout *layout = new QVBoxLayout;
-    layout->addWidget(label);
-    page->setLayout(layout);
-
-    return page;
-}
-
 int AddPrinter::newInstance()
 {
-    KAssistantDialog *wizard = new KAssistantDialog;
-    wizard->addPage(createIntroPage(), i18n("Welcome to the Add New Printer \
                Wizard"));
-    PageDestinations *widget = new PageDestinations;
-    wizard->addPage(widget, i18n("Select a Printer to Add"));
-//     connect(widget, SIGNAL(canProceed(bool)), wizard, SLOT(enable))
-//     wizard.addPage(createConclusionPage());
-
-    wizard->setWindowTitle(i18n("Add a New Printer"));
-    wizard->showButton(KDialog::Cancel, false);
-    QSize size = wizard->minimumSizeHint();
-    size += QSize(150, 0);
-    (void)wizard->setMaximumSize(size);
-    (void)wizard->setMinimumSize(size);
+    AddPrinterAssistant *wizard = new AddPrinterAssistant;
     wizard->show();
-//     wizard->layout()->setContentsMargins(0,0,0,0);
 
     return 0;
 }
--- trunk/playground/base/print-manager/add-printer/CMakeLists.txt #1124125:1124126
@@ -5,8 +5,10 @@
     AddPrinter.cpp
     DevicesModel.cpp
     AddPrinterInterface.cpp
+    GenericPage.cpp
     PageIntro.cpp
     PageDestinations.cpp
+    AddPrinterAssistant.cpp
 )
 
 kde4_add_ui_files(addprinter_SRCS
--- trunk/playground/base/print-manager/add-printer/DevicesModel.cpp #1124125:1124126
@@ -41,6 +41,8 @@
         return;
     }
 
+    // clear the model to don't duplicate items
+    clear();
     m_ret = QCups::getDevices();
     connect(m_ret, SIGNAL(device(const QString &, const QString &, const QString &, \
                const QString &, const QString &, const QString &)),
             this, SLOT(device(const QString &, const QString &, const QString &, \
                const QString &, const QString &, const QString &)));
--- trunk/playground/base/print-manager/add-printer/PageDestinations.cpp \
#1124125:1124126 @@ -28,7 +28,7 @@
 #include <KDebug>
 
 PageDestinations::PageDestinations(QWidget *parent)
- : QWidget(parent)
+ : GenericPage(parent)
 {
     setupUi(this);
     setAttribute(Qt::WA_DeleteOnClose);
@@ -57,16 +57,15 @@
     painter.drawPixmap(startPoint, pixmap);
     printerL->setPixmap(icon);
 
-    DevicesModel *model = new DevicesModel(this);
-    KCategorizedSortFilterProxyModel *proxy = new \
                KCategorizedSortFilterProxyModel(model);
-    proxy->setSourceModel(model);
+    m_model = new DevicesModel(this);
+    KCategorizedSortFilterProxyModel *proxy = new \
KCategorizedSortFilterProxyModel(m_model); +    proxy->setSourceModel(m_model);
     proxy->setCategorizedModel(true);
     proxy->setDynamicSortFilter(true);
     proxy->sort(0);
     KCategoryDrawerV2 *drawer = new KCategoryDrawerV2(devicesLV);
     devicesLV->setModel(proxy);
     devicesLV->setCategoryDrawer(drawer);
-    model->update();
     connect(devicesLV->selectionModel(), SIGNAL(selectionChanged(const \
QItemSelection &, const QItemSelection &)),  this, SLOT(checkSelected()));
 }
@@ -75,6 +74,11 @@
 {
 }
 
+void PageDestinations::load()
+{
+    m_model->update();
+}
+
 void PageDestinations::checkSelected()
 {
     emit canProceed(!devicesLV->selectionModel()->selection().isEmpty());
--- trunk/playground/base/print-manager/add-printer/PageDestinations.h \
#1124125:1124126 @@ -23,18 +23,27 @@
 
 #include "ui_PageDestinations.h"
 
-class PageDestinations : public QWidget, Ui::PageDestinations
+#include "GenericPage.h"
+
+class DevicesModel;
+class PageDestinations : public GenericPage, Ui::PageDestinations
 {
     Q_OBJECT
 public:
     PageDestinations(QWidget *parent = 0);
     ~PageDestinations();
 
+public slots:
+    void load();
+
 signals:
     void canProceed(bool value);
 
 private slots:
     void checkSelected();
+
+private:
+    DevicesModel *m_model;
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic