Skip to content

Commit

Permalink
fman fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
psemiletov committed Apr 19, 2019
1 parent ba72102 commit ec23cf5
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 62 deletions.
100 changes: 50 additions & 50 deletions fman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void CFMan::dir_up()
{
if (dir.path() == "/")
return;

QString oldcurdir = dir.dirName();

dir.cdUp();
Expand All @@ -61,34 +61,34 @@ void CFMan::nav (const QString &path)
setModel (0);

QDir::SortFlags sort_flags = 0;

if (sort_order == Qt::DescendingOrder)
sort_flags |= QDir::Reversed;

if (sort_mode == 0)
sort_flags |= QDir::Name;

if (sort_mode == 1)
sort_flags |= QDir::Size;

if (sort_mode == 2)
sort_flags |= QDir::Time;

sort_flags |= QDir::DirsFirst;
sort_flags |= QDir::IgnoreCase;
sort_flags |= QDir::LocaleAware;


mymodel->removeRows (0, mymodel->rowCount());

QFileInfoList lst = dir.entryInfoList (QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot |
QDir::Files | QDir::Drives,
QDir::Files | QDir::Drives,
sort_flags);



/*QFileInfoList lst = dir.entryInfoList (QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot |
QDir::Files | QDir::Drives,
QDir::Files | QDir::Drives,
QDir::Name |
QDir::DirsFirst | QDir::IgnoreCase | QDir::LocaleAware);
Expand All @@ -105,10 +105,10 @@ QDir::DirsLast 0x20 Put the files first, then the directories.
QDir::Reversed 0x08 Reverse the sort order.
QDir::IgnoreCase 0x10 Sort case-insensitively.
QDir::LocaleAware 0x40 Sort items appropriately using the current locale settings.
*/

#if defined(Q_OS_WIN) || defined(Q_OS_OS2)

if (path != "/")
Expand All @@ -123,7 +123,7 @@ QDir::LocaleAware 0x40 Sort items appropriately using the current locale settin

foreach (QFileInfo fi, lst)
add_entry (fi);

setModel (mymodel);
connect (selectionModel(), SIGNAL(currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT(cb_fman_currentChanged (const QModelIndex &, const QModelIndex &)));
emit dir_changed (path);
Expand All @@ -144,20 +144,20 @@ const QModelIndex CFMan::index_from_name (const QString &name)
void CFMan::tv_activated (const QModelIndex &index)
{
QString item_string = index.data().toString();

QString dpath = dir.path();

if (dpath.size() > 1)
if (dpath.endsWith("/") || dpath.endsWith("\\"))
dpath.truncate(dpath.size() - 1);

QString full_path;

if (dpath == "/")
full_path = "/" + item_string;
else
full_path = dpath + "/" + item_string;

if (item_string == ".." && dir.path() != "/")
{
dir_up();
Expand Down Expand Up @@ -228,52 +228,52 @@ void CFMan::append_dot_entry (const QString &fname)

void CFMan::header_view_sortIndicatorChanged (int logicalIndex, Qt::SortOrder order)
{
// qDebug() << "header col = " << logicalIndex << " order = " << order;
// qDebug() << "header col = " << logicalIndex << " order = " << order;
sort_order = order;
sort_mode = logicalIndex;

settings->setValue ("fman_sort_mode", sort_mode);
settings->setValue ("fman_sort_order", sort_order);
refresh();

refresh();
}


CFMan::CFMan (QWidget *parent): QTreeView (parent)
{
sort_mode = settings->value ("fman_sort_mode", 0).toInt();
sort_order = Qt::SortOrder (settings->value ("fman_sort_order", 0).toInt());
sort_mode = settings->value ("fman_sort_mode", 0).toInt();
sort_order = Qt::SortOrder (settings->value ("fman_sort_order", 0).toInt());

mymodel = new QStandardItemModel (0, 3, parent);

mymodel->setHeaderData (0, Qt::Horizontal, QObject::tr ("Name"));
mymodel->setHeaderData (1, Qt::Horizontal, QObject::tr ("Size"));
mymodel->setHeaderData (2, Qt::Horizontal, QObject::tr ("Modified at"));

setRootIsDecorated (false);
setAlternatingRowColors (true);
setAllColumnsShowFocus (true);
setModel (mymodel);
setDragEnabled (true);


#if QT_VERSION >= 0x050000

header()->setSectionResizeMode (QHeaderView::ResizeToContents);
header()->setSectionsClickable (true);

#else

header()->setResizeMode (QHeaderView::ResizeToContents);
header()->setClickable (true);

#endif

header()->setSortIndicator (sort_mode, sort_order);
header()->setSortIndicatorShown (true);
header()->setSortIndicatorShown (true);

connect (header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(header_view_sortIndicatorChanged(int, Qt::SortOrder)));

header()->setStretchLastSection (false);

setSelectionMode (QAbstractItemView::ExtendedSelection);
Expand Down Expand Up @@ -325,11 +325,11 @@ QStringList CFMan::get_sel_fnames()
foreach (QModelIndex index, il)
{
QString item_string = index.data().toString();
if (item_string != "..")
if (item_string != "..")
{
QString full_path = dir.path() + "/" + item_string;
li.append (full_path);
}
}
}

return li;
Expand All @@ -341,10 +341,10 @@ void CFMan::refresh()
QString current;

if (selectionModel()->hasSelection())
{
{
QModelIndex index = selectionModel()->currentIndex();
current = index.data().toString();
}
}

nav (dir.path());

Expand Down Expand Up @@ -376,29 +376,29 @@ int CFMan::get_sel_index()

void CFMan::mouseMoveEvent (QMouseEvent *event)
{
if (! (event->buttons() & Qt::LeftButton))
if (! (event->buttons() & Qt::LeftButton))
return;

QStringList l = get_sel_fnames();
if (l.size() < 1)
return;

QDrag *drag = new QDrag (this);
QMimeData *mimeData = new QMimeData;

QList <QUrl> list;

foreach (QString fn, l)
list.append (QUrl::fromLocalFile (fn));
list.append (QUrl::fromLocalFile (fn));

mimeData->setUrls (list);
mimeData->setUrls (list);
drag->setMimeData (mimeData);
if (drag->exec (Qt::CopyAction |

if (drag->exec (Qt::CopyAction |
Qt::MoveAction |
Qt::LinkAction) == Qt::MoveAction)
refresh();

event->accept();
}

Expand Down Expand Up @@ -433,15 +433,15 @@ void CFMan::keyPressEvent (QKeyEvent *event)
return;
}


if (event->key() == Qt::Key_Backspace)
{
dir_up();
event->accept();
return;
}


if (event->key() == Qt::Key_Return)
{
tv_activated (currentIndex());
Expand All @@ -462,7 +462,7 @@ void CFMan::keyPressEvent (QKeyEvent *event)
event->accept();
return;
}


if (event->key() == Qt::Key_Down)
{
Expand Down Expand Up @@ -529,12 +529,12 @@ void CFMan::drawRow (QPainter *painter, const QStyleOptionViewItem &option, cons
o.rect = option.rect.adjusted(1,1,-1,-1);
o.state |= QStyle::State_KeyboardFocusChange;
o.state |= QStyle::State_Item;

//o.backgroundColor = palette().color(QPalette::Background);
//o.backgroundColor = QColor ("red");

QApplication::style()->drawPrimitive (QStyle::PE_FrameFocusRect, &o, painter);

QRect r = option.rect.adjusted (1, 1, -1,-1);
painter->drawRect (r);
}
Expand Down
33 changes: 21 additions & 12 deletions rvln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,18 +823,27 @@ void rvln::open()
if (! settings->value ("use_trad_dialogs", "0").toBool())
{
CDocument *d = documents->get_current();

if (d)
{
if (file_exists (d->file_name))
fman->nav (get_file_path (d->file_name));
fman->nav (get_file_path (d->file_name));
else
fman->nav (dir_last);
if (file_exists (dir_last))
fman->nav (dir_last);
else
fman->nav (QDir::homePath());
}
else
fman->nav (dir_last);
if (file_exists (dir_last))
fman->nav (dir_last);
else
fman->nav (QDir::homePath());

main_tab_widget->setCurrentIndex (idx_tab_fman);
fm_entry_mode = FM_ENTRY_MODE_OPEN;
main_tab_widget->setCurrentIndex (idx_tab_fman);
fm_entry_mode = FM_ENTRY_MODE_OPEN;

return;
}
Expand Down Expand Up @@ -10654,16 +10663,16 @@ void rvln::logmemo_double_click (const QString &txt)
if (! d)
return;

QTextCursor cur = d->textEdit->textCursor();
if (cur.isNull())
return;
QTextCursor cur = d->textEdit->textCursor();
if (cur.isNull())
return;

cur.movePosition (QTextCursor::Start);
cur.movePosition (QTextCursor::Down, QTextCursor::MoveAnchor, source_line.toInt() - 1);
cur.movePosition (QTextCursor::Right, QTextCursor::MoveAnchor, source_col.toInt() - 1);
cur.select (QTextCursor::WordUnderCursor);
d->textEdit->setTextCursor (cur);
d->textEdit->setFocus();
cur.movePosition (QTextCursor::Start);
cur.movePosition (QTextCursor::Down, QTextCursor::MoveAnchor, source_line.toInt() - 1);
cur.movePosition (QTextCursor::Right, QTextCursor::MoveAnchor, source_col.toInt() - 1);
cur.select (QTextCursor::WordUnderCursor);
d->textEdit->setTextCursor (cur);
d->textEdit->setFocus();
}


Expand Down

0 comments on commit ec23cf5

Please sign in to comment.