@@ -425,18 +425,18 @@ void ClipboardBrowser::setEditorWidget(ItemEditorWidget *editor, bool changeClip
425
425
setHorizontalScrollBarPolicy (scrollbarPolicy);
426
426
}
427
427
428
- void ClipboardBrowser::editItem (const QModelIndex &index, bool editNotes, bool changeClipboard)
428
+ void ClipboardBrowser::editItem (
429
+ const QModelIndex &index, const QString &format, bool changeClipboard)
429
430
{
430
431
if (!index.isValid ())
431
432
return ;
432
433
433
- ItemEditorWidget *editor = d.createCustomEditor (this , index, editNotes );
434
+ ItemEditorWidget *editor = d.createCustomEditor (this , index, format );
434
435
if (editor != nullptr && editor->isValid () ) {
435
436
setEditorWidget (editor, changeClipboard);
436
437
} else {
437
438
delete editor;
438
- if (!editNotes)
439
- openEditor (index);
439
+ openEditor (index, format);
440
440
}
441
441
}
442
442
@@ -1213,19 +1213,21 @@ void ClipboardBrowser::doItemsLayout()
1213
1213
bool ClipboardBrowser::openEditor ()
1214
1214
{
1215
1215
const QModelIndexList selected = selectionModel ()->selectedRows ();
1216
- return (selected.size () == 1 ) ? openEditor ( selected.first () )
1217
- : openEditor ( selectedText ().toUtf8 () );
1216
+ return (selected.size () == 1 ) ? openEditor ( selected.first (), mimeText )
1217
+ : openEditor ( {}, mimeText, selectedText ().toUtf8 () );
1218
1218
}
1219
1219
1220
- bool ClipboardBrowser::openEditor (const QByteArray &textData, bool changeClipboard)
1220
+ bool ClipboardBrowser::openEditor (
1221
+ const QModelIndex &index, const QString &format, const QByteArray &content, bool changeClipboard)
1221
1222
{
1222
1223
if ( !isLoaded () )
1223
1224
return false ;
1224
1225
1225
1226
if ( m_sharedData->editor .isEmpty () )
1226
1227
return false ;
1227
1228
1228
- QObject *editor = new ItemEditor (textData, mimeText, m_sharedData->editor , this );
1229
+ auto editor = new ItemEditor (content, format, m_sharedData->editor , this );
1230
+ editor->setIndex (index);
1229
1231
if ( !startEditor (editor) )
1230
1232
return false ;
1231
1233
@@ -1237,7 +1239,7 @@ bool ClipboardBrowser::openEditor(const QByteArray &textData, bool changeClipboa
1237
1239
return true ;
1238
1240
}
1239
1241
1240
- bool ClipboardBrowser::openEditor (const QModelIndex &index)
1242
+ bool ClipboardBrowser::openEditor (const QModelIndex &index, const QString &format )
1241
1243
{
1242
1244
if ( !isLoaded () )
1243
1245
return false ;
@@ -1253,7 +1255,7 @@ bool ClipboardBrowser::openEditor(const QModelIndex &index)
1253
1255
if ( !m_sharedData->editor .trimmed ().isEmpty () ) {
1254
1256
const QString text = getTextData (data);
1255
1257
if ( !text.isNull () ) {
1256
- auto itemEditor = new ItemEditor ( text.toUtf8 (), mimeText , m_sharedData->editor , this );
1258
+ auto itemEditor = new ItemEditor ( text.toUtf8 (), format , m_sharedData->editor , this );
1257
1259
itemEditor->setIndex (index);
1258
1260
if ( startEditor (itemEditor) )
1259
1261
return true ;
@@ -1272,7 +1274,7 @@ void ClipboardBrowser::editNotes()
1272
1274
scrollTo (ind, PositionAtTop);
1273
1275
emit requestShow (this );
1274
1276
1275
- editItem (ind, true );
1277
+ editItem (ind, mimeItemNotes );
1276
1278
}
1277
1279
1278
1280
void ClipboardBrowser::itemModified (const QByteArray &bytes, const QString &mime, const QModelIndex &index)
@@ -1357,7 +1359,7 @@ void ClipboardBrowser::moveToClipboard(const QModelIndexList &indexes)
1357
1359
emit changeClipboard (data);
1358
1360
}
1359
1361
1360
- void ClipboardBrowser::editNew (const QString &text , bool changeClipboard)
1362
+ void ClipboardBrowser::editNew (const QString &format, const QByteArray &content , bool changeClipboard)
1361
1363
{
1362
1364
if ( !isLoaded () )
1363
1365
return ;
@@ -1366,11 +1368,11 @@ void ClipboardBrowser::editNew(const QString &text, bool changeClipboard)
1366
1368
filterItems (nullptr );
1367
1369
1368
1370
m_selectNewItems = true ;
1369
- const bool added = add (text );
1371
+ const bool added = add ( createDataMap (format, content) );
1370
1372
m_selectNewItems = false ;
1371
1373
1372
1374
if (added)
1373
- editItem (currentIndex (), false , changeClipboard);
1375
+ editItem (currentIndex (), format , changeClipboard);
1374
1376
}
1375
1377
1376
1378
void ClipboardBrowser::keyPressEvent (QKeyEvent *event)
@@ -1532,7 +1534,7 @@ void ClipboardBrowser::editSelected()
1532
1534
QModelIndex ind = currentIndex ();
1533
1535
if ( ind.isValid () ) {
1534
1536
emit requestShow (this );
1535
- editItem (ind);
1537
+ editItem (ind, mimeText );
1536
1538
}
1537
1539
}
1538
1540
}
@@ -1797,9 +1799,9 @@ void ClipboardBrowser::setStoreItems(bool store)
1797
1799
::removeItems (m_tabName);
1798
1800
}
1799
1801
1800
- void ClipboardBrowser::editRow (int row)
1802
+ void ClipboardBrowser::editRow (int row, const QString &format )
1801
1803
{
1802
- editItem ( index (row) );
1804
+ editItem ( index (row), format );
1803
1805
}
1804
1806
1805
1807
void ClipboardBrowser::move (int key)
0 commit comments