Remove headers.h
[novacoin.git] / src / qt / addresstablemodel.cpp
index 8fd6d52..7b95f51 100644 (file)
@@ -2,7 +2,7 @@
 #include "guiutil.h"
 #include "walletmodel.h"
 
-#include "headers.h"
+#include "wallet.h"
 
 #include <QFont>
 #include <QColor>
@@ -27,8 +27,9 @@ struct AddressTableEntry
 };
 
 // Private implementation
-struct AddressTablePriv
+class AddressTablePriv
 {
+public:
     CWallet *wallet;
     QList<AddressTableEntry> cachedAddressTable;
 
@@ -39,8 +40,8 @@ struct AddressTablePriv
     {
         cachedAddressTable.clear();
 
-        CRITICAL_BLOCK(wallet->cs_wallet)
         {
+            LOCK(wallet->cs_wallet);
             BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, std::string)& item, wallet->mapAddressBook)
             {
                 const CBitcoinAddress& address = item.first;
@@ -169,8 +170,8 @@ bool AddressTableModel::setData(const QModelIndex & index, const QVariant & valu
             // Double-check that we're not overwriting a receiving address
             if(rec->type == AddressTableEntry::Sending)
             {
-                CRITICAL_BLOCK(wallet->cs_wallet)
                 {
+                    LOCK(wallet->cs_wallet);
                     // Remove old entry
                     wallet->DelAddressBookName(rec->address.toStdString());
                     // Add new entry with new address
@@ -231,7 +232,7 @@ QModelIndex AddressTableModel::index(int row, int column, const QModelIndex & pa
     }
 }
 
-void AddressTableModel::updateList()
+void AddressTableModel::update()
 {
     // Update address book model from Bitcoin core
     beginResetModel();
@@ -254,8 +255,8 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
             return QString();
         }
         // Check for duplicate addresses
-        CRITICAL_BLOCK(wallet->cs_wallet)
         {
+            LOCK(wallet->cs_wallet);
             if(wallet->mapAddressBook.count(strAddress))
             {
                 editStatus = DUPLICATE_ADDRESS;
@@ -285,10 +286,11 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
     {
         return QString();
     }
-    // Add entry and update list
-    CRITICAL_BLOCK(wallet->cs_wallet)
+    // Add entry
+    {
+        LOCK(wallet->cs_wallet);
         wallet->SetAddressBookName(strAddress, strLabel);
-    updateList();
+    }
     return QString::fromStdString(strAddress);
 }
 
@@ -302,25 +304,19 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex & paren
         // Also refuse to remove receiving addresses.
         return false;
     }
-    CRITICAL_BLOCK(wallet->cs_wallet)
     {
+        LOCK(wallet->cs_wallet);
         wallet->DelAddressBookName(rec->address.toStdString());
     }
-    updateList();
     return true;
 }
 
-void AddressTableModel::update()
-{
-
-}
-
 /* Look up label for address in address book, if not found return empty string.
  */
 QString AddressTableModel::labelForAddress(const QString &address) const
 {
-    CRITICAL_BLOCK(wallet->cs_wallet)
     {
+        LOCK(wallet->cs_wallet);
         CBitcoinAddress address_parsed(address.toStdString());
         std::map<CBitcoinAddress, std::string>::iterator mi = wallet->mapAddressBook.find(address_parsed);
         if (mi != wallet->mapAddressBook.end())