# # # patch "res/forms/dialogs/generate_keypair.ui" # from [7a7913333631ef38db4a1807f1559e89b353d91d] # to [e610eb7e431daa5ce1e8dc247fa22abc5da1d302] # # patch "res/forms/dialogs/key_management.ui" # from [4913ed46e0685544cb5e3cf7cdf98b54aacd42ce] # to [845a74ded7cf3c377ee77a6f637aac9ce8084f20] # # patch "src/model/Keys.cpp" # from [11aae606f14aaa15d64c9f68f651bf3630733dd6] # to [5f6eedc7c6099bdaf294cced4707c935ba47c759] # # patch "src/model/Keys.h" # from [ebd6f123cf516f8d150820ec8b89c10038cb3cd2] # to [2ac3f606bafd5e8d70b9c23a33f85e841bb0699e] # # patch "src/view/dialogs/GenerateKeypair.cpp" # from [17c560ed391524a64ae4f86642641999a1eb99d7] # to [9b53712e884c27fabeb6b076c31d32de7266c7a6] # # patch "src/view/dialogs/KeyManagement.cpp" # from [8ec198b535cf0ccf759843678aaeafb14025faf4] # to [8f926ce4de668c7c928aca4eb69cc7af94397ec1] # # patch "src/view/dialogs/KeyManagement.h" # from [214e2e8db3dc757a231a87ef49b4450668ec21fc] # to [f110b2cd75d8543287ccff9d17bd4e7f611276bb] # ============================================================ --- res/forms/dialogs/generate_keypair.ui 7a7913333631ef38db4a1807f1559e89b353d91d +++ res/forms/dialogs/generate_keypair.ui e610eb7e431daa5ce1e8dc247fa22abc5da1d302 @@ -1,145 +1,132 @@ - + + GenerateKeypair - - + + Qt::WindowModal - + true - + 0 0 - 335 - 136 + 382 + 182 - - - 5 - 5 + + 0 0 - + 0 0 - + Generate new Keypair - - :/icons/guitone.png + + + :/icons/guitone.png:/icons/guitone.png - + false - + false - - - 9 + + + QFormLayout::ExpandingFieldsGrow - - 6 + + 16 - - - - 0 + + + + Key ID (e.g. email) - - 6 + + + + + + + 0 + 0 + - - - - 0 - - - 6 - - - - - 0 - - - 6 - - - - - Key ID (e.g. email) - - - - - - - Password - - - - - - - Repeat password - - - - - - - - - 0 - - - 6 - - - - - - - - QLineEdit::Password - - - - - - - QLineEdit::Password - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok - - - - + + + + + allow duplicate key ID + + + + + + + Password + + + + + + + + 0 + 0 + + + + QLineEdit::Password + + + + + + + Repeat password + + + + + + + + 0 + 0 + + + + QLineEdit::Password + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + - + + @@ -148,11 +135,11 @@ GenerateKeypair accept() - + 248 254 - + 157 274 @@ -164,11 +151,11 @@ GenerateKeypair reject() - + 316 260 - + 286 274 ============================================================ --- res/forms/dialogs/key_management.ui 4913ed46e0685544cb5e3cf7cdf98b54aacd42ce +++ res/forms/dialogs/key_management.ui 845a74ded7cf3c377ee77a6f637aac9ce8084f20 @@ -1,7 +1,8 @@ - + + KeyManagement - - + + 0 0 @@ -9,64 +10,56 @@ 433 - + Key Management - - :/icons/guitone.png + + + :/icons/guitone.png:/icons/guitone.png - - - 9 - - - 6 - + - - - 0 - - - 6 - + - - + + 400 0 - + + QAbstractItemView::NoEditTriggers + + false - + false + + false + + + false + - - - 0 - - - 6 - + - - + + Generate Keypair - + Qt::Horizontal - + 40 20 @@ -75,11 +68,11 @@ - - + + Close - + true @@ -103,7 +96,8 @@ generateKey - + + @@ -112,11 +106,11 @@ KeyManagement accept() - + 523 24 - + 293 216 ============================================================ --- src/model/Keys.cpp 11aae606f14aaa15d64c9f68f651bf3630733dd6 +++ src/model/Keys.cpp 5f6eedc7c6099bdaf294cced4707c935ba47c759 @@ -62,28 +62,28 @@ void Keys::processTaskResult(const Monot StanzaEntry entry = stanza.at(j); // we're now only interested in stanzas starting with a "name" entry - if (j == 0 && entry.sym != "name") break; + if (j == 0 && entry.sym != "hash") break; isItem = true; - if (entry.sym == "name") + if (entry.sym == "hash") { - I(entry.vals.size() == 1); - key.name = entry.vals.at(0); + I(!entry.hash.isNull()); + key.hash = entry.hash; continue; } - if (entry.sym == "public_hash") + if (entry.sym == "given_name") { - I(!entry.hash.isNull()); - key.public_hash = entry.hash; + I(entry.vals.size() == 1); + key.given_name = entry.vals.at(0); continue; } - if (entry.sym == "private_hash") + if (entry.sym == "local_name") { - I(!entry.hash.isNull()); - key.private_hash = entry.hash; + I(entry.vals.size() == 1); + key.local_name = entry.vals.at(0); continue; } @@ -166,9 +166,9 @@ QVariant Keys::data(const QModelIndex & switch (index.column()) { - case 0: return QVariant(key.name); - case 1: return QVariant(key.public_hash); - case 2: return QVariant(key.private_hash); + case 0: return QVariant(key.hash); + case 1: return QVariant(key.given_name); + case 2: return QVariant(key.local_name); case 3: return QVariant(getLocationString(key.public_locations)); case 4: return QVariant(getLocationString(key.private_locations)); } @@ -198,9 +198,9 @@ QVariant Keys::headerData(int section, Q { switch (section) { - case 0: return QVariant(tr("Name")); - case 1: return QVariant(tr("Public Hash")); - case 2: return QVariant(tr("Private Hash")); + case 0: return QVariant(tr("Hash")); + case 1: return QVariant(tr("Given Name")); + case 2: return QVariant(tr("Local Name")); case 3: return QVariant(tr("Public Locations")); case 4: return QVariant(tr("Private Locations")); } ============================================================ --- src/model/Keys.h ebd6f123cf516f8d150820ec8b89c10038cb3cd2 +++ src/model/Keys.h 2ac3f606bafd5e8d70b9c23a33f85e841bb0699e @@ -26,9 +26,9 @@ struct Key { struct Key { static const int Database; static const int Keystore; - QString name; - QString public_hash; - QString private_hash; + QString given_name; + QString local_name; + QString hash; int public_locations; int private_locations; Key() : public_locations(0), private_locations(0) {}; ============================================================ --- src/view/dialogs/GenerateKeypair.cpp 17c560ed391524a64ae4f86642641999a1eb99d7 +++ src/view/dialogs/GenerateKeypair.cpp 9b53712e884c27fabeb6b076c31d32de7266c7a6 @@ -57,11 +57,18 @@ void GenerateKeypair::accept() return; } + QStringList options; + if (allowDuplicateKey->isChecked()) + { + options << "force-duplicate-key" << "1"; + } + MonotoneTask out = MonotoneUtil::runSynchronousDatabaseTask( databaseFile, MonotoneTask(QStringList() << "genkey" << lineKeyName->text() - << lineKeyPasswd->text() + << lineKeyPasswd->text(), + options ) ); if (!out.isFinished()) F("task aborted"); ============================================================ --- src/view/dialogs/KeyManagement.cpp 8ec198b535cf0ccf759843678aaeafb14025faf4 +++ src/view/dialogs/KeyManagement.cpp 8f926ce4de668c7c928aca4eb69cc7af94397ec1 @@ -32,8 +32,12 @@ KeyManagement::KeyManagement(QWidget * p Dialog::init(); model = new Keys(this, databaseFile); - keyList->setModel(model); + proxyModel = new QSortFilterProxyModel(this); + proxyModel->setSourceModel(model); + keyList->setModel(proxyModel); + keyList->setSortingEnabled(true); + connect( generateKey, SIGNAL(clicked()), this, SIGNAL(generateKeypair()) @@ -46,14 +50,20 @@ KeyManagement::KeyManagement(QWidget * p popupMenu = new QMenu(this); - QAction * act = new QAction(tr("Copy key name to clipboard"), this); - connect(act, SIGNAL(triggered()), this, SLOT(copyKeyNameToClipboard())); + QAction * act = new QAction(tr("Copy key hash to clipboard"), this); + connect(act, SIGNAL(triggered()), this, SLOT(copyKeyHashToClipboard())); popupMenu->addAction(act); - act = new QAction(tr("Copy public key hash to clipboard"), this); - connect(act, SIGNAL(triggered()), this, SLOT(copyPubkeyHashToClipboard())); + act = new QAction(tr("Copy given name to clipboard"), this); + connect(act, SIGNAL(triggered()), this, SLOT(copyGivenNameToClipboard())); popupMenu->addAction(act); + act = new QAction(tr("Copy local name to clipboard"), this); + connect(act, SIGNAL(triggered()), this, SLOT(copyLocalNameToClipboard())); + popupMenu->addAction(act); + + popupMenu->addSeparator(); + act = new QAction(tr("Copy public key data to clipboard"), this); connect(act, SIGNAL(triggered()), this, SLOT(copyPubkeyDataToClipboard())); popupMenu->addAction(act); @@ -61,6 +71,7 @@ KeyManagement::~KeyManagement() KeyManagement::~KeyManagement() { + delete proxyModel; delete model; qDeleteAll(popupMenu->findChildren()); delete popupMenu; @@ -81,33 +92,56 @@ Key * KeyManagement::getKeyFromSelection { QItemSelectionModel * selection = keyList->selectionModel(); QList indexList = selection->selectedIndexes(); - // we're only interested in the first column's internal pointer - return static_cast(indexList[0].internalPointer()); + + if (indexList.size() == 0) + return 0; + + QModelIndex srcIndex = proxyModel->mapToSource(indexList.at(0)); + return static_cast(srcIndex.internalPointer()); } -void KeyManagement::copyKeyNameToClipboard() +void KeyManagement::copyKeyHashToClipboard() { Key * key = getKeyFromSelection(); + if (key == 0) + return; + QClipboard * clipboard = QApplication::clipboard(); - clipboard->setText(key->name); + clipboard->setText(key->hash); } -void KeyManagement::copyPubkeyHashToClipboard() +void KeyManagement::copyGivenNameToClipboard() { Key * key = getKeyFromSelection(); + if (key == 0) + return; + QClipboard * clipboard = QApplication::clipboard(); - clipboard->setText(key->public_hash); + clipboard->setText(key->given_name); } +void KeyManagement::copyLocalNameToClipboard() +{ + Key * key = getKeyFromSelection(); + if (key == 0) + return; + + QClipboard * clipboard = QApplication::clipboard(); + clipboard->setText(key->local_name); +} + //! \todo should be converted to automate pubkey, if available void KeyManagement::copyPubkeyDataToClipboard() { Key * key = getKeyFromSelection(); + if (key == 0) + return; + QClipboard * clipboard = QApplication::clipboard(); QStringList args; QByteArray output; - args << "-d" << databaseFile << "pubkey" << key->name; + args << "-d" << databaseFile << "pubkey" << key->hash; if (!MonotoneManager::singleRun(Settings::getMtnBinaryPath(), args, output)) { @@ -115,7 +149,7 @@ void KeyManagement::copyPubkeyDataToClip this, tr("Couldn't query public key data"), tr("Failed to query public key data for key \"%1\".") - .arg(key->name), + .arg(key->hash), QMessageBox::Ok ); return; ============================================================ --- src/view/dialogs/KeyManagement.h 214e2e8db3dc757a231a87ef49b4450668ec21fc +++ src/view/dialogs/KeyManagement.h f110b2cd75d8543287ccff9d17bd4e7f611276bb @@ -25,6 +25,7 @@ #include #include +#include class KeyManagement : public Dialog, private Ui::KeyManagement { @@ -43,13 +44,15 @@ private: Key * getKeyFromSelection() const; Keys * model; + QSortFilterProxyModel * proxyModel; QMenu * popupMenu; DatabaseFile databaseFile; private slots: void contextMenuEvent(const QModelIndexList &, const QPoint &); - void copyKeyNameToClipboard(); - void copyPubkeyHashToClipboard(); + void copyKeyHashToClipboard(); + void copyGivenNameToClipboard(); + void copyLocalNameToClipboard(); void copyPubkeyDataToClipboard(); };