| ︙ | | |
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
|
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
+
+
+
-
+
|
fullpath += '/';
}
}
//------------------------------------------------------------------------------
void MainWindow::updateDirView()
{
if(viewMode == VIEWMODE_TREE)
{
// Directory View
repoDirModel.clear();
QStandardItem *root = new QStandardItem(QIcon(":icons/icons/My Documents-01.png"), projectName);
root->setData(""); // Empty Path
root->setEditable(false);
QString aa = root->data().toString();
repoDirModel.appendRow(root);
for(pathset_t::iterator it = pathSet.begin(); it!=pathSet.end(); ++it)
{
const QString &dir = *it;
if(dir.isEmpty())
continue;
if(viewMode != VIEWMODE_TREE)
return;
// Directory View
repoDirModel.clear();
QStandardItem *root = new QStandardItem(QIcon(":icons/icons/My Documents-01.png"), projectName);
root->setData(""); // Empty Path
root->setEditable(false);
QString aa = root->data().toString();
repoDirModel.appendRow(root);
for(stringset_t::iterator it = pathSet.begin(); it!=pathSet.end(); ++it)
{
const QString &dir = *it;
if(dir.isEmpty())
continue;
addPathToTree(*root, dir);
}
ui->treeView->expandToDepth(0);
addPathToTree(*root, dir);
}
ui->treeView->expandToDepth(0);
}
ui->treeView->sortByColumn(0, Qt::AscendingOrder);
}
//------------------------------------------------------------------------------
void MainWindow::updateFileView()
{
// File View
// Clear all rows (except header)
repoFileModel.clear();
QStringList header;
header << tr("S") << tr("File") << tr("Ext") << tr("Modified");
bool multiple_dirs = selectedDirs.count()>1;
if(viewMode==VIEWMODE_LIST)
if(viewMode==VIEWMODE_LIST || multiple_dirs)
header << tr("Path");
repoFileModel.setHorizontalHeaderLabels(header);
struct { RepoFile::EntryType type; const char *tag; const char *tooltip; const char *icon; }
stats[] =
{
|
| ︙ | | |
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
|
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
|
-
+
|
size_t item_id=0;
for(filemap_t::iterator it = workspaceFiles.begin(); it!=workspaceFiles.end(); ++it)
{
const RepoFile &e = *it.value();
QString path = e.getPath();
// In Tree mode, filter all items not included in the current dir
if(viewMode==VIEWMODE_TREE && path != viewDir)
if(viewMode==VIEWMODE_TREE && !selectedDirs.contains(path))
continue;
// Status Column
const char *tag = "?"; // Default Tag
const char *tooltip = "Unknown";
const char *status_icon= ":icons/icons/Button Blank Gray-01.png"; // Default icon
|
| ︙ | | |
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
|
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
|
-
+
|
QStandardItem *status = new QStandardItem(QIcon(status_icon), tag);
status->setToolTip(tooltip);
repoFileModel.setItem(item_id, COLUMN_STATUS, status);
QFileInfo finfo = e.getFileInfo();
QStandardItem *filename_item = 0;
if(viewMode==VIEWMODE_LIST)
if(viewMode==VIEWMODE_LIST || multiple_dirs)
{
repoFileModel.setItem(item_id, COLUMN_PATH, new QStandardItem(path));
filename_item = new QStandardItem(e.getFilePath());
}
else // In Tree mode the path is implicit so the file name is enough
filename_item = new QStandardItem(e.getFilename());
|
| ︙ | | |
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
|
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
|
-
+
-
+
|
if(QApplication::focusWidget() == ui->tableView)
getFileViewSelection(filenames, includeMask, allIfEmpty);
else if(QApplication::focusWidget() == ui->treeView)
getDirViewSelection(filenames, includeMask, allIfEmpty);
}
//------------------------------------------------------------------------------
void MainWindow::getSelectionPaths(pathset_t &paths)
void MainWindow::getSelectionPaths(stringset_t &paths)
{
// Determine the directories selected
QModelIndexList selection = ui->treeView->selectionModel()->selectedIndexes();
for(QModelIndexList::iterator mi_it = selection.begin(); mi_it!=selection.end(); ++mi_it)
{
const QModelIndex &mi = *mi_it;
QVariant data = repoDirModel.data(mi, REPODIRMODEL_ROLE_PATH);
paths.insert(data.toString());
}
}
//------------------------------------------------------------------------------
void MainWindow::getDirViewSelection(QStringList &filenames, int includeMask, bool allIfEmpty)
{
// Determine the directories selected
pathset_t paths;
stringset_t paths;
QModelIndexList selection = ui->treeView->selectionModel()->selectedIndexes();
if(!(selection.empty() && allIfEmpty))
{
getSelectionPaths(paths);
}
|
| ︙ | | |
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
|
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
|
-
+
-
|
bool include = true;
// If we have a limited set of paths to filter, check them
if(!paths.empty())
include = false;
for(pathset_t::iterator p_it=paths.begin(); p_it!=paths.end(); ++p_it)
for(stringset_t::iterator p_it=paths.begin(); p_it!=paths.end(); ++p_it)
{
const QString &path = *p_it;
// An empty path is the root folder, so it includes all files
// If the file's path starts with this, we include id
if(path.isEmpty() || e.getPath().indexOf(path)==0)
{
include = true;
break;
}
}
if(!include)
continue;
filenames.append(e.getFilePath());
}
qDebug() << filenames;
}
//------------------------------------------------------------------------------
void MainWindow::getFileViewSelection(QStringList &filenames, int includeMask, bool allIfEmpty)
{
QModelIndexList selection = ui->tableView->selectionModel()->selectedIndexes();
if(selection.empty() && allIfEmpty)
|
| ︙ | | |
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
|
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
|
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
|
//------------------------------------------------------------------------------
QString MainWindow::getFossilHttpAddress()
{
return "http://127.0.0.1:"+fossilUIPort;
}
//------------------------------------------------------------------------------
void MainWindow::on_treeView_selectionChanged(const QItemSelection &selected, const QItemSelection &/*deselected*/)
void MainWindow::on_treeView_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
{
selectedDirs.clear();
if(selected.indexes().count()!=1)
return;
QModelIndex index = selected.indexes().at(0);
viewDir = repoDirModel.data(index, REPODIRMODEL_ROLE_PATH).toString();
setStatus(viewDir);
QModelIndexList selection = ui->treeView->selectionModel()->selectedIndexes();
int num_selected = selection.count();
for(int i=0; i<num_selected; ++i)
{
QModelIndex index = selection.at(i);
QString dir = repoDirModel.data(index, REPODIRMODEL_ROLE_PATH).toString();
selectedDirs.insert(dir);
}
updateFileView();
}
//------------------------------------------------------------------------------
void MainWindow::on_actionOpenFolder_triggered()
{
const QItemSelection &selection = ui->treeView->selectionModel()->selection();
|
| ︙ | | |
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
|
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
|
-
+
|
QUrl url = QUrl::fromLocalFile(target);
QDesktopServices::openUrl(url);
}
//------------------------------------------------------------------------------
void MainWindow::on_actionRenameFolder_triggered()
{
pathset_t paths;
stringset_t paths;
getSelectionPaths(paths);
if(paths.size()!=1)
return;
QString old_path = *paths.begin();
|
| ︙ | | |