25 #include <QApplication>
29 #include <QDataStream>
30 #include <QMessageBox>
31 #include <QAbstractItemModel>
32 #include <QModelIndex>
35 #include <QVBoxLayout>
36 #include <QStackedWidget>
38 #include <QHeaderView>
39 #include <QTextDocument>
40 #include <QTextCursor>
41 #include <QTextCharFormat>
47 #include <QDragEnterEvent>
48 #include <QDragMoveEvent>
49 #include <QStandardItemModel>
50 #include <QItemDelegate>
53 #include <ui_klflibopenresourcedlg.h>
54 #include <ui_klflibrespropeditor.h>
55 #include <ui_klflibnewsubresdlg.h>
73 for (k = 0; k < img.
height(); ++k) {
74 for (j = 0; j < img.
width(); ++j) {
75 QRgb c = img2.
pixel(j, k);
76 img2.
setPixel(j, k, qRgba(qRed(c),qGreen(c),qBlue(c),(
int)(factor*qAlpha(c))));
88 int min_x = -1, max_x = -1, min_y = -1, max_y = -1;
90 for (x = 0; x < img.
width(); ++x) {
91 for (y = 0; y < img.
height(); ++y) {
92 if (qAlpha(img.
pixel(x,y)) - alpha_threshold > 0) {
94 if (min_x == -1 || min_x > x) min_x = x;
95 if (max_x == -1 || max_x < x) max_x = x;
96 if (min_y == -1 || min_y > y) min_y = y;
97 if (max_y == -1 || max_y < y) max_y = y;
106 static const float C_r = 11.f, C_g = 16.f, C_b = 5.f;
107 static const float C_avg = (C_r + C_g + C_b) / 3.f;
115 static const float drkfactor = 1;
117 float alpha = qAlpha(a)/255.f;
120 m = qRgb((
int)(qRed(a)+(1-alpha)*qRed(b)),
121 (
int)(qGreen(a)+(1-alpha)*qGreen(b)),
122 (
int)(qBlue(a)+(1-alpha)*qBlue(b)));
124 m = qRgb((
int)(alpha*qRed(a)+(1-alpha)*qRed(b)),
125 (
int)(alpha*qGreen(a)+(1-alpha)*qGreen(b)),
126 (
int)(alpha*qBlue(a)+(1-alpha)*qBlue(b)));
128 float dst = qMax( qMax(C_r*abs(qRed(m) - qRed(b)), C_g*abs(qGreen(m) - qGreen(b))),
129 C_b*abs(qBlue(m) - qBlue(b)) ) * drkfactor / C_avg;
139 int fmt = imgsrc.
format();
143 case QImage::Format_ARGB32: img = imgsrc; apremultiplied =
false;
break;
144 case QImage::Format_ARGB32_Premultiplied: img = imgsrc; apremultiplied =
true;
break;
147 apremultiplied =
false;
150 QRgb bg = background.
rgb();
153 for (x = 0; x < img.
width(); ++x) {
154 for (y = 0; y < img.
height(); ++y) {
158 if (dist > threshold) {
172 :
QWidget(parent), pResourceEngine(NULL)
179 disconnect(pResourceEngine, 0,
this, 0);
180 pResourceEngine = resource;
183 connect(pResourceEngine, SIGNAL(resourcePropertyChanged(
int)),
185 connect(pResourceEngine, SIGNAL(defaultSubResourceChanged(
const QString&)),
215 :
QObject(parent), pViewTypeIdentifiers(viewTypeIdentifiers)
217 registerFactory(
this);
221 unRegisterFactory(
this);
227 if (pRegisteredFactories.
size() > 0)
228 return pRegisteredFactories[0]->pViewTypeIdentifiers.first();
234 if (viewTypeIdentifier.
isEmpty()) {
235 if (pRegisteredFactories.
size() > 0)
236 return pRegisteredFactories[0];
241 for (k = 0; k < pRegisteredFactories.
size(); ++k) {
243 return pRegisteredFactories[k];
253 for (k = 0; k < pRegisteredFactories.
size(); ++k)
264 if (factory->pViewTypeIdentifiers.size() == 0) {
265 qWarning(
"KLFLibViewFactory::registerFactory: factory must provide at least one view type!");
268 if (pRegisteredFactories.
indexOf(factory) != -1)
270 pRegisteredFactories.
append(factory);
275 if (pRegisteredFactories.
indexOf(factory) == -1)
352 return dbg.nospace() <<
"NodeId("<<skind<<
"+"<<n.
index<<
")";
356 return dbg <<
"[kind="<<n.
kind<<
", children/sz="<<n.
children.size()
361 return dbg <<
"EntryNode(entryid="<<en.
entryid<<
"; entry/latex="<<en.
entry.
latex()<<
"; parent="
369 KLF_EXPORT QDebug&
operator<<(QDebug& dbg,
const KLFLibModel::PersistentId& n)
371 return dbg <<
"PersistentId("<<n.kind<<
", entry_id="<<n.entry_id<<
", cat...path="<<n.categorylabel_fullpath<<
")";
373 KLF_EXPORT QDebug&
operator<<(QDebug& d,
const KLFLibViewDelegate::ColorRegion& c)
375 return d <<
"ColorRegion["<<c.start<<
"->+"<<c.len<<
"]";
392 if ( groupCategories ) {
401 qWarning(
"KLFLibModelSorter::operator(): Bad node kinds!! a: %d and b: %d",
413 int entryProp = entrysorter->
propId();
414 int sortorderfactor = (entrysorter->
order() == Qt::AscendingOrder) ? 1 : -1;
438 klfDbgT(
"saving persistent indexes ...");
441 klfDbgT(
"... done saving persistent indexes.");
445 pCategoryLabelCache.
clear();
466 klfDbgT(
"about to query resource...");
468 klfDbgT(
"resource returned "<<count<<
" entries.");
473 if (count < pModel->pFetchBatchCount) {
475 klfDbg(
"all children have been fetched.") ;
482 for (it = everything.
begin(); it != everything.
end(); ++it) {
499 klfDbgT(
"About to query categories...");
502 klfDbgT(
"... got categories. inserting them ...");
503 for (QVariantList::const_iterator vcit = vcatlist.begin(); vcit != vcatlist.end(); ++vcit) {
504 QString cat = (*vcit).toString();
505 if (cat.
isEmpty() || cat ==
"/")
511 qWarning()<<
KLF_FUNC_NAME<<
": Failed to create category node for category "<<cat;
514 insertCategoryStringInSuggestionCache(catelements);
516 klfDbgT(
"... ins catnodes done.") ;
523 klfDbg(
"restoring persistent indexes ...");
524 QModelIndexList newPersistentIndexes =
pModel->newPersistentIndexList(persistentIndexIds);
527 klfDbg(
"... done restoring persistent indexes.");
547 klfDbg(
": nodeid="<<nodeid<<
"; row="<<row<<
"; col="<<column ) ;
552 if (!parentid.
valid())
558 klfDbgT(
": need to fetch more children/size="
559 <<
getNode(parentid).children.size()<<
"<row="<<row<<
" !");
576 qWarning()<<
KLF_FUNC_NAME<<
": Invalid entry node reference: "<<n;
581 qWarning()<<
KLF_FUNC_NAME<<
": Invalid category label node reference: "<<n;
600 if (!nodeid.
valid()) {
601 qWarning()<<
"KLFLibModelCache::getNodeRef: Invalid Node Id: "<<nodeid;
606 qWarning()<<
"KLFLibModelCache::getNodeRef: Invalid Entry Node Id: "<<nodeid<<
" : index out of range!";
609 return pEntryCache[nodeid.
index];
611 if (nodeid.
index < 0 || nodeid.
index >= pCategoryLabelCache.
size()) {
612 qWarning()<<
"KLFLibModelCache::getNodeRef: Invalid Category Label Node Id: "<<nodeid
613 <<
" : index out of range!";
616 return pCategoryLabelCache[nodeid.
index];
618 qWarning(
"KLFLibModelCache::getNodeRef(): Invalid kind: %d (index=%d)\n", nodeid.
kind, nodeid.
index);
626 qWarning()<<
"KLFLibModelCache::getEntryNodeRef: Invalid Entry Node "<<nodeid<<
"!";
627 return dummyerrornode;
629 if (enforceNotMinimalist && pEntryCache[nodeid.
index].minimalist)
632 return pEntryCache[nodeid.
index];
639 qWarning()<<
"KLFLibModelCache::getCat.LabelNode: Invalid Category Label Node "<<nodeid<<
"!";
640 return pCategoryLabelCache[0];
642 return pCategoryLabelCache[nodeid.
index];
647 if ( ! node.
valid() )
655 if ( !pparentid.
valid() ) {
657 qWarning()<<
KLF_FUNC_NAME<<
": Found parentless non-root node: "<<node;
663 for (k = 0; k < pparent.
children.size(); ++k)
668 qWarning()<<
KLF_FUNC_NAME<<
": Unable to get node row: parent-child one-way broken!! node="<<node;
680 countdown =
pModel->pFetchBatchCount;
701 for (k = 0; k < updatedentries.
size(); ++k) {
704 qWarning()<<
KLF_FUNC_NAME<<
" got unrequested updated entry ID ?! id="<<eid;
707 NodeId nid = wantedIds[eid];
708 pEntryCache[nid.
index].entry = updatedentries[k].entry;
709 pEntryCache[nid.
index].minimalist =
false;
711 klfDbg(
": updated entries "<<wantedIds.
keys() ) ;
720 if (!parentId.
valid())
723 klfDbg(
"parentId="<<parentId) ;
732 klfDbg(
"cannot fetchmore.") ;
740 if (fetchBatchCount < 0)
741 fetchBatchCount =
pModel->pFetchBatchCount;
745 pIsFetchingMore =
true;
753 klfDbg(
"can't fetch more in this node kind. n="<<n);
754 qWarning()<<
KLF_FUNC_NAME<<
": Can't fetch more children of a non-category-label node.";
763 klfDbg(
"can't fetch more: all children are fetched! noderef="<<noderef<<
"; n (the id)="<<n) ;
765 pIsFetchingMore =
false;
785 qWarning()<<
KLF_FUNC_NAME<<
": error fetching more results: count is "<<count;
786 pIsFetchingMore =
false;
799 pModel->startLayoutChange(
false);
804 if (count < q.
limit) {
821 klfDbg(
"appending "<<e<<
" in category node.") ;
823 noderef.
children.append(entryindex);
826 klfDbg(
"Fetched more. About to notify view of end of rows inserted ... meanwile the dump:") ;
830 klfDbg(
"signal emitted. restore persistent indexes...") ;
831 pModel->endLayoutChange(
false);
833 klfDbg(
"views notified, persistent indexes restored.") ;
835 pIsFetchingMore =
false;
843 klfDbg(
"modifyType="<<modifyType<<
" entryIdList="<<entryIdList ) ;
846 klfDbg(
"Performing full refresh.") ;
851 if (entryIdList.
size() > 10 &&
852 (entryIdList.
size() > pEntryCache.
size()/3 || entryIdList.
size() > 100)) {
854 klfDbg(
"Performing full refresh.") ;
863 QObject::tr(
"Updating View...",
"[[KLFLibModelCache, progress text]]"));
864 progressReporter.doReportProgress(0);
867 switch (modifyType) {
872 for (k = 0; k < entryList.
size(); ++k) {
876 en.
entry = entryList[k].entry;
880 qDebug(
"%s: entry ID %d inserted",
KLF_FUNC_NAME, entryIdList[k]);
883 progressReporter.doReportProgress(k+1);
892 for (k = 0; k < entryIdList.
size(); ++k) {
893 klfDbg(
"modifying entry ID="<<entryIdList[k]<<
", modif."<<k) ;
901 klfDbg(
"entry change: old="<<oldentry<<
"; new="<<newentry) ;
904 pModel->startLayoutChange(
false);
910 entrynode.
entryid = entryIdList[k];
911 entrynode.
entry = newentry;
914 pModel->endLayoutChange(
false);
919 pEntryCache[n.
index].entry = newentry;
925 progressReporter.doReportProgress(k+1);
933 for (k = 0; k < entryIdList.
size(); ++k) {
934 qDebug(
"%s: deleting entry ID=%d.",
KLF_FUNC_NAME, entryIdList[k]);
944 progressReporter.doReportProgress(k+1);
951 qWarning()<<
KLF_FUNC_NAME<<
": Bad modify-type parameter: "<<modifyType;
958 klfDbg(
": udpated; full tree dump:" ) ;
967 bool notifyQtApi = !rebuildingcache;
968 klfDbg(
"entrynode="<<entrynode<<
",notifyQtApi="<<notifyQtApi<<
"" ) ;
976 insertCategoryStringInSuggestionCache(catelements);
988 qWarning(
"Flavor Flags have unknown display type! flavorFlags=%#010x",
pModel->pFlavorFlags);
999 pEntryCache[index].parent =
NodeId();
1006 if (rebuildingcache || pLastSortPropId < 0) {
1007 insertPos = childlistref.
size();
1017 insertPos = qLowerBound(childlistref.
begin(), childlistref.
end(), n, srt) - childlistref.
begin();
1025 if (insertPos < childlistref.
size() && childlistref[insertPos] == n)
1037 qDebug(
"\tinserting (%d,%d) at pos %d in category '%s'", n.
kind, n.
index, insertPos,
1040 pEntryCache[n.
index].parent = parentid;
1042 childlistref.
insert(insertPos, n);
1052 klfDbg(
"("<<nodeid<<
","<<notifyQtApi<<
")" ) ;
1057 qWarning()<<
KLF_FUNC_NAME<<
": nodeid="<<nodeid<<
" does not reference an entry node!";
1062 klfDbg(
"The entrynode in question is "<<entrynode) ;
1065 bool willRemoveParent;
1072 klfDbg(
"Getting interested to remove entry ID="<<n<<
", from its parent of id="<<parentid) ;
1074 qWarning()<<
KLF_FUNC_NAME<<
"("<<n<<
"): Bad parent node kind: "<<parentid.
kind<<
"!";
1078 int childIndex = pCategoryLabelCache[parentid.
index].children.
indexOf(n);
1079 if (childIndex < 0) {
1080 qWarning()<<
KLF_FUNC_NAME<<
"("<<n<<
"): !!?! bad child-parent relation, can't find "<<n
1081 <<
" in child list "<<pCategoryLabelCache[parentid.
index].children<<
"; full dump:\n"
1082 <<
"\tEntryCache = "<<pEntryCache<<
"\n"
1083 <<
"\tCat.Lbl.Cache = "<<pCategoryLabelCache;
1092 klfDbg(
"unlinking entry node "<<n);
1095 klfDbg(
"unlinking category label node "<<n);
1098 qWarning()<<
KLF_FUNC_NAME<<
": unlinking elements: unknown node kind in id="<<n<<
"!";
1102 klfDbg(
"removing child #"<<childIndex<<
" from parent id="<<parentid<<
"; parent itself is "<<parentref) ;
1103 parentref.
children.removeAt(childIndex);
1107 }
while (willRemoveParent);
1117 bool notifyQtApi,
bool newlyCreatedAreChildrenFetched)
1119 klfDbg(
"catelmnts="<<catelements<<
", createIfNotExists="<<createIfNotExists<<
", notifyQtApi="<<notifyQtApi ) ;
1124 for (i = 0; i < pCategoryLabelCache.
size(); ++i) {
1126 pCategoryLabelCache[i].parent.valid() &&
1127 pCategoryLabelCache[i].fullCategoryPath == catelpath) {
1132 if (catelements.isEmpty())
1137 if ( ! createIfNotExists )
1141 qWarning(
"cacheFindCategoryLabel: but not in a category tree display type (flavor flags=%#010x)",
1146 QStringList catelementsparent = catelements.mid(0, catelements.size()-1);
1163 if (pLastSortPropId < 0) {
1164 insertPos = childlistref.
size();
1167 insertPos = qLowerBound(childlistref.
begin(), childlistref.
end(),
1171 <<
" at position "<<insertPos ) ;
1176 qDebug(
"%s: Inserting this_index=%d in parent_index=%d 's children",
KLF_FUNC_NAME, this_index,
1196 if (entryProperty < 0) {
1197 qWarning()<<
KLF_FUNC_NAME<<
": invalid entry property ID : "<<entryProperty;
1215 bool requireSimpleReverse =
false;
1226 requireSimpleReverse =
true;
1238 if (category.
index < 0 || category.
index >= pCategoryLabelCache.
size())
1245 if (requireSimpleReverse) {
1247 int N = childlistref.
size();
1248 int firstEntryInd = 0;
1250 for (firstEntryInd = 0; firstEntryInd < N &&
1251 childlistref[firstEntryInd].kind !=
EntryKind; ++firstEntryInd)
1256 for (k = 0; k < (N-firstEntryInd)/2; ++k)
1257 qSwap(childlistref[firstEntryInd+k], childlistref[N-k-1]);
1259 qSort(childlistref.
begin(), childlistref.
end(), *sorter);
1263 for (k = 0; k < childlistref.
size(); ++k)
1296 while ( (parentid = nn.
parent).valid() ) {
1299 if (row+1 < parent.
children.size()) {
1350 qWarning()<<
KLF_FUNC_NAME<<
": internal error: node "<<n<<
", node="<<nn
1351 <<
" has allChildrenFetched=false, but can't fetch more!";
1374 for (k = 0; k < indexlist.size(); ++k) {
1394 for (k = 0; k < indexlist.size(); ++k) {
1406 klfDbg(
": eidlist="<<eidlist ) ;
1409 QModelIndexList indexlist;
1411 for (k = 0; k < eidlist.
size(); ++k)
1415 for (k = 0; k < pEntryCache.
size(); ++k) {
1416 if (!pEntryCache[k].entryIsValid())
1418 int i = eidlist.
indexOf(pEntryCache[k].entryid);
1421 if (++count == eidlist.
size())
1432 for (k = 0; k < pEntryCache.
size(); ++k)
1433 if (pEntryCache[k].entryid == eId && pEntryCache[k].entryIsValid())
1436 klfDbg(
"...not found.") ;
1445 qDebug(
"---------------------------------------------------------");
1446 qDebug(
"------------- FULL CACHE DUMP ---------------------------");
1447 qDebug(
"---------------------------------------------------------");
1449 qDebug(
"Entry cache dump:");
1450 for (k = 0; k < pEntryCache.
size(); ++k)
1451 qDebug()<<
"#"<<k<<
": "<<pEntryCache[k];
1453 qDebug(
"Category Label cache dump: ");
1454 for (k = 0; k < pCategoryLabelCache.
size(); ++k)
1455 qDebug()<<
"#"<<k<<
": "<<pCategoryLabelCache[k];
1459 qDebug(
"---------------------------------------------------------");
1460 qDebug(
"---------------------------------------------------------");
1461 qDebug(
"---------------------------------------------------------");
1471 qDebug(
"---------------- NODE TREE DUMP -------------------------");
1473 char sindent[] =
" + ";
1474 if (indent < (
signed)strlen(sindent))
1475 sindent[indent] =
'\0';
1478 qDebug() << sindent <<
"(Invalid Node)";
1482 switch (node.
kind) {
1485 qDebug() << sindent << node <<
"\n"<<sindent<<
"\t\t"<<en;
1489 qDebug() << sindent << node <<
"\n"<<sindent<<
"\t\t"<<cn;
1492 qDebug() << sindent << node <<
"\n"<<sindent<<
"\t\t*InvalidNodeKind*(kind="<<node.
kind<<
")";
1498 for (k = 0; k < n.
children.size(); ++k) {
1504 qDebug(
"---------------------------------------------------------");
1505 qDebug(
"---------------------------------------------------------");
1551 delete pEntrySorter;
1561 updateCacheSetupModel();
1567 if (pResource == NULL) {
1572 return pResource->
url();
1583 if ( (flags & modify_mask) == (pFlavorFlags & modify_mask) )
1585 uint other_flags = pFlavorFlags & ~modify_mask;
1586 pFlavorFlags = flags | other_flags;
1590 updateCacheSetupModel();
1594 Qt::SortOrder ord = pEntrySorter->
order();
1602 return pFlavorFlags;
1609 for (k = 0; k < indexes.size(); ++k) {
1610 if (!indexes[k].isValid())
1614 klfDbg(
"Invalid index: indexes[k].row="<<indexes[k].row());
1637 return QVariant::fromValue<int>(p.
kind);
1646 return QVariant::fromValue<KLFLib::entryId>(ep.
entryid);
1648 if (role == Qt::ToolTipRole || role == Qt::DisplayRole) {
1657 if (role < Qt::UserRole)
1671 return entry.
latex();
1678 return entry.
tags();
1688 return QVariant::fromValue<QImage>(entry.
preview());
1697 if (role == Qt::ToolTipRole)
1713 Qt::ItemFlags flagdropenabled = 0;
1714 if ( index.
column() == 0 &&
1717 flagdropenabled = Qt::ItemIsDropEnabled;
1720 return flagdropenabled;
1726 return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled;
1728 return Qt::ItemIsEnabled | flagdropenabled;
1730 qWarning()<<
KLF_FUNC_NAME<<
": bad item kind! index-row="<<index.
row()<<
"; p="<<p;
1752 if (role == Qt::FontRole) {
1753 return qApp->font();
1755 if (role == Qt::SizeHintRole && orientation == Qt::Horizontal) {
1758 return QSize(280,30);
1760 return QSize(350,30);
1763 return QSize(200,30);
1768 if (role == Qt::DisplayRole) {
1769 if (orientation == Qt::Horizontal)
1800 klfDbgT(
": row="<<row<<
"; column="<<column<<
"; parent="<<parent);
1806 klfDbgT(
": requesting parent of index "<<index);
1827 klfDbg(
" parent="<<parent<<
"; numchildren="<<n.
children.size() ) ;
1857 switch (entryPropertyId) {
1894 return Qt::CopyAction|Qt::MoveAction;
1899 return QStringList() <<
"application/x-klf-internal-lib-move-entries"
1907 QModelIndexList indexes = indlist;
1914 for (k = 0; k < indexes.size(); ++k) {
1925 entriesnodeids << n;
1933 vprop[
"Url"] = myurl;
1940 {
QDataStream imstr(&internalmovedata, QIODevice::WriteOnly);
1942 imstr << vprop << entryids;
1944 mimedata->
setData(
"application/x-klf-internal-lib-move-entries", internalmovedata);
1950 bool KLFLibModel::dropCanInternal(
const QMimeData *mimedata)
1953 if ( ! mimedata->
hasFormat(
"application/x-klf-internal-lib-move-entries") ||
1957 QByteArray imdata = mimedata->
data(
"application/x-klf-internal-lib-move-entries");
1959 imstr.setVersion(QDataStream::Qt_4_4);
1962 QUrl theirurl = vprop.value(
"Url").toUrl();
1965 klfDbg(
"drag originated from "<<theirurl<<
"; we are "<<oururl<<
"; OK="<<ok ) ;
1973 klfDbg(
"Drop data: action="<<action<<
" row="<<row<<
" col="<<column
1974 <<
" parent="<<parent ) ;
1976 if (action == Qt::IgnoreAction)
1978 if (action != Qt::CopyAction)
1981 if ( ! (mimedata->
hasFormat(
"application/x-klf-internal-lib-move-entries") &&
1994 bool useinternalmove = dropCanInternal(mimedata);
1995 if (useinternalmove) {
1996 klfDbg(
"Dropping application/x-klf-internal-lib-move-entries" ) ;
2000 QByteArray imdata = mimedata->
data(
"application/x-klf-internal-lib-move-entries");
2005 imstr >> vprop >> idlist;
2012 qWarning()<<
"Dropped in a non-category index! (kind="<<pn.
kind<<
")";
2019 newcategory.
chop(1);
2023 klfDbg(
"Accepted drop of type application/x-klf-internal-lib-move-entries. Res="<<r<<
"\n"
2024 <<
"ID list is "<<idlist<<
" new category is "<<newcategory ) ;
2032 klfDbg(
"Dropping entry list." ) ;
2038 qWarning()<<
KLF_FUNC_NAME<<
": Drop: Can't decode mime data! provided types="
2041 tr(
"Error dropping data."));
2051 klfDbg(
"Dropped entry list "<<elist<<
". Originating URL="
2052 <<(vprop.contains(
"Url")?vprop[
"Url"]:
"(none)")<<
". result="<<res ) ;
2063 const QMimeData *mdata =
event->mimeData();
2064 if (dropCanInternal(mdata)) {
2085 if (indexes.isEmpty())
2090 const QPointF delta(18.0, 20.0);
2094 int iS = indexes.
size();
2095 int n = qMin(1+MAX, iS);
2096 for (j = 0, k = 0; k < iS && j < n; ++k) {
2104 previewlist << en.
entry.
preview().
scaled(s1, Qt::KeepAspectRatio, Qt::SmoothTransformation);
2110 int N = qMin(MAX, previewlist.
size());
2112 QImage image(s2, QImage::Format_ARGB32_Premultiplied);
2113 image.
fill(qRgba(0,0,0,0));
2118 for (k = 0; k < N; ++k) {
2201 if (pEntrySorter == entrySorter)
2203 if (entrySorter == NULL) {
2208 delete pEntrySorter;
2217 klfDbg(
" s="<<queryString<<
" from "<<fromIndex<<
" forward="<<forward ) ;
2218 pSearchAborted =
false;
2219 pSearchString = queryString;
2220 pSearchCurNode = fromIndex;
2226 pSearchAborted =
false;
2241 Qt::CaseSensitivity cs = Qt::CaseInsensitive;
2243 cs = Qt::CaseSensitive;
2247 (curNode = (pCache->*stepfunc)(curNode)).valid() ) {
2253 qApp->processEvents();
2261 klfDbg(
"found "<<pSearchString<<
" at "<<pSearchCurNode ) ;
2262 return pSearchCurNode;
2269 pSearchAborted =
true;
2273 Qt::CaseSensitivity cs)
2277 if (
nodeValue(nodeId).contains(searchString, cs))
2344 updateCacheSetupModel();
2353 updateCacheSetupModel();
2395 for (k = 0; k < persistentIndexes.size(); ++k) {
2407 qWarning(
"KLFLibModel::persistentIdList: Bad Node kind: %d!!",
id.kind);
2409 id.column = persistentIndexes[k].column();
2410 persistentIndexIds << id;
2411 klfDbg(
"saved persistent id "<<
id) ;
2413 return persistentIndexIds;
2415 QModelIndexList KLFLibModel::newPersistentIndexList(
const QList<PersistentId>& persistentIndexIds)
2418 QModelIndexList newPersistentIndexes;
2420 for (k = 0; k < persistentIndexIds.
size(); ++k) {
2422 PersistentId
id = persistentIndexIds[k];
2432 qWarning(
"%s: bad persistent id node kind! :%d", KLF_FUNC_NAME,
id.kind);
2435 newPersistentIndexes <<
index;
2436 klfDbg(
"restoring persistent id "<<
id<<
" as index "<<index) ;
2438 return newPersistentIndexes;
2442 void KLFLibModel::startLayoutChange(
bool withQtLayoutChangedSignal)
2446 if (withQtLayoutChangedSignal)
2450 pLytChgIds = persistentIdList(pLytChgIndexes);
2452 void KLFLibModel::endLayoutChange(
bool withQtLayoutChangedSignal)
2456 QModelIndexList newpindexes = newPersistentIndexList(pLytChgIds);
2459 if (withQtLayoutChangedSignal)
2464 void KLFLibModel::updateCacheSetupModel()
2477 pPreviewSize(
klfconfig.UI.labelOutputFixedSize)
2479 pAutoBackgroundItems =
true;
2521 klfDbg(
"\tindex="<<index<<
"; rect="<<option.rect ) ;
2532 if (rmodel != NULL) rres = rmodel->
resource();
2539 pp.
isselected = (option.state & QStyle::State_Selected);
2540 QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
2541 ? QPalette::Normal : QPalette::Disabled;
2542 if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
2543 cg = QPalette::Inactive;
2545 pp.
background = option.palette.brush(cg, QPalette::Highlight);
2546 painter->
setPen(option.palette.color(cg, QPalette::HighlightedText));
2550 ? pAutoBackgroundColor
2551 : option.palette.brush(cg, QPalette::Base);
2552 painter->
setPen(option.palette.color(cg, QPalette::Text));
2561 if (option.state & QStyle::State_HasFocus) {
2563 o.QStyleOption::operator=(option);
2564 o.rect = option.rect;
2565 o.state |= QStyle::State_KeyboardFocusChange;
2566 o.state |= QStyle::State_Item;
2567 QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled)
2568 ? QPalette::Normal : QPalette::Disabled;
2569 o.
backgroundColor = option.palette.color(cg, (option.state & QStyle::State_Selected)
2570 ? QPalette::Highlight : QPalette::Window);
2572 if (
const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3 *>(&option))
2575 style->
drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter, w);
2603 if (pAutoBackgroundItems) {
2619 bglista = bglistb = bglist;
2621 for (count = 0; count < 5; ++count)
2622 bglista << bglista.
last().darker(105+count*2);
2623 for (count = 0; count < 5; ++count)
2624 bglistb << bglistb.
last().lighter(105+count*2);
2627 klfDbg(
"alt. bg list is "<<bglist );
2629 for (k = 0; k < bglist.
size(); ++k) {
2633 if ( distinguishable )
2637 if (k > 0 && k < bglist.
size())
2662 .toDateTime(), QLocale::LongFormat), fl);
2666 qDebug(
"KLFLibViewDelegate::paintEntry(): Got bad contents type %d !",
2688 if ( pTheTreeView != NULL && !pTheTreeView->
isExpanded(index) &&
2700 QPalette::ColorGroup cg = p->
option->state & QStyle::State_Enabled
2701 ? QPalette::Normal : QPalette::Disabled;
2702 if (cg == QPalette::Normal && !(p->
option->state & QStyle::State_Active))
2703 cg = QPalette::Inactive;
2705 p->
p->
setPen(p->
option->palette.color(cg, QPalette::HighlightedText));
2725 QColor textcol = p->
option->palette.color(QPalette::Text);
2727 QGradientStops borderfadelingrstops;
2728 borderfadelingrstops << QGradientStop(0.0f, textcoltransp)
2729 << QGradientStop(0.1f, textcol)
2730 << QGradientStop(0.9f, textcol)
2731 << QGradientStop(1.0f, textcoltransp);
2733 borderfadelingr.setStops(borderfadelingrstops);
2734 borderfadelingr.setCoordinateMode(QGradient::LogicalMode);
2736 QPen normalpen =
QPen(textcol, 1.0f);
2741 text.
indexOf(pSearchString, 0, Qt::CaseInsensitive) == -1) &&
2746 drawnTextWidth = s.
width();
2750 klfDbg(
"Need border fade pen for text "<<text) ;
2753 klfDbg(
"Don't need border fade pen for text "<<text) ;
2763 f_highlight.setBackground(
QColor(0,255,0,80));
2764 f_highlight.setForeground(
QColor(128,0,0));
2768 if (!pSearchString.
isEmpty()) {
2769 while ((i = text.
indexOf(pSearchString, i+1, Qt::CaseInsensitive)) != -1)
2770 c << ColorRegion(f_highlight, i, pSearchString.
length());
2775 textDocument.setDefaultFont(font);
2778 for (i = ci = 0; i < text.
length(); ++i) {
2780 if (ci >= c.
size() && appliedfmts.
size() == 0) {
2785 while (ci < c.
size() && c[ci].start == i) {
2786 appliedfmts.
append(c[ci]);
2790 for (j = 0; j < appliedfmts.
size(); ++j) {
2791 if (i >= appliedfmts[j].start + appliedfmts[j].len) {
2797 f.merge(appliedfmts[j].fmt);
2802 QSizeF s = textDocument.size();
2808 if (flags & PTF_SelUnderline) {
2809 QColor h1 = p->
option->palette.color(QPalette::Highlight);
2814 gr.setCoordinateMode(QGradient::ObjectBoundingMode);
2815 gr.setColorAt(0.f, h1);
2816 gr.setColorAt(1.f, h2);
2821 textRect.
width(), 10), selbrush);
2825 drawnTextWidth = (int)s.
width();
2832 klfDbg(
"Need borderfadepen for (rich) text "<<textDocument.
toHtml());
2869 klfDbg(
"\tindex="<<index ) ;
2883 .toDateTime(), QLocale::LongFormat) )+
QSize(4,2);
2890 s.
scale(pPreviewSize, Qt::KeepAspectRatio);
2892 return s+
QSize(2,2);
2901 qWarning(
"KLFLibItemViewDelegate::sizeHint(): Bad Item kind: %d\n", kind);
2915 klfDbg(
"\t parent="<<parent ) ;
2928 klfDbg(
"selection size is "<<selection.size() ) ;
2930 for (k = 0; k < selection.size(); ++k) {
2931 if (selection[k].parent() != parent)
2933 if (selection[k].isValid())
2940 int timeLimitMs)
const
2948 klfDbg(
"selection under index parent="<<parent ) ;
2952 if (model == NULL) {
2959 for (k = 0; k < model->
rowCount(parent); ++k) {
2960 idx = model->
index(k, 0, parent);
2967 if (timer.
elapsed() > timeLimitMs)
2988 pPreviewSizeMenu = NULL;
2990 pEventFilterNoRecurse =
false;
2998 switch (pViewType) {
3012 setFocusPolicy(Qt::NoFocus);
3016 switch (pViewType) {
3019 klfDbg(
"Created list view." ) ;
3020 listView->setViewMode(QListView::IconMode);
3021 listView->setSpacing(15);
3022 listView->setMovement(QListView::Free);
3024 listView->setResizeMode(QListView::Adjust);
3025 klfDbg(
"prepared list view." ) ;
3032 treeView->setSortingEnabled(
true);
3033 treeView->setIndentation(16);
3034 treeView->setAllColumnsShowFocus(
true);
3041 lyt->addWidget(pView);
3044 pView->setSelectionBehavior(QAbstractItemView::SelectRows);
3045 pView->setSelectionMode(QAbstractItemView::ExtendedSelection);
3046 pView->setDragEnabled(
true);
3047 pView->setDragDropMode(QAbstractItemView::DragDrop);
3048 pView->setDragDropOverwriteMode(
false);
3049 pView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
3050 pView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
3052 pView->viewport()->installEventFilter(
this);
3053 pView->installEventFilter(
this);
3054 installEventFilter(
this);
3056 connect(pView, SIGNAL(clicked(
const QModelIndex&)),
3058 connect(pView, SIGNAL(doubleClicked(
const QModelIndex&)),
3071 return pModel->
url();
3075 bool baseequal =
false;
3076 uint resultFlags = 0x0;
3092 resultFlags |= KlfUrlCompareLessSpecific;
3093 }
else if (other.
hasQueryItem(
"klfDefaultSubResource")) {
3095 resultFlags |= KlfUrlCompareLessSpecific;
3108 resultFlags |= KlfUrlCompareMoreSpecific;
3114 resultFlags |= KlfUrlCompareMoreSpecific;
3120 bool hesupportssubres = other.
hasQueryItem(
"klfDefaultSubResource");
3121 if ( wesupportsubres && hesupportssubres ) {
3124 resultFlags |= KlfUrlCompareEqual;
3125 }
else if ( !wesupportsubres && ! hesupportssubres ) {
3127 resultFlags |= KlfUrlCompareEqual;
3133 klfDbg(
"and the final resultFlags are"<<
klfFmtCC(
"%#010x",resultFlags) ) ;
3151 if (pEventFilterNoRecurse) {
3152 klfDbg(
"Avoiding recursion") ;
3153 return KLFAbstractLibView::eventFilter(
object, event);
3157 if (
object == pView && event->
type() == QEvent::KeyPress) {
3161 for (k = 0; k < pViewActionsWithShortcut.
size(); ++k) {
3162 QAction *a = pViewActionsWithShortcut[k];
3163 if (a->shortcut() == thisKey) {
3164 klfDbg(
"Activating view action "<<a->text()<<
" for shortcut key "<<thisKey<<
".") ;
3170 return KLFAbstractLibView::eventFilter(
object, event);
3179 for (k = 0; k < idListWithDupl.
size(); ++k) {
3180 if (!idList.
contains(idListWithDupl[k]))
3181 idList << idListWithDupl[k];
3188 QModelIndexList selectedindexes = selectedEntryIndexes();
3192 for (k = 0; k < selectedindexes.size(); ++k) {
3196 klfDbg(
"selection list: adding item [latex="<<entry.
latex()<<
"; tags="<<entry.
tags()<<
"]" ) ;
3206 actionList << pIconViewActions;
3209 actionList << pShowColumnActions;
3220 KLF_ASSERT_NOT_NULL( tv,
"Tree View is NULL in view type "<<pViewType<<
" !!",
return QVariantMap() )
3222 vst[
"ColumnsState"] = QVariant::fromValue<QByteArray>(tv->
header()->saveState());
3227 vst[
"IconPreviewSize"] = QVariant::fromValue<QSize>(
previewSize());
3233 QByteArray colstate = vstate[
"ColumnsState"].toByteArray();
3235 KLF_ASSERT_NOT_NULL( tv,
"Tree View is NULL in view type"<<pViewType<<
"!!",
return false )
3237 tv->
header()->restoreState(colstate);
3251 KLF_ASSERT_NOT_NULL( lv,
"KLFLibDefListView List View is NULL in view type "<<pViewType<<
" !!",
3257 KLF_ASSERT_NOT_NULL( tv,
"KLFLibDefTreeView List View is NULL in view type "<<pViewType<<
" !!",
3268 #ifdef KLF_DEBUG_USE_MODELTEST
3278 if (resource == NULL) {
3281 for (k = 0; k < pShowColumnActions.
size(); ++k)
3282 delete pShowColumnActions[k];
3283 pShowColumnActions.
clear();
3287 uint model_flavor = 0;
3288 switch (pViewType) {
3302 if (pGroupSubCategories)
3305 pModel =
new KLFLibModel(resource, model_flavor,
this);
3310 klfDbg(
"created model. pModel="<<
klfFmtCC(
"%p", (
void*)pModel)<<
"; view type="<<pViewType);
3312 #ifdef KLF_DEBUG_USE_MODELTEST
3313 new ModelTest(pModel,
this);
3341 QAction *selectAllAction =
new QAction(tr(
"Select All",
"[[menu action]]"), pView);
3342 selectAllAction->setShortcut(selectAllKey);
3343 connect(selectAllAction, SIGNAL(triggered()),
this, SLOT(
slotSelectAll()));
3344 QAction *refreshAction =
new QAction(tr(
"Refresh",
"[[menu action]]"), pView);
3345 refreshAction->setShortcut(refreshKey);
3346 connect(refreshAction, SIGNAL(triggered()),
this, SLOT(
slotRefresh()));
3349 ag->setExclusive(
true);
3350 QAction *aPreviewSizeLarge =
new QAction(tr(
"Large",
"[[icon preview size menu item]]"), ag);
3351 aPreviewSizeLarge->setCheckable(
true);
3352 aPreviewSizeLarge->
setData(100);
3354 QAction *aPreviewSizeMedium =
new QAction(tr(
"Medium",
"[[icon preview size menu item]]"), ag);
3355 aPreviewSizeMedium->setCheckable(
true);
3356 aPreviewSizeMedium->
setData(75);
3358 QAction *aPreviewSizeSmall =
new QAction(tr(
"Small",
"[[icon preview size menu item]]"), ag);
3359 aPreviewSizeSmall->setCheckable(
true);
3360 aPreviewSizeSmall->
setData(50);
3363 pPreviewSizeMenu =
new QMenu(
this);
3364 pPreviewSizeMenu->
addAction(aPreviewSizeLarge);
3365 pPreviewSizeMenu->
addAction(aPreviewSizeMedium);
3366 pPreviewSizeMenu->
addAction(aPreviewSizeSmall);
3368 QAction *aPreviewSize =
new QAction(tr(
"Icon Size",
"[[icon preview size option menu]]"), pView);
3369 aPreviewSize->
setMenu(pPreviewSizeMenu);
3373 pCommonActions =
QList<QAction*>() << selectAllAction << refreshAction << aPreviewSize;
3374 pViewActionsWithShortcut << selectAllAction << refreshAction;
3377 klfDbg(
"About to prepare iconview." ) ;
3378 QAction * iconViewRelayoutAction =
new QAction(tr(
"Relayout All Icons",
"[[menu action]]"),
this);
3379 connect(iconViewRelayoutAction, SIGNAL(triggered()),
this, SLOT(
slotRelayoutIcons()));
3397 for (col = 0; col < pModel->
columnCount(); ++col) {
3401 a->setProperty(
"klfModelColumn", col);
3402 a->setCheckable(
true);
3407 QAction *menuAction =
new QAction(tr(
"Show/Hide Columns",
"[[menu with sub-menu]]"),
this);
3425 klfDbg(
"is category view.") ;
3433 klfDbg(
"i="<<i<<
"; i/rowCount="<<pModel->
rowCount(i)<<
"; numRootItems="<<numRootItems) ;
3434 if (pModel->
rowCount(i) < 6 || numRootItems < 6) {
3435 klfDbg(
"expanding item i="<<i) ;
3449 klfDbg(
"The resource modified its data [type="<<modifyType<<
"] in subres="<<subRes<<
". Our subres="<<
resourceEngine()->defaultSubResource()<<
"; matches?="<<
resourceEngine()->compareDefaultSubResourceEquals(subRes));
3466 klfDbg(
"propId="<<propId ) ;
3485 KLF_ASSERT_NOT_NULL( lv,
"KLFLibDefListView List View is NULL in view type "<<pViewType<<
" !!",
3486 return QListView::TopToBottom)
3490 qWarning()<<
KLF_FUNC_NAME<<
": requesting icon view flow in the wrong mode `"<<pViewType
3491 <<
"'. Should only be called for icon view modes.";
3492 return QListView::TopToBottom;
3527 klfDbg(
"selecting entries: "<<idList) ;
3532 for (k = 0; k < mil.size(); ++k)
3535 pView->
selectionModel()->select(sel, QItemSelectionModel::ClearAndSelect);
3537 if (pViewType ==
CategoryTreeView && pView->inherits(
"KLFLibDefTreeView")) {
3548 QModelIndexList sel = selectedEntryIndexes();
3549 if (sel.size() != 1) {
3550 qWarning(
"KLFLibDefaultView::restoreWithStyle(): Cannot restore: %d items selected.", sel.size());
3561 if ( ! pView->inherits(
"QTreeView") ) {
3562 qWarning(
"KLFLibDefaultView::showColumns(%d,%s): Resource view for %s: view does not inherit QTreeView!",
3563 propIdColumn, show?
"[show]":
"[hide]", qPrintable(
resourceEngine()->
url().toString()));
3567 qobject_cast<
QTreeView*>(pView)->setColumnHidden(colNo, show);
3572 if ( ! pView->inherits(
"QTreeView") ) {
3573 qWarning(
"KLFLibDefaultView::showBy(%d,%s): Resource view for %s: view does not inherit QTreeView!",
3574 propIdColumn, (sortorder == Qt::AscendingOrder)?
"[Ascending]":
"[Descending]" ,
3580 if (colNo < 0 || colNo >= pModel->
columnCount()) {
3581 qWarning(
"KLFLibDefaultView::showBy(%d,%s): column number %d is not valid or hidden!",
3582 propIdColumn, (sortorder == Qt::AscendingOrder)?
"[Ascending]":
"[Descending]", colNo);
3605 func_selectAll(parent, selectAllFlags, &tm, &pleaseWait);
3607 if (selectAllFlags & NoSignals)
3615 bool KLFLibDefaultView::func_selectAll(
const QModelIndex& parent, uint selectAllFlags,
QTime *tm,
3628 qApp->processEvents();
3642 QTreeView *treeView = pView->inherits(
"QTreeView") ? qobject_cast<
QTreeView*>(pView) : NULL;
3643 if (treeView != NULL)
3644 treeView->
expand(parent);
3647 for (k = 0; k < pModel->
rowCount(parent); ++k) {
3649 if ( ! func_selectAll(child, selectAllFlags, tm, pleaseWait) )
3652 qApp->processEvents();
3687 int curPreviewSizePercent
3690 curPreviewSizePercent = (int)(curPreviewSizePercent/5 +0.5)*5;
3693 klfDbg(
"There are "<<alist.
size()<<
" actions...") ;
3696 int a_sz = (int)(a->
data().toInt()/5 +0.5)*5;
3697 klfDbg(
"Processing action "<< a->text() <<
" (data="<<a->
data().toInt()<<
" ~= "<<a_sz
3698 <<
") curPreviewSizePercent="<<curPreviewSizePercent) ;
3700 if ( a_sz == curPreviewSizePercent )
3701 a->setChecked(
true);
3703 a->setChecked(
false);
3710 if (pViewType !=
IconView || !pView->inherits(
"KLFLibDefListView")) {
3722 KLF_ASSERT_NOT_NULL( lv,
"KLFLibDefListView List View is NULL in view type "<<pViewType<<
" !!",
3733 pView->viewport()->
update();
3768 void KLFLibDefaultView::searchFound(
const QModelIndex& i)
3777 pView->
scrollTo(i, QAbstractItemView::EnsureVisible);
3781 qobject_cast<
QTreeView*>(pView)->expand(i);
3785 QItemSelectionModel::ClearAndSelect|
3786 QItemSelectionModel::Rows);
3814 QModelIndexList indexes = rng.
indexes();
3909 if ( ! pView->inherits(
"QTreeView") )
3911 int colNo = a->
property(
"klfModelColumn").toInt();
3912 qobject_cast<
QTreeView*>(pView)->setColumnHidden(colNo, !showCol);
3918 QModelIndexList KLFLibDefaultView::selectedEntryIndexes()
const
3922 QModelIndexList selection = pView->
selectionModel()->selectedIndexes();
3923 QModelIndexList entryindexes;
3927 for (k = 0; k < selection.size(); ++k) {
3929 int iPos = qLowerBound(doneEntryIds.
begin(), doneEntryIds.
end(), eid) - doneEntryIds.
begin();
3930 if ( iPos < doneEntryIds.
size() && doneEntryIds[iPos] == eid )
3932 doneEntryIds.
insert(iPos, eid);
3933 entryindexes << selection[k];
3935 return entryindexes;
3953 if (viewTypeIdent ==
"default")
3954 return tr(
"Category Tree View");
3955 if (viewTypeIdent ==
"default+list")
3956 return tr(
"List View");
3957 if (viewTypeIdent ==
"default+icons")
3958 return tr(
"Icon View");
3969 if (viewTypeIdent ==
"default")
3971 else if (viewTypeIdent ==
"default+list")
3973 else if (viewTypeIdent ==
"default+icons")
3989 pUi =
new Ui::KLFLibOpenResourceDlg;
3991 setWindowIcon(
QPixmap(
":/pics/klatexformula-64.png"));
3995 if (!defaultlocation.
isEmpty())
3998 if (efactory == NULL) {
3999 if (!defaultlocation.
isEmpty())
4000 qWarning()<<
"No Factory for URL "<<defaultlocation<<
"'s scheme!";
4008 for (k = 0; k < wtypeList.size(); ++k) {
4009 qDebug(
"KLFLibOpenRes.Dlg::[constr.]() Adding widget for wtype %s", qPrintable(wtypeList[k]));
4011 QUrl thisdefaultlocation;
4012 if (wtypeList[k] == defaultwtype)
4013 thisdefaultlocation = defaultlocation;
4015 thisdefaultlocation);
4016 pUi->stkOpenWidgets->insertWidget(k, openWidget);
4024 pUi->cbxType->setCurrentIndex(0);
4025 pUi->stkOpenWidgets->setCurrentIndex(0);
4027 pUi->cbxType->setCurrentIndex(k = wtypeList.
indexOf(defaultwtype));
4028 pUi->stkOpenWidgets->setCurrentIndex(k);
4031 btnGo = pUi->btnBar->button(QDialogButtonBox::Open);
4044 int k = pUi->cbxType->currentIndex();
4045 QString wtype = pUi->cbxType->itemData(k).toString();
4058 if (pUi->chkReadOnly->isChecked())
4060 if (pUi->cbxSubResource->count())
4062 pUi->cbxSubResource->itemData(pUi->cbxSubResource->currentIndex()).toString());
4063 klfDbg(
"Got URL: "<<url ) ;
4071 w->
setProperty(
"__klflibopenresourcedlg_readyToOpen", isready);
4076 QWidget *w = pUi->stkOpenWidgets->currentWidget();
4079 bool w_is_ready = w->property(
"readyToOpen").toBool();
4083 QVariant v = w->property(
"__klflibopenresourcedlg_readyToOpen");
4087 btnGo->setEnabled(w_is_ready);
4089 pUi->frmSubResource->show();
4090 pUi->cbxSubResource->clear();
4092 pUi->frmSubResource->hide();
4097 pUi->frmSubResource->hide();
4101 QString subrestitle = it.value();
4103 subrestitle = subres;
4104 pUi->cbxSubResource->addItem(subrestitle,
QVariant(subres));
4115 if (result != QDialog::Accepted)
4131 pUi =
new Ui::KLFLibOpenResourceDlg;
4133 setWindowIcon(
QPixmap(
":/pics/klatexformula-64.png"));
4135 pUi->lblMain->setText(tr(
"Create New Library Resource",
"[[dialog label title]]"));
4136 setWindowTitle(tr(
"Create New Library Resource",
"[[dialog window title]]"));
4137 pUi->chkReadOnly->hide();
4139 pUi->cbxSubResource->setEnabled(
true);
4140 pUi->cbxSubResource->setEditable(
true);
4141 pUi->cbxSubResource->setEditText(tr(
"SubResource1"));
4143 pUi->btnBar->setStandardButtons(QDialogButtonBox::Save|QDialogButtonBox::Cancel);
4144 btnGo = pUi->btnBar->button(QDialogButtonBox::Save);
4146 int defaultIndex = 0;
4150 for (k = 0; k < wtypeList.size(); ++k) {
4156 pUi->stkOpenWidgets->insertWidget(k, createResWidget);
4160 if (wtypeList[k] == defaultWtype)
4163 connect(createResWidget, SIGNAL(readyToCreate(
bool)),
4165 klfDbg(
"Added create-res-widget of type "<<wtypeList[k]) ;
4168 pUi->cbxType->setCurrentIndex(defaultIndex);
4169 pUi->stkOpenWidgets->setCurrentIndex(defaultIndex);
4183 int k = pUi->cbxType->currentIndex();
4184 QString wtype = pUi->cbxType->itemData(k).toString();
4188 p[
"klfWidgetType"] = wtype;
4189 p[
"klfDefaultSubResource"] = pUi->cbxSubResource->currentText();
4190 p[
"klfDefaultSubResourceTitle"] = pUi->cbxSubResource->currentText();
4192 klfDbg(
"Create parameters are: "<<p) ;
4201 if (p ==
Parameters() || p[
"klfCancel"].toBool() ==
true) {
4205 if (p[
"klfRetry"].toBool() ==
true)
4222 w->
setProperty(
"__klflibcreateresourcedlg_readyToCreate", isready);
4227 QWidget *w = pUi->stkOpenWidgets->currentWidget();
4228 if (w == NULL)
return;
4229 QVariant v = w->property(
"__klflibcreateresourcedlg_readyToCreate");
4241 if (result != QDialog::Accepted)
4245 QString scheme = p[
"klfScheme"].toString();
4248 qWarning()<<
"KLFLibCr.Res.Dlg::createRes.(): Widget Type "<<p[
"klfWidgetType"]
4249 <<
" failed to announce what scheme it wanted in p[\"klfScheme\"]!";
4255 qPrintable(
QString(
"Couldn't find factory for scheme %1 ?!?").arg(scheme)),
4270 U =
new Ui::KLFLibResPropEditor;
4272 setWindowIcon(
QPixmap(
":/pics/klatexformula-64.png"));
4274 QPalette pal = U->txtUrl->palette();
4276 pal.
setColor(QPalette::Background, pal.
color(QPalette::Window));
4277 U->txtUrl->setPalette(pal);
4280 qWarning(
"KLFLibResPropEditor: NULL Resource! Expect CRASH!");
4289 connect(pResource, SIGNAL(resourcePropertyChanged(
int)),
4291 connect(pResource, SIGNAL(subResourcePropertyChanged(
const QString&,
int)),
4297 U->tblProperties->setModel(pPropModel);
4306 U->tblSubResProperties->setModel(pSubResPropModel);
4307 U->tblSubResProperties->setItemDelegate(
new QItemDelegate(
this));
4309 connect(pSubResPropModel, SIGNAL(itemChanged(
QStandardItem *)),
4312 U->frmAdvanced->setShown(U->btnAdvanced->isChecked());
4321 connect(U->btnApply, SIGNAL(clicked()),
this, SLOT(
apply()));
4337 bool srislocked =
false;
4338 if (pSuppSubRes && pSuppSubResProps)
4342 bool lockmodified = (pResource->
locked() != U->chkLocked->isChecked());
4343 bool srlockmodified =
false;
4344 if (pSuppSubRes && pSuppSubResProps && srislocked != U->chkSubResLocked->isChecked()) {
4345 srlockmodified =
true;
4347 bool wantunlock = lockmodified && !U->chkLocked->isChecked();
4348 bool srwantunlock = srlockmodified && !U->chkSubResLocked->isChecked();
4349 bool wantlock = lockmodified && !wantunlock;
4350 bool srwantlock = srlockmodified && !srwantunlock;
4351 bool titlemodified = (pResource->
title() != U->txtTitle->text());
4352 bool subrestitlemodified =
false;
4353 if (pSuppSubRes && pSuppSubResProps &&
4355 != U->txtSubResTitle->text()) {
4356 subrestitlemodified =
true;
4359 klfDbg(
": lockmodif="<<lockmodified<<
"; srlockmodified="<<srlockmodified
4360 <<
"; wantunlock="<<wantunlock<<
"; srwantunlock="<<srwantunlock<<
"; wantlock="<<wantlock
4361 <<
"; srwantlock="<<srwantlock<<
"; titlemodif="<<titlemodified
4362 <<
"; srtitlemodif="<<subrestitlemodified ) ;
4364 if ( (pResource->
locked() && !lockmodified) ||
4365 (srislocked && !srlockmodified) ) {
4367 if (titlemodified || subrestitlemodified) {
4385 .arg(curSubResource()));
4389 QString newTitle = U->txtTitle->text();
4390 QString newSubResTitle = U->txtSubResTitle->text();
4392 if ( titlemodified && ! pResource->
setTitle(newTitle) ) {
4397 if ( subrestitlemodified &&
4403 .arg(curSubResource()));
4417 .arg(curSubResource()));
4427 U->frmAdvanced->setShown(on);
4428 if (U->frmAdvanced->isVisible()) {
4430 int w = width() / 3;
4431 U->tblProperties->setColumnWidth(0, w);
4432 U->tblProperties->setColumnWidth(1, w);
4433 U->tblSubResProperties->setColumnWidth(0, w);
4434 U->tblSubResProperties->setColumnWidth(1, w);
4447 klfDbg(
"KLFLibResPropEditor::updateSubResources("<<curSubRes<<
")" ) ;
4448 if ( pSuppSubRes ) {
4449 U->cbxSubResource->blockSignals(
true);
4450 U->cbxSubResource->clear();
4453 int curSubResIndex = 0;
4454 for (k = 0; k < subResList.size(); ++k) {
4459 title =
QString(
"%1 (%2)").arg(thissrtitle, subResList[k]);
4461 title = subResList[k];
4462 U->cbxSubResource->addItem(title, subResList[k]);
4463 if (subResList[k] == curSubRes)
4466 klfDbg(
"KLFLibResPropEditor::updateSubResources("<<curSubRes<<
") : setting cur index="<<curSubResIndex ) ;
4467 U->cbxSubResource->setCurrentIndex(curSubResIndex);
4468 U->cbxSubResource->blockSignals(
false);
4469 if ( pSuppSubResProps ) {
4470 U->wSubResProps->show();
4471 U->txtSubResTitle->setEnabled(
true);
4472 U->chkSubResLocked->setEnabled(
true);
4474 U->txtSubResTitle->setEnabled(pResource
4475 ->canModifySubResourceProperty(curSubResource(),
4480 U->chkSubResLocked->setEnabled(pResource
4481 ->canModifySubResourceProperty(curSubResource(),
4487 U->wSubResProps->hide();
4488 U->chkSubResLocked->setEnabled(
false);
4489 U->txtSubResTitle->setText(
"");
4490 U->txtSubResTitle->setEnabled(
false);
4493 U->cbxSubResource->clear();
4494 U->cbxSubResource->setEnabled(
false);
4495 U->wSubResProps->hide();
4496 U->chkSubResLocked->setEnabled(
false);
4497 U->txtSubResTitle->setText(
"");
4498 U->txtSubResTitle->setEnabled(
false);
4504 klfDbg(
"advPropEdited("<<item<<
")" ) ;
4506 int propId = item->
data(Qt::UserRole).toInt();
4510 tr(
"Failed to set resource property \"%1\".")
4527 QPalette pal = U->tblSubResProperties->palette();
4528 for (k = 0; k < props.size(); ++k) {
4537 QPalette::ColorGroup cg = editable ? QPalette::Active : QPalette::Disabled;
4540 i2->
setData(val, Qt::EditRole);
4541 i2->
setData(propId, Qt::UserRole);
4545 U->txtTitle->setText(pResource->
title());
4550 U->txtUrl->setText(surl);
4551 U->chkLocked->setChecked(pResource->
locked());
4555 QString KLFLibResPropEditor::curSubResource()
const
4557 return U->cbxSubResource->itemData(U->cbxSubResource->currentIndex()).toString();
4562 klfDbg(
"item="<<item<<
"" ) ;
4564 int propId = item->
data(Qt::UserRole).toInt();
4568 tr(
"Failed to set sub-resource \"%1\"'s property \"%2\".")
4569 .arg(curSubResource(), propId));
4586 if (subResource != curSubResource())
4589 if (subResPropId != -2) {
4597 if ( ! pSuppSubResProps )
4607 QPalette pal = U->tblSubResProperties->palette();
4610 for (k = 0; k < props.
size(); ++k) {
4611 int propId = props[k];
4618 QPalette::ColorGroup cg = editable ? QPalette::Active : QPalette::Disabled;
4621 i2->
setData(val, Qt::EditRole);
4622 i2->
setData(propId, Qt::UserRole);
4640 lyt->addWidget(pEditor);
4643 Qt::Horizontal,
this);
4644 lyt->addWidget(btns);
4646 connect(btns->
button(QDialogButtonBox::Ok), SIGNAL(clicked()),
4650 connect(btns->
button(QDialogButtonBox::Cancel), SIGNAL(clicked()),
4654 setWindowTitle(pEditor->windowTitle());
4655 setAttribute(Qt::WA_DeleteOnClose,
true);
4664 if (pEditor->
apply()) {
4678 :
QDialog(parent), isAutoName(true)
4680 u =
new Ui::KLFLibNewSubResDlg;
4682 setWindowIcon(
QPixmap(
":/pics/klatexformula-64.png"));
4684 u->lblNoTitle->hide();
4688 u->lblName->setEnabled(
false);
4689 u->txtName->setEnabled(
false);
4690 u->lblTitle->setEnabled(
false);
4691 u->txtTitle->setEnabled(
false);
4692 u->btns->button(QDialogButtonBox::Ok)->setEnabled(
false);
4694 u->lblTitle->setEnabled(
false);
4695 u->txtTitle->setEnabled(
false);
4696 u->lblNoTitle->show();
4699 u->lblResource->setText(resource->
title());
4708 return u->txtName->text();
4713 return u->txtTitle->text();
4721 QRegExp rx(
"(?:\\s|-)([a-z])");
4723 while ((i = rx.
indexIn(nm,i+1)) >= 0) {
4732 void KLFLibNewSubResDlg::on_txtTitle_textChanged(
const QString& text)
4735 u->txtName->blockSignals(
true);
4737 u->txtName->blockSignals(
false);
4741 void KLFLibNewSubResDlg::on_txtName_textChanged(
const QString& text)
4752 qWarning(
"KLFLibNewSubResDlg::createSubResourceIn: can't create sub-resource in resource not "
4753 "supporting sub-resources (!) : %s", qPrintable(resource->
url().
toString()));
4758 if (r != QDialog::Accepted)
4801 return tr(
"Local File");
4808 QUrl defaultlocation)
4812 w->
setUrl(defaultlocation);
4820 if (wtype ==
"LocalFile") {
4821 if (widget == NULL || !widget->inherits(
"KLFLibLocalFileOpenWidget")) {
4822 qWarning(
"KLFLibBasicWidgetFactory::retrieveUrlFromWidget(): Bad Widget provided!");
4827 qWarning()<<
"KLFLibB.W.Factory::retrieveUrlFromWidget(): Bad widget type: "<<wtype;
4839 w->
setUrl(defaultparameters[
"Url"].toUrl());
4850 if (widget == NULL || !widget->inherits(
"KLFLibLocalFileCreateWidget")) {
4851 qWarning(
"KLFLibBasicWidgetFactory::retrieveUrlFromWidget(): Bad Widget provided!");
4858 QMessageBox::StandardButton result =
4860 tr(
"The specified file already exists. Overwrite it?"),
4861 QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel,
4863 if (result == QMessageBox::No) {
4864 p[
"klfRetry"] =
true;
4866 }
else if (result == QMessageBox::Cancel) {
4878 p[
"Filename"] = filename;
bool searchNodeMatches(const NodeId &nodeId, const QString &searchString, Qt::CaseSensitivity cs)
virtual void updateResourceEngine()
void updateSubResourceProperties()
KLFLibModel(KLFLibResourceEngine *resource, uint flavorFlags=LinearList|GroupSubCategories, QObject *parent=NULL)
virtual KLFLibResourceEngine * resource()
KLFAbstractLibView(QWidget *parent)
void doReportProgress(int value)
virtual void setDefaultSubResource(const QString &subResource)
Set the default sub-resource.
void setGroupSubCategories(bool yesOrNo)
setFontItalic(bool italic)
void slotSubResourcePropertyChanged(const QString &subResource, int propId)
virtual void setTheTreeView(QTreeView *theTreeView)
drawContents(QPainter *p, const QRectF &rect=QRectF()
virtual QStringList categoryList() const
const QStyleOptionViewItem * option
rowCount(const QModelIndex &parent=QModelIndex()
virtual bool canModifySubResourceProperty(const QString &subResource, int propId) const
setPointSize(int pointSize)
static QUrl queryOpenResource(const QUrl &defaultlocation=QUrl(), QWidget *parent=0)
virtual void sort(int column, Qt::SortOrder order=Qt::AscendingOrder)
change the entrySorter accordingly and re-sort the model.
data(const QString &mimeType)
virtual bool event(QEvent *e)
Model for Item-Views displaying a library resource's contents.
index(int row, int column, const QModelIndex &parent=QModelIndex()
virtual void updateResourceEngine()=0
virtual QImage dragImage(const QModelIndexList &indexes)
bool allChildrenFetched
TRUE if all the children of this node have been fetched and stored into children, FALSE if possibly t...
static float color_distinguishable_distance(QRgb a, QRgb b, bool aPremultiplied=false)
static QStringList allSupportedViewTypeIdentifiers()
static int entryItemRole(int propertyId)
fillRect(const QRectF &rectangle, const QBrush &brush)
setCompositionMode(CompositionMode mode)
virtual bool createSubResource(const QString &subResource, const QString &subResourceTitle)
Create a new sub-resource.
virtual QVariant subResourceProperty(const QString &subResource, int propId) const
void requestRestore(const KLFLibEntry &entry, uint restoreflags=KLFLib::RestoreLatexAndStyle)
virtual void redoSort()
notify the model that the entrySorter() settings were changed, and we need to re-sort.
A structure that describes a query for query()
QList< KLFLib::entryId > entryIdList(const QModelIndexList &indexlist)
setColor(ColorGroup group, ColorRole role, const QColor &color)
A cached value of the size of value in Preview.
virtual void setOrder(Qt::SortOrder order)
Set the sort order.
virtual uint compareUrlTo(const QUrl &other, uint interestFlags=0xfffffff) const =0
Compare this resource's URL with another's.
int treePreviewSizePercent
friend class KLFLibModelCache
#define klfDbgT(streamableItems)
Sub-Resources may be assigned properties and values.
void setIconViewFlow(QListView::Flow flow)
Sets the icon view flow, see QListView::Flow.
virtual void slotRefresh()
virtual bool func_indexHasSelectedDescendant(const QModelIndex &parent, const QTime &timer, int timeLimitMs) const
setBackground(const QBrush &brush)
qint32 entryId
An entry ID.
virtual QModelIndex searchFindNext(bool forward)
KLFLibNewSubResDlg(KLFLibResourceEngine *resource, QWidget *parent=0)
split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive)
void dumpNodeTree(NodeId node, int indent=0)
#define KLF_DEBUG_TEE(expr)
virtual bool locked() const
Is this resource is locked?
QString fullCategoryPath
The full category path of this category eg. "Physics/General Relativity".
virtual QModelIndexList findEntryIdList(const QList< KLFLib::entryId > &eidlist) const
setModel(QAbstractItemModel *model)
virtual void slotRelayoutIcons()
QString categoryLabel
The last element in fullCategoryPath eg. "General Relativity".
void ensureNotMinimalist(NodeId nodeId, int count=-1)
virtual QList< KLFLibEntryWithId > entries(const QString &subResource, const QList< KLFLib::entryId > &idList, const QList< int > &wantedEntryProperties=QList< int >())=0
query multiple entries in this resource
color(ColorGroup group, ColorRole role)
virtual bool searchFind(const QString &queryString, bool forward=true)
virtual uint dropFlags(QDragMoveEvent *event, QAbstractItemView *view)
IndexType cacheFindCategoryLabel(QStringList catelements, bool createIfNotExists=false, bool notifyQtApi=false, bool newlyCreatedAreChildrenFetched=true)
KLFLibViewFactory(const QStringList &viewTypeIdentifiers, QObject *parent=NULL)
contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive)
changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to)
void resourceDataChanged(const QList< KLFLib::entryId > &entryIdList)
static int entryPropIdForItemRole(int role)
void ensureExpandedTo(const QModelIndexList &mil)
indexAt(const QPoint &point)
virtual bool setSubResourceProperty(const QString &subResource, int propId, const QVariant &value)
#define klfDbg(streamableItems)
#define KLF_DEBUG_BLOCK(msg)
Qt::SortOrder orderDirection
int listPreviewSizePercent
setHorizontalHeaderLabels(const QStringList &labels)
virtual QVariant resourceProperty(const QString &name) const
Get the value of a resource property.
void updateResourceProperties()
virtual QList< int > subResourcePropertyIdList() const
scale(int width, int height, Qt::AspectRatioMode mode)
virtual KLFLibEntry entry(const QString &subResource, entryId id)=0
query an entry in this resource
int getNodeRow(NodeId nodeid)
static bool canDecodeMimeData(const QMimeData *mimeData)
pixel(const QPoint &position)
virtual void setSelectionModel(QItemSelectionModel *sm)
CategoryLabelNode & getCategoryLabelNodeRef(NodeId nodeid)
virtual bool setTitle(const QString &title)
set a new resource title for this library resource
join(const QString &separator)
_klf_block_progress_blocker(KLFLibResourceEngine *r)
hasQueryItem(const QString &key)
sortByColumn(int column, Qt::SortOrder order)
void slotEntryDoubleClicked(const QModelIndex &index)
drawLine(const QLineF &line)
copy(const QRect &rectangle=QRect()
virtual void updateResourceOwnData(const QList< KLFLib::entryId > &entryIdList)
virtual KLFAbstractLibView * createLibView(const QString &viewTypeIdent, QWidget *parent, KLFLibResourceEngine *resourceEngine)
virtual void updateReadyToOpenFromSender(bool isready)
QList< KLFLib::entryId > entryIdForIndexList(const QModelIndexList &indexlist)
virtual QList< KLFLib::entryId > entryIdForIndexList(const QModelIndexList &indexlist) const
toString(FormattingOptions options=None)
bool canFetchMore(NodeId parentId)
tr(const char *sourceText, const char *comment=0, int n=-1)
static QImage autocrop_image(const QImage &img, int alpha_threshold=0)
virtual uint flavorFlags() const
virtual QList< QVariant > queryValues(const QString &subResource, int entryPropId)=0
List all distinct values that a property takes in all entries.
QString newSubResourceTitle() const
virtual QVariantMap saveGuiState() const
virtual void updateReadyToCreate()
static QImage transparentify_image(const QImage &img, qreal factor)
isColumnHidden(int column)
QList< KLFLibEntryWithId > entryWithIdList
virtual void updateData(const QList< KLFLib::entryId > &entryIdList, int modifyType)
QListView::Flow iconViewFlow() const
static QStringList allEncodingMimeTypes()
virtual Parameters getCreateParameters() const
__klf_guarded_bool(bool *var)
#define KLF_ASSERT_NOT_NULL(ptr, msg, failaction)
virtual int entryColumnContentsPropertyId(int column) const
setData(const QVariant &value, int role=Qt::UserRole+1)
static KLFLibViewFactory * findFactoryFor(const QString &viewTypeIdentifier)
replace(int position, int n, const QString &after)
The Latex Code of the equation.
static QList< int > minimalistEntryPropIds()
void fetchMore(NodeId parentId, int batchCount=-1)
virtual KLFLibEntryList selectedEntries() const
indexOf(const T &value, int from=0)
virtual ~KLFLibNewSubResDlg()
QString nodeValue(NodeId node, int propId=KLFLibEntry::Latex)
indexIn(const QString &str, int offset=0, CaretMode caretMode=CaretAtZero)
void sortCategory(NodeId category, KLFLibModelSorter *sorter, bool rootCall=true)
virtual QList< KLFLib::entryId > selectedEntryIds() const
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
setFont(const QFont &font)
KLFLibEngineFactory::Parameters Parameters
virtual bool compareDefaultSubResourceEquals(const QString &subResourceName) const
Compare our sub-resource name to another.
virtual QStringList viewTypeIdentifiers()
setColumnWidth(int column, int width)
setColumnCount(int columns)
virtual void expandRootNice()
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual ~KLFLibCreateResourceDlg()
virtual void showEvent(QShowEvent *event)
void unlinkNode(const NodeId &nid)
virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const
drawPoint(const QPointF &position)
virtual void updateResourceDefaultSubResourceChanged(const QString &newSubResource)
QModelIndex createIndexFromId(NodeId nodeid, int row, int column)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
static KLFLibResourceEngine * createResource(const QString &defaultWtype, QObject *resourceParent, QWidget *parent=0)
property(const char *name)
virtual void setFetchBatchCount(int count)
virtual bool selectionIntersectsIndexChildren(const QItemSelection &selection, const QModelIndex &parent) const
virtual void restore(uint restoreflags=KLFLib::RestoreLatexAndStyle)
virtual ~KLFLibResPropEditorDlg()
virtual QString viewTypeTitle(const QString &viewTypeIdent) const
brush(ColorGroup group, ColorRole role)
virtual ~KLFLibResPropEditor()
virtual ~KLFLibViewFactory()
update(const QModelIndex &index)
dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
resizeColumnToContents(int column)
virtual int query(const QString &subResource, const Query &query, QueryResult *result)=0
query entries in this resource with specified property values
NodeId nextNode(NodeId n)
NodeId prevNode(NodeId n)
EntryNode & getEntryNodeRef(NodeId nodeid, bool requireNotMinimalist=false)
virtual QUrl retrieveRawUrl() const
virtual bool setLocked(bool locked)
Set the resource to be locked.
Qt::SortOrder order() const
The currently set sorting order.
void setSortingBy(int propId, Qt::SortOrder order)
EntryNode pInvalidEntryNode
virtual bool isDesendantOf(const QModelIndex &child, const QModelIndex &ancestor)
KLFFactoryBase * findFactoryFor(const QString &objType)
insertText(const QString &text)
virtual void paintEntry(PaintPrivate *p, const QModelIndex &index) const
Data can be stored in separate sub-resources.
removeAll(const T &value)
QModelIndex curVisibleIndex(bool firstOrLast) const
beginRemoveRows(const QModelIndex &parent, int first, int last)
setItemDelegate(QAbstractItemDelegate *delegate)
NodeId getNodeForIndex(const QModelIndex &index)
int propId() const
The currently set property that will be queried in the items we're sorting.
virtual QStringList mimeTypes() const
void slotViewItemClicked(const QModelIndex &index)
virtual void paintCategoryLabel(PaintPrivate *p, const QModelIndex &index) const
bool isAllocated(IndexType i)
virtual int columnForEntryPropertyId(int entryPropertyId) const
void treeInsertEntry(const EntryNode &e, bool isRebuildingCache=false)
virtual void wantMoreCategorySuggestions()
virtual void updateResourceProp(int propId)
virtual void updateResourceProp(int propId)=0
drawText(const QPointF &position, const QString &text)
endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive)
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
int propertyIdForName(const QString &propertyName) const
virtual bool setResourceProperty(int propId, const QVariant &value)
Set a resource property to the given value.
static EntryMatchCondition mkPropertyMatch(PropertyMatch pmatch)
A view widget to display a library resource's contents.
KLFLibCreateResourceDlg(const QString &defaultWtype, QWidget *parent=0)
virtual KLFLibResourceEngine * createResource(const QString &scheme, const Parameters ¶meters, QObject *parent=NULL)
Create a new resource of given type and parameters.
~_klf_block_progress_blocker()
KLFLibDefaultView(QWidget *parent, ViewType viewtype=CategoryTreeView)
The Category to which eq. belongs (path-style string)
virtual void setFlavorFlags(uint flags, uint modify_mask=0xffffffff)
void entriesSelected(const KLFLibEntryList &entries)
virtual void updateReadyToOpen()
UIDType universalId() const
void operationStartReportingProgress(KLFProgressReporter *progressReporter, const QString &descriptiveText)
virtual QString entryValue(const KLFLibEntry &entry, int propId) const
Returns a string representation of the given property in the given entry.
isExpanded(const QModelIndex &index)
static bool image_is_distinguishable(const QImage &imgsrc, QColor background, float threshold)
void on_cbxSubResource_currentIndexChanged(int newSubResItemIndex)
virtual ~KLFLibLocalFileSchemeGuesser()
static QString makeSubResInternalName(const QString &title)
virtual bool hasIndex(int row, int column, const QModelIndex &parent=QModelIndex()) const
virtual QString defaultSubResource() const
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Add a query item for default sub-res. as "klfDefaultSubResource".
#define KLF_DEBUG_TIME_BLOCK(msg)
virtual void updateResourceData(const QString &subres, int modifyType, const QList< KLFLib::entryId > &entryIdList)=0
QSize previewSize() const
KLFLibDefaultViewFactory(QObject *parent=NULL)
virtual void setResource(KLFLibResourceEngine *resource)
virtual void prefetch(const QModelIndexList &index) const
createIndex(int row, int column, void *ptr=0)
void slotResourceModelReset()
Dialog prompting user to choose a resource and a sub-resource to open.
virtual bool eventFilter(QObject *o, QEvent *e)
void advSubResPropEdited(QStandardItem *item)
setData(const QVariant &userData)
void setPreviewSize(const QSize &size)
virtual uint supportedFeatureFlags() const
List of features supported by this resource engine.
virtual bool canModifyData(const QString &subResource, ModifyType modifytype) const
setColumnHidden(int column, bool hide)
contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive)
virtual QList< entryId > insertEntries(const QString &subResource, const KLFLibEntryList &entrylist)=0
Insert new entries in this resource.
virtual QStringList subResourceList() const
virtual ~KLFLibOpenResourceDlg()
virtual void fetchMore(const QModelIndex &parent)
Tags about the equation (string)
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
virtual void setEntrySorter(KLFLibEntrySorter *entrySorter)
virtual void searchAbort()
void setPreviewSize(const QSize &psize)
virtual QModelIndex currentVisibleIndex() const
The first index that is currently visible in the current scrolling position.
QPointF sizeToPointF(const QSizeF &s)
virtual void searchAbort()
virtual void setResourceEngine(KLFLibResourceEngine *resource)
virtual QModelIndex parent(const QModelIndex &index) const
fromValue(const T &value)
virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
virtual QString title() const
The human-set title of this resource.
virtual void setSearchString(const QString &s)
QStringList registeredPropertyNameList() const
beginInsertRows(const QModelIndex &parent, int first, int last)
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
virtual bool canFetchMore(const QModelIndex &parent) const
static bool decodeMimeData(const QMimeData *mimeData, KLFLibEntryList *entryList, QVariantMap *metaData)
void blockProgressReporting(bool block)
(Un)Blocks generally progress reporting
setFontWeight(int weight)
static QString createSubResourceIn(KLFLibResourceEngine *resource, QWidget *parent=0)
Interface for guessing file schemes.
virtual QString correspondingWidgetType(const QString &scheme) const =0
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
A structure that will hold the result of a query() query.
QModelIndexList findEntryIdList(const QList< KLFLib::entryId > &eidlist)
setForeground(const QBrush &brush)
setPixel(const QPoint &position, uint index_or_rgb)
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
NodeId lastNode(NodeId n)
virtual void updateReadyToCreateFromSender(bool isready)
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const
void updateSubResources(const QString &curSubResource=QString())
void slotResourceDataChanged(const QModelIndex &topLeft, const QModelIndex &botRight)
QString newSubResourceName() const
void slotShowColumnSenderAction(bool showCol)
virtual bool selectEntries(const QList< KLFLib::entryId > &idList)
drawImage(const QRectF &target, const QImage &image, const QRectF &source, Qt::ImageConversionFlags flags=Qt::AutoColor)
virtual QStringList getCategorySuggestions()=0
virtual KLFLibEntrySorter * entrySorter()
The current KLFLibEntrySorter that sorts our items.
static QStringList defaultViewTypeIds
setClipRect(const QRectF &rectangle, Qt::ClipOperation operation=Qt::ReplaceClip)
mid(int position, int n=-1)
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
data(int role=Qt::DisplayRole)
bool operator()(const NodeId &a, const NodeId &b)
virtual ~KLFLibDefaultView()
QStringList categoryListCache()
An entry (single formula) in the library.
Node & getNodeRef(NodeId nodeid)
scaled(const QSize &size, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio, Qt::TransformationMode transformMode=Qt::FastTransformation)
void slotResourcePropertyChanged(int propId)
QList< int > wantedEntryProperties
virtual void setSearchIndex(const QModelIndex &index)
insert(int i, const T &value)
hasChildren(const QModelIndex &parent=QModelIndex()
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
virtual Qt::DropActions supportedDropActions() const
virtual KLFLib::entryId entryIdForIndex(const QModelIndex &index) const
static KLFLibEngineFactory * findFactoryFor(const QUrl &url)
KLFLibViewDelegate(QObject *parent)
void slotPreviewSizeActionsRefreshChecked()
virtual KLFLibResourceEngine * resourceEngine() const
QStringList allSupportedTypes()
columnCount(const QModelIndex &parent=QModelIndex()
int iconPreviewSizePercent
KLFLibOpenResourceDlg(const QUrl &defaultlocation=QUrl(), QWidget *parent=0)
An Image Preview of equation (scaled down QImage)
void on_btnAdvanced_toggled(bool on)
virtual bool changeEntries(const QString &subResource, const QList< entryId > &idlist, const QList< int > &properties, const QList< QVariant > &values)=0
Change some entries in this resource.
critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
mid(int pos, int length=-1)
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
static QMap< QString, QString > listSubResourcesWithTitles(const QUrl &url)
KLFLibLocalFileSchemeGuesser()
KLFLibResPropEditorDlg(KLFLibResourceEngine *resource, QWidget *parent=0)
translate(const QPointF &offset)
drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=0)
void slotPreviewSizeFromActionSender()
virtual void showColumns(int propIdColumn, bool show)
KLF_EXPORT void klfDrawGlowedImage(QPainter *p, const QImage &foreground, const QColor &glowcol, int r, bool also_draw_image)
Node getNode(NodeId nodeid)
virtual void updateResourceData(const QString &subRes, int modifyType, const QList< KLFLib::entryId > &entryIdList)
virtual void completeRefresh()
void moreCategorySuggestions(const QStringList &categorylist)
addQueryItem(const QString &key, const QString &value)
warning(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
indexOf(const QRegExp &rx, int from=0)
KLFLibEntrySorter * entrySorter()
virtual void paintText(PaintPrivate *p, const QString &text, uint flags=PTF_HighlightSearch) const
A KLFLibEntry in combination with a KLFLib::entryId.
setProperty(const char *name, const QVariant &value)
QSizeF pointToSizeF(const QPointF &p)
size(int flags, const QString &text, int tabStops=0, int *tabArray=0)
static QString defaultViewTypeIdentifier()
KLF_EXPORT QDebug & operator<<(QDebug &dbg, const KLFLibModelCache::NodeId &n)
virtual QModelIndex searchFind(const QString &queryString, const QModelIndex &fromIndex=QModelIndex(), bool forward=true)
virtual QStringList getCategorySuggestions()
setData(const QString &mimeType, const QByteArray &data)
Utility class for sorting library entry items.
virtual QUrl url(uint flags=0x0) const
query URL
void operationStartReportingProgress(KLFProgressReporter *progressReporter, const QString &descriptiveText)
QSize labelOutputFixedSize
virtual bool searchFindNext(bool forward)
expand(const QModelIndex &index)
QDateTime dateTime() const
An abstract resource engine.
virtual void slotSelectAll(bool expandItems=false)
virtual QModelIndex walkNextIndex(const QModelIndex &cur)
Call repeatedly to walk all indexes (once each exactly, first column only)
virtual QList< QAction * > addContextMenuActions(const QPoint &pos)
QString propertyNameForId(int propId) const
The Date/Time at which the equation was evaluated.
struct KLFConfig::@4 LibraryBrowser
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
static NodeId fromUID(UIDType uid)
virtual ~KLFLibViewDelegate()
virtual bool indexHasSelectedDescendant(const QModelIndex &parent) const
void slotViewSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
static QMimeData * createMimeData(const KLFLibEntryList &entryList, const QVariantMap &metaData)
Creates a QMetaData with all known registered encoding mime types.
KLFLib::EntryMatchCondition matchCondition
toHtml(const QByteArray &encoding=QByteArray()
void updateData(const QList< KLFLib::entryId > &entryIdList, int modifyType)
virtual uint compareUrlTo(const QUrl &other, uint interestFlags=0xFFFFFFFF) const
void advPropEdited(QStandardItem *item)
#define KLF_DEBUG_ASSIGN_SAME_REF_INSTANCE(object)
IndexType insertNewNode(const N &n)
indexOf(const QString &str, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive)
virtual bool canModifyProp(int propId) const
virtual void sortBy(int propIdColumn, Qt::SortOrder sortorder)
appendRow(const QList< QStandardItem * > &items)
EntryNode treeTakeEntry(const NodeId &e, bool notifyQtApi=true)
virtual void setPropId(int propId)
Set the KLFLibEntry property id the sort will take into account.
data(int role=Qt::UserRole+1)
queryItemValue(const QString &key)
NodeId findEntryId(KLFLib::entryId eId)
setEditable(bool editable)
KLFLibResPropEditor(KLFLibResourceEngine *resource, QWidget *parent=0)
toEncoded(FormattingOptions options=None)
localeAwareCompare(const QString &s1, const QString &s2)
virtual QList< QAction * > addContextMenuActions(const QPoint &pos)
virtual QModelIndex walkPrevIndex(const QModelIndex &cur)
Call repeatedly to walk all indexes in model in reverse order.
virtual bool restoreGuiState(const QVariantMap &state)
virtual QString subResourcePropertyName(int propId) const
QSize previewSize() const
virtual QModelIndex findEntryId(KLFLib::entryId eid) const
static QString normalizeCategoryPath(const QString &categoryPath)