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

List:       kde-commits
Subject:    extragear/sysadmin/muon/installer
From:       Jonathan Michael Thomas <echidnaman () kubuntu ! org>
Date:       2010-12-07 22:40:06
Message-ID: 20101207224006.59362AC8A5 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1204552 by jmthomas:

In preparation for addons support, make the Transaction struct a class


 M  +19 -17    ApplicationBackend.cpp  
 M  +5 -17     ApplicationBackend.h  
 M  +3 -3      ApplicationDetailsView/ApplicationDetailsWidget.cpp  
 M  +1 -0      ApplicationDetailsView/ApplicationDetailsWidget.h  
 M  +3 -3      ApplicationModel/ApplicationExtender.cpp  
 M  +1 -0      ApplicationModel/ApplicationExtender.h  
 M  +3 -2      ApplicationModel/ApplicationViewWidget.cpp  
 M  +2 -1      CMakeLists.txt  


--- trunk/extragear/sysadmin/muon/installer/ApplicationBackend.cpp #1204551:1204552
@@ -33,6 +33,7 @@
 
 #include "Application.h"
 #include "ApplicationLauncher.h"
+#include "Transaction.h"
 
 ApplicationBackend::ApplicationBackend(QObject *parent)
     : QObject(parent)
@@ -80,6 +81,7 @@
     qSort(popconScores);
 
     m_maxPopconScore = popconScores.last();
+    qDeleteAll(m_queue);
     m_queue.clear();
 }
 
@@ -112,15 +114,15 @@
     Application *app = 0;
     m_workerState.first = event;
     if (!m_queue.isEmpty()) {
-        m_workerState.second = (*m_currentTransaction).application;
-        app = (*m_currentTransaction).application;
+        m_workerState.second = (*m_currentTransaction)->application();
+        app = (*m_currentTransaction)->application();
     }
 
     emit workerEvent(event, app);
 
     switch (event) {
     case QApt::PackageDownloadStarted:
-        (*m_currentTransaction).state = RunningState;
+        (*m_currentTransaction)->setState(RunningState);
         connect(m_backend, SIGNAL(downloadProgress(int, int, int)),
                 this, SLOT(updateDownloadProgress(int)));
         break;
@@ -130,7 +132,7 @@
         break;
     case QApt::CommitChangesStarted:
         m_debconfGui = new DebconfKde::DebconfGui("/tmp/qapt-sock");
-        (*m_currentTransaction).state = RunningState;
+        (*m_currentTransaction)->setState(RunningState);
         connect(m_backend, SIGNAL(commitProgress(const QString &, int)),
                 this, SLOT(updateCommitProgress(const QString &, int)));
         m_debconfGui->connect(m_debconfGui, SIGNAL(activated()), m_debconfGui, \
SLOT(show())); @@ -141,12 +143,12 @@
                    this, SLOT(updateCommitProgress(const QString &, int)));
 
         if (m_currentTransaction != m_queue.end()) {
-            m_appLaunchQueue << \
(*m_currentTransaction).application->package()->name(); +            m_appLaunchQueue \
<< (*m_currentTransaction)->application()->package()->name();  }
 
         m_workerState.first = QApt::InvalidEvent;
         m_workerState.second = 0;
-        (*m_currentTransaction).state = DoneState;
+        (*m_currentTransaction)->setState(DoneState);
         ++m_currentTransaction;
 
         if (m_currentTransaction == m_queue.end()) {
@@ -173,7 +175,7 @@
     // buttons do both marking and committing
     switch (error) {
     case QApt::AuthError:
-        emit transactionCancelled((*m_currentTransaction).application);
+        emit transactionCancelled((*m_currentTransaction)->application());
         m_backend->undo();
         break;
     case QApt::UserCancelError:
@@ -198,7 +200,7 @@
 
 void ApplicationBackend::updateDownloadProgress(int percentage)
 {
-    Application *app = (*m_currentTransaction).application;
+    Application *app = (*m_currentTransaction)->application();
     emit progress(app, percentage);
 }
 
@@ -206,13 +208,13 @@
 {
     Q_UNUSED(text);
 
-    Application *app = (*m_currentTransaction).application;
+    Application *app = (*m_currentTransaction)->application();
     emit progress(app, percentage);
 }
 
-void ApplicationBackend::addTransaction(Transaction transaction)
+void ApplicationBackend::addTransaction(Transaction *transaction)
 {
-    transaction.state = QueuedState;
+    transaction->setState(QueuedState);
     m_queue.append(transaction);
 
     if (m_queue.count() == 1) {
@@ -227,11 +229,11 @@
                this, SLOT(updateDownloadProgress(int)));
     disconnect(m_backend, SIGNAL(commitProgress(const QString &, int)),
                this, SLOT(updateCommitProgress(const QString &, int)));
-    QList<Transaction>::iterator iter = m_queue.begin();
+    QList<Transaction *>::iterator iter = m_queue.begin();
 
     while (iter != m_queue.end()) {
-        if ((*iter).application == app) {
-            if ((*iter).state == RunningState) {
+        if ((*iter)->application() == app) {
+            if ((*iter)->state() == RunningState) {
                 m_backend->cancelDownload();
                 m_backend->undo();
             }
@@ -249,9 +251,9 @@
     QApt::CacheState oldCacheState = m_backend->currentCacheState();
     m_backend->saveCacheState();
 
-    Application *app = (*m_currentTransaction).application;
+    Application *app = (*m_currentTransaction)->application();
 
-    switch ((*m_currentTransaction).action) {
+    switch ((*m_currentTransaction)->action()) {
     case QApt::Package::ToInstall:
     case QApt::Package::ToUpgrade:
         app->package()->setInstall();
@@ -331,7 +333,7 @@
     return m_workerState;
 }
 
-QList<Transaction> ApplicationBackend::transactions() const
+QList<Transaction *> ApplicationBackend::transactions() const
 {
     return m_queue;
 }
--- trunk/extragear/sysadmin/muon/installer/ApplicationBackend.h #1204551:1204552
@@ -37,20 +37,8 @@
 
 class Application;
 class ApplicationLauncher;
+class Transaction;
 
-enum TransactionState {
-    InvalidState = 0,
-    QueuedState = 1,
-    RunningState = 2,
-    DoneState = 3
-};
-
-struct Transaction {
-    Application *application;
-    int action;
-    TransactionState state;
-};
-
 class ApplicationBackend : public QObject
 {
     Q_OBJECT
@@ -60,10 +48,10 @@
 
     QList<Application *> applicationList() const;
     QPair<QApt::WorkerEvent, Application *> workerState() const;
-    QList<Transaction> transactions() const;
+    QList<Transaction *> transactions() const;
     int maxPopconScore() const;
 
-    void addTransaction(Transaction transaction);
+    void addTransaction(Transaction *transaction);
     void cancelTransaction(Application *app);
 
 private:
@@ -72,8 +60,8 @@
     QList<Application *> m_appList;
     QList<QString> m_appLaunchQueue;
     QList<QString> m_pkgBlacklist;
-    QList<Transaction> m_queue;
-    QList<Transaction>::iterator m_currentTransaction;
+    QList<Transaction *> m_queue;
+    QList<Transaction *>::iterator m_currentTransaction;
     QPair<QApt::WorkerEvent, Application *> m_workerState;
     int m_maxPopconScore;
 
--- trunk/extragear/sysadmin/muon/installer/ApplicationDetailsView/ApplicationDetailsWidget.cpp \
#1204551:1204552 @@ -286,9 +286,9 @@
     QPair<QApt::WorkerEvent, Application *> workerState = \
m_appBackend->workerState();  workerEvent(workerState.first, workerState.second);
 
-    foreach (Transaction transaction, m_appBackend->transactions()) {
-        if (transaction.application == m_app){
-            showTransactionState(transaction.state);
+    foreach (Transaction *transaction, m_appBackend->transactions()) {
+        if (transaction->application() == m_app){
+            showTransactionState(transaction->state());
         }
     }
 
--- trunk/extragear/sysadmin/muon/installer/ApplicationDetailsView/ApplicationDetailsWidget.h \
#1204551:1204552 @@ -29,6 +29,7 @@
 
 // Own includes
 #include "ApplicationBackend.h"
+#include "Transaction.h"
 
 class QLabel;
 class QProgressBar;
--- trunk/extragear/sysadmin/muon/installer/ApplicationModel/ApplicationExtender.cpp \
#1204551:1204552 @@ -85,9 +85,9 @@
     QPair<QApt::WorkerEvent, Application *> workerState = \
m_appBackend->workerState();  workerEvent(workerState.first, workerState.second);
 
-    foreach (Transaction transaction, m_appBackend->transactions()) {
-        if (transaction.application == m_app){
-            showTransactionState(transaction.state);
+    foreach (Transaction *transaction, m_appBackend->transactions()) {
+        if (transaction->application() == m_app){
+            showTransactionState(transaction->state());
         }
     }
 }
--- trunk/extragear/sysadmin/muon/installer/ApplicationModel/ApplicationExtender.h \
#1204551:1204552 @@ -26,6 +26,7 @@
 #include <LibQApt/Globals>
 
 #include "ApplicationBackend.h"
+#include "Transaction.h"
 
 class QProgressBar;
 class QPushButton;
--- trunk/extragear/sysadmin/muon/installer/ApplicationModel/ApplicationViewWidget.cpp \
#1204551:1204552 @@ -39,6 +39,7 @@
 #include "../ApplicationDetailsView/ApplicationDetailsView.h"
 #include "../BreadcrumbWidget/BreadcrumbItem.h"
 #include "../CategoryView/Category.h"
+#include "../Transaction.h"
 
 ApplicationViewWidget::ApplicationViewWidget(QWidget *parent, ApplicationBackend \
*appBackend)  : AbstractViewBase(parent)
@@ -164,13 +165,13 @@
 
 void ApplicationViewWidget::installButtonClicked(Application *app)
 {
-    Transaction transaction = { app, QApt::Package::ToInstall, (TransactionState)0 \
}; +    Transaction *transaction = new Transaction(app, QApt::Package::ToInstall);
     m_appBackend->addTransaction(transaction);
 }
 
 void ApplicationViewWidget::removeButtonClicked(Application *app)
 {
-    Transaction transaction = { app, QApt::Package::ToRemove, (TransactionState)0 };
+    Transaction *transaction = new Transaction(app, QApt::Package::ToRemove);
 
     m_appBackend->addTransaction(transaction);
 }
--- trunk/extragear/sysadmin/muon/installer/CMakeLists.txt #1204551:1204552
@@ -25,7 +25,8 @@
     ClickableLabel.cpp
     effects/GraphicsOpacityDropShadowEffect.cpp
     ViewSwitcher.cpp
-    ScreenShotViewer.cpp)
+    ScreenShotViewer.cpp
+    Transaction.cpp)
 
 kde4_add_kcfg_files(muon_installer_SRCS GENERATE_MOC \
config/MuonInstallerSettings.kcfgc)  


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

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