Main application class.
More...
Main application class.
Definition at line 253 of file TreeViewDragDrop.C.
◆ TreeViewDragDrop()
Constructor.
Definition at line 258 of file TreeViewDragDrop.C.
262 {
264
265
266
267
269 std::make_shared<WStandardItemModel>(0, 1);
271
272
274 std::make_shared<FileModel>();
276
277
278
279
280
281
282
283
284
285
291
292
293
294
296
297 }
Wt::Auth::Dbo::UserDatabase< AuthInfo > UserDatabase
std::shared_ptr< WStandardItemModel > fileModel_
The file model (used by fileView_)
std::shared_ptr< WSortFilterProxyModel > fileFilterModel_
The sort filter proxy model that adapts fileModel_.
void createUI()
Setup the user interface.
std::shared_ptr< WStandardItemModel > folderModel_
The folder model (used by folderView_)
std::unique_ptr< WMessageBox > popupActionBox_
Message box to confirm the poup menu action.
std::unique_ptr< WPopupMenu > popup_
Popup menu on the folder view.
void populateFiles()
Populate the files model.
void populateFolders()
Populate the folders model.
◆ ~TreeViewDragDrop()
virtual TreeViewDragDrop::~TreeViewDragDrop |
( |
| ) |
|
|
inlinevirtual |
◆ aboutDisplay()
std::unique_ptr< WWidget > TreeViewDragDrop::aboutDisplay |
( |
| ) |
|
|
inlineprivate |
Creates the hints text.
Definition at line 485 of file TreeViewDragDrop.C.
485 {
486 std::unique_ptr<WText>
result
487 = std::make_unique<WText>(WString::tr("about-text"));
488 result->setStyleClass(
"about");
490 }
◆ convertToDate()
void TreeViewDragDrop::convertToDate |
( |
WStandardItem * |
item | ) |
|
|
inlineprivate |
Convert a string to a date.
Definition at line 618 of file TreeViewDragDrop.C.
618 {
620 item->setData(cpp17::any(
d), ItemDataRole::Display);
621 }
static WString dateEditFormat
Date edit format.
◆ convertToNumber()
void TreeViewDragDrop::convertToNumber |
( |
WStandardItem * |
item | ) |
|
|
inlineprivate |
Convert a string to a number.
Definition at line 625 of file TreeViewDragDrop.C.
625 {
627 item->setData(cpp17::any(
i), ItemDataRole::Edit);
628 }
◆ createFolderItem()
std::unique_ptr< WStandardItem > TreeViewDragDrop::createFolderItem |
( |
const WString & |
location, |
|
|
const std::string & |
folderId = std::string() |
|
) |
| |
|
inlineprivate |
Create a folder item.
Configures flags for drag and drop support.
Definition at line 665 of file TreeViewDragDrop.C.
667 {
669 = std::make_unique<WStandardItem>(
location);
670
673 result->setFlags(
result->flags() | ItemFlag::DropEnabled);
675 } else
676 result->setFlags(
result->flags().clear(ItemFlag::Selectable));
677
678 result->setIcon(
"icons/folder.gif");
679
681 }
std::map< std::string, WString > folderNameMap_
Maps folder id's to folder descriptions.
◆ createTitle()
std::unique_ptr< WText > TreeViewDragDrop::createTitle |
( |
const WString & |
title | ) |
|
|
inlineprivate |
◆ createUI()
void TreeViewDragDrop::createUI |
( |
| ) |
|
|
inlineprivate |
Setup the user interface.
Definition at line 333 of file TreeViewDragDrop.C.
333 {
334 WContainerWidget *
w =
root();
335 w->setStyleClass(
"maindiv");
336
337
338
339
340 std::unique_ptr<WGridLayout>
layout =
341 std::make_unique<WGridLayout>();
345 layout->setColumnResizable(0);
346
347
349
350 std::unique_ptr<WVBoxLayout>
vbox =
351 std::make_unique<WVBoxLayout>();
354 vbox->setResizable(0);
355
357
359
360
361
362
363 layout->setRowStretch(1, 1);
364 layout->setColumnStretch(1, 1);
365
366 w->setLayout(std::move(
layout));
367 }
std::unique_ptr< WWidget > aboutDisplay()
Creates the hints text.
std::unique_ptr< WTreeView > folderView()
Creates the folder WTreeView.
std::unique_ptr< WText > createTitle(const WString &title)
Creates a title widget.
std::unique_ptr< WTableView > fileView()
Creates the file table view (a WTableView)
std::unique_ptr< WWidget > pieChart()
Creates the chart.
WTreeView * folderView_
The folder view.
◆ dialogDone()
void TreeViewDragDrop::dialogDone |
( |
| ) |
|
|
inlineprivate |
◆ editFile()
Edit a particular row.
Definition at line 449 of file TreeViewDragDrop.C.
449 {
451 }
WTableView * fileView_
The file view.
◆ fileView()
std::unique_ptr< WTableView > TreeViewDragDrop::fileView |
( |
| ) |
|
|
inlineprivate |
Creates the file table view (a WTableView)
Definition at line 411 of file TreeViewDragDrop.C.
411 {
413 = std::make_unique<WTableView>();
414
415 tableView->setAlternatingRowColors(
true);
416
418 tableView->setSelectionMode(SelectionMode::Extended);
420
427
428 auto delegate = std::make_shared<WItemDelegate>();
432
433 tableView->setColumnAlignment(3, AlignmentFlag::Right);
434 tableView->setColumnAlignment(4, AlignmentFlag::Right);
435 tableView->setColumnAlignment(5, AlignmentFlag::Right);
436
437 tableView->sortByColumn(1, SortOrder::Ascending);
438
440 this, std::placeholders::_1));
441
443
445 }
static WString dateDisplayFormat
Date display format.
void editFile(const WModelIndex &item)
Edit a particular row.
◆ folderChanged()
void TreeViewDragDrop::folderChanged |
( |
| ) |
|
|
inlineprivate |
Change the filter on the file view when the selected folder changes.
Definition at line 495 of file TreeViewDragDrop.C.
495 {
497 return;
498
500 cpp17::any
d =
selected.data(ItemDataRole::User);
501 if (cpp17::any_has_value(
d)) {
502 std::string
folder = cpp17::any_cast<std::string>(
d);
503
504
505
506
507
509 }
510 }
◆ folderView()
std::unique_ptr< WTreeView > TreeViewDragDrop::folderView |
( |
| ) |
|
|
inlineprivate |
Creates the folder WTreeView.
Definition at line 381 of file TreeViewDragDrop.C.
381 {
382 auto treeView = std::make_unique<FolderView>();
383
384
385
386
387
388
389
390
392 ("oncontextmenu",
393 "event.cancelBubble = true; event.returnValue = false; return false;");
395 treeView->resize(200, WLength::Auto);
396 treeView->setSelectionMode(SelectionMode::Single);
397 treeView->setEnabledDropLocations(DropLocation::OnItem);
401
403
405
407 }
void folderChanged()
Change the filter on the file view when the selected folder changes.
void showPopup(const WModelIndex &item, const WMouseEvent &event)
Show a popup for a folder item.
◆ pieChart()
std::unique_ptr< WWidget > TreeViewDragDrop::pieChart |
( |
| ) |
|
|
inlineprivate |
Creates the chart.
Definition at line 455 of file TreeViewDragDrop.C.
455 {
456 using namespace Chart;
457
458 auto chart = std::make_unique<WPieChart>();
459
461 chart->setTitle(
"File sizes");
462
463 chart->setLabelsColumn(1);
464 chart->setDataColumn(3);
465
466 chart->setPerspectiveEnabled(
true, 0.2);
467 chart->setDisplayLabels(LabelOption::Outside | LabelOption::TextLabel);
468
470 chart->resize(500, 200);
471 chart->setMargin(WLength::Auto, Side::Left | Side::Right);
472
473 auto w = std::make_unique<WContainerWidget>();
474 w->addWidget(std::move(
chart));
475 w->setStyleClass(
"about");
477 } else {
478 chart->setStyleClass(
"about");
479 return std::move(
chart);
480 }
481 }
◆ populateFiles()
void TreeViewDragDrop::populateFiles |
( |
| ) |
|
|
inlineprivate |
Populate the files model.
Data (and headers) is read from the CSV file data/files.csv. We add icons to the first column, resolve the folder id to the actual folder name, and configure item flags, and parse date values.
Definition at line 590 of file TreeViewDragDrop.C.
590 {
591 fileModel_->invisibleRootItem()->setRowCount(0);
592
594
596 throw std::runtime_error("Could not read: data/files.csv");
597
599
602 item->setFlags(item->flags() | ItemFlag::DragEnabled);
603 item->setIcon("icons/file.gif");
604
605 std::string
folderId = item->text().toUTF8();
606
607 item->setData(cpp17::any(
folderId), ItemDataRole::User);
609
613 }
614 }
void convertToDate(WStandardItem *item)
Convert a string to a date.
void convertToNumber(WStandardItem *item)
Convert a string to a number.
void readFromCsv(std::istream &f, std::shared_ptr< WAbstractItemModel > model, int numRows, bool firstLineIsHeaders)
◆ populateFolders()
void TreeViewDragDrop::populateFolders |
( |
| ) |
|
|
inlineprivate |
Populate the folders model.
Definition at line 632 of file TreeViewDragDrop.C.
632 {
633 std::unique_ptr<WStandardItem>
level1;
634
639
646
652
656
658 cpp17::any(std::string("SandBox")));
659 }
std::unique_ptr< WStandardItem > createFolderItem(const WString &location, const std::string &folderId=std::string())
Create a folder item.
◆ popupAction()
void TreeViewDragDrop::popupAction |
( |
| ) |
|
|
inlineprivate |
Process the result of the popup menu.
Definition at line 556 of file TreeViewDragDrop.C.
556 {
558
559
560
561
564
566 +
text +
"' is not implemented.",
567 Icon::None,
568 StandardButton::Ok);
572 } else {
574 }
575 }
void dialogDone()
Process the result of the message box.
◆ showPopup()
Show a popup for a folder item.
Definition at line 514 of file TreeViewDragDrop.C.
514 {
515 if (
event.button() == MouseButton::Right) {
516
519
521 popup_ = std::make_unique<WPopupMenu>();
522 popup_->addItem(
"icons/folder_new.gif",
"Create a New Folder");
523 popup_->addItem(
"Rename this Folder")->setCheckable(
true);
524 popup_->addItem(
"Delete this Folder");
526 popup_->addItem(
"Folder Details");
528 popup_->addItem(
"Application Inventory");
529 popup_->addItem(
"Hardware Inventory");
531
532 std::unique_ptr<WPopupMenu>
subMenu = std::make_unique<WPopupMenu>();
533 subMenu->addItem(
"Sub Item 1");
534 subMenu->addItem(
"Sub Item 2");
536
537
538
539
540
541
542
543
545 }
546
549 else
551 }
552 }
void popupAction()
Process the result of the popup menu.
◆ dialog_
◆ fileFilterModel_
◆ fileModel_
std::shared_ptr<WStandardItemModel> TreeViewDragDrop::fileModel_ |
|
private |
◆ fileView_
◆ folderModel_
std::shared_ptr<WStandardItemModel> TreeViewDragDrop::folderModel_ |
|
private |
◆ folderNameMap_
std::map<std::string, WString> TreeViewDragDrop::folderNameMap_ |
|
private |
◆ folderView_
WTreeView* TreeViewDragDrop::folderView_ |
|
private |
◆ popup_
std::unique_ptr<WPopupMenu> TreeViewDragDrop::popup_ |
|
private |
◆ popupActionBox_
std::unique_ptr<WMessageBox> TreeViewDragDrop::popupActionBox_ |
|
private |
The documentation for this class was generated from the following file: